#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 primeGeneratr(int);
int /*<<< orphan*/ printf(char *, int);
void testPrimality() {
  int ns[] = {10, 100, 500, 1000, 2000, 10000, 100000};
  int size = 7;
  for (int i = 0; i < size; i++) {
    int last_idx = primeGeneratr(ns[i]);
    printf("# primes = %d\n\n", last_idx);
  }
}


x86 assembly (clang, -O0):
<testPrimality>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec9(%rip),%eax
mov    %eax,-0x8(%rbp)
movl   $0x7,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1199 <testPrimality+0x79>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
call   1030 <primeGeneratr@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1160 <testPrimality+0x40>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testPrimality>:
push   %rbx
mov    $0xa,%edi
call   1030 <primeGeneratr@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x64,%edi
call   1030 <primeGeneratr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1f4,%edi
call   1030 <primeGeneratr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x3e8,%edi
call   1030 <primeGeneratr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x7d0,%edi
call   1030 <primeGeneratr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x2710,%edi
call   1030 <primeGeneratr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x186a0,%edi
call   1030 <primeGeneratr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@__const.testPrimality.ns = [7 x i32] [i32 10, i32 100, i32 500, i32 1000, i32 2000, i32 10000, i32 100000]
@.str = [16 x i8] c"# primes = %d\0A\0A\00"
define void @testPrimality() {
%1 = alloca [7 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [7 x i32]* %1 to i8*
store i32 7, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %18, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %21
10: ; preds = %6
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 @primeGeneratr(i32 %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %10
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %6
21: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"# primes = %d\0A\0A\00"
define void @testPrimality() {
%1 = tail call i32 @primeGeneratr(i32 10)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @primeGeneratr(i32 100)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @primeGeneratr(i32 500)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @primeGeneratr(i32 1000)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @primeGeneratr(i32 2000)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @primeGeneratr(i32 10000)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = tail call i32 @primeGeneratr(i32 100000)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %13)
ret void
}