#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(void) {
  int first, second, next, limit;
  printf("How many Numbers in the Series?");
  scanf("%d", &limit);
  first = 0;
  second = 1;
  printf("%d,%d", first, second);
  while (limit > 2) {
    next = first + second;
    printf(",%d", next);
    first = second;
    second = next;
    --limit;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x14(%rbp)
jle    11ad <main+0x8d>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <main+0x4f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xed2(%rip),%rdi
mov    $0x1,%ebx
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x3,0xc(%rsp)
jl     11a4 <main+0x84>
lea    0xeb3(%rip),%r14
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%ecx
lea    -0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
mov    %ebx,%eax
mov    %ebp,%ebx
cmp    $0x3,%ecx
jg     1180 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"How many Numbers in the Series?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"%d,%d\00"
@.str.3 = [4 x i8] c",%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
store i32 0, i32* %2
store i32 1, i32* %3
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9)
br label %11
11: ; preds = %14, %0
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 2
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = add nsw i32 %15, %16
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %3
store i32 %20, i32* %2
%21 = load i32, i32* %4
store i32 %21, i32* %3
%22 = load i32, i32* %5
%23 = add nsw i32 %22, -1
store i32 %23, i32* %5
br label %11
24: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"How many Numbers in the Series?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"%d,%d\00"
@.str.3 = [4 x i8] c",%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 2
br i1 %7, label %8, label %16
8: ; preds = %0, %8
%9 = phi i32 [ %10, %8 ], [ 0, %0 ]
%10 = phi i32 [ %11, %8 ], [ 1, %0 ]
%11 = add nsw i32 %9, %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %1
%14 = add nsw i32 %13, -1
store i32 %14, i32* %1
%15 = icmp sgt i32 %13, 3
br i1 %15, label %8, label %16
16: ; preds = %8, %0
ret i32 0
}