#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ power(long long **, long long);
long long int fib(long long int n) {
  long long int F[2][2] = {{1, 1}, {1, 0}};
  long long int v;
  if (n == 0)
    return 0;
  if (n == 1)
    return 1;
  power(F, n - 1);
  v = (F[0][0]) % 1000000007;
  return v;
}


x86 assembly (clang, -O0):
<fib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed4(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1160 <fib+0x50>
movq   $0x0,-0x8(%rbp)
jmp    11a3 <fib+0x93>
cmpq   $0x1,-0x10(%rbp)
jne    1178 <fib+0x68>
movq   $0x1,-0x8(%rbp)
jmp    11a3 <fib+0x93>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
call   1030 <power@plt>
mov    -0x30(%rbp),%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fib>:
sub    $0x28,%rsp
mov    %rdi,%rsi
movaps 0xef2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,(%rsp)
test   %rdi,%rdi
je     117b <fib+0x6b>
cmp    $0x1,%rsi
jne    1140 <fib+0x30>
mov    $0x1,%esi
jmp    117b <fib+0x6b>
add    $0xffffffffffffffff,%rsi
mov    %rsp,%rdi
call   1030 <power@plt>
mov    (%rsp),%rsi
movabs $0x89705f3112a28fe5,%rcx
5f 70 89
mov    %rsi,%rax
imul   %rcx
add    %rsi,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca07,%rdx,%rax
sub    %rax,%rsi
mov    %rsi,%rax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.fib.F = [2 x [2 x i64]] [[2 x i64] [i64 1, i64 1], [2 x i64] [i64 1, i64 0]]
define i64 @fib(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca [2 x [2 x i64]]
%5 = alloca i64
store i64 %0, i64* %3
%6 = bitcast [2 x [2 x i64]]* %4 to i8*
%7 = load i64, i64* %3
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i64 0, i64* %2
br label %25
10: ; preds = %1
%11 = load i64, i64* %3
%12 = icmp eq i64 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %10
store i64 1, i64* %2
br label %25
14: ; preds = %10
%15 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %4, i64 0, i64 0
%16 = bitcast [2 x i64]* %15 to i64**
%17 = load i64, i64* %3
%18 = sub nsw i64 %17, 1
%19 = call i32 @power(i64** %16, i64 %18)
%20 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %4, i64 0, i64 0
%21 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 0
%22 = load i64, i64* %21
%23 = srem i64 %22, 1000000007
store i64 %23, i64* %5
%24 = load i64, i64* %5
store i64 %24, i64* %2
br label %25
25: ; preds = %14, %13, %9
%26 = load i64, i64* %2
ret i64 %26
}

LLVM IR (-O2):
@__const.fib.F = [2 x [2 x i64]] [[2 x i64] [i64 1, i64 1], [2 x i64] [i64 1, i64 0]]
define i64 @fib(i64 %0) {
%2 = alloca [2 x [2 x i64]]
%3 = bitcast [2 x [2 x i64]]* %2 to i8*
switch i64 %0, label %5 [
i64 0, label %12
i64 1, label %4
]
4: ; preds = %1
br label %12
5: ; preds = %1
%6 = bitcast [2 x [2 x i64]]* %2 to i64**
%7 = add nsw i64 %0, -1
%8 = call i32 @power(i64** %6, i64 %7)
%9 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %2, i64 0, i64 0, i64 0
%10 = load i64, i64* %9
%11 = srem i64 %10, 1000000007
br label %12
12: ; preds = %1, %5, %4
%13 = phi i64 [ 1, %4 ], [ %11, %5 ], [ %0, %1 ]
ret i64 %13
}