// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_type1046(bamboo::rtcm_t*, int)
static int encode_type1046(rtcm_t *rtcm, int sync)
{
    eph_t *eph;
    unsigned int sqrtA,e;
    int i=24,prn,week,toe,toc,i0,OMG0,omg,M0,deln,idot,OMGd,crs,crc;
    int cus,cuc,cis,cic,af0,af1,af2,bgd1,bgd2,oshs1,osdvs1,oshs2,osdvs2;
    
    trace(3,"encode_type1046: sync=%d\n",sync);
    
    if (satsys(rtcm->ephsat,&prn)!=SYS_GAL) return 0;
    eph=rtcm->nav.eph+rtcm->ephsat-1;
    if (eph->sat!=rtcm->ephsat) return 0;
    week=(eph->week-1024)%4096; /* gst-week = gal-week - 1024 */
    toe  =ROUND(eph->toes/60.0);
    toc  =ROUND(time2gpst(eph->toc,NULL)/60.0);
    sqrtA=ROUND_U(sqrt(eph->A)/P2_19);
    e    =ROUND_U(eph->e/P2_33);
    i0   =ROUND(eph->i0  /P2_31/SC2RAD);
    OMG0 =ROUND(eph->OMG0/P2_31/SC2RAD);
    omg  =ROUND(eph->omg /P2_31/SC2RAD);
    M0   =ROUND(eph->M0  /P2_31/SC2RAD);
    deln =ROUND(eph->deln/P2_43/SC2RAD);
    idot =ROUND(eph->idot/P2_43/SC2RAD);
    OMGd =ROUND(eph->OMGd/P2_43/SC2RAD);
    crs  =ROUND(eph->crs/P2_5 );
    crc  =ROUND(eph->crc/P2_5 );
    cus  =ROUND(eph->cus/P2_29);
    cuc  =ROUND(eph->cuc/P2_29);
    cis  =ROUND(eph->cis/P2_29);
    cic  =ROUND(eph->cic/P2_29);
    af0  =ROUND(eph->f0 /P2_34);
    af1  =ROUND(eph->f1 /P2_46);
    af2  =ROUND(eph->f2 /P2_59);
    bgd1 =ROUND(eph->tgd[0]/P2_32); /* E5a/E1 */
    bgd2 =ROUND(eph->tgd[1]/P2_32); /* E5b/E1 */
    oshs1 =(eph->svh>>7)&3;         /* E5b SVH */
    osdvs1=(eph->svh>>6)&1;         /* E5b DVS */
    oshs2 =(eph->svh>>1)&3;         /* E1 SVH */
    osdvs2=(eph->svh>>0)&1;         /* E1 DVS */
    setbitu(rtcm->buff,i,12,1046     ); i+=12;
    setbitu(rtcm->buff,i, 6,prn      ); i+= 6;
    setbitu(rtcm->buff,i,12,week     ); i+=12;
    setbitu(rtcm->buff,i,10,eph->iode); i+=10;
    setbitu(rtcm->buff,i, 8,eph->sva ); i+= 8;
    setbits(rtcm->buff,i,14,idot     ); i+=14;
    setbitu(rtcm->buff,i,14,toc      ); i+=14;
    setbits(rtcm->buff,i, 6,af2      ); i+= 6;
    setbits(rtcm->buff,i,21,af1      ); i+=21;
    setbits(rtcm->buff,i,31,af0      ); i+=31;
    setbits(rtcm->buff,i,16,crs      ); i+=16;
    setbits(rtcm->buff,i,16,deln     ); i+=16;
    setbits(rtcm->buff,i,32,M0       ); i+=32;
    setbits(rtcm->buff,i,16,cuc      ); i+=16;
    setbitu(rtcm->buff,i,32,e        ); i+=32;
    setbits(rtcm->buff,i,16,cus      ); i+=16;
    setbitu(rtcm->buff,i,32,sqrtA    ); i+=32;
    setbitu(rtcm->buff,i,14,toe      ); i+=14;
    setbits(rtcm->buff,i,16,cic      ); i+=16;
    setbits(rtcm->buff,i,32,OMG0     ); i+=32;
    setbits(rtcm->buff,i,16,cis      ); i+=16;
    setbits(rtcm->buff,i,32,i0       ); i+=32;
    setbits(rtcm->buff,i,16,crc      ); i+=16;
    setbits(rtcm->buff,i,32,omg      ); i+=32;
    setbits(rtcm->buff,i,24,OMGd     ); i+=24;
    setbits(rtcm->buff,i,10,bgd1     ); i+=10;
    setbits(rtcm->buff,i,10,bgd2     ); i+=10;
    setbitu(rtcm->buff,i, 2,oshs1    ); i+= 2; /* E5b SVH */
    setbitu(rtcm->buff,i, 1,osdvs1   ); i+= 1; /* E5b DVS */
    setbitu(rtcm->buff,i, 2,oshs2    ); i+= 2; /* E1 SVH */
    setbitu(rtcm->buff,i, 1,osdvs2   ); i+= 1; /* E1 DVS */
    rtcm->nbit=i;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %edx
movq %rdi, %r15
leaq 0x2874e(%rip), %rsi     # 0x704c4
xorl %ebx, %ebx
movl $0x3, %edi
xorl %eax, %eax
callq 0x4d55d
movl 0x9bdd4(%r15), %edi
leaq -0x84(%rbp), %rsi
callq 0x4d2f2
cmpl $0x8, %eax
jne 0x4846f
movq 0x80(%r15), %r12
movslq 0x9bdd4(%r15), %rcx
leaq (%rcx,%rcx,8), %rax
shlq $0x5, %rax
cmpl %ecx, -0x120(%r12,%rax)
jne 0x4846f
addq %rax, %r12
movl -0x10c(%r12), %eax
leal -0x400(%rax), %ecx
leal 0xbff(%rax), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
andl $0xfffff000, %edx       # imm = 0xFFFFF000
negl %edx
addl %edx, %eax
addl $0xfffffc00, %eax       # imm = 0xFFFFFC00
movl %eax, -0x70(%rbp)
movsd -0x58(%r12), %xmm0
divsd 0x22ab7(%rip), %xmm0    # 0x6a8b8
addsd 0x23e6f(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x80(%rbp)
movq -0xf0(%r12), %rdi
movsd -0xe8(%r12), %xmm0
xorl %esi, %esi
callq 0x4f2b1
divsd 0x22a82(%rip), %xmm0    # 0x6a8b8
addsd 0x23e3a(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x6c(%rbp)
movsd -0xd0(%r12), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x47e64
sqrtsd %xmm0, %xmm0
jmp 0x47e69
callq 0x84e0
mulsd 0x22c37(%rip), %xmm0    # 0x6aaa8
movsd 0x23dff(%rip), %xmm1    # 0x6bc78
addsd %xmm1, %xmm0
callq 0x8ac0
cvttsd2si %xmm0, %rax
movq %rax, -0xa0(%rbp)
movsd -0xc8(%r12), %xmm0
divsd 0x24e20(%rip), %xmm0    # 0x6ccc0
addsd 0x23dd0(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %rax
movq %rax, -0x98(%rbp)
movsd -0xc0(%r12), %xmm0
mulsd 0x22bd5(%rip), %xmm0    # 0x6aaa0
divsd 0x23ed5(%rip), %xmm0    # 0x6bda8
addsd 0x23d9d(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x7c(%rbp)
movsd -0xb8(%r12), %xmm0
mulsd 0x22ba7(%rip), %xmm0    # 0x6aaa0
divsd 0x23ea7(%rip), %xmm0    # 0x6bda8
addsd 0x23d6f(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x74(%rbp)
movsd -0xb0(%r12), %xmm0
mulsd 0x22b79(%rip), %xmm0    # 0x6aaa0
divsd 0x23e79(%rip), %xmm0    # 0x6bda8
addsd 0x23d41(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x78(%rbp)
movsd 0x22b55(%rip), %xmm0    # 0x6aaa0
mulsd -0xa8(%r12), %xmm0
divsd 0x23e4b(%rip), %xmm0    # 0x6bda8
addsd 0x23d13(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x60(%rbp)
movsd -0xa0(%r12), %xmm0
divsd 0x24d4d(%rip), %xmm0    # 0x6ccd0
divsd 0x23e1d(%rip), %xmm0    # 0x6bda8
addsd 0x23ce5(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x5c(%rbp)
movsd -0x90(%r12), %xmm0
divsd 0x24d1f(%rip), %xmm0    # 0x6ccd0
divsd 0x23def(%rip), %xmm0    # 0x6bda8
addsd 0x23cb7(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movsd -0x98(%r12), %xmm0
divsd 0x24cf1(%rip), %xmm0    # 0x6ccd0
divsd 0x23dc1(%rip), %xmm0    # 0x6bda8
addsd 0x23c89(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x68(%rbp)
movsd -0x80(%r12), %xmm0
mulsd 0x2812e(%rip), %xmm0    # 0x70138
addsd 0x23c66(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x40(%rbp)
movsd 0x28112(%rip), %xmm0    # 0x70138
mulsd -0x88(%r12), %xmm0
addsd 0x23c40(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x64(%rbp)
movsd -0x70(%r12), %xmm0
mulsd 0x280ed(%rip), %xmm0    # 0x70140
addsd 0x23c1d(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x54(%rbp)
movsd -0x78(%r12), %xmm0
mulsd 0x280ca(%rip), %xmm0    # 0x70140
addsd 0x23bfa(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movsd -0x60(%r12), %xmm0
mulsd 0x280a7(%rip), %xmm0    # 0x70140
addsd 0x23bd7(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x58(%rbp)
movsd 0x2808b(%rip), %xmm0    # 0x70140
mulsd -0x68(%r12), %xmm0
addsd 0x23bb4(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x48(%rbp)
movsd -0x48(%r12), %xmm0
divsd 0x24c09(%rip), %xmm0    # 0x6cce8
addsd 0x23b91(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x34(%rbp)
movsd -0x40(%r12), %xmm0
divsd 0x24bee(%rip), %xmm0    # 0x6ccf0
addsd 0x23b6e(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x30(%rbp)
movsd -0x38(%r12), %xmm0
divsd 0x24bd3(%rip), %xmm0    # 0x6ccf8
addsd 0x23b4b(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x2c(%rbp)
movsd -0x30(%r12), %xmm0
divsd 0x24bb8(%rip), %xmm0    # 0x6cd00
addsd 0x23b28(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x4c(%rbp)
movsd -0x28(%r12), %xmm0
divsd 0x24b95(%rip), %xmm0    # 0x6cd00
addsd 0x23b05(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x44(%rbp)
movl -0x110(%r12), %r14d
movl %r14d, %ebx
shrl $0x7, %ebx
andl $0x3, %ebx
movl %r14d, %r13d
shrl $0x6, %r13d
andl $0x1, %r13d
movl %r14d, %eax
shrl %eax
andl $0x3, %eax
movl %eax, -0x50(%rbp)
andl $0x1, %r14d
movq %r15, -0x90(%rbp)
addq $0x9f0c4, %r15          # imm = 0x9F0C4
movq %r15, %rdi
movl $0x18, %esi
movl $0xc, %edx
movl $0x416, %ecx            # imm = 0x416
callq 0x4da98
movl -0x84(%rbp), %ecx
movq %r15, %rdi
movl $0x24, %esi
movl $0x6, %edx
callq 0x4da98
movq %r15, %rdi
movl $0x2a, %esi
movl $0xc, %edx
movl -0x70(%rbp), %ecx
callq 0x4da98
movl -0x11c(%r12), %ecx
movq %r15, %rdi
movl $0x36, %esi
movl $0xa, %edx
callq 0x4da98
movl -0x114(%r12), %ecx
movq %r15, %rdi
movl $0x40, %esi
movl $0x8, %edx
callq 0x4da98
movq %r15, %rdi
movl $0x48, %esi
movl $0xe, %edx
movl -0x3c(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x56, %esi
movl $0xe, %edx
movl -0x6c(%rbp), %ecx
callq 0x4da98
movq %r15, %rdi
movl $0x64, %esi
movl $0x6, %edx
movl -0x2c(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x6a, %esi
movl $0x15, %edx
movl -0x30(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x7f, %esi
movl $0x1f, %edx
movl -0x34(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x9e, %esi
movl $0x10, %edx
movl -0x40(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0xae, %esi
movl $0x10, %edx
movl -0x5c(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0xbe, %esi
movl $0x20, %edx
movl -0x60(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0xde, %esi
movl $0x10, %edx
movl -0x38(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0xee, %esi
movl $0x20, %edx
movq -0x98(%rbp), %rcx
callq 0x4da98
movq %r15, %rdi
movl $0x10e, %esi            # imm = 0x10E
movl $0x10, %edx
movl -0x54(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x11e, %esi            # imm = 0x11E
movl $0x20, %edx
movq -0xa0(%rbp), %rcx
callq 0x4da98
movq %r15, %rdi
movl $0x13e, %esi            # imm = 0x13E
movl $0xe, %edx
movl -0x80(%rbp), %ecx
callq 0x4da98
movq %r15, %rdi
movl $0x14c, %esi            # imm = 0x14C
movl $0x10, %edx
movl -0x48(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x15c, %esi            # imm = 0x15C
movl $0x20, %edx
movl -0x74(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x17c, %esi            # imm = 0x17C
movl $0x10, %edx
movl -0x58(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x18c, %esi            # imm = 0x18C
movl $0x20, %edx
movl -0x7c(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x1ac, %esi            # imm = 0x1AC
movl $0x10, %edx
movl -0x64(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x1bc, %esi            # imm = 0x1BC
movl $0x20, %edx
movl -0x78(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x1dc, %esi            # imm = 0x1DC
movl $0x18, %edx
movl -0x68(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x1f4, %esi            # imm = 0x1F4
movl $0xa, %edx
movl -0x4c(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x1fe, %esi            # imm = 0x1FE
movl $0xa, %edx
movl -0x44(%rbp), %ecx
callq 0x4db0c
movq %r15, %rdi
movl $0x208, %esi            # imm = 0x208
movl $0x2, %edx
movl %ebx, %ecx
callq 0x4da98
movl $0x1, %ebx
movq %r15, %rdi
movl $0x20a, %esi            # imm = 0x20A
movl $0x1, %edx
movl %r13d, %ecx
callq 0x4da98
movq %r15, %rdi
movl $0x20b, %esi            # imm = 0x20B
movl $0x2, %edx
movl -0x50(%rbp), %ecx
callq 0x4da98
movq %r15, %rdi
movl $0x20d, %esi            # imm = 0x20D
movl $0x1, %edx
movl %r14d, %ecx
callq 0x4da98
movq -0x90(%rbp), %rax
movl $0x20e, 0x9f0bc(%rax)   # imm = 0x20E
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq