// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/skytraq.cpp
// Function: bamboo::decode_stqbds(bamboo::raw_t*)
static int decode_stqbds(raw_t *raw)
{
    eph_t eph={0};
    unsigned int word;
    int i,j=0,id,pgn,prn,sat;
    unsigned char *p=raw->buff+4;
    
    trace(4,"decode_stqbds: len=%d\n",raw->len);
    
    if (raw->len<38) {
        trace(2,"stq bds subframe length error: len=%d\n",raw->len);
        return -1;
    }
    if (raw->outtype) {
        sprintf(raw->msgtype,"SKYTRAQ BDSSF (%4d): prn=%2d id=%d",raw->len,
                U1(p+1)-200,U1(p+2));
    }
    prn=U1(p+1)-200;
    if (!(sat=satno(SYS_CMP,prn))) {
        trace(2,"stq bds subframe satellite number error: prn=%d\n",prn);
        return -1;
    }
    id=U1(p+2); /* subframe id */
    if (id<1||5<id) {
        trace(2,"stq bds subframe id error: prn=%2d\n",prn);
        return -1;
    }
    if (prn>5) { /* IGSO/MEO */
        word=getbitu(p+3,j,26)<<4; j+=26;
        setbitu(raw->subfrm[sat-1]+(id-1)*38,0,30,word);
        
        for (i=1;i<10;i++) {
            word=getbitu(p+3,j,22)<<8; j+=22;
            setbitu(raw->subfrm[sat-1]+(id-1)*38,i*30,30,word);
        }
        if (id!=3) return 0;
        
        /* decode beidou D1 ephemeris */
        if (!decode_bds_d1(raw->subfrm[sat-1],&eph)) return 0;
    }
    else { /* GEO */
        if (id!=1) return 0;
        
        pgn=getbitu(p+3,26+12,4); /* page number */
        if (pgn<1||10<pgn) {
            trace(2,"stq bds subframe page number error: prn=%2d pgn=%d\n",prn,pgn);
            return -1;
        }
        word=getbitu(p+3,j,26)<<4; j+=26;
        setbitu(raw->subfrm[sat-1]+(pgn-1)*38,0,30,word);
        
        for (i=1;i<10;i++) {
            word=getbitu(p+3,j,22)<<8; j+=22;
            setbitu(raw->subfrm[sat-1]+(pgn-1)*38,i*30,30,word);
        }
        if (pgn!=10) return 0;
        
        /* decode beidou D2 ephemeris */
        if (!decode_bds_d2(raw->subfrm[sat-1],&eph)) return 0;
    }
    if (!strstr(raw->opt,"-EPHALL")) {
        if (timediff(eph.toe,raw->nav.eph[sat-1].toe)==0.0&&
            eph.iode==raw->nav.eph[sat-1].iode&&
            eph.iodc==raw->nav.eph[sat-1].iodc) return 0; /* unchanged */
    }
    eph.sat=sat;
    raw->nav.eph[sat-1]=eph;
    raw->ephsat=sat;
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, %rbx
leaq -0x160(%rbp), %rdi
movl $0x120, %edx            # imm = 0x120
xorl %esi, %esi
callq 0x8390
movl 0x81a78(%rbx), %edx
leaq 0x1e365(%rip), %rsi     # 0x75a07
movl $0x4, %edi
xorl %eax, %eax
callq 0x4d55d
movl 0x81a78(%rbx), %edx
cmpl $0x25, %edx
jg 0x576c7
leaq 0x1e35e(%rip), %rsi     # 0x75a1e
movl $0x2, %edi
jmp 0x57741
cmpl $0x0, 0x81a8c(%rbx)
je 0x576fa
leaq 0x70e70(%rbx), %rdi
movzbl 0x81a95(%rbx), %ecx
addl $0xffffff38, %ecx       # imm = 0xFFFFFF38
movzbl 0x81a96(%rbx), %r8d
leaq 0x1e352(%rip), %rsi     # 0x75a45
xorl %eax, %eax
callq 0x8120
movzbl 0x81a95(%rbx), %r14d
leal -0xc8(%r14), %r13d
movl $0x20, %edi
movl %r13d, %esi
callq 0x4d28d
testl %eax, %eax
je 0x57732
movzbl 0x81a96(%rbx), %edx
leal -0x6(%rdx), %ecx
cmpb $-0x6, %cl
ja 0x57763
leaq 0x1e369(%rip), %rsi     # 0x75a99
jmp 0x57739
leaq 0x1e32f(%rip), %rsi     # 0x75a68
movl $0x2, %edi
movl %r13d, %edx
xorl %eax, %eax
callq 0x4d55d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $-0x32, %r14b
jb 0x5789e
leaq 0x81a97(%rbx), %r15
movq %rax, %r14
movl $0x1a, %r12d
movq %r15, %rdi
xorl %esi, %esi
movq %rdx, %r13
movl $0x1a, %edx
callq 0x4d9d6
shll $0x4, %eax
movq %r14, -0x40(%rbp)
leal -0x1(%r14), %ecx
movslq %ecx, %rcx
imulq $0x17c, %rcx, %rcx      # imm = 0x17C
leaq (%rbx,%rcx), %rdx
addq %rbx, %rcx
addq $0x70f70, %rcx          # imm = 0x70F70
movq %rcx, -0x30(%rbp)
movq %r13, -0x38(%rbp)
imulq $0x26, %r13, %rcx
leaq (%rcx,%rdx), %r13
addq $0x70f4a, %r13          # imm = 0x70F4A
movl $0x1e, %r14d
movq %r13, %rdi
xorl %esi, %esi
movl $0x1e, %edx
movl %eax, %ecx
callq 0x4da98
movq %r15, %rdi
movl %r12d, %esi
movl $0x16, %edx
callq 0x4d9d6
shll $0x8, %eax
addl $0x16, %r12d
movq %r13, %rdi
movl %r14d, %esi
movl $0x1e, %edx
movl %eax, %ecx
callq 0x4da98
addl $0x1e, %r14d
cmpl $0xe0, %r12d
jne 0x577e0
xorl %r12d, %r12d
cmpl $0x3, -0x38(%rbp)
jne 0x5774e
leaq -0x160(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0x33af1
testl %eax, %eax
je 0x5774e
leaq 0x82a90(%rbx), %rdi
leaq 0x14e7e(%rip), %rsi     # 0x6c6c7
callq 0x8160
testq %rax, %rax
movq -0x40(%rbp), %r15
je 0x579aa
leaq -0x160(%rbp), %rsi
movl %r15d, (%rsi)
movq 0x1d80(%rbx), %rax
movslq %r15d, %rcx
leaq (%rcx,%rcx,8), %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %rdi
addq $-0x120, %rdi           # imm = 0xFEE0
movl $0x120, %edx            # imm = 0x120
callq 0x84f0
movl %r15d, 0x70e40(%rbx)
movl $0x2, %r12d
jmp 0x5774e
cmpl $0x1, %edx
jne 0x57a1e
movq %rax, -0x40(%rbp)
leaq 0x81a97(%rbx), %r12
movq %r12, %rdi
movl $0x26, %esi
movl $0x4, %edx
callq 0x4d9d6
movl %eax, %r14d
leal -0xb(%r14), %eax
cmpl $-0xb, %eax
ja 0x578ee
leaq 0x1e1e6(%rip), %rsi     # 0x75abd
movl $0x2, %edi
movl %r13d, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4d55d
jmp 0x57748
movl $0x1a, %r13d
movq %r12, %rdi
xorl %esi, %esi
movl $0x1a, %edx
callq 0x4d9d6
shll $0x4, %eax
movq -0x40(%rbp), %rcx
decl %ecx
movslq %ecx, %rcx
imulq $0x17c, %rcx, %rcx      # imm = 0x17C
leaq (%rbx,%rcx), %rdx
addq %rbx, %rcx
addq $0x70f70, %rcx          # imm = 0x70F70
movq %rcx, -0x30(%rbp)
movq %r14, -0x38(%rbp)
imull $0x26, %r14d, %ecx
leaq (%rcx,%rdx), %r15
addq $0x70f4a, %r15          # imm = 0x70F4A
movl $0x1e, %r14d
movq %r15, %rdi
xorl %esi, %esi
movl $0x1e, %edx
movl %eax, %ecx
callq 0x4da98
movq %r12, %rdi
movl %r13d, %esi
movl $0x16, %edx
callq 0x4d9d6
shll $0x8, %eax
addl $0x16, %r13d
movq %r15, %rdi
movl %r14d, %esi
movl $0x1e, %edx
movl %eax, %ecx
callq 0x4da98
addl $0x1e, %r14d
cmpl $0xe0, %r13d
jne 0x57952
xorl %r12d, %r12d
cmpl $0xa, -0x38(%rbp)
jne 0x5774e
leaq -0x160(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0x34306
jmp 0x57833
movq -0x140(%rbp), %rdi
movsd -0x138(%rbp), %xmm0
movq 0x1d80(%rbx), %rax
leal -0x1(%r15), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,8), %r14
shlq $0x5, %r14
movq 0x20(%rax,%r14), %rsi
movsd 0x28(%rax,%r14), %xmm1
callq 0x4f51b
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5785b
jp 0x5785b
movl -0x15c(%rbp), %ecx
movq 0x1d80(%rbx), %rax
cmpl 0x4(%rax,%r14), %ecx
jne 0x5785b
addq %r14, %rax
movl -0x158(%rbp), %ecx
cmpl 0x8(%rax), %ecx
jne 0x5785b
xorl %r12d, %r12d
jmp 0x5774e