#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 */
unsigned int BinetsFormula(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int);
int main(void) {
  unsigned int i = 2, nth_fib_element = 0, even_fib_sum = 0;
  while (nth_fib_element < 4000000) {
    nth_fib_element = BinetsFormula(i);
    if (nth_fib_element % 2 == 0 && nth_fib_element < 4000000) {
      even_fib_sum += nth_fib_element;
    }
    i++;
  }
  printf("%d", even_fib_sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x3d0900,-0xc(%rbp)
jae    118f <main+0x6f>
mov    -0x8(%rbp),%edi
call   1030 <BinetsFormula@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1181 <main+0x61>
cmpl   $0x3d0900,-0xc(%rbp)
jae    1181 <main+0x61>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <main+0x24>
mov    -0x10(%rbp),%esi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x2,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <BinetsFormula@plt>
test   $0x1,%al
mov    $0x0,%ecx
cmove  %eax,%ecx
cmp    $0x3d0900,%eax
cmovae %r14d,%ecx
add    %ecx,%ebx
add    $0x1,%ebp
cmp    $0x3d0900,%eax
jb     1130 <main+0x10>
lea    0xea3(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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