Last active
October 16, 2021 00:20
-
-
Save mrowe/7e1e2b12a98bf8d77ea66b431a67e398 to your computer and use it in GitHub Desktop.
clang compiled to ARM assembler
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
.section __TEXT,__text,regular,pure_instructions | |
.build_version macos, 11, 0 sdk_version 11, 3 | |
.globl _main ; -- Begin function main | |
.p2align 2 | |
_main: ; @main | |
Lfunc_begin0: | |
.file 1 "/Users/mrowe/src" "better.c" | |
.loc 1 4 0 ; better.c:4:0 | |
.cfi_startproc | |
; %bb.0: | |
sub sp, sp, #48 ; =48 | |
stp x29, x30, [sp, #32] ; 16-byte Folded Spill | |
add x29, sp, #32 ; =32 | |
.cfi_def_cfa w29, 16 | |
.cfi_offset w30, -8 | |
.cfi_offset w29, -16 | |
stur wzr, [x29, #-4] | |
stur w0, [x29, #-8] | |
str x1, [sp, #16] | |
Ltmp0: | |
.loc 1 0 0 prologue_end ; better.c:0:0 | |
adrp x0, l_.str@PAGE | |
add x0, x0, l_.str@PAGEOFF | |
.loc 1 6 3 ; better.c:6:3 | |
bl _printf | |
mov w8, #1 | |
.loc 1 8 7 ; better.c:8:7 | |
str w8, [sp, #12] | |
.loc 1 9 21 ; better.c:9:21 | |
ldr w9, [sp, #12] | |
.loc 1 9 26 is_stmt 0 ; better.c:9:26 | |
ldr w10, [sp, #12] | |
add w11, w10, #1 ; =1 | |
str w11, [sp, #12] | |
.loc 1 9 23 ; better.c:9:23 | |
subs w9, w9, w10 | |
cset w10, gt | |
.loc 1 9 8 ; better.c:9:8 | |
and w8, w10, w8 | |
strb w8, [sp, #11] | |
Ltmp1: | |
.loc 1 11 6 is_stmt 1 ; better.c:11:6 | |
ldrb w8, [sp, #11] | |
Ltmp2: | |
.loc 1 11 6 is_stmt 0 ; better.c:11:6 | |
tbnz w8, #0, LBB0_1 | |
b LBB0_2 | |
LBB0_1: | |
Ltmp3: | |
.loc 1 0 0 ; better.c:0:0 | |
adrp x0, l_.str.1@PAGE | |
add x0, x0, l_.str.1@PAGEOFF | |
.loc 1 12 5 is_stmt 1 ; better.c:12:5 | |
bl _printf | |
.loc 1 13 3 ; better.c:13:3 | |
b LBB0_3 | |
Ltmp4: | |
LBB0_2: | |
.loc 1 0 0 is_stmt 0 ; better.c:0:0 | |
adrp x0, l_.str.2@PAGE | |
add x0, x0, l_.str.2@PAGEOFF | |
.loc 1 14 5 is_stmt 1 ; better.c:14:5 | |
bl _printf | |
Ltmp5: | |
LBB0_3: | |
.loc 1 0 0 is_stmt 0 ; better.c:0:0 | |
adrp x0, l_.str.3@PAGE | |
add x0, x0, l_.str.3@PAGEOFF | |
.loc 1 17 3 is_stmt 1 ; better.c:17:3 | |
bl _printf | |
mov w8, #0 | |
.loc 1 19 3 ; better.c:19:3 | |
mov x0, x8 | |
ldp x29, x30, [sp, #32] ; 16-byte Folded Reload | |
add sp, sp, #48 ; =48 | |
ret | |
Ltmp6: | |
Lfunc_end0: | |
.cfi_endproc | |
; -- End function | |
.section __TEXT,__cstring,cstring_literals | |
l_.str: ; @.str | |
.asciz "Which is greater, C or C++?\nAnswer: " | |
l_.str.1: ; @.str.1 | |
.asciz "C" | |
l_.str.2: ; @.str.2 | |
.asciz "C++" | |
l_.str.3: ; @.str.3 | |
.asciz "\n" | |
.section __DWARF,__debug_abbrev,regular,debug | |
Lsection_abbrev: | |
.byte 1 ; Abbreviation Code | |
.byte 17 ; DW_TAG_compile_unit | |
.byte 1 ; DW_CHILDREN_yes | |
.byte 37 ; DW_AT_producer | |
.byte 14 ; DW_FORM_strp | |
.byte 19 ; DW_AT_language | |
.byte 5 ; DW_FORM_data2 | |
.byte 3 ; DW_AT_name | |
.byte 14 ; DW_FORM_strp | |
.ascii "\202|" ; DW_AT_LLVM_sysroot | |
.byte 14 ; DW_FORM_strp | |
.ascii "\357\177" ; DW_AT_APPLE_sdk | |
.byte 14 ; DW_FORM_strp | |
.byte 16 ; DW_AT_stmt_list | |
.byte 23 ; DW_FORM_sec_offset | |
.byte 27 ; DW_AT_comp_dir | |
.byte 14 ; DW_FORM_strp | |
.byte 17 ; DW_AT_low_pc | |
.byte 1 ; DW_FORM_addr | |
.byte 18 ; DW_AT_high_pc | |
.byte 6 ; DW_FORM_data4 | |
.byte 0 ; EOM(1) | |
.byte 0 ; EOM(2) | |
.byte 2 ; Abbreviation Code | |
.byte 46 ; DW_TAG_subprogram | |
.byte 1 ; DW_CHILDREN_yes | |
.byte 17 ; DW_AT_low_pc | |
.byte 1 ; DW_FORM_addr | |
.byte 18 ; DW_AT_high_pc | |
.byte 6 ; DW_FORM_data4 | |
.byte 64 ; DW_AT_frame_base | |
.byte 24 ; DW_FORM_exprloc | |
.byte 3 ; DW_AT_name | |
.byte 14 ; DW_FORM_strp | |
.byte 58 ; DW_AT_decl_file | |
.byte 11 ; DW_FORM_data1 | |
.byte 59 ; DW_AT_decl_line | |
.byte 11 ; DW_FORM_data1 | |
.byte 39 ; DW_AT_prototyped | |
.byte 25 ; DW_FORM_flag_present | |
.byte 73 ; DW_AT_type | |
.byte 19 ; DW_FORM_ref4 | |
.byte 63 ; DW_AT_external | |
.byte 25 ; DW_FORM_flag_present | |
.byte 0 ; EOM(1) | |
.byte 0 ; EOM(2) | |
.byte 3 ; Abbreviation Code | |
.byte 5 ; DW_TAG_formal_parameter | |
.byte 0 ; DW_CHILDREN_no | |
.byte 2 ; DW_AT_location | |
.byte 24 ; DW_FORM_exprloc | |
.byte 3 ; DW_AT_name | |
.byte 14 ; DW_FORM_strp | |
.byte 58 ; DW_AT_decl_file | |
.byte 11 ; DW_FORM_data1 | |
.byte 59 ; DW_AT_decl_line | |
.byte 11 ; DW_FORM_data1 | |
.byte 73 ; DW_AT_type | |
.byte 19 ; DW_FORM_ref4 | |
.byte 0 ; EOM(1) | |
.byte 0 ; EOM(2) | |
.byte 4 ; Abbreviation Code | |
.byte 52 ; DW_TAG_variable | |
.byte 0 ; DW_CHILDREN_no | |
.byte 2 ; DW_AT_location | |
.byte 24 ; DW_FORM_exprloc | |
.byte 3 ; DW_AT_name | |
.byte 14 ; DW_FORM_strp | |
.byte 58 ; DW_AT_decl_file | |
.byte 11 ; DW_FORM_data1 | |
.byte 59 ; DW_AT_decl_line | |
.byte 11 ; DW_FORM_data1 | |
.byte 73 ; DW_AT_type | |
.byte 19 ; DW_FORM_ref4 | |
.byte 0 ; EOM(1) | |
.byte 0 ; EOM(2) | |
.byte 5 ; Abbreviation Code | |
.byte 36 ; DW_TAG_base_type | |
.byte 0 ; DW_CHILDREN_no | |
.byte 3 ; DW_AT_name | |
.byte 14 ; DW_FORM_strp | |
.byte 62 ; DW_AT_encoding | |
.byte 11 ; DW_FORM_data1 | |
.byte 11 ; DW_AT_byte_size | |
.byte 11 ; DW_FORM_data1 | |
.byte 0 ; EOM(1) | |
.byte 0 ; EOM(2) | |
.byte 6 ; Abbreviation Code | |
.byte 15 ; DW_TAG_pointer_type | |
.byte 0 ; DW_CHILDREN_no | |
.byte 73 ; DW_AT_type | |
.byte 19 ; DW_FORM_ref4 | |
.byte 0 ; EOM(1) | |
.byte 0 ; EOM(2) | |
.byte 0 ; EOM(3) | |
.section __DWARF,__debug_info,regular,debug | |
Lsection_info: | |
Lcu_begin0: | |
.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ; Length of Unit | |
.long Lset0 | |
Ldebug_info_start0: | |
.short 4 ; DWARF version number | |
.set Lset1, Lsection_abbrev-Lsection_abbrev ; Offset Into Abbrev. Section | |
.long Lset1 | |
.byte 8 ; Address Size (in bytes) | |
.byte 1 ; Abbrev [1] 0xb:0x99 DW_TAG_compile_unit | |
.long 0 ; DW_AT_producer | |
.short 12 ; DW_AT_language | |
.long 47 ; DW_AT_name | |
.long 56 ; DW_AT_LLVM_sysroot | |
.long 108 ; DW_AT_APPLE_sdk | |
.set Lset2, Lline_table_start0-Lsection_line ; DW_AT_stmt_list | |
.long Lset2 | |
.long 119 ; DW_AT_comp_dir | |
.quad Lfunc_begin0 ; DW_AT_low_pc | |
.set Lset3, Lfunc_end0-Lfunc_begin0 ; DW_AT_high_pc | |
.long Lset3 | |
.byte 2 ; Abbrev [2] 0x32:0x52 DW_TAG_subprogram | |
.quad Lfunc_begin0 ; DW_AT_low_pc | |
.set Lset4, Lfunc_end0-Lfunc_begin0 ; DW_AT_high_pc | |
.long Lset4 | |
.byte 1 ; DW_AT_frame_base | |
.byte 109 | |
.long 136 ; DW_AT_name | |
.byte 1 ; DW_AT_decl_file | |
.byte 4 ; DW_AT_decl_line | |
; DW_AT_prototyped | |
.long 132 ; DW_AT_type | |
; DW_AT_external | |
.byte 3 ; Abbrev [3] 0x4b:0xe DW_TAG_formal_parameter | |
.byte 2 ; DW_AT_location | |
.byte 145 | |
.byte 120 | |
.long 145 ; DW_AT_name | |
.byte 1 ; DW_AT_decl_file | |
.byte 4 ; DW_AT_decl_line | |
.long 132 ; DW_AT_type | |
.byte 3 ; Abbrev [3] 0x59:0xe DW_TAG_formal_parameter | |
.byte 2 ; DW_AT_location | |
.byte 143 | |
.byte 16 | |
.long 150 ; DW_AT_name | |
.byte 1 ; DW_AT_decl_file | |
.byte 4 ; DW_AT_decl_line | |
.long 139 ; DW_AT_type | |
.byte 4 ; Abbrev [4] 0x67:0xe DW_TAG_variable | |
.byte 2 ; DW_AT_location | |
.byte 143 | |
.byte 12 | |
.long 160 ; DW_AT_name | |
.byte 1 ; DW_AT_decl_file | |
.byte 8 ; DW_AT_decl_line | |
.long 132 ; DW_AT_type | |
.byte 4 ; Abbrev [4] 0x75:0xe DW_TAG_variable | |
.byte 2 ; DW_AT_location | |
.byte 143 | |
.byte 11 | |
.long 162 ; DW_AT_name | |
.byte 1 ; DW_AT_decl_file | |
.byte 9 ; DW_AT_decl_line | |
.long 156 ; DW_AT_type | |
.byte 0 ; End Of Children Mark | |
.byte 5 ; Abbrev [5] 0x84:0x7 DW_TAG_base_type | |
.long 141 ; DW_AT_name | |
.byte 5 ; DW_AT_encoding | |
.byte 4 ; DW_AT_byte_size | |
.byte 6 ; Abbrev [6] 0x8b:0x5 DW_TAG_pointer_type | |
.long 144 ; DW_AT_type | |
.byte 6 ; Abbrev [6] 0x90:0x5 DW_TAG_pointer_type | |
.long 149 ; DW_AT_type | |
.byte 5 ; Abbrev [5] 0x95:0x7 DW_TAG_base_type | |
.long 155 ; DW_AT_name | |
.byte 6 ; DW_AT_encoding | |
.byte 1 ; DW_AT_byte_size | |
.byte 5 ; Abbrev [5] 0x9c:0x7 DW_TAG_base_type | |
.long 173 ; DW_AT_name | |
.byte 2 ; DW_AT_encoding | |
.byte 1 ; DW_AT_byte_size | |
.byte 0 ; End Of Children Mark | |
Ldebug_info_end0: | |
.section __DWARF,__debug_str,regular,debug | |
Linfo_string: | |
.asciz "Apple clang version 12.0.5 (clang-1205.0.22.9)" ; string offset=0 | |
.asciz "better.c" ; string offset=47 | |
.asciz "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" ; string offset=56 | |
.asciz "MacOSX.sdk" ; string offset=108 | |
.asciz "/Users/mrowe/src" ; string offset=119 | |
.asciz "main" ; string offset=136 | |
.asciz "int" ; string offset=141 | |
.asciz "argc" ; string offset=145 | |
.asciz "argv" ; string offset=150 | |
.asciz "char" ; string offset=155 | |
.asciz "c" ; string offset=160 | |
.asciz "cIsGreater" ; string offset=162 | |
.asciz "_Bool" ; string offset=173 | |
.section __DWARF,__apple_names,regular,debug | |
Lnames_begin: | |
.long 1212240712 ; Header Magic | |
.short 1 ; Header Version | |
.short 0 ; Header Hash Function | |
.long 1 ; Header Bucket Count | |
.long 1 ; Header Hash Count | |
.long 12 ; Header Data Length | |
.long 0 ; HeaderData Die Offset Base | |
.long 1 ; HeaderData Atom Count | |
.short 1 ; DW_ATOM_die_offset | |
.short 6 ; DW_FORM_data4 | |
.long 0 ; Bucket 0 | |
.long 2090499946 ; Hash in Bucket 0 | |
.set Lset5, LNames0-Lnames_begin ; Offset in Bucket 0 | |
.long Lset5 | |
LNames0: | |
.long 136 ; main | |
.long 1 ; Num DIEs | |
.long 50 | |
.long 0 | |
.section __DWARF,__apple_objc,regular,debug | |
Lobjc_begin: | |
.long 1212240712 ; Header Magic | |
.short 1 ; Header Version | |
.short 0 ; Header Hash Function | |
.long 1 ; Header Bucket Count | |
.long 0 ; Header Hash Count | |
.long 12 ; Header Data Length | |
.long 0 ; HeaderData Die Offset Base | |
.long 1 ; HeaderData Atom Count | |
.short 1 ; DW_ATOM_die_offset | |
.short 6 ; DW_FORM_data4 | |
.long -1 ; Bucket 0 | |
.section __DWARF,__apple_namespac,regular,debug | |
Lnamespac_begin: | |
.long 1212240712 ; Header Magic | |
.short 1 ; Header Version | |
.short 0 ; Header Hash Function | |
.long 1 ; Header Bucket Count | |
.long 0 ; Header Hash Count | |
.long 12 ; Header Data Length | |
.long 0 ; HeaderData Die Offset Base | |
.long 1 ; HeaderData Atom Count | |
.short 1 ; DW_ATOM_die_offset | |
.short 6 ; DW_FORM_data4 | |
.long -1 ; Bucket 0 | |
.section __DWARF,__apple_types,regular,debug | |
Ltypes_begin: | |
.long 1212240712 ; Header Magic | |
.short 1 ; Header Version | |
.short 0 ; Header Hash Function | |
.long 3 ; Header Bucket Count | |
.long 3 ; Header Hash Count | |
.long 20 ; Header Data Length | |
.long 0 ; HeaderData Die Offset Base | |
.long 3 ; HeaderData Atom Count | |
.short 1 ; DW_ATOM_die_offset | |
.short 6 ; DW_FORM_data4 | |
.short 3 ; DW_ATOM_die_tag | |
.short 5 ; DW_FORM_data2 | |
.short 4 ; DW_ATOM_type_flags | |
.short 11 ; DW_FORM_data1 | |
.long -1 ; Bucket 0 | |
.long -1 ; Bucket 1 | |
.long 0 ; Bucket 2 | |
.long 193495088 ; Hash in Bucket 2 | |
.long 249311216 ; Hash in Bucket 2 | |
.long 2090147939 ; Hash in Bucket 2 | |
.set Lset6, Ltypes0-Ltypes_begin ; Offset in Bucket 2 | |
.long Lset6 | |
.set Lset7, Ltypes1-Ltypes_begin ; Offset in Bucket 2 | |
.long Lset7 | |
.set Lset8, Ltypes2-Ltypes_begin ; Offset in Bucket 2 | |
.long Lset8 | |
Ltypes0: | |
.long 141 ; int | |
.long 1 ; Num DIEs | |
.long 132 | |
.short 36 | |
.byte 0 | |
.long 0 | |
Ltypes1: | |
.long 173 ; _Bool | |
.long 1 ; Num DIEs | |
.long 156 | |
.short 36 | |
.byte 0 | |
.long 0 | |
Ltypes2: | |
.long 155 ; char | |
.long 1 ; Num DIEs | |
.long 149 | |
.short 36 | |
.byte 0 | |
.long 0 | |
.subsections_via_symbols | |
.section __DWARF,__debug_line,regular,debug | |
Lsection_line: | |
Lline_table_start0: |
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
#include <stdio.h> | |
#include <stdbool.h> | |
int main(int argc, char* argv[]) { | |
printf("Which is greater, C or C++?\nAnswer: "); | |
int c = 1; | |
bool cIsGreater = c > c++; | |
if(cIsGreater) { | |
printf("C"); | |
} else { | |
printf("C++"); | |
} | |
printf("\n"); | |
return 0; | |
}; |
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
.section __TEXT,__text,regular,pure_instructions | |
.build_version macos, 11, 0 sdk_version 11, 3 | |
.globl _main ; -- Begin function main | |
.p2align 2 | |
_main: ; @main | |
.cfi_startproc | |
; %bb.0: | |
sub sp, sp, #48 ; =48 | |
stp x29, x30, [sp, #32] ; 16-byte Folded Spill | |
add x29, sp, #32 ; =32 | |
.cfi_def_cfa w29, 16 | |
.cfi_offset w30, -8 | |
.cfi_offset w29, -16 | |
stur wzr, [x29, #-4] | |
stur w0, [x29, #-8] | |
str x1, [sp, #16] | |
adrp x0, l_.str@PAGE | |
add x0, x0, l_.str@PAGEOFF | |
bl _printf | |
mov w8, #1 | |
str w8, [sp, #12] | |
ldr w9, [sp, #12] | |
ldr w10, [sp, #12] | |
add w11, w10, #1 ; =1 | |
str w11, [sp, #12] | |
subs w9, w9, w10 | |
cset w10, gt | |
and w8, w10, w8 | |
strb w8, [sp, #11] | |
ldrb w8, [sp, #11] | |
tbnz w8, #0, LBB0_1 | |
b LBB0_2 | |
LBB0_1: | |
adrp x0, l_.str.1@PAGE | |
add x0, x0, l_.str.1@PAGEOFF | |
bl _printf | |
b LBB0_3 | |
LBB0_2: | |
adrp x0, l_.str.2@PAGE | |
add x0, x0, l_.str.2@PAGEOFF | |
bl _printf | |
LBB0_3: | |
adrp x0, l_.str.3@PAGE | |
add x0, x0, l_.str.3@PAGEOFF | |
bl _printf | |
mov w8, #0 | |
mov x0, x8 | |
ldp x29, x30, [sp, #32] ; 16-byte Folded Reload | |
add sp, sp, #48 ; =48 | |
ret | |
.cfi_endproc | |
; -- End function | |
.section __TEXT,__cstring,cstring_literals | |
l_.str: ; @.str | |
.asciz "Which is greater, C or C++?\nAnswer: " | |
l_.str.1: ; @.str.1 | |
.asciz "C" | |
l_.str.2: ; @.str.2 | |
.asciz "C++" | |
l_.str.3: ; @.str.3 | |
.asciz "\n" | |
.subsections_via_symbols |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment