#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 max = 4000000;
  int total = 0;
  int previous = 1;
  int current = 1;
  while (current < max) {
    int next = current + previous;
    if (!(current % 2))
      total += current;
    previous = current;
    current = next;
  }
  printf("%d\n", total);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3d0900,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    117e <main+0x6e>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116d <main+0x5d>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    113b <main+0x2b>
mov    -0xc(%rbp),%esi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

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