// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_type1020(bamboo::rtcm_t*)
static int decode_type1020(rtcm_t *rtcm)
{
    geph_t geph={0};
    double tk_h,tk_m,tk_s,toe,tow,tod,tof;
    char *msg;
    int i=24+12,prn,sat,week,tb,bn,sys=SYS_GLO;
    
    if (i+348<=rtcm->len*8) {
        prn        =getbitu(rtcm->buff,i, 6);           i+= 6;
        geph.frq   =getbitu(rtcm->buff,i, 5)-7;         i+= 5+2+2;
        tk_h       =getbitu(rtcm->buff,i, 5);           i+= 5;
        tk_m       =getbitu(rtcm->buff,i, 6);           i+= 6;
        tk_s       =getbitu(rtcm->buff,i, 1)*30.0;      i+= 1;
        bn         =getbitu(rtcm->buff,i, 1);           i+= 1+1;
        tb         =getbitu(rtcm->buff,i, 7);           i+= 7;
        geph.vel[0]=getbitg(rtcm->buff,i,24)*P2_20*1E3; i+=24;
        geph.pos[0]=getbitg(rtcm->buff,i,27)*P2_11*1E3; i+=27;
        geph.acc[0]=getbitg(rtcm->buff,i, 5)*P2_30*1E3; i+= 5;
        geph.vel[1]=getbitg(rtcm->buff,i,24)*P2_20*1E3; i+=24;
        geph.pos[1]=getbitg(rtcm->buff,i,27)*P2_11*1E3; i+=27;
        geph.acc[1]=getbitg(rtcm->buff,i, 5)*P2_30*1E3; i+= 5;
        geph.vel[2]=getbitg(rtcm->buff,i,24)*P2_20*1E3; i+=24;
        geph.pos[2]=getbitg(rtcm->buff,i,27)*P2_11*1E3; i+=27;
        geph.acc[2]=getbitg(rtcm->buff,i, 5)*P2_30*1E3; i+= 5+1;
        geph.gamn  =getbitg(rtcm->buff,i,11)*P2_40;     i+=11+3;
        geph.taun  =getbitg(rtcm->buff,i,22)*P2_30;
    }
    else {
        trace(2,"rtcm3 1020 length error: len=%d\n",rtcm->len);
        return -1;
    }
    if (!(sat=satno(sys,prn))) {
        trace(2,"rtcm3 1020 satellite number error: prn=%d\n",prn);
        return -1;
    }
    trace(4,"decode_type1020: prn=%d tk=%02.0f:%02.0f:%02.0f\n",prn,tk_h,tk_m,tk_s);
    
    if (rtcm->outtype) {
        msg=rtcm->msgtype+strlen(rtcm->msgtype);
        sprintf(msg," prn=%2d tk=%02.0f:%02.0f:%02.0f frq=%2d bn=%d tb=%d",
                prn,tk_h,tk_m,tk_s,geph.frq,bn,tb);
    }
    geph.sat=sat;
    geph.svh=bn;
    geph.iode=tb&0x7F;
    if (rtcm->time.time==0) rtcm->time=utc2gpst(timeget());
    tow=time2gpst(gpst2utc(rtcm->time),&week);
    tod=fmod(tow,86400.0); tow-=tod;
    tof=tk_h*3600.0+tk_m*60.0+tk_s-10800.0; /* lt->utc */
    if      (tof<tod-43200.0) tof+=86400.0;
    else if (tof>tod+43200.0) tof-=86400.0;
    geph.tof=utc2gpst(gpst2time(week,tow+tof));
    toe=tb*900.0-10800.0; /* lt->utc */
    if      (toe<tod-43200.0) toe+=86400.0;
    else if (toe>tod+43200.0) toe-=86400.0;
    geph.toe=utc2gpst(gpst2time(week,tow+toe)); /* utc->gpst */
    
    if (!strstr(rtcm->opt,"-EPHALL")) {
        if (fabs(timediff(geph.toe,rtcm->nav.geph[prn-1].toe))<1.0&&
            geph.svh==rtcm->nav.geph[prn-1].svh) return 0; /* unchanged */
    }
    rtcm->nav.geph[prn-1]=geph;
    rtcm->ephsat=sat;
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x10(%rbp)
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x93d0
movl $0x24, -0xec(%rbp)
movl $0x4, -0x104(%rbp)
movl -0xec(%rbp), %eax
addl $0x15c, %eax            # imm = 0x15C
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x71f36
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x6, %edx
movl %edx, -0x1ac(%rbp)
callq 0x8bfc0
movl %eax, -0xf0(%rbp)
movl -0xec(%rbp), %eax
addl $0x6, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x5, %edx
movl %edx, -0x1b0(%rbp)
callq 0x8bfc0
movl -0x1b0(%rbp), %edx
addl $-0x7, %eax
movl %eax, -0xa0(%rbp)
movl -0xec(%rbp), %eax
addl $0x9, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
callq 0x8bfc0
movl -0x1ac(%rbp), %edx
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0xb0(%rbp)
movl -0xec(%rbp), %eax
addl $0x5, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0xb8(%rbp)
movl -0xec(%rbp), %eax
addl $0x6, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x1, %edx
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0x4ee2d(%rip), %xmm1    # 0xc0a00
mulsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x1, %edx
callq 0x8bfc0
movl %eax, -0x100(%rbp)
movl -0xec(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x7, %edx
callq 0x8bfc0
movl %eax, -0xfc(%rbp)
movl -0xec(%rbp), %eax
addl $0x7, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x18, %edx
callq 0x7a9c0
movsd 0x4d22f(%rip), %xmm1    # 0xbeea0
mulsd %xmm1, %xmm0
movsd 0x4b7ab(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0xec(%rbp), %eax
addl $0x18, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x1b, %edx
callq 0x7a9c0
movsd 0x4d1e0(%rip), %xmm1    # 0xbee98
mulsd %xmm1, %xmm0
movsd 0x4b764(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0xec(%rbp), %eax
addl $0x1b, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x5, %edx
callq 0x7a9c0
movsd 0x4d191(%rip), %xmm1    # 0xbee90
mulsd %xmm1, %xmm0
movsd 0x4b71d(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0xec(%rbp), %eax
addl $0x5, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x18, %edx
callq 0x7a9c0
movsd 0x4d15a(%rip), %xmm1    # 0xbeea0
mulsd %xmm1, %xmm0
movsd 0x4b6d6(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0xec(%rbp), %eax
addl $0x18, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x1b, %edx
callq 0x7a9c0
movsd 0x4d10b(%rip), %xmm1    # 0xbee98
mulsd %xmm1, %xmm0
movsd 0x4b68f(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0xec(%rbp), %eax
addl $0x1b, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x5, %edx
callq 0x7a9c0
movsd 0x4d0bc(%rip), %xmm1    # 0xbee90
mulsd %xmm1, %xmm0
movsd 0x4b648(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0xec(%rbp), %eax
addl $0x5, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x18, %edx
callq 0x7a9c0
movsd 0x4d085(%rip), %xmm1    # 0xbeea0
mulsd %xmm1, %xmm0
movsd 0x4b601(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0xec(%rbp), %eax
addl $0x18, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x1b, %edx
callq 0x7a9c0
movsd 0x4d036(%rip), %xmm1    # 0xbee98
mulsd %xmm1, %xmm0
movsd 0x4b5ba(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0xec(%rbp), %eax
addl $0x1b, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x5, %edx
callq 0x7a9c0
movsd 0x4cfe7(%rip), %xmm1    # 0xbee90
mulsd %xmm1, %xmm0
movsd 0x4b573(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0xec(%rbp), %eax
addl $0x6, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0xb, %edx
callq 0x7a9c0
movsd 0x4cfb8(%rip), %xmm1    # 0xbeea8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0xec(%rbp), %eax
addl $0xe, %eax
movl %eax, -0xec(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xec(%rbp), %esi
movl $0x16, %edx
callq 0x7a9c0
movsd 0x4cf65(%rip), %xmm1    # 0xbee90
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x71f5f
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %edx
movl $0x2, %edi
leaq 0x4f526(%rip), %rsi     # 0xc1472
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x724cd
movl -0x104(%rbp), %edi
movl -0xf0(%rbp), %esi
callq 0x8b1b0
movl %eax, -0xf4(%rbp)
cmpl $0x0, %eax
jne 0x71fa0
movl -0xf0(%rbp), %edx
movl $0x2, %edi
leaq 0x4f506(%rip), %rsi     # 0xc1493
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x724cd
movl -0xf0(%rbp), %edx
movsd -0xb0(%rbp), %xmm0
movsd -0xb8(%rbp), %xmm1
movsd -0xc0(%rbp), %xmm2
movl $0x4, %edi
leaq 0x4f4f4(%rip), %rsi     # 0xc14be
movb $0x3, %al
callq 0x8b980
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x72057
movq -0x10(%rbp), %rax
addq $0x9b9d0, %rax          # imm = 0x9B9D0
movq %rax, -0x1b8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9b9d0, %rdi          # imm = 0x9B9D0
callq 0x92e0
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
movl -0xf0(%rbp), %edx
movsd -0xb0(%rbp), %xmm0
movsd -0xb8(%rbp), %xmm1
movsd -0xc0(%rbp), %xmm2
movl -0xa0(%rbp), %ecx
movl -0x100(%rbp), %r8d
movl -0xfc(%rbp), %r9d
leaq 0x4f49f(%rip), %rsi     # 0xc14ef
movb $0x3, %al
callq 0x9150
movl -0xf4(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0x100(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0xfc(%rbp), %eax
andl $0x7f, %eax
movl %eax, -0xa4(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x720da
callq 0x8e920
movq %rax, -0x128(%rbp)
movsd %xmm0, -0x120(%rbp)
movq -0x128(%rbp), %rdi
movsd -0x120(%rbp), %xmm0
callq 0x8f0a0
movq %rax, -0x118(%rbp)
movsd %xmm0, -0x110(%rbp)
movq -0x10(%rbp), %rax
movq -0x118(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x110(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x148(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x148(%rbp), %rdi
movsd -0x140(%rbp), %xmm0
callq 0x8ef80
movq %rax, -0x138(%rbp)
movsd %xmm0, -0x130(%rbp)
movq -0x138(%rbp), %rdi
movsd -0x130(%rbp), %xmm0
leaq -0xf8(%rbp), %rsi
callq 0x8e540
movsd %xmm0, -0xd0(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd 0x4acd6(%rip), %xmm1    # 0xbce20
callq 0x99f0
movsd %xmm0, -0xd8(%rbp)
movsd -0xd8(%rbp), %xmm1
movsd -0xd0(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0xb0(%rbp), %xmm0
movsd 0x4ac95(%rip), %xmm1    # 0xbce18
mulsd -0xb8(%rbp), %xmm1
movsd 0x4ac7d(%rip), %xmm2    # 0xbce10
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd -0xc0(%rbp), %xmm0
movsd 0x4ae45(%rip), %xmm1    # 0xbcff0
subsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0xe0(%rbp), %xmm1
movsd -0xd8(%rbp), %xmm0
movsd 0x4bba1(%rip), %xmm2    # 0xbdd70
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x721f3
movsd 0x4ac3f(%rip), %xmm0    # 0xbce20
addsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
jmp 0x7222f
movsd -0xe0(%rbp), %xmm0
movsd 0x4bb6d(%rip), %xmm1    # 0xbdd70
addsd -0xd8(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x7222d
movsd -0xe0(%rbp), %xmm0
movsd 0x4abff(%rip), %xmm1    # 0xbce20
subsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
jmp 0x7222f
movl -0xf8(%rbp), %edi
movsd -0xd0(%rbp), %xmm0
addsd -0xe0(%rbp), %xmm0
callq 0x8e4a0
movq %rax, -0x168(%rbp)
movsd %xmm0, -0x160(%rbp)
movq -0x168(%rbp), %rdi
movsd -0x160(%rbp), %xmm0
callq 0x8f0a0
movq %rax, -0x158(%rbp)
movsd %xmm0, -0x150(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x150(%rbp), %rax
movq %rax, -0x78(%rbp)
cvtsi2sdl -0xfc(%rbp), %xmm0
movsd 0x4ad46(%rip), %xmm1    # 0xbcfe8
mulsd %xmm1, %xmm0
movsd 0x4cc02(%rip), %xmm1    # 0xbeeb0
addsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0xc8(%rbp), %xmm1
movsd -0xd8(%rbp), %xmm0
movsd 0x4ba9e(%rip), %xmm2    # 0xbdd70
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x722f6
movsd 0x4ab3c(%rip), %xmm0    # 0xbce20
addsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
jmp 0x72332
movsd -0xc8(%rbp), %xmm0
movsd 0x4ba6a(%rip), %xmm1    # 0xbdd70
addsd -0xd8(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x72330
movsd -0xc8(%rbp), %xmm0
movsd 0x4aafc(%rip), %xmm1    # 0xbce20
subsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
jmp 0x72332
movl -0xf8(%rbp), %edi
movsd -0xd0(%rbp), %xmm0
addsd -0xc8(%rbp), %xmm0
callq 0x8e4a0
movq %rax, -0x188(%rbp)
movsd %xmm0, -0x180(%rbp)
movq -0x188(%rbp), %rdi
movsd -0x180(%rbp), %xmm0
callq 0x8f0a0
movq %rax, -0x178(%rbp)
movsd %xmm0, -0x170(%rbp)
movq -0x178(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9fd48, %rdi          # imm = 0x9FD48
leaq 0x4c4b2(%rip), %rsi     # 0xbe85f
callq 0x91b0
cmpq $0x0, %rax
jne 0x72485
movq -0x90(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movl -0xf0(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rcx
movq %rcx, -0x1a8(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1a0(%rbp)
movq -0x198(%rbp), %rdi
movsd -0x190(%rbp), %xmm0
movq -0x1a8(%rbp), %rsi
movsd -0x1a0(%rbp), %xmm1
callq 0x8e8e0
movaps %xmm0, %xmm1
movaps 0x4ade4(%rip), %xmm0    # 0xbd220
pand %xmm0, %xmm1
movsd 0x49a18(%rip), %xmm0    # 0xbbe60
ucomisd %xmm1, %xmm0
jbe 0x72483
movl -0x9c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x88(%rcx), %rcx
movl -0xf0(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x98, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jne 0x72483
movl $0x0, -0x4(%rbp)
jmp 0x724cd
jmp 0x72485
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movl -0xf0(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x98, %rax, %rax
addq %rax, %rdi
leaq -0xa8(%rbp), %rsi
movl $0x98, %edx
callq 0x9610
movl -0xf4(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x9bdd4(%rax)
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
nopl (%rax)