#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int fib(int, int /*<<< orphan*/, int *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("need 1 integers.\n");
    return EXIT_FAILURE;
  }
  int n, val;
  int maxsize = 1;
  n = (int)strtol(argv[1], NULL, 10);
  val = fib(n, 0, &maxsize);
  printf("fib(%d) = %d. maxsize = %d\n", n, val, maxsize);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116f <main+0x3f>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c3 <main+0x93>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
lea    -0x1c(%rbp),%rdx
call   1050 <fib@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1192 <main+0x52>
movl   $0x1,0xc(%rsp)
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <fib@plt>
mov    0xc(%rsp),%ecx
lea    0xe82(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e48(%rip),%rax
jmp    11a5 <main+0x65>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"need 1 integers.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [28 x i8] c"fib(%d) = %d. maxsize = %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %27
14: ; preds = %2
store i32 1, i32* %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strtol(i8* %17, i32* null, i32 10)
%19 = trunc i64 %18 to i32
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = call i32 @fib(i32 %20, i32 0, i32* %8)
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
%26 = load i32, i32* @EXIT_SUCCESS
store i32 %26, i32* %3
br label %27
27: ; preds = %14, %11
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.1 = [28 x i8] c"fib(%d) = %d. maxsize = %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [17 x i8] c"need 1 integers.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
br label %18
8: ; preds = %2
%9 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strtol(i8* nocapture %11, i32* null, i32 10)
%13 = trunc i64 %12 to i32
%14 = call i32 @fib(i32 %13, i32 0, i32* %3)
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %14, i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
br label %18
18: ; preds = %8, %5
%19 = phi i32 [ %7, %5 ], [ %17, %8 ]
ret i32 %19
}