// File: /workspace/github_cpp_makefile_star2_O3/jingdao[P]PointCloudApp/pcd.cpp
// Function: wgs2utm(double, double, double*, double*)
void wgs2utm(double lat, double lon, double *easting, double *northing) {
	double a = 6378137;
	double f = 1 / 298.257223563;
	double k0 = 0.9996;
	double b = a * (1 - f);
	double e = sqrt(1 - b * b / a / a);
	double phi = lat / 180 * M_PI;

	double utmz = 1 + floor((lon + 180) / 6);            // longitude to utm zone
	double zcm = 3 + 6 * (utmz - 1) - 180;                     // central meridian of a zone
	double esq = (1 - (b / a) * (b / a));
	double e0sq = e * e / (1 - pow(e, 2));
	double M = 0;

	double N = a / sqrt(1 - pow(e * sin(phi), 2));
	double T = pow(tan(phi), 2);
	double C = e0sq * pow(cos(phi), 2);
	double A = (lon - zcm) * M_PI / 180 * cos(phi);

	// calculate M (USGS style)
	M = phi * (1 - esq * (1.0 / 4 + esq * (3.0 / 64 + 5 * esq / 256)));
	M = M - sin(2 * phi) * (esq * (3.0 / 8 + esq * (3.0 / 32 + 45 * esq / 1024)));
	M = M + sin(4 * phi) * (esq * esq * (15.0 / 256 + esq * 45.0 / 1024));
	M = M - sin(6 * phi) * (esq * esq * esq * (35.0 / 3072));
	M = M * a;                                      //Arc length along standard meridian
	double M0 = 0;                                         // if another point of origin is used than the equator

	// now we are ready to calculate the UTM values...
	// first the easting
	double x = k0 * N * A * (1 + A * A * ((1 - T + C) / 6 + A * A * (5 - 18 * T + T * T + 72 * C - 58 * e0sq) / 120)); //Easting relative to CM
	x = x + 500000; // standard easting
	// now the northing
	double y = k0 * (M - M0 + N * tan(phi) * (A * A * (1.0 / 2 + A * A * ((5 - T + 9 * C + 4 * C * C) / 24 + A * A * (61 - 58 * T + T * T + 600 * C - 330 * e0sq) / 720))));    // first from the equator
	if (y < 0) {
		y = 10000000 + y;   // add in false northing if south of the equator
	}

	*easting = x;
	*northing = y;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movapd %xmm0, %xmm2
movsd 0x83ef(%rip), %xmm0     # 0xb230
divsd %xmm0, %xmm2
mulsd 0x83eb(%rip), %xmm2     # 0xb238
movsd %xmm2, 0x8(%rsp)
movapd %xmm1, 0x10(%rsp)
addsd %xmm1, %xmm0
divsd 0x83db(%rip), %xmm0     # 0xb240
callq 0x2390
addsd 0x83d6(%rip), %xmm0     # 0xb248
addsd 0x83d6(%rip), %xmm0     # 0xb250
mulsd 0x83be(%rip), %xmm0     # 0xb240
addsd 0x83ce(%rip), %xmm0     # 0xb258
addsd 0x83ce(%rip), %xmm0     # 0xb260
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2070
movapd %xmm0, %xmm1
mulsd 0x83ba(%rip), %xmm1     # 0xb268
mulsd %xmm1, %xmm1
movsd 0x838e(%rip), %xmm0     # 0xb248
subsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2ece
sqrtsd %xmm0, %xmm0
jmp 0x2ed3
callq 0x2170
movapd %xmm0, 0x30(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2110
mulsd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x23b0
mulsd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movapd 0x10(%rsp), %xmm0
subsd (%rsp), %xmm0
mulsd 0x8322(%rip), %xmm0     # 0xb238
movapd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x23b0
movaps %xmm0, 0x40(%rsp)
movsd 0x833c(%rip), %xmm1     # 0xb270
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
addsd %xmm0, %xmm0
callq 0x2070
mulsd 0x8324(%rip), %xmm0     # 0xb278
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x831a(%rip), %xmm1     # 0xb280
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x2070
mulsd 0x830b(%rip), %xmm0     # 0xb288
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x82b1(%rip), %xmm0     # 0xb240
mulsd 0x8(%rsp), %xmm0
callq 0x2070
mulsd 0x82ee(%rip), %xmm0     # 0xb290
addsd (%rsp), %xmm0
mulsd 0x82e9(%rip), %xmm0     # 0xb298
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2110
movsd 0x82d9(%rip), %xmm1     # 0xb2a0
movsd 0x82e9(%rip), %xmm3     # 0xb2b8
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm3
addsd %xmm1, %xmm3
movapd %xmm1, %xmm5
subsd %xmm2, %xmm5
movsd 0x82bb(%rip), %xmm6     # 0xb2a8
mulsd %xmm2, %xmm6
addsd 0x82b7(%rip), %xmm6     # 0xb2b0
movapd %xmm2, %xmm7
movapd %xmm2, %xmm8
mulsd %xmm2, %xmm7
addsd %xmm7, %xmm6
movapd 0x833e(%rip), %xmm2     # 0xb350
movapd 0x30(%rsp), %xmm1
shufpd $0x2, 0x833f(%rip), %xmm1 # xmm1 = xmm1[0],mem[1]
unpcklpd 0x10(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
divpd %xmm1, %xmm2
movapd 0x833d(%rip), %xmm4     # 0xb370
unpcklpd 0x40(%rsp), %xmm4       # xmm4 = xmm4[0],mem[0]
mulpd %xmm2, %xmm4
movapd %xmm4, %xmm1
unpckhpd %xmm4, %xmm1            # xmm1 = xmm1[1],xmm4[1]
mulsd %xmm4, %xmm1
addsd %xmm7, %xmm3
movapd 0x50(%rsp), %xmm7
shufpd $0x2, %xmm4, %xmm7      # xmm7 = xmm7[0],xmm4[1]
movlpd 0x8260(%rip), %xmm4     # xmm4 = mem[0],xmm4[1]
mulpd %xmm7, %xmm4
movsd 0x825c(%rip), %xmm7     # 0xb2c8
mulsd %xmm4, %xmm7
addsd %xmm5, %xmm7
movsd 0x8203(%rip), %xmm9     # 0xb280
mulsd %xmm4, %xmm9
mulsd %xmm4, %xmm9
addsd %xmm7, %xmm9
movsd 0x823c(%rip), %xmm5     # 0xb2d0
mulsd %xmm4, %xmm5
addsd %xmm6, %xmm5
addsd 0x8234(%rip), %xmm5     # 0xb2d8
movsd 0x824c(%rip), %xmm6     # 0xb2f8
mulsd %xmm4, %xmm6
addsd %xmm3, %xmm6
unpcklpd %xmm6, %xmm3            # xmm3 = xmm3[0],xmm6[0]
movsd 0x8188(%rip), %xmm7     # 0xb248
movapd %xmm7, %xmm6
subsd %xmm8, %xmm6
addpd 0x82bf(%rip), %xmm3     # 0xb390
addpd %xmm4, %xmm6
mulpd %xmm4, %xmm3
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
mulsd %xmm4, %xmm5
unpcklpd %xmm5, %xmm9            # xmm9 = xmm9[0],xmm5[0]
divpd 0x8291(%rip), %xmm9     # 0xb380
mulsd %xmm0, %xmm2
movapd %xmm9, %xmm0
unpckhpd %xmm9, %xmm0            # xmm0 = xmm0[1],xmm9[1]
addsd %xmm9, %xmm0
mulsd %xmm4, %xmm0
addsd 0x81d2(%rip), %xmm0     # 0xb2e0
mulsd %xmm4, %xmm0
mulsd %xmm2, %xmm0
addsd (%rsp), %xmm0
mulsd 0x81c5(%rip), %xmm0     # 0xb2e8
movsd 0x81c5(%rip), %xmm2     # 0xb2f0
addsd %xmm0, %xmm2
movapd %xmm0, %xmm5
cmpltsd 0x7ee4(%rip), %xmm5     # 0xb020
andpd %xmm5, %xmm2
andnpd %xmm0, %xmm5
orpd %xmm2, %xmm5
movsd %xmm6, %xmm3            # xmm3 = xmm6[0],xmm3[1]
divpd 0x824c(%rip), %xmm3     # 0xb3a0
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
addsd %xmm3, %xmm0
mulsd %xmm4, %xmm0
addsd %xmm7, %xmm0
mulsd %xmm1, %xmm0
addsd 0x818c(%rip), %xmm0     # 0xb300
movsd %xmm0, (%r14)
movlpd %xmm5, (%rbx)
addq $0x68, %rsp
popq %rbx
popq %r14
retq
nop