#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 *, int);
int main(int argc, char *argv[]) {
  const int upperBound = 4e6;
  int previous = 1, current = 2, sum = 0, temp;
  do {
    if (current % 2 == 0) {
      sum += current;
    }
    temp = current;
    current += previous;
    previous = temp;
  } while (current < upperBound);
  printf("Solution: %d.\n", sum);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3d0900,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115f <main+0x4f>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x3d0900,-0x1c(%rbp)
jl     1142 <main+0x32>
mov    -0x20(%rbp),%esi
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

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

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

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