Created
May 12, 2024 18:29
-
-
Save doug65536/994f309a11f2d91eb29d6a09838086bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Entering scope (function_definiton) | |
# Exiting scope (function_definition) | |
# Entering scope (function_definiton) | |
# Exiting scope (function_definition) | |
# Entering scope (function_definiton) | |
# Exiting scope (function_definition) | |
# Entering scope (function_definiton) | |
# Exiting scope (function_definition) | |
# Entering scope (function_definiton) | |
# void eratosthenes(int ) | |
.text | |
.global eratosthenes | |
.type eratosthenes,@function | |
eratosthenes: | |
.file 1 "test/simple/eratosthenes.c" | |
.loc 1 10 18 | |
.cfi_startproc | |
push %rbp | |
.cfi_adjust_cfa_offset 8 | |
.cfi_offset rbp,-16 | |
mov %rsp,%rbp | |
.cfi_def_cfa rbp,16 | |
add $ -32,%rsp | |
# Save n parameter | |
mov %edi,-4(%rbp) | |
# Entering scope (scoped_block) | |
# Variable declaration: unsigned char *prime | |
.loc 1 15 39 | |
# Allocated rax for init#1 | |
# used registers: rax | |
mov -4(%rbp),%edi # Load from int n | |
# Allocated rcx for +#4 | |
# used registers: rax, rcx | |
mov $ 1,%ecx # Load constant | |
add %ecx,%edi | |
# Freed rcx +#4 | |
# used registers: rax | |
call malloc | |
mov %rax,-16(%rbp) # Initialize unsigned char *prime | |
# Freed rax init#1 | |
# used registers: <none> | |
# Entering scope (forloop_outside) | |
.loc 1 17 20 | |
# Variable declaration: int i | |
# Assign constant to i | |
movl $ 0,-20(%rbp) | |
# for loop top label forr#5 | |
.L_for_top_1: | |
# Allocated eax for cmpj#6 | |
# used registers: rax | |
# Allocated ecx for cmpj#6 | |
# used registers: rax, rcx | |
mov -20(%rbp),%eax # Load from int i | |
mov -4(%rbp),%ecx # Load from int n | |
cmp %ecx,%eax | |
jnl .L_for_break_3 | |
# Freed rax cmpj#6 | |
# used registers: rcx | |
# Freed rcx cmpj#6 | |
# used registers: <none> | |
.L_for_body_2: | |
.loc 1 18 22 | |
# For loop body | |
# Allocated rax for =#7 | |
# used registers: rax | |
# Allocated cl for =#8 | |
# used registers: rax, rcx | |
mov $ 1,%ecx # Load constant | |
# Preparing value to store | |
mov -16(%rbp),%rax # Load from unsigned char *prime | |
# Allocated rsi for +#11 | |
# used registers: rax, rcx, rsi | |
mov -20(%rbp),%esi # Load from int i | |
movslq %esi,%rsi | |
add %rsi,%rax | |
# Freed rsi +#11 | |
# used registers: rax, rcx | |
# Deref (store) 1 bytes: (prime + i) | |
mov %cl,(%rax) | |
# Freed rcx =#8 | |
# used registers: rax | |
# Freed rax =#7 | |
# used registers: <none> | |
# continue label forr#5 | |
.L_for_continue_4: | |
.loc 1 17 32 | |
# for loop increment forr#5 | |
incl -20(%rbp) # Increment int i | |
jmp .L_for_top_1 | |
# End of for loop forr#5 | |
.L_for_break_3: | |
# Exiting scope (forloop_outside) | |
# Entering scope (forloop_outside) | |
.loc 1 20 20 | |
# Variable declaration: int p | |
# Assign constant to p | |
movl $ 2,-24(%rbp) | |
# for loop top label forr#12 | |
.L_for_top_5: | |
# Allocated eax for cmpj#13 | |
# used registers: rax | |
# Allocated ecx for cmpj#13 | |
# used registers: rax, rcx | |
mov -24(%rbp),%eax # Load from int p | |
# Allocated rsi for *#15 | |
# used registers: rax, rcx, rsi | |
mov -24(%rbp),%esi # Load from int p | |
imul %esi,%eax | |
# Freed rsi *#15 | |
# used registers: rax, rcx | |
mov -4(%rbp),%ecx # Load from int n | |
cmp %ecx,%eax | |
jnle .L_for_break_7 | |
# Freed rax cmpj#13 | |
# used registers: rcx | |
# Freed rcx cmpj#13 | |
# used registers: <none> | |
.L_for_body_6: | |
.loc 1 35 6 | |
# For loop body | |
# Entering scope (scoped_block) | |
.loc 1 23 21 | |
# Allocated rax for if_els#16 | |
# used registers: rax | |
# Preparing pointer for deref (load) | |
mov -16(%rbp),%rax # Load from unsigned char *prime | |
# Allocated rcx for +#19 | |
# used registers: rax, rcx | |
mov -24(%rbp),%ecx # Load from int p | |
movslq %ecx,%rcx | |
add %rcx,%rax | |
# Freed rcx +#19 | |
# used registers: rax | |
# Deref (load) 1 bytes: (prime + p) | |
mov (%rax),%al | |
test %al,%al | |
jz .L_endif_10 | |
# Freed rax if_els#16 | |
# used registers: <none> | |
.loc 1 34 10 | |
# Entering scope (scoped_block) | |
# Entering scope (forloop_outside) | |
.loc 1 29 32 | |
# Variable declaration: int i | |
# Allocated rax for init#21 | |
# used registers: rax | |
mov -24(%rbp),%eax # Load from int p | |
# Allocated rcx for *#23 | |
# used registers: rax, rcx | |
mov -24(%rbp),%ecx # Load from int p | |
imul %ecx,%eax | |
# Freed rcx *#23 | |
# used registers: rax | |
mov %eax,-28(%rbp) # Initialize int i | |
# Freed rax init#21 | |
# used registers: <none> | |
# for loop top label forr#20 | |
.L_for_top_11: | |
# Allocated eax for cmpj#24 | |
# used registers: rax | |
# Allocated ecx for cmpj#24 | |
# used registers: rax, rcx | |
mov -28(%rbp),%eax # Load from int i | |
mov -4(%rbp),%ecx # Load from int n | |
cmp %ecx,%eax | |
jnle .L_for_break_13 | |
# Freed rax cmpj#24 | |
# used registers: rcx | |
# Freed rcx cmpj#24 | |
# used registers: <none> | |
.L_for_body_12: | |
.loc 1 32 14 | |
# For loop body | |
# Entering scope (scoped_block) | |
.loc 1 30 30 | |
# Allocated rax for =#25 | |
# used registers: rax | |
# Allocated cl for =#26 | |
# used registers: rax, rcx | |
xor %ecx,%ecx # Load zero | |
# Preparing value to store | |
mov -16(%rbp),%rax # Load from unsigned char *prime | |
# Allocated rsi for +#29 | |
# used registers: rax, rcx, rsi | |
mov -28(%rbp),%esi # Load from int i | |
movslq %esi,%rsi | |
add %rsi,%rax | |
# Freed rsi +#29 | |
# used registers: rax, rcx | |
# Deref (store) 1 bytes: (prime + i) | |
mov %cl,(%rax) | |
# Freed rcx =#26 | |
# used registers: rax | |
# Freed rax =#25 | |
# used registers: <none> | |
# Exiting scope (scoped_block) | |
# continue label forr#20 | |
.L_for_continue_14: | |
.loc 1 29 51 | |
# for loop increment forr#20 | |
# Allocated rax for =#30 | |
# used registers: rax | |
# Allocated ecx for =#31 | |
# used registers: rax, rcx | |
mov -28(%rbp),%ecx # Load from int i | |
# Allocated rsi for +#33 | |
# used registers: rax, rcx, rsi | |
mov -24(%rbp),%esi # Load from int p | |
add %esi,%ecx | |
# Freed rsi +#33 | |
# used registers: rax, rcx | |
mov %ecx,-28(%rbp) # Store to int i | |
# Freed rcx =#31 | |
# used registers: rax | |
# Freed rax =#30 | |
# used registers: <none> | |
jmp .L_for_top_11 | |
# End of for loop forr#20 | |
.L_for_break_13: | |
# Exiting scope (forloop_outside) | |
# Exiting scope (scoped_block) | |
.L_endif_10: | |
# Exiting scope (scoped_block) | |
# continue label forr#12 | |
.L_for_continue_8: | |
.loc 1 20 36 | |
# for loop increment forr#12 | |
# Allocated rax for -#34 | |
# used registers: rax | |
incl -24(%rbp) # Increment int p | |
# Allocated rcx for -#35 | |
# used registers: rax, rcx | |
mov $ 1,%ecx # Load constant | |
sub %ecx,%eax | |
# Freed rcx -#35 | |
# used registers: rax | |
# Freed rax -#34 | |
# used registers: <none> | |
jmp .L_for_top_5 | |
# End of for loop forr#12 | |
.L_for_break_7: | |
# Exiting scope (forloop_outside) | |
# Entering scope (forloop_outside) | |
.loc 1 39 20 | |
# Variable declaration: int p | |
# Assign constant to p | |
movl $ 2,-28(%rbp) | |
# for loop top label forr#36 | |
.L_for_top_15: | |
# Allocated eax for cmpj#37 | |
# used registers: rax | |
# Allocated ecx for cmpj#37 | |
# used registers: rax, rcx | |
mov -28(%rbp),%eax # Load from int p | |
mov -4(%rbp),%ecx # Load from int n | |
cmp %ecx,%eax | |
jnle .L_for_break_17 | |
# Freed rax cmpj#37 | |
# used registers: rcx | |
# Freed rcx cmpj#37 | |
# used registers: <none> | |
.L_for_body_16: | |
.loc 1 42 11 | |
# For loop body | |
.loc 1 40 21 | |
# Allocated rax for if_els#38 | |
# used registers: rax | |
# Preparing pointer for deref (load) | |
mov -16(%rbp),%rax # Load from unsigned char *prime | |
# Allocated rcx for +#41 | |
# used registers: rax, rcx | |
mov -28(%rbp),%ecx # Load from int p | |
movslq %ecx,%rcx | |
add %rcx,%rax | |
# Freed rcx +#41 | |
# used registers: rax | |
# Deref (load) 1 bytes: (prime + p) | |
mov (%rax),%al | |
test %al,%al | |
jz .L_endif_20 | |
# Freed rax if_els#38 | |
# used registers: <none> | |
.loc 1 41 30 | |
# Allocated rax for call#42 | |
# used registers: rax | |
mov -28(%rbp),%esi # Load from int p | |
lea .Lu8str0(%rip),%rdi # String "%d " | |
call printf | |
# Freed rax call#42 | |
# used registers: <none> | |
.L_endif_20: | |
# continue label forr#36 | |
.L_for_continue_18: | |
.loc 1 39 32 | |
# for loop increment forr#36 | |
# Allocated rax for -#43 | |
# used registers: rax | |
incl -28(%rbp) # Increment int p | |
# Allocated rcx for -#44 | |
# used registers: rax, rcx | |
mov $ 1,%ecx # Load constant | |
sub %ecx,%eax | |
# Freed rcx -#44 | |
# used registers: rax | |
# Freed rax -#43 | |
# used registers: <none> | |
jmp .L_for_top_15 | |
# End of for loop forr#36 | |
.L_for_break_17: | |
# Exiting scope (forloop_outside) | |
.loc 1 42 17 | |
# Allocated rax for call#45 | |
# used registers: rax | |
lea .Lu8str1(%rip),%rdi # String "\n" | |
call printf | |
# Freed rax call#45 | |
# used registers: <none> | |
.loc 1 45 16 | |
# Allocated rax for call#46 | |
# used registers: rax | |
mov -16(%rbp),%rdi # Load from unsigned char *prime | |
call free | |
# Freed rax call#46 | |
# used registers: <none> | |
# Exiting scope (scoped_block) | |
leave | |
.cfi_def_cfa rsp,8 | |
ret | |
.L_eratosthenes_end_21: | |
.size eratosthenes,.L_eratosthenes_end_21-eratosthenes | |
.cfi_endproc | |
# Exiting scope (function_definition) | |
# Entering scope (function_definiton) | |
# int main(int , char **) | |
.text | |
.global main | |
.type main,@function | |
main: | |
.loc 1 51 9 | |
.cfi_startproc | |
push %rbp | |
.cfi_adjust_cfa_offset 8 | |
.cfi_offset rbp,-16 | |
mov %rsp,%rbp | |
.cfi_def_cfa rbp,16 | |
add $ -32,%rsp | |
# Save argc parameter | |
mov %edi,-4(%rbp) | |
# Save argv parameter | |
mov %rsi,-16(%rbp) | |
# Entering scope (scoped_block) | |
# Variable declaration: int n | |
.loc 1 53 13 | |
# Assign constant to n | |
movl $ 30,-20(%rbp) | |
.loc 1 54 18 | |
# Allocated rax for if_els#47 | |
# used registers: rax | |
mov -4(%rbp),%eax # Load from int argc | |
# Allocated rcx for >#49 | |
# used registers: rax, rcx | |
mov $ 1,%ecx # Load constant | |
cmp %ecx,%eax | |
setg %al | |
# Freed rcx >#49 | |
# used registers: rax | |
test %al,%al | |
jz .L_endif_23 | |
# Freed rax if_els#47 | |
# used registers: <none> | |
.loc 1 55 27 | |
# Allocated rax for =#50 | |
# used registers: rax | |
# Allocated ecx for =#51 | |
# used registers: rax, rcx | |
# Preparing pointer for deref (load) | |
mov -16(%rbp),%rdi # Load from char **argv | |
# Allocated rsi for +#55 | |
# used registers: rax, rcx, rsi | |
mov $ 1,%esi # Load constant | |
movslq %esi,%rsi | |
shl $ 3,%rsi # Times 8 | |
add %rsi,%rdi | |
# Freed rsi +#55 | |
# used registers: rax, rcx | |
# Deref (load) 8 bytes: (argv + 1) | |
mov (%rdi),%rdi | |
call atoi | |
mov %eax,%ecx | |
mov %ecx,-20(%rbp) # Store to int n | |
# Freed rcx =#51 | |
# used registers: rax | |
# Freed rax =#50 | |
# used registers: <none> | |
.L_endif_23: | |
.loc 1 57 45 | |
# Allocated rax for call#56 | |
# used registers: rax | |
mov -20(%rbp),%esi # Load from int n | |
lea .Lu8str2(%rip),%rdi # String "Following are the prime numbers smaller... | |
call printf | |
# Freed rax call#56 | |
# used registers: <none> | |
.loc 1 58 20 | |
# Allocated rax for call#57 | |
# used registers: rax | |
mov -20(%rbp),%edi # Load from int n | |
call eratosthenes | |
# Freed rax call#57 | |
# used registers: <none> | |
.loc 1 59 12 | |
xor %eax,%eax # Load zero | |
.L_return_24: | |
.cfi_remember_state | |
leave | |
.cfi_def_cfa rsp,8 | |
ret | |
.cfi_restore_state | |
# Exiting scope (scoped_block) | |
ud2 | |
.L_main_end_25: | |
.size main,.L_main_end_25-main | |
.cfi_endproc | |
# Exiting scope (function_definition) | |
# | |
# String literals | |
.section .rodata,"a" | |
.Lu8str1: | |
.byte 0x0a, 0x00 # |..| | |
.Lu8str0: | |
.byte 0x25, 0x64, 0x20, 0x00 # |%d .| | |
.Lu8str2: | |
.byte 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e # |Followin| | |
.byte 0x67, 0x20, 0x61, 0x72, 0x65, 0x20, 0x74, 0x68 # |g are th| | |
.byte 0x65, 0x20, 0x70, 0x72, 0x69, 0x6d, 0x65, 0x20 # |e prime | | |
.byte 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x20 # |numbers | | |
.byte 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x20 # |smaller | | |
.byte 0x74, 0x68, 0x61, 0x6e, 0x20, 0x6f, 0x72, 0x20 # |than or | | |
.byte 0x65, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x74, 0x6f # |equal to| | |
.byte 0x20, 0x25, 0x64, 0x0a, 0x00 # | %d..| | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment