#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__ prime(double);
double nthPrime(double n) {
  register double primes = 1;
  register double d = 1;
  if (n == 1)
    return 2;
  while (primes < n) {
    d += 2;
    if (prime(d))
      primes++;
  }
  return d;
}


x86 assembly (clang, -O0):
<nthPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xedb(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xece(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xebc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1166 <nthPrime+0x56>
jp     1166 <nthPrime+0x56>
movsd  0xeac(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c6 <nthPrime+0xb6>
jmp    116b <nthPrime+0x5b>
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11bc <nthPrime+0xac>
movsd  0xe81(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <prime@plt>
cmp    $0x0,%rax
je     11b7 <nthPrime+0xa7>
movsd  0xe53(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    116b <nthPrime+0x5b>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nthPrime>:
sub    $0x18,%rsp
ucomisd 0xeec(%rip),%xmm0
jne    112a <nthPrime+0x1a>
jp     112a <nthPrime+0x1a>
movsd  0xed8(%rip),%xmm1
jmp    119b <nthPrime+0x8b>
movsd  0xed6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119b <nthPrime+0x8b>
movsd  0xec8(%rip),%xmm2
movapd %xmm2,%xmm1
movsd  %xmm0,(%rsp)
jmp    1161 <nthPrime+0x51>
nopl   0x0(%rax,%rax,1)
movsd  (%rsp),%xmm0
ucomisd %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
jbe    119b <nthPrime+0x8b>
movsd  %xmm2,0x8(%rsp)
addsd  0xe91(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
call   1030 <prime@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm0
addsd  0xe78(%rip),%xmm0
test   %rax,%rax
je     1150 <nthPrime+0x40>
movapd %xmm0,%xmm2
jmp    1150 <nthPrime+0x40>
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @nthPrime(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double 1.000000e+00, double* %4
store double 1.000000e+00, double* %5
%6 = load double, double* %3
%7 = fcmp oeq double %6, 1.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %1
store double 2.000000e+00, double* %2
br label %26
9: ; preds = %1
br label %10
10: ; preds = %23, %9
%11 = load double, double* %4
%12 = load double, double* %3
%13 = fcmp olt double %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load double, double* %5
%16 = fadd double %15, 2.000000e+00
store double %16, double* %5
%17 = load double, double* %5
%18 = call i64 @prime(double %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load double, double* %4
%22 = fadd double %21, 1.000000e+00
store double %22, double* %4
br label %23
23: ; preds = %20, %14
br label %10
24: ; preds = %10
%25 = load double, double* %5
store double %25, double* %2
br label %26
26: ; preds = %24, %8
%27 = load double, double* %2
ret double %27
}

LLVM IR (-O2):
define double @nthPrime(double %0) {
%2 = fcmp oeq double %0, 1.000000e+00
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = fcmp ogt double %0, 1.000000e+00
br i1 %4, label %5, label %14
5: ; preds = %3, %5
%6 = phi double [ %8, %5 ], [ 1.000000e+00, %3 ]
%7 = phi double [ %12, %5 ], [ 1.000000e+00, %3 ]
%8 = fadd double %6, 2.000000e+00
%9 = tail call i64 @prime(double %8)
%10 = icmp eq i64 %9, 0
%11 = fadd double %7, 1.000000e+00
%12 = select i1 %10, double %7, double %11
%13 = fcmp olt double %12, %0
br i1 %13, label %5, label %14
14: ; preds = %5, %3, %1
%15 = phi double [ 2.000000e+00, %1 ], [ 1.000000e+00, %3 ], [ %8, %5 ]
ret double %15
}