// File: /workspace/github_cpp_makefile_star2_O3/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 0x4d9d6
movl %eax, %r14d
movl 0x9f0c0(%rbx), %ecx
leaq 0x351cb(%rip), %rsi     # 0x6e3b0
movl $0x3, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x4d55d
movq %r15, %rdi
movl $0x18, %esi
movl $0xd, %edx
callq 0x4d9d6
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x350f4(%rip), %xmm0    # 0x6e308
ucomisd 0x316a4(%rip), %xmm0    # 0x6a8c0
jae 0x39233
movsd %xmm0, -0x38(%rbp)
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x39250
movsd 0x18(%rbx), %xmm0
jmp 0x39269
leaq 0x35196(%rip), %rsi     # 0x6e3d0
movl $0x2, %edi
movb $0x1, %al
callq 0x4d55d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x39481
callq 0x4f542
movq %rax, %rdi
callq 0x4fa70
movq %rax, %rdi
movq %rax, 0x10(%rbx)
movsd %xmm0, 0x18(%rbx)
leaq -0x2c(%rbp), %rsi
callq 0x4f2b1
movsd %xmm0, -0x40(%rbp)
divsd 0x31641(%rip), %xmm0    # 0x6a8c0
callq 0x8ac0
movsd -0x40(%rbp), %xmm3
movsd 0x3162f(%rip), %xmm1    # 0x6a8c0
mulsd %xmm0, %xmm1
subsd %xmm1, %xmm3
movsd 0x3506f(%rip), %xmm1    # 0x6e310
addsd %xmm3, %xmm1
movsd -0x38(%rbp), %xmm2
ucomisd %xmm2, %xmm1
jbe 0x392ba
movsd 0x31608(%rip), %xmm1    # 0x6a8c0
jmp 0x392d4
addsd 0x35056(%rip), %xmm3    # 0x6e318
ucomisd %xmm3, %xmm2
movapd %xmm2, %xmm1
jbe 0x392d8
movsd 0x3504c(%rip), %xmm1    # 0x6e320
addsd %xmm2, %xmm1
movl -0x2c(%rbp), %edi
mulsd 0x315dd(%rip), %xmm0    # 0x6a8c0
addsd %xmm1, %xmm0
callq 0x4f24a
movq %rax, 0x10(%rbx)
movsd %xmm0, 0x18(%rbx)
movq %r15, %rdi
movl $0xe, %esi
movl $0xa, %edx
callq 0x4d9d6
movl %eax, %r12d
movq %r15, %rdi
movl $0x25, %esi
movl $0x3, %edx
callq 0x4d9d6
movl %eax, %r13d
movq %r15, %rdi
movl $0x2d, %esi
movl $0x3, %edx
callq 0x4d9d6
movl %eax, %r15d
movl 0x8(%rbx), %edx
movl %r13d, %eax
subl %edx, %eax
cmpl $-0x7, %eax
je 0x3935c
cmpl $0x1, %eax
je 0x3935c
leaq 0x350ac(%rip), %rsi     # 0x6e3f9
movl $0x2, %edi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x4d55d
movl %r13d, 0x8(%rbx)
movl %r15d, 0x4(%rbx)
cmpl $0x0, 0xc(%rbx)
movsd -0x38(%rbp), %xmm0
je 0x39393
leaq 0x9b9d0(%rbx), %rdi
movl 0x9f0c0(%rbx), %ecx
leaq 0x3509a(%rip), %rsi     # 0x6e41d
movl %r14d, %edx
movl %r12d, %r8d
movl %r13d, %r9d
movb $0x1, %al
callq 0x8120
cmpl $0x18, %r14d
ja 0x393fa
movl $0x1c00008, %eax        # imm = 0x1C00008
btl %r14d, %eax
jae 0x393fa
movl (%rbx), %edx
testl %edx, %edx
sete %al
cmpl %edx, %r12d
sete %cl
orb %al, %cl
jne 0x393cb
leaq 0x3508e(%rip), %rsi     # 0x6e44a
movl $0x2, %edi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x4d55d
movl %r12d, (%rbx)
leal -0x1(%r14), %ecx
cmpl $0x15, %ecx
ja 0x39490
leaq 0x34f56(%rip), %rax     # 0x6e338
movslq (%rax,%rcx,4), %rdx
addq %rax, %rdx
jmpq *%rdx
movq %rbx, %rdi
callq 0x394a1
movl $0x7, %eax
jmp 0x39477
movl (%rbx), %ecx
testl %ecx, %ecx
sete %al
cmpl %ecx, %r12d
sete %dl
orb %al, %dl
jne 0x393ce
leaq 0x3505a(%rip), %rsi     # 0x6e46c
movl $0x2, %edi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4d55d
jmp 0x39246
movq %rbx, %rdi
callq 0x39654
jmp 0x3946f
movq %rbx, %rdi
callq 0x398ec
jmp 0x3946f
movq %rbx, %rdi
callq 0x39fbf
jmp 0x3946f
movq %rbx, %rdi
callq 0x3a2c8
jmp 0x3946f
movq %rbx, %rdi
callq 0x39729
jmp 0x3946f
movq %rbx, %rdi
callq 0x39839
movl $0x9, %eax
jmp 0x39477
movq %rbx, %rdi
callq 0x3a57e
testl %eax, %eax
js 0x39246
movl %r14d, %ecx
incl 0x9f578(%rbx,%rcx,4)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
cmpl $0x62, %ecx
jbe 0x39477
incl 0x9f578(%rbx)
xorl %eax, %eax
jmp 0x39481