#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 */
double pow(int, int);
double sqrt(int);
int climbStairs(int n) {
  double sqrt5 = sqrt(5);
  double fibn = pow((1 + sqrt5) / 2, n + 1) - pow((1 - sqrt5) / 2, n + 1);
  return (int)(fibn / sqrt5);
}


x86 assembly (clang, -O0):
<climbStairs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x5,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xec6(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xeb1(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x4(%rbp),%esi
add    $0x1,%esi
call   1030 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe99(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x4(%rbp),%esi
add    $0x1,%esi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<climbStairs>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    $0x5,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
addsd  0xebe(%rip),%xmm1
mulsd  0xebe(%rip),%xmm1
cvttsd2si %xmm1,%edi
add    $0x1,%ebx
mov    %ebx,%esi
call   1030 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe9a(%rip),%xmm0
subsd  (%rsp),%xmm0
mulsd  0xe95(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
divsd  (%rsp),%xmm1
cvttsd2si %xmm1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @climbStairs(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 %0, i32* %2
%5 = call double @sqrt(i32 5)
store double %5, double* %3
%6 = load double, double* %3
%7 = fadd double 1.000000e+00, %6
%8 = fdiv double %7, 2.000000e+00
%9 = fptosi double %8 to i32
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = call double @pow(i32 %9, i32 %11)
%13 = load double, double* %3
%14 = fsub double 1.000000e+00, %13
%15 = fdiv double %14, 2.000000e+00
%16 = fptosi double %15 to i32
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
%19 = call double @pow(i32 %16, i32 %18)
%20 = fsub double %12, %19
store double %20, double* %4
%21 = load double, double* %4
%22 = load double, double* %3
%23 = fdiv double %21, %22
%24 = fptosi double %23 to i32
ret i32 %24
}

LLVM IR (-O2):
define i32 @climbStairs(i32 %0) {
%2 = tail call double @sqrt(i32 5)
%3 = fadd double %2, 1.000000e+00
%4 = fmul double %3, 5.000000e-01
%5 = fptosi double %4 to i32
%6 = add nsw i32 %0, 1
%7 = tail call double @pow(i32 %5, i32 %6)
%8 = fsub double 1.000000e+00, %2
%9 = fmul double %8, 5.000000e-01
%10 = fptosi double %9 to i32
%11 = tail call double @pow(i32 %10, i32 %6)
%12 = fsub double %7, %11
%13 = fdiv double %12, %2
%14 = fptosi double %13 to i32
ret i32 %14
}