#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*/ BuG(char *);
int /*<<< orphan*/ _cross_prod(long double *, long double *, long double *);
int _den(long double, long double, long double, long double, long double,
         long double);
int /*<<< orphan*/ _to_cart(long double *, long double *);
int /*<<< orphan*/ _to_sphere(long double *, long double *);
double angle_betw_0pi(long double *, long double *);
scalar_t__ euclid_dist(long double *, long double *);
int fabsl(long double);
int proj_point_to_circle(long double *p0, long double *p1, long double *px,
                         long double *ph, long double *dist) {
  long double A[3], B[3], P[3];
  _to_cart(p0, A);
  _to_cart(p1, B);
  _to_cart(px, P);
  long double N[3];
  _cross_prod(A, B, N);
  long double theta =
      angle_betw_0pi(N, P) -
      3.14159265358979323846264338327950288419716939937510582097 / 2.;
  *dist = 6371000. * fabsl(theta);
  long double T[3];
  _cross_prod(N, P, T);
  long double a = N[0];
  long double b = N[1];
  long double c = N[2];
  long double d = T[0];
  long double e = T[1];
  long double f = T[2];
  long double t = 6371000. / _den(a, b, c, d, e, f);
  if (_den(a, b, c, d, e, f) == 0)
    BuG("DEN ZERO\n");
  if ((b * d - a * e) == 0)
    BuG("bd ae zero\n");
  long double X1[3], X2[3];
  X1[0] = -((b * f - c * e) / (b * d - a * e)) * t;
  X1[1] = -((c * d - a * f) / (b * d - a * e)) * t;
  X1[2] = t;
  X2[0] = -X1[0];
  X2[1] = -X1[1];
  X2[2] = -X1[2];
  if (euclid_dist(X1, A) < euclid_dist(X2, A))
    _to_sphere(X1, ph);
  else
    _to_sphere(X2, ph);
  return 1;
}


x86 assembly (clang, -O0):
<proj_point_to_circle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    %rsi,-0x240(%rbp)
call   10a0 <_to_cart@plt>
mov    -0x10(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    %rsi,-0x238(%rbp)
call   10a0 <_to_cart@plt>
mov    -0x18(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
mov    %rsi,-0x228(%rbp)
call   10a0 <_to_cart@plt>
mov    -0x240(%rbp),%rdi
mov    -0x238(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
mov    %rdx,-0x230(%rbp)
call   1070 <_cross_prod@plt>
mov    -0x230(%rbp),%rdi
mov    -0x228(%rbp),%rsi
call   1060 <angle_betw_0pi@plt>
movsd  0xde3(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x208(%rbp)
ff
fldl   -0x208(%rbp)
fstpt  -0x100(%rbp)
fldt   -0x100(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <fabsl@plt>
mov    -0x230(%rbp),%rdi
mov    -0x228(%rbp),%rsi
cvtsi2sd %eax,%xmm0
movsd  0xda9(%rip),%xmm1
movsd  %xmm1,-0x220(%rbp)
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x210(%rbp)
ff
fldl   -0x210(%rbp)
mov    -0x28(%rbp),%rax
fstpt  (%rax)
lea    -0x130(%rbp),%rdx
call   1070 <_cross_prod@plt>
fldt   -0xf0(%rbp)
fstpt  -0x140(%rbp)
fldt   -0xe0(%rbp)
fstpt  -0x150(%rbp)
fldt   -0xd0(%rbp)
fstpt  -0x160(%rbp)
fldt   -0x130(%rbp)
fstpt  -0x170(%rbp)
fldt   -0x120(%rbp)
fstpt  -0x180(%rbp)
fldt   -0x110(%rbp)
fstpt  -0x190(%rbp)
fldt   -0x140(%rbp)
fldt   -0x150(%rbp)
fldt   -0x160(%rbp)
fldt   -0x170(%rbp)
fldt   -0x180(%rbp)
fldt   -0x190(%rbp)
mov    %rsp,%rax
fstpt  0x50(%rax)
fstpt  0x40(%rax)
fstpt  0x30(%rax)
fstpt  0x20(%rax)
fstpt  0x10(%rax)
fstpt  (%rax)
call   1030 <_den@plt>
movsd  -0x220(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x218(%rbp)
ff
fldl   -0x218(%rbp)
fstpt  -0x1a0(%rbp)
fldt   -0x140(%rbp)
fldt   -0x150(%rbp)
fldt   -0x160(%rbp)
fldt   -0x170(%rbp)
fldt   -0x180(%rbp)
fldt   -0x190(%rbp)
mov    %rsp,%rax
fstpt  0x50(%rax)
fstpt  0x40(%rax)
fstpt  0x30(%rax)
fstpt  0x20(%rax)
fstpt  0x10(%rax)
fstpt  (%rax)
call   1030 <_den@plt>
cmp    $0x0,%eax
jne    1386 <proj_point_to_circle+0x206>
lea    0xc8f(%rip),%rdi
call   1050 <BuG@plt>
fldt   -0x150(%rbp)
fldt   -0x170(%rbp)
fldt   -0x140(%rbp)
fldt   -0x180(%rbp)
fmulp  %st,%st(1)
fxch   %st(2)
fmulp  %st,%st(1)
fsubp  %st,%st(1)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    13cb <proj_point_to_circle+0x24b>
jp     13cb <proj_point_to_circle+0x24b>
jmp    13bf <proj_point_to_circle+0x23f>
lea    0xc54(%rip),%rdi
call   1050 <BuG@plt>
fldt   -0x150(%rbp)
fldt   -0x190(%rbp)
fldt   -0x160(%rbp)
fldt   -0x180(%rbp)
fmul   %st,%st(1)
fxch   %st(2)
fmul   %st(3),%st
fsubp  %st,%st(1)
fldt   -0x170(%rbp)
fldt   -0x140(%rbp)
fmulp  %st,%st(3)
fmulp  %st,%st(3)
fxch   %st(2)
fsubp  %st,%st(1)
fdivrp %st,%st(1)
fchs
fldt   -0x1a0(%rbp)
fmulp  %st,%st(1)
fstpt  -0x1d0(%rbp)
fldt   -0x160(%rbp)
fldt   -0x170(%rbp)
fldt   -0x140(%rbp)
fldt   -0x190(%rbp)
fmul   %st(1),%st
fxch   %st(3)
fmul   %st(2),%st
fsubp  %st,%st(3)
fldt   -0x150(%rbp)
fldt   -0x180(%rbp)
fmulp  %st,%st(2)
fmulp  %st,%st(2)
fsubrp %st,%st(1)
fdivrp %st,%st(1)
fchs
fldt   -0x1a0(%rbp)
fmulp  %st,%st(1)
fstpt  -0x1c0(%rbp)
fldt   -0x1a0(%rbp)
fstpt  -0x1b0(%rbp)
fldt   -0x1d0(%rbp)
fchs
fstpt  -0x200(%rbp)
fldt   -0x1c0(%rbp)
fchs
fstpt  -0x1f0(%rbp)
fldt   -0x1b0(%rbp)
fchs
fstpt  -0x1e0(%rbp)
lea    -0x1d0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <euclid_dist@plt>
mov    %rax,-0x248(%rbp)
lea    -0x200(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <euclid_dist@plt>
mov    %rax,%rcx
mov    -0x248(%rbp),%rax
cmp    %rcx,%rax
jge    14da <proj_point_to_circle+0x35a>
lea    -0x1d0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <_to_sphere@plt>
jmp    14ea <proj_point_to_circle+0x36a>
lea    -0x200(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <_to_sphere@plt>
mov    $0x1,%eax
add    $0x2b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proj_point_to_circle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %r8,%r15
mov    %rcx,0xa8(%rsp)
mov    %rdx,%r13
mov    %rsi,%rbx
lea    0x1a0(%rsp),%rbp
mov    %rbp,%rsi
call   10a0 <_to_cart@plt>
lea    0x200(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <_to_cart@plt>
lea    0x1d0(%rsp),%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   10a0 <_to_cart@plt>
lea    0x170(%rsp),%rbx
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1070 <_cross_prod@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <angle_betw_0pi@plt>
addsd  0xdff(%rip),%xmm0
movsd  %xmm0,0xc0(%rsp)
fldl   0xc0(%rsp)
fstpt  (%rsp)
call   1040 <fabsl@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xde0(%rip),%xmm0
movsd  %xmm0,0xb8(%rsp)
fldl   0xb8(%rsp)
fstpt  (%r15)
lea    0x140(%rsp),%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <_cross_prod@plt>
fldt   0x170(%rsp)
fld    %st(0)
fstpt  0x60(%rsp)
fldt   0x180(%rsp)
fld    %st(0)
fstpt  0x78(%rsp)
fldt   0x190(%rsp)
fld    %st(0)
fstpt  0x9c(%rsp)
fldt   0x140(%rsp)
fld    %st(0)
fstpt  0x84(%rsp)
fldt   0x150(%rsp)
fld    %st(0)
fstpt  0x6c(%rsp)
fldt   0x160(%rsp)
fld    %st(0)
fstpt  0x90(%rsp)
fstpt  0x50(%rsp)
fstpt  0x40(%rsp)
fstpt  0x30(%rsp)
fstpt  0x20(%rsp)
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1030 <_den@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xd38(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0xb0(%rsp)
fldl   0xb0(%rsp)
fstpt  0xd4(%rsp)
fldt   0x90(%rsp)
fstpt  0x50(%rsp)
fldt   0x6c(%rsp)
fstpt  0x40(%rsp)
fldt   0x84(%rsp)
fstpt  0x30(%rsp)
fldt   0x9c(%rsp)
fstpt  0x20(%rsp)
fldt   0x78(%rsp)
fstpt  0x10(%rsp)
fldt   0x60(%rsp)
fstpt  (%rsp)
call   1030 <_den@plt>
test   %eax,%eax
jne    1338 <proj_point_to_circle+0x1b8>
lea    0xcdd(%rip),%rdi
call   1050 <BuG@plt>
fldt   0x60(%rsp)
fld    %st(0)
fchs
fldt   0x6c(%rsp)
fmul   %st,%st(2)
fldt   0x78(%rsp)
fldt   0x84(%rsp)
fld    %st(1)
fmul   %st(1),%st
fsubp  %st,%st(5)
fldz
fxch   %st(5)
fucomi %st(5),%st
fstp   %st(5)
jne    13a2 <proj_point_to_circle+0x222>
jp     13a2 <proj_point_to_circle+0x222>
fstp   %st(2)
fstp   %st(0)
fstp   %st(0)
lea    0xcaa(%rip),%rdi
fxch   %st(1)
fstpt  0x60(%rsp)
fstpt  0xc8(%rsp)
call   1050 <BuG@plt>
fldt   0xc8(%rsp)
fldt   0x60(%rsp)
fldt   0x6c(%rsp)
fldt   0x78(%rsp)
fldt   0x84(%rsp)
fxch   %st(3)
fxch   %st(4)
fxch   %st(3)
fldt   0x9c(%rsp)
fmul   %st,%st(3)
fldt   0x90(%rsp)
fmul   %st,%st(3)
fxch   %st(3)
fsubp  %st,%st(4)
fxch   %st(2)
fmulp  %st,%st(4)
fmulp  %st,%st(1)
faddp  %st,%st(2)
fchs
fdiv   %st(2),%st
fxch   %st(1)
fchs
fdivp  %st,%st(2)
fldt   0xd4(%rsp)
fmul   %st,%st(1)
fld    %st(1)
fstpt  0x110(%rsp)
fxch   %st(1)
fchs
fstpt  0xe0(%rsp)
fmul   %st,%st(1)
fld    %st(1)
fstpt  0x120(%rsp)
fxch   %st(1)
fchs
fstpt  0xf0(%rsp)
fld    %st(0)
fstpt  0x130(%rsp)
fchs
fstpt  0x100(%rsp)
lea    0x110(%rsp),%r14
lea    0x1a0(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <euclid_dist@plt>
mov    %rax,%rbx
lea    0xe0(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
call   1080 <euclid_dist@plt>
cmp    %rax,%rbx
cmovl  %r14,%rbp
mov    %rbp,%rdi
mov    0xa8(%rsp),%rsi
call   1090 <_to_sphere@plt>
mov    $0x1,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"DEN ZERO\0A\00"
@.str.1 = [12 x i8] c"bd ae zero\0A\00"
define i32 @proj_point_to_circle(x86_fp80* %0, x86_fp80* %1, x86_fp80* %2, x86_fp80* %3, x86_fp80* %4) {
%6 = alloca x86_fp80*
%7 = alloca x86_fp80*
%8 = alloca x86_fp80*
%9 = alloca x86_fp80*
%10 = alloca x86_fp80*
%11 = alloca [3 x x86_fp80]
%12 = alloca [3 x x86_fp80]
%13 = alloca [3 x x86_fp80]
%14 = alloca [3 x x86_fp80]
%15 = alloca x86_fp80
%16 = alloca [3 x x86_fp80]
%17 = alloca x86_fp80
%18 = alloca x86_fp80
%19 = alloca x86_fp80
%20 = alloca x86_fp80
%21 = alloca x86_fp80
%22 = alloca x86_fp80
%23 = alloca x86_fp80
%24 = alloca [3 x x86_fp80]
%25 = alloca [3 x x86_fp80]
store x86_fp80* %0, x86_fp80** %6
store x86_fp80* %1, x86_fp80** %7
store x86_fp80* %2, x86_fp80** %8
store x86_fp80* %3, x86_fp80** %9
store x86_fp80* %4, x86_fp80** %10
%26 = load x86_fp80*, x86_fp80** %6
%27 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %11, i64 0, i64 0
%28 = call i32 @_to_cart(x86_fp80* %26, x86_fp80* %27)
%29 = load x86_fp80*, x86_fp80** %7
%30 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %12, i64 0, i64 0
%31 = call i32 @_to_cart(x86_fp80* %29, x86_fp80* %30)
%32 = load x86_fp80*, x86_fp80** %8
%33 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %13, i64 0, i64 0
%34 = call i32 @_to_cart(x86_fp80* %32, x86_fp80* %33)
%35 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %11, i64 0, i64 0
%36 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %12, i64 0, i64 0
%37 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %14, i64 0, i64 0
%38 = call i32 @_cross_prod(x86_fp80* %35, x86_fp80* %36, x86_fp80* %37)
%39 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %14, i64 0, i64 0
%40 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %13, i64 0, i64 0
%41 = call double @angle_betw_0pi(x86_fp80* %39, x86_fp80* %40)
%42 = fsub double %41, 0x3FF921FB54442D18
%43 = fpext double %42 to x86_fp80
store x86_fp80 %43, x86_fp80* %15
%44 = load x86_fp80, x86_fp80* %15
%45 = call i32 @fabsl(x86_fp80 %44)
%46 = sitofp i32 %45 to double
%47 = fmul double 6.371000e+06, %46
%48 = fpext double %47 to x86_fp80
%49 = load x86_fp80*, x86_fp80** %10
store x86_fp80 %48, x86_fp80* %49
%50 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %14, i64 0, i64 0
%51 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %13, i64 0, i64 0
%52 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %16, i64 0, i64 0
%53 = call i32 @_cross_prod(x86_fp80* %50, x86_fp80* %51, x86_fp80* %52)
%54 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %14, i64 0, i64 0
%55 = load x86_fp80, x86_fp80* %54
store x86_fp80 %55, x86_fp80* %17
%56 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %14, i64 0, i64 1
%57 = load x86_fp80, x86_fp80* %56
store x86_fp80 %57, x86_fp80* %18
%58 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %14, i64 0, i64 2
%59 = load x86_fp80, x86_fp80* %58
store x86_fp80 %59, x86_fp80* %19
%60 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %16, i64 0, i64 0
%61 = load x86_fp80, x86_fp80* %60
store x86_fp80 %61, x86_fp80* %20
%62 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %16, i64 0, i64 1
%63 = load x86_fp80, x86_fp80* %62
store x86_fp80 %63, x86_fp80* %21
%64 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %16, i64 0, i64 2
%65 = load x86_fp80, x86_fp80* %64
store x86_fp80 %65, x86_fp80* %22
%66 = load x86_fp80, x86_fp80* %17
%67 = load x86_fp80, x86_fp80* %18
%68 = load x86_fp80, x86_fp80* %19
%69 = load x86_fp80, x86_fp80* %20
%70 = load x86_fp80, x86_fp80* %21
%71 = load x86_fp80, x86_fp80* %22
%72 = call i32 @_den(x86_fp80 %66, x86_fp80 %67, x86_fp80 %68, x86_fp80 %69, x86_fp80 %70, x86_fp80 %71)
%73 = sitofp i32 %72 to double
%74 = fdiv double 6.371000e+06, %73
%75 = fpext double %74 to x86_fp80
store x86_fp80 %75, x86_fp80* %23
%76 = load x86_fp80, x86_fp80* %17
%77 = load x86_fp80, x86_fp80* %18
%78 = load x86_fp80, x86_fp80* %19
%79 = load x86_fp80, x86_fp80* %20
%80 = load x86_fp80, x86_fp80* %21
%81 = load x86_fp80, x86_fp80* %22
%82 = call i32 @_den(x86_fp80 %76, x86_fp80 %77, x86_fp80 %78, x86_fp80 %79, x86_fp80 %80, x86_fp80 %81)
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %5
%85 = call i32 @BuG(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %86
86: ; preds = %84, %5
%87 = load x86_fp80, x86_fp80* %18
%88 = load x86_fp80, x86_fp80* %20
%89 = load x86_fp80, x86_fp80* %17
%90 = load x86_fp80, x86_fp80* %21
%91 = fmul x86_fp80 %89, %90
%92 = fneg x86_fp80 %91
%93 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %87, x86_fp80 %88, x86_fp80 %92)
%94 = fcmp oeq x86_fp80 %93, 0xK00000000000000000000
br i1 %94, label %95, label %97
95: ; preds = %86
%96 = call i32 @BuG(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %97
97: ; preds = %95, %86
%98 = load x86_fp80, x86_fp80* %18
%99 = load x86_fp80, x86_fp80* %22
%100 = load x86_fp80, x86_fp80* %19
%101 = load x86_fp80, x86_fp80* %21
%102 = fmul x86_fp80 %100, %101
%103 = fneg x86_fp80 %102
%104 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %98, x86_fp80 %99, x86_fp80 %103)
%105 = load x86_fp80, x86_fp80* %18
%106 = load x86_fp80, x86_fp80* %20
%107 = load x86_fp80, x86_fp80* %17
%108 = load x86_fp80, x86_fp80* %21
%109 = fmul x86_fp80 %107, %108
%110 = fneg x86_fp80 %109
%111 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %105, x86_fp80 %106, x86_fp80 %110)
%112 = fdiv x86_fp80 %104, %111
%113 = fneg x86_fp80 %112
%114 = load x86_fp80, x86_fp80* %23
%115 = fmul x86_fp80 %113, %114
%116 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %24, i64 0, i64 0
store x86_fp80 %115, x86_fp80* %116
%117 = load x86_fp80, x86_fp80* %19
%118 = load x86_fp80, x86_fp80* %20
%119 = load x86_fp80, x86_fp80* %17
%120 = load x86_fp80, x86_fp80* %22
%121 = fmul x86_fp80 %119, %120
%122 = fneg x86_fp80 %121
%123 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %117, x86_fp80 %118, x86_fp80 %122)
%124 = load x86_fp80, x86_fp80* %18
%125 = load x86_fp80, x86_fp80* %20
%126 = load x86_fp80, x86_fp80* %17
%127 = load x86_fp80, x86_fp80* %21
%128 = fmul x86_fp80 %126, %127
%129 = fneg x86_fp80 %128
%130 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %124, x86_fp80 %125, x86_fp80 %129)
%131 = fdiv x86_fp80 %123, %130
%132 = fneg x86_fp80 %131
%133 = load x86_fp80, x86_fp80* %23
%134 = fmul x86_fp80 %132, %133
%135 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %24, i64 0, i64 1
store x86_fp80 %134, x86_fp80* %135
%136 = load x86_fp80, x86_fp80* %23
%137 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %24, i64 0, i64 2
store x86_fp80 %136, x86_fp80* %137
%138 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %24, i64 0, i64 0
%139 = load x86_fp80, x86_fp80* %138
%140 = fneg x86_fp80 %139
%141 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %25, i64 0, i64 0
store x86_fp80 %140, x86_fp80* %141
%142 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %24, i64 0, i64 1
%143 = load x86_fp80, x86_fp80* %142
%144 = fneg x86_fp80 %143
%145 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %25, i64 0, i64 1
store x86_fp80 %144, x86_fp80* %145
%146 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %24, i64 0, i64 2
%147 = load x86_fp80, x86_fp80* %146
%148 = fneg x86_fp80 %147
%149 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %25, i64 0, i64 2
store x86_fp80 %148, x86_fp80* %149
%150 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %24, i64 0, i64 0
%151 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %11, i64 0, i64 0
%152 = call i64 @euclid_dist(x86_fp80* %150, x86_fp80* %151)
%153 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %25, i64 0, i64 0
%154 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %11, i64 0, i64 0
%155 = call i64 @euclid_dist(x86_fp80* %153, x86_fp80* %154)
%156 = icmp slt i64 %152, %155
br i1 %156, label %157, label %161
157: ; preds = %97
%158 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %24, i64 0, i64 0
%159 = load x86_fp80*, x86_fp80** %9
%160 = call i32 @_to_sphere(x86_fp80* %158, x86_fp80* %159)
br label %165
161: ; preds = %97
%162 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %25, i64 0, i64 0
%163 = load x86_fp80*, x86_fp80** %9
%164 = call i32 @_to_sphere(x86_fp80* %162, x86_fp80* %163)
br label %165
165: ; preds = %161, %157
ret i32 1
}

LLVM IR (-O2):
@.str = [10 x i8] c"DEN ZERO\0A\00"
@.str.1 = [12 x i8] c"bd ae zero\0A\00"
define i32 @proj_point_to_circle(x86_fp80* %0, x86_fp80* %1, x86_fp80* %2, x86_fp80* %3, x86_fp80* nocapture writeonly %4) {
%6 = alloca [3 x x86_fp80]
%7 = alloca [3 x x86_fp80]
%8 = alloca [3 x x86_fp80]
%9 = alloca [3 x x86_fp80]
%10 = alloca [3 x x86_fp80]
%11 = alloca [3 x x86_fp80]
%12 = alloca [3 x x86_fp80]
%13 = bitcast [3 x x86_fp80]* %6 to i8*
%14 = bitcast [3 x x86_fp80]* %7 to i8*
%15 = bitcast [3 x x86_fp80]* %8 to i8*
%16 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %6, i64 0, i64 0
%17 = call i32 @_to_cart(x86_fp80* %0, x86_fp80* %16)
%18 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %7, i64 0, i64 0
%19 = call i32 @_to_cart(x86_fp80* %1, x86_fp80* %18)
%20 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %8, i64 0, i64 0
%21 = call i32 @_to_cart(x86_fp80* %2, x86_fp80* %20)
%22 = bitcast [3 x x86_fp80]* %9 to i8*
%23 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %9, i64 0, i64 0
%24 = call i32 @_cross_prod(x86_fp80* %16, x86_fp80* %18, x86_fp80* %23)
%25 = call double @angle_betw_0pi(x86_fp80* %23, x86_fp80* %20)
%26 = fadd double %25, 0xBFF921FB54442D18
%27 = fpext double %26 to x86_fp80
%28 = call i32 @fabsl(x86_fp80 %27)
%29 = sitofp i32 %28 to double
%30 = fmul double %29, 6.371000e+06
%31 = fpext double %30 to x86_fp80
store x86_fp80 %31, x86_fp80* %4
%32 = bitcast [3 x x86_fp80]* %10 to i8*
%33 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %10, i64 0, i64 0
%34 = call i32 @_cross_prod(x86_fp80* %23, x86_fp80* %20, x86_fp80* %33)
%35 = load x86_fp80, x86_fp80* %23
%36 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %9, i64 0, i64 1
%37 = load x86_fp80, x86_fp80* %36
%38 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %9, i64 0, i64 2
%39 = load x86_fp80, x86_fp80* %38
%40 = load x86_fp80, x86_fp80* %33
%41 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %10, i64 0, i64 1
%42 = load x86_fp80, x86_fp80* %41
%43 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %10, i64 0, i64 2
%44 = load x86_fp80, x86_fp80* %43
%45 = call i32 @_den(x86_fp80 %35, x86_fp80 %37, x86_fp80 %39, x86_fp80 %40, x86_fp80 %42, x86_fp80 %44)
%46 = sitofp i32 %45 to double
%47 = fdiv double 6.371000e+06, %46
%48 = fpext double %47 to x86_fp80
%49 = call i32 @_den(x86_fp80 %35, x86_fp80 %37, x86_fp80 %39, x86_fp80 %40, x86_fp80 %42, x86_fp80 %44)
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %5
%52 = call i32 @BuG(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %53
53: ; preds = %51, %5
%54 = fneg x86_fp80 %35
%55 = fmul x86_fp80 %42, %54
%56 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %37, x86_fp80 %40, x86_fp80 %55)
%57 = fcmp oeq x86_fp80 %56, 0xK00000000000000000000
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 @BuG(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %60
60: ; preds = %58, %53
%61 = bitcast [3 x x86_fp80]* %11 to i8*
%62 = bitcast [3 x x86_fp80]* %12 to i8*
%63 = fneg x86_fp80 %39
%64 = fmul x86_fp80 %42, %63
%65 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %37, x86_fp80 %44, x86_fp80 %64)
%66 = fneg x86_fp80 %65
%67 = fdiv x86_fp80 %66, %56
%68 = fmul x86_fp80 %67, %48
%69 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %11, i64 0, i64 0
store x86_fp80 %68, x86_fp80* %69
%70 = fmul x86_fp80 %44, %54
%71 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %39, x86_fp80 %40, x86_fp80 %70)
%72 = fneg x86_fp80 %71
%73 = fdiv x86_fp80 %72, %56
%74 = fmul x86_fp80 %73, %48
%75 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %11, i64 0, i64 1
store x86_fp80 %74, x86_fp80* %75
%76 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %11, i64 0, i64 2
store x86_fp80 %48, x86_fp80* %76
%77 = fneg x86_fp80 %68
%78 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %12, i64 0, i64 0
store x86_fp80 %77, x86_fp80* %78
%79 = fneg x86_fp80 %74
%80 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %12, i64 0, i64 1
store x86_fp80 %79, x86_fp80* %80
%81 = fneg x86_fp80 %48
%82 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %12, i64 0, i64 2
store x86_fp80 %81, x86_fp80* %82
%83 = call i64 @euclid_dist(x86_fp80* %69, x86_fp80* %16)
%84 = call i64 @euclid_dist(x86_fp80* %78, x86_fp80* %16)
%85 = icmp slt i64 %83, %84
%86 = select i1 %85, x86_fp80* %69, x86_fp80* %78
%87 = call i32 @_to_sphere(x86_fp80* %86, x86_fp80* %3)
ret i32 1
}