#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 *, long long);
int main() {
  char flag[2000000];
  register int i;
  long long int sum = 0;
  for (i = 0; i < 2000000; i++)
    flag[i] = 'a';
  for (i = 2; i < 2000000; i++) {
    if (flag[i] == 'a') {
      sum += i;
      int mul_factor = 2;
      while ((i * mul_factor) < 2000000) {
        flag[i * mul_factor] = 'b';
        mul_factor++;
      }
    }
  }
  printf("%lld", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e84b0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x1e84a0(%rbp)
movl   $0x0,-0x1e8494(%rbp)
cmpl   $0x1e8480,-0x1e8494(%rbp)
jge    116a <main+0x5a>
movslq -0x1e8494(%rbp),%rax
movb   $0x61,-0x1e8490(%rbp,%rax,1)
61
mov    -0x1e8494(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1e8494(%rbp)
jmp    1137 <main+0x27>
movl   $0x2,-0x1e8494(%rbp)
cmpl   $0x1e8480,-0x1e8494(%rbp)
jge    121c <main+0x10c>
movslq -0x1e8494(%rbp),%rax
movsbl -0x1e8490(%rbp,%rax,1),%eax
ff
cmp    $0x61,%eax
jne    1203 <main+0xf3>
movslq -0x1e8494(%rbp),%rax
add    -0x1e84a0(%rbp),%rax
mov    %rax,-0x1e84a0(%rbp)
movl   $0x2,-0x1e84a4(%rbp)
mov    -0x1e8494(%rbp),%eax
imul   -0x1e84a4(%rbp),%eax
cmp    $0x1e8480,%eax
jge    11fe <main+0xee>
mov    -0x1e8494(%rbp),%eax
imul   -0x1e84a4(%rbp),%eax
cltq
movb   $0x62,-0x1e8490(%rbp,%rax,1)
62
mov    -0x1e84a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1e84a4(%rbp)
jmp    11bb <main+0xab>
jmp    1203 <main+0xf3>
jmp    1208 <main+0xf8>
mov    -0x1e8494(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1e8494(%rbp)
jmp    1174 <main+0x64>
mov    -0x1e84a0(%rbp),%rsi
lea    0xdd6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1e84b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x1e8488,%rsp
mov    %rsp,%rdi
mov    $0x1e8480,%edx
mov    $0x61,%esi
call   1040 <memset@plt>
mov    $0x4,%eax
mov    $0x2,%ecx
xor    %esi,%esi
jmp    1161 <main+0x41>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rcx
add    $0x2,%rax
cmp    $0x1e8480,%rcx
je     1192 <main+0x72>
cmpb   $0x61,(%rsp,%rcx,1)
jne    1150 <main+0x30>
add    %rcx,%rsi
cmp    $0xf423f,%rcx
ja     1150 <main+0x30>
mov    %rax,%rdx
cs nopw 0x0(%rax,%rax,1)
movb   $0x62,(%rsp,%rdx,1)
add    %rcx,%rdx
cmp    $0x1e8480,%rdx
jb     1180 <main+0x60>
jmp    1150 <main+0x30>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1e8488,%rsp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2000000 x i8]
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %4
store i32 0, i32* %3
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 2000000
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [2000000 x i8], [2000000 x i8]* %2, i64 0, i64 %11
store i8 97, i8* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %6
16: ; preds = %6
store i32 2, i32* %3
br label %17
17: ; preds = %47, %16
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 2000000
br i1 %19, label %20, label %50
20: ; preds = %17
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [2000000 x i8], [2000000 x i8]* %2, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 97
br i1 %26, label %27, label %46
27: ; preds = %20
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = load i64, i64* %4
%31 = add nsw i64 %30, %29
store i64 %31, i64* %4
store i32 2, i32* %5
br label %32
32: ; preds = %37, %27
%33 = load i32, i32* %3
%34 = load i32, i32* %5
%35 = mul nsw i32 %33, %34
%36 = icmp slt i32 %35, 2000000
br i1 %36, label %37, label %45
37: ; preds = %32
%38 = load i32, i32* %3
%39 = load i32, i32* %5
%40 = mul nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [2000000 x i8], [2000000 x i8]* %2, i64 0, i64 %41
store i8 98, i8* %42
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %32
45: ; preds = %32
br label %46
46: ; preds = %45, %20
br label %47
47: ; preds = %46
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %17
50: ; preds = %17
%51 = load i64, i64* %4
%52 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %51)
ret i32 0
}

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