#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 cache[35] = {0};
  cache[0] = 0;
  cache[1] = 1;
  cache[2] = 1;
  int sum = 0;
  const int max = 4000000;
  for (int i = 3; sum < max; ++i) {
    int old = cache[i - 2];
    int mid = cache[i - 1];
    int new = old + mid;
    cache[i] = new;
    if (new % 2 == 0)
      sum += new;
  }
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x8c,%edx
call   1040 <memset@plt>
movl   $0x0,-0x90(%rbp)
movl   $0x1,-0x8c(%rbp)
movl   $0x1,-0x88(%rbp)
movl   $0x0,-0x94(%rbp)
movl   $0x3d0900,-0x98(%rbp)
movl   $0x3,-0x9c(%rbp)
cmpl   $0x3d0900,-0x94(%rbp)
jge    1229 <main+0x109>
mov    -0x9c(%rbp),%eax
sub    $0x2,%eax
cltq
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0xa0(%rbp)
mov    -0x9c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0xa4(%rbp)
mov    -0xa0(%rbp),%eax
add    -0xa4(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0xa8(%rbp),%ecx
movslq -0x9c(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
mov    -0xa8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1210 <main+0xf0>
mov    -0xa8(%rbp),%eax
add    -0x94(%rbp),%eax
mov    %eax,-0x94(%rbp)
jmp    1215 <main+0xf5>
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1181 <main+0x61>
mov    -0x94(%rbp),%esi
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

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

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

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