// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rcvraw.cpp
// Function: bamboo::decode_bds_d1(unsigned char const*, bamboo::eph_t*)
extern int decode_bds_d1(const unsigned char *buff, eph_t *eph)
{
    double toc_bds,sqrtA;
    unsigned int toe1,toe2,sow1,sow2,sow3;
    int i,frn1,frn2,frn3;
    
    trace(3,"decode_bds_d1:\n");
    
    i=8*38*0; /* subframe 1 */
    frn1       =getbitu (buff,i+ 15, 3);
    sow1       =getbitu2(buff,i+ 18, 8,i+30,12);
    eph->svh   =getbitu (buff,i+ 42, 1); /* SatH1 */
    eph->iodc  =getbitu (buff,i+ 43, 5); /* AODC */
    eph->sva   =getbitu (buff,i+ 48, 4);
    eph->week  =getbitu (buff,i+ 60,13); /* week in BDT */
    toc_bds    =getbitu2(buff,i+ 73, 9,i+ 90, 8)*8.0;
    eph->tgd[0]=getbits (buff,i+ 98,10)*0.1*1E-9;
    eph->tgd[1]=getbits2(buff,i+108, 4,i+120, 6)*0.1*1E-9;
    eph->f2    =getbits (buff,i+214,11)*P2_66;
    eph->f0    =getbits2(buff,i+225, 7,i+240,17)*P2_33;
    eph->f1    =getbits2(buff,i+257, 5,i+270,17)*P2_50;
    eph->iode  =getbitu (buff,i+287, 5); /* AODE */
    
    i=8*38*1; /* subframe 2 */
    frn2       =getbitu (buff,i+ 15, 3);
    sow2       =getbitu2(buff,i+ 18, 8,i+30,12);
    eph->deln  =getbits2(buff,i+ 42,10,i+ 60, 6)*P2_43*SC2RAD;
    eph->cuc   =getbits2(buff,i+ 66,16,i+ 90, 2)*P2_31;
    eph->M0    =getbits2(buff,i+ 92,20,i+120,12)*P2_31*SC2RAD;
    eph->e     =getbitu2(buff,i+132,10,i+150,22)*P2_33;
    eph->cus   =getbits (buff,i+180,18)*P2_31;
    eph->crc   =getbits2(buff,i+198, 4,i+210,14)*P2_6;
    eph->crs   =getbits2(buff,i+224, 8,i+240,10)*P2_6;
    sqrtA      =getbitu2(buff,i+250,12,i+270,20)*P2_19;
    toe1       =getbitu (buff,i+290, 2); /* TOE 2-MSB */
    eph->A     =sqrtA*sqrtA;
    
    i=8*38*2; /* subframe 3 */
    frn3       =getbitu (buff,i+ 15, 3);
    sow3       =getbitu2(buff,i+ 18, 8,i+30,12);
    toe2       =getbitu2(buff,i+ 42,10,i+ 60, 5); /* TOE 5-LSB */
    eph->i0    =getbits2(buff,i+ 65,17,i+ 90,15)*P2_31*SC2RAD;
    eph->cic   =getbits2(buff,i+105, 7,i+120,11)*P2_31;
    eph->OMGd  =getbits2(buff,i+131,11,i+150,13)*P2_43*SC2RAD;
    eph->cis   =getbits2(buff,i+163, 9,i+180, 9)*P2_31;
    eph->idot  =getbits2(buff,i+189,13,i+210, 1)*P2_43*SC2RAD;
    eph->OMG0  =getbits2(buff,i+211,21,i+240,11)*P2_31*SC2RAD;
    eph->omg   =getbits2(buff,i+251,11,i+270,21)*P2_31*SC2RAD;
    eph->toes  =merge_two_u(toe1,toe2,15)*8.0;
    
    /* check consistency of subframe numbers, sows and toe/toc */
    if (frn1!=1||frn2!=2||frn3!=3) {
        trace(3,"decode_bds_d1 error: frn=%d %d %d\n",frn1,frn2,frn3);
        return 0;
    }
    if (sow2!=sow1+6||sow3!=sow2+6) {
        trace(3,"decode_bds_d1 error: sow=%d %d %d\n",sow1,sow2,sow3);
        return 0;
    }
    if (toc_bds!=eph->toes) {
        trace(3,"decode_bds_d1 error: toe=%.0f toc=%.0f\n",eph->toes,toc_bds);
        return 0;
    }
    eph->ttr=bdt2gpst(bdt2time(eph->week,sow1));      /* bdt -> gpst */
    if      (eph->toes>sow1+302400.0) eph->week++;
    else if (eph->toes<sow1-302400.0) eph->week--;
    eph->toe=bdt2gpst(bdt2time(eph->week,eph->toes)); /* bdt -> gpst */
    eph->toc=bdt2gpst(bdt2time(eph->week,toc_bds));   /* bdt -> gpst */
    eph->code=0; /* data source = unknown */
    eph->flag=1; /* nav type = IGSO/MEO */
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r13
leaq 0x38ee5(%rip), %rsi     # 0x6d02c
movl $0x3, %edi
xorl %eax, %eax
callq 0x4ded0
movq %r13, %rdi
movl $0xf, %esi
movl $0x3, %edx
callq 0x4e341
movl %eax, -0x40(%rbp)
movq %r13, %rdi
movl $0x12, %esi
movl $0x8, %edx
callq 0x4e341
movq %rax, -0x70(%rbp)
movq %r13, %rdi
movl $0x1e, %esi
movl $0xc, %edx
callq 0x4e341
movl %eax, -0x50(%rbp)
movq %r13, %rdi
movl $0x2a, %esi
movl $0x1, %edx
callq 0x4e341
movl %eax, 0x10(%rbx)
movq %r13, %rdi
movl $0x2b, %esi
movl $0x5, %edx
callq 0x4e341
movl %eax, 0x8(%rbx)
movq %r13, %rdi
movl $0x30, %esi
movl $0x4, %edx
callq 0x4e341
movl %eax, 0xc(%rbx)
movq %r13, %rdi
movl $0x3c, %esi
movl $0xd, %edx
callq 0x4e341
movl %eax, 0x14(%rbx)
movq %r13, %rdi
movl $0x49, %esi
movl $0x9, %edx
callq 0x4e341
movq %rax, -0x60(%rbp)
movq %r13, %rdi
movl $0x5a, %esi
movl $0x8, %edx
callq 0x4e341
movl %eax, -0x44(%rbp)
movq %r13, %rdi
movl $0x62, %esi
movl $0xa, %edx
callq 0x4e390
cvtsi2sd %eax, %xmm0
mulsd 0x37b58(%rip), %xmm0    # 0x6bd88
mulsd 0x38ad0(%rip), %xmm0    # 0x6cd08
movsd %xmm0, 0xf0(%rbx)
movq %r13, %rdi
movl $0x6c, %esi
movl $0x4, %edx
movl $0x78, %ecx
movl $0x6, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x37b1c(%rip), %xmm0    # 0x6bd88
mulsd 0x38a94(%rip), %xmm0    # 0x6cd08
movsd %xmm0, 0xf8(%rbx)
movq %r13, %rdi
movl $0xd6, %esi
movl $0xb, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38a73(%rip), %xmm0    # 0x6cd10
movsd %xmm0, 0xe8(%rbx)
movq %r13, %rdi
movl $0xe1, %esi
movl $0x7, %edx
movl $0xf0, %ecx
movl $0x11, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x389ef(%rip), %xmm0    # 0x6ccc0
movsd %xmm0, 0xd8(%rbx)
movq %r13, %rdi
movl $0x101, %esi            # imm = 0x101
movl $0x5, %edx
movl $0x10e, %ecx            # imm = 0x10E
movl $0x11, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38a13(%rip), %xmm0    # 0x6cd18
movsd %xmm0, 0xe0(%rbx)
movq %r13, %rdi
movl $0x11f, %esi            # imm = 0x11F
movl $0x5, %edx
callq 0x4e341
movl %eax, 0x4(%rbx)
movq %r13, %rdi
movl $0x13f, %esi            # imm = 0x13F
movl $0x3, %edx
callq 0x4e341
movl %eax, -0x38(%rbp)
movq %r13, %rdi
movl $0x142, %esi            # imm = 0x142
movl $0x8, %edx
callq 0x4e341
movq %rax, -0x68(%rbp)
movq %r13, %rdi
movl $0x14e, %esi            # imm = 0x14E
movl $0xc, %edx
callq 0x4e341
movl %eax, -0x4c(%rbp)
movq %r13, %rdi
movl $0x15a, %esi            # imm = 0x15A
movl $0xa, %edx
movl $0x16c, %ecx            # imm = 0x16C
movl $0x6, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38942(%rip), %xmm0    # 0x6ccd0
mulsd 0x37a12(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x80(%rbx)
movq %r13, %rdi
movl $0x172, %esi            # imm = 0x172
movl $0x10, %edx
movl $0x18a, %ecx            # imm = 0x18A
movl $0x2, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x388ee(%rip), %xmm0    # 0x6ccb8
movsd %xmm0, 0xa8(%rbx)
movq %r13, %rdi
movl $0x18c, %esi            # imm = 0x18C
movl $0x14, %edx
movl $0x1a8, %ecx            # imm = 0x1A8
movl $0xc, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x388ba(%rip), %xmm0    # 0x6ccb8
mulsd 0x379a2(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x78(%rbx)
movq %r13, %rdi
movl $0x1b4, %esi            # imm = 0x1B4
movl $0xa, %edx
callq 0x4e341
movl %eax, %r14d
shll $0x16, %r14d
movq %r13, %rdi
movl $0x1c6, %esi            # imm = 0x1C6
movl $0x16, %edx
callq 0x4e341
addl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x38877(%rip), %xmm0    # 0x6ccc0
movsd %xmm0, 0x58(%rbx)
movq %r13, %rdi
movl $0x1e4, %esi            # imm = 0x1E4
movl $0x12, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38849(%rip), %xmm0    # 0x6ccb8
movsd %xmm0, 0xb0(%rbx)
movq %r13, %rdi
movl $0x1f6, %esi            # imm = 0x1F6
movl $0x4, %edx
movl $0x202, %ecx            # imm = 0x202
movl $0xe, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x3887d(%rip), %xmm0    # 0x6cd20
movsd %xmm0, 0x98(%rbx)
movq %r13, %rdi
movl $0x210, %esi            # imm = 0x210
movl $0x8, %edx
movl $0x220, %ecx            # imm = 0x220
movl $0xa, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38849(%rip), %xmm0    # 0x6cd20
movsd %xmm0, 0xa0(%rbx)
movq %r13, %rdi
movl $0x22a, %esi            # imm = 0x22A
movl $0xc, %edx
callq 0x4e341
movl %eax, %r14d
shll $0x14, %r14d
movq %r13, %rdi
movl $0x23e, %esi            # imm = 0x23E
movl $0x14, %edx
callq 0x4e341
addl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x387ab(%rip), %xmm0    # 0x6ccc8
movsd %xmm0, -0x30(%rbp)
movq %r13, %rdi
movl $0x252, %esi            # imm = 0x252
movl $0x2, %edx
callq 0x4e341
movl %eax, %r14d
movsd -0x30(%rbp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x50(%rbx)
movq %r13, %rdi
movl $0x26f, %esi            # imm = 0x26F
movl $0x3, %edx
callq 0x4e341
movl %eax, -0x30(%rbp)
movq %r13, %rdi
movl $0x272, %esi            # imm = 0x272
movl $0x8, %edx
callq 0x4e341
movl %eax, %r12d
movq %r13, %rdi
movl $0x27e, %esi            # imm = 0x27E
movl $0xc, %edx
callq 0x4e341
movl %eax, -0x48(%rbp)
movq %r13, %rdi
movl $0x28a, %esi            # imm = 0x28A
movl $0xa, %edx
callq 0x4e341
movl %eax, %r15d
shll $0x5, %r15d
movq %r13, %rdi
movl $0x29c, %esi            # imm = 0x29C
movl $0x5, %edx
callq 0x4e341
movl %eax, -0x54(%rbp)
movq %r13, %rdi
movl $0x2a1, %esi            # imm = 0x2A1
movl $0x11, %edx
movl $0x2ba, %ecx            # imm = 0x2BA
movl $0xf, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x386da(%rip), %xmm0    # 0x6ccb8
mulsd 0x377c2(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x60(%rbx)
movq %r13, %rdi
movl $0x2c9, %esi            # imm = 0x2C9
movl $0x7, %edx
movl $0x2d8, %ecx            # imm = 0x2D8
movl $0xb, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x386a1(%rip), %xmm0    # 0x6ccb8
movsd %xmm0, 0xb8(%rbx)
movq %r13, %rdi
movl $0x2e3, %esi            # imm = 0x2E3
movl $0xb, %edx
movl $0x2f6, %ecx            # imm = 0x2F6
movl $0xd, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38685(%rip), %xmm0    # 0x6ccd0
mulsd 0x37755(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x88(%rbx)
movq %r13, %rdi
movl $0x303, %esi            # imm = 0x303
movl $0x9, %edx
movl $0x314, %ecx            # imm = 0x314
movl $0x9, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38631(%rip), %xmm0    # 0x6ccb8
movsd %xmm0, 0xc0(%rbx)
movq %r13, %rdi
movl $0x31d, %esi            # imm = 0x31D
movl $0xd, %edx
movl $0x332, %ecx            # imm = 0x332
movl $0x1, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38615(%rip), %xmm0    # 0x6ccd0
mulsd 0x376e5(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x90(%rbx)
movq %r13, %rdi
movl $0x333, %esi            # imm = 0x333
movl $0x15, %edx
movl $0x350, %ecx            # imm = 0x350
movl $0xb, %r8d
callq 0x348d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x385c1(%rip), %xmm0    # 0x6ccb8
mulsd 0x376a9(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x68(%rbx)
movq %r13, %rdi
movl $0x35b, %esi            # imm = 0x35B
movl $0xb, %edx
movl $0x36e, %ecx            # imm = 0x36E
movl $0x15, %r8d
callq 0x348d8
movl -0x30(%rbp), %r8d
movl -0x38(%rbp), %ecx
movsd 0x36310(%rip), %xmm2    # 0x6aa40
movl -0x40(%rbp), %edx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38576(%rip), %xmm0    # 0x6ccb8
mulsd 0x3765e(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x70(%rbx)
shll $0xf, %r14d
addl -0x54(%rbp), %r14d
addl %r15d, %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0xc8(%rbx)
movl %edx, %eax
xorl $0x1, %eax
movl %ecx, %esi
xorl $0x2, %esi
orl %eax, %esi
movl %r8d, %eax
xorl $0x3, %eax
orl %esi, %eax
je 0x34799
leaq 0x388b1(%rip), %rsi     # 0x6d03c
movl $0x3, %edi
xorl %eax, %eax
callq 0x4ded0
jmp 0x347f2
movq -0x70(%rbp), %rdx
shll $0xc, %edx
addl -0x50(%rbp), %edx
movq -0x68(%rbp), %rcx
shll $0xc, %ecx
addl -0x4c(%rbp), %ecx
shll $0xc, %r12d
addl -0x48(%rbp), %r12d
leal 0x6(%rdx), %eax
xorl %ecx, %eax
leal 0x6(%rcx), %esi
xorl %r12d, %esi
orl %eax, %esi
jne 0x347f9
movq -0x60(%rbp), %rax
shll $0x8, %eax
addl -0x44(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jne 0x347df
jnp 0x34816
leaq 0x3889c(%rip), %rsi     # 0x6d082
movl $0x3, %edi
movb $0x2, %al
callq 0x4ded0
xorl %ebx, %ebx
jmp 0x348c7
leaq 0x3885f(%rip), %rsi     # 0x6d05f
xorl %ebx, %ebx
movl $0x3, %edi
movl %r12d, %r8d
xorl %eax, %eax
callq 0x4ded0
jmp 0x348c7
movsd %xmm1, -0x40(%rbp)
movl 0x14(%rbx), %edi
movl %edx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x38(%rbp)
callq 0x4fd84
movq %rax, %rdi
callq 0x504ed
movsd -0x38(%rbp), %xmm2
movq %rax, 0x40(%rbx)
movsd %xmm0, 0x48(%rbx)
movsd 0xc8(%rbx), %xmm0
movsd 0x37580(%rip), %xmm1    # 0x6bdd8
addsd %xmm2, %xmm1
movl $0x1, %eax
ucomisd %xmm1, %xmm0
ja 0x3487a
addsd 0x37561(%rip), %xmm2    # 0x6bdd0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
ucomisd %xmm0, %xmm2
jbe 0x3487d
addl %eax, 0x14(%rbx)
movl 0x14(%rbx), %edi
callq 0x4fd84
movq %rax, %rdi
callq 0x504ed
movq %rax, 0x20(%rbx)
movsd %xmm0, 0x28(%rbx)
movl 0x14(%rbx), %edi
movsd -0x40(%rbp), %xmm0
callq 0x4fd84
movq %rax, %rdi
callq 0x504ed
movq %rax, 0x30(%rbx)
movsd %xmm0, 0x38(%rbx)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x18(%rbx)
movl $0x1, %ebx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq