#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 *, unsigned long);
int main(void) {
  int first = 1;
  int second = 2;
  unsigned long int sum = 2;
  int result = first + second;
  while (result < 4000000) {
    first = second;
    second = result;
    result = first + second;
    if (!(result & 0x01))
      sum += result;
  }
  printf("The sum is :%lu \n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x3d0900,-0x1c(%rbp)
jge    1180 <main+0x70>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    117b <main+0x6b>
movslq -0x1c(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    113e <main+0x2e>
mov    -0x18(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

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

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