// File: DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::getcodepri(int, unsigned char, char const*)
extern int getcodepri(int sys, unsigned char code, const char *opt)
{
    const char *p,*optstr;
    char *obs,str[8]="";
    int i,j;
    
    switch (sys) {
        case SYS_GPS: i=0; optstr="-GL%2s"; break;
        case SYS_GLO: i=1; optstr="-RL%2s"; break;
        case SYS_GAL: i=2; optstr="-EL%2s"; break;
        case SYS_QZS: i=3; optstr="-JL%2s"; break;
        case SYS_SBS: i=4; optstr="-SL%2s"; break;
        case SYS_CMP: i=5; optstr="-CL%2s"; break;
        case SYS_IRN: i=6; optstr="-IL%2s"; break;
        default: return 0;
    }
    obs=code2obs(code,&j);
    
    /* parse code options */
    for (p=opt;p&&(p=strchr(p,'-'));p++) {
        if (sscanf(p,optstr,str)<1||str[0]!=obs[0]) continue;
        return str[1]==obs[1]?15:0;
    }
    /* search code priority */
    return (p=strchr(codepris[i][j-1],obs[1]))?14-(int)(p-codepris[i][j-1]):0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %sil, %al
movl %edi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x38(%rbp)
movl -0x8(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x3f, %eax
ja 0x8be84
movq -0x48(%rbp), %rax
leaq 0x36d68(%rip), %rcx     # 0xc2b54
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x3c(%rbp)
leaq 0x3bad4(%rip), %rax     # 0xc78d7
movq %rax, -0x28(%rbp)
jmp 0x8be90
movl $0x1, -0x3c(%rbp)
leaq 0x3bac4(%rip), %rax     # 0xc78de
movq %rax, -0x28(%rbp)
jmp 0x8be90
movl $0x2, -0x3c(%rbp)
leaq 0x3bab7(%rip), %rax     # 0xc78e5
movq %rax, -0x28(%rbp)
jmp 0x8be90
movl $0x3, -0x3c(%rbp)
leaq 0x3baaa(%rip), %rax     # 0xc78ec
movq %rax, -0x28(%rbp)
jmp 0x8be90
movl $0x4, -0x3c(%rbp)
leaq 0x3ba9d(%rip), %rax     # 0xc78f3
movq %rax, -0x28(%rbp)
jmp 0x8be90
movl $0x5, -0x3c(%rbp)
leaq 0x3ba90(%rip), %rax     # 0xc78fa
movq %rax, -0x28(%rbp)
jmp 0x8be90
movl $0x6, -0x3c(%rbp)
leaq 0x3ba83(%rip), %rax     # 0xc7901
movq %rax, -0x28(%rbp)
jmp 0x8be90
movl $0x0, -0x4(%rbp)
jmp 0x8bfb0
leaq -0x40(%rbp), %rsi
movzbl -0x9(%rbp), %edi
callq 0x8bb90
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x20(%rbp)
movb %al, -0x49(%rbp)
je 0x8bed1
movq -0x20(%rbp), %rdi
movl $0x2d, %esi
callq 0x9280
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x8beda
jmp 0x8bf34
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movb $0x0, %al
callq 0x9750
cmpl $0x1, %eax
jl 0x8bf01
movsbl -0x38(%rbp), %eax
movq -0x30(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x8bf03
jmp 0x8bf23
movsbl -0x37(%rbp), %edx
movq -0x30(%rbp), %rax
movsbl 0x1(%rax), %esi
xorl %eax, %eax
movl $0xf, %ecx
cmpl %esi, %edx
cmovel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x8bfb0
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x8bea9
movslq -0x3c(%rbp), %rax
leaq 0x6c981(%rip), %rdi     # 0xf88c0
imulq $0x70, %rax, %rax
addq %rax, %rdi
movl -0x40(%rbp), %eax
subl $0x1, %eax
cltq
shlq $0x4, %rax
addq %rax, %rdi
movq -0x30(%rbp), %rax
movsbl 0x1(%rax), %esi
callq 0x9280
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x8bfa3
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rdx
leaq 0x6c945(%rip), %rcx     # 0xf88c0
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movl -0x40(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
subq %rcx, %rax
movl %eax, %ecx
movl $0xe, %eax
subl %ecx, %eax
movl %eax, -0x50(%rbp)
jmp 0x8bfaa
xorl %eax, %eax
movl %eax, -0x50(%rbp)
jmp 0x8bfaa
movl -0x50(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)