#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(void) {
  unsigned int sum = 1;
  unsigned int i = 3;
  int skip = 1;
  while (i < 1001 * 1001) {
    sum += i;
    i += skip + 1;
    sum += i;
    i += skip + 1;
    sum += i;
    i += skip + 1;
    sum += i;
    skip += 2;
    i += skip + 1;
  }
  printf("%u\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0xf4a11,-0xc(%rbp)
jae    11a3 <main+0x93>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <main+0x24>
mov    -0x8(%rbp),%esi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x27e2bd39,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 3, i32* %3
store i32 1, i32* %4
br label %5
5: ; preds = %8, %0
%6 = load i32, i32* %3
%7 = icmp ult i32 %6, 1002001
br i1 %7, label %8, label %39
8: ; preds = %5
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = add i32 %10, %9
store i32 %11, i32* %2
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
%14 = load i32, i32* %3
%15 = add i32 %14, %13
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = add i32 %17, %16
store i32 %18, i32* %2
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
%21 = load i32, i32* %3
%22 = add i32 %21, %20
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = add i32 %24, %23
store i32 %25, i32* %2
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %3
%29 = add i32 %28, %27
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = add i32 %31, %30
store i32 %32, i32* %2
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 2
store i32 %34, i32* %4
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
%37 = load i32, i32* %3
%38 = add i32 %37, %36
store i32 %38, i32* %3
br label %5
39: ; preds = %5
%40 = load i32, i32* %2
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%u\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 669171001)
ret i32 0
}