// File: /workspace/github_cpp_makefile_star2_O3/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 0x3f373
movq %rdi, %rbx
leaq 0x9f0c4(%rdi), %r15
movq %r15, %rdi
movl $0x24, %esi
movl $0x6, %edx
callq 0x4d9d6
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
movl $0x2a, %esi
movl $0xc, %edx
callq 0x4d9d6
movl %eax, -0x40(%rbp)
movq %r15, %rdi
movl $0x36, %esi
movl $0xa, %edx
callq 0x4d9d6
movl %eax, -0x30(%rbp)
movq %r15, %rdi
movl $0x40, %esi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, -0xa0(%rbp)
movq %r15, %rdi
movl $0x48, %esi
movl $0xe, %edx
callq 0x4da25
movl %eax, -0x58(%rbp)
movq %r15, %rdi
movl $0x56, %esi
movl $0xe, %edx
callq 0x4d9d6
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x2bbda(%rip), %xmm0    # 0x6a8b8
movsd %xmm0, -0x38(%rbp)
movq %r15, %rdi
movl $0x64, %esi
movl $0x6, %edx
callq 0x4da25
movl %eax, -0xa8(%rbp)
movq %r15, %rdi
movl $0x6a, %esi
movl $0x15, %edx
callq 0x4da25
movl %eax, -0xa4(%rbp)
movq %r15, %rdi
movl $0x7f, %esi
movl $0x1f, %edx
callq 0x4da25
movl %eax, -0x9c(%rbp)
movq %r15, %rdi
movl $0x9e, %esi
movl $0x10, %edx
callq 0x4da25
movl %eax, -0x50(%rbp)
movq %r15, %rdi
movl $0xae, %esi
movl $0x10, %edx
callq 0x4da25
movl %eax, -0x8c(%rbp)
movq %r15, %rdi
movl $0xbe, %esi
movl $0x20, %edx
callq 0x4da25
movl %eax, -0x80(%rbp)
movq %r15, %rdi
movl $0xde, %esi
movl $0x10, %edx
callq 0x4da25
movl %eax, -0x90(%rbp)
movq %r15, %rdi
movl $0xee, %esi
movl $0x20, %edx
callq 0x4d9d6
movl %eax, -0x98(%rbp)
movq %r15, %rdi
movl $0x10e, %esi            # imm = 0x10E
movl $0x10, %edx
callq 0x4da25
movl %eax, -0x88(%rbp)
movq %r15, %rdi
movl $0x11e, %esi            # imm = 0x11E
movl $0x20, %edx
callq 0x4d9d6
movl %eax, -0x94(%rbp)
movq %r15, %rdi
movl $0x13e, %esi            # imm = 0x13E
movl $0xe, %edx
callq 0x4d9d6
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x2bac7(%rip), %xmm0    # 0x6a8b8
movsd %xmm0, -0x48(%rbp)
movq %r15, %rdi
movl $0x14c, %esi            # imm = 0x14C
movl $0x10, %edx
callq 0x4da25
movl %eax, -0x74(%rbp)
movq %r15, %rdi
movl $0x15c, %esi            # imm = 0x15C
movl $0x20, %edx
callq 0x4da25
movl %eax, -0x6c(%rbp)
movq %r15, %rdi
movl $0x17c, %esi            # imm = 0x17C
movl $0x10, %edx
callq 0x4da25
movl %eax, -0x70(%rbp)
movq %r15, %rdi
movl $0x18c, %esi            # imm = 0x18C
movl $0x20, %edx
callq 0x4da25
movl %eax, -0x68(%rbp)
movq %r15, %rdi
movl $0x1ac, %esi            # imm = 0x1AC
movl $0x10, %edx
callq 0x4da25
movl %eax, -0x84(%rbp)
movq %r15, %rdi
movl $0x1bc, %esi            # imm = 0x1BC
movl $0x20, %edx
callq 0x4da25
movl %eax, -0x64(%rbp)
movq %r15, %rdi
movl $0x1dc, %esi            # imm = 0x1DC
movl $0x18, %edx
callq 0x4da25
movl %eax, -0x60(%rbp)
movq %r15, %rdi
movl $0x1f4, %esi            # imm = 0x1F4
movl $0xa, %edx
callq 0x4da25
movl %eax, -0x7c(%rbp)
movq %r15, %rdi
movl $0x1fe, %esi            # imm = 0x1FE
movl $0xa, %edx
callq 0x4da25
movl %eax, -0x78(%rbp)
movq %r15, %rdi
movl $0x208, %esi            # imm = 0x208
movl $0x2, %edx
callq 0x4d9d6
movl %eax, %r13d
movq %r15, %rdi
movl $0x20a, %esi            # imm = 0x20A
movl $0x1, %edx
callq 0x4d9d6
movq %rax, -0xb8(%rbp)
movq %r15, %rdi
movl $0x20b, %esi            # imm = 0x20B
movl $0x2, %edx
callq 0x4d9d6
movq %rax, -0xb0(%rbp)
movq %r15, %rdi
movl $0x20d, %esi            # imm = 0x20D
movl $0x1, %edx
callq 0x4d9d6
movl %eax, %r14d
leaq 0x3081e(%rip), %rsi     # 0x6f737
movl $0x4, %edi
movl -0x2c(%rbp), %edx
movl %edx, %r12d
movl -0x30(%rbp), %ecx
movl %ecx, %r15d
movsd -0x48(%rbp), %xmm0
movb $0x1, %al
callq 0x4d55d
cmpl $0x0, 0xc(%rbx)
je 0x3ef8e
leaq 0x9b9d0(%rbx), %rdi
callq 0x8290
leaq (%rbx,%rax), %rdi
addq $0x9b9d0, %rdi          # imm = 0x9B9D0
subq $0x8, %rsp
leaq 0x30803(%rip), %rsi     # 0x6f761
movl %r12d, %edx
movl %r15d, %ecx
movl -0x40(%rbp), %r8d
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movl %r13d, %r9d
movb $0x2, %al
pushq %r14
pushq -0xb8(%rbp)
pushq -0xb0(%rbp)
callq 0x8120
addq $0x20, %rsp
movq %r14, -0xd0(%rbp)
movl $0x8, %edi
movl %r12d, %esi
callq 0x4d28d
testl %eax, %eax
je 0x3f381
movl %eax, -0x2c(%rbp)
movl %r13d, -0x5c(%rbp)
movl -0x40(%rbp), %r14d
leaq 0x9fd48(%rbx), %r12
leaq 0x2d7f0(%rip), %rsi     # 0x6c7b3
movq %r12, %rdi
callq 0x8160
xorl %r13d, %r13d
testq %rax, %rax
jne 0x3f39d
addl $0x400, %r14d           # imm = 0x400
movl %r14d, %edi
movsd -0x48(%rbp), %xmm0
callq 0x4f24a
movq %rax, -0x40(%rbp)
movsd %xmm0, -0xc8(%rbp)
movl %r14d, %edi
movsd -0x38(%rbp), %xmm0
callq 0x4f24a
movq %rax, -0x38(%rbp)
movsd %xmm0, -0xc0(%rbp)
movups 0x10(%rbx), %xmm0
movaps %xmm0, -0xe0(%rbp)
leaq 0x2d6a5(%rip), %rsi     # 0x6c6c7
movq %r12, %rdi
callq 0x8160
movq 0x80(%rbx), %rcx
movl -0x2c(%rbp), %r8d
movslq %r8d, %rdx
leaq (%rdx,%rdx,8), %rdx
testq %rax, %rax
movl -0x30(%rbp), %esi
jne 0x3f058
movq %rdx, %rax
shlq $0x5, %rax
cmpl -0x11c(%rcx,%rax), %esi
je 0x3f39d
cvtsi2sdl -0x58(%rbp), %xmm7
xorps %xmm1, %xmm1
cvtsi2sdl -0x8c(%rbp), %xmm1
cvtsi2sdl -0x80(%rbp), %xmm2
cvtsi2sdl -0x6c(%rbp), %xmm4
cvtsi2sdl -0x68(%rbp), %xmm6
cvtsi2sdl -0x64(%rbp), %xmm5
cvtsi2sdl -0x60(%rbp), %xmm3
xorps %xmm0, %xmm0
cvtsi2sdl -0x50(%rbp), %xmm0
cvtsi2sdl -0x90(%rbp), %xmm8
cvtsi2sdl -0x88(%rbp), %xmm9
cvtsi2sdl -0x74(%rbp), %xmm10
cvtsi2sdl -0x70(%rbp), %xmm11
movsd 0x2dc08(%rip), %xmm12   # 0x6ccb8
mulsd %xmm12, %xmm2
mulsd %xmm12, %xmm4
mulsd %xmm12, %xmm6
mulsd %xmm12, %xmm5
movsd 0x2dc03(%rip), %xmm12   # 0x6ccd0
mulsd %xmm12, %xmm7
mulsd %xmm12, %xmm1
mulsd %xmm12, %xmm3
movsd 0x2dbf3(%rip), %xmm12   # 0x6ccd8
mulsd %xmm12, %xmm8
movsd %xmm8, -0x58(%rbp)
mulsd %xmm12, %xmm9
mulsd %xmm12, %xmm10
mulsd %xmm12, %xmm11
movsd 0x2dbd8(%rip), %xmm12   # 0x6cce0
mulsd %xmm12, %xmm0
movsd %xmm0, -0x50(%rbp)
cvtsi2sdl -0x84(%rbp), %xmm14
mulsd %xmm12, %xmm14
movsd 0x2cc7f(%rip), %xmm13   # 0x6bda8
mulsd %xmm13, %xmm7
mulsd %xmm13, %xmm1
mulsd %xmm13, %xmm2
mulsd %xmm13, %xmm4
mulsd %xmm13, %xmm6
mulsd %xmm13, %xmm5
xorps %xmm12, %xmm12
cvtsi2sdl -0x7c(%rbp), %xmm12
mulsd %xmm13, %xmm3
xorps %xmm13, %xmm13
cvtsi2sdl -0x78(%rbp), %xmm13
movsd 0x2db97(%rip), %xmm15   # 0x6cd00
mulsd %xmm15, %xmm12
mulsd %xmm15, %xmm13
movl -0x5c(%rbp), %eax
shll $0x7, %eax
movq -0xb8(%rbp), %rdi
shll $0x6, %edi
addl %eax, %edi
movq -0xb0(%rbp), %rax
leal (%rdi,%rax,2), %eax
addl -0xd0(%rbp), %eax
shlq $0x5, %rdx
movl %r8d, -0x120(%rcx,%rdx)
movl %esi, -0x11c(%rcx,%rdx)
movl $0x0, -0x118(%rcx,%rdx)
movl -0xa0(%rbp), %esi
movl %esi, -0x114(%rcx,%rdx)
movl %eax, -0x110(%rcx,%rdx)
movl %r14d, -0x10c(%rcx,%rdx)
movq $0x201, -0x108(%rcx,%rdx) # imm = 0x201
movq -0x40(%rbp), %rax
movq %rax, -0x100(%rcx,%rdx)
movsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0xf8(%rcx,%rdx)
movq -0x38(%rbp), %rax
movq %rax, -0xf0(%rcx,%rdx)
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0xe8(%rcx,%rdx)
movl -0x98(%rbp), %eax
xorps %xmm15, %xmm15
cvtsi2sd %rax, %xmm15
mulsd 0x2da93(%rip), %xmm15   # 0x6ccc0
movl -0x94(%rbp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movaps -0xe0(%rbp), %xmm8
movups %xmm8, -0xe0(%rcx,%rdx)
mulsd 0x2da74(%rip), %xmm0    # 0x6ccc8
mulsd %xmm0, %xmm0
movsd %xmm0, -0xd0(%rcx,%rdx)
movsd %xmm15, -0xc8(%rcx,%rdx)
movsd %xmm6, -0xc0(%rcx,%rdx)
movsd %xmm4, -0xb8(%rcx,%rdx)
movsd %xmm5, -0xb0(%rcx,%rdx)
movsd %xmm2, -0xa8(%rcx,%rdx)
movsd %xmm1, -0xa0(%rcx,%rdx)
movsd %xmm3, -0x98(%rcx,%rdx)
movsd %xmm7, -0x90(%rcx,%rdx)
movsd %xmm14, -0x88(%rcx,%rdx)
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x80(%rcx,%rdx)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x78(%rcx,%rdx)
movsd %xmm9, -0x70(%rcx,%rdx)
movsd %xmm10, -0x68(%rcx,%rdx)
xorps %xmm0, %xmm0
cvtsi2sdl -0xa8(%rbp), %xmm0
movsd %xmm11, -0x60(%rcx,%rdx)
movsd -0x48(%rbp), %xmm1
movsd %xmm1, -0x58(%rcx,%rdx)
xorps %xmm1, %xmm1
cvtsi2sdl -0x9c(%rbp), %xmm1
mulsd 0x2d9e0(%rip), %xmm1    # 0x6cce8
movq $0x0, -0x50(%rcx,%rdx)
movsd %xmm1, -0x48(%rcx,%rdx)
xorps %xmm1, %xmm1
cvtsi2sdl -0xa4(%rbp), %xmm1
mulsd 0x2d9c6(%rip), %xmm1    # 0x6ccf0
movsd %xmm1, -0x40(%rcx,%rdx)
mulsd 0x2d9c0(%rip), %xmm0    # 0x6ccf8
movsd %xmm0, -0x38(%rcx,%rdx)
movsd %xmm12, -0x30(%rcx,%rdx)
movsd %xmm13, -0x28(%rcx,%rdx)
movaps -0x100(%rbp), %xmm0
movaps -0xf0(%rbp), %xmm1
movups %xmm1, -0x10(%rcx,%rdx)
movups %xmm0, -0x20(%rcx,%rdx)
movl %r8d, 0x9bdd4(%rbx)
movl $0x2, %r13d
jmp 0x3f39d
leaq 0x3039c(%rip), %rsi     # 0x6f716
movl $0x2, %edi
jmp 0x3f390
leaq 0x3041a(%rip), %rsi     # 0x6f7a2
movl $0x2, %edi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4d55d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r13d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq