// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %r14
leaq 0x324f8(%rip), %rsi     # 0x632b4
pushq $0x4
popq %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x455bc
testq %rbx, %rbx
je 0x31012
movslq %r15d, %rax
imulq $0x70, %rax, %rax
cmpl $0x0, -0x64(%rbx,%rax)
je 0x31012
addq %rax, %rbx
movl %r15d, -0x70(%rbx)
pushq $0x32
popq %rsi
pushq $0x10
popq %r12
movq %r14, %rdi
movl %r12d, %edx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x31f7f(%rip), %xmm0    # 0x62d88
movsd %xmm0, -0x48(%rbx)
pushq $0x42
popq %rsi
pushq $0x8
popq %r15
movq %r14, %rdi
movl %r15d, %edx
callq 0x459f7
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x31f41(%rip), %xmm0    # 0x62d70
movsd %xmm0, -0x18(%rbx)
pushq $0x4a
popq %rsi
movq %r14, %rdi
movl %r12d, %edx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x31e7a(%rip), %xmm0    # 0x62cc8
mulsd 0x30f52(%rip), %xmm0    # 0x61da8
movsd %xmm0, -0x30(%rbp)
pushq $0x5a
popq %rsi
movq %r14, %rdi
movl %r12d, %edx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x31f1b(%rip), %xmm0    # 0x62d90
mulsd 0x30f2b(%rip), %xmm0    # 0x61da8
movsd %xmm0, -0x20(%rbx)
pushq $0x6a
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
callq 0x459f7
movl %eax, -0x6c(%rbx)
pushq $0x72
popq %rsi
pushq $0x18
popq %r12
movq %r14, %rdi
movl %r12d, %edx
callq 0x459f7
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x31e84(%rip), %xmm0    # 0x62d38
movsd %xmm0, -0x28(%rbp)
movq %r14, %rdi
movl $0x8a, %esi
movl %r12d, %edx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x31ec3(%rip), %xmm0    # 0x62d98
mulsd 0x30ecb(%rip), %xmm0    # 0x61da8
movsd %xmm0, -0x38(%rbx)
movq %r14, %rdi
movl $0xa2, %esi
movl %r12d, %edx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x31e9a(%rip), %xmm0    # 0x62d98
mulsd 0x30ea2(%rip), %xmm0    # 0x61da8
movsd %xmm0, -0x30(%rbx)
movq %r14, %rdi
movl $0xba, %esi
movl %r12d, %edx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x31e71(%rip), %xmm0    # 0x62d98
mulsd 0x30e79(%rip), %xmm0    # 0x61da8
movsd %xmm0, -0x28(%rbx)
movq %r14, %rdi
movl $0xd2, %esi
movl %r15d, %edx
callq 0x459f7
movl %eax, %r15d
pushq $0xb
popq %rdx
movq %r14, %rdi
movl $0xda, %esi
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x31e2d(%rip), %xmm0    # 0x62d90
movsd %xmm0, -0x8(%rbx)
pushq $0x3
popq %rdx
movq %r14, %rdi
movl $0xe5, %esi
callq 0x45a39
cvtsi2sd %eax, %xmm0
cvtsi2sd %r15d, %xmm1
mulsd 0x31d9f(%rip), %xmm1    # 0x62d28
mulsd 0x31e0f(%rip), %xmm0    # 0x62da0
addsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbx)
movsd -0x28(%rbp), %xmm1
mulsd %xmm1, %xmm1
movsd -0x30(%rbp), %xmm0
addsd 0x31df8(%rip), %xmm0    # 0x62da8
movsd %xmm1, -0x50(%rbx)
movsd %xmm0, -0x40(%rbx)
movl -0x64(%rbx), %edi
movsd -0x18(%rbx), %xmm0
callq 0x4708a
movq -0x60(%rbx), %rsi
movsd -0x58(%rbx), %xmm1
movq %rax, %rdi
callq 0x47322
movsd 0x30de8(%rip), %xmm1    # 0x61dc8
ucomisd %xmm0, %xmm1
jbe 0x30fed
movl -0x64(%rbx), %edi
decl %edi
jmp 0x30ffc
ucomisd 0x30dd3(%rip), %xmm0    # 0x61dc8
movl -0x64(%rbx), %edi
jbe 0x30fff
incl %edi
movl %edi, -0x64(%rbx)
movsd -0x18(%rbx), %xmm0
callq 0x4708a
movq %rax, -0x60(%rbx)
movsd %xmm0, -0x58(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop