#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 */
double CLOCKS_PER_SEC;
double clock();
scalar_t__ isPrime(unsigned int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double start, end = 0;
  printf("Algorithm starts, Please wait...\n");
  start = clock();
  unsigned int i = 3;
  unsigned long primeSummatory = 2;
  while (i <= (2 * pow(10, 6))) {
    if (isPrime(i)) {
      primeSummatory += i;
    }
    i += 2;
  }
  end = clock();
  printf("Algorithm end\n");
  printf("Total time: %f\n", (end - start) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x3,-0x24(%rbp)
movq   $0x2,-0x30(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
shl    $0x1,%ecx
cmp    %ecx,%eax
ja     11d7 <main+0x97>
mov    -0x24(%rbp),%edi
call   1050 <isPrime@plt>
cmp    $0x0,%rax
je     11c9 <main+0x89>
mov    -0x24(%rbp),%eax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    1187 <main+0x47>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2de6(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1070 <pow@plt>
add    %eax,%eax
cmp    $0x3,%eax
jb     11af <main+0x5f>
mov    $0x3,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
call   1060 <isPrime@plt>
add    $0x2,%ebx
mov    $0xa,%edi
mov    $0x6,%esi
call   1070 <pow@plt>
add    %eax,%eax
cmp    %eax,%ebx
jbe    1190 <main+0x40>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mov    0x2e0f(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe1c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Algorithm starts, Please wait...\0A\00"
@.str.1 = [15 x i8] c"Algorithm end\0A\00"
@.str.2 = [16 x i8] c"Total time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = call double (...) @clock()
store double %11, double* %6
store i32 3, i32* %8
store i64 2, i64* %9
br label %12
12: ; preds = %26, %2
%13 = load i32, i32* %8
%14 = call i32 @pow(i32 10, i32 6)
%15 = mul nsw i32 2, %14
%16 = icmp ule i32 %13, %15
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i32, i32* %8
%19 = call i64 @isPrime(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i32, i32* %8
%23 = zext i32 %22 to i64
%24 = load i64, i64* %9
%25 = add i64 %24, %23
store i64 %25, i64* %9
br label %26
26: ; preds = %21, %17
%27 = load i32, i32* %8
%28 = add i32 %27, 2
store i32 %28, i32* %8
br label %12
29: ; preds = %12
%30 = call double (...) @clock()
store double %30, double* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%32 = load double, double* %7
%33 = load double, double* %6
%34 = fsub double %32, %33
%35 = load double, double* @CLOCKS_PER_SEC
%36 = fdiv double %34, %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %36)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [16 x i8] c"Total time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@str = [33 x i8] c"Algorithm starts, Please wait...\00"
@str.3 = [14 x i8] c"Algorithm end\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%4 = tail call double (...) @clock()
%5 = tail call i32 @pow(i32 10, i32 6)
%6 = shl nsw i32 %5, 1
%7 = icmp ult i32 %6, 3
br i1 %7, label %15, label %8
8: ; preds = %2, %8
%9 = phi i32 [ %11, %8 ], [ 3, %2 ]
%10 = tail call i64 @isPrime(i32 %9)
%11 = add i32 %9, 2
%12 = tail call i32 @pow(i32 10, i32 6)
%13 = shl nsw i32 %12, 1
%14 = icmp ugt i32 %11, %13
br i1 %14, label %15, label %8
15: ; preds = %8, %2
%16 = tail call double (...) @clock()
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
%18 = fsub double %16, %4
%19 = load double, double* @CLOCKS_PER_SEC
%20 = fdiv double %18, %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %20)
ret i32 0
}