// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movapd %xmm0, %xmm2
movsd 0x83eb(%rip), %xmm0     # 0xb230
divsd %xmm0, %xmm2
mulsd 0x83e7(%rip), %xmm2     # 0xb238
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, 0x10(%rsp)
addsd %xmm1, %xmm0
divsd 0x83d7(%rip), %xmm0     # 0xb240
callq 0x2390
addsd 0x83d2(%rip), %xmm0     # 0xb248
addsd 0x83d2(%rip), %xmm0     # 0xb250
mulsd 0x83ba(%rip), %xmm0     # 0xb240
addsd 0x83ca(%rip), %xmm0     # 0xb258
addsd 0x83ca(%rip), %xmm0     # 0xb260
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2070
movapd %xmm0, %xmm1
mulsd 0x83b6(%rip), %xmm1     # 0xb268
mulsd %xmm1, %xmm1
movsd 0x838a(%rip), %xmm0     # 0xb248
subsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2ed2
sqrtsd %xmm0, %xmm0
jmp 0x2ed7
callq 0x2170
movsd 0x8391(%rip), %xmm1     # 0xb270
divsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2110
mulsd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x23c0
mulsd %xmm0, %xmm0
mulsd 0x8363(%rip), %xmm0     # 0xb278
movsd %xmm0, 0x20(%rsp)
movsd 0x10(%rsp), %xmm0
subsd (%rsp), %xmm0
mulsd 0x830a(%rip), %xmm0     # 0xb238
divsd 0x82fa(%rip), %xmm0     # 0xb230
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x23c0
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x8325(%rip), %xmm1     # 0xb280
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
addsd %xmm0, %xmm0
callq 0x2070
mulsd 0x830d(%rip), %xmm0     # 0xb288
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
mulsd 0x82fd(%rip), %xmm0     # 0xb290
callq 0x2070
mulsd 0x82f8(%rip), %xmm0     # 0xb298
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
movsd 0x8288(%rip), %xmm1     # 0xb240
mulsd %xmm1, %xmm0
callq 0x2070
mulsd 0x82d7(%rip), %xmm0     # 0xb2a0
addsd (%rsp), %xmm0
mulsd 0x829a(%rip), %xmm0     # 0xb270
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2110
movsd 0x30(%rsp), %xmm6
mulsd %xmm6, %xmm0
movsd 0x82a0(%rip), %xmm1     # 0xb2a8
movapd %xmm1, %xmm2
movsd 0x28(%rsp), %xmm5
subsd %xmm5, %xmm2
movsd 0x8292(%rip), %xmm3     # 0xb2b0
movsd 0x20(%rsp), %xmm8
mulsd %xmm8, %xmm3
addsd %xmm2, %xmm3
movsd 0x825a(%rip), %xmm2     # 0xb290
mulsd %xmm8, %xmm2
mulsd %xmm8, %xmm2
addsd %xmm3, %xmm2
divsd 0x826c(%rip), %xmm2     # 0xb2b8
movapd %xmm2, %xmm10
movsd 0x8267(%rip), %xmm4     # 0xb2c0
mulsd %xmm5, %xmm4
addsd 0x8263(%rip), %xmm4     # 0xb2c8
movapd %xmm5, %xmm2
movapd %xmm5, %xmm7
mulsd %xmm5, %xmm2
addsd %xmm2, %xmm4
movsd 0x8253(%rip), %xmm3     # 0xb2d0
mulsd %xmm8, %xmm3
addsd %xmm4, %xmm3
addsd 0x824a(%rip), %xmm3     # 0xb2d8
movsd 0x18(%rsp), %xmm9
mulsd %xmm9, %xmm3
divsd 0x823e(%rip), %xmm3     # 0xb2e0
addsd %xmm10, %xmm3
mulsd %xmm9, %xmm3
addsd 0x8234(%rip), %xmm3     # 0xb2e8
mulsd %xmm9, %xmm3
mulsd %xmm0, %xmm3
addsd (%rsp), %xmm3
movsd 0x8226(%rip), %xmm4     # 0xb2f0
mulsd %xmm4, %xmm3
movsd 0x8222(%rip), %xmm5     # 0xb2f8
addsd %xmm3, %xmm5
movapd %xmm3, %xmm0
cmpltsd 0x7f39(%rip), %xmm0     # 0xb020
andpd %xmm0, %xmm5
andnpd %xmm3, %xmm0
orpd %xmm5, %xmm0
movapd %xmm6, %xmm3
mulsd %xmm4, %xmm3
mulsd 0x10(%rsp), %xmm3
movapd %xmm3, %xmm5
movsd 0x813b(%rip), %xmm4     # 0xb248
movapd %xmm4, %xmm3
subsd %xmm7, %xmm3
mulsd 0x81e3(%rip), %xmm7     # 0xb300
movapd %xmm8, %xmm6
addsd %xmm8, %xmm3
addsd %xmm1, %xmm7
mulsd 0x81d5(%rip), %xmm6     # 0xb308
addsd %xmm2, %xmm7
addsd %xmm7, %xmm6
addsd 0x81cd(%rip), %xmm6     # 0xb310
divsd 0x80f5(%rip), %xmm3     # 0xb240
mulsd %xmm9, %xmm6
divsd 0x81c0(%rip), %xmm6     # 0xb318
addsd %xmm3, %xmm6
mulsd %xmm9, %xmm6
addsd %xmm4, %xmm6
mulsd %xmm5, %xmm6
addsd 0x81af(%rip), %xmm6     # 0xb320
movsd %xmm6, (%r14)
movlpd %xmm0, (%rbx)
addq $0x38, %rsp
popq %rbx
popq %r14
retq