#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 *, double);
int main(int argc, char *argv[]) {
  int mark[2000000];
  int i, j;
  double sum = 0;
  for (i = 1; i < 1999999; i++) {
    mark[i - 1] = 0;
  }
  for (i = 2; i < 2000000; i++) {
    if (mark[i] == 0) {
      sum += i;
      for (j = i; j < 2000000; j += i) {
        mark[j] = 1;
      }
    }
  }
  printf("%.0f\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a1220,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x7a1220(%rbp)
ff
movl   $0x1,-0x7a1214(%rbp)
cmpl   $0x1e847f,-0x7a1214(%rbp)
jge    1178 <main+0x68>
mov    -0x7a1214(%rbp),%eax
sub    $0x1,%eax
cltq
movl   $0x0,-0x7a1210(%rbp,%rax,4)
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    113e <main+0x2e>
movl   $0x2,-0x7a1214(%rbp)
cmpl   $0x1e8480,-0x7a1214(%rbp)
jge    1222 <main+0x112>
movslq -0x7a1214(%rbp),%rax
cmpl   $0x0,-0x7a1210(%rbp,%rax,4)
jne    1209 <main+0xf9>
cvtsi2sdl -0x7a1214(%rbp),%xmm0
ff
addsd  -0x7a1220(%rbp),%xmm0
ff
movsd  %xmm0,-0x7a1220(%rbp)
ff
mov    -0x7a1214(%rbp),%eax
mov    %eax,-0x7a1218(%rbp)
cmpl   $0x1e8480,-0x7a1218(%rbp)
jge    1204 <main+0xf4>
movslq -0x7a1218(%rbp),%rax
movl   $0x1,-0x7a1210(%rbp,%rax,4)
mov    -0x7a1214(%rbp),%eax
add    -0x7a1218(%rbp),%eax
mov    %eax,-0x7a1218(%rbp)
jmp    11cb <main+0xbb>
jmp    1209 <main+0xf9>
jmp    120e <main+0xfe>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    1182 <main+0x72>
movsd  -0x7a1220(%rbp),%xmm0
ff
lea    0xdcf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x7a1220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x7a1208,%rsp
mov    %rsp,%rdi
mov    $0x7a11f8,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
xorpd  %xmm0,%xmm0
mov    $0x2,%esi
mov    $0x8,%r10d
mov    $0xc,%edi
jmp    117d <main+0x5d>
cs nopw 0x0(%rax,%rax,1)
add    $0x2,%rsi
add    $0x8,%r8
add    $0x8,%r10
add    $0x8,%r9
add    $0x8,%rdi
cmp    $0x1e8480,%rsi
je     11fa <main+0xda>
cmpl   $0x0,(%rsp,%rsi,4)
jne    11b5 <main+0x95>
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
addsd  %xmm1,%xmm0
mov    %r8,%rdx
mov    %rsi,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movl   $0x1,(%rdx)
add    %rsi,%rcx
add    %r10,%rdx
cmp    $0x1e8480,%rcx
jb     11a0 <main+0x80>
mov    %rsi,%rax
or     $0x1,%rax
cmpl   $0x0,(%rsp,%rax,4)
jne    1160 <main+0x40>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
mov    %r9,%rcx
mov    %rax,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movl   $0x1,(%rcx)
add    %rax,%rdx
add    %rdi,%rcx
cmp    $0x1e8480,%rdx
jb     11e0 <main+0xc0>
jmp    1160 <main+0x40>
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7a1208,%rsp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%.0f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2000000 x i32]
%4 = bitcast [2000000 x i32]* %3 to i8*
br label %5
5: ; preds = %35, %2
%6 = phi i64 [ 2, %2 ], [ %37, %35 ]
%7 = phi double [ 0.000000e+00, %2 ], [ %36, %35 ]
%8 = getelementptr inbounds [2000000 x i32], [2000000 x i32]* %3, i64 0, i64 %6
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %5
%12 = trunc i64 %6 to i32
%13 = sitofp i32 %12 to double
%14 = fadd double %7, %13
br label %15
15: ; preds = %11, %15
%16 = phi i64 [ %6, %11 ], [ %18, %15 ]
%17 = getelementptr inbounds [2000000 x i32], [2000000 x i32]* %3, i64 0, i64 %16
store i32 1, i32* %17
%18 = add nuw nsw i64 %16, %6
%19 = icmp ult i64 %18, 2000000
br i1 %19, label %15, label %20
20: ; preds = %15, %5
%21 = phi double [ %7, %5 ], [ %14, %15 ]
%22 = or i64 %6, 1
%23 = getelementptr inbounds [2000000 x i32], [2000000 x i32]* %3, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %20
%27 = trunc i64 %22 to i32
%28 = sitofp i32 %27 to double
%29 = fadd double %21, %28
br label %30
30: ; preds = %30, %26
%31 = phi i64 [ %22, %26 ], [ %33, %30 ]
%32 = getelementptr inbounds [2000000 x i32], [2000000 x i32]* %3, i64 0, i64 %31
store i32 1, i32* %32
%33 = add nuw nsw i64 %31, %22
%34 = icmp ult i64 %33, 2000000
br i1 %34, label %30, label %35
35: ; preds = %30, %20
%36 = phi double [ %21, %20 ], [ %29, %30 ]
%37 = add nuw nsw i64 %6, 2
%38 = icmp eq i64 %37, 2000000
br i1 %38, label %39, label %5
39: ; preds = %35
%40 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %36)
ret i32 0
}