// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rcvraw.cpp
// Function: bamboo::decode_almanac(unsigned char const*, int, bamboo::alm_t*)
static void decode_almanac(const unsigned char *buff, int sat, alm_t *alm)
{
    gtime_t toa;
    double deltai,sqrtA,tt;
    int i=50,f0;
    
    trace(4,"decode_almanac: sat=%2d\n",sat);
    
    if (!alm||alm[sat-1].week==0) return;
    
    alm[sat-1].sat =sat;
    alm[sat-1].e   =getbits(buff,i,16)*P2_21;        i+=16;
    alm[sat-1].toas=getbitu(buff,i, 8)*4096.0;       i+= 8;
    deltai         =getbits(buff,i,16)*P2_19*SC2RAD; i+=16;
    alm[sat-1].OMGd=getbits(buff,i,16)*P2_38*SC2RAD; i+=16;
    alm[sat-1].svh =getbitu(buff,i, 8);              i+= 8;
    sqrtA          =getbitu(buff,i,24)*P2_11;        i+=24;
    alm[sat-1].OMG0=getbits(buff,i,24)*P2_23*SC2RAD; i+=24;
    alm[sat-1].omg =getbits(buff,i,24)*P2_23*SC2RAD; i+=24;
    alm[sat-1].M0  =getbits(buff,i,24)*P2_23*SC2RAD; i+=24;
    f0             =getbitu(buff,i, 8);              i+= 8;
    alm[sat-1].f1  =getbits(buff,i,11)*P2_38;        i+=11;
    alm[sat-1].f0  =getbits(buff,i, 3)*P2_17+f0*P2_20;
    alm[sat-1].A   =sqrtA*sqrtA;
    alm[sat-1].i0  =0.3*SC2RAD+deltai;
    
    toa=gpst2time(alm[sat-1].week,alm[sat-1].toas);
    tt=timediff(toa,alm[sat-1].toa);
    if      (tt<302400.0) alm[sat-1].week--;
    else if (tt>302400.0) alm[sat-1].week++;
    alm[sat-1].toa=gpst2time(alm[sat-1].week,alm[sat-1].toas);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %r14
leaq 0x35db1(%rip), %rsi     # 0x6d2b4
movl $0x4, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x4ded0
testq %rbx, %rbx
je 0x3778f
movslq %r15d, %rax
imulq $0x70, %rax, %rax
cmpl $0x0, -0x64(%rbx,%rax)
je 0x3778f
addq %rax, %rbx
movl %r15d, -0x70(%rbx)
movq %r14, %rdi
movl $0x32, %esi
movl $0x10, %edx
callq 0x4e390
cvtsi2sd %eax, %xmm0
mulsd 0x35836(%rip), %xmm0    # 0x6cd88
movsd %xmm0, -0x48(%rbx)
movq %r14, %rdi
movl $0x42, %esi
movl $0x8, %edx
callq 0x4e341
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x357f5(%rip), %xmm0    # 0x6cd70
movsd %xmm0, -0x18(%rbx)
movq %r14, %rdi
movl $0x4a, %esi
movl $0x10, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x35727(%rip), %xmm0    # 0x6ccc8
mulsd 0x347ff(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x28(%rbp)
movq %r14, %rdi
movl $0x5a, %esi
movl $0x10, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x357c1(%rip), %xmm0    # 0x6cd90
mulsd 0x347d1(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x20(%rbx)
movq %r14, %rdi
movl $0x6a, %esi
movl $0x8, %edx
callq 0x4e341
movl %eax, -0x6c(%rbx)
movq %r14, %rdi
movl $0x72, %esi
movl $0x18, %edx
callq 0x4e341
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x35723(%rip), %xmm0    # 0x6cd38
movsd %xmm0, -0x20(%rbp)
movq %r14, %rdi
movl $0x8a, %esi
movl $0x18, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x3575d(%rip), %xmm0    # 0x6cd98
mulsd 0x34765(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x38(%rbx)
movq %r14, %rdi
movl $0xa2, %esi
movl $0x18, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x3572f(%rip), %xmm0    # 0x6cd98
mulsd 0x34737(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x30(%rbx)
movq %r14, %rdi
movl $0xba, %esi
movl $0x18, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x35701(%rip), %xmm0    # 0x6cd98
mulsd 0x34709(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x28(%rbx)
movq %r14, %rdi
movl $0xd2, %esi
movl $0x8, %edx
callq 0x4e341
movl %eax, %r15d
movq %r14, %rdi
movl $0xda, %esi
movl $0xb, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x356b6(%rip), %xmm0    # 0x6cd90
movsd %xmm0, -0x8(%rbx)
movq %r14, %rdi
movl $0xe5, %esi
movl $0x3, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cvtsi2sd %r15d, %xmm1
mulsd 0x35623(%rip), %xmm1    # 0x6cd28
mulsd 0x35693(%rip), %xmm0    # 0x6cda0
addsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbx)
movsd -0x20(%rbp), %xmm1
mulsd %xmm1, %xmm1
movsd -0x28(%rbp), %xmm0
addsd 0x3567c(%rip), %xmm0    # 0x6cda8
movsd %xmm1, -0x50(%rbx)
movsd %xmm0, -0x40(%rbx)
movl -0x64(%rbx), %edi
movsd -0x18(%rbx), %xmm0
callq 0x4fbc6
movq -0x60(%rbx), %rsi
movsd -0x58(%rbx), %xmm1
movq %rax, %rdi
callq 0x4fe97
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movsd 0x34677(%rip), %xmm1    # 0x6bdd8
ucomisd %xmm0, %xmm1
ja 0x37776
movl $0x1, %eax
ucomisd 0x34664(%rip), %xmm0    # 0x6bdd8
jbe 0x37779
addl %eax, -0x64(%rbx)
movl -0x64(%rbx), %edi
movsd -0x18(%rbx), %xmm0
callq 0x4fbc6
movq %rax, -0x60(%rbx)
movsd %xmm0, -0x58(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop