// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_type1046(bamboo::rtcm_t*)
static int decode_type1046(rtcm_t *rtcm)
{
    eph_t eph={0};
    double toc,sqrtA;
    char *msg;
    int i=24+12,prn,sat,week,e5b_hs,e5b_dvs,e1_hs,e1_dvs,sys=SYS_GAL;
    
    if (i+492<=rtcm->len*8) {
        prn       =getbitu(rtcm->buff,i, 6);              i+= 6;
        week      =getbitu(rtcm->buff,i,12);              i+=12;
        eph.iode  =getbitu(rtcm->buff,i,10);              i+=10;
        eph.sva   =getbitu(rtcm->buff,i, 8);              i+= 8;
        eph.idot  =getbits(rtcm->buff,i,14)*P2_43*SC2RAD; i+=14;
        toc       =getbitu(rtcm->buff,i,14)*60.0;         i+=14;
        eph.f2    =getbits(rtcm->buff,i, 6)*P2_59;        i+= 6;
        eph.f1    =getbits(rtcm->buff,i,21)*P2_46;        i+=21;
        eph.f0    =getbits(rtcm->buff,i,31)*P2_34;        i+=31;
        eph.crs   =getbits(rtcm->buff,i,16)*P2_5;         i+=16;
        eph.deln  =getbits(rtcm->buff,i,16)*P2_43*SC2RAD; i+=16;
        eph.M0    =getbits(rtcm->buff,i,32)*P2_31*SC2RAD; i+=32;
        eph.cuc   =getbits(rtcm->buff,i,16)*P2_29;        i+=16;
        eph.e     =getbitu(rtcm->buff,i,32)*P2_33;        i+=32;
        eph.cus   =getbits(rtcm->buff,i,16)*P2_29;        i+=16;
        sqrtA     =getbitu(rtcm->buff,i,32)*P2_19;        i+=32;
        eph.toes  =getbitu(rtcm->buff,i,14)*60.0;         i+=14;
        eph.cic   =getbits(rtcm->buff,i,16)*P2_29;        i+=16;
        eph.OMG0  =getbits(rtcm->buff,i,32)*P2_31*SC2RAD; i+=32;
        eph.cis   =getbits(rtcm->buff,i,16)*P2_29;        i+=16;
        eph.i0    =getbits(rtcm->buff,i,32)*P2_31*SC2RAD; i+=32;
        eph.crc   =getbits(rtcm->buff,i,16)*P2_5;         i+=16;
        eph.omg   =getbits(rtcm->buff,i,32)*P2_31*SC2RAD; i+=32;
        eph.OMGd  =getbits(rtcm->buff,i,24)*P2_43*SC2RAD; i+=24;
        eph.tgd[0]=getbits(rtcm->buff,i,10)*P2_32;        i+=10; /* E5a/E1 */
        eph.tgd[1]=getbits(rtcm->buff,i,10)*P2_32;        i+=10; /* E5b/E1 */
        e5b_hs    =getbitu(rtcm->buff,i, 2);              i+= 2; /* E5b OSHS */
        e5b_dvs   =getbitu(rtcm->buff,i, 1);              i+= 1; /* E5b OSDVS */
        e1_hs     =getbitu(rtcm->buff,i, 2);              i+= 2; /* E1 OSHS */
        e1_dvs    =getbitu(rtcm->buff,i, 1);              i+= 1; /* E1 OSDVS */
    }
    else {
        trace(2,"rtcm3 1046 length error: len=%d\n",rtcm->len);
        return -1;
    }
    trace(4,"decode_type1046: prn=%d iode=%d toe=%.0f\n",prn,eph.iode,eph.toes);
    
    if (rtcm->outtype) {
        msg=rtcm->msgtype+strlen(rtcm->msgtype);
        sprintf(msg," prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d %d dvs=%d %d",
                prn,eph.iode,week,eph.toes,toc,e5b_hs,e1_hs,e5b_dvs,e1_dvs);
    }
    if (!(sat=satno(sys,prn))) {
        trace(2,"rtcm3 1046 satellite number error: prn=%d\n",prn);
        return -1;
    }
    if (strstr(rtcm->opt,"-GALFNAV")) {
        return 0;
    }
    eph.sat=sat;
    eph.week=week+1024; /* gal-week = gst-week + 1024 */
    eph.toe=gpst2time(eph.week,eph.toes);
    eph.toc=gpst2time(eph.week,toc);
    eph.ttr=rtcm->time;
    eph.A=sqrtA*sqrtA;
    eph.svh=(e5b_hs<<7)+(e5b_dvs<<6)+(e1_hs<<1)+(e1_dvs<<0);
    eph.code=(1<<0)|(1<<9); /* data source = i/nav e1b + af0-2,toc,sisa for e5b-e1 */
    if (!strstr(rtcm->opt,"-EPHALL")) {
        if (eph.iode==rtcm->nav.eph[sat-1].iode) return 0; /* unchanged */
    }
    rtcm->nav.eph[sat-1]=eph;
    rtcm->ephsat=sat;
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps %xmm0, -0xf0(%rbp)
movl 0x9f0c0(%rdi), %edx
cmpl $0x42, %edx
jl 0x3fa33
movq %rdi, %rbx
leaq 0x9f0c4(%rdi), %r15
movq %r15, %rdi
movl $0x24, %esi
movl $0x6, %edx
callq 0x4e341
movl %eax, %r12d
movq %r15, %rdi
movl $0x2a, %esi
movl $0xc, %edx
callq 0x4e341
movl %eax, %r13d
movq %r15, %rdi
movl $0x36, %esi
movl $0xa, %edx
callq 0x4e341
movl %eax, %r14d
movq %r15, %rdi
movl $0x40, %esi
movl $0x8, %edx
callq 0x4e341
movl %eax, -0x98(%rbp)
movq %r15, %rdi
movl $0x48, %esi
movl $0xe, %edx
callq 0x4e390
movl %eax, -0x50(%rbp)
movq %r15, %rdi
movl $0x56, %esi
movl $0xe, %edx
callq 0x4e341
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x2b511(%rip), %xmm0    # 0x6a8b8
movsd %xmm0, -0x38(%rbp)
movq %r15, %rdi
movl $0x64, %esi
movl $0x6, %edx
callq 0x4e390
movl %eax, -0xa0(%rbp)
movq %r15, %rdi
movl $0x6a, %esi
movl $0x15, %edx
callq 0x4e390
movl %eax, -0x9c(%rbp)
movq %r15, %rdi
movl $0x7f, %esi
movl $0x1f, %edx
callq 0x4e390
movl %eax, -0x94(%rbp)
movq %r15, %rdi
movl $0x9e, %esi
movl $0x10, %edx
callq 0x4e390
movl %eax, -0x48(%rbp)
movq %r15, %rdi
movl $0xae, %esi
movl $0x10, %edx
callq 0x4e390
movl %eax, -0x84(%rbp)
movq %r15, %rdi
movl $0xbe, %esi
movl $0x20, %edx
callq 0x4e390
movl %eax, -0x78(%rbp)
movq %r15, %rdi
movl $0xde, %esi
movl $0x10, %edx
callq 0x4e390
movl %eax, -0x88(%rbp)
movq %r15, %rdi
movl $0xee, %esi
movl $0x20, %edx
callq 0x4e341
movl %eax, -0x90(%rbp)
movq %r15, %rdi
movl $0x10e, %esi            # imm = 0x10E
movl $0x10, %edx
callq 0x4e390
movl %eax, -0x80(%rbp)
movq %r15, %rdi
movl $0x11e, %esi            # imm = 0x11E
movl $0x20, %edx
callq 0x4e341
movl %eax, -0x8c(%rbp)
movq %r15, %rdi
movl $0x13e, %esi            # imm = 0x13E
movl $0xe, %edx
callq 0x4e341
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x2b401(%rip), %xmm0    # 0x6a8b8
movsd %xmm0, -0x40(%rbp)
movq %r15, %rdi
movl $0x14c, %esi            # imm = 0x14C
movl $0x10, %edx
callq 0x4e390
movl %eax, -0x6c(%rbp)
movq %r15, %rdi
movl $0x15c, %esi            # imm = 0x15C
movl $0x20, %edx
callq 0x4e390
movl %eax, -0x64(%rbp)
movq %r15, %rdi
movl $0x17c, %esi            # imm = 0x17C
movl $0x10, %edx
callq 0x4e390
movl %eax, -0x68(%rbp)
movq %r15, %rdi
movl $0x18c, %esi            # imm = 0x18C
movl $0x20, %edx
callq 0x4e390
movl %eax, -0x60(%rbp)
movq %r15, %rdi
movl $0x1ac, %esi            # imm = 0x1AC
movl $0x10, %edx
callq 0x4e390
movl %eax, -0x7c(%rbp)
movq %r15, %rdi
movl $0x1bc, %esi            # imm = 0x1BC
movl $0x20, %edx
callq 0x4e390
movl %eax, -0x5c(%rbp)
movq %r15, %rdi
movl $0x1dc, %esi            # imm = 0x1DC
movl $0x18, %edx
callq 0x4e390
movl %eax, -0x58(%rbp)
movq %r15, %rdi
movl $0x1f4, %esi            # imm = 0x1F4
movl $0xa, %edx
callq 0x4e390
movl %eax, -0x74(%rbp)
movq %r15, %rdi
movl $0x1fe, %esi            # imm = 0x1FE
movl $0xa, %edx
callq 0x4e390
movl %eax, -0x70(%rbp)
movq %r15, %rdi
movl $0x208, %esi            # imm = 0x208
movl $0x2, %edx
callq 0x4e341
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
movl $0x20a, %esi            # imm = 0x20A
movl $0x1, %edx
callq 0x4e341
movq %rax, -0xb0(%rbp)
movq %r15, %rdi
movl $0x20b, %esi            # imm = 0x20B
movl $0x2, %edx
callq 0x4e341
movq %rax, -0xa8(%rbp)
movq %r15, %rdi
movl %r12d, %r15d
movl $0x20d, %esi            # imm = 0x20D
movl $0x1, %edx
callq 0x4e341
movl %eax, %r12d
leaq 0x30158(%rip), %rsi     # 0x6f737
movl $0x4, %edi
movl %r15d, %edx
movl %r14d, %ecx
movsd -0x40(%rbp), %xmm0
movb $0x1, %al
callq 0x4ded0
cmpl $0x0, 0xc(%rbx)
je 0x3f64e
leaq 0x9b9d0(%rbx), %rdi
callq 0x8290
leaq (%rbx,%rax), %rdi
addq $0x9b9d0, %rdi          # imm = 0x9B9D0
subq $0x8, %rsp
leaq 0x30143(%rip), %rsi     # 0x6f761
movl %r15d, %edx
movl %r14d, %ecx
movl %r13d, %r8d
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movl -0x2c(%rbp), %r9d
movb $0x2, %al
pushq %r12
pushq -0xb0(%rbp)
pushq -0xa8(%rbp)
callq 0x8120
addq $0x20, %rsp
movq %r12, -0xd0(%rbp)
movl $0x8, %edi
movl %r15d, %r12d
movl %r15d, %esi
callq 0x4dbc5
testl %eax, %eax
je 0x3fa41
movl %eax, %r15d
movl %r14d, -0x54(%rbp)
movl %r13d, %r14d
leaq 0x9fd48(%rbx), %r12
leaq 0x2d12e(%rip), %rsi     # 0x6c7b3
movq %r12, %rdi
callq 0x8160
xorl %r13d, %r13d
testq %rax, %rax
jne 0x3fa5d
addl $0x400, %r14d           # imm = 0x400
movl %r14d, %edi
movsd -0x40(%rbp), %xmm0
callq 0x4fbc6
movq %rax, -0xc8(%rbp)
movsd %xmm0, -0xc0(%rbp)
movl %r14d, %edi
movsd -0x38(%rbp), %xmm0
callq 0x4fbc6
movq %rax, -0x38(%rbp)
movsd %xmm0, -0xb8(%rbp)
movups 0x10(%rbx), %xmm0
movaps %xmm0, -0xe0(%rbp)
leaq 0x2cfe0(%rip), %rsi     # 0x6c6c7
movq %r12, %rdi
callq 0x8160
movslq %r15d, %rcx
testq %rax, %rax
movl -0x54(%rbp), %edi
jne 0x3f716
movq 0x80(%rbx), %rax
leaq (%rcx,%rcx,8), %rdx
shlq $0x5, %rdx
cmpl -0x11c(%rax,%rdx), %edi
je 0x3fa5d
cvtsi2sdl -0x50(%rbp), %xmm7
xorps %xmm1, %xmm1
cvtsi2sdl -0x84(%rbp), %xmm1
cvtsi2sdl -0x78(%rbp), %xmm2
cvtsi2sdl -0x64(%rbp), %xmm4
cvtsi2sdl -0x60(%rbp), %xmm6
cvtsi2sdl -0x5c(%rbp), %xmm5
cvtsi2sdl -0x58(%rbp), %xmm3
xorps %xmm0, %xmm0
cvtsi2sdl -0x48(%rbp), %xmm0
cvtsi2sdl -0x88(%rbp), %xmm8
cvtsi2sdl -0x80(%rbp), %xmm9
cvtsi2sdl -0x6c(%rbp), %xmm10
cvtsi2sdl -0x68(%rbp), %xmm11
movsd 0x2d54d(%rip), %xmm12   # 0x6ccb8
mulsd %xmm12, %xmm2
mulsd %xmm12, %xmm4
mulsd %xmm12, %xmm6
mulsd %xmm12, %xmm5
movsd 0x2d548(%rip), %xmm12   # 0x6ccd0
mulsd %xmm12, %xmm7
mulsd %xmm12, %xmm1
mulsd %xmm12, %xmm3
movsd 0x2d538(%rip), %xmm12   # 0x6ccd8
mulsd %xmm12, %xmm8
movsd %xmm8, -0x50(%rbp)
mulsd %xmm12, %xmm9
mulsd %xmm12, %xmm10
mulsd %xmm12, %xmm11
movsd 0x2d51d(%rip), %xmm12   # 0x6cce0
mulsd %xmm12, %xmm0
movsd %xmm0, -0x48(%rbp)
cvtsi2sdl -0x7c(%rbp), %xmm13
mulsd %xmm12, %xmm13
movsd 0x2c5c7(%rip), %xmm12   # 0x6bda8
mulsd %xmm12, %xmm7
mulsd %xmm12, %xmm1
mulsd %xmm12, %xmm2
mulsd %xmm12, %xmm4
mulsd %xmm12, %xmm6
mulsd %xmm12, %xmm5
mulsd %xmm12, %xmm3
xorps %xmm12, %xmm12
cvtsi2sdl -0x74(%rbp), %xmm12
movsd 0x2d4e9(%rip), %xmm15   # 0x6cd00
mulsd %xmm15, %xmm12
cvtsi2sdl -0x70(%rbp), %xmm14
mulsd %xmm15, %xmm14
movl -0x2c(%rbp), %eax
shll $0x7, %eax
movq -0xb0(%rbp), %rdx
shll $0x6, %edx
addl %eax, %edx
movq -0xa8(%rbp), %rax
leal (%rdx,%rax,2), %esi
addl -0xd0(%rbp), %esi
leaq (%rcx,%rcx,8), %rax
shlq $0x5, %rax
movq 0x80(%rbx), %rdx
movl %ecx, -0x120(%rdx,%rax)
movl %edi, -0x11c(%rdx,%rax)
movl $0x0, -0x118(%rdx,%rax)
movl -0x98(%rbp), %edi
movl %edi, -0x114(%rdx,%rax)
movl %esi, -0x110(%rdx,%rax)
movl %r14d, -0x10c(%rdx,%rax)
movq $0x201, -0x108(%rdx,%rax) # imm = 0x201
movq -0xc8(%rbp), %rsi
movq %rsi, -0x100(%rdx,%rax)
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0xf8(%rdx,%rax)
movq -0x38(%rbp), %rsi
movq %rsi, -0xf0(%rdx,%rax)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0xe8(%rdx,%rax)
movl -0x90(%rbp), %esi
xorps %xmm15, %xmm15
cvtsi2sd %rsi, %xmm15
mulsd 0x2d3d2(%rip), %xmm15   # 0x6ccc0
movl -0x8c(%rbp), %esi
xorps %xmm0, %xmm0
cvtsi2sd %rsi, %xmm0
movaps -0xe0(%rbp), %xmm8
movups %xmm8, -0xe0(%rdx,%rax)
mulsd 0x2d3b3(%rip), %xmm0    # 0x6ccc8
mulsd %xmm0, %xmm0
movsd %xmm0, -0xd0(%rdx,%rax)
movsd %xmm15, -0xc8(%rdx,%rax)
movsd %xmm6, -0xc0(%rdx,%rax)
movsd %xmm4, -0xb8(%rdx,%rax)
movsd %xmm5, -0xb0(%rdx,%rax)
movsd %xmm2, -0xa8(%rdx,%rax)
movsd %xmm1, -0xa0(%rdx,%rax)
movsd %xmm3, -0x98(%rdx,%rax)
movsd %xmm7, -0x90(%rdx,%rax)
movsd %xmm13, -0x88(%rdx,%rax)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x80(%rdx,%rax)
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x78(%rdx,%rax)
movsd %xmm9, -0x70(%rdx,%rax)
movsd %xmm10, -0x68(%rdx,%rax)
xorps %xmm0, %xmm0
cvtsi2sdl -0xa0(%rbp), %xmm0
movsd %xmm11, -0x60(%rdx,%rax)
movsd -0x40(%rbp), %xmm1
movsd %xmm1, -0x58(%rdx,%rax)
xorps %xmm1, %xmm1
cvtsi2sdl -0x94(%rbp), %xmm1
mulsd 0x2d31f(%rip), %xmm1    # 0x6cce8
movq $0x0, -0x50(%rdx,%rax)
movsd %xmm1, -0x48(%rdx,%rax)
xorps %xmm1, %xmm1
cvtsi2sdl -0x9c(%rbp), %xmm1
mulsd 0x2d305(%rip), %xmm1    # 0x6ccf0
movsd %xmm1, -0x40(%rdx,%rax)
mulsd 0x2d2ff(%rip), %xmm0    # 0x6ccf8
movsd %xmm0, -0x38(%rdx,%rax)
movsd %xmm12, -0x30(%rdx,%rax)
movsd %xmm14, -0x28(%rdx,%rax)
movaps -0x100(%rbp), %xmm0
movaps -0xf0(%rbp), %xmm1
movups %xmm1, -0x10(%rdx,%rax)
movups %xmm0, -0x20(%rdx,%rax)
movl %ecx, 0x9bdd4(%rbx)
movl $0x2, %r13d
jmp 0x3fa5d
leaq 0x2fcdc(%rip), %rsi     # 0x6f716
movl $0x2, %edi
jmp 0x3fa50
leaq 0x2fd5a(%rip), %rsi     # 0x6f7a2
movl $0x2, %edi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4ded0
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r13d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq