// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rtcm2.cpp
// Function: bamboo::decode_rtcm2(bamboo::rtcm_t*)
extern int decode_rtcm2(rtcm_t *rtcm)
{
    double zcnt;
    int staid,seqno,stah,ret=0,type=getbitu(rtcm->buff,8,6);
    
    trace(3,"decode_rtcm2: type=%2d len=%3d\n",type,rtcm->len);
    
    if ((zcnt=getbitu(rtcm->buff,24,13)*0.6)>=3600.0) {
        trace(2,"rtcm2 modified z-count error: zcnt=%.1f\n",zcnt);
        return -1;
    }
    adjhour(rtcm,zcnt);
    staid=getbitu(rtcm->buff,14,10);
    seqno=getbitu(rtcm->buff,37, 3);
    stah =getbitu(rtcm->buff,45, 3);
    if (seqno-rtcm->seqno!=1&&seqno-rtcm->seqno!=-7) {
        trace(2,"rtcm2 message outage: seqno=%d->%d\n",rtcm->seqno,seqno);
    }
    rtcm->seqno=seqno;
    rtcm->stah =stah;
    
    if (rtcm->outtype) {
        sprintf(rtcm->msgtype,"RTCM %2d (%4d) zcnt=%7.1f staid=%3d seqno=%d",
                type,rtcm->len,zcnt,staid,seqno);
    }
    if (type==3||type==22||type==23||type==24) {
        if (rtcm->staid!=0&&staid!=rtcm->staid) {
           trace(2,"rtcm2 station id changed: %d->%d\n",rtcm->staid,staid);
        }
        rtcm->staid=staid;
    }
    if (rtcm->staid!=0&&staid!=rtcm->staid) {
        trace(2,"rtcm2 station id invalid: %d %d\n",staid,rtcm->staid);
        return -1;
    }
    switch (type) {
        case  1: ret=decode_type1 (rtcm); break;
        case  3: ret=decode_type3 (rtcm); break;
        case  9: ret=decode_type1 (rtcm); break;
        case 14: ret=decode_type14(rtcm); break;
        case 16: ret=decode_type16(rtcm); break;
        case 17: ret=decode_type17(rtcm); break;
        case 18: ret=decode_type18(rtcm); break;
        case 19: ret=decode_type19(rtcm); break;
        case 22: ret=decode_type22(rtcm); break;
        case 23: ret=decode_type23(rtcm); break; /* not supported */
        case 24: ret=decode_type24(rtcm); break; /* not supported */
        case 31: ret=decode_type31(rtcm); break; /* not supported */
        case 32: ret=decode_type32(rtcm); break; /* not supported */
        case 34: ret=decode_type34(rtcm); break; /* not supported */
        case 36: ret=decode_type36(rtcm); break; /* not supported */
        case 37: ret=decode_type37(rtcm); break; /* not supported */
        case 59: ret=decode_type59(rtcm); break; /* not supported */
    }
    if (ret>=0) {
        if (1<=type&&type<=99) rtcm->nmsg2[type]++; else rtcm->nmsg2[0]++;
    }
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x9f0c4(%rdi), %r15
movq %r15, %rdi
movl $0x8, %esi
movl $0x6, %edx
callq 0x4e341
movl %eax, %r14d
movl 0x9f0c0(%rbx), %ecx
leaq 0x34b7b(%rip), %rsi     # 0x6e3b0
movl $0x3, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x4ded0
movq %r15, %rdi
movl $0x18, %esi
movl $0xd, %edx
callq 0x4e341
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x34aa4(%rip), %xmm0    # 0x6e308
ucomisd 0x31054(%rip), %xmm0    # 0x6a8c0
jae 0x398ea
movsd %xmm0, -0x38(%rbp)
cmpq $0x0, 0x10(%rbx)
jne 0x39890
callq 0x4febe
movq %rax, %rdi
callq 0x5040e
movq %rax, 0x10(%rbx)
movsd %xmm0, 0x18(%rbx)
movq 0x10(%rbx), %rdi
movsd 0x18(%rbx), %xmm0
leaq -0x2c(%rbp), %rsi
callq 0x4fc2d
movsd %xmm0, -0x40(%rbp)
divsd 0x31011(%rip), %xmm0    # 0x6a8c0
callq 0x8ad0
movsd -0x40(%rbp), %xmm3
movsd 0x30fff(%rip), %xmm1    # 0x6a8c0
mulsd %xmm0, %xmm1
subsd %xmm1, %xmm3
movsd 0x34a3f(%rip), %xmm1    # 0x6e310
addsd %xmm3, %xmm1
movsd -0x38(%rbp), %xmm2
ucomisd %xmm2, %xmm1
jbe 0x39902
movsd 0x30fd8(%rip), %xmm1    # 0x6a8c0
jmp 0x3991c
leaq 0x34adf(%rip), %rsi     # 0x6e3d0
movl $0x2, %edi
movb $0x1, %al
callq 0x4ded0
jmp 0x39a6c
addsd 0x34a0e(%rip), %xmm3    # 0x6e318
ucomisd %xmm3, %xmm2
movapd %xmm2, %xmm1
jbe 0x39920
movsd 0x34a04(%rip), %xmm1    # 0x6e320
addsd %xmm2, %xmm1
movl -0x2c(%rbp), %edi
mulsd 0x30f95(%rip), %xmm0    # 0x6a8c0
addsd %xmm1, %xmm0
callq 0x4fbc6
movq %rax, 0x10(%rbx)
movsd %xmm0, 0x18(%rbx)
movq %r15, %rdi
movl $0xe, %esi
movl $0xa, %edx
callq 0x4e341
movl %eax, %r12d
movq %r15, %rdi
movl $0x25, %esi
movl $0x3, %edx
callq 0x4e341
movl %eax, %r13d
movq %r15, %rdi
movl $0x2d, %esi
movl $0x3, %edx
callq 0x4e341
movl %eax, %r15d
movl 0x8(%rbx), %edx
movl %r13d, %eax
subl %edx, %eax
cmpl $-0x7, %eax
je 0x399a4
cmpl $0x1, %eax
je 0x399a4
leaq 0x34a64(%rip), %rsi     # 0x6e3f9
movl $0x2, %edi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x4ded0
movl %r13d, 0x8(%rbx)
movl %r15d, 0x4(%rbx)
cmpl $0x0, 0xc(%rbx)
movsd -0x38(%rbp), %xmm0
je 0x399db
leaq 0x9b9d0(%rbx), %rdi
movl 0x9f0c0(%rbx), %ecx
leaq 0x34a52(%rip), %rsi     # 0x6e41d
movl %r14d, %edx
movl %r12d, %r8d
movl %r13d, %r9d
movb $0x1, %al
callq 0x8120
cmpl $0x18, %r14d
ja 0x39a16
movl $0x1c00008, %eax        # imm = 0x1C00008
btl %r14d, %eax
jae 0x39a16
movl (%rbx), %edx
testl %edx, %edx
sete %al
cmpl %edx, %r12d
sete %cl
orb %al, %cl
jne 0x39a13
leaq 0x34a46(%rip), %rsi     # 0x6e44a
movl $0x2, %edi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x4ded0
movl %r12d, (%rbx)
movl (%rbx), %ecx
testl %ecx, %ecx
sete %al
cmpl %ecx, %r12d
sete %dl
orb %al, %dl
je 0x39a56
xorl %eax, %eax
leal -0x1(%r14), %r15d
cmpl $0x15, %r15d
ja 0x39ac9
leaq 0x348fa(%rip), %rcx     # 0x6e338
movslq (%rcx,%r15,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movq %rbx, %rdi
callq 0x39ae7
movl $0x7, %eax
jmp 0x39ac9
leaq 0x34a0f(%rip), %rsi     # 0x6e46c
movl $0x2, %edi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4ded0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x39c9a
jmp 0x39ac9
movq %rbx, %rdi
callq 0x39f32
jmp 0x39ac9
movq %rbx, %rdi
callq 0x3a612
jmp 0x39ac9
movq %rbx, %rdi
callq 0x3a91b
jmp 0x39ac9
movq %rbx, %rdi
callq 0x39d6f
jmp 0x39ac9
movq %rbx, %rdi
callq 0x39e7f
movl $0x9, %eax
jmp 0x39ac9
movq %rbx, %rdi
callq 0x3abd1
testl %eax, %eax
js 0x39a71
cmpl $0x62, %r15d
ja 0x39adf
movl %r14d, %ecx
incl 0x9f578(%rbx,%rcx,4)
jmp 0x39a71
incl 0x9f578(%rbx)
jmp 0x39a71