// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]eph_converter/src/Com.cpp
// Function: xyzblh(double*, double, double, double, double, double, double, double*)
void xyzblh(double* x, double scale, double a0, double b0, double dx, double dy,
		double dz, double* geod) {
	double a, b;
	long double xp, yp, zp, s, e2, rhd, rbd, n, zps, tmp1, tmp2;
	int i;

	if (a0 == 0 || b0 == 0) {
		a = 6378137.0;
		b = 298.257223563;  //alpha = (a-b)/a
	} else {
		a = a0;
		b = b0;
	}
	for (i = 0; i < 3; i++)
		geod[i] = 0;
	xp = x[0] * scale + dx;
	yp = x[1] * scale + dy;
	zp = x[2] * scale + dz;

	if (b <= 6000000)
		b = a - a / b;
	e2 = (a * a - b * b) / (a * a);
	s = sqrt(xp * xp + yp * yp);
	geod[1] = atan(yp / xp);
	if (geod[1] < 0) {
		if (yp > 0)
			geod[1] += PI;
		if (yp < 0)
			geod[1] += 2 * PI;
	} else {
		if (yp < 0)
			geod[1] += PI;
	}
	zps = zp / s;
	geod[2] = sqrt(xp * xp + yp * yp + zp * zp) - a;
	geod[0] = atan(zps / (1.0 - e2 * a / (a + geod[2])));
	n = 1;
	rhd = rbd = 1;
	while (rbd * n > 1e-4 || rhd > 1e-4) {
		n = a / sqrt(1.0 - e2 * sin(geod[0]) * sin(geod[0]));
		tmp1 = geod[0];
		tmp2 = geod[2];
		geod[2] = s / cos(geod[0]) - n;
		geod[0] = atan(zps / (1.0 - e2 * n / (n + geod[2])));
		rbd = ABS(tmp1 - geod[0]);
		rhd = ABS(tmp2 - geod[2]);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, %rbx
xorpd %xmm8, %xmm8
movapd %xmm2, %xmm7
cmpeqpd %xmm8, %xmm7
movapd %xmm1, %xmm6
cmpeqpd %xmm8, %xmm6
orpd %xmm7, %xmm6
movd %xmm6, %eax
testb $0x1, %al
je 0xad88
movsd 0x3520(%rip), %xmm2     # 0xe2a8
xorpd %xmm6, %xmm6
movupd %xmm6, (%rbx)
movq $0x0, 0x10(%rbx)
je 0xada2
movsd 0x350e(%rip), %xmm1     # 0xe2b0
movsd (%rdi), %xmm6
mulsd %xmm0, %xmm6
addsd %xmm3, %xmm6
movsd %xmm6, -0xd8(%rbp)
fldl -0xd8(%rbp)
movsd 0x8(%rdi), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm4, %xmm3
movapd %xmm3, -0x50(%rbp)
movsd %xmm3, -0xe0(%rbp)
fldl -0xe0(%rbp)
mulsd 0x10(%rdi), %xmm0
addsd %xmm5, %xmm0
movsd %xmm0, -0xe8(%rbp)
fldl -0xe8(%rbp)
fstpt -0x2c(%rbp)
movapd %xmm1, %xmm0
divsd %xmm2, %xmm0
movapd %xmm1, %xmm3
subsd %xmm0, %xmm3
movapd %xmm2, %xmm0
cmpnlesd 0x34a5(%rip), %xmm0     # 0xe2b8
andpd %xmm0, %xmm2
andnpd %xmm3, %xmm0
orpd %xmm2, %xmm0
mulsd %xmm0, %xmm0
movapd %xmm1, -0x40(%rbp)
mulsd %xmm1, %xmm1
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, -0xc8(%rbp)
fldl -0xc8(%rbp)
fstpt -0x20(%rbp)
fld %st(0)
fmul %st(1), %st
fld %st(2)
fmul %st(3), %st
faddp %st, %st(1)
fld %st(0)
fstpt -0x14(%rbp)
fsqrt
fstpt -0x5c(%rbp)
fdivp %st, %st(1)
fstpt (%rsp)
callq 0x3470
fstpl -0xd0(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, 0x8(%rbx)
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0xaed4
movapd -0x50(%rbp), %xmm5
ucomisd %xmm1, %xmm5
movapd -0x40(%rbp), %xmm4
je 0xaef1
movsd 0x2ecc(%rip), %xmm2     # 0xdd68
addsd %xmm0, %xmm2
xorpd %xmm3, %xmm3
cmpltsd %xmm5, %xmm3
andpd %xmm3, %xmm2
andnpd %xmm0, %xmm3
orpd %xmm2, %xmm3
cmpltsd %xmm1, %xmm5
movapd %xmm5, %xmm0
andnpd %xmm3, %xmm0
addsd 0x2e96(%rip), %xmm3     # 0xdd60
andpd %xmm3, %xmm5
orpd %xmm0, %xmm5
jmp 0xaeec
ucomisd -0x50(%rbp), %xmm1
movapd -0x40(%rbp), %xmm4
jbe 0xaef1
addsd 0x2e80(%rip), %xmm0     # 0xdd68
movapd %xmm0, %xmm5
movsd %xmm5, 0x8(%rbx)
fldt -0x2c(%rbp)
fld %st(0)
fmul %st(1), %st
fldt -0x14(%rbp)
faddp %st, %st(1)
fsqrt
movsd %xmm4, -0xc0(%rbp)
fldl -0xc0(%rbp)
fsubr %st, %st(1)
fxch %st(1)
fstpl -0xb8(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, 0x10(%rbx)
fldt -0x20(%rbp)
fld %st(1)
fstpt -0x10c(%rbp)
fmulp %st, %st(1)
addsd %xmm0, %xmm4
movsd %xmm4, -0xb0(%rbp)
fdivl -0xb0(%rbp)
fldt -0x5c(%rbp)
fdivrp %st, %st(2)
fld1
fsubp %st, %st(1)
fld %st(1)
fstpt -0x100(%rbp)
fdivrp %st, %st(1)
fstpt (%rsp)
callq 0x3470
fstpl -0xa8(%rbp)
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, (%rbx)
fldt -0x20(%rbp)
fchs
fstpt -0xf4(%rbp)
fldl 0x333f(%rip)            # 0xe2c0
fstpt -0x14(%rbp)
fldz
fstp %st(0)
callq 0x30a0
movsd %xmm0, -0xa0(%rbp)
movsd (%rbx), %xmm0
callq 0x30a0
movsd %xmm0, -0x98(%rbp)
fldt -0xf4(%rbp)
fmull -0xa0(%rbp)
fmull -0x98(%rbp)
fld1
faddp %st, %st(1)
fstpt (%rsp)
callq 0x33d0
fldt -0x10c(%rbp)
fdivp %st, %st(1)
fstpt -0x40(%rbp)
movsd (%rbx), %xmm0
movsd %xmm0, -0x90(%rbp)
fldl -0x90(%rbp)
fstpt -0x50(%rbp)
fldl 0x10(%rbx)
fstpt -0x2c(%rbp)
callq 0x34e0
movsd %xmm0, -0x88(%rbp)
fldt -0x5c(%rbp)
fdivl -0x88(%rbp)
fldt -0x40(%rbp)
fsubr %st, %st(1)
fxch %st(1)
fstpl -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, 0x10(%rbx)
movsd %xmm0, -0x78(%rbp)
fld %st(0)
faddl -0x78(%rbp)
fldt -0x20(%rbp)
fmulp %st, %st(2)
fdivrp %st, %st(1)
fld1
fsubp %st, %st(1)
fldt -0x100(%rbp)
fdivp %st, %st(1)
fstpt (%rsp)
callq 0x3470
fstpl -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, (%rbx)
movsd %xmm0, -0x68(%rbp)
fldt -0x50(%rbp)
fsubl -0x68(%rbp)
fld %st(0)
fchs
fxch %st(1)
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
fldt -0x2c(%rbp)
fsubl 0x10(%rbx)
fld %st(0)
fchs
fxch %st(1)
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
fldt -0x40(%rbp)
fmulp %st, %st(2)
fldt -0x14(%rbp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
ja 0xaf86
fldt -0x14(%rbp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
fldz
ja 0xaf86
fstp %st(0)
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %rbp
retq