#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 INT_MAX;
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i, first = 1, previous = 1, next = 1, total = 0;
  for (i = 0; i < INT_MAX; i++) {
    printf("%d", next);
    if (first + previous > 4000000) {
      break;
    } else {
      printf(", ");
    }
    next = first + previous;
    first = previous;
    previous = next;
    if (!(next % 2)) {
      total += next;
    }
  }
  printf("\n");
  printf("\n");
  printf("%d\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e9c(%rip),%rcx
cmp    (%rcx),%eax
jge    11ce <main+0xbe>
mov    -0x14(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
cmp    $0x3d0900,%eax
jle    117b <main+0x6b>
jmp    11ce <main+0xbe>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11bb <main+0xab>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11c0 <main+0xb0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <main+0x32>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2eb6(%rip),%r12
cmpl   $0x0,(%r12)
jle    119c <main+0x7c>
mov    $0x1,%ebp
xor    %r13d,%r13d
mov    $0x1,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r15d,%r14d
mov    %ebp,%r15d
lea    0xea3(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%ebp
add    %r15d,%ebp
cmp    $0x3d0900,%ebp
jg     119f <main+0x7f>
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bpl
mov    $0x0,%eax
cmove  %ebp,%eax
add    %eax,%r13d
add    $0x1,%ebx
cmp    (%r12),%ebx
jl     1150 <main+0x30>
jmp    119f <main+0x7f>
xor    %r13d,%r13d
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe4c(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
store i32 1, i32* %4
store i32 1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %2
br label %7
7: ; preds = %35, %0
%8 = load i32, i32* %2
%9 = load i32, i32* @INT_MAX
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %38
11: ; preds = %7
%12 = load i32, i32* %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = add nsw i32 %14, %15
%17 = icmp sgt i32 %16, 4000000
br i1 %17, label %18, label %19
18: ; preds = %11
br label %38
19: ; preds = %11
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = add nsw i32 %22, %23
store i32 %24, i32* %5
%25 = load i32, i32* %4
store i32 %25, i32* %3
%26 = load i32, i32* %5
store i32 %26, i32* %4
%27 = load i32, i32* %5
%28 = srem i32 %27, 2
%29 = icmp ne i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %21
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = add nsw i32 %32, %31
store i32 %33, i32* %6
br label %34
34: ; preds = %30, %21
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %7
38: ; preds = %18, %7
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %41)
ret i32 0
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c", \00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = load i32, i32* @INT_MAX
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %20
3: ; preds = %0, %11
%4 = phi i32 [ %16, %11 ], [ 0, %0 ]
%5 = phi i32 [ %9, %11 ], [ 1, %0 ]
%6 = phi i32 [ %5, %11 ], [ 1, %0 ]
%7 = phi i32 [ %17, %11 ], [ 0, %0 ]
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%9 = add nsw i32 %5, %6
%10 = icmp sgt i32 %9, 4000000
br i1 %10, label %20, label %11
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = and i32 %9, 1
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i32 %9, i32 0
%16 = add nsw i32 %15, %4
%17 = add nuw nsw i32 %7, 1
%18 = load i32, i32* @INT_MAX
%19 = icmp slt i32 %17, %18
br i1 %19, label %3, label %20
20: ; preds = %11, %3, %0
%21 = phi i32 [ 0, %0 ], [ %4, %3 ], [ %16, %11 ]
%22 = tail call i32 @putchar(i32 10)
%23 = tail call i32 @putchar(i32 10)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %21)
ret i32 0
}