#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() {
  long int a, b, c, max, sum;
  max = 4000000;
  a = 0;
  b = 1;
  sum = 0;
  while ((c = a + b) < max) {
    a = b;
    b = c;
    sum += (c % 2 == 0) ? c : 0;
  }
  printf("The result is %li\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x3d0900,-0x28(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmp    -0x28(%rbp),%rax
jge    11a6 <main+0x96>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    118a <main+0x7a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1195 <main+0x85>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    1195 <main+0x85>
mov    -0x38(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    113f <main+0x2f>
mov    -0x30(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

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

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

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