#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 n, first = 0, second = 1, next, c;
  printf("This program needs 1 initial digit(s) to provide Fibonacci Series "
         "for you\n\n");
  printf("Enter the number of terms\n");
  scanf("%d", &n);
  printf("First %d terms of Fibonacci series are :\n", n);
  for (c = 0; c < n; c++) {
    if (c <= 1)
      next = c;
    else {
      next = first + second;
      first = second;
      second = next;
    }
    printf("%d\n", next);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf07(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d6 <main+0xb6>
cmpl   $0x1,-0x18(%rbp)
jg     11a2 <main+0x82>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11b7 <main+0x97>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%esi
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1181 <main+0x61>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf32(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaa(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11b4 <main+0x84>
mov    $0x1,%ebx
lea    0xea8(%rip),%r14
xor    %ebp,%ebp
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%r15,1),%esi
cmp    $0x2,%ebp
cmovae %ebx,%r15d
cmovae %esi,%ebx
cmovb  %ebp,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1190 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [76 x i8] c"This program needs 1 initial digit(s) to provide Fibonacci Series for you\0A\0A\00"
@.str.1 = [27 x i8] c"Enter the number of terms\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [42 x i8] c"First %d terms of Fibonacci series are :\0A\00"
@.str.4 = [4 x i8] c"%d\0A\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* %3
store i32 1, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %10)
store i32 0, i32* %6
br label %12
12: ; preds = %30, %0
%13 = load i32, i32* %6
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = load i32, i32* %6
%18 = icmp sle i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load i32, i32* %6
store i32 %20, i32* %5
br label %27
21: ; preds = %16
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = add nsw i32 %22, %23
store i32 %24, i32* %5
%25 = load i32, i32* %4
store i32 %25, i32* %3
%26 = load i32, i32* %5
store i32 %26, i32* %4
br label %27
27: ; preds = %21, %19
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %12
33: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [42 x i8] c"First %d terms of Fibonacci series are :\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [75 x i8] c"This program needs 1 initial digit(s) to provide Fibonacci Series for you\0A\00"
@str.5 = [26 x i8] c"Enter the number of terms\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.5, 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 i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %0, %10
%11 = phi i32 [ %20, %10 ], [ 0, %0 ]
%12 = phi i32 [ %17, %10 ], [ 1, %0 ]
%13 = phi i32 [ %16, %10 ], [ 0, %0 ]
%14 = icmp ult i32 %11, 2
%15 = add nsw i32 %12, %13
%16 = select i1 %14, i32 %13, i32 %12
%17 = select i1 %14, i32 %12, i32 %15
%18 = select i1 %14, i32 %11, i32 %15
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i32 %11, 1
%21 = load i32, i32* %1
%22 = icmp slt i32 %20, %21
br i1 %22, label %10, label %23
23: ; preds = %10, %0
ret i32 0
}