#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 *, long);
void printFibonacci(int n) {
  static long int first = 0, second = 1, sum;
  if (n > 0) {
    sum = first + second;
    first = second;
    second = sum;
    printf("%ld ", sum);
    printFibonacci(n - 1);
  }
}


x86 assembly (clang, -O0):
<printFibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    1184 <printFibonacci+0x64>
mov    0x2f04(%rip),%rax
add    0x2eed(%rip),%rax
mov    %rax,0x2efe(%rip)
mov    0x2edf(%rip),%rax
mov    %rax,0x2ee8(%rip)
mov    0x2ee9(%rip),%rax
mov    %rax,0x2eca(%rip)
mov    0x2edb(%rip),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
call   1040 <printFibonacci@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printFibonacci>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    115f <printFibonacci+0x4f>
mov    %edi,%ebx
add    $0x1,%ebx
lea    0xedc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2ef1(%rip),%rax
mov    0x2efa(%rip),%rsi
add    %rax,%rsi
mov    %rax,0x2ef0(%rip)
mov    %rsi,0x2ed9(%rip)
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1130 <printFibonacci+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@printFibonacci.first = internal global i64 0
@printFibonacci.second = internal global i64 1
@printFibonacci.sum = internal global i64 0
@.str = [5 x i8] c"%ld \00"
define void @printFibonacci(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = load i64, i64* @printFibonacci.first
%7 = load i64, i64* @printFibonacci.second
%8 = add nsw i64 %6, %7
store i64 %8, i64* @printFibonacci.sum
%9 = load i64, i64* @printFibonacci.second
store i64 %9, i64* @printFibonacci.first
%10 = load i64, i64* @printFibonacci.sum
store i64 %10, i64* @printFibonacci.second
%11 = load i64, i64* @printFibonacci.sum
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %11)
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, 1
br label %15
15: ; preds = %5, %1
ret void
}

LLVM IR (-O2):
@printFibonacci.first = internal unnamed_addr global i64 0
@printFibonacci.second = internal unnamed_addr global i64 1
@.str = [5 x i8] c"%ld \00"
define void @printFibonacci(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %11
3: ; preds = %1, %3
%4 = phi i32 [ %9, %3 ], [ %0, %1 ]
%5 = load i64, i64* @printFibonacci.first
%6 = load i64, i64* @printFibonacci.second
%7 = add nsw i64 %6, %5
store i64 %6, i64* @printFibonacci.first
store i64 %7, i64* @printFibonacci.second
%8 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = add nsw i32 %4, -1
%10 = icmp ugt i32 %4, 1
br i1 %10, label %3, label %11
11: ; preds = %3, %1
ret void
}