#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 *, int);
int main() {
  int a, i, k, l, n, s = 2;
  k = 1;
  l = 1;
  while (l <= 4000) {
    a = l + k;
    k = l;
    l = a;
    if (l % 2 == 1)
      s += l;
  }
  printf("\n%d\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xfa0,-0x14(%rbp)
jg     1178 <main+0x68>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1173 <main+0x63>
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1134 <main+0x24>
mov    -0x1c(%rbp),%esi
lea    0xe7e(%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    $0x1,%eax
nop
mov    %ecx,%edx
add    %eax,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
add    %edx,%ecx
and    $0xfffffffe,%ecx
mov    %edx,%edi
sub    %ecx,%edi
cmp    $0x1,%edi
mov    $0x0,%ecx
cmove  %edx,%ecx
add    %ecx,%esi
mov    %eax,%ecx
mov    %edx,%eax
cmp    $0xfa1,%edx
jl     1120 <main+0x10>
push   %rax
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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