#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 argc, char const *argv[]) {
  int i_m1 = 1;
  int i_m2 = 0;
  int cur;
  int res = 0;
  do {
    cur = i_m1 + i_m2;
    i_m2 = i_m1;
    i_m1 = cur;
    ((cur & 1) == 0) && (res += cur);
  } while (cur < 4000000);
  printf("The answer to Euler Problem 2 is %i\n", res);
  return 0;
}


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   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%ecx
and    $0x1,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
jne    1176 <main+0x66>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
cmpl   $0x3d0900,-0x1c(%rbp)
jl     113b <main+0x2b>
mov    -0x20(%rbp),%esi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [37 x i8] c"The answer to Euler Problem 2 is %i\0A\00"
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 0, i32* %7
store i32 0, i32* %9
br label %10
10: ; preds = %27, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = add nsw i32 %11, %12
store i32 %13, i32* %8
%14 = load i32, i32* %6
store i32 %14, i32* %7
%15 = load i32, i32* %8
store i32 %15, i32* %6
%16 = load i32, i32* %8
%17 = and i32 %16, 1
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %10
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = add nsw i32 %21, %20
store i32 %22, i32* %9
%23 = icmp ne i32 %22, 0
br label %24
24: ; preds = %19, %10
%25 = phi i1 [ false, %10 ], [ %23, %19 ]
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %24
%28 = load i32, i32* %8
%29 = icmp slt i32 %28, 4000000
br i1 %29, label %10, label %30
30: ; preds = %27
%31 = load i32, i32* %9
%32 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %31)
ret i32 0
}

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