#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 fib(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int n = 0;
  scanf("%d", &n);
  if (n < 0) {
    fprintf(stderr, "Invalid number (must be >= %d)\n", 0);
    return -1;
  }
  if (n > 1000) {
    fprintf(stderr, "Invalid number (must be < %d)\n", 1000);
    return -1;
  }
  printf("%d\n", fib(n));
  return 0;
}


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)
movl   $0x0,-0x14(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    119a <main+0x5a>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
xor    %edx,%edx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <main+0xaa>
cmpl   $0x3e8,-0x14(%rbp)
jle    11cd <main+0x8d>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
mov    $0x3e8,%edx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <main+0xaa>
mov    -0x14(%rbp),%edi
call   1060 <fib@plt>
mov    %eax,%esi
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeb0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
js     1181 <main+0x41>
cmp    $0x3e9,%edi
jb     119f <main+0x5f>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
mov    $0x3e8,%edx
jmp    1193 <main+0x53>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
xor    %edx,%edx
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
call   1060 <fib@plt>
lea    0xe97(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"Invalid number (must be >= %d)\0A\00"
@.str.2 = [31 x i8] c"Invalid number (must be < %d)\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 0)
store i32 -1, i32* %3
br label %23
13: ; preds = %2
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, 1000
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 1000)
store i32 -1, i32* %3
br label %23
19: ; preds = %13
%20 = load i32, i32* %6
%21 = call i32 @fib(i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %21)
store i32 0, i32* %3
br label %23
23: ; preds = %19, %16, %10
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"Invalid number (must be >= %d)\0A\00"
@.str.2 = [31 x i8] c"Invalid number (must be < %d)\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %19
11: ; preds = %2
%12 = icmp ugt i32 %6, 1000
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 1000)
br label %19
16: ; preds = %11
%17 = call i32 @fib(i32 %6)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %13, %8
%20 = phi i32 [ -1, %8 ], [ -1, %13 ], [ 0, %16 ]
ret i32 %20
}