#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 *, int, int);
int main(void) {
  int nprime = 1, i, j, prime = 0;
  for (i = 3; nprime < 10001; i++) {
    for (j = 2; j < i; j++) {
      if (i % j == 0)
        break;
    }
    if (j == i) {
      prime = i;
      nprime++;
    }
  }
  printf("%d -> %d\n", nprime, prime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x3,-0xc(%rbp)
cmpl   $0x2711,-0x8(%rbp)
jge    11aa <main+0x9a>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117c <main+0x6c>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1169 <main+0x59>
jmp    117c <main+0x6c>
jmp    116e <main+0x5e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <main+0x38>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1197 <main+0x87>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119c <main+0x8c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <main+0x24>
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%esi
mov    $0x3,%edi
xor    %r8d,%r8d
mov    $0xffffffff,%r9d
jmp    114c <main+0x3c>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
cmp    %edi,%ecx
sete   %al
cmove  %edi,%r8d
add    %eax,%esi
add    $0x1,%edi
add    $0xffffffff,%r9d
cmp    $0x2711,%esi
jae    117d <main+0x6d>
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edi,%eax
xor    %edx,%edx
div    %ecx
test   %edx,%edx
je     1130 <main+0x20>
lea    (%r9,%rcx,1),%eax
add    $0x1,%eax
add    $0x1,%ecx
cmp    $0x2,%eax
jne    1160 <main+0x50>
mov    %edi,%ecx
jmp    1130 <main+0x20>
push   %rax
lea    0xe7b(%rip),%rdi
mov    %r8d,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%d -> %d\0A\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* %2
store i32 0, i32* %5
store i32 3, i32* %3
br label %6
6: ; preds = %33, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 10001
br i1 %8, label %9, label %36
9: ; preds = %6
store i32 2, i32* %4
br label %10
10: ; preds = %21, %9
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = srem i32 %15, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %24
20: ; preds = %14
br label %21
21: ; preds = %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %10
24: ; preds = %19, %10
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* %3
store i32 %29, i32* %5
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %32
32: ; preds = %28, %24
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %6
36: ; preds = %6
%37 = load i32, i32* %2
%38 = load i32, i32* %5
%39 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %38)
ret i32 0
}

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