// File: DoubleString[P]RtConverter/src/Rtklib/skytraq.cpp
// Function: bamboo::decode_stqglo(bamboo::raw_t*)
static int decode_stqglo(raw_t *raw)
{
    geph_t geph={0};
    int i,prn,sat,m;
    unsigned char *p=raw->buff+4;
    
    trace(4,"decode_stqglo: len=%d\n",raw->len);
    
    if (raw->len<19) {
        trace(2,"stq glo string length error: len=%d\n",raw->len);
        return -1;
    }
    if (raw->outtype) {
        sprintf(raw->msgtype,"SKYTRAQ GLSTR (%4d): prn=%2d no=%d",raw->len,
                U1(p+1)-64,U1(p+2));
    }
    prn=U1(p+1)-64;
    if (!(sat=satno(SYS_GLO,prn))) {
        trace(2,"stq glo string satellite number error: prn=%d\n",prn);
        return -1;
    }
    m=U1(p+2); /* string number */
    if (m<1||4<m) {
        return 0; /* non-immediate info and almanac */
    }
    setbitu(raw->subfrm[sat-1]+(m-1)*10,1,4,m);
    for (i=0;i<9;i++) {
        setbitu(raw->subfrm[sat-1]+(m-1)*10,5+i*8,8,p[3+i]);
    }
    if (m!=4) return 0;
    
    /* decode glonass ephemeris strings */
    geph.tof=raw->time;
    if (!decode_glostr(raw->subfrm[sat-1],&geph)||geph.sat!=sat) return 0;
    
    if (!strstr(raw->opt,"-EPHALL")) {
        if (geph.iode==raw->nav.geph[prn-1].iode) return 0; /* unchanged */
    }
    /* keep freq channel number */
    geph.frq=raw->nav.geph[prn-1].frq;
    raw->nav.geph[prn-1]=geph;
    raw->ephsat=sat;
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x93d0
movq -0x10(%rbp), %rax
addq $0x81a90, %rax          # imm = 0x81A90
addq $0x4, %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl $0x4, %edi
leaq 0x2ca0c(%rip), %rsi     # 0xc86d9
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rax
cmpl $0x13, 0x81a78(%rax)
jge 0x9bd0a
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl $0x2, %edi
leaq 0x2c9f9(%rip), %rsi     # 0xc86f0
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9bfdc
movq -0x10(%rbp), %rax
cmpl $0x0, 0x81a8c(%rax)
je 0x9bd54
movq -0x10(%rbp), %rdi
addq $0x70e70, %rdi          # imm = 0x70E70
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movq -0xc0(%rbp), %rax
movzbl 0x1(%rax), %ecx
subl $0x40, %ecx
movq -0xc0(%rbp), %rax
movzbl 0x2(%rax), %r8d
leaq 0x2c9c8(%rip), %rsi     # 0xc8715
movb $0x0, %al
callq 0x9150
movq -0xc0(%rbp), %rax
movzbl 0x1(%rax), %eax
subl $0x40, %eax
movl %eax, -0xb0(%rbp)
movl -0xb0(%rbp), %esi
movl $0x4, %edi
callq 0x8b1b0
movl %eax, -0xb4(%rbp)
cmpl $0x0, %eax
jne 0x9bda8
movl -0xb0(%rbp), %edx
movl $0x2, %edi
leaq 0x2c9a3(%rip), %rsi     # 0xc8738
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9bfdc
movq -0xc0(%rbp), %rax
movzbl 0x2(%rax), %eax
movl %eax, -0xb8(%rbp)
cmpl $0x1, -0xb8(%rbp)
jl 0x9bdcf
movl $0x4, %eax
cmpl -0xb8(%rbp), %eax
jge 0x9bddb
movl $0x0, -0x4(%rbp)
jmp 0x9bfdc
movq -0x10(%rbp), %rdi
addq $0x70f70, %rdi          # imm = 0x70F70
movl -0xb4(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x17c, %rax, %rax      # imm = 0x17C
addq %rax, %rdi
movl -0xb8(%rbp), %eax
subl $0x1, %eax
imull $0xa, %eax, %eax
cltq
addq %rax, %rdi
movl -0xb8(%rbp), %ecx
movl $0x1, %esi
movl $0x4, %edx
callq 0x8c0d0
movl $0x0, -0xac(%rbp)
cmpl $0x9, -0xac(%rbp)
jge 0x9bea3
movq -0x10(%rbp), %rdi
addq $0x70f70, %rdi          # imm = 0x70F70
movl -0xb4(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x17c, %rax, %rax      # imm = 0x17C
addq %rax, %rdi
movl -0xb8(%rbp), %eax
subl $0x1, %eax
imull $0xa, %eax, %eax
cltq
addq %rax, %rdi
movl -0xac(%rbp), %esi
shll $0x3, %esi
addl $0x5, %esi
movq -0xc0(%rbp), %rax
movl -0xac(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %ecx
movl $0x8, %edx
callq 0x8c0d0
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x9be2b
cmpl $0x4, -0xb8(%rbp)
je 0x9beb8
movl $0x0, -0x4(%rbp)
jmp 0x9bfdc
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
addq $0x70f70, %rdi          # imm = 0x70F70
movl -0xb4(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x17c, %rax, %rax      # imm = 0x17C
addq %rax, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x64c10
cmpl $0x0, %eax
je 0x9bf0a
movl -0xa8(%rbp), %eax
cmpl -0xb4(%rbp), %eax
je 0x9bf16
movl $0x0, -0x4(%rbp)
jmp 0x9bfdc
movq -0x10(%rbp), %rdi
addq $0x82a90, %rdi          # imm = 0x82A90
leaq 0x22937(%rip), %rsi     # 0xbe85f
callq 0x91b0
cmpq $0x0, %rax
jne 0x9bf6a
movl -0xa4(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x1d88(%rcx), %rcx
movl -0xb0(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x98, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jne 0x9bf68
movl $0x0, -0x4(%rbp)
jmp 0x9bfdc
jmp 0x9bf6a
movq -0x10(%rbp), %rax
movq 0x1d88(%rax), %rax
movl -0xb0(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq 0x1d88(%rax), %rdi
movl -0xb0(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x98, %rax, %rax
addq %rax, %rdi
leaq -0xa8(%rbp), %rsi
movl $0x98, %edx
callq 0x9610
movl -0xb4(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x70e40(%rax)
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)