#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*/ generatePrimesSieve();
scalar_t__ isPrimeGeneratingInteger(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i;
  long long total = 0;
  printf("Generating primes:");
  generatePrimesSieve();
  printf("done.\n");
  for (i = 1; i <= 100000000; i++) {
    if (isPrimeGeneratingInteger(i)) {
      total = total + (long long)i;
      printf("pgi:  %d - total: %lld\n", i, total);
    }
  }
  printf("solution: %lld\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <generatePrimesSieve@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x5f5e100,-0x8(%rbp)
jg     11c7 <main+0x97>
mov    -0x8(%rbp),%edi
call   1050 <isPrimeGeneratingInteger@plt>
cmp    $0x0,%rax
je     11b4 <main+0x84>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <main+0x89>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1171 <main+0x41>
mov    -0x10(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <generatePrimesSieve@plt>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
lea    0xea1(%rip),%r15
xor    %r14d,%r14d
jmp    118d <main+0x4d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x5f5e101,%rbx
je     11ad <main+0x6d>
mov    %ebx,%edi
call   1060 <isPrimeGeneratingInteger@plt>
test   %rax,%rax
je     1180 <main+0x40>
add    %rbx,%r14
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <main+0x40>
lea    0xe77(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Generating primes:\00"
@.str.1 = [7 x i8] c"done.\0A\00"
@.str.2 = [24 x i8] c"pgi: %d - total: %lld\0A\00"
@.str.3 = [16 x i8] c"solution: %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @generatePrimesSieve()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 100000000
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i64 @isPrimeGeneratingInteger(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i64, i64* %3
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = add nsw i64 %15, %17
store i64 %18, i64* %3
%19 = load i32, i32* %2
%20 = load i64, i64* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %19, i64 %20)
br label %22
22: ; preds = %14, %10
br label %23
23: ; preds = %22
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %7
26: ; preds = %7
%27 = load i64, i64* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i64 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Generating primes:\00"
@.str.2 = [24 x i8] c"pgi: %d - total: %lld\0A\00"
@.str.3 = [16 x i8] c"solution: %lld\0A\00"
@str = [6 x i8] c"done.\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @generatePrimesSieve()
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %13
%5 = phi i64 [ 1, %0 ], [ %15, %13 ]
%6 = phi i64 [ 0, %0 ], [ %14, %13 ]
%7 = trunc i64 %5 to i32
%8 = tail call i64 @isPrimeGeneratingInteger(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %4
%11 = add nsw i64 %6, %5
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %7, i64 %11)
br label %13
13: ; preds = %4, %10
%14 = phi i64 [ %11, %10 ], [ %6, %4 ]
%15 = add nuw nsw i64 %5, 1
%16 = icmp eq i64 %15, 100000001
br i1 %16, label %17, label %4
17: ; preds = %13
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i64 %14)
ret i32 0
}