#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 *, unsigned int);
int main(void) {
  unsigned int a = 1, b = 2, sum = b, lim = 4e6, res;
  for (;;) {
    res = a + b;
    if (res >= lim)
      break;
    else if (res % 2 == 0)
      sum += res;
    a = b;
    b = res;
  }
  printf("%d\n", sum);
  return EXIT_SUCCESS;
}


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)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x3d0900,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jb     1154 <main+0x44>
jmp    1182 <main+0x72>
mov    -0x18(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    116c <main+0x5c>
mov    -0x18(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1171 <main+0x61>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    113a <main+0x2a>
mov    -0x10(%rbp),%esi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x2,%eax
mov    $0x3,%ecx
mov    $0x2,%esi
nop
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
jb     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 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 2, i32* %3
%7 = load i32, i32* %3
store i32 %7, i32* %4
store i32 4000000, i32* %5
br label %8
8: ; preds = %25, %0
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = add i32 %9, %10
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = icmp uge i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %8
br label %28
16: ; preds = %8
%17 = load i32, i32* %6
%18 = urem i32 %17, 2
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %6
%22 = load i32, i32* %4
%23 = add i32 %22, %21
store i32 %23, i32* %4
br label %24
24: ; preds = %20, %16
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
store i32 %26, i32* %2
%27 = load i32, i32* %6
store i32 %27, i32* %3
br label %8
28: ; preds = %15
%29 = load i32, i32* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @EXIT_SUCCESS
ret i32 %31
}

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