#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 a, long long int b, long long int n) {
  long long int F[2][2] = {{1, 1}, {1, 0}};
  long long int v;
  if (n == 0)
    return a;
  if (n == 1)
    return b;
  power(F, n - 1);
  v = ((F[0][0] * b) % 1000000007 + (F[0][1] * a) % 1000000007) % 1000000007;
  return v;
}


x86 assembly (clang, -O0):
<fib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0xed5(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xed2(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xecf(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xecc(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1168 <fib+0x58>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d8 <fib+0xc8>
cmpq   $0x1,-0x20(%rbp)
jne    1180 <fib+0x70>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d8 <fib+0xc8>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
sub    $0x1,%rsi
call   1030 <power@plt>
mov    -0x40(%rbp),%rax
imul   -0x18(%rbp),%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x50(%rbp)
mov    -0x38(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    -0x50(%rbp),%rax
add    %rdx,%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fib>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
movaps 0xeef(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,(%rsp)
test   %rdx,%rdx
je     11d6 <fib+0xc6>
mov    %rsi,%r14
cmp    $0x1,%rdx
jne    114b <fib+0x3b>
mov    %r14,%rbx
jmp    11d6 <fib+0xc6>
add    $0xffffffffffffffff,%rdx
mov    %rsp,%rdi
mov    %rdx,%rsi
call   1030 <power@plt>
imul   (%rsp),%r14
movabs $0x89705f3112a28fe5,%rcx
5f 70 89
mov    %r14,%rax
imul   %rcx
add    %r14,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca07,%rdx,%rsi
imul   0x8(%rsp),%rbx
mov    %rbx,%rax
imul   %rcx
sub    %rsi,%r14
add    %rbx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca07,%rdx,%rax
sub    %rax,%rbx
add    %r14,%rbx
movslq %ebx,%rax
imul   $0x44b82f99,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x3c,%rcx
add    %edx,%ecx
imul   $0x3b9aca07,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%rbx
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r14
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, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca [2 x [2 x i64]]
%9 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%10 = bitcast [2 x [2 x i64]]* %8 to i8*
%11 = load i64, i64* %7
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = load i64, i64* %5
store i64 %14, i64* %4
br label %41
15: ; preds = %3
%16 = load i64, i64* %7
%17 = icmp eq i64 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i64, i64* %6
store i64 %19, i64* %4
br label %41
20: ; preds = %15
%21 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %8, i64 0, i64 0
%22 = bitcast [2 x i64]* %21 to i64**
%23 = load i64, i64* %7
%24 = sub nsw i64 %23, 1
%25 = call i32 @power(i64** %22, i64 %24)
%26 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %8, i64 0, i64 0
%27 = getelementptr inbounds [2 x i64], [2 x i64]* %26, i64 0, i64 0
%28 = load i64, i64* %27
%29 = load i64, i64* %6
%30 = mul nsw i64 %28, %29
%31 = srem i64 %30, 1000000007
%32 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %8, i64 0, i64 0
%33 = getelementptr inbounds [2 x i64], [2 x i64]* %32, i64 0, i64 1
%34 = load i64, i64* %33
%35 = load i64, i64* %5
%36 = mul nsw i64 %34, %35
%37 = srem i64 %36, 1000000007
%38 = add nsw i64 %31, %37
%39 = srem i64 %38, 1000000007
store i64 %39, i64* %9
%40 = load i64, i64* %9
store i64 %40, i64* %4
br label %41
41: ; preds = %20, %18, %13
%42 = load i64, i64* %4
ret i64 %42
}

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, i64 %1, i64 %2) {
%4 = alloca [2 x [2 x i64]]
%5 = bitcast [2 x [2 x i64]]* %4 to i8*
switch i64 %2, label %7 [
i64 0, label %23
i64 1, label %6
]
6: ; preds = %3
br label %23
7: ; preds = %3
%8 = bitcast [2 x [2 x i64]]* %4 to i64**
%9 = add nsw i64 %2, -1
%10 = call i32 @power(i64** %8, i64 %9)
%11 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %4, i64 0, i64 0, i64 0
%12 = load i64, i64* %11
%13 = mul nsw i64 %12, %1
%14 = srem i64 %13, 1000000007
%15 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %4, i64 0, i64 0, i64 1
%16 = load i64, i64* %15
%17 = mul nsw i64 %16, %0
%18 = srem i64 %17, 1000000007
%19 = add nsw i64 %18, %14
%20 = trunc i64 %19 to i32
%21 = srem i32 %20, 1000000007
%22 = sext i32 %21 to i64
br label %23
23: ; preds = %3, %7, %6
%24 = phi i64 [ %1, %6 ], [ %22, %7 ], [ %0, %3 ]
ret i64 %24
}