#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, unsigned long);
int main() {
  unsigned long a = 1, b = 1, sum = 0;
  while (b < 4000000) {
    unsigned long c = a + b;
    a = b;
    b = c;
    if (c % 2 == 0) {
      sum += c;
    }
  }
  printf("%lu\n", sum);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x3d0900,-0x18(%rbp)
jae    1184 <main+0x74>
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    117f <main+0x6f>
mov    -0x28(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1137 <main+0x27>
mov    -0x20(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [5 x i8] c"%lu\0A\00"
@EXIT_SUCCESS = global i32 0
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 1, i64* %3
store i64 0, i64* %4
br label %6
6: ; preds = %22, %0
%7 = load i64, i64* %3
%8 = icmp ult i64 %7, 4000000
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i64, i64* %2
%11 = load i64, i64* %3
%12 = add i64 %10, %11
store i64 %12, i64* %5
%13 = load i64, i64* %3
store i64 %13, i64* %2
%14 = load i64, i64* %5
store i64 %14, i64* %3
%15 = load i64, i64* %5
%16 = urem i64 %15, 2
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %9
%19 = load i64, i64* %5
%20 = load i64, i64* %4
%21 = add i64 %20, %19
store i64 %21, i64* %4
br label %22
22: ; preds = %18, %9
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)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 1, %0 ], [ %4, %1 ]
%3 = phi i64 [ 0, %0 ], [ %9, %1 ]
%4 = phi i64 [ 1, %0 ], [ %5, %1 ]
%5 = add nuw nsw i64 %2, %4
%6 = and i64 %5, 1
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i64 %5, i64 0
%9 = add i64 %8, %3
%10 = icmp ult i64 %5, 4000000
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 %9)
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
}