#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(long long);
int /*<<< orphan*/ printf(char *, int, long long);
long long int findPrime(int n) {
  int count = 0;
  long long i = 1;
  while (count < n) {
    i++;
    if (isPrime(i)) {
      count++;
      printf("%d\t%lld\n", count, i);
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<findPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1186 <findPrime+0x66>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     1181 <findPrime+0x61>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
jmp    113a <findPrime+0x1a>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findPrime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1168 <findPrime+0x48>
mov    %edi,%r14d
xor    %ebp,%ebp
mov    $0x1,%ebx
lea    0xec4(%rip),%r15
jmp    1145 <findPrime+0x25>
xchg   %ax,%ax
cmp    %r14d,%ebp
jge    116d <findPrime+0x4d>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1140 <findPrime+0x20>
add    $0x1,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
jmp    1140 <findPrime+0x20>
mov    $0x1,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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