#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 /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n, i, fibonacciNumber, previousFibNum1, previousFibNum2;
  double fibonacciQuotient;
  do {
    printf("Enter an integer between 2 and 46, inclusive (or 0 to quit): ");
    scanf("%d", &n);
    if (n == 0) {
      return 0;
    }
  } while (n < 2 || n > 46);
  printf("\n           Fibonacci        Fibonacci\n N           number         "
         " quotient\n-------------------------------------\n");
  printf("%2d%14d                  N/A\n", 0, 0);
  printf("%2d%14d                  N/A\n", 1, 1);
  previousFibNum2 = 0;
  previousFibNum1 = 1;
  for (i = 2; i <= n; i++) {
    fibonacciNumber = previousFibNum1 + previousFibNum2;
    fibonacciQuotient = (double)fibonacciNumber / (double)previousFibNum1;
    printf("%2d%14d%21.16f\n", i, fibonacciNumber, fibonacciQuotient);
    previousFibNum2 = previousFibNum1;
    previousFibNum1 = fibonacciNumber;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1163 <main+0x43>
movl   $0x0,-0x4(%rbp)
jmp    1238 <main+0x118>
jmp    1168 <main+0x48>
mov    $0x1,%al
cmpl   $0x2,-0x8(%rbp)
mov    %al,-0x21(%rbp)
jl     1181 <main+0x61>
cmpl   $0x2e,-0x8(%rbp)
setg   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    112f <main+0xf>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf14(%rip),%rdi
xor    %edx,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1231 <main+0x111>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
lea    0xec3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d6 <main+0xb6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%r14
lea    0xef4(%rip),%r15
lea    0xc(%rsp),%rbx
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1206 <main+0xd6>
add    $0xffffffd1,%eax
cmp    $0xffffffd3,%eax
jb     1150 <main+0x20>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%r14
xor    %r15d,%r15d
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x2,0xc(%rsp)
jl     1206 <main+0xd6>
lea    0xe9b(%rip),%r14
mov    $0x1,%r12d
nopw   0x0(%rax,%rax,1)
mov    %r15d,%ebp
add    %r12d,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
add    $0x1,%ebx
xorps  %xmm1,%xmm1
cvtsi2sd %r12d,%xmm1
divsd  %xmm1,%xmm0
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r12d,%r15d
mov    %ebp,%r12d
cmp    0xc(%rsp),%ebx
jl     11d0 <main+0xa0>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [62 x i8] c"Enter an integer between 2 and 46, inclusive (or 0 to quit): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [116 x i8] c"\0A Fibonacci Fibonacci\0A N number quotient\0A-------------------------------------\0A\00"
@.str.3 = [30 x i8] c"%2d%14d N/A\0A\00"
@.str.4 = [16 x i8] c"%2d%14d%21.16f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 0, i32* %1
br label %8
8: ; preds = %21, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
store i32 0, i32* %1
br label %50
14: ; preds = %8
br label %15
15: ; preds = %14
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 2
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 46
br label %21
21: ; preds = %18, %15
%22 = phi i1 [ true, %15 ], [ %20, %18 ]
br i1 %22, label %8, label %23
23: ; preds = %21
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 1)
store i32 0, i32* %6
store i32 1, i32* %5
store i32 2, i32* %3
br label %27
27: ; preds = %46, %23
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %49
31: ; preds = %27
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = add nsw i32 %32, %33
store i32 %34, i32* %4
%35 = load i32, i32* %4
%36 = sitofp i32 %35 to double
%37 = load i32, i32* %5
%38 = sitofp i32 %37 to double
%39 = fdiv double %36, %38
store double %39, double* %7
%40 = load i32, i32* %3
%41 = load i32, i32* %4
%42 = load double, double* %7
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %41, double %42)
%44 = load i32, i32* %5
store i32 %44, i32* %6
%45 = load i32, i32* %4
store i32 %45, i32* %5
br label %46
46: ; preds = %31
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %27
49: ; preds = %27
store i32 0, i32* %1
br label %50
50: ; preds = %49, %13
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str = [62 x i8] c"Enter an integer between 2 and 46, inclusive (or 0 to quit): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [30 x i8] c"%2d%14d N/A\0A\00"
@.str.4 = [16 x i8] c"%2d%14d%21.16f\0A\00"
@str = [115 x i8] c"\0A Fibonacci Fibonacci\0A N number quotient\0A-------------------------------------\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %8, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %29, label %8
8: ; preds = %3
%9 = add i32 %6, -47
%10 = icmp ult i32 %9, -45
br i1 %10, label %3, label %11
11: ; preds = %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([115 x i8], [115 x i8]* @str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 1)
%15 = load i32, i32* %1
%16 = icmp slt i32 %15, 2
br i1 %16, label %29, label %17
17: ; preds = %11, %17
%18 = phi i32 [ %19, %17 ], [ 0, %11 ]
%19 = phi i32 [ %21, %17 ], [ 1, %11 ]
%20 = phi i32 [ %26, %17 ], [ 2, %11 ]
%21 = add nsw i32 %18, %19
%22 = sitofp i32 %21 to double
%23 = sitofp i32 %19 to double
%24 = fdiv double %22, %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %20, i32 %21, double %24)
%26 = add nuw nsw i32 %20, 1
%27 = load i32, i32* %1
%28 = icmp slt i32 %20, %27
br i1 %28, label %17, label %29
29: ; preds = %3, %17, %11
ret i32 0
}