// File: DoubleString[P]eph_converter/src/Broadcast.cpp
// Function: BroadcastEphUtils::pz902wgs84(int, double, double*, double*, char const*)
void BroadcastEphUtils::pz902wgs84(int mjd, double sod, double* pos,
		double *xsat, const char* trans) {
	double factor, biase[3], mat[3][3], vec[3];
	int i, j;
	if (timdif(mjd, sod, 54362, 86367.0) >= 0.0) {
		factor = 1.0;
//		biase[0] = -0.36e-3;
//		biase[1] = 0.08e-3;
//		biase[2] = 0.18e-3;

		biase[0] = 0.008e-3;
		biase[1] = 0.001e-3;
		biase[2] = 0.001e-3;
		for (i = 0; i < 3; i++)
			for (j = 0; j < 3; j++) {
				if (i == j) {
					mat[i][j] = 1.0;
				} else {
					mat[i][j] = 0.0;
				}
			}
	} else {
		if (strstr(trans, "MCC") != NULL) {
			factor = 1.0 + 22.0e-9;
			biase[0] = -0.47e-3;
			biase[1] = -0.51e-3;
			biase[2] = -1.56e-3;
			mat[0][0] = 1.0;
			mat[0][1] = -1.728e-6;
			mat[0][2] = -1.7e-8;
			mat[1][0] = 1.728e-6;
			mat[1][1] = 1.0;
			mat[1][2] = 7.6e-8;
			mat[2][0] = 1.7e-8;
			mat[2][1] = -7.6e-8;
			mat[2][2] = 1.0;
		} else if (strstr(trans, "RUS") != NULL) {
			factor = 1.0 - 1.2e-7;
			biase[0] = -1.1e-3;
			biase[1] = -0.3e-3;
			biase[2] = -0.9e-3;
			mat[0][0] = 1.0;
			mat[0][1] = -8.2e-7;
			mat[0][2] = 0.0;
			mat[1][0] = 8.2e-7;
			mat[1][1] = 1.0;
			mat[1][2] = 0.0;
			mat[2][0] = 0.0;
			mat[2][1] = 0.0;
			mat[2][2] = 1.0;
		} else if (strstr(trans, "LMU") != NULL) {
			factor = 1.0;
			biase[0] = 0.0;
			biase[1] = 0.0;
			biase[2] = 0.0;
			mat[0][0] = 1.0;
			mat[0][1] = -1.6e-6;
			mat[0][2] = 0.0;
			mat[1][0] = 1.6e-6;
			mat[1][1] = 1.0;
			mat[1][2] = 0.0;
			mat[2][0] = 0.0;
			mat[2][1] = 0.0;
			mat[2][2] = 1.0;
		} else if (strstr(trans, "MIT") != NULL) {
			factor = 1.0;
			biase[0] = 0.0;
			biase[1] = 2.5e-3;
			biase[2] = 0.0;
			mat[0][0] = 1.0;
			mat[0][1] = -1.9e-6;
			mat[0][2] = 0.0;
			mat[1][0] = 1.9e-6;
			mat[1][1] = 1.0;
			mat[1][2] = 0.0;
			mat[2][0] = 0.0;
			mat[2][1] = 0.0;
			mat[2][2] = 1.0;
		} else {
			printf("***ERROR(pz902wgs84): unknown transformation type %s!\n",
					trans);
			exit(1);
		}
	}
	matmpy((double*) mat, pos, vec, 3, 3, 1);
	for (i = 0; i < 3; i++)
		xsat[i] = biase[i] + factor * vec[i];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl -0xc(%rbp), %edi
movsd -0x18(%rbp), %xmm0
movl $0xd45a, %esi           # imm = 0xD45A
movsd 0x7cd0(%rip), %xmm1     # 0x17d88
callq 0x152d0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x101b3
movsd 0x7c66(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x38(%rbp)
movsd 0x7d61(%rip), %xmm0     # 0x17e40
movsd %xmm0, -0x50(%rbp)
movsd 0x7d4c(%rip), %xmm0     # 0x17e38
movsd %xmm0, -0x48(%rbp)
movsd 0x7d3f(%rip), %xmm0     # 0x17e38
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0xc4(%rbp)
cmpl $0x3, -0xc4(%rbp)
jge 0x101ae
movl $0x0, -0xc8(%rbp)
cmpl $0x3, -0xc8(%rbp)
jge 0x10198
movl -0xc4(%rbp), %eax
cmpl -0xc8(%rbp), %eax
jne 0x10161
movslq -0xc4(%rbp), %rcx
leaq -0xa0(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0xc8(%rbp), %rcx
movsd 0x7bde(%rip), %xmm0     # 0x17d38
movsd %xmm0, (%rax,%rcx,8)
jmp 0x10185
movslq -0xc4(%rbp), %rcx
leaq -0xa0(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0xc8(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x10187
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0x1011f
jmp 0x1019a
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x10108
jmp 0x104cf
movq -0x30(%rbp), %rdi
leaq 0x7d9b(%rip), %rsi      # 0x17f59
callq 0x30c0
cmpq $0x0, %rax
je 0x10287
movsd 0x7c5b(%rip), %xmm0     # 0x17e30
movsd %xmm0, -0x38(%rbp)
movsd 0x7c46(%rip), %xmm0     # 0x17e28
movsd %xmm0, -0x50(%rbp)
movsd 0x7c31(%rip), %xmm0     # 0x17e20
movsd %xmm0, -0x48(%rbp)
movsd 0x7c1c(%rip), %xmm0     # 0x17e18
movsd %xmm0, -0x40(%rbp)
movsd 0x7b2f(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0xa0(%rbp)
movsd 0x7bf7(%rip), %xmm0     # 0x17e10
movsd %xmm0, -0x98(%rbp)
movsd 0x7bdf(%rip), %xmm0     # 0x17e08
movsd %xmm0, -0x90(%rbp)
movsd 0x7bc7(%rip), %xmm0     # 0x17e00
movsd %xmm0, -0x88(%rbp)
movsd 0x7aef(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x80(%rbp)
movsd 0x7ba2(%rip), %xmm0     # 0x17df8
movsd %xmm0, -0x78(%rbp)
movsd 0x7b8d(%rip), %xmm0     # 0x17df0
movsd %xmm0, -0x70(%rbp)
movsd 0x7b78(%rip), %xmm0     # 0x17de8
movsd %xmm0, -0x68(%rbp)
movsd 0x7abb(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x60(%rbp)
jmp 0x104cd
movq -0x30(%rbp), %rdi
leaq 0x7ccb(%rip), %rsi      # 0x17f5d
callq 0x30c0
cmpq $0x0, %rax
je 0x10347
movsd 0x7b37(%rip), %xmm0     # 0x17de0
movsd %xmm0, -0x38(%rbp)
movsd 0x7b22(%rip), %xmm0     # 0x17dd8
movsd %xmm0, -0x50(%rbp)
movsd 0x7b0d(%rip), %xmm0     # 0x17dd0
movsd %xmm0, -0x48(%rbp)
movsd 0x7af8(%rip), %xmm0     # 0x17dc8
movsd %xmm0, -0x40(%rbp)
movsd 0x7a5b(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0xa0(%rbp)
movsd 0x7ad3(%rip), %xmm0     # 0x17dc0
movsd %xmm0, -0x98(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd 0x7ab0(%rip), %xmm0     # 0x17db8
movsd %xmm0, -0x88(%rbp)
movsd 0x7a20(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x79fb(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x60(%rbp)
jmp 0x104cb
movq -0x30(%rbp), %rdi
leaq 0x7c0f(%rip), %rsi      # 0x17f61
callq 0x30c0
cmpq $0x0, %rax
je 0x103f8
movsd 0x79cf(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x79aa(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0xa0(%rbp)
movsd 0x7a12(%rip), %xmm0     # 0x17db0
movsd %xmm0, -0x98(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd 0x79ef(%rip), %xmm0     # 0x17da8
movsd %xmm0, -0x88(%rbp)
movsd 0x796f(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x794a(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x60(%rbp)
jmp 0x104c9
movq -0x30(%rbp), %rdi
leaq 0x7b62(%rip), %rsi      # 0x17f65
callq 0x30c0
cmpq $0x0, %rax
je 0x104ab
movsd 0x791e(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd 0x7971(%rip), %xmm0     # 0x17da0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x78f4(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0xa0(%rbp)
movsd 0x7944(%rip), %xmm0     # 0x17d98
movsd %xmm0, -0x98(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd 0x7921(%rip), %xmm0     # 0x17d90
movsd %xmm0, -0x88(%rbp)
movsd 0x78b9(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x7894(%rip), %xmm0     # 0x17d38
movsd %xmm0, -0x60(%rbp)
jmp 0x104c7
movq -0x30(%rbp), %rsi
leaq 0x7ab3(%rip), %rdi      # 0x17f69
movb $0x0, %al
callq 0x3050
movl $0x1, %edi
callq 0x3360
jmp 0x104c9
jmp 0x104cb
jmp 0x104cd
jmp 0x104cf
leaq -0xa0(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
movl $0x3, %r8d
movl $0x1, %r9d
movl %r8d, %ecx
callq 0x14f80
movl $0x0, -0xc4(%rbp)
cmpl $0x3, -0xc4(%rbp)
jge 0x10553
movslq -0xc4(%rbp), %rax
movsd -0x50(%rbp,%rax,8), %xmm1
movsd -0x38(%rbp), %xmm0
movslq -0xc4(%rbp), %rax
movsd -0xc0(%rbp,%rax,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movslq -0xc4(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x104ff
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)