// File: DoubleString[P]RtConverter/src/Rtklib/binex.cpp
// Function: bamboo::decode_bnx_01_01(bamboo::raw_t*, unsigned char*, int)
static int decode_bnx_01_01(raw_t *raw, unsigned char *buff, int len)
{
    eph_t eph={0};
    unsigned char *p=buff;
    double tow,ura,sqrtA;
    int prn,flag;
    
    trace(4,"binex 0x01-01: len=%d\n",len);
    
    if (len>=127) {
        prn       =U1(p)+1;      p+=1;
        eph.week  =U2(p);        p+=2;
        tow       =I4(p);        p+=4;
        eph.toes  =I4(p);        p+=4;
        eph.tgd[0]=R4(p);        p+=4;
        eph.iodc  =I4(p);        p+=4;
        eph.f2    =R4(p);        p+=4;
        eph.f1    =R4(p);        p+=4;
        eph.f0    =R4(p);        p+=4;
        eph.iode  =I4(p);        p+=4;
        eph.deln  =R4(p)*SC2RAD; p+=4;
        eph.M0    =R8(p);        p+=8;
        eph.e     =R8(p);        p+=8;
        sqrtA     =R8(p);        p+=8;
        eph.cic   =R4(p);        p+=4;
        eph.crc   =R4(p);        p+=4;
        eph.cis   =R4(p);        p+=4;
        eph.crs   =R4(p);        p+=4;
        eph.cuc   =R4(p);        p+=4;
        eph.cus   =R4(p);        p+=4;
        eph.OMG0  =R8(p);        p+=8;
        eph.omg   =R8(p);        p+=8;
        eph.i0    =R8(p);        p+=8;
        eph.OMGd  =R4(p)*SC2RAD; p+=4;
        eph.idot  =R4(p)*SC2RAD; p+=4;
        ura       =R4(p)*0.1;    p+=4;
        eph.svh   =U2(p);        p+=2;
        flag      =U2(p);
    }
    else {
        trace(2,"binex 0x01-01: length error len=%d\n",len);
        return -1;
    }
    if (!(eph.sat=satno(SYS_GPS,prn))) {
        trace(2,"binex 0x01-01: satellite error prn=%d\n",prn);
        return -1;
    }
    eph.A=sqrtA*sqrtA;
    eph.toe=gpst2time(eph.week,eph.toes);
    eph.toc=gpst2time(eph.week,eph.toes);
    eph.ttr=adjweek(eph.toe,tow);
    eph.fit=flag&0xFF;
    eph.flag=(flag>>8)&0x01;
    eph.code=(flag>>9)&0x03;
    eph.sva=uraindex(ura);
    
    if (!strstr(raw->opt,"-EPHALL")) {
        if (raw->nav.eph[eph.sat-1].iode==eph.iode&&
            raw->nav.eph[eph.sat-1].iodc==eph.iodc) return 0; /* unchanged */
    }
    raw->nav.eph[eph.sat-1]=eph;
    raw->ephsat=eph.sat;
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq -0x140(%rbp), %rdi
xorl %esi, %esi
movl $0x120, %edx            # imm = 0x120
callq 0x93d0
movq -0x18(%rbp), %rax
movq %rax, -0x148(%rbp)
movl -0x1c(%rbp), %edx
movl $0x4, %edi
leaq 0x621ea(%rip), %rsi     # 0xbe7fd
movb $0x0, %al
callq 0x8b980
cmpl $0x7f, -0x1c(%rbp)
jl 0x5ca98
movq -0x148(%rbp), %rax
movzbl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x164(%rbp)
movq -0x148(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5b2b0
movzwl %ax, %eax
movl %eax, -0x12c(%rbp)
movq -0x148(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f860
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x150(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f860
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f860
movl %eax, -0x138(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f860
movl %eax, -0x13c(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd 0x6159b(%rip), %xmm1    # 0xbdd58
mulsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f8e0
movsd %xmm0, -0xc8(%rbp)
movq -0x148(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f8e0
movsd %xmm0, -0xe8(%rbp)
movq -0x148(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f8e0
movsd %xmm0, -0x160(%rbp)
movq -0x148(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0xa0(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x98(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f8e0
movsd %xmm0, -0xd8(%rbp)
movq -0x148(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f8e0
movsd %xmm0, -0xd0(%rbp)
movq -0x148(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f8e0
movsd %xmm0, -0xe0(%rbp)
movq -0x148(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd 0x61388(%rip), %xmm1    # 0xbdd58
mulsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd 0x61352(%rip), %xmm1    # 0xbdd58
mulsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5f880
cvtss2sd %xmm0, %xmm0
movsd 0x61314(%rip), %xmm1    # 0xbdd50
mulsd %xmm1, %xmm0
movsd %xmm0, -0x158(%rbp)
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5b2b0
movzwl %ax, %eax
movl %eax, -0x130(%rbp)
movq -0x148(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5b2b0
movzwl %ax, %eax
movl %eax, -0x168(%rbp)
jmp 0x5caba
movl -0x1c(%rbp), %edx
movl $0x2, %edi
leaq 0x61d6d(%rip), %rsi     # 0xbe814
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5ccfe
movl -0x164(%rbp), %esi
movl $0x1, %edi
callq 0x8b1b0
movl %eax, -0x140(%rbp)
cmpl $0x0, %eax
jne 0x5cafa
movl -0x164(%rbp), %edx
movl $0x2, %edi
leaq 0x61d51(%rip), %rsi     # 0xbe838
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5ccfe
movsd -0x160(%rbp), %xmm0
mulsd -0x160(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
movl -0x12c(%rbp), %edi
movsd -0x78(%rbp), %xmm0
callq 0x8e4a0
movq %rax, -0x178(%rbp)
movsd %xmm0, -0x170(%rbp)
movq -0x178(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0x118(%rbp)
movl -0x12c(%rbp), %edi
movsd -0x78(%rbp), %xmm0
callq 0x8e4a0
movq %rax, -0x188(%rbp)
movsd %xmm0, -0x180(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x180(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x120(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movsd -0x150(%rbp), %xmm1
movq -0x1a8(%rbp), %rdi
movsd -0x1a0(%rbp), %xmm0
callq 0x5f940
movq %rax, -0x198(%rbp)
movsd %xmm0, -0x190(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x190(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl -0x168(%rbp), %eax
andl $0xff, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x168(%rbp), %eax
sarl $0x8, %eax
andl $0x1, %eax
movl %eax, -0x124(%rbp)
movl -0x168(%rbp), %eax
sarl $0x9, %eax
andl $0x3, %eax
movl %eax, -0x128(%rbp)
movsd -0x158(%rbp), %xmm0
callq 0x5fa10
movl %eax, -0x134(%rbp)
movq -0x10(%rbp), %rdi
addq $0x82a90, %rdi          # imm = 0x82A90
leaq 0x61c17(%rip), %rsi     # 0xbe85f
callq 0x91b0
cmpq $0x0, %rax
jne 0x5ccb6
movq -0x10(%rbp), %rax
movq 0x1d80(%rax), %rax
movl -0x140(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x120, %rcx, %rcx      # imm = 0x120
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpl -0x13c(%rbp), %eax
jne 0x5ccb4
movq -0x10(%rbp), %rax
movq 0x1d80(%rax), %rax
movl -0x140(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x120, %rcx, %rcx      # imm = 0x120
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x138(%rbp), %eax
jne 0x5ccb4
movl $0x0, -0x4(%rbp)
jmp 0x5ccfe
jmp 0x5ccb6
movq -0x10(%rbp), %rax
movq 0x1d80(%rax), %rdi
movl -0x140(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x120, %rax, %rax      # imm = 0x120
addq %rax, %rdi
leaq -0x140(%rbp), %rsi
movl $0x120, %edx            # imm = 0x120
callq 0x9610
movl -0x140(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x70e40(%rax)
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopw (%rax,%rax)