#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 *, int);
int fib(int param1) {
  int g3;
  int g3_2;
  int local5;
  if (param1 <= 1) {
    if (param1 != 1) {
      local5 = param1;
    } else {
      local5 = 1;
    }
  } else {
    g3 = fib(param1 - 1);
    g3_2 = fib(g3 - 1);
    printf("%d", g3 + g3_2);
    local5 = g3;
  }
  return local5;
}


x86 assembly (clang, -O0):
<fib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jg     1156 <fib+0x36>
cmpl   $0x1,-0x4(%rbp)
je     114a <fib+0x2a>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1151 <fib+0x31>
movl   $0x1,-0x10(%rbp)
jmp    118a <fib+0x6a>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
call   1040 <fib@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1040 <fib@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fib>:
push   %rbx
mov    %edi,%ebx
cmp    $0x1,%edi
jle    114c <fib+0x2c>
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1040 <fib@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%edi
call   1040 <fib@plt>
mov    %ebx,%esi
add    %eax,%esi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

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