#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 argc, char *argv[]) {
  int limit = 1001 * 1001;
  int skip = 0;
  int total = 1;
  int count = 0;
  for (int i = 3; i <= limit; i += 2) {
    for (int j = 0; j < skip; j++)
      i += 2;
    total += i;
    count++;
    if (count % 4 == 0)
      skip++;
  }
  printf("%i", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xf4a11,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x3,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11c1 <main+0xb1>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    117f <main+0x6f>
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    115c <main+0x4c>
mov    -0x24(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ae <main+0x9e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b3 <main+0xa3>
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    1149 <main+0x39>
mov    -0x1c(%rbp),%esi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
xor    %edx,%edx
mov    $0x3,%eax
mov    $0x1,%edi
mov    $0x1,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rax,%rdx,2),%r8d
add    %r8d,%esi
mov    %edi,%ecx
and    $0x3,%ecx
cmp    $0x1,%ecx
lea    0x2(%rax,%rdx,2),%eax
mov    %edx,%ecx
adc    $0x0,%ecx
add    $0x1,%edi
mov    %ecx,%edx
cmp    $0xf4a10,%r8d
jl     1130 <main+0x20>
push   %rax
lea    0xea2(%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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1002001, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
store i32 0, i32* %9
store i32 3, i32* %10
br label %12
12: ; preds = %40, %2
%13 = load i32, i32* %10
%14 = load i32, i32* %6
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %43
16: ; preds = %12
store i32 0, i32* %11
br label %17
17: ; preds = %24, %16
%18 = load i32, i32* %11
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i32, i32* %10
%23 = add nsw i32 %22, 2
store i32 %23, i32* %10
br label %24
24: ; preds = %21
%25 = load i32, i32* %11
%26 = add nsw i32 %25, 1
store i32 %26, i32* %11
br label %17
27: ; preds = %17
%28 = load i32, i32* %10
%29 = load i32, i32* %8
%30 = add nsw i32 %29, %28
store i32 %30, i32* %8
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
%33 = load i32, i32* %9
%34 = srem i32 %33, 4
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %27
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %39
39: ; preds = %36, %27
br label %40
40: ; preds = %39
%41 = load i32, i32* %10
%42 = add nsw i32 %41, 2
store i32 %42, i32* %10
br label %12
43: ; preds = %12
%44 = load i32, i32* %8
%45 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %44)
ret i32 0
}

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