#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 fib(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  long sum = 0;
  printf("Please input an integer:");
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    sum += fib(i);
    printf("%ld+", fib(i));
  }
  printf("\b=%ld", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11af <main+0x7f>
mov    -0x14(%rbp),%edi
call   1050 <fib@plt>
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <fib@plt>
mov    %rax,%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <main+0x3c>
mov    -0x10(%rbp),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1199 <main+0x69>
lea    0xeb7(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebp,%edi
call   1050 <fib@plt>
add    %rax,%rbx
mov    %ebp,%edi
call   1050 <fib@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1170 <main+0x40>
jmp    119b <main+0x6b>
xor    %ebx,%ebx
lea    0xe7f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Please input an integer:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%ld+\00"
@.str.3 = [6 x i8] c"\08=%ld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
br label %7
7: ; preds = %19, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = load i32, i32* %4
%13 = call i64 @fib(i32 %12)
%14 = load i64, i64* %3
%15 = add nsw i64 %14, %13
store i64 %15, i64* %3
%16 = load i32, i32* %4
%17 = call i64 @fib(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %17)
br label %19
19: ; preds = %11
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %7
22: ; preds = %7
%23 = load i64, i64* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Please input an integer:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%ld+\00"
@.str.3 = [6 x i8] c"\08=%ld\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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 sgt i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %10, %0
%8 = phi i64 [ 0, %0 ], [ %14, %10 ]
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %8)
ret i32 0
10: ; preds = %0, %10
%11 = phi i32 [ %17, %10 ], [ 0, %0 ]
%12 = phi i64 [ %14, %10 ], [ 0, %0 ]
%13 = call i64 @fib(i32 %11)
%14 = add nsw i64 %13, %12
%15 = call i64 @fib(i32 %11)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %15)
%17 = add nuw nsw i32 %11, 1
%18 = load i32, i32* %1
%19 = icmp slt i32 %17, %18
br i1 %19, label %10, label %7
}