// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rnxobs/Com.cpp
// Function: bamboo::bds_code_cor(char*, int, char (*) [4], double, double*)
void bds_code_cor(char *ctype, int nfreq, char cfreq[MAXFREQ][LEN_FREQ],
		double elev, double *bias) {
	int isat, i, idx, ifreq[3] = { 0 };
	double alpha;
	static double coef[2][3][10] = { -0.11, -0.11, -0.09, -0.07, -0.02, -0.08,
			0.13, 0.24, 0.25, 0.33, -0.06, -0.11, -0.07, -0.05, -0.01, 0.06,
			0.11, 0.19, 0.26, 0.28, -0.27, -0.23, -0.21, -0.15, -0.11, -0.04,
			0.05, 0.14, 0.19, 0.32, -0.13, -0.20, -0.17, -0.12, -0.04, 0.10,
			0.32, 0.61, 0.82, 0.92, -0.12, -0.16, -0.12, -0.09, -0.01, 0.10,
			0.25, 0.42, 0.56, 0.64, -0.22, -0.15, -0.13, -0.10, -0.04, 0.05,
			0.14, 0.27, 0.36, 0.47 };
	if (nfreq > 3) {
		printf("the number of frequency is more than 3");
		printf(
				"***ERROR(bds_code_cor):the number of frequency is more than 3!\n");
		exit(1);
	}
	if (strstr(ctype, "BEIDOU-2I")) {
		isat = 0;
	} else if (strstr(ctype, "BEIDOU-2M")) {
		isat = 1;
	} else {
		return;
	}
	for (i = 0; i < nfreq; i++) {
		if (strstr(cfreq[i], "L2") || strstr(cfreq[i],"L1"))
			ifreq[i] = 0;
		if (strstr(cfreq[i], "L7"))
			ifreq[i] = 1;
		if (strstr(cfreq[i], "L6"))
			ifreq[i] = 2;
	}
	if (elev <= 0.0) {
		for (i = 0; i < nfreq; i++)
			bias[i] = coef[isat][ifreq[i]][0];
	} else if (elev >= 90.0) {
		for (i = 0; i < nfreq; i++)
			bias[i] = coef[isat][ifreq[i]][9];
	} else {
		idx = (int) (elev / 10.0);
		for (i = 0; i < nfreq; i++) {
			alpha = (coef[isat][ifreq[i]][idx + 1] - coef[isat][ifreq[i]][idx])
					/ 10.0;
			bias[i] = alpha * (elev - idx * 10.0) + coef[isat][ifreq[i]][idx];
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movsd %xmm0, -0x58(%rbp)
andl $0x0, -0x30(%rbp)
andq $0x0, -0x38(%rbp)
cmpl $0x4, %esi
jge 0x1d4ca
movq %rcx, %r14
movq %rdx, %r15
movl %esi, %r13d
movq %rdi, %rbx
leaq 0x44137(%rip), %rsi     # 0x61414
callq 0x8170
xorl %r12d, %r12d
testq %rax, %rax
je 0x1d2f8
movq %r14, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
jmp 0x1d31b
leaq 0x4411f(%rip), %rsi     # 0x6141e
movq %rbx, %rdi
callq 0x8170
testq %rax, %rax
je 0x1d4bb
movq %r14, -0x48(%rbp)
pushq $0x1
popq %rax
movq %rax, -0x40(%rbp)
testl %r13d, %r13d
cmovlel %r12d, %r13d
movq %r13, -0x50(%rbp)
leaq (,%r13,4), %r13
leaq 0x44029(%rip), %rbx     # 0x6135e
cmpq %r12, %r13
je 0x1d3a8
leaq (%r15,%r12), %r14
movq %r14, %rdi
leaq 0x43fc3(%rip), %rsi     # 0x6130b
callq 0x8170
testq %rax, %rax
jne 0x1d366
movq %r14, %rdi
leaq 0x43fac(%rip), %rsi     # 0x61308
callq 0x8170
testq %rax, %rax
je 0x1d36c
andl $0x0, -0x38(%rbp,%r12)
movq %r14, %rdi
leaq 0x43feb(%rip), %rsi     # 0x61361
callq 0x8170
testq %rax, %rax
je 0x1d389
movl $0x1, -0x38(%rbp,%r12)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8170
testq %rax, %rax
je 0x1d3a2
movl $0x2, -0x38(%rbp,%r12)
addq $0x4, %r12
jmp 0x1d335
xorpd %xmm0, %xmm0
movsd -0x58(%rbp), %xmm2
ucomisd %xmm2, %xmm0
jae 0x1d44f
ucomisd 0x436ed(%rip), %xmm2    # 0x60ab0
movq -0x48(%rbp), %r8
movq -0x50(%rbp), %r9
jae 0x1d488
movsd 0x436df(%rip), %xmm0    # 0x60ab8
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
leal 0x1(%rcx), %eax
cltq
movslq %ecx, %rcx
cvttpd2dq %xmm1, %xmm1
cvtdq2pd %xmm1, %xmm1
mulsd %xmm0, %xmm1
subsd %xmm1, %xmm2
movapd %xmm2, %xmm3
xorl %edx, %edx
imulq $0xf0, -0x40(%rbp), %rdi
leaq 0x43c6e(%rip), %rsi     # 0x61080
addq %rdi, %rsi
cmpq %rdx, %r9
je 0x1d4bb
movslq -0x38(%rbp,%rdx,4), %rdi
imulq $0x50, %rdi, %rdi
addq %rsi, %rdi
movsd (%rdi,%rax,8), %xmm1
movsd (%rdi,%rcx,8), %xmm2
subsd %xmm2, %xmm1
divsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd %xmm1, (%r8,%rdx,8)
incq %rdx
jmp 0x1d415
xorl %eax, %eax
imulq $0xf0, -0x40(%rbp), %rdx
leaq 0x43c20(%rip), %rcx     # 0x61080
addq %rdx, %rcx
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdi
cmpq %rax, %rdi
je 0x1d4bb
movslq -0x38(%rbp,%rax,4), %rdx
imulq $0x50, %rdx, %rdx
movsd (%rdx,%rcx), %xmm0
movsd %xmm0, (%rsi,%rax,8)
incq %rax
jmp 0x1d46b
xorl %eax, %eax
imulq $0xf0, -0x40(%rbp), %rdx
leaq 0x43be7(%rip), %rcx     # 0x61080
addq %rdx, %rcx
cmpq %rax, %r9
je 0x1d4bb
movslq -0x38(%rbp,%rax,4), %rdx
imulq $0x50, %rdx, %rdx
movsd 0x48(%rdx,%rcx), %xmm0
movsd %xmm0, (%r8,%rax,8)
incq %rax
jmp 0x1d49c
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x43f1c(%rip), %rdi     # 0x613ed
xorl %eax, %eax
callq 0x8070
leaq 0x43f49(%rip), %rdi     # 0x61428
callq 0x8970
pushq $0x1
popq %rdi
callq 0x8790