// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_type1029(bamboo::rtcm_t*)
static int decode_type1029(rtcm_t *rtcm)
{
    char *msg;
    int i=24+12,j,staid,mjd,tod,nchar,cunit;
    
    if (i+60<=rtcm->len*8) {
        staid=getbitu(rtcm->buff,i,12); i+=12;
        mjd  =getbitu(rtcm->buff,i,16); i+=16;
        tod  =getbitu(rtcm->buff,i,17); i+=17;
        nchar=getbitu(rtcm->buff,i, 7); i+= 7;
        cunit=getbitu(rtcm->buff,i, 8); i+= 8;
    }
    else {
        trace(2,"rtcm3 1029 length error: len=%d\n",rtcm->len);
        return -1;
    }
    if (i+nchar*8>rtcm->len*8) {
        trace(2,"rtcm3 1029 length error: len=%d nchar=%d\n",rtcm->len,nchar);
        return -1;
    } 
    for (j=0;j<nchar&&j<126;j++) {
        rtcm->msg[j]=getbitu(rtcm->buff,i,8); i+=8;
    }
    rtcm->msg[j]='\0';
    
    if (rtcm->outtype) {
        msg=rtcm->msgtype+strlen(rtcm->msgtype);
        sprintf(msg," staid=%4d text=%s",staid,rtcm->msg);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl $0x24, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x3c, %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x72714
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0xc, %edx
callq 0x8bfc0
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %eax
addl $0xc, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x10, %edx
callq 0x8bfc0
movl %eax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x11, %edx
callq 0x8bfc0
movl %eax, -0x2c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x11, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x7, %edx
callq 0x8bfc0
movl %eax, -0x30(%rbp)
movl -0x1c(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x8, %edx
callq 0x8bfc0
movl %eax, -0x34(%rbp)
movl -0x1c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x1c(%rbp)
jmp 0x7273d
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %edx
movl $0x2, %edi
leaq 0x4eeef(%rip), %rsi     # 0xc1619
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x72856
movl -0x1c(%rbp), %eax
movl -0x30(%rbp), %ecx
shll $0x3, %ecx
addl %ecx, %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jle 0x72785
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %edx
movl -0x30(%rbp), %ecx
movl $0x2, %edi
leaq 0x4eec8(%rip), %rsi     # 0xc163a
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x72856
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %ecx
xorl %eax, %eax
cmpl -0x30(%rbp), %ecx
movb %al, -0x35(%rbp)
jge 0x727a3
cmpl $0x7e, -0x20(%rbp)
setl %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0x727ac
jmp 0x727e9
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x8, %edx
callq 0x8bfc0
movb %al, %dl
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb %dl, 0x9b950(%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x7278c
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb $0x0, 0x9b950(%rax,%rcx)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x7284f
movq -0x10(%rbp), %rax
addq $0x9b9d0, %rax          # imm = 0x9B9D0
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9b9d0, %rdi          # imm = 0x9B9D0
callq 0x92e0
movq %rax, %rcx
movq -0x40(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %edx
movq -0x10(%rbp), %rcx
addq $0x9b950, %rcx          # imm = 0x9B950
leaq 0x4ee1c(%rip), %rsi     # 0xc1664
movb $0x0, %al
callq 0x9150
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop