#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*/ printf(char *, double, double, double);
double fib(int n) {
  if (n < 2)
    return 1;
  else {
    double a = fib(n - 1);
    double b = fib(n - 2);
    printf("%f + %f = %f\n", a, b, a + b);
    return a + b;
  }
}


x86 assembly (clang, -O0):
<fib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    1147 <fib+0x27>
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1196 <fib+0x76>
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
call   1040 <fib@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
sub    $0x2,%edi
call   1040 <fib@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
addsd  -0x20(%rbp),%xmm2
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fib>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     1134 <fib+0x14>
movsd  0xece(%rip),%xmm0
jmp    1176 <fib+0x56>
mov    %edi,%ebx
lea    -0x1(%rbx),%edi
call   1040 <fib@plt>
movsd  %xmm0,0x8(%rsp)
add    $0xfffffffe,%ebx
mov    %ebx,%edi
call   1040 <fib@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%f + %f = %f\0A\00"
define double @fib(i32 %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %9
8: ; preds = %1
store double 1.000000e+00, double* %2
br label %25
9: ; preds = %1
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 1
%12 = call double @fib(i32 %11)
store double %12, double* %4
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 2
%15 = call double @fib(i32 %14)
store double %15, double* %5
%16 = load double, double* %4
%17 = load double, double* %5
%18 = load double, double* %4
%19 = load double, double* %5
%20 = fadd double %18, %19
%21 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %16, double %17, double %20)
%22 = load double, double* %4
%23 = load double, double* %5
%24 = fadd double %22, %23
store double %24, double* %2
br label %25
25: ; preds = %9, %8
%26 = load double, double* %2
ret double %26
}

LLVM IR (-O2):
@.str = [14 x i8] c"%f + %f = %f\0A\00"
define double @fib(i32 %0) {
%2 = icmp slt i32 %0, 2
br i1 %2, label %3, label %5
3: ; preds = %1, %5
%4 = phi double [ %10, %5 ], [ 1.000000e+00, %1 ]
ret double %4
5: ; preds = %1
%6 = add nsw i32 %0, -1
%7 = tail call double @fib(i32 %6)
%8 = add nsw i32 %0, -2
%9 = tail call double @fib(i32 %8)
%10 = fadd double %7, %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %7, double %9, double %10)
br label %3
}