#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fibgen(unsigned long);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
unsigned long strtoul(char *, char **, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  unsigned long n;
  char *endptr;
  if (argc != 2) {
    usage(argv[0]);
    exit(EXIT_FAILURE);
  }
  errno = 0;
  n = strtoul(argv[1], &endptr, 10);
  if (errno || *endptr || !*argv[1]) {
    fprintf(stderr, "Bad number given.\n");
    usage(argv[0]);
    exit(EXIT_FAILURE);
  }
  if (n > 40) {
    fprintf(stderr, "I see you gave a number higher than 40.\n"
                    "I also like to live dangerously.\n");
    exit(EXIT_FAILURE);
  }
  fibgen(n);
  exit(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     118a <main+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2e47(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e1f(%rip),%rax
cmpq   $0x0,(%rax)
jne    11e4 <main+0x94>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11e4 <main+0x94>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
cmpb   $0x0,(%rax)
jne    1213 <main+0xc3>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
cmpq   $0x28,-0x18(%rbp)
jbe    1241 <main+0xf1>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fibgen@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11a8 <main+0x58>
mov    0x2e75(%rip),%r14
movq   $0x0,(%r14)
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
cmpq   $0x0,(%r14)
jne    1193 <main+0x43>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1193 <main+0x43>
mov    0x8(%rbx),%rcx
cmpb   $0x0,(%rcx)
jne    11be <main+0x6e>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%rdi
call   1050 <usage@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
cmp    $0x29,%rax
jb     11db <main+0x8b>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11b0 <main+0x60>
mov    %rax,%rdi
call   1030 <fibgen@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@stderr = global i32 0
@.str = [19 x i8] c"Bad number given.\0A\00"
@.str.1 = [74 x i8] c"I see you gave a number higher than 40.\0AI also like to live dangerously.\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 i64
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @usage(i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
store i64 0, i64* @errno
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strtoul(i8* %20, i8** %7, i32 10)
store i64 %21, i64* %6
%22 = load i64, i64* @errno
%23 = icmp ne i64 %22, 0
br i1 %23, label %35, label %24
24: ; preds = %17
%25 = load i8*, i8** %7
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %24
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
br i1 %34, label %44, label %35
35: ; preds = %29, %24, %17
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @usage(i8* %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %29
%45 = load i64, i64* %6
%46 = icmp ugt i64 %45, 40
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %44
%53 = load i64, i64* %6
%54 = call i32 @fibgen(i64 %53)
%55 = load i32, i32* @EXIT_SUCCESS
%56 = call i32 @exit(i32 %55)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@stderr = global i32 0
@.str = [19 x i8] c"Bad number given.\0A\00"
@.str.1 = [74 x i8] c"I see you gave a number higher than 40.\0AI also like to live dangerously.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @usage(i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
store i64 0, i64* @errno
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strtoul(i8* %13, i8** %3, i32 10)
%15 = load i64, i64* @errno
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8*, i8** %12
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %21, %17, %11
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%28 = load i8*, i8** %1
%29 = tail call i32 @usage(i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %21
%33 = icmp ugt i64 %14, 40
br i1 %33, label %34, label %39
34: ; preds = %32
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = tail call i32 @exit(i32 %37)
unreachable
39: ; preds = %32
%40 = tail call i32 @fibgen(i64 %14)
%41 = load i32, i32* @EXIT_SUCCESS
%42 = tail call i32 @exit(i32 %41)
unreachable
}