#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 int);
int main(int argc, char *argv[]) {
  unsigned t1 = 1;
  unsigned t2 = 2;
  unsigned tnext;
  unsigned sum = t2;
  while (t2 <= 4000000) {
    tnext = t1 + t2;
    if (!(tnext % 2))
      sum += tnext;
    t1 = t2;
    t2 = tnext;
  }
  printf("Sum of even Fibonacci numbers: %u\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x3d0900,-0x18(%rbp)
ja     1179 <main+0x69>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1168 <main+0x58>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    113a <main+0x2a>
mov    -0x20(%rbp),%esi
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%ecx
mov    $0x2,%esi
mov    $0x2,%eax
nop
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    $0x3d0901,%edx
jb     1120 <main+0x10>
push   %rax
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Sum of even Fibonacci numbers: %u\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 2, i32* %7
%10 = load i32, i32* %7
store i32 %10, i32* %9
br label %11
11: ; preds = %25, %2
%12 = load i32, i32* %7
%13 = icmp ule i32 %12, 4000000
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = add i32 %15, %16
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = urem i32 %18, 2
%20 = icmp ne i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %14
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = add i32 %23, %22
store i32 %24, i32* %9
br label %25
25: ; preds = %21, %14
%26 = load i32, i32* %7
store i32 %26, i32* %6
%27 = load i32, i32* %8
store i32 %27, i32* %7
br label %11
28: ; preds = %11
%29 = load i32, i32* %9
%30 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Sum of even Fibonacci numbers: %u\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 2, %2 ], [ %11, %3 ]
%5 = phi i32 [ 1, %2 ], [ %6, %3 ]
%6 = phi i32 [ 2, %2 ], [ %7, %3 ]
%7 = add nuw nsw i32 %5, %6
%8 = and i32 %7, 1
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 %7, i32 0
%11 = add i32 %10, %4
%12 = icmp ult i32 %7, 4000001
br i1 %12, label %3, label %13
13: ; preds = %3
%14 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
}