// File: /workspace/github_cpp_makefile_star2_O3/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)
movl $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
cmpl $0x4, %esi
jge 0x20d42
movq %rcx, %r14
movq %rdx, %r15
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x4a8ed(%rip), %rsi     # 0x6b424
callq 0x8160
testq %rax, %rax
je 0x20b45
xorl %ecx, %ecx
jmp 0x20b62
leaq 0x4a8e2(%rip), %rsi     # 0x6b42e
movq %rbx, %rdi
callq 0x8160
movl $0x1, %ecx
testq %rax, %rax
je 0x20d33
testl %r12d, %r12d
jle 0x20d33
movq %rcx, -0x40(%rbp)
movq %r14, -0x50(%rbp)
movl %r12d, -0x2c(%rbp)
movl %r12d, %eax
movq %rax, -0x48(%rbp)
leaq (,%rax,4), %r12
xorl %r14d, %r14d
leaq 0x4a7de(%rip), %r13     # 0x6b36e
leaq (%r15,%r14), %rbx
movq %rbx, %rdi
leaq 0x4a77d(%rip), %rsi     # 0x6b31b
callq 0x8160
testq %rax, %rax
jne 0x20bbc
movq %rbx, %rdi
leaq 0x4a766(%rip), %rsi     # 0x6b318
callq 0x8160
testq %rax, %rax
je 0x20bc5
movl $0x0, -0x38(%rbp,%r14)
movq %rbx, %rdi
leaq 0x4a7a2(%rip), %rsi     # 0x6b371
callq 0x8160
testq %rax, %rax
je 0x20be2
movl $0x1, -0x38(%rbp,%r14)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8160
testq %rax, %rax
je 0x20bfb
movl $0x2, -0x38(%rbp,%r14)
addq $0x4, %r14
cmpq %r14, %r12
jne 0x20b90
xorpd %xmm0, %xmm0
movsd -0x58(%rbp), %xmm3
ucomisd %xmm3, %xmm0
jae 0x20cb5
ucomisd 0x49ea1(%rip), %xmm3    # 0x6aac0
movq -0x50(%rbp), %r8
movq -0x48(%rbp), %r9
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %eax
jae 0x20cfb
testl %eax, %eax
jle 0x20d33
movsd 0x49e84(%rip), %xmm0    # 0x6aac8
movapd %xmm3, %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, %xmm3
xorl %edx, %edx
imulq $0xf0, %rsi, %rdi
leaq 0x4a418(%rip), %rsi     # 0x6b090
addq %rdi, %rsi
movslq -0x38(%rbp,%rdx,4), %rdi
leaq (%rdi,%rdi,4), %rdi
shlq $0x4, %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
cmpq %rdx, %r9
jne 0x20c7b
jmp 0x20d33
cmpl $0x0, -0x2c(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rcx
jle 0x20d33
xorl %eax, %eax
imulq $0xf0, %rcx, %rdx
leaq 0x4a3b9(%rip), %rcx     # 0x6b090
addq %rdx, %rcx
movslq -0x38(%rbp,%rax,4), %rdx
leaq (%rdx,%rdx,4), %rdx
shlq $0x4, %rdx
movsd (%rdx,%rcx), %xmm0
movsd %xmm0, (%rsi,%rax,8)
incq %rax
cmpq %rax, %rdi
jne 0x20cda
jmp 0x20d33
testl %eax, %eax
jle 0x20d33
xorl %eax, %eax
imulq $0xf0, %rsi, %rdx
leaq 0x4a381(%rip), %rcx     # 0x6b090
addq %rdx, %rcx
movslq -0x38(%rbp,%rax,4), %rdx
leaq (%rdx,%rdx,4), %rdx
shlq $0x4, %rdx
movsd 0x48(%rdx,%rcx), %xmm0
movsd %xmm0, (%r8,%rax,8)
incq %rax
cmpq %rax, %r9
jne 0x20d12
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a6b4(%rip), %rdi     # 0x6b3fd
xorl %eax, %eax
callq 0x8080
leaq 0x4a6e1(%rip), %rdi     # 0x6b438
callq 0x8970
movl $0x1, %edi
callq 0x87b0
nop