#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 EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long);
long strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  long n = strtol(argv[1], NULL, 10);
  long a = 0;
  long b = 1;
  long c;
  while (b < n) {
    printf("%ld\n", b);
    c = b;
    b = a + b;
    a = c;
    if (b < 0) {
      printf("E: overflow %ld\n", b);
      exit(EXIT_FAILURE);
    }
  }
  return EXIT_SUCCESS;
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11d8 <main+0xa8>
mov    -0x28(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    11d3 <main+0xa3>
mov    -0x28(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    1170 <main+0x40>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
cmp    $0x2,%rax
jl     116c <main+0x4c>
mov    %rax,%r14
mov    $0x1,%ebx
xor    %r12d,%r12d
lea    0xeb0(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r12,%rax
add    %rbx,%rax
mov    %rbx,%r12
mov    %rax,%rbx
cmp    %r14,%rax
jl     1150 <main+0x30>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [17 x i8] c"E: overflow %ld\0A\00"
@EXIT_FAILURE = global i32 0
@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 i64
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strtol(i8* %12, i32* null, i32 10)
store i64 %13, i64* %6
store i64 0, i64* %7
store i64 1, i64* %8
br label %14
14: ; preds = %33, %2
%15 = load i64, i64* %8
%16 = load i64, i64* %6
%17 = icmp slt i64 %15, %16
br i1 %17, label %18, label %34
18: ; preds = %14
%19 = load i64, i64* %8
%20 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %19)
%21 = load i64, i64* %8
store i64 %21, i64* %9
%22 = load i64, i64* %7
%23 = load i64, i64* %8
%24 = add nsw i64 %22, %23
store i64 %24, i64* %8
%25 = load i64, i64* %9
store i64 %25, i64* %7
%26 = load i64, i64* %8
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %18
%29 = load i64, i64* %8
%30 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64 %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %18
br label %14
34: ; preds = %14
%35 = load i32, i32* @EXIT_SUCCESS
ret i32 %35
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i64 @strtol(i8* nocapture %4, i32* null, i32 10)
%6 = icmp sgt i64 %5, 1
br i1 %6, label %7, label %13
7: ; preds = %2, %7
%8 = phi i64 [ %9, %7 ], [ 0, %2 ]
%9 = phi i64 [ %11, %7 ], [ 1, %2 ]
%10 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = add nuw nsw i64 %8, %9
%12 = icmp slt i64 %11, %5
br i1 %12, label %7, label %13
13: ; preds = %7, %2
%14 = load i32, i32* @EXIT_SUCCESS
ret i32 %14
}