#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*/ fillFibonacci(int *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int strtol(char *, char **, int);
int main(int ArgCount, char *ArgVals[]) {
  if (ArgCount < 2) {
    fprintf(stderr, "Usage: %s SequenceSize\n", ArgVals[0]);
    return 1;
  }
  int SequenceSize;
  char *EndRead;
  SequenceSize = strtol(ArgVals[1], &EndRead, 10);
  if (EndRead == ArgVals[1]) {
    fprintf(stderr, "Invalid SequenceSize given\n");
    return 1;
  }
  int *FibonacciBuffer = malloc(sizeof(*FibonacciBuffer) * SequenceSize);
  fillFibonacci(FibonacciBuffer, SequenceSize);
  for (int Index = 0; Index < SequenceSize; ++Index) {
    printf("%d ", FibonacciBuffer[Index]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119a <main+0x4a>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1246 <main+0xf6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%rax
jne    11e8 <main+0x98>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1246 <main+0xf6>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <fillFibonacci@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    123f <main+0xef>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    120e <main+0xbe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     118a <main+0x3a>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe88(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%r14d
jmp    1219 <main+0xc9>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rax
cmp    0x8(%rbx),%rax
je     11f7 <main+0xa7>
lea    0x0(,%r14,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r14d,%esi
call   1030 <fillFibonacci@plt>
test   %r14d,%r14d
jle    1216 <main+0xc6>
mov    %r14d,%r13d
xor    %r14d,%r14d
lea    0xe5c(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11e0 <main+0x90>
jmp    1219 <main+0xc9>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%r14d
jmp    1219 <main+0xc9>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s SequenceSize\0A\00"
@.str.1 = [28 x i8] c"Invalid SequenceSize given\0A\00"
@.str.2 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %55
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strtol(i8* %21, i8** %7, i32 10)
store i32 %22, i32* %6
%23 = load i8*, i8** %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = icmp eq i8* %23, %26
br i1 %27, label %28, label %31
28: ; preds = %18
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %55
31: ; preds = %18
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = mul i64 4, %33
%35 = trunc i64 %34 to i32
%36 = call i32* @malloc(i32 %35)
store i32* %36, i32** %8
%37 = load i32*, i32** %8
%38 = load i32, i32* %6
%39 = call i32 @fillFibonacci(i32* %37, i32 %38)
store i32 0, i32* %9
br label %40
40: ; preds = %51, %31
%41 = load i32, i32* %9
%42 = load i32, i32* %6
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %54
44: ; preds = %40
%45 = load i32*, i32** %8
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %44
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %40
54: ; preds = %40
store i32 0, i32* %3
br label %55
55: ; preds = %54, %28, %12
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s SequenceSize\0A\00"
@.str.1 = [28 x i8] c"Invalid SequenceSize given\0A\00"
@.str.2 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %36
9: ; preds = %2
%10 = bitcast i8** %3 to i8*
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strtol(i8* %12, i8** %3, i32 10)
%14 = load i8*, i8** %3
%15 = load i8*, i8** %11
%16 = icmp eq i8* %14, %15
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %34
20: ; preds = %9
%21 = shl i32 %13, 2
%22 = tail call i32* @malloc(i32 %21)
%23 = tail call i32 @fillFibonacci(i32* %22, i32 %13)
%24 = icmp sgt i32 %13, 0
br i1 %24, label %25, label %34
25: ; preds = %20
%26 = zext i32 %13 to i64
br label %27
27: ; preds = %25, %27
%28 = phi i64 [ 0, %25 ], [ %32, %27 ]
%29 = getelementptr inbounds i32, i32* %22, i64 %28
%30 = load i32, i32* %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = add nuw nsw i64 %28, 1
%33 = icmp eq i64 %32, %26
br i1 %33, label %34, label %27
34: ; preds = %27, %20, %17
%35 = phi i32 [ 1, %17 ], [ 0, %20 ], [ 0, %27 ]
br label %36
36: ; preds = %34, %5
%37 = phi i32 [ 1, %5 ], [ %35, %34 ]
ret i32 %37
}