#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 i, a, b, res;
  const int N = 4000000;
  res = 0;
  a = 1;
  b = 2;
  while (b <= N) {
    if (b % 2 == 0)
      res += b;
    int tmp = b;
    b = b + a;
    a = tmp;
  }
  printf("%d", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3d0900,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
cmpl   $0x3d0900,-0x10(%rbp)
jg     117f <main+0x6f>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1165 <main+0x55>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    113b <main+0x2b>
mov    -0x14(%rbp),%esi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
xor    %esi,%esi
mov    $0x2,%eax
mov    $0x1,%ecx
nopl   0x0(%rax)
test   $0x1,%al
mov    $0x0,%edx
cmove  %eax,%edx
add    %edx,%esi
mov    %ecx,%edx
add    %eax,%edx
mov    %eax,%ecx
mov    %edx,%eax
cmp    $0x3d0901,%edx
jl     1120 <main+0x10>
push   %rax
lea    0xebc(%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 i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 4000000, i32* %6
store i32 0, i32* %5
store i32 1, i32* %3
store i32 2, i32* %4
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %4
%10 = icmp sle i32 %9, 4000000
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i32, i32* %4
%13 = srem i32 %12, 2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = add nsw i32 %17, %16
store i32 %18, i32* %5
br label %19
19: ; preds = %15, %11
%20 = load i32, i32* %4
store i32 %20, i32* %7
%21 = load i32, i32* %4
%22 = load i32, i32* %3
%23 = add nsw i32 %21, %22
store i32 %23, i32* %4
%24 = load i32, i32* %7
store i32 %24, i32* %3
br label %8
25: ; preds = %8
%26 = load i32, i32* %5
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %26)
ret i32 0
}

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