#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*/ num_fibonacci(int);
int /*<<< orphan*/ print_fibonacci_series(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sum_even_fibonacci(int, int, int);
int main() {
  int limit;
  print_fibonacci_series(-1, 1);
  printf("\n\nSum of even fibonacci up to %d is %lu", 4000000,
         sum_even_fibonacci(1, 1, 2));
  printf("\n\nEnter N to print N fibonacci numbers: ");
  scanf("%d", &limit);
  for (int i = 0; i < limit; i++) {
    printf("%lu ", num_fibonacci(i));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1030 <print_fibonacci_series@plt>
mov    $0x1,%esi
mov    $0x2,%edx
mov    %esi,%edi
call   1040 <sum_even_fibonacci@plt>
mov    %eax,%edx
lea    0xe78(%rip),%rdi
mov    $0x3d0900,%esi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11eb <main+0x9b>
mov    -0xc(%rbp),%edi
call   1060 <num_fibonacci@plt>
mov    %eax,%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b9 <main+0x69>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1030 <print_fibonacci_series@plt>
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x2,%edx
call   1040 <sum_even_fibonacci@plt>
lea    0xe83(%rip),%rdi
mov    $0x3d0900,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11dc <main+0x8c>
lea    0xe9c(%rip),%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1060 <num_fibonacci@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     11c0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"\0A\0ASum of even fibonacci up to %d is %lu\00"
@.str.1 = [41 x i8] c"\0A\0AEnter N to print N fibonacci numbers: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"%lu \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @print_fibonacci_series(i32 -1, i32 1)
%5 = call i32 @sum_even_fibonacci(i32 1, i32 1, i32 2)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 4000000, i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %9
9: ; preds = %17, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i32, i32* %3
%15 = call i32 @num_fibonacci(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %13
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %9
20: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"\0A\0ASum of even fibonacci up to %d is %lu\00"
@.str.1 = [41 x i8] c"\0A\0AEnter N to print N fibonacci numbers: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"%lu \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @print_fibonacci_series(i32 -1, i32 1)
%4 = tail call i32 @sum_even_fibonacci(i32 1, i32 1, i32 2)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 4000000, i32 %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %11, %0
ret i32 0
11: ; preds = %0, %11
%12 = phi i32 [ %15, %11 ], [ 0, %0 ]
%13 = call i32 @num_fibonacci(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i32 %12, 1
%16 = load i32, i32* %1
%17 = icmp slt i32 %15, %16
br i1 %17, label %11, label %10
}