88 lines · plain
1# Source (tiny.cc):2# void a() {}3# void b() {}4# int main(int argc, char** argv) {5# void(*ptr)();6# if (argc == 1)7# ptr = &a;8# else9# ptr = &b;10# ptr();11# }12# Compile with:13# clang++ tiny.cc -S -o tiny.s14 15 .text16 .file "tiny.cc"17 .globl _Z1av # -- Begin function _Z1av18 .p2align 4, 0x9019 .type _Z1av,@function20_Z1av: # @_Z1av21 .cfi_startproc22# %bb.0:23 pushq %rbp24 .cfi_def_cfa_offset 1625 .cfi_offset %rbp, -1626 movq %rsp, %rbp27 .cfi_def_cfa_register %rbp28 popq %rbp29 retq30.Lfunc_end0:31 .size _Z1av, .Lfunc_end0-_Z1av32 .cfi_endproc33 # -- End function34 .globl _Z1bv # -- Begin function _Z1bv35 .p2align 4, 0x9036 .type _Z1bv,@function37_Z1bv: # @_Z1bv38 .cfi_startproc39# %bb.0:40 pushq %rbp41 .cfi_def_cfa_offset 1642 .cfi_offset %rbp, -1643 movq %rsp, %rbp44 .cfi_def_cfa_register %rbp45 popq %rbp46 retq47.Lfunc_end1:48 .size _Z1bv, .Lfunc_end1-_Z1bv49 .cfi_endproc50 # -- End function51 .globl main # -- Begin function main52 .p2align 4, 0x9053 .type main,@function54main: # @main55 .cfi_startproc56# %bb.0:57 pushq %rbp58 .cfi_def_cfa_offset 1659 .cfi_offset %rbp, -1660 movq %rsp, %rbp61 .cfi_def_cfa_register %rbp62 subq $32, %rsp63 movl $0, -4(%rbp)64 movl %edi, -8(%rbp)65 movq %rsi, -16(%rbp)66 cmpl $1, -8(%rbp)67 jne .LBB2_268# %bb.1:69 movabsq $_Z1av, %rax70 movq %rax, -24(%rbp)71 jmp .LBB2_372.LBB2_2:73 movabsq $_Z1bv, %rax74 movq %rax, -24(%rbp)75.LBB2_3:76 callq *-24(%rbp)77 movl -4(%rbp), %eax78 addq $32, %rsp79 popq %rbp80 retq81.Lfunc_end2:82 .size main, .Lfunc_end2-main83 .cfi_endproc84 # -- End function85 86 .ident "clang version 6.0.0 (trunk 316774)"87 .section ".note.GNU-stack","",@progbits88