// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_type1020(bamboo::rtcm_t*, int)
static int encode_type1020(rtcm_t *rtcm, int sync)
{
    geph_t *geph;
    gtime_t time;
    double ep[6];
    int i=24,j,prn,tk_h,tk_m,tk_s,tb,pos[3],vel[3],acc[3],gamn,taun,dtaun;
    int fcn,NT;
    
    trace(3,"encode_type1020: sync=%d\n",sync);
    
    if (satsys(rtcm->ephsat,&prn)!=SYS_GLO) return 0;
    geph=rtcm->nav.geph+prn-1;
    if (geph->sat!=rtcm->ephsat) return 0;
    fcn=geph->frq+7;
    
    /* time of frame within day (utc(su) + 3 hr) */
    time=timeadd(gpst2utc(geph->tof),10800.0);
    time2epoch(time,ep);
    tk_h=(int)ep[3];
    tk_m=(int)ep[4];
    tk_s=ROUND(ep[5]/30.0);
    
    /* # of days since jan 1 in leap year */
    ep[0]=floor(ep[0]/4.0)*4.0; ep[1]=ep[2]=1.0;
    ep[3]=ep[4]=ep[5]=0.0;
    NT=(int)floor(timediff(time,epoch2time(ep))/86400.+1.0);
    
    /* index of time interval within day (utc(su) + 3 hr) */
    time=timeadd(gpst2utc(geph->toe),10800.0);
    time2epoch(time,ep);
    tb=ROUND((ep[3]*3600.0+ep[4]*60.0+ep[5])/900.0);
    
    for (j=0;j<3;j++) {
        pos[j]=ROUND(geph->pos[j]/P2_11/1E3);
        vel[j]=ROUND(geph->vel[j]/P2_20/1E3);
        acc[j]=ROUND(geph->acc[j]/P2_30/1E3);
    }
    gamn =ROUND(geph->gamn /P2_40);
    taun =ROUND(geph->taun /P2_30);
    dtaun=ROUND(geph->dtaun/P2_30);
    
    setbitu(rtcm->buff,i,12,1020     ); i+=12;
    setbitu(rtcm->buff,i, 6,prn      ); i+= 6;
    setbitu(rtcm->buff,i, 5,fcn      ); i+= 5;
    setbitu(rtcm->buff,i, 4,0        ); i+= 4; /* almanac health,P1 */
    setbitu(rtcm->buff,i, 5,tk_h     ); i+= 5;
    setbitu(rtcm->buff,i, 6,tk_m     ); i+= 6;
    setbitu(rtcm->buff,i, 1,tk_s     ); i+= 1;
    setbitu(rtcm->buff,i, 1,geph->svh); i+= 1; /* Bn */
    setbitu(rtcm->buff,i, 1,0        ); i+= 1; /* P2 */
    setbitu(rtcm->buff,i, 7,tb       ); i+= 7;
    setbitg(rtcm->buff,i,24,vel[0]   ); i+=24;
    setbitg(rtcm->buff,i,27,pos[0]   ); i+=27;
    setbitg(rtcm->buff,i, 5,acc[0]   ); i+= 5;
    setbitg(rtcm->buff,i,24,vel[1]   ); i+=24;
    setbitg(rtcm->buff,i,27,pos[1]   ); i+=27;
    setbitg(rtcm->buff,i, 5,acc[1]   ); i+= 5;
    setbitg(rtcm->buff,i,24,vel[2]   ); i+=24;
    setbitg(rtcm->buff,i,27,pos[2]   ); i+=27;
    setbitg(rtcm->buff,i, 5,acc[2]   ); i+= 5;
    setbitu(rtcm->buff,i, 1,0        ); i+= 1; /* P3 */
    setbitg(rtcm->buff,i,11,gamn     ); i+=11;
    setbitu(rtcm->buff,i, 3,0        ); i+= 3; /* P,ln */
    setbitg(rtcm->buff,i,22,taun     ); i+=22;
    setbitu(rtcm->buff,i, 5,dtaun    ); i+= 5;
    setbitu(rtcm->buff,i, 5,geph->age); i+= 5; /* En */
    setbitu(rtcm->buff,i, 1,0        ); i+= 1; /* P4 */
    setbitu(rtcm->buff,i, 4,0        ); i+= 4; /* FT */
    setbitu(rtcm->buff,i,11,NT       ); i+=11;
    setbitu(rtcm->buff,i, 2,0        ); i+= 2; /* M */
    setbitu(rtcm->buff,i, 1,0        ); i+= 1; /* flag for addtional data */
    setbitu(rtcm->buff,i,11,0        ); i+=11; /* NA */
    setbitu(rtcm->buff,i,32,0        ); i+=32; /* tauc */
    setbitu(rtcm->buff,i, 5,0        ); i+= 5; /* N4 */
    setbitu(rtcm->buff,i,22,0        ); i+=22; /* taugps */
    setbitu(rtcm->buff,i, 1,0        ); i+= 1; /* ln */
    setbitu(rtcm->buff,i, 7,0        ); i+= 7;
    rtcm->nbit=i;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %esi, %edx
movq %rdi, %rbx
leaq 0x29bb3(%rip), %rsi     # 0x70442
xorl %r15d, %r15d
movl $0x3, %edi
xorl %eax, %eax
callq 0x4ded0
movl 0x9bdd4(%rbx), %edi
leaq -0x3c(%rbp), %rsi
callq 0x4dc2a
cmpl $0x4, %eax
jne 0x46ffd
movq 0x88(%rbx), %r13
movslq -0x3c(%rbp), %rax
imulq $0x98, %rax, %rax
movl -0x98(%r13,%rax), %ecx
cmpl 0x9bdd4(%rbx), %ecx
jne 0x46ffd
addq %rax, %r13
movl -0x90(%r13), %r12d
movq -0x70(%r13), %rdi
movsd -0x68(%r13), %xmm0
callq 0x5034e
movsd 0x241b3(%rip), %xmm1    # 0x6aab0
movq %rax, %rdi
callq 0x4fe63
movq %rax, %r15
movsd %xmm0, -0x38(%rbp)
leaq -0xc0(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x4fa81
movsd (%r14), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x18(%r14), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd 0x20(%r14), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd 0x28(%r14), %xmm0
divsd 0x284fb(%rip), %xmm0    # 0x6ee48
addsd 0x25323(%rip), %xmm0    # 0x6bc78
callq 0x8ad0
movsd %xmm0, -0x48(%rbp)
movsd -0x30(%rbp), %xmm0
mulsd 0x240a4(%rip), %xmm0    # 0x6aa10
callq 0x8ad0
mulsd 0x23f2f(%rip), %xmm0    # 0x6a8a8
movsd %xmm0, (%r14)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x10(%r14)
movq %rax, 0x8(%r14)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%r14)
movq $0x0, 0x28(%r14)
movq %r14, %rdi
callq 0x4f9a4
movapd %xmm0, %xmm1
movq %r15, %rdi
movsd -0x38(%rbp), %xmm0
movq %rax, %rsi
callq 0x4fe97
divsd 0x23f0a(%rip), %xmm0    # 0x6a8d0
addsd 0x22f52(%rip), %xmm0    # 0x69920
callq 0x8ad0
movsd %xmm0, -0x38(%rbp)
movq -0x80(%r13), %rdi
movsd -0x78(%r13), %xmm0
callq 0x5034e
movq %rax, %rdi
movsd 0x240be(%rip), %xmm1    # 0x6aab0
callq 0x4fe63
movq %rax, %rdi
movq %r14, %rsi
callq 0x4fa81
movsd 0x18(%r14), %xmm0
movsd 0x20(%r14), %xmm1
mulsd 0x23ea2(%rip), %xmm1    # 0x6a8b8
mulsd 0x23ea2(%rip), %xmm0    # 0x6a8c0
addsd %xmm1, %xmm0
addsd 0x28(%r14), %xmm0
divsd 0x24088(%rip), %xmm0    # 0x6aab8
addsd 0x25240(%rip), %xmm0    # 0x6bc78
callq 0x8ad0
movsd %xmm0, -0x30(%rbp)
xorl %r14d, %r14d
movsd -0x60(%r13,%r14,2), %xmm0
mulsd 0x26304(%rip), %xmm0    # 0x6cd58
movsd 0x24a1c(%rip), %xmm1    # 0x6b478
divsd %xmm1, %xmm0
movsd 0x25210(%rip), %xmm1    # 0x6bc78
addsd %xmm1, %xmm0
callq 0x8ad0
cvttsd2si %xmm0, %eax
movl %eax, -0x84(%rbp,%r14)
movsd -0x48(%r13,%r14,2), %xmm0
mulsd 0x296bc(%rip), %xmm0    # 0x70148
divsd 0x249e4(%rip), %xmm0    # 0x6b478
addsd 0x251dc(%rip), %xmm0    # 0x6bc78
callq 0x8ad0
cvttsd2si %xmm0, %eax
movl %eax, -0x78(%rbp,%r14)
movsd -0x30(%r13,%r14,2), %xmm0
mulsd 0x29697(%rip), %xmm0    # 0x70150
divsd 0x249b7(%rip), %xmm0    # 0x6b478
addsd 0x251af(%rip), %xmm0    # 0x6bc78
callq 0x8ad0
cvttsd2si %xmm0, %eax
movl %eax, -0x6c(%rbp,%r14)
addq $0x4, %r14
cmpq $0xc, %r14
jne 0x46a45
addl $0x7, %r12d
cvttsd2si -0x58(%rbp), %r15d
cvttsd2si -0x50(%rbp), %eax
movl %eax, -0x5c(%rbp)
cvttsd2si -0x48(%rbp), %eax
movl %eax, -0x60(%rbp)
cvttsd2si -0x38(%rbp), %eax
movl %eax, -0x58(%rbp)
cvttsd2si -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movsd -0x10(%r13), %xmm0
divsd 0x26223(%rip), %xmm0    # 0x6cd40
movsd 0x25153(%rip), %xmm1    # 0x6bc78
addsd %xmm1, %xmm0
callq 0x8ad0
cvttsd2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movsd -0x18(%r13), %xmm0
movsd 0x2960d(%rip), %xmm1    # 0x70150
mulsd %xmm1, %xmm0
addsd 0x25129(%rip), %xmm0    # 0x6bc78
callq 0x8ad0
cvttsd2si %xmm0, %eax
movl %eax, -0x48(%rbp)
movsd 0x295ed(%rip), %xmm0    # 0x70150
mulsd -0x8(%r13), %xmm0
addsd 0x25107(%rip), %xmm0    # 0x6bc78
callq 0x8ad0
cvttsd2si %xmm0, %eax
movl %eax, -0x50(%rbp)
leaq 0x9f0c4(%rbx), %r14
movq %r14, %rdi
movl $0x18, %esi
movl $0xc, %edx
movl $0x3fc, %ecx            # imm = 0x3FC
callq 0x4e403
movl -0x3c(%rbp), %ecx
movq %r14, %rdi
movl $0x24, %esi
movl $0x6, %edx
callq 0x4e403
movq %r14, %rdi
movl $0x2a, %esi
movl $0x5, %edx
movl %r12d, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x2f, %esi
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x33, %esi
movl $0x5, %edx
movl %r15d, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x38, %esi
movl $0x6, %edx
movl -0x5c(%rbp), %ecx
callq 0x4e403
movl $0x1, %r15d
movq %r14, %rdi
movl $0x3e, %esi
movl $0x1, %edx
movl -0x60(%rbp), %ecx
callq 0x4e403
movl -0x8c(%r13), %ecx
movq %r14, %rdi
movl $0x3f, %esi
movl $0x1, %edx
callq 0x4e403
movq %r14, %rdi
movl $0x40, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x41, %esi
movl $0x7, %edx
movl -0x30(%rbp), %ecx
callq 0x4e403
movl -0x78(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0x48, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0x49, %esi
movl $0x17, %edx
callq 0x4e403
movl -0x84(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0x60, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0x61, %esi
movl $0x1a, %edx
callq 0x4e403
movl -0x6c(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0x7b, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0x7c, %esi
movl $0x4, %edx
callq 0x4e403
movl -0x74(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0x80, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0x81, %esi
movl $0x17, %edx
callq 0x4e403
movl -0x80(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0x98, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0x99, %esi
movl $0x1a, %edx
callq 0x4e403
movl -0x68(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0xb3, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0xb4, %esi
movl $0x4, %edx
callq 0x4e403
movl -0x70(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0xb8, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0xb9, %esi
movl $0x17, %edx
callq 0x4e403
movl -0x7c(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0xd0, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0xd1, %esi
movl $0x1a, %edx
callq 0x4e403
movl -0x64(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0xeb, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0xec, %esi
movl $0x4, %edx
callq 0x4e403
movq %r14, %rdi
movl $0xf0, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x4e403
movl -0x38(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0xf1, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0xf2, %esi
movl $0xa, %edx
callq 0x4e403
movq %r14, %rdi
movl $0xfc, %esi
movl $0x3, %edx
xorl %ecx, %ecx
callq 0x4e403
movl -0x48(%rbp), %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
movq %r14, %rdi
movl $0xff, %esi
movl $0x1, %edx
callq 0x4e403
movl %r12d, %ecx
negl %ecx
cmovsl %r12d, %ecx
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0x15, %edx
callq 0x4e403
movq %r14, %rdi
movl $0x115, %esi            # imm = 0x115
movl $0x5, %edx
movl -0x50(%rbp), %ecx
callq 0x4e403
movl -0x84(%r13), %ecx
movq %r14, %rdi
movl $0x11a, %esi            # imm = 0x11A
movl $0x5, %edx
callq 0x4e403
movq %r14, %rdi
movl $0x11f, %esi            # imm = 0x11F
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x120, %esi            # imm = 0x120
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x124, %esi            # imm = 0x124
movl $0xb, %edx
movl -0x58(%rbp), %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x12f, %esi            # imm = 0x12F
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x131, %esi            # imm = 0x131
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x132, %esi            # imm = 0x132
movl $0xb, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x13d, %esi            # imm = 0x13D
movl $0x20, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x15d, %esi            # imm = 0x15D
movl $0x5, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x162, %esi            # imm = 0x162
movl $0x16, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x178, %esi            # imm = 0x178
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x4e403
movq %r14, %rdi
movl $0x179, %esi            # imm = 0x179
movl $0x7, %edx
xorl %ecx, %ecx
callq 0x4e403
movl $0x180, 0x9f0bc(%rbx)   # imm = 0x180
movl %r15d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq