// File: DoubleString[P]RtConverter/src/Rtklib/binex.cpp
// Function: bamboo::decode_bnx_01_02(bamboo::raw_t*, unsigned char*, int)
static int decode_bnx_01_02(raw_t *raw, unsigned char *buff, int len)
{
    geph_t geph={0};
    unsigned char *p=buff;
    double tod,tof,tau_gps;
    int prn,day,leap;
    
    trace(4,"binex 0x01-02: len=%d\n",len);
    
    if (len>=119) {
        prn        =U1(p)+1;   p+=1;
        day        =U2(p);     p+=2;
        tod        =U4(p);     p+=4;
        geph.taun  =-R8(p);    p+=8;
        geph.gamn  =R8(p);     p+=8;
        tof        =U4(p);     p+=4;
        geph.pos[0]=R8(p)*1E3; p+=8;
        geph.vel[0]=R8(p)*1E3; p+=8;
        geph.acc[0]=R8(p)*1E3; p+=8;
        geph.pos[1]=R8(p)*1E3; p+=8;
        geph.vel[1]=R8(p)*1E3; p+=8;
        geph.acc[1]=R8(p)*1E3; p+=8;
        geph.pos[2]=R8(p)*1E3; p+=8;
        geph.vel[2]=R8(p)*1E3; p+=8;
        geph.acc[2]=R8(p)*1E3; p+=8;
        geph.svh   =U1(p)&0x1; p+=1;
        geph.frq   =I1(p);     p+=1;
        geph.age   =U1(p);     p+=1;
        leap       =U1(p);     p+=1;
        tau_gps    =R8(p);     p+=8;
        geph.dtaun =R8(p);
    }
    else {
        trace(2,"binex 0x01-02: length error len=%d\n",len);
        return -1;
    }
    if (!(geph.sat=satno(SYS_GLO,prn))) {
        trace(2,"binex 0x01-02: satellite error prn=%d\n",prn);
        return -1;
    }
    if (raw->time.time==0) return 0;
    geph.toe=utc2gpst(adjday(raw->time,tod-10800.0));
    geph.tof=utc2gpst(adjday(raw->time,tof-10800.0));
    geph.iode=(int)(fmod(tod,86400.0)/900.0+0.5);
    
    if (!strstr(raw->opt,"-EPHALL")) {
        if (fabs(timediff(geph.toe,raw->nav.geph[prn-MINPRNGLO].toe))<1.0&&
            geph.svh==raw->nav.geph[prn-MINPRNGLO].svh) return 0; /* unchanged */
    }
    raw->nav.geph[prn-1]=geph;
    raw->ephsat=geph.sat;
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq -0xb8(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x93d0
movq -0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x1c(%rbp), %edx
movl $0x4, %edi
leaq 0x61b14(%rip), %rsi     # 0xbe867
movb $0x0, %al
callq 0x8b980
cmpl $0x77, -0x1c(%rbp)
jl 0x5d0c4
movq -0xc0(%rbp), %rax
movzbl (%rax), %eax
incl %eax
movl %eax, -0xdc(%rbp)
movq -0xc0(%rbp), %rax
incq %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5b2b0
movzwl %ax, %eax
movl %eax, -0xe0(%rbp)
movq -0xc0(%rbp), %rax
addq $0x2, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5be80
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0xc8(%rbp)
movq -0xc0(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movaps 0x5e922(%rip), %xmm1    # 0xbb710
pxor %xmm1, %xmm0
movlpd %xmm0, -0x38(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd %xmm0, -0x30(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5be80
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0xd0(%rbp)
movq -0xc0(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd 0x605bb(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd 0x6058c(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd 0x6055d(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd 0x6052e(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd 0x604ff(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd 0x604d0(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd 0x604a1(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd 0x60472(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd 0x60443(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movzbl (%rax), %eax
andl $0x1, %eax
movl %eax, -0xac(%rbp)
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0xb0(%rbp)
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0xa4(%rbp)
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0xe4(%rbp)
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd %xmm0, -0xd8(%rbp)
movq -0xc0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x5f8e0
movsd %xmm0, -0x28(%rbp)
jmp 0x5d0e6
movl -0x1c(%rbp), %edx
movl $0x2, %edi
leaq 0x617ab(%rip), %rsi     # 0xbe87e
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5d3c3
movl -0xdc(%rbp), %esi
movl $0x4, %edi
callq 0x8b1b0
movl %eax, -0xb8(%rbp)
cmpl $0x0, %eax
jne 0x5d126
movl -0xdc(%rbp), %edx
movl $0x2, %edi
leaq 0x6178f(%rip), %rsi     # 0xbe8a2
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5d3c3
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x5d13c
movl $0x0, -0x4(%rbp)
jmp 0x5d3c3
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x118(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x110(%rbp)
movsd -0xc8(%rbp), %xmm1
movsd 0x5fe8b(%rip), %xmm0    # 0xbcff0
subsd %xmm0, %xmm1
movq -0x118(%rbp), %rdi
movsd -0x110(%rbp), %xmm0
callq 0x5fa60
movq %rax, -0x108(%rbp)
movsd %xmm0, -0x100(%rbp)
movq -0x108(%rbp), %rdi
movsd -0x100(%rbp), %xmm0
callq 0x8f0a0
movq %rax, -0xf8(%rbp)
movsd %xmm0, -0xf0(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x148(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x140(%rbp)
movsd -0xd0(%rbp), %xmm1
movsd 0x5fdfc(%rip), %xmm0    # 0xbcff0
subsd %xmm0, %xmm1
movq -0x148(%rbp), %rdi
movsd -0x140(%rbp), %xmm0
callq 0x5fa60
movq %rax, -0x138(%rbp)
movsd %xmm0, -0x130(%rbp)
movq -0x138(%rbp), %rdi
movsd -0x130(%rbp), %xmm0
callq 0x8f0a0
movq %rax, -0x128(%rbp)
movsd %xmm0, -0x120(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x120(%rbp), %rax
movq %rax, -0x88(%rbp)
movsd -0xc8(%rbp), %xmm0
movsd 0x5fbb6(%rip), %xmm1    # 0xbce20
callq 0x99f0
movsd 0x5fd71(%rip), %xmm1    # 0xbcfe8
divsd %xmm1, %xmm0
movsd 0x5fbfd(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xb4(%rbp)
movq -0x10(%rbp), %rdi
addq $0x82a90, %rdi          # imm = 0x82A90
leaq 0x615bc(%rip), %rsi     # 0xbe85f
callq 0x91b0
cmpq $0x0, %rax
jne 0x5d37b
movq -0xa0(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x10(%rbp), %rax
movq 0x1d88(%rax), %rax
movl -0xdc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rcx
movq %rcx, -0x168(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x160(%rbp)
movq -0x158(%rbp), %rdi
movsd -0x150(%rbp), %xmm0
movq -0x168(%rbp), %rsi
movsd -0x160(%rbp), %xmm1
callq 0x8e8e0
movaps %xmm0, %xmm1
movaps 0x5feee(%rip), %xmm0    # 0xbd220
pand %xmm0, %xmm1
movsd 0x5eb22(%rip), %xmm0    # 0xbbe60
ucomisd %xmm1, %xmm0
jbe 0x5d379
movl -0xac(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x1d88(%rcx), %rcx
movl -0xdc(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x98, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jne 0x5d379
movl $0x0, -0x4(%rbp)
jmp 0x5d3c3
jmp 0x5d37b
movq -0x10(%rbp), %rax
movq 0x1d88(%rax), %rdi
movl -0xdc(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x98, %rax, %rax
addq %rax, %rdi
leaq -0xb8(%rbp), %rsi
movl $0x98, %edx
callq 0x9610
movl -0xb8(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x70e40(%rax)
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nop