#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*/ remainder(double, double);
double rt;
int prime(double n) {
  double sqrt(double x);
  register double d = 3;
  register rt;
  if (n < 2)
    return 0;
  if (n == 2)
    return 1;
  if (!(remainder((n), (2))))
    return 0;
  rt = sqrt(n);
  while (d <= rt) {
    if (!(remainder((n), (d))))
      return 0;
    d += 2;
  }
  return 1;
}


x86 assembly (clang, -O0):
<prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xed3(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xebe(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1159 <prime+0x39>
movl   $0x0,-0x4(%rbp)
jmp    1210 <prime+0xf0>
movsd  -0x10(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1182 <prime+0x62>
jp     1182 <prime+0x62>
movl   $0x1,-0x4(%rbp)
jmp    1210 <prime+0xf0>
movsd  -0x10(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
call   1030 <remainder@plt>
cmp    $0x0,%eax
jne    11a9 <prime+0x89>
movl   $0x0,-0x4(%rbp)
jmp    1210 <prime+0xf0>
movsd  -0x10(%rbp),%xmm0
call   1040 <sqrt@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1209 <prime+0xe9>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <remainder@plt>
cmp    $0x0,%eax
jne    11f2 <prime+0xd2>
movl   $0x0,-0x4(%rbp)
jmp    1210 <prime+0xf0>
movsd  0xe06(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ba <prime+0x9a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prime>:
push   %rbx
sub    $0x20,%rsp
xor    %ebx,%ebx
movsd  0xed1(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1146 <prime+0x26>
ucomisd 0xec3(%rip),%xmm0
jne    114e <prime+0x2e>
jp     114e <prime+0x2e>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret
movsd  0xeaa(%rip),%xmm1
movsd  %xmm0,(%rsp)
call   1030 <remainder@plt>
test   %eax,%eax
je     1146 <prime+0x26>
xorpd  %xmm0,%xmm0
movsd  (%rsp),%xmm2
ucomisd %xmm0,%xmm2
jb     117c <prime+0x5c>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    118a <prime+0x6a>
movapd %xmm2,%xmm0
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm2
cvttsd2si %xmm0,%eax
cmp    $0x3,%eax
jl     1141 <prime+0x21>
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0xe5f(%rip),%xmm1
nopl   0x0(%rax)
movapd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <remainder@plt>
test   %eax,%eax
je     1146 <prime+0x26>
movsd  0x8(%rsp),%xmm1
addsd  0xe2f(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
ucomisd %xmm1,%xmm0
movsd  (%rsp),%xmm2
jae    11b0 <prime+0x90>
jmp    1141 <prime+0x21>

LLVM IR (-O0):
@rt = global double 0.000000e+00
define i32 @prime(double %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double %0, double* %3
store double 3.000000e+00, double* %4
%6 = load double, double* %3
%7 = fcmp olt double %6, 2.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %37
9: ; preds = %1
%10 = load double, double* %3
%11 = fcmp oeq double %10, 2.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 1, i32* %2
br label %37
13: ; preds = %9
%14 = load double, double* %3
%15 = call i32 @remainder(double %14, double 2.000000e+00)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i32 0, i32* %2
br label %37
18: ; preds = %13
%19 = load double, double* %3
%20 = call double @sqrt(double %19)
%21 = fptosi double %20 to i32
store i32 %21, i32* %5
br label %22
22: ; preds = %33, %18
%23 = load double, double* %4
%24 = load i32, i32* %5
%25 = sitofp i32 %24 to double
%26 = fcmp ole double %23, %25
br i1 %26, label %27, label %36
27: ; preds = %22
%28 = load double, double* %3
%29 = load double, double* %4
%30 = call i32 @remainder(double %28, double %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %27
store i32 0, i32* %2
br label %37
33: ; preds = %27
%34 = load double, double* %4
%35 = fadd double %34, 2.000000e+00
store double %35, double* %4
br label %22
36: ; preds = %22
store i32 1, i32* %2
br label %37
37: ; preds = %36, %32, %17, %12, %8
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@rt = global double 0.000000e+00
define i32 @prime(double %0) {
%2 = fcmp olt double %0, 2.000000e+00
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = fcmp oeq double %0, 2.000000e+00
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = tail call i32 @remainder(double %0, double 2.000000e+00)
%7 = icmp eq i32 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %5
%9 = tail call double @sqrt(double %0)
%10 = fptosi double %9 to i32
%11 = sitofp i32 %10 to double
%12 = icmp slt i32 %10, 3
br i1 %12, label %20, label %13
13: ; preds = %8, %17
%14 = phi double [ %18, %17 ], [ 3.000000e+00, %8 ]
%15 = tail call i32 @remainder(double %0, double %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = fadd double %14, 2.000000e+00
%19 = fcmp ugt double %18, %11
br i1 %19, label %20, label %13
20: ; preds = %13, %17, %8, %5, %3, %1
%21 = phi i32 [ 0, %1 ], [ 1, %3 ], [ 0, %5 ], [ 1, %8 ], [ 0, %13 ], [ 1, %17 ]
ret i32 %21
}