#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 *, long long);
int main() {
  int a = 1, b = 2;
  int c = a + b;
  long long int sum = 2;
  while (c <= 4000000) {
    if (c % 2 == 0)
      sum += c;
    a = b;
    b = c;
    c = a + b;
  }
  printf("%d", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movq   $0x2,-0x18(%rbp)
cmpl   $0x3d0900,-0x10(%rbp)
jg     1185 <main+0x75>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116b <main+0x5b>
movslq -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    113e <main+0x2e>
mov    -0x18(%rbp),%rsi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
store i32 0, i32* %1
store i32 1, i32* %2
store i32 2, i32* %3
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = add nsw i32 %6, %7
store i32 %8, i32* %4
store i64 2, i64* %5
br label %9
9: ; preds = %21, %0
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 4000000
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = load i32, i32* %4
%14 = srem i32 %13, 2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = load i64, i64* %5
%20 = add nsw i64 %19, %18
store i64 %20, i64* %5
br label %21
21: ; preds = %16, %12
%22 = load i32, i32* %3
store i32 %22, i32* %2
%23 = load i32, i32* %4
store i32 %23, i32* %3
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = add nsw i32 %24, %25
store i32 %26, i32* %4
br label %9
27: ; preds = %9
%28 = load i64, i64* %5
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 %28)
%30 = load i32, i32* %1
ret i32 %30
}

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