| 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 |
# else |
| 9 |
# ptr = &b; |
| 10 |
# ptr(); |
| 11 |
# } |
| 12 |
# Compile with: |
| 13 |
# clang++ tiny.cc -S -o tiny.s |
| 14 |
|
| 15 |
.text |
| 16 |
.file "tiny.cc" |
| 17 |
.globl _Z1av # -- Begin function _Z1av |
| 18 |
.p2align 4, 0x90 |
| 19 |
.type _Z1av,@function |
| 20 |
_Z1av: # @_Z1av |
| 21 |
.cfi_startproc |
| 22 |
# %bb.0: |
| 23 |
pushq %rbp |
| 24 |
.cfi_def_cfa_offset 16 |
| 25 |
.cfi_offset %rbp, -16 |
| 26 |
movq %rsp, %rbp |
| 27 |
.cfi_def_cfa_register %rbp |
| 28 |
popq %rbp |
| 29 |
retq |
| 30 |
.Lfunc_end0: |
| 31 |
.size _Z1av, .Lfunc_end0-_Z1av |
| 32 |
.cfi_endproc |
| 33 |
# -- End function |
| 34 |
.globl _Z1bv # -- Begin function _Z1bv |
| 35 |
.p2align 4, 0x90 |
| 36 |
.type _Z1bv,@function |
| 37 |
_Z1bv: # @_Z1bv |
| 38 |
.cfi_startproc |
| 39 |
# %bb.0: |
| 40 |
pushq %rbp |
| 41 |
.cfi_def_cfa_offset 16 |
| 42 |
.cfi_offset %rbp, -16 |
| 43 |
movq %rsp, %rbp |
| 44 |
.cfi_def_cfa_register %rbp |
| 45 |
popq %rbp |
| 46 |
retq |
| 47 |
.Lfunc_end1: |
| 48 |
.size _Z1bv, .Lfunc_end1-_Z1bv |
| 49 |
.cfi_endproc |
| 50 |
# -- End function |
| 51 |
.globl main # -- Begin function main |
| 52 |
.p2align 4, 0x90 |
| 53 |
.type main,@function |
| 54 |
main: # @main |
| 55 |
.cfi_startproc |
| 56 |
# %bb.0: |
| 57 |
pushq %rbp |
| 58 |
.cfi_def_cfa_offset 16 |
| 59 |
.cfi_offset %rbp, -16 |
| 60 |
movq %rsp, %rbp |
| 61 |
.cfi_def_cfa_register %rbp |
| 62 |
subq $32, %rsp |
| 63 |
movl $0, -4(%rbp) |
| 64 |
movl %edi, -8(%rbp) |
| 65 |
movq %rsi, -16(%rbp) |
| 66 |
cmpl $1, -8(%rbp) |
| 67 |
jne .LBB2_2 |
| 68 |
# %bb.1: |
| 69 |
movabsq $_Z1av, %rax |
| 70 |
movq %rax, -24(%rbp) |
| 71 |
jmp .LBB2_3 |
| 72 |
.LBB2_2: |
| 73 |
movabsq $_Z1bv, %rax |
| 74 |
movq %rax, -24(%rbp) |
| 75 |
.LBB2_3: |
| 76 |
callq *-24(%rbp) |
| 77 |
movl -4(%rbp), %eax |
| 78 |
addq $32, %rsp |
| 79 |
popq %rbp |
| 80 |
retq |
| 81 |
.Lfunc_end2: |
| 82 |
.size main, .Lfunc_end2-main |
| 83 |
.cfi_endproc |
| 84 |
# -- End function |
| 85 |
|
| 86 |
.ident "clang version 6.0.0 (trunk 316774)" |
| 87 |
.section ".note.GNU-stack","",@progbits |