// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rnxobs/Com.cpp
// Function: bamboo::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
xorps %xmm6, %xmm6
movups %xmm6, (%rsi)
movq $0x0, 0x10(%rsi)
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 0x1e29f
movsd 0x4c651(%rip), %xmm2    # 0x6a8f0
je 0x1e2a9
movsd 0x4c64f(%rip), %xmm1    # 0x6a8f8
movsd (%rdi), %xmm6
mulsd %xmm0, %xmm6
addsd %xmm3, %xmm6
movsd %xmm6, -0xf0(%rbp)
fldl -0xf0(%rbp)
fld %st(0)
fstpt -0x3c(%rbp)
movsd 0x8(%rdi), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, -0x18(%rbp)
movsd %xmm3, -0xf8(%rbp)
fldl -0xf8(%rbp)
fld %st(0)
fstpt -0x24(%rbp)
mulsd 0x10(%rdi), %xmm0
addsd %xmm5, %xmm0
movsd %xmm0, -0x100(%rbp)
fldl -0x100(%rbp)
fstpt -0x54(%rbp)
movapd %xmm1, %xmm0
divsd %xmm2, %xmm0
movapd %xmm1, %xmm3
subsd %xmm0, %xmm3
movapd %xmm2, %xmm0
cmpnlesd 0x4c5dc(%rip), %xmm0    # 0x6a900
andpd %xmm0, %xmm2
andnpd %xmm3, %xmm0
orpd %xmm2, %xmm0
mulsd %xmm0, %xmm0
movapd %xmm1, -0x70(%rbp)
mulsd %xmm1, %xmm1
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, -0xe8(%rbp)
fldl -0xe8(%rbp)
fstpt -0x48(%rbp)
fmul %st, %st(0)
fxch %st(1)
fmul %st, %st(0)
faddp %st, %st(1)
fld %st(0)
fstpt -0x30(%rbp)
fstpt (%rsp)
callq 0x88b0
fstpt -0x7c(%rbp)
fldt -0x24(%rbp)
fldt -0x3c(%rbp)
fdivrp %st, %st(1)
fstpt (%rsp)
callq 0x8ab0
fstpl -0xe0(%rbp)
movsd -0xe0(%rbp), %xmm0
movsd %xmm0, 0x8(%rbx)
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1e3cc
movsd -0x18(%rbp), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x1e3b7
addsd 0x4c55e(%rip), %xmm0    # 0x6a910
movsd %xmm0, 0x8(%rbx)
ucomisd %xmm2, %xmm1
jbe 0x1e3e0
movsd 0x8(%rbx), %xmm0
addsd 0x4c54e(%rip), %xmm0    # 0x6a918
jmp 0x1e3db
ucomisd -0x18(%rbp), %xmm1
jbe 0x1e3e0
addsd 0x4c535(%rip), %xmm0    # 0x6a910
movsd %xmm0, 0x8(%rbx)
fldt -0x7c(%rbp)
fldt -0x54(%rbp)
fdiv %st, %st(1)
fxch %st(1)
fstpt -0x24(%rbp)
fmul %st, %st(0)
fldt -0x30(%rbp)
faddp %st, %st(1)
fstpt (%rsp)
callq 0x88b0
movapd -0x70(%rbp), %xmm1
movsd %xmm1, -0xd8(%rbp)
fldl -0xd8(%rbp)
fsubr %st, %st(1)
fxch %st(1)
fstpl -0xd0(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, 0x10(%rbx)
fldt -0x48(%rbp)
fld %st(1)
fstpt -0x3c(%rbp)
fmulp %st, %st(1)
addsd %xmm0, %xmm1
movsd %xmm1, -0xc8(%rbp)
fdivl -0xc8(%rbp)
fld1
fsubp %st, %st(1)
fldt -0x24(%rbp)
fdivp %st, %st(1)
fstpt (%rsp)
callq 0x8ab0
fstpl (%rbx)
fldt -0x48(%rbp)
fchs
fstpt -0x10c(%rbp)
fldl 0x4c4ba(%rip)           # 0x6a920
fstpt -0x30(%rbp)
fldz
fstp %st(0)
movsd (%rbx), %xmm0
callq 0x8150
movsd %xmm0, -0xc0(%rbp)
movsd (%rbx), %xmm0
callq 0x8150
movsd %xmm0, -0xb8(%rbp)
fldt -0x10c(%rbp)
fmull -0xc0(%rbp)
fmull -0xb8(%rbp)
fld1
faddp %st, %st(1)
fstpt (%rsp)
callq 0x88b0
fldt -0x3c(%rbp)
fdivp %st, %st(1)
fstpt -0x70(%rbp)
movsd (%rbx), %xmm0
movsd %xmm0, -0xb0(%rbp)
fldl -0xb0(%rbp)
fstpt -0x18(%rbp)
fldl 0x10(%rbx)
fstpt -0x54(%rbp)
callq 0x8c00
movsd %xmm0, -0xa8(%rbp)
fldt -0x7c(%rbp)
fdivl -0xa8(%rbp)
fldt -0x70(%rbp)
fsubr %st, %st(1)
fxch %st(1)
fstpl -0xa0(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, 0x10(%rbx)
movsd %xmm0, -0x98(%rbp)
fld %st(0)
faddl -0x98(%rbp)
fldt -0x48(%rbp)
fmulp %st, %st(2)
fdivrp %st, %st(1)
fld1
fsubp %st, %st(1)
fldt -0x24(%rbp)
fdivp %st, %st(1)
fstpt (%rsp)
callq 0x8ab0
fstpl -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, (%rbx)
movsd %xmm0, -0x88(%rbp)
fldt -0x18(%rbp)
fsubl -0x88(%rbp)
fld %st(0)
fchs
fxch %st(1)
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
fldt -0x54(%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 -0x70(%rbp)
fmulp %st, %st(2)
fldt -0x30(%rbp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
ja 0x1e46b
fldt -0x30(%rbp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
fldz
ja 0x1e46b
fstp %st(0)
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %rbp
retq