#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("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     11b2 <main+0x82>
mov    -0x8(%rbp),%edi
call   1050 <isPrimeGeneratingInteger@plt>
cmp    $0x0,%rax
je     119f <main+0x6f>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    11a4 <main+0x74>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1171 <main+0x41>
mov    -0x10(%rbp),%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <generatePrimesSieve@plt>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
nopl   (%rax)
mov    %ebx,%edi
call   1060 <isPrimeGeneratingInteger@plt>
test   %rax,%rax
cmovne %rbx,%rax
add    %rax,%r14
add    $0x1,%rbx
cmp    $0x5f5e101,%rbx
jne    1170 <main+0x30>
lea    0xe7e(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Generating primes:\00"
@.str.1 = [7 x i8] c"done.\0A\00"
@.str.2 = [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 = %20, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 100000000
br i1 %9, label %10, label %23
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 %19
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
br label %19
19: ; preds = %14, %10
br label %20
20: ; preds = %19
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %7
23: ; preds = %7
%24 = load i64, i64* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Generating primes:\00"
@.str.2 = [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, %4
%5 = phi i64 [ 1, %0 ], [ %12, %4 ]
%6 = phi i64 [ 0, %0 ], [ %11, %4 ]
%7 = trunc i64 %5 to i32
%8 = tail call i64 @isPrimeGeneratingInteger(i32 %7)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i64 0, i64 %5
%11 = add nuw nsw i64 %10, %6
%12 = add nuw nsw i64 %5, 1
%13 = icmp eq i64 %12, 100000001
br i1 %13, label %14, label %4
14: ; preds = %4
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 %11)
ret i32 0
}