#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 */
scalar_t__ isPrime(int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int primes[100];
  int primes_found;
  int n = 2;
  for (primes_found = 0; primes_found < 100; ++primes_found) {
    while (isPrime(n) == 0) {
      n++;
    }
    printf("%d\n", n);
    primes[primes_found] = n++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x1a8(%rbp)
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    11c6 <main+0xa6>
jmp    1158 <main+0x38>
mov    -0x1a8(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
jne    1181 <main+0x61>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    1158 <main+0x38>
mov    -0x1a8(%rbp),%esi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1a8(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1146 <main+0x26>
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
mov    $0x2,%ebx
lea    0xece(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
call   1040 <isPrime@plt>
add    $0x1,%ebx
test   %rax,%rax
je     1140 <main+0x20>
lea    -0x1(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    $0x64,%ebp
jne    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %9
%2 = phi i32 [ 2, %0 ], [ %8, %9 ]
%3 = phi i32 [ 0, %0 ], [ %11, %9 ]
br label %4
4: ; preds = %4, %1
%5 = phi i32 [ %8, %4 ], [ %2, %1 ]
%6 = tail call i64 @isPrime(i32 %5)
%7 = icmp eq i64 %6, 0
%8 = add nsw i32 %5, 1
br i1 %7, label %4, label %9
9: ; preds = %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%11 = add nuw nsw i32 %3, 1
%12 = icmp eq i32 %11, 100
br i1 %12, label %13, label %1
13: ; preds = %9
ret i32 0
}