#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, unsigned int);
double sqrt(int);
unsigned int BinetsFormula(unsigned int num) {
  double PHI = (1.0 + sqrt(5)) / 2.0;
  unsigned int fibonacci_number = 0;
  fibonacci_number = (pow(PHI, num) - pow(1 - PHI, num)) / sqrt(5);
  return fibonacci_number;
}


x86 assembly (clang, -O0):
<BinetsFormula>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x5,%edi
mov    %edi,-0x2c(%rbp)
call   1040 <sqrt@plt>
movsd  0xec0(%rip),%xmm1
movsd  %xmm1,-0x38(%rbp)
addsd  %xmm1,%xmm0
movsd  0xeb7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cvttsd2si -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  %xmm1,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x4(%rbp),%esi
call   1030 <pow@plt>
mov    -0x2c(%rbp),%edi
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @BinetsFormula(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 = tail call double @pow(i32 %5, i32 %0)
%7 = fsub double 1.000000e+00, %4
%8 = fptosi double %7 to i32
%9 = tail call double @pow(i32 %8, i32 %0)
%10 = fsub double %6, %9
%11 = tail call double @sqrt(i32 5)
%12 = fdiv double %10, %11
%13 = fptoui double %12 to i32
ret i32 %13
}