// File: /workspace/github_cpp_makefile_star2_O2/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 0x747f(%rip), %xmm0     # 0xa230
divsd %xmm0, %xmm2
mulsd 0x747b(%rip), %xmm2     # 0xa238
movsd %xmm2, 0x8(%rsp)
movapd %xmm1, 0x10(%rsp)
addsd %xmm1, %xmm0
divsd 0x746b(%rip), %xmm0     # 0xa240
callq 0x23a0
addsd 0x7466(%rip), %xmm0     # 0xa248
addsd 0x7466(%rip), %xmm0     # 0xa250
mulsd 0x744e(%rip), %xmm0     # 0xa240
addsd 0x745e(%rip), %xmm0     # 0xa258
addsd 0x745e(%rip), %xmm0     # 0xa260
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2070
movapd %xmm0, %xmm1
mulsd 0x744a(%rip), %xmm1     # 0xa268
mulsd %xmm1, %xmm1
movsd 0x741e(%rip), %xmm0     # 0xa248
subsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2e3e
sqrtsd %xmm0, %xmm0
jmp 0x2e43
callq 0x2170
movapd %xmm0, 0x30(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2110
mulsd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x23c0
mulsd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movapd 0x10(%rsp), %xmm0
subsd (%rsp), %xmm0
mulsd 0x73b2(%rip), %xmm0     # 0xa238
movapd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x23c0
movaps %xmm0, 0x40(%rsp)
movsd 0x73cc(%rip), %xmm1     # 0xa270
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
addsd %xmm0, %xmm0
callq 0x2070
mulsd 0x73b4(%rip), %xmm0     # 0xa278
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x73aa(%rip), %xmm1     # 0xa280
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x2070
mulsd 0x739b(%rip), %xmm0     # 0xa288
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x7341(%rip), %xmm0     # 0xa240
mulsd 0x8(%rsp), %xmm0
callq 0x2070
mulsd 0x737e(%rip), %xmm0     # 0xa290
addsd (%rsp), %xmm0
mulsd 0x7379(%rip), %xmm0     # 0xa298
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2110
movsd 0x7369(%rip), %xmm1     # 0xa2a0
movsd 0x7379(%rip), %xmm3     # 0xa2b8
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm3
addsd %xmm1, %xmm3
movapd %xmm1, %xmm5
subsd %xmm2, %xmm5
movsd 0x734b(%rip), %xmm6     # 0xa2a8
mulsd %xmm2, %xmm6
addsd 0x7347(%rip), %xmm6     # 0xa2b0
movapd %xmm2, %xmm7
movapd %xmm2, %xmm8
mulsd %xmm2, %xmm7
addsd %xmm7, %xmm6
movapd 0x73de(%rip), %xmm2     # 0xa360
movapd 0x30(%rsp), %xmm1
shufpd $0x2, 0x73df(%rip), %xmm1 # xmm1 = xmm1[0],mem[1]
unpcklpd 0x10(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
divpd %xmm1, %xmm2
movapd 0x73dd(%rip), %xmm4     # 0xa380
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 0x72f0(%rip), %xmm4     # xmm4 = mem[0],xmm4[1]
mulpd %xmm7, %xmm4
movsd 0x72ec(%rip), %xmm7     # 0xa2c8
mulsd %xmm4, %xmm7
addsd %xmm5, %xmm7
movsd 0x7293(%rip), %xmm9     # 0xa280
mulsd %xmm4, %xmm9
mulsd %xmm4, %xmm9
addsd %xmm7, %xmm9
movsd 0x72cc(%rip), %xmm5     # 0xa2d0
mulsd %xmm4, %xmm5
addsd %xmm6, %xmm5
addsd 0x72c4(%rip), %xmm5     # 0xa2d8
movsd 0x72dc(%rip), %xmm6     # 0xa2f8
mulsd %xmm4, %xmm6
addsd %xmm3, %xmm6
unpcklpd %xmm6, %xmm3            # xmm3 = xmm3[0],xmm6[0]
movsd 0x7218(%rip), %xmm7     # 0xa248
movapd %xmm7, %xmm6
subsd %xmm8, %xmm6
addpd 0x735f(%rip), %xmm3     # 0xa3a0
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 0x7331(%rip), %xmm9     # 0xa390
mulsd %xmm0, %xmm2
movapd %xmm9, %xmm0
unpckhpd %xmm9, %xmm0            # xmm0 = xmm0[1],xmm9[1]
addsd %xmm9, %xmm0
mulsd %xmm4, %xmm0
addsd 0x7262(%rip), %xmm0     # 0xa2e0
mulsd %xmm4, %xmm0
mulsd %xmm2, %xmm0
addsd (%rsp), %xmm0
mulsd 0x7255(%rip), %xmm0     # 0xa2e8
movsd 0x7255(%rip), %xmm2     # 0xa2f0
addsd %xmm0, %xmm2
movapd %xmm0, %xmm5
cmpltsd 0x6f74(%rip), %xmm5     # 0xa020
andpd %xmm5, %xmm2
andnpd %xmm0, %xmm5
orpd %xmm2, %xmm5
movsd %xmm6, %xmm3            # xmm3 = xmm6[0],xmm3[1]
divpd 0x72ec(%rip), %xmm3     # 0xa3b0
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
addsd %xmm3, %xmm0
mulsd %xmm4, %xmm0
addsd %xmm7, %xmm0
mulsd %xmm1, %xmm0
addsd 0x721c(%rip), %xmm0     # 0xa300
movsd %xmm0, (%r14)
movlpd %xmm5, (%rbx)
addq $0x68, %rsp
popq %rbx
popq %r14
retq
nop