#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 */
long long fibonacci(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int userNumber;
  long long int result;
  printf("\n");
  printf("Enter a number to calculate its Fibonacci number: ");
  scanf("%i", &userNumber);
  result = fibonacci(userNumber);
  printf("\n");
  if (result == -1)
    printf("Invalid Number");
  else if (result < -1)
    printf("Result overflows long long int: %lld", result);
  else
    printf("Result is %lld", result);
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1040 <fibonacci@plt>
mov    %rax,-0x10(%rbp)
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0xffffffffffffffff,-0x10(%rbp)
jne    11a3 <main+0x73>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <main+0xac>
cmpq   $0xffffffffffffffff,-0x10(%rbp)
jge    11c5 <main+0x95>
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d7 <main+0xa7>
mov    -0x10(%rbp),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <main+0xac>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
call   1060 <fibonacci@plt>
mov    %rax,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0xffffffffffffffff,%rbx
je     11a5 <main+0x55>
jge    11b5 <main+0x65>
lea    0xea2(%rip),%rdi
jmp    11bc <main+0x6c>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c6 <main+0x76>
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeac(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [51 x i8] c"Enter a number to calculate its Fibonacci number: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [15 x i8] c"Invalid Number\00"
@.str.4 = [37 x i8] c"Result overflows long long int: %lld\00"
@.str.5 = [15 x i8] c"Result is %lld\00"
@.str.6 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = call i64 @fibonacci(i32 %7)
store i64 %8, i64* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = load i64, i64* %3
%11 = icmp eq i64 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %24
14: ; preds = %0
%15 = load i64, i64* %3
%16 = icmp slt i64 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i64, i64* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i64 %18)
br label %23
20: ; preds = %14
%21 = load i64, i64* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i64 %21)
br label %23
23: ; preds = %20, %17
br label %24
24: ; preds = %23, %12
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [51 x i8] c"Enter a number to calculate its Fibonacci number: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [15 x i8] c"Invalid Number\00"
@.str.4 = [37 x i8] c"Result overflows long long int: %lld\00"
@.str.5 = [15 x i8] c"Result is %lld\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i64 @fibonacci(i32 %6)
%8 = call i32 @putchar(i32 10)
%9 = icmp eq i64 %7, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %18
12: ; preds = %0
%13 = icmp slt i64 %7, -1
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i64 %7)
br label %18
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i64 %7)
br label %18
18: ; preds = %14, %16, %10
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}