#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*/ printf(char *, long);
int main(void) {
  long count, currentNumber, primeCount;
  primeCount = 1;
  for (currentNumber = 3; primeCount != 10001;
       currentNumber = currentNumber + 2) {
    for (count = 3; count < currentNumber; count = count + 2) {
      if (currentNumber % count == 0)
        break;
    }
    if (count == currentNumber)
      primeCount++;
  }
  printf("10001st Prime number: %li", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x20(%rbp)
movq   $0x3,-0x18(%rbp)
cmpq   $0x2711,-0x20(%rbp)
je     11b2 <main+0xa2>
movq   $0x3,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1182 <main+0x72>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x10(%rbp)
cmp    $0x0,%rdx
jne    116c <main+0x5c>
jmp    1182 <main+0x72>
jmp    1171 <main+0x61>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    1145 <main+0x35>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    119c <main+0x8c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a1 <main+0x91>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    112f <main+0x1f>
mov    -0x10(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x3,%ecx
mov    $0x1,%edi
jmp    1138 <main+0x28>
nopl   0x0(%rax)
xor    %eax,%eax
cmp    %rcx,%rsi
sete   %al
add    %rax,%rdi
add    $0x2,%rcx
cmp    $0x2711,%rdi
je     1186 <main+0x76>
mov    $0x3,%esi
cmp    $0x4,%rcx
jb     1120 <main+0x10>
mov    $0x3,%esi
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     1170 <main+0x60>
mov    %rcx,%rax
xor    %edx,%edx
div    %rsi
test   %rdx,%rdx
jne    117b <main+0x6b>
jmp    1120 <main+0x10>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
test   %rdx,%rdx
je     1120 <main+0x10>
add    $0x2,%rsi
cmp    %rcx,%rsi
jb     1150 <main+0x40>
jmp    1120 <main+0x10>
push   %rax
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"10001st Prime number: %li\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
store i64 1, i64* %4
store i64 3, i64* %3
br label %5
5: ; preds = %31, %0
%6 = load i64, i64* %4
%7 = icmp ne i64 %6, 10001
br i1 %7, label %8, label %34
8: ; preds = %5
store i64 3, i64* %2
br label %9
9: ; preds = %20, %8
%10 = load i64, i64* %2
%11 = load i64, i64* %3
%12 = icmp slt i64 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i64, i64* %3
%15 = load i64, i64* %2
%16 = srem i64 %14, %15
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
br label %23
19: ; preds = %13
br label %20
20: ; preds = %19
%21 = load i64, i64* %2
%22 = add nsw i64 %21, 2
store i64 %22, i64* %2
br label %9
23: ; preds = %18, %9
%24 = load i64, i64* %2
%25 = load i64, i64* %3
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i64, i64* %4
%29 = add nsw i64 %28, 1
store i64 %29, i64* %4
br label %30
30: ; preds = %27, %23
br label %31
31: ; preds = %30
%32 = load i64, i64* %3
%33 = add nsw i64 %32, 2
store i64 %33, i64* %3
br label %5
34: ; preds = %5
%35 = load i64, i64* %2
%36 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i64 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"10001st Prime number: %li\00"
define i32 @main() {
br label %1
1: ; preds = %0, %12
%2 = phi i64 [ 1, %0 ], [ %16, %12 ]
%3 = phi i64 [ 3, %0 ], [ %17, %12 ]
%4 = icmp ugt i64 %3, 3
br i1 %4, label %5, label %12
5: ; preds = %1, %9
%6 = phi i64 [ %10, %9 ], [ 3, %1 ]
%7 = urem i64 %3, %6
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = add nuw nsw i64 %6, 2
%11 = icmp ult i64 %10, %3
br i1 %11, label %5, label %12
12: ; preds = %9, %5, %1
%13 = phi i64 [ 3, %1 ], [ %6, %5 ], [ %10, %9 ]
%14 = icmp eq i64 %13, %3
%15 = zext i1 %14 to i64
%16 = add nuw nsw i64 %2, %15
%17 = add nuw nsw i64 %3, 2
%18 = icmp eq i64 %16, 10001
br i1 %18, label %19, label %1
19: ; preds = %12
%20 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i64 %13)
ret i32 0
}