#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() {
  int number = 0, fibonacciInput = 0, fibonacciA = 1, fibonacciB = 1,
      fibonacciC = 0;
  printf("Please enter a Fibonacci number: ");
  scanf("%d", &fibonacciInput);
  if (fibonacciInput < 0) {
    printf("1, 1\n");
  } else if (fibonacciInput == 0) {
    printf("1, 1\n");
  } else {
    for (number = 3; fibonacciC <= fibonacciInput; number++) {
      fibonacciC = fibonacciA + fibonacciB;
      fibonacciA = fibonacciB;
      fibonacciB = fibonacciC;
    }
    if ((fibonacciC - fibonacciInput) < (fibonacciInput - fibonacciA)) {
      printf("%d, %d", fibonacciC, number - 1);
    } else if ((fibonacciC - fibonacciInput) > (fibonacciInput - fibonacciA)) {
      printf("%d, %d", fibonacciA, number - 2);
    } else if ((fibonacciC - fibonacciInput) == (fibonacciInput - fibonacciA)) {
      printf("%d, %d", fibonacciA, number - 2);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    118d <main+0x6d>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127f <main+0x15f>
cmpl   $0x0,-0xc(%rbp)
jne    11aa <main+0x8a>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127a <main+0x15a>
movl   $0x3,-0x8(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11e0 <main+0xc0>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b1 <main+0x91>
mov    -0x18(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    1210 <main+0xf0>
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1275 <main+0x155>
mov    -0x18(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jle    1240 <main+0x120>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    $0x2,%edx
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1270 <main+0x150>
mov    -0x18(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jne    126b <main+0x14b>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    $0x2,%edx
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1270 <main+0x150>
jmp    1275 <main+0x155>
jmp    127a <main+0x15a>
jmp    127f <main+0x15f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
js     11a2 <main+0x72>
je     11a2 <main+0x72>
mov    $0x1,%eax
mov    $0x2,%edx
mov    $0x1,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %esi,%edi
mov    %eax,%esi
mov    %edi,%eax
add    %esi,%eax
add    $0x1,%edx
mov    %eax,%edi
sub    %ecx,%edi
jle    1180 <main+0x50>
sub    %esi,%ecx
cmp    %ecx,%edi
jge    11b0 <main+0x80>
lea    0xe84(%rip),%rdi
mov    %eax,%esi
jmp    11be <main+0x8e>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
jmp    11c5 <main+0x95>
jg     11b4 <main+0x84>
jne    11c5 <main+0x95>
add    $0xffffffff,%edx
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Please enter a Fibonacci number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"1, 1\0A\00"
@.str.3 = [7 x i8] c"%d, %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
store i32 1, i32* %5
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %75
13: ; preds = %0
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %74
18: ; preds = %13
store i32 3, i32* %2
br label %19
19: ; preds = %29, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %3
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = add nsw i32 %24, %25
store i32 %26, i32* %6
%27 = load i32, i32* %5
store i32 %27, i32* %4
%28 = load i32, i32* %6
store i32 %28, i32* %5
br label %29
29: ; preds = %23
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %19
32: ; preds = %19
%33 = load i32, i32* %6
%34 = load i32, i32* %3
%35 = sub nsw i32 %33, %34
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = sub nsw i32 %36, %37
%39 = icmp slt i32 %35, %38
br i1 %39, label %40, label %45
40: ; preds = %32
%41 = load i32, i32* %6
%42 = load i32, i32* %2
%43 = sub nsw i32 %42, 1
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %43)
br label %73
45: ; preds = %32
%46 = load i32, i32* %6
%47 = load i32, i32* %3
%48 = sub nsw i32 %46, %47
%49 = load i32, i32* %3
%50 = load i32, i32* %4
%51 = sub nsw i32 %49, %50
%52 = icmp sgt i32 %48, %51
br i1 %52, label %53, label %58
53: ; preds = %45
%54 = load i32, i32* %4
%55 = load i32, i32* %2
%56 = sub nsw i32 %55, 2
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %54, i32 %56)
br label %72
58: ; preds = %45
%59 = load i32, i32* %6
%60 = load i32, i32* %3
%61 = sub nsw i32 %59, %60
%62 = load i32, i32* %3
%63 = load i32, i32* %4
%64 = sub nsw i32 %62, %63
%65 = icmp eq i32 %61, %64
br i1 %65, label %66, label %71
66: ; preds = %58
%67 = load i32, i32* %4
%68 = load i32, i32* %2
%69 = sub nsw i32 %68, 2
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %67, i32 %69)
br label %71
71: ; preds = %66, %58
br label %72
72: ; preds = %71, %53
br label %73
73: ; preds = %72, %40
br label %74
74: ; preds = %73, %16
br label %75
75: ; preds = %74, %11
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Please enter a Fibonacci number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [7 x i8] c"%d, %d\00"
@str.4 = [5 x i8] c"1, 1\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.4, i64 0, i64 0))
br label %36
9: ; preds = %0
%10 = icmp eq i32 %5, 0
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.4, i64 0, i64 0))
br label %36
13: ; preds = %9, %13
%14 = phi i32 [ %17, %13 ], [ 1, %9 ]
%15 = phi i32 [ %14, %13 ], [ 1, %9 ]
%16 = phi i32 [ %18, %13 ], [ 3, %9 ]
%17 = add nsw i32 %14, %15
%18 = add nuw nsw i32 %16, 1
%19 = icmp sgt i32 %17, %5
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = sub nsw i32 %17, %5
%22 = sub nsw i32 %5, %14
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %16)
br label %36
26: ; preds = %20
%27 = icmp sgt i32 %21, %22
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = add nsw i32 %16, -1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 %29)
br label %36
31: ; preds = %26
%32 = icmp eq i32 %21, %22
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = add nsw i32 %16, -1
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 %34)
br label %36
36: ; preds = %11, %28, %33, %31, %24, %7
ret i32 0
}