#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*/ fibonacci_computing(unsigned int *, unsigned int *);
int /*<<< orphan*/ printf(char *, ...);
void fibonacci(unsigned int nbr_terms) {
  unsigned int i = 0;
  unsigned int lastTerm = 0;
  unsigned int oldTerm = 1;
  for (i = 0; i < nbr_terms; i++) {
    fibonacci_computing(&lastTerm, &oldTerm);
    printf("%d", lastTerm);
    if (i + 1 != nbr_terms) {
      printf(" - ");
    } else {
      printf("\n");
    }
  }
  printf("le rapport entre %d et %d (%d / %d) = %lf\n", lastTerm, oldTerm,
         lastTerm, oldTerm, (double)lastTerm / oldTerm);
  return;
}


x86 assembly (clang, -O0):
<fibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11b4 <fibonacci+0x94>
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <fibonacci_computing@plt>
mov    -0xc(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cmp    -0x4(%rbp),%eax
je     1193 <fibonacci+0x73>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a1 <fibonacci+0x81>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a6 <fibonacci+0x86>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1147 <fibonacci+0x27>
mov    -0xc(%rbp),%eax
mov    %eax,%edi
mov    %edi,%esi
mov    -0x10(%rbp),%eax
mov    %eax,%edx
mov    %esi,%ecx
mov    %edx,%r8d
cvtsi2sd %rdi,%xmm0
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
lea    0xe2d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibonacci>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x1,0xc(%rsp)
test   %edi,%edi
je     11b6 <fibonacci+0x86>
mov    %edi,%ebx
lea    0x8(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0xe9c(%rip),%r12
lea    0xe98(%rip),%r13
jmp    117f <fibonacci+0x4f>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
je     11ac <fibonacci+0x7c>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <fibonacci_computing@plt>
mov    0x8(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
je     1170 <fibonacci+0x40>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    117f <fibonacci+0x4f>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%edx
jmp    11bd <fibonacci+0x8d>
xor    %ecx,%ecx
mov    $0x1,%edx
mov    %ecx,%eax
cvtsi2sd %rax,%xmm0
mov    %edx,%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
lea    0xe31(%rip),%rdi
mov    %ecx,%esi
mov    %edx,%r8d
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c" - \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [43 x i8] c"le rapport entre %d et %d (%d / %d) = %lf\0A\00"
define void @fibonacci(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %5
store i32 0, i32* %3
br label %6
6: ; preds = %23, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp ult i32 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = call i32 @fibonacci_computing(i32* %4, i32* %5)
%12 = load i32, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %3
%15 = add i32 %14, 1
%16 = load i32, i32* %2
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %22
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add i32 %24, 1
store i32 %25, i32* %3
br label %6
26: ; preds = %6
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = load i32, i32* %4
%32 = uitofp i32 %31 to double
%33 = load i32, i32* %5
%34 = uitofp i32 %33 to double
%35 = fdiv double %32, %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28, i32 %29, i32 %30, double %35)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c" - \00"
@.str.3 = [43 x i8] c"le rapport entre %d et %d (%d / %d) = %lf\0A\00"
define void @fibonacci(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%6 = icmp eq i32 %0, 0
br i1 %6, label %23, label %7
7: ; preds = %1, %18
%8 = phi i32 [ %12, %18 ], [ 0, %1 ]
%9 = call i32 @fibonacci_computing(i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = add nuw i32 %8, 1
%13 = icmp eq i32 %12, %0
br i1 %13, label %16, label %14
14: ; preds = %7
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %7
%17 = call i32 @putchar(i32 10)
br label %18
18: ; preds = %14, %16
%19 = icmp eq i32 %12, %0
br i1 %19, label %20, label %7
20: ; preds = %18
%21 = load i32, i32* %2
%22 = load i32, i32* %3
br label %23
23: ; preds = %20, %1
%24 = phi i32 [ %22, %20 ], [ 1, %1 ]
%25 = phi i32 [ %21, %20 ], [ 0, %1 ]
%26 = uitofp i32 %25 to double
%27 = uitofp i32 %24 to double
%28 = fdiv double %26, %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 %24, i32 %25, i32 %24, double %28)
ret void
}