// File: /workspace/github_cpp_makefile_star2_O3/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 0x3951d(%rip), %rsi     # 0x6d02c
movl $0x3, %edi
xorl %eax, %eax
callq 0x4d55d
movq %r13, %rdi
movl $0xf, %esi
movl $0x3, %edx
callq 0x4d9d6
movl %eax, -0x40(%rbp)
movq %r13, %rdi
movl $0x12, %esi
movl $0x8, %edx
callq 0x4d9d6
movq %rax, -0x70(%rbp)
movq %r13, %rdi
movl $0x1e, %esi
movl $0xc, %edx
callq 0x4d9d6
movl %eax, -0x50(%rbp)
movq %r13, %rdi
movl $0x2a, %esi
movl $0x1, %edx
callq 0x4d9d6
movl %eax, 0x10(%rbx)
movq %r13, %rdi
movl $0x2b, %esi
movl $0x5, %edx
callq 0x4d9d6
movl %eax, 0x8(%rbx)
movq %r13, %rdi
movl $0x30, %esi
movl $0x4, %edx
callq 0x4d9d6
movl %eax, 0xc(%rbx)
movq %r13, %rdi
movl $0x3c, %esi
movl $0xd, %edx
callq 0x4d9d6
movl %eax, 0x14(%rbx)
movq %r13, %rdi
movl $0x49, %esi
movl $0x9, %edx
callq 0x4d9d6
movq %rax, -0x60(%rbp)
movq %r13, %rdi
movl $0x5a, %esi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, -0x44(%rbp)
movq %r13, %rdi
movl $0x62, %esi
movl $0xa, %edx
callq 0x4da25
cvtsi2sd %eax, %xmm0
mulsd 0x38190(%rip), %xmm0    # 0x6bd88
mulsd 0x39108(%rip), %xmm0    # 0x6cd08
movsd %xmm0, 0xf0(%rbx)
movq %r13, %rdi
movl $0x6c, %esi
movl $0x4, %edx
movl $0x78, %ecx
movl $0x6, %r8d
callq 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38154(%rip), %xmm0    # 0x6bd88
mulsd 0x390cc(%rip), %xmm0    # 0x6cd08
movsd %xmm0, 0xf8(%rbx)
movq %r13, %rdi
movl $0xd6, %esi
movl $0xb, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x390ab(%rip), %xmm0    # 0x6cd10
movsd %xmm0, 0xe8(%rbx)
movq %r13, %rdi
movl $0xe1, %esi
movl $0x7, %edx
movl $0xf0, %ecx
movl $0x11, %r8d
callq 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x39027(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x3904b(%rip), %xmm0    # 0x6cd18
movsd %xmm0, 0xe0(%rbx)
movq %r13, %rdi
movl $0x11f, %esi            # imm = 0x11F
movl $0x5, %edx
callq 0x4d9d6
movl %eax, 0x4(%rbx)
movq %r13, %rdi
movl $0x13f, %esi            # imm = 0x13F
movl $0x3, %edx
callq 0x4d9d6
movl %eax, -0x38(%rbp)
movq %r13, %rdi
movl $0x142, %esi            # imm = 0x142
movl $0x8, %edx
callq 0x4d9d6
movq %rax, -0x68(%rbp)
movq %r13, %rdi
movl $0x14e, %esi            # imm = 0x14E
movl $0xc, %edx
callq 0x4d9d6
movl %eax, -0x4c(%rbp)
movq %r13, %rdi
movl $0x15a, %esi            # imm = 0x15A
movl $0xa, %edx
movl $0x16c, %ecx            # imm = 0x16C
movl $0x6, %r8d
callq 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38f7a(%rip), %xmm0    # 0x6ccd0
mulsd 0x3804a(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38f26(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38ef2(%rip), %xmm0    # 0x6ccb8
mulsd 0x37fda(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x78(%rbx)
movq %r13, %rdi
movl $0x1b4, %esi            # imm = 0x1B4
movl $0xa, %edx
callq 0x4d9d6
movl %eax, %r14d
shll $0x16, %r14d
movq %r13, %rdi
movl $0x1c6, %esi            # imm = 0x1C6
movl $0x16, %edx
callq 0x4d9d6
addl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x38eaf(%rip), %xmm0    # 0x6ccc0
movsd %xmm0, 0x58(%rbx)
movq %r13, %rdi
movl $0x1e4, %esi            # imm = 0x1E4
movl $0x12, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38e81(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38eb5(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38e81(%rip), %xmm0    # 0x6cd20
movsd %xmm0, 0xa0(%rbx)
movq %r13, %rdi
movl $0x22a, %esi            # imm = 0x22A
movl $0xc, %edx
callq 0x4d9d6
movl %eax, %r14d
shll $0x14, %r14d
movq %r13, %rdi
movl $0x23e, %esi            # imm = 0x23E
movl $0x14, %edx
callq 0x4d9d6
addl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x38de3(%rip), %xmm0    # 0x6ccc8
movsd %xmm0, -0x30(%rbp)
movq %r13, %rdi
movl $0x252, %esi            # imm = 0x252
movl $0x2, %edx
callq 0x4d9d6
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 0x4d9d6
movl %eax, -0x30(%rbp)
movq %r13, %rdi
movl $0x272, %esi            # imm = 0x272
movl $0x8, %edx
callq 0x4d9d6
movl %eax, %r12d
movq %r13, %rdi
movl $0x27e, %esi            # imm = 0x27E
movl $0xc, %edx
callq 0x4d9d6
movl %eax, -0x48(%rbp)
movq %r13, %rdi
movl $0x28a, %esi            # imm = 0x28A
movl $0xa, %edx
callq 0x4d9d6
movl %eax, %r15d
shll $0x5, %r15d
movq %r13, %rdi
movl $0x29c, %esi            # imm = 0x29C
movl $0x5, %edx
callq 0x4d9d6
movl %eax, -0x54(%rbp)
movq %r13, %rdi
movl $0x2a1, %esi            # imm = 0x2A1
movl $0x11, %edx
movl $0x2ba, %ecx            # imm = 0x2BA
movl $0xf, %r8d
callq 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38d12(%rip), %xmm0    # 0x6ccb8
mulsd 0x37dfa(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38cd9(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38cbd(%rip), %xmm0    # 0x6ccd0
mulsd 0x37d8d(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38c69(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38c4d(%rip), %xmm0    # 0x6ccd0
mulsd 0x37d1d(%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 0x3429f
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38bf9(%rip), %xmm0    # 0x6ccb8
mulsd 0x37ce1(%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 0x3429f
movl -0x30(%rbp), %r8d
movl -0x38(%rbp), %ecx
movsd 0x36948(%rip), %xmm2    # 0x6aa40
movl -0x40(%rbp), %edx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38bae(%rip), %xmm0    # 0x6ccb8
mulsd 0x37c96(%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 0x34161
leaq 0x38ee9(%rip), %rsi     # 0x6d03c
movl $0x3, %edi
xorl %eax, %eax
callq 0x4d55d
jmp 0x341ba
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 0x341c1
movq -0x60(%rbp), %rax
shll $0x8, %eax
addl -0x44(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jne 0x341a7
jnp 0x341de
leaq 0x38ed4(%rip), %rsi     # 0x6d082
movl $0x3, %edi
movb $0x2, %al
callq 0x4d55d
xorl %ebx, %ebx
jmp 0x3428e
leaq 0x38e97(%rip), %rsi     # 0x6d05f
xorl %ebx, %ebx
movl $0x3, %edi
movl %r12d, %r8d
xorl %eax, %eax
callq 0x4d55d
jmp 0x3428e
movsd %xmm1, -0x40(%rbp)
movl 0x14(%rbx), %edi
movl %edx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x38(%rbp)
callq 0x4f408
movq %rax, %rdi
callq 0x4fb4f
movsd -0x38(%rbp), %xmm2
movq %rax, 0x40(%rbx)
movsd %xmm0, 0x48(%rbx)
movsd 0xc8(%rbx), %xmm0
movsd 0x37bb8(%rip), %xmm1    # 0x6bdd8
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x34231
movl 0x14(%rbx), %edi
incl %edi
jmp 0x34244
addsd 0x37b97(%rip), %xmm2    # 0x6bdd0
ucomisd %xmm0, %xmm2
movl 0x14(%rbx), %edi
jbe 0x34247
decl %edi
movl %edi, 0x14(%rbx)
callq 0x4f408
movq %rax, %rdi
callq 0x4fb4f
movq %rax, 0x20(%rbx)
movsd %xmm0, 0x28(%rbx)
movl 0x14(%rbx), %edi
movsd -0x40(%rbp), %xmm0
callq 0x4f408
movq %rax, %rdi
callq 0x4fb4f
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