// File: 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
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x32, -0x44(%rbp)
movl -0xc(%rbp), %edx
movl $0x4, %edi
leaq 0x57d68(%rip), %rsi     # 0xbf414
movb $0x0, %al
callq 0x8b980
cmpq $0x0, -0x18(%rbp)
je 0x676d4
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jne 0x676d9
jmp 0x67bbc
movl -0xc(%rbp), %edx
movq -0x18(%rbp), %rax
movl %edx, %ecx
decl %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
movl %edx, (%rax,%rcx)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0x10, %edx
movl %edx, -0x9c(%rbp)
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x577e7(%rip), %xmm1    # 0xbeef8
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
movsd %xmm0, 0x28(%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0x8, %edx
movl %edx, -0x8c(%rbp)
callq 0x8bfc0
movl -0x9c(%rbp), %edx
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0x577a0(%rip), %xmm1    # 0xbef00
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
movsd %xmm0, 0x58(%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x8c050
movl -0x9c(%rbp), %edx
cvtsi2sd %eax, %xmm0
movsd 0x5583f(%rip), %xmm1    # 0xbcfe0
mulsd %xmm1, %xmm0
movsd 0x565ab(%rip), %xmm1    # 0xbdd58
movsd %xmm1, -0x98(%rbp)
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x44(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x8c050
movsd -0x98(%rbp), %xmm1
movl -0x8c(%rbp), %edx
cvtsi2sd %eax, %xmm0
movsd 0x576fb(%rip), %xmm2    # 0xbeee8
mulsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
movsd %xmm0, 0x50(%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x8bfc0
movl %eax, %edx
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
movl %edx, 0x4(%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0x18, %edx
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0x57639(%rip), %xmm1    # 0xbee98
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x44(%rbp), %eax
addl $0x18, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0x18, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x57662(%rip), %xmm1    # 0xbeef0
mulsd %xmm1, %xmm0
movsd 0x564be(%rip), %xmm1    # 0xbdd58
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x38(%rax)
movl -0x44(%rbp), %eax
addl $0x18, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0x18, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x57613(%rip), %xmm1    # 0xbeef0
mulsd %xmm1, %xmm0
movsd 0x5646f(%rip), %xmm1    # 0xbdd58
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x40(%rax)
movl -0x44(%rbp), %eax
addl $0x18, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0x18, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x575c4(%rip), %xmm1    # 0xbeef0
mulsd %xmm1, %xmm0
movsd 0x56420(%rip), %xmm1    # 0xbdd58
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x48(%rax)
movl -0x44(%rbp), %eax
addl $0x18, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0x8, %edx
callq 0x8bfc0
movl %eax, -0x48(%rbp)
movl -0x44(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0xb, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x57550(%rip), %xmm1    # 0xbeee8
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x68(%rax)
movl -0x44(%rbp), %eax
addl $0xb, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl $0x3, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
cvtsi2sdl -0x48(%rbp), %xmm1
movsd 0x574c0(%rip), %xmm2    # 0xbeea0
mulsd %xmm2, %xmm1
movsd 0x574f4(%rip), %xmm2    # 0xbeee0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x60(%rax)
movsd -0x38(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
movsd 0x574a0(%rip), %xmm0    # 0xbeed8
addsd -0x30(%rbp), %xmm0
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x30(%rax)
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %edi
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x58(%rax), %xmm0
callq 0x8e4a0
movq %rax, -0x58(%rbp)
movsd %xmm0, -0x50(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x78(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
movsd -0x60(%rbp), %xmm0
movq -0x78(%rbp), %rsi
movsd -0x70(%rbp), %xmm1
callq 0x8e8e0
movsd %xmm0, -0x40(%rbp)
movsd 0x56264(%rip), %xmm0    # 0xbdd60
ucomisd -0x40(%rbp), %xmm0
jbe 0x67b22
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x67b54
movsd -0x40(%rbp), %xmm0
movsd 0x56231(%rip), %xmm1    # 0xbdd60
ucomisd %xmm1, %xmm0
jbe 0x67b52
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x67b54
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %edi
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movsd 0x58(%rax), %xmm0
callq 0x8e4a0
movq %rax, -0x88(%rbp)
movsd %xmm0, -0x80(%rbp)
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq -0x88(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x80(%rbp), %rcx
movq %rcx, 0x18(%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)