Created
October 7, 2017 08:17
-
-
Save fcamel/63f24f7ec4922a944884708ea9ad6331 to your computer and use it in GitHub Desktop.
fib(n)
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
0000000000400ef0 <_Z3fibi>: | |
long long fib(int n) { | |
400ef0: b8 01 00 00 00 mov $0x1,%eax | |
if (n <= 1) | |
400ef5: 83 ff 02 cmp $0x2,%edi | |
400ef8: 0f 8c 8f 00 00 00 jl 400f8d <_Z3fibi+0x9d> | |
long long a = 1; | |
long long b = 1; | |
long long c; | |
for (int i = 2; i <= n; i++) { | |
c = a + b; | |
400efe: 44 8d 4f 07 lea 0x7(%rdi),%r9d | |
400f02: 44 8d 47 fe lea -0x2(%rdi),%r8d | |
400f06: b8 01 00 00 00 mov $0x1,%eax | |
400f0b: 41 f6 c1 07 test $0x7,%r9b | |
400f0f: 74 3d je 400f4e <_Z3fibi+0x5e> | |
400f11: 41 83 e1 07 and $0x7,%r9d | |
400f15: 31 d2 xor %edx,%edx | |
400f17: b8 01 00 00 00 mov $0x1,%eax | |
400f1c: b9 01 00 00 00 mov $0x1,%ecx | |
400f21: 66 66 66 66 66 66 2e data16 data16 data16 data16 data16 nopw %cs:0x0(%rax,%rax,1) | |
400f28: 0f 1f 84 00 00 00 00 | |
400f2f: 00 | |
400f30: 48 89 ce mov %rcx,%rsi | |
400f33: 48 89 c1 mov %rax,%rcx | |
400f36: 41 89 d2 mov %edx,%r10d | |
400f39: 48 89 f0 mov %rsi,%rax | |
400f3c: 48 01 c8 add %rcx,%rax | |
return 1; | |
long long a = 1; | |
long long b = 1; | |
long long c; | |
for (int i = 2; i <= n; i++) { | |
400f3f: 41 8d 52 01 lea 0x1(%r10),%edx | |
400f43: 41 39 d1 cmp %edx,%r9d | |
400f46: 75 e8 jne 400f30 <_Z3fibi+0x40> | |
400f48: 41 83 c2 03 add $0x3,%r10d | |
400f4c: eb 0b jmp 400f59 <_Z3fibi+0x69> | |
400f4e: 41 ba 02 00 00 00 mov $0x2,%r10d | |
400f54: b9 01 00 00 00 mov $0x1,%ecx | |
c = a + b; | |
400f59: 41 83 f8 07 cmp $0x7,%r8d | |
400f5d: 72 2e jb 400f8d <_Z3fibi+0x9d> | |
400f5f: ff c7 inc %edi | |
400f61: 44 29 d7 sub %r10d,%edi | |
400f64: 66 66 66 2e 0f 1f 84 data16 data16 nopw %cs:0x0(%rax,%rax,1) | |
400f6b: 00 00 00 00 00 | |
400f70: 48 01 c1 add %rax,%rcx | |
400f73: 48 01 c8 add %rcx,%rax | |
400f76: 48 01 c1 add %rax,%rcx | |
400f79: 48 01 c8 add %rcx,%rax | |
400f7c: 48 01 c1 add %rax,%rcx | |
400f7f: 48 01 c8 add %rcx,%rax | |
400f82: 48 01 c1 add %rax,%rcx | |
400f85: 48 01 c8 add %rcx,%rax | |
return 1; | |
long long a = 1; | |
long long b = 1; | |
long long c; | |
for (int i = 2; i <= n; i++) { | |
400f88: 83 c7 f8 add $0xfffffff8,%edi | |
400f8b: 75 e3 jne 400f70 <_Z3fibi+0x80> | |
c = a + b; | |
a = b; | |
b = c; | |
} | |
return c; | |
} | |
400f8d: c3 retq | |
400f8e: 66 90 xchg %ax,%ax |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment