// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::to_sigid(int, unsigned char, int*)
static int to_sigid(int sys, unsigned char code, int *freq)
{
    const char **msm_sig;
    char *sig;
    int i;
    
    /* signal conversion for undefined signal by rtcm */
    if (sys==SYS_GPS) {
        if      (code==CODE_L1Y) code=CODE_L1P;
        else if (code==CODE_L1M) code=CODE_L1P;
        else if (code==CODE_L1N) code=CODE_L1P;
        else if (code==CODE_L2D) code=CODE_L2P;
        else if (code==CODE_L2Y) code=CODE_L2P;
        else if (code==CODE_L2M) code=CODE_L2P;
        else if (code==CODE_L2N) code=CODE_L2P;
    }
    if (!*(sig=code2obs(code,freq))) return 0;
    
    switch (sys) {
        case SYS_GPS: msm_sig=msm_sig_gps; break;
        case SYS_GLO: msm_sig=msm_sig_glo; break;
        case SYS_GAL: msm_sig=msm_sig_gal; break;
        case SYS_QZS: msm_sig=msm_sig_qzs; break;
        case SYS_SBS: msm_sig=msm_sig_sbs; break;
        case SYS_CMP: msm_sig=msm_sig_cmp; break;
        default: return 0;
    }
    /* freqency index for beidou and galileo */
    if (sys==SYS_CMP) {
        if      (*freq==5) *freq=2; /* B2 */
        else if (*freq==4) *freq=3; /* B3 */
    }
    else if (sys==SYS_GAL) {
        if (*freq==5) *freq=2; /* E5b */
    }
    for (i=0;i<32;i++) {
        if (!strcmp(sig,msm_sig[i])) return i+1;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movl %edi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
cmpl $0x1, -0x8(%rbp)
jne 0x8a040
movzbl -0x9(%rbp), %eax
cmpl $0x4, %eax
jne 0x89fda
movb $0x2, -0x9(%rbp)
jmp 0x8a03e
movzbl -0x9(%rbp), %eax
cmpl $0x5, %eax
jne 0x89fe9
movb $0x2, -0x9(%rbp)
jmp 0x8a03c
movzbl -0x9(%rbp), %eax
cmpl $0x6, %eax
jne 0x89ff8
movb $0x2, -0x9(%rbp)
jmp 0x8a03a
movzbl -0x9(%rbp), %eax
cmpl $0xf, %eax
jne 0x8a007
movb $0x13, -0x9(%rbp)
jmp 0x8a038
movzbl -0x9(%rbp), %eax
cmpl $0x15, %eax
jne 0x8a016
movb $0x13, -0x9(%rbp)
jmp 0x8a036
movzbl -0x9(%rbp), %eax
cmpl $0x16, %eax
jne 0x8a025
movb $0x13, -0x9(%rbp)
jmp 0x8a034
movzbl -0x9(%rbp), %eax
cmpl $0x17, %eax
jne 0x8a032
movb $0x13, -0x9(%rbp)
jmp 0x8a034
jmp 0x8a036
jmp 0x8a038
jmp 0x8a03a
jmp 0x8a03c
jmp 0x8a03e
jmp 0x8a040
movb -0x9(%rbp), %al
movq -0x18(%rbp), %rsi
movzbl %al, %edi
callq 0x8bb90
movq %rax, -0x28(%rbp)
cmpb $0x0, (%rax)
jne 0x8a064
movl $0x0, -0x4(%rbp)
jmp 0x8a177
movl -0x8(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x1f, %eax
ja 0x8a0d6
movq -0x38(%rbp), %rax
leaq 0x382d9(%rip), %rcx     # 0xc2358
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x6df11(%rip), %rax     # 0xf7fa0
movq %rax, -0x20(%rbp)
jmp 0x8a0e2
leaq 0x6e004(%rip), %rax     # 0xf80a0
movq %rax, -0x20(%rbp)
jmp 0x8a0e2
leaq 0x6e0f7(%rip), %rax     # 0xf81a0
movq %rax, -0x20(%rbp)
jmp 0x8a0e2
leaq 0x6e1ea(%rip), %rax     # 0xf82a0
movq %rax, -0x20(%rbp)
jmp 0x8a0e2
leaq 0x6e2dd(%rip), %rax     # 0xf83a0
movq %rax, -0x20(%rbp)
jmp 0x8a0e2
leaq 0x6e3d0(%rip), %rax     # 0xf84a0
movq %rax, -0x20(%rbp)
jmp 0x8a0e2
movl $0x0, -0x4(%rbp)
jmp 0x8a177
cmpl $0x20, -0x8(%rbp)
jne 0x8a114
movq -0x18(%rbp), %rax
cmpl $0x5, (%rax)
jne 0x8a0fd
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
jmp 0x8a112
movq -0x18(%rbp), %rax
cmpl $0x4, (%rax)
jne 0x8a110
movq -0x18(%rbp), %rax
movl $0x3, (%rax)
jmp 0x8a112
jmp 0x8a131
cmpl $0x8, -0x8(%rbp)
jne 0x8a12f
movq -0x18(%rbp), %rax
cmpl $0x5, (%rax)
jne 0x8a12d
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
jmp 0x8a12f
jmp 0x8a131
movl $0x0, -0x2c(%rbp)
cmpl $0x20, -0x2c(%rbp)
jge 0x8a170
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x9a60
cmpl $0x0, %eax
jne 0x8a163
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x8a177
jmp 0x8a165
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8a138
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq