#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 long);
void main(void) {
  unsigned int a, b, temp;
  unsigned long long int sum = 0;
  for (a = 0, b = 1; b < 4000000; temp = b, b += a, a = temp) {
    if (b % 2 == 0)
      sum += b;
    printf("%d ", b);
  }
  printf("\n%d\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x3d0900,-0x8(%rbp)
jae    1180 <main+0x70>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1155 <main+0x45>
mov    -0x8(%rbp),%eax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%esi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    112e <main+0x1e>
mov    -0x18(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
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    %ebx,%ebx
lea    0xedb(%rip),%r14
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
test   $0x1,%bpl
mov    %ebp,%esi
mov    $0x0,%eax
cmove  %rsi,%rax
add    %rax,%rbx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15d,%eax
add    %ebp,%eax
mov    %ebp,%r15d
mov    %eax,%ebp
cmp    $0x3d0900,%eax
jb     1130 <main+0x20>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

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

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