Created
January 25, 2019 01:43
-
-
Save kaityo256/11c5bb56da06e0d7e8036350ba74781f to your computer and use it in GitHub Desktop.
demons fly out of your nose
This file contains hidden or 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
| // Modified from https://qiita.com/tkmtSo/items/de3148dd1dcb70f38d6a | |
| #include <cstdio> | |
| int collatz(int n) { | |
| while (true) { | |
| if (n == 1) | |
| return 1; | |
| if (n % 2 == 0) { | |
| n /= 2; | |
| } else { | |
| n = 3 * n + 1; | |
| } | |
| } | |
| } | |
| int test(int n) { | |
| return collatz(n); | |
| } |
Author
kaityo256
commented
Jan 25, 2019
Author
$ clang++ -O3 -S collatz.cpp;c++filt <collatz.s > collatz.clang.s
The function test returns 1 without any calculation!
test(int): ## @_Z4testi
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
movl $1, %eax
popq %rbp
retq
.cfi_endproc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment