// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movsd %xmm0, -0x50(%rbp)
movl $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
cmpl $0x4, %esi
jge 0x213a6
movq %rcx, %r14
movq %rdx, %r15
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x4a284(%rip), %rsi     # 0x6b424
callq 0x8160
testq %rax, %rax
je 0x211b4
movq $0x0, -0x40(%rbp)
jmp 0x211d5
leaq 0x4a273(%rip), %rsi     # 0x6b42e
movq %rbx, %rdi
callq 0x8160
movl $0x1, %ecx
movq %rcx, -0x40(%rbp)
testq %rax, %rax
je 0x21397
movq %r14, -0x48(%rbp)
movl %r12d, -0x2c(%rbp)
testl %r12d, %r12d
jle 0x2126c
movl -0x2c(%rbp), %r12d
shlq $0x2, %r12
xorl %r14d, %r14d
leaq 0x4a176(%rip), %r13     # 0x6b36e
leaq (%r15,%r14), %rbx
movq %rbx, %rdi
leaq 0x4a115(%rip), %rsi     # 0x6b31b
callq 0x8160
testq %rax, %rax
jne 0x21224
movq %rbx, %rdi
leaq 0x4a0fe(%rip), %rsi     # 0x6b318
callq 0x8160
testq %rax, %rax
je 0x2122d
movl $0x0, -0x38(%rbp,%r14)
movq %rbx, %rdi
leaq 0x4a13a(%rip), %rsi     # 0x6b371
callq 0x8160
testq %rax, %rax
je 0x2124a
movl $0x1, -0x38(%rbp,%r14)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8160
testq %rax, %rax
je 0x21263
movl $0x2, -0x38(%rbp,%r14)
addq $0x4, %r14
cmpq %r14, %r12
jne 0x211f8
xorpd %xmm0, %xmm0
movsd -0x50(%rbp), %xmm3
ucomisd %xmm3, %xmm0
jae 0x2131a
ucomisd 0x49839(%rip), %xmm3    # 0x6aac0
movq -0x48(%rbp), %r9
movl -0x2c(%rbp), %edx
jae 0x2135c
testl %edx, %edx
jle 0x21397
movsd 0x49824(%rip), %xmm0    # 0x6aac8
movapd %xmm3, %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
leal 0x1(%rcx), %eax
cltq
cvttpd2dq %xmm1, %xmm1
cvtdq2pd %xmm1, %xmm1
movslq %ecx, %rcx
mulsd %xmm0, %xmm1
subsd %xmm1, %xmm3
movl %edx, %edx
xorl %esi, %esi
imulq $0xf0, -0x40(%rbp), %r8
leaq 0x49db5(%rip), %rdi     # 0x6b090
addq %r8, %rdi
movslq -0x38(%rbp,%rsi,4), %r8
leaq (%r8,%r8,4), %r8
shlq $0x4, %r8
addq %rdi, %r8
movsd (%r8,%rax,8), %xmm1
movsd (%r8,%rcx,8), %xmm2
subsd %xmm2, %xmm1
divsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd %xmm1, (%r9,%rsi,8)
incq %rsi
cmpq %rsi, %rdx
jne 0x212de
jmp 0x21397
movl -0x2c(%rbp), %eax
testl %eax, %eax
movq -0x48(%rbp), %rdi
jle 0x21397
movl %eax, %eax
xorl %ecx, %ecx
imulq $0xf0, -0x40(%rbp), %rsi
leaq 0x49d58(%rip), %rdx     # 0x6b090
addq %rsi, %rdx
movslq -0x38(%rbp,%rcx,4), %rsi
leaq (%rsi,%rsi,4), %rsi
shlq $0x4, %rsi
movsd (%rsi,%rdx), %xmm0
movsd %xmm0, (%rdi,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x2133b
jmp 0x21397
testl %edx, %edx
jle 0x21397
movl %edx, %eax
xorl %ecx, %ecx
imulq $0xf0, -0x40(%rbp), %rsi
leaq 0x49d1d(%rip), %rdx     # 0x6b090
addq %rsi, %rdx
movslq -0x38(%rbp,%rcx,4), %rsi
leaq (%rsi,%rsi,4), %rsi
shlq $0x4, %rsi
movsd 0x48(%rsi,%rdx), %xmm0
movsd %xmm0, (%r9,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x21376
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4a050(%rip), %rdi     # 0x6b3fd
xorl %eax, %eax
callq 0x8080
leaq 0x4a07d(%rip), %rdi     # 0x6b438
callq 0x8980
movl $0x1, %edi
callq 0x87c0
nop