// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r13
leaq 0x34f3c(%rip), %rsi     # 0x6302c
pushq $0x3
popq %r14
movl %r14d, %edi
xorl %eax, %eax
callq 0x455bc
pushq $0xf
popq %rsi
movq %r13, %rdi
movl %r14d, %edx
callq 0x459f7
movl %eax, -0x40(%rbp)
pushq $0x12
popq %rsi
pushq $0x8
popq %r14
pushq $0x1e
popq %rcx
pushq $0xc
popq %r8
movq %r13, %rdi
movl %r14d, %edx
callq 0x2e762
movq %rax, -0x60(%rbp)
pushq $0x2a
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rdi
callq 0x459f7
movl %eax, 0x10(%rbx)
pushq $0x2b
popq %rsi
pushq $0x5
popq %rdx
movq %r13, %rdi
callq 0x459f7
movl %eax, 0x8(%rbx)
pushq $0x30
popq %rsi
pushq $0x4
popq %r12
movq %r13, %rdi
movl %r12d, %edx
callq 0x459f7
movl %eax, 0xc(%rbx)
pushq $0x3c
popq %rsi
pushq $0xd
popq %rdx
movq %r13, %rdi
callq 0x459f7
movl %eax, 0x14(%rbx)
pushq $0x49
popq %rsi
pushq $0x9
popq %rdx
pushq $0x5a
popq %rcx
movq %r13, %rdi
movl %r14d, %r8d
callq 0x2e762
movl %eax, -0x44(%rbp)
pushq $0x62
popq %rsi
pushq $0xa
popq %rdx
movq %r13, %rdi
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x33be3(%rip), %xmm0    # 0x61d88
mulsd 0x34b5b(%rip), %xmm0    # 0x62d08
movsd %xmm0, 0xf0(%rbx)
pushq $0x6c
popq %rsi
pushq $0x78
popq %rcx
pushq $0x6
popq %r15
movq %r13, %rdi
movl %r12d, %edx
movl %r15d, %r8d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x33baf(%rip), %xmm0    # 0x61d88
mulsd 0x34b27(%rip), %xmm0    # 0x62d08
movsd %xmm0, 0xf8(%rbx)
pushq $0xb
popq %rdx
movq %r13, %rdi
movl $0xd6, %esi
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x34b0b(%rip), %xmm0    # 0x62d10
movsd %xmm0, 0xe8(%rbx)
pushq $0x7
popq %rdx
pushq $0x11
popq %r14
movq %r13, %rdi
movl $0xe1, %esi
movl $0xf0, %ecx
movl %r14d, %r8d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x34a8b(%rip), %xmm0    # 0x62cc0
movsd %xmm0, 0xd8(%rbx)
movq %r13, %rdi
movl $0x101, %esi            # imm = 0x101
pushq $0x5
popq %r12
movl %r12d, %edx
movl $0x10e, %ecx            # imm = 0x10E
movl %r14d, %r8d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x34ab3(%rip), %xmm0    # 0x62d18
movsd %xmm0, 0xe0(%rbx)
movq %r13, %rdi
movl $0x11f, %esi            # imm = 0x11F
movl %r12d, %edx
callq 0x459f7
movl %eax, 0x4(%rbx)
movq %r13, %rdi
movl $0x13f, %esi            # imm = 0x13F
pushq $0x3
popq %rdx
callq 0x459f7
movl %eax, -0x38(%rbp)
movq %r13, %rdi
movl $0x142, %esi            # imm = 0x142
pushq $0x8
popq %rdx
movl $0x14e, %ecx            # imm = 0x14E
pushq $0xc
popq %r12
movl %r12d, %r8d
callq 0x2e762
movq %rax, -0x58(%rbp)
movq %r13, %rdi
movl $0x15a, %esi            # imm = 0x15A
pushq $0xa
popq %r14
movl %r14d, %edx
movl $0x16c, %ecx            # imm = 0x16C
movl %r15d, %r8d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x349f5(%rip), %xmm0    # 0x62cd0
mulsd 0x33ac5(%rip), %xmm0    # 0x61da8
movsd %xmm0, 0x80(%rbx)
pushq $0x10
popq %rdx
pushq $0x2
popq %r8
movq %r13, %rdi
movl $0x172, %esi            # imm = 0x172
movl $0x18a, %ecx            # imm = 0x18A
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x349a8(%rip), %xmm0    # 0x62cb8
movsd %xmm0, 0xa8(%rbx)
pushq $0x14
popq %rdx
movq %r13, %rdi
movl $0x18c, %esi            # imm = 0x18C
movl $0x1a8, %ecx            # imm = 0x1A8
movl %r12d, %r8d
movl %r12d, %r15d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x34979(%rip), %xmm0    # 0x62cb8
mulsd 0x33a61(%rip), %xmm0    # 0x61da8
movsd %xmm0, 0x78(%rbx)
pushq $0x16
popq %r8
movq %r13, %rdi
movl $0x1b4, %esi            # imm = 0x1B4
movl %r14d, %edx
movl $0x1c6, %ecx            # imm = 0x1C6
callq 0x2e762
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x3494c(%rip), %xmm0    # 0x62cc0
movsd %xmm0, 0x58(%rbx)
movq %r13, %rdi
movl $0x1e4, %esi            # imm = 0x1E4
pushq $0x12
popq %rdx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x34923(%rip), %xmm0    # 0x62cb8
movsd %xmm0, 0xb0(%rbx)
pushq $0xe
popq %r8
movq %r13, %rdi
movl $0x1f6, %esi            # imm = 0x1F6
pushq $0x4
popq %rdx
movl $0x202, %ecx            # imm = 0x202
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x3495e(%rip), %xmm0    # 0x62d20
movsd %xmm0, 0x98(%rbx)
movq %r13, %rdi
movl $0x210, %esi            # imm = 0x210
pushq $0x8
popq %r12
movl %r12d, %edx
movl $0x220, %ecx            # imm = 0x220
movl %r14d, %r8d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x3492e(%rip), %xmm0    # 0x62d20
movsd %xmm0, 0xa0(%rbx)
movq %r13, %rdi
movl $0x22a, %esi            # imm = 0x22A
movl %r15d, %edx
movl $0x23e, %ecx            # imm = 0x23E
pushq $0x14
popq %r8
callq 0x2e762
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x348a6(%rip), %xmm0    # 0x62cc8
movsd %xmm0, -0x30(%rbp)
movq %r13, %rdi
movl $0x252, %esi            # imm = 0x252
pushq $0x2
popq %rdx
callq 0x459f7
movl %eax, %r14d
movsd -0x30(%rbp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x50(%rbx)
movq %r13, %rdi
movl $0x26f, %esi            # imm = 0x26F
pushq $0x3
popq %rdx
callq 0x459f7
movl %eax, -0x30(%rbp)
movq %r13, %rdi
movl $0x272, %esi            # imm = 0x272
movl %r12d, %edx
movl $0x27e, %ecx            # imm = 0x27E
movl %r15d, %r8d
callq 0x2e762
movl %eax, -0x48(%rbp)
movq %r13, %rdi
movl $0x28a, %esi            # imm = 0x28A
pushq $0xa
popq %rdx
movl $0x29c, %ecx            # imm = 0x29C
pushq $0x5
popq %r8
callq 0x2e762
movl %eax, -0x4c(%rbp)
movq %r13, %rdi
movl $0x2a1, %esi            # imm = 0x2A1
pushq $0x11
popq %rdx
movl $0x2ba, %ecx            # imm = 0x2BA
pushq $0xf
popq %r8
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x34801(%rip), %xmm0    # 0x62cb8
mulsd 0x338e9(%rip), %xmm0    # 0x61da8
movsd %xmm0, 0x60(%rbx)
movq %r13, %rdi
movl $0x2c9, %esi            # imm = 0x2C9
pushq $0x7
popq %rdx
movl $0x2d8, %ecx            # imm = 0x2D8
pushq $0xb
popq %r12
movl %r12d, %r8d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x347cc(%rip), %xmm0    # 0x62cb8
movsd %xmm0, 0xb8(%rbx)
movq %r13, %rdi
movl $0x2e3, %esi            # imm = 0x2E3
movl %r12d, %edx
movl $0x2f6, %ecx            # imm = 0x2F6
pushq $0xd
popq %r15
movl %r15d, %r8d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x347b4(%rip), %xmm0    # 0x62cd0
mulsd 0x33884(%rip), %xmm0    # 0x61da8
movsd %xmm0, 0x88(%rbx)
movq %r13, %rdi
movl $0x303, %esi            # imm = 0x303
pushq $0x9
popq %rdx
movl $0x314, %ecx            # imm = 0x314
movl %edx, %r8d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x34768(%rip), %xmm0    # 0x62cb8
movsd %xmm0, 0xc0(%rbx)
movq %r13, %rdi
movl $0x31d, %esi            # imm = 0x31D
movl %r15d, %edx
movl $0x332, %ecx            # imm = 0x332
pushq $0x1
popq %r8
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x34753(%rip), %xmm0    # 0x62cd0
mulsd 0x33823(%rip), %xmm0    # 0x61da8
movsd %xmm0, 0x90(%rbx)
pushq $0x15
popq %r15
movq %r13, %rdi
movl $0x333, %esi            # imm = 0x333
movl %r15d, %edx
movl $0x350, %ecx            # imm = 0x350
movl %r12d, %r8d
callq 0x2e79c
cvtsi2sd %eax, %xmm0
mulsd 0x34703(%rip), %xmm0    # 0x62cb8
mulsd 0x337eb(%rip), %xmm0    # 0x61da8
movsd %xmm0, 0x68(%rbx)
movq %r13, %rdi
movl $0x35b, %esi            # imm = 0x35B
movl %r12d, %edx
movl $0x36e, %ecx            # imm = 0x36E
movl %r15d, %r8d
callq 0x2e79c
movl -0x30(%rbp), %r8d
movl -0x38(%rbp), %ecx
movsd 0x32447(%rip), %xmm2    # 0x60a30
movl -0x40(%rbp), %edx
cvtsi2sd %eax, %xmm0
mulsd 0x346c0(%rip), %xmm0    # 0x62cb8
mulsd 0x337a8(%rip), %xmm0    # 0x61da8
movsd %xmm0, 0x70(%rbx)
shll $0xf, %r14d
addl -0x4c(%rbp), %r14d
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 0x2e647
leaq 0x34a01(%rip), %rsi     # 0x6303c
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x455bc
jmp 0x2e687
movq -0x60(%rbp), %rdx
leal 0x6(%rdx), %eax
movq -0x58(%rbp), %rcx
xorl %ecx, %eax
leal 0x6(%rcx), %esi
movl -0x48(%rbp), %r8d
xorl %r8d, %esi
orl %eax, %esi
jne 0x2e68e
movl -0x44(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jne 0x2e676
jnp 0x2e6a6
leaq 0x34a05(%rip), %rsi     # 0x63082
pushq $0x3
popq %rdi
movb $0x2, %al
callq 0x455bc
xorl %ebx, %ebx
jmp 0x2e751
leaq 0x349ca(%rip), %rsi     # 0x6305f
xorl %ebx, %ebx
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x455bc
jmp 0x2e751
movsd %xmm1, -0x40(%rbp)
movl 0x14(%rbx), %edi
movl %edx, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x38(%rbp)
callq 0x47222
movq %rax, %rdi
callq 0x478a9
movsd -0x38(%rbp), %xmm2
movq %rax, 0x40(%rbx)
movsd %xmm0, 0x48(%rbx)
movsd 0xc8(%rbx), %xmm0
movsd 0x336e3(%rip), %xmm1    # 0x61dc8
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2e6f6
movl 0x14(%rbx), %edi
incl %edi
jmp 0x2e709
addsd 0x336c2(%rip), %xmm2    # 0x61dc0
ucomisd %xmm0, %xmm2
movl 0x14(%rbx), %edi
jbe 0x2e70c
decl %edi
movl %edi, 0x14(%rbx)
callq 0x47222
movq %rax, %rdi
callq 0x478a9
movq %rax, 0x20(%rbx)
movsd %xmm0, 0x28(%rbx)
movl 0x14(%rbx), %edi
movsd -0x40(%rbp), %xmm0
callq 0x47222
movq %rax, %rdi
callq 0x478a9
movq %rax, 0x30(%rbx)
movsd %xmm0, 0x38(%rbx)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x18(%rbx)
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq