// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_tsip_ephem(int, int)
void parse_tsip_ephem(int prn, int len)
{
   // decode the satellite ephemeris message
   prn = tsip_byte();

   if(prn < 1) return;
   if(prn > 32) return;

   sat[prn].t_ephem = (double) tsip_single();
//sprintf(debug_text, "prn:%d  len:%d  flag:%02X  t_ephm:%.9f  polled:%08lX", prn,len, sat[prn].eph_flag, sat[prn].t_ephem, eph_polled);
//if(debug_file) fprintf(debug_file, "prn:%d  len:%d  flag:%02X  t_ephm:%.9f\n", prn,len, sat[prn].eph_flag, sat[prn].t_ephem);

   sat[prn].eph_week = tsip_word();   // !!!!! we need to fix for rollover !!!!!
   sat[prn].codeL2 = tsip_byte();   
   sat[prn].L2Pdata = tsip_byte();  
   sat[prn].sv_accu_raw = tsip_byte();
   sat[prn].sv_health = tsip_byte();
   sat[prn].iodc = tsip_word(); 
   sat[prn].tGD = (double) tsip_single();
check_eph_val(1, prn);
   sat[prn].toc = (double) tsip_single();
check_eph_val(2, prn);
   sat[prn].af2 = (double) tsip_single();
check_eph_val(3, prn);
   sat[prn].af1 = (double) tsip_single();
check_eph_val(4, prn);
   sat[prn].af0 = (double) tsip_single();
check_eph_val(5, prn);
   sat[prn].eph_sv_accu = (double) tsip_single();
check_eph_val(6, prn);
   sat[prn].eph_iode = tsip_byte();
check_eph_val(7, prn);
   sat[prn].fit_interval = tsip_byte();
check_eph_val(8, prn);
   sat[prn].Crs = (double) tsip_single();
check_eph_val(9, prn);
   sat[prn].delta_n = (double) tsip_single();
check_eph_val(10, prn);
   sat[prn].M0 = tsip_double();
check_eph_val(11, prn);
   sat[prn].Cuc = (double) tsip_single();
check_eph_val(12, prn);
   sat[prn].e = tsip_double();
check_eph_val(13, prn);
   sat[prn].Cus = (double) tsip_single();
check_eph_val(14, prn);
   sat[prn].sqrtA = tsip_double();
check_eph_val(15, prn);
   sat[prn].eph_toe = (double) tsip_single();
check_eph_val(16, prn);
   sat[prn].Cic = (double) tsip_single();
check_eph_val(17, prn);
   sat[prn].omega_0 = tsip_double();
check_eph_val(18, prn);
   sat[prn].Cis = (double) tsip_single();
check_eph_val(19, prn);
   sat[prn].io = tsip_double(); 
check_eph_val(20, prn);
   sat[prn].Crc = (double) tsip_single();
check_eph_val(21, prn);
   sat[prn].omega = tsip_double();
check_eph_val(22, prn);
   sat[prn].omega_dot = (double) tsip_single();
check_eph_val(23, prn);
   sat[prn].i_dot = (double) tsip_single();
check_eph_val(24, prn);
   sat[prn].axis = tsip_double(); // sqrt(A)2
check_eph_val(25, prn);
   sat[prn].n = tsip_double();
check_eph_val(26, prn);
   sat[prn].r1me2 = tsip_double();
check_eph_val(27, prn);
   sat[prn].omega_n = tsip_double();
check_eph_val(28, prn);
   sat[prn].odot_n = tsip_double();
check_eph_val(29, prn);

   sat[prn].eph_valid = 1;
   if(tsip_error) sat[prn].eph_valid = 0;
   if(sat[prn].t_ephem < 0.0) sat[prn].eph_valid = 0;
   if(sat[prn].sqrtA == 0.0)  sat[prn].eph_valid = 0;  // missing ephem will have 0.0 sqrtA
if(0 && log_file) fprintf(log_file, "#t_ephem: %f\n", sat[prn].t_ephem);

//sprintf(debug_text2, "omega_0: %.9f", sat[prn].omega_0); 
//if(debug_file) fprintf(debug_file, "omega_0:%.9f\n", sat[prn].omega_0); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0x4(%rbp)
cmpl $0x1, -0x4(%rbp)
jge 0x9ddf4
jmp 0x9e55e
cmpl $0x20, -0x4(%rbp)
jle 0x9ddff
jmp 0x9e55e
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x20037d(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x248(%rax)
callq 0x7a560
movzwl %ax, %ecx
movslq -0x4(%rbp), %rdx
leaq 0x200358(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x250(%rax)
callq 0x7a510
movzbl %al, %ecx
movslq -0x4(%rbp), %rdx
leaq 0x200335(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x254(%rax)
callq 0x7a510
movzbl %al, %ecx
movslq -0x4(%rbp), %rdx
leaq 0x200312(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x258(%rax)
callq 0x7a510
movzbl %al, %ecx
movslq -0x4(%rbp), %rdx
leaq 0x2002ef(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x25c(%rax)
callq 0x7a510
movzbl %al, %ecx
movslq -0x4(%rbp), %rdx
leaq 0x2002cc(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x260(%rax)
callq 0x7a560
movzwl %ax, %ecx
movslq -0x4(%rbp), %rdx
leaq 0x2002a9(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x264(%rax)
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x200285(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x268(%rax)
movl -0x4(%rbp), %esi
movl $0x1, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x200252(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x270(%rax)
movl -0x4(%rbp), %esi
movl $0x2, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x20021f(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x278(%rax)
movl -0x4(%rbp), %esi
movl $0x3, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x2001ec(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x280(%rax)
movl -0x4(%rbp), %esi
movl $0x4, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x2001b9(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x288(%rax)
movl -0x4(%rbp), %esi
movl $0x5, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x200186(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x290(%rax)
movl -0x4(%rbp), %esi
movl $0x6, %edi
callq 0x9ddc0
callq 0x7a510
movzbl %al, %ecx
movslq -0x4(%rbp), %rdx
leaq 0x200154(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x298(%rax)
movl -0x4(%rbp), %esi
movl $0x7, %edi
callq 0x9ddc0
callq 0x7a510
movzbl %al, %ecx
movslq -0x4(%rbp), %rdx
leaq 0x200124(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x29c(%rax)
movl -0x4(%rbp), %esi
movl $0x8, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x2000f3(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2a0(%rax)
movl -0x4(%rbp), %esi
movl $0x9, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x2000c0(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2a8(%rax)
movl -0x4(%rbp), %esi
movl $0xa, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x200091(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2b0(%rax)
movl -0x4(%rbp), %esi
movl $0xb, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x20005e(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2b8(%rax)
movl -0x4(%rbp), %esi
movl $0xc, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x20002f(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2c0(%rax)
movl -0x4(%rbp), %esi
movl $0xd, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ffffc(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2c8(%rax)
movl -0x4(%rbp), %esi
movl $0xe, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x1fffcd(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2d0(%rax)
movl -0x4(%rbp), %esi
movl $0xf, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1fff9a(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2d8(%rax)
movl -0x4(%rbp), %esi
movl $0x10, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1fff67(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2e0(%rax)
movl -0x4(%rbp), %esi
movl $0x11, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x1fff38(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2e8(%rax)
movl -0x4(%rbp), %esi
movl $0x12, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1fff05(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2f0(%rax)
movl -0x4(%rbp), %esi
movl $0x13, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x1ffed6(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x2f8(%rax)
movl -0x4(%rbp), %esi
movl $0x14, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ffea3(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x300(%rax)
movl -0x4(%rbp), %esi
movl $0x15, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x1ffe74(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x308(%rax)
movl -0x4(%rbp), %esi
movl $0x16, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ffe41(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x310(%rax)
movl -0x4(%rbp), %esi
movl $0x17, %edi
callq 0x9ddc0
callq 0x7a860
cvtss2sd %xmm0, %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1ffe0e(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x318(%rax)
movl -0x4(%rbp), %esi
movl $0x18, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x1ffddf(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x320(%rax)
movl -0x4(%rbp), %esi
movl $0x19, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x1ffdb0(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x328(%rax)
movl -0x4(%rbp), %esi
movl $0x1a, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x1ffd81(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x330(%rax)
movl -0x4(%rbp), %esi
movl $0x1b, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x1ffd52(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x338(%rax)
movl -0x4(%rbp), %esi
movl $0x1c, %edi
callq 0x9ddc0
callq 0x7a9d0
movslq -0x4(%rbp), %rcx
leaq 0x1ffd23(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x340(%rax)
movl -0x4(%rbp), %esi
movl $0x1d, %edi
callq 0x9ddc0
movslq -0x4(%rbp), %rcx
leaq 0x1ffcf9(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x1, 0x244(%rax)
leaq 0x1ffc9e(%rip), %rax    # 0x29e150
cmpl $0x0, (%rax)
je 0x9e4d6
movslq -0x4(%rbp), %rcx
leaq 0x1ffcce(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x0, 0x244(%rax)
movslq -0x4(%rbp), %rcx
leaq 0x1ffcaf(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
xorps %xmm0, %xmm0
ucomisd 0x248(%rax), %xmm0
jbe 0x9e517
movslq -0x4(%rbp), %rcx
leaq 0x1ffc8d(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x0, 0x244(%rax)
movslq -0x4(%rbp), %rcx
leaq 0x1ffc6e(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x2d0(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x9e55e
jp 0x9e55e
movslq -0x4(%rbp), %rcx
leaq 0x1ffc46(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x0, 0x244(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)