#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 i;
  int answer;
  int count = 1;
  int n = 2;
  for (i = 2; count != 10002; i++) {
    if (isprime(i)) {
      answer = i;
      count++;
    }
  }
  printf("%d", answer);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
movl   $0x2,-0x8(%rbp)
cmpl   $0x2712,-0x10(%rbp)
je     1185 <main+0x65>
mov    -0x8(%rbp),%edi
call   1040 <isprime@plt>
cmp    $0x0,%rax
je     1172 <main+0x52>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <main+0x57>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <main+0x24>
mov    -0xc(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebp
mov    $0x2,%ebx
xchg   %ax,%ax
mov    %ebx,%edi
call   1040 <isprime@plt>
xor    %ecx,%ecx
test   %rax,%rax
cmovne %ebx,%r14d
lea    0x1(%rbx),%eax
setne  %cl
add    %ecx,%ebp
mov    %eax,%ebx
cmp    $0x2712,%ebp
jne    1130 <main+0x10>
lea    0xea7(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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