#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 atoi(char *);
int /*<<< orphan*/ fibonacci(int, int *, int);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ print_array(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Usage:\n> fibonacci N\n\nWhere N >= 0\n");
    return 1;
  }
  char *cn = argv[1];
  if (!isdigit(*cn)) {
    printf("'%c' is not a number\n", *cn);
    return 1;
  }
  int n = atoi(cn);
  if (n < 0) {
    printf("Number have to be greater or equal to 0\n");
    return 1;
  }
  int seq[n];
  seq[0] = 0;
  seq[1] = 1;
  fibonacci(n, seq, 2);
  print_array(seq, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118a <main+0x3a>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1257 <main+0x107>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11cc <main+0x7c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1257 <main+0x107>
mov    -0x18(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11fc <main+0xac>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1257 <main+0x107>
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,(%rsi)
movl   $0x1,0x4(%rsi)
mov    -0x1c(%rbp),%edi
mov    $0x2,%edx
call   1060 <fibonacci@plt>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <print_array@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11de <main+0x7e>
mov    0x8(%rsi),%rbx
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11e7 <main+0x87>
mov    %rbx,%rdi
call   1080 <atoi@plt>
test   %eax,%eax
js     11fa <main+0x9a>
mov    %eax,%r14d
mov    %rsp,%r15
mov    %eax,%eax
mov    %rsp,%rcx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rcx,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
neg    %rax
movabs $0x100000000,%rdx
mov    %rdx,(%rcx,%rax,1)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1070 <fibonacci@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <print_array@plt>
xor    %eax,%eax
mov    %r15,%rsp
jmp    120b <main+0xab>
lea    0xe59(%rip),%rdi
jmp    1201 <main+0xa1>
movsbl (%rbx),%esi
lea    0xe0f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1206 <main+0xa6>
lea    0xe15(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Usage:\0A> fibonacci N\0A\0AWhere N >= 0\0A\00"
@.str.1 = [22 x i8] c"'%c' is not a number\0A\00"
@.str.2 = [41 x i8] c"Number have to be greater or equal to 0\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %46
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = call i32 @isdigit(i8 signext %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %14
%23 = load i8*, i8** %6
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %25)
store i32 1, i32* %3
br label %46
27: ; preds = %14
%28 = load i8*, i8** %6
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %46
34: ; preds = %27
%35 = load i32, i32* %7
%36 = zext i32 %35 to i64
%37 = call i8* @llvm.stacksave()
store i8* %37, i8** %8
%38 = alloca i32, i64 %36
store i64 %36, i64* %9
%39 = getelementptr inbounds i32, i32* %38, i64 0
store i32 0, i32* %39
%40 = getelementptr inbounds i32, i32* %38, i64 1
store i32 1, i32* %40
%41 = load i32, i32* %7
%42 = call i32 @fibonacci(i32 %41, i32* %38, i32 2)
%43 = load i32, i32* %7
%44 = call i32 @print_array(i32* %38, i32 %43)
store i32 0, i32* %3
%45 = load i8*, i8** %8
br label %46
46: ; preds = %34, %32, %22, %12
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"'%c' is not a number\0A\00"
@str = [40 x i8] c"Number have to be greater or equal to 0\00"
@str.3 = [35 x i8] c"Usage:\0A> fibonacci N\0A\0AWhere N >= 0\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.3, i64 0, i64 0))
br label %28
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = tail call i32 @isdigit(i8 signext %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = load i8, i8* %8
%14 = sext i8 %13 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %28
16: ; preds = %6
%17 = tail call i32 @atoi(i8* %8)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %28
21: ; preds = %16
%22 = zext i32 %17 to i64
%23 = tail call i8* @llvm.stacksave()
%24 = alloca i32, i64 %22
store i32 0, i32* %24
%25 = getelementptr inbounds i32, i32* %24, i64 1
store i32 1, i32* %25
%26 = call i32 @fibonacci(i32 %17, i32* %24, i32 2)
%27 = call i32 @print_array(i32* %24, i32 %17)
br label %28
28: ; preds = %12, %21, %19, %4
%29 = phi i32 [ 1, %4 ], [ 1, %12 ], [ 1, %19 ], [ 0, %21 ]
ret i32 %29
}