// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_type1005(bamboo::rtcm_t*)
static int decode_type1005(rtcm_t *rtcm)
{
    double rr[3],re[3],pos[3];
    char *msg;
    int i=24+12,j,staid,itrf;
    
    if (i+140==rtcm->len*8) {
        staid=getbitu(rtcm->buff,i,12); i+=12;
        itrf =getbitu(rtcm->buff,i, 6); i+= 6+4;
        rr[0]=getbits_38(rtcm->buff,i); i+=38+2;
        rr[1]=getbits_38(rtcm->buff,i); i+=38+2;
        rr[2]=getbits_38(rtcm->buff,i);
    }
    else {
        trace(2,"rtcm3 1005 length error: len=%d\n",rtcm->len);
        return -1;
    }
    if (rtcm->outtype) {
        msg=rtcm->msgtype+strlen(rtcm->msgtype);
        for (j=0;j<3;j++) re[j]=rr[j]*0.0001;
        ecef2pos(re,pos);
        sprintf(msg," staid=%4d pos=%.8f %.8f %.3f",staid,pos[0]*R2D,pos[1]*R2D,
                pos[2]);
    }
    /* test station id */
    if (!test_staid(rtcm,staid)) return -1;
    
    rtcm->sta.deltype=0; /* xyz */
    for (j=0;j<3;j++) {
        rtcm->sta.pos[j]=rr[j]*0.0001;
        rtcm->sta.del[j]=0.0;
    }
    rtcm->sta.hgt=0.0;
    rtcm->sta.itrf=itrf;
    return 5;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl 0x9f0c0(%rdi), %edx
cmpl $0x16, %edx
jne 0x3b956
movq %rdi, %rbx
leaq 0x9f0c4(%rdi), %r12
movq %r12, %rdi
movl $0x24, %esi
movl $0xc, %edx
callq 0x4d9d6
movl %eax, %r15d
movq %r12, %rdi
movl $0x30, %esi
movl $0x6, %edx
callq 0x4d9d6
movl %eax, %r14d
movq %r12, %rdi
movl $0x3a, %esi
movl $0x20, %edx
callq 0x4da25
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r12, %rdi
movl $0x5a, %esi
movl $0x6, %edx
callq 0x4d9d6
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x30(%rbp), %xmm1
mulsd 0x2f2c7(%rip), %xmm1    # 0x6aa90
addsd %xmm0, %xmm1
movsd %xmm1, -0x50(%rbp)
movq %r12, %rdi
movl $0x62, %esi
movl $0x20, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r12, %rdi
movl $0x82, %esi
movl $0x6, %edx
callq 0x4d9d6
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x30(%rbp), %xmm1
mulsd 0x2f277(%rip), %xmm1    # 0x6aa90
addsd %xmm0, %xmm1
movsd %xmm1, -0x48(%rbp)
movq %r12, %rdi
movl $0x8a, %esi
movl $0x20, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r12, %rdi
movl $0xaa, %esi
movl $0x6, %edx
callq 0x4d9d6
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x30(%rbp), %xmm1
mulsd 0x2f227(%rip), %xmm1    # 0x6aa90
addsd %xmm0, %xmm1
movsd %xmm1, -0x40(%rbp)
cmpl $0x0, 0xc(%rbx)
je 0x3b8f2
leaq 0x9b9d0(%rbx), %r12
movq %r12, %rdi
callq 0x8290
xorl %ecx, %ecx
movsd 0x2f08f(%rip), %xmm0    # 0x6a920
movsd -0x50(%rbp,%rcx,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x70(%rbp,%rcx,8)
incq %rcx
cmpq $0x3, %rcx
jne 0x3b891
addq %rax, %r12
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %r13
movq %r13, %rsi
callq 0x500e2
movsd 0x33570(%rip), %xmm1    # 0x6ee38
movsd (%r13), %xmm0
mulsd %xmm1, %xmm0
mulsd 0x8(%r13), %xmm1
movsd 0x10(%r13), %xmm2
leaq 0x33777(%rip), %rsi     # 0x6f05c
movq %r12, %rdi
movl %r15d, %edx
movb $0x3, %al
callq 0x8120
movq %rbx, %rdi
movl %r15d, %esi
callq 0x426d9
testl %eax, %eax
je 0x3b969
movl $0x0, 0x6f100(%rbx)
xorl %eax, %eax
movsd 0x2f00b(%rip), %xmm0    # 0x6a920
movsd -0x50(%rbp,%rax,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x6f108(%rbx,%rax,8)
movq $0x0, 0x6f120(%rbx,%rax,8)
incq %rax
cmpq $0x3, %rax
jne 0x3b915
movq $0x0, 0x6f138(%rbx)
movl %r14d, 0x6f0fc(%rbx)
movl $0x5, %eax
jmp 0x3b96e
leaq 0x336de(%rip), %rsi     # 0x6f03b
movl $0x2, %edi
xorl %eax, %eax
callq 0x4d55d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq