#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);
int main(void) {
  long int fib_1 = 1, fib_2 = 2;
  long int sum = 0;
  long int temp;
  while (fib_2 <= 4000000) {
    if (fib_2 % 2 == 0)
      sum = sum + fib_2;
    temp = fib_1;
    fib_1 = fib_2;
    fib_2 = fib_1 + temp;
  }
  printf("%ld\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x10(%rbp)
movq   $0x2,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x3d0900,-0x18(%rbp)
jg     118a <main+0x7a>
mov    -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1169 <main+0x59>
mov    -0x20(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1137 <main+0x27>
mov    -0x20(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

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

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

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