#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 EXIT_SUCCESS;
scalar_t__ isPrime(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int primeCount = 1, testNumber = 3;
  while (1) {
    if (isPrime(testNumber)) {
      if (++primeCount == 10001) {
        break;
      }
    }
    testNumber++;
  }
  printf("Solution: %d.\n", testNumber);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     1174 <main+0x54>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x2711,%eax
jne    116f <main+0x4f>
jmp    1182 <main+0x62>
jmp    1174 <main+0x54>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <main+0x24>
mov    -0x18(%rbp),%esi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x3,%ebx
mov    $0x1,%ebp
jmp    1133 <main+0x13>
nop
add    $0x1,%ebx
mov    %ebx,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1130 <main+0x10>
add    $0x1,%ebp
cmp    $0x2711,%ebp
jne    1130 <main+0x10>
lea    0xeaf(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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