#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 fibonacci2(int n) {
  if (n < 0) {
    printf("aaaa");
  } else if (n == 1 || n == 2) {
    return 1;
  } else {
    return fibonacci2(n - 1) + fibonacci2(n - 2);
  }
}


x86 assembly (clang, -O0):
<fibonacci2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1146 <fibonacci2+0x26>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
jmp    1189 <fibonacci2+0x69>
cmpl   $0x1,-0x8(%rbp)
je     115a <fibonacci2+0x3a>
cmpl   $0x2,-0x8(%rbp)
jne    1166 <fibonacci2+0x46>
movl   $0x1,-0x4(%rbp)
jmp    1189 <fibonacci2+0x69>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1040 <fibonacci2@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
call   1040 <fibonacci2@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibonacci2>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
js     114f <fibonacci2+0x2f>
mov    %edi,%ebx
add    $0x2,%ebx
xor    %r14d,%r14d
lea    -0x3(%rbx),%edi
cmp    $0x2,%edi
jb     1160 <fibonacci2+0x40>
call   1040 <fibonacci2@plt>
mov    %eax,%ebp
add    %r14d,%ebp
add    $0xfffffffe,%ebx
mov    %ebp,%r14d
cmp    $0x2,%ebx
jge    1130 <fibonacci2+0x10>
jmp    1151 <fibonacci2+0x31>
xor    %ebp,%ebp
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    %ebp,%r14d
add    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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