// File: 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
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl $0x24, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
addl $0x8c, %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jne 0x6fa5d
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x7c(%rbp), %esi
movl $0xc, %edx
callq 0x8bfc0
movl %eax, -0x84(%rbp)
movl -0x7c(%rbp), %eax
addl $0xc, %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x7c(%rbp), %esi
movl $0x6, %edx
callq 0x8bfc0
movl %eax, -0x88(%rbp)
movl -0x7c(%rbp), %eax
addl $0xa, %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x7c(%rbp), %esi
callq 0x7a500
movsd %xmm0, -0x30(%rbp)
movl -0x7c(%rbp), %eax
addl $0x28, %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x7c(%rbp), %esi
callq 0x7a500
movsd %xmm0, -0x28(%rbp)
movl -0x7c(%rbp), %eax
addl $0x28, %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x7c(%rbp), %esi
callq 0x7a500
movsd %xmm0, -0x20(%rbp)
jmp 0x6fa86
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %edx
movl $0x2, %edi
leaq 0x517ed(%rip), %rsi     # 0xc1260
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6fbe1
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x6fb3e
movq -0x10(%rbp), %rax
addq $0x9b9d0, %rax          # imm = 0x9B9D0
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9b9d0, %rdi          # imm = 0x9B9D0
callq 0x92e0
movq %rax, %rcx
movq -0x90(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x80(%rbp)
cmpl $0x3, -0x80(%rbp)
jge 0x6fafa
movslq -0x80(%rbp), %rax
movsd 0x4d389(%rip), %xmm0    # 0xbce68
mulsd -0x30(%rbp,%rax,8), %xmm0
movslq -0x80(%rbp), %rax
movsd %xmm0, -0x50(%rbp,%rax,8)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x6facd
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8fb80
movq -0x78(%rbp), %rdi
movl -0x84(%rbp), %edx
movsd 0x50ed7(%rip), %xmm0    # 0xc09f0
mulsd -0x70(%rbp), %xmm0
movsd 0x50eca(%rip), %xmm1    # 0xc09f0
mulsd -0x68(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
leaq 0x5174a(%rip), %rsi     # 0xc1281
movb $0x3, %al
callq 0x9150
movq -0x10(%rbp), %rdi
movl -0x84(%rbp), %esi
callq 0x79f30
cmpl $0x0, %eax
jne 0x6fb5e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6fbe1
movq -0x10(%rbp), %rax
movl $0x0, 0x6f100(%rax)
movl $0x0, -0x80(%rbp)
cmpl $0x3, -0x80(%rbp)
jge 0x6fbbb
movslq -0x80(%rbp), %rax
movsd 0x4d2e3(%rip), %xmm0    # 0xbce68
mulsd -0x30(%rbp,%rax,8), %xmm0
movq -0x10(%rbp), %rax
movslq -0x80(%rbp), %rcx
movsd %xmm0, 0x6f108(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x80(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x6f120(%rax,%rcx,8)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x6fb73
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x6f138(%rax)
movl -0x88(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x6f0fc(%rax)
movl $0x5, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)