#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 Fibonacci(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void ComputeFibonacci() {
  int input, i, output;
  printf("1- Compute nth term\n2- Compute Fibonacci till nth term\n\n\n Enter "
         "Choice\n>>");
  scanf("%d", &input);
  if (input == 1) {
    printf("Enter Number\n\n>>");
    scanf("%d", &input);
    printf("The %dth term Fibonacci is %dof \n\n>>", input, Fibonacci(input));
  } else if (input == 2) {
    printf("Enter Number\n\n>>");
    scanf("%d", &input);
    printf("Fibonacci till %dth term\\n\n>>", input);
    for (i = 0; i <= input; i++) {
      printf("%d", Fibonacci(i));
    }
  }
}


x86 assembly (clang, -O0):
<ComputeFibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xefd(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11a4 <ComputeFibonacci+0x74>
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <Fibonacci@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1220 <ComputeFibonacci+0xf0>
cmpl   $0x2,-0x4(%rbp)
jne    121b <ComputeFibonacci+0xeb>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1216 <ComputeFibonacci+0xe6>
mov    -0x8(%rbp),%edi
call   1030 <Fibonacci@plt>
mov    %eax,%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e4 <ComputeFibonacci+0xb4>
jmp    121b <ComputeFibonacci+0xeb>
jmp    1220 <ComputeFibonacci+0xf0>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComputeFibonacci>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf01(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     11a3 <ComputeFibonacci+0x73>
cmp    $0x1,%eax
jne    120c <ComputeFibonacci+0xdc>
lea    0xee1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ebx
mov    %ebx,%edi
call   1030 <Fibonacci@plt>
lea    0xec8(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    120c <ComputeFibonacci+0xdc>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe92(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x4(%rsp)
js     120c <ComputeFibonacci+0xdc>
mov    $0xffffffff,%ebx
lea    0xe63(%rip),%r14
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %ebx,%edi
call   1030 <Fibonacci@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0x4(%rsp),%ebx
jl     11f0 <ComputeFibonacci+0xc0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [74 x i8] c"1- Compute nth term\0A2- Compute Fibonacci till nth term\0A\0A\0A Enter Choice\0A>>\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"Enter Number\0A\0A>>\00"
@.str.3 = [37 x i8] c"The %dth term Fibonacci is %dof \0A\0A>>\00"
@.str.4 = [30 x i8] c"Fibonacci till %dth term\\n\0A>>\00"
define void @ComputeFibonacci() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 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, 1
br i1 %7, label %8, label %15
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = load i32, i32* %1
%13 = call i32 @Fibonacci(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %13)
br label %36
15: ; preds = %0
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %21)
store i32 0, i32* %2
br label %23
23: ; preds = %31, %18
%24 = load i32, i32* %2
%25 = load i32, i32* %1
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %34
27: ; preds = %23
%28 = load i32, i32* %2
%29 = call i32 @Fibonacci(i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %27
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %23
34: ; preds = %23
br label %35
35: ; preds = %34, %15
br label %36
36: ; preds = %35, %8
ret void
}

LLVM IR (-O2):
@.str = [74 x i8] c"1- Compute nth term\0A2- Compute Fibonacci till nth term\0A\0A\0A Enter Choice\0A>>\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"Enter Number\0A\0A>>\00"
@.str.3 = [37 x i8] c"The %dth term Fibonacci is %dof \0A\0A>>\00"
@.str.4 = [30 x i8] c"Fibonacci till %dth term\\n\0A>>\00"
define void @ComputeFibonacci() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 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
switch i32 %5, label %26 [
i32 1, label %6
i32 2, label %12
]
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = call i32 @Fibonacci(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %10)
br label %26
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %1
%18 = icmp slt i32 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %12, %19
%20 = phi i32 [ %23, %19 ], [ 0, %12 ]
%21 = call i32 @Fibonacci(i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i32 %20, 1
%24 = load i32, i32* %1
%25 = icmp slt i32 %20, %24
br i1 %25, label %19, label %26
26: ; preds = %19, %12, %0, %6
ret void
}