// File: /workspace/github_cpp_makefile_star2_O3/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 0x363fc(%rip), %rsi     # 0x6d2b4
movl $0x4, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x4d55d
testq %rbx, %rbx
je 0x37143
movslq %r15d, %rax
imulq $0x70, %rax, %rax
cmpl $0x0, -0x64(%rbx,%rax)
je 0x37143
addq %rax, %rbx
movl %r15d, -0x70(%rbx)
movq %r14, %rdi
movl $0x32, %esi
movl $0x10, %edx
callq 0x4da25
cvtsi2sd %eax, %xmm0
mulsd 0x35e81(%rip), %xmm0    # 0x6cd88
movsd %xmm0, -0x48(%rbx)
movq %r14, %rdi
movl $0x42, %esi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x35e40(%rip), %xmm0    # 0x6cd70
movsd %xmm0, -0x18(%rbx)
movq %r14, %rdi
movl $0x4a, %esi
movl $0x10, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x35d72(%rip), %xmm0    # 0x6ccc8
mulsd 0x34e4a(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x28(%rbp)
movq %r14, %rdi
movl $0x5a, %esi
movl $0x10, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x35e0c(%rip), %xmm0    # 0x6cd90
mulsd 0x34e1c(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x20(%rbx)
movq %r14, %rdi
movl $0x6a, %esi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, -0x6c(%rbx)
movq %r14, %rdi
movl $0x72, %esi
movl $0x18, %edx
callq 0x4d9d6
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x35d6e(%rip), %xmm0    # 0x6cd38
movsd %xmm0, -0x20(%rbp)
movq %r14, %rdi
movl $0x8a, %esi
movl $0x18, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x35da8(%rip), %xmm0    # 0x6cd98
mulsd 0x34db0(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x38(%rbx)
movq %r14, %rdi
movl $0xa2, %esi
movl $0x18, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x35d7a(%rip), %xmm0    # 0x6cd98
mulsd 0x34d82(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x30(%rbx)
movq %r14, %rdi
movl $0xba, %esi
movl $0x18, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x35d4c(%rip), %xmm0    # 0x6cd98
mulsd 0x34d54(%rip), %xmm0    # 0x6bda8
movsd %xmm0, -0x28(%rbx)
movq %r14, %rdi
movl $0xd2, %esi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, %r15d
movq %r14, %rdi
movl $0xda, %esi
movl $0xb, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x35d01(%rip), %xmm0    # 0x6cd90
movsd %xmm0, -0x8(%rbx)
movq %r14, %rdi
movl $0xe5, %esi
movl $0x3, %edx
callq 0x4da25
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cvtsi2sd %r15d, %xmm1
mulsd 0x35c6e(%rip), %xmm1    # 0x6cd28
mulsd 0x35cde(%rip), %xmm0    # 0x6cda0
addsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbx)
movsd -0x20(%rbp), %xmm1
mulsd %xmm1, %xmm1
movsd -0x28(%rbp), %xmm0
addsd 0x35cc7(%rip), %xmm0    # 0x6cda8
movsd %xmm1, -0x50(%rbx)
movsd %xmm0, -0x40(%rbx)
movl -0x64(%rbx), %edi
movsd -0x18(%rbx), %xmm0
callq 0x4f24a
movq -0x60(%rbx), %rsi
movsd -0x58(%rbx), %xmm1
movq %rax, %rdi
callq 0x4f51b
movsd 0x34cc7(%rip), %xmm1    # 0x6bdd8
ucomisd %xmm0, %xmm1
jbe 0x3711e
movl -0x64(%rbx), %edi
decl %edi
jmp 0x3712d
ucomisd 0x34cb2(%rip), %xmm0    # 0x6bdd8
movl -0x64(%rbx), %edi
jbe 0x37130
incl %edi
movl %edi, -0x64(%rbx)
movsd -0x18(%rbx), %xmm0
callq 0x4f24a
movq %rax, -0x60(%rbx)
movsd %xmm0, -0x58(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop