#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*/ printf(char *, int);
int main(int argc, char **argv) {
  int f[3] = {3, 2, 1};
  int answer = 2;
  while ((f[0] = f[1] + f[2]) < 4e6) {
    if (f[0] % 2 == 0)
      answer += f[0];
    f[2] = f[1];
    f[1] = f[0];
  }
  printf("%i\n", answer);
  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)
mov    0xedb(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xed9(%rip),%eax
mov    %eax,-0x14(%rbp)
movl   $0x2,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sd %eax,%xmm1
movsd  0xeaa(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    118e <main+0x7e>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117d <main+0x6d>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1141 <main+0x31>
mov    -0x20(%rbp),%esi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x2,%esi
mov    $0x3,%ecx
mov    $0x2,%eax
nop
mov    %ecx,%edx
test   $0x1,%dl
mov    $0x0,%ecx
cmove  %edx,%ecx
add    %ecx,%esi
add    %edx,%eax
mov    %eax,%ecx
cmp    $0x3d0900,%eax
mov    %edx,%eax
jl     1120 <main+0x10>
push   %rax
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.f = [3 x i32] [i32 3, i32 2, i32 1]
@.str = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i32]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [3 x i32]* %6 to i8*
store i32 2, i32* %7
br label %9
9: ; preds = %28, %2
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
%13 = load i32, i32* %12
%14 = add nsw i32 %11, %13
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
store i32 %14, i32* %15
%16 = sitofp i32 %14 to double
%17 = fcmp olt double %16, 4.000000e+06
br i1 %17, label %18, label %35
18: ; preds = %9
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%20 = load i32, i32* %19
%21 = srem i32 %20, 2
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%25 = load i32, i32* %24
%26 = load i32, i32* %7
%27 = add nsw i32 %26, %25
store i32 %27, i32* %7
br label %28
28: ; preds = %23, %18
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
%30 = load i32, i32* %29
%31 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
store i32 %30, i32* %31
%32 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%33 = load i32, i32* %32
%34 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
store i32 %33, i32* %34
br label %9
35: ; preds = %9
%36 = load i32, i32* %7
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
ret i32 0
}

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