// File: DoubleString[P]RtConverter/src/Rtklib/binex.cpp
// Function: bamboo::decode_bnx_01_05(bamboo::raw_t*, unsigned char*, int)
static int decode_bnx_01_05(raw_t *raw, unsigned char *buff, int len)
{
    eph_t eph={0};
    unsigned char *p=buff;
    double tow,toc,sqrtA;
    int prn,flag1,flag2;
    
    trace(4,"binex 0x01-05: len=%d\n",len);
    
    if (len>=117) {
        prn       =U1(p);        p+=1;
        eph.week  =U2(p);        p+=2;
        tow       =I4(p);        p+=4;
        toc       =I4(p);        p+=4;
        eph.toes  =I4(p);        p+=4;
        eph.f2    =R4(p);        p+=4;
        eph.f1    =R4(p);        p+=4;
        eph.f0    =R4(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;
        flag1     =U2(p);        p+=2;
        flag2     =U4(p);
    }
    else {
        trace(2,"binex 0x01-05: length error len=%d\n",len);
        return -1;
    }
    if (!(eph.sat=satno(SYS_CMP,prn))) {
        trace(2,"binex 0x01-05: satellite error prn=%d\n",prn);
        return 0;
    }
    eph.A=sqrtA*sqrtA;
    eph.toe=gpst2time(eph.week+1356,eph.toes+14.0); /* bdt -> gpst */
    eph.toc=gpst2time(eph.week+1356,eph.toes+14.0); /* bdt -> gpst */
    eph.ttr=adjweek(eph.toe,tow+14.0); /* bdt -> gpst */
    eph.iodc=(flag1>>1)&0x1F;
    eph.iode=(flag1>>6)&0x1F;
    eph.svh=flag1&0x01;
    eph.sva=flag2&0x0F; /* ura index */
    eph.tgd[0]=bds_tgd(flag2>> 4); /* TGD1 (s) */
    eph.tgd[1]=bds_tgd(flag2>>14); /* TGD2 (s) */
    eph.flag=(flag1>>11)&0x07; /* nav type (0:unknown,1:IGSO/MEO,2:GEO) */
    eph.code=(flag2>>25)&0x7F;
        /* message source (0:unknown,1:B1I,2:B1Q,3:B2I,4:B2Q,5:B3I,6:B3Q)*/
    
    if (!strstr(raw->opt,"-EPHALL")) {
        if (timediff(raw->nav.eph[eph.sat-1].toe,eph.toe)==0.0&&
            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 $0x1d0, %rsp            # imm = 0x1D0
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 0x6081c(%rip), %rsi     # 0xbe99f
movb $0x0, %al
callq 0x8b980
cmpl $0x75, -0x1c(%rbp)
jl 0x5e587
movq -0x148(%rbp), %rax
movzbl (%rax), %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, -0x158(%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, -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 0x5f880
cvtss2sd %xmm0, %xmm0
movsd 0x5fa73(%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 0x5f860(%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 0x5f82a(%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 0x5b2b0
movzwl %ax, %eax
movl %eax, -0x168(%rbp)
movq -0x148(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5be80
movl %eax, -0x16c(%rbp)
jmp 0x5e5a9
movl -0x1c(%rbp), %edx
movl $0x2, %edi
leaq 0x60420(%rip), %rsi     # 0xbe9b6
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5e8d6
movl -0x164(%rbp), %esi
movl $0x20, %edi
callq 0x8b1b0
movl %eax, -0x140(%rbp)
cmpl $0x0, %eax
jne 0x5e5e9
movl -0x164(%rbp), %edx
movl $0x2, %edi
leaq 0x60404(%rip), %rsi     # 0xbe9da
movb $0x0, %al
callq 0x8b980
movl $0x0, -0x4(%rbp)
jmp 0x5e8d6
movsd -0x160(%rbp), %xmm0
mulsd -0x160(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
movl -0x12c(%rbp), %edi
addl $0x54c, %edi            # imm = 0x54C
movsd 0x5e8d3(%rip), %xmm0    # 0xbcee8
addsd -0x78(%rbp), %xmm0
callq 0x8e4a0
movq %rax, -0x180(%rbp)
movsd %xmm0, -0x178(%rbp)
movq -0x180(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x178(%rbp), %rax
movq %rax, -0x118(%rbp)
movl -0x12c(%rbp), %edi
addl $0x54c, %edi            # imm = 0x54C
movsd 0x5e88a(%rip), %xmm0    # 0xbcee8
addsd -0x78(%rbp), %xmm0
callq 0x8e4a0
movq %rax, -0x190(%rbp)
movsd %xmm0, -0x188(%rbp)
movq -0x190(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x120(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movsd 0x5e831(%rip), %xmm1    # 0xbcee8
addsd -0x150(%rbp), %xmm1
movq -0x1b0(%rbp), %rdi
movsd -0x1a8(%rbp), %xmm0
callq 0x5f940
movq %rax, -0x1a0(%rbp)
movsd %xmm0, -0x198(%rbp)
movq -0x1a0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl -0x168(%rbp), %eax
sarl %eax
andl $0x1f, %eax
movl %eax, -0x138(%rbp)
movl -0x168(%rbp), %eax
sarl $0x6, %eax
andl $0x1f, %eax
movl %eax, -0x13c(%rbp)
movl -0x168(%rbp), %eax
andl $0x1, %eax
movl %eax, -0x130(%rbp)
movl -0x16c(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x134(%rbp)
movl -0x16c(%rbp), %edi
sarl $0x4, %edi
callq 0x5fc80
movsd %xmm0, -0x50(%rbp)
movl -0x16c(%rbp), %edi
sarl $0xe, %edi
callq 0x5fc80
movsd %xmm0, -0x48(%rbp)
movl -0x168(%rbp), %eax
sarl $0xb, %eax
andl $0x7, %eax
movl %eax, -0x124(%rbp)
movl -0x16c(%rbp), %eax
sarl $0x19, %eax
andl $0x7f, %eax
movl %eax, -0x128(%rbp)
movq -0x10(%rbp), %rdi
addq $0x82a90, %rdi          # imm = 0x82A90
leaq 0x600c4(%rip), %rsi     # 0xbe85f
callq 0x91b0
cmpq $0x0, %rax
jne 0x5e88e
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
movq 0x20(%rax), %rcx
movq %rcx, -0x1c0(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0x1b8(%rbp)
movq -0x120(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x1c0(%rbp), %rdi
movsd -0x1b8(%rbp), %xmm0
movq -0x1d0(%rbp), %rsi
movsd -0x1c8(%rbp), %xmm1
callq 0x8e8e0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5e88c
jp 0x5e88c
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 0x5e88c
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 0x5e88c
movl $0x0, -0x4(%rbp)
jmp 0x5e8d6
jmp 0x5e88e
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 $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
nopw %cs:(%rax,%rax)