#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 counter;
  int number = 2;
  for (counter = 1; counter <= 10001; counter++) {
    while (1) {
      if (isPrime(number)) {
        if (counter != 10001)
          number++;
        break;
      } else {
        number++;
      }
    }
  }
  printf("result %d", number);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x2711,-0x8(%rbp)
jg     119d <main+0x7d>
jmp    114f <main+0x2f>
mov    -0xc(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     117c <main+0x5c>
cmpl   $0x2711,-0x8(%rbp)
je     1177 <main+0x57>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118a <main+0x6a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <main+0x2f>
jmp    118f <main+0x6f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ecx
mov    $0x2,%eax
xchg   %ax,%ax
mov    %ecx,%r14d
mov    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
call   1040 <isPrime@plt>
add    $0x1,%ebx
test   %rax,%rax
je     1140 <main+0x20>
xor    %eax,%eax
cmp    $0x2711,%r14d
setne  %al
add    %ebx,%eax
add    $0xffffffff,%eax
lea    0x1(%r14),%ecx
cmp    $0x2712,%ecx
jne    1130 <main+0x10>
xor    %eax,%eax
cmp    $0x2711,%r14d
setne  %al
lea    (%rax,%rbx,1),%esi
add    $0xffffffff,%esi
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"result %d\00"
define i32 @main() {
br label %1
1: ; preds = %0, %9
%2 = phi i32 [ 2, %0 ], [ %12, %9 ]
%3 = phi i32 [ 1, %0 ], [ %13, %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 = icmp ne i32 %3, 10001
%11 = zext i1 %10 to i32
%12 = add nsw i32 %5, %11
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 10002
br i1 %14, label %15, label %1
15: ; preds = %9
%16 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %12)
ret i32 0
}