Skip to content

Instantly share code, notes, and snippets.

@kquick
Created December 10, 2020 00:15
Show Gist options
  • Save kquick/6e4e507f866510bfe6267606edca41f3 to your computer and use it in GitHub Desktop.
Save kquick/6e4e507f866510bfe6267606edca41f3 to your computer and use it in GitHub Desktop.
.file "saturate_add-good.c"
.text
.globl saturate_add
.type saturate_add, @function
saturate_add:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movq %rdi, -24(%rbp)
movq %rsi, -32(%rbp)
movq -24(%rbp), %rdx
movq -32(%rbp), %rax
addq %rdx, %rax
movq %rax, -8(%rbp)
movq -8(%rbp), %rax
cmpq -24(%rbp), %rax
jl .L2
movq -8(%rbp), %rax
cmpq -32(%rbp), %rax
jge .L3
.L2:
movabsq $9223372036854775807, %rax
movq %rax, -8(%rbp)
.L3:
movq -8(%rbp), %rax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size saturate_add, .-saturate_add
.globl _start
.type _start, @function
_start:
.LFB1:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl $6, %esi
movl $5, %edi
call saturate_add
movq %rax, -8(%rbp)
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE1:
.size _start, .-_start
.ident "GCC: (Ubuntu 7.3.0-16ubuntu3) 7.3.0"
.section .note.GNU-stack,"",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment