#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() {
  unsigned int a = 1;
  unsigned int b = 1;
  unsigned int c = 0;
  unsigned int limit = 4000000;
  unsigned int sum = 0;
  for (;;) {
    c = a + b;
    a = b;
    b = c;
    if (c > limit) {
      break;
    } else {
      if (c % 2 == 0) {
        printf("%d\n", c);
        sum += c;
      }
    }
  }
  printf("Result: %d\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   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x3d0900,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jbe    1168 <main+0x58>
jmp    1199 <main+0x89>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    118f <main+0x7f>
mov    -0x10(%rbp),%esi
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1194 <main+0x84>
jmp    1142 <main+0x32>
mov    -0x18(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebp
xor    %r15d,%r15d
mov    $0x2,%eax
lea    0xedd(%rip),%r14
jmp    113e <main+0x2e>
nopl   (%rax)
add    %ebx,%ebp
mov    %ebp,%eax
cmp    $0x3d0901,%ebp
mov    %ebx,%ebp
jae    1154 <main+0x44>
mov    %eax,%ebx
test   $0x1,%bl
jne    1130 <main+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    %ebx,%r15d
jmp    1130 <main+0x20>
lea    0xea5(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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