#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(void) {
  int count, c;
  int a = 1;
  int b = 2;
  int sum = 2;
  for (count = 1; b < 4000000; count++) {
    c = a;
    a = b;
    b = c + a;
    if (count % 3 == 0)
      sum = sum + b;
  }
  printf("%i", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x3d0900,-0x14(%rbp)
jge    118d <main+0x7d>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117a <main+0x6a>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    117f <main+0x6f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113b <main+0x2b>
mov    -0x18(%rbp),%esi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%eax
mov    $0x2,%esi
mov    $0xffffffff,%ecx
mov    $0xaaaaaaab,%r8d
mov    $0x2,%edx
mov    $0x1,%edi
nop
mov    %edx,%r9d
mov    %edi,%edx
imul   %r8,%rdx
shr    $0x21,%rdx
lea    (%rdx,%rdx,2),%edx
add    %r9d,%eax
add    %ecx,%edx
mov    $0x0,%edx
cmove  %eax,%edx
add    %edx,%esi
add    $0x1,%edi
add    $0xffffffff,%ecx
mov    %eax,%edx
cmp    $0x3d0900,%eax
mov    %r9d,%eax
jl     1130 <main+0x20>
push   %rax
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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