// File: jkingan[P]ladyheather/heathgps.cpp
// Function: rt17_expanded(int)
void rt17_expanded(int rif)
{
int prn;
int flags1, flags2;
int flag_status;
int az, el;
double snr;
double l2_snr;
double prange;
double phase;
double doppler;
int lli;

   // parse expanded format realtine observation info

   prn = tsip_byte();
   flags1 = tsip_byte();
   flags2 = tsip_byte();
   flag_status = tsip_byte();
   el = (int) (s16) tsip_word();
   az = (int) (s16) tsip_word();

   snr = 0.0;
   prange = 0.0;
   phase = 0.0;
   doppler = 0.0;
   lli = 0;

   if(flags1 & 0x40) {  // L1 data
      snr = tsip_double();      // snr
      prange = tsip_double();   // pseudorange
      phase = tsip_double();    // phase
      doppler = tsip_double();  // doppler
      tsip_double();  // rsvd

      if((prn >= 1) && (prn <= 32)) {
         sat[prn].level_msg = 1;
         sat[prn].sig_level = (float) snr;
         have_snr |= rinex_gnss(prn);
         record_sig_levels(prn);

         phase = 0.0-phase;
         sat[prn].code_phase = phase;
         if(phase) {
            have_phase |= rinex_gnss(prn);
         }

         sat[prn].range = prange;
         if(prange) {
            have_range |= rinex_gnss(prn);
         }

         sat[prn].doppler = doppler;
         if(doppler) {
            have_doppler |= rinex_gnss(prn);
         }

         lli = 0;
         if(prange && (flags1 & 0x02)) lli |= CYCLE_SLIP;
         sat[prn].ca_lli = lli;
      }
sprintf(out, "  prn:%02d l1: snr:%f  phase:%f  range:%f  doppler:%f  flags1:%02X  flags2:%02X  lli:%02X", prn, snr, phase, prange, doppler, flags1,flags2, lli);
if(debug_file) fprintf(debug_file, "%s\n", out);
   }

   l2_snr = 0.0;
   prange = 0.0;
   phase = 0.0;
   doppler = 0.0;

   if(flags1 & 0x01) {  // L2 data
      l2_snr = tsip_double();  // snr
      phase = tsip_double();   // phase
      prange = tsip_double();  // pseudorange

      if((prn >= 1) && (prn <= 32)) {
         sat[prn].l2_sig_level = (float) l2_snr;
         sat[prn].l2_level_msg = 17;
         have_l2_snr |= rinex_gnss(prn);

         if(flags1 & 0x10) phase = 0.0-phase;
         else phase = 0.0;

         if(flags1 & 0x20) prange = sat[prn].range + prange;
         else {
            prange = 0.0;
            phase = 0.0-sqrt(fabs(phase));
         }

         sat[prn].l2_code_phase = phase;
         if(phase) {
            have_l2_phase |= rinex_gnss(prn);
         }

         sat[prn].l2_range = prange;
         if(prange) {
            have_l2_range |= rinex_gnss(prn);
         }

         lli = 0;
         if(prange && (flags1 & 0x04)) lli |= CYCLE_SLIP;
         if(prange && (flags2 & 0x04)) lli |= P_TRACK;  // tracking encrypted code
         sat[prn].l2_lli = lli;
      }
   }

   if(rif & 0x02) {  // expanded format
      tsip_byte();    // iode
      tsip_byte();    // L1 slip counter
      tsip_byte();    // L2 slip counter
      tsip_byte();    // rsvd
      doppler = tsip_double();  // L2 doppler
      if((prn >= 1) && (prn <= 32)) {
         sat[prn].l2_doppler = doppler;
         if(doppler) {
            have_l2_doppler |= rinex_gnss(prn);
         }
      }
   }

   if((prn >= 1) && (prn <= 32)) {
      set_sat_azel(prn, (float) az, (float) el);
      if(snr > 0) sat[prn].tracking = prn;
      else        sat[prn].tracking = (-1);
      have_sat_azel = 17;
   }

sprintf(out, "  prn:%02d l2: snr:%f  phase:%f  range:%f  doppler:%f  flags1:%02X  flags2:%02X  lli:%02X", prn, l2_snr, phase, prange, doppler, flags1,flags2, lli);
if(debug_file) fprintf(debug_file, "%s\n", out);

   return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0x8(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0xc(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0x10(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0x14(%rbp)
callq 0x7a560
cwtl
movl %eax, -0x1c(%rbp)
callq 0x7a560
cwtl
movl %eax, -0x18(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0xc(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xaf954
callq 0x7a9d0
movsd %xmm0, -0x28(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x38(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x40(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x48(%rbp)
callq 0x7a9d0
cmpl $0x1, -0x8(%rbp)
jl 0xaf8ef
cmpl $0x20, -0x8(%rbp)
jg 0xaf8ef
movslq -0x8(%rbp), %rcx
leaq 0x1eea35(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x1, 0x1c(%rax)
movsd -0x28(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x1eea10(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movss %xmm0, 0x20(%rax)
movl -0x8(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2bcd8c(%rip), %rax    # 0x36c52c
orl (%rax), %ecx
leaq 0x2bcd83(%rip), %rax    # 0x36c52c
movl %ecx, (%rax)
movl -0x8(%rbp), %edi
callq 0x80340
xorps %xmm0, %xmm0
subsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x1ee9c0(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x28(%rax)
movsd -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaf7f1
jp 0xaf7f1
jmp 0xaf80d
movl -0x8(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2bcd22(%rip), %rax    # 0x36c524
orl (%rax), %ecx
leaq 0x2bcd19(%rip), %rax    # 0x36c524
movl %ecx, (%rax)
movsd -0x38(%rbp), %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x1ee973(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x38(%rax)
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaf83e
jp 0xaf83e
jmp 0xaf85a
movl -0x8(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2bccd9(%rip), %rax    # 0x36c528
orl (%rax), %ecx
leaq 0x2bccd0(%rip), %rax    # 0x36c528
movl %ecx, (%rax)
movsd -0x48(%rbp), %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x1ee926(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x30(%rax)
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaf88b
jp 0xaf88b
jmp 0xaf8a7
movl -0x8(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2bcc84(%rip), %rax    # 0x36c520
orl (%rax), %ecx
leaq 0x2bcc7b(%rip), %rax    # 0x36c520
movl %ecx, (%rax)
movl $0x0, -0x4c(%rbp)
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xaf8c0
jp 0xaf8c0
jmp 0xaf8d4
movl -0xc(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xaf8d4
movl -0x4c(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %ecx
movslq -0x8(%rbp), %rdx
leaq 0x1ee8ae(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x68(%rax)
movl -0x8(%rbp), %edx
movsd -0x28(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x48(%rbp), %xmm3
movl -0xc(%rbp), %ecx
movl -0x10(%rbp), %r8d
movl -0x4c(%rbp), %r9d
leaq 0x2ebae8(%rip), %rdi    # 0x39b400
leaq 0xd65bc(%rip), %rsi     # 0x185edb
movb $0x4, %al
callq 0x9060
leaq 0x1edc43(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xaf952
leaq 0x1edc36(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0xd94bb(%rip), %rsi     # 0x188dff
leaq 0x2ebab5(%rip), %rdx    # 0x39b400
movb $0x0, %al
callq 0x9550
jmp 0xaf954
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0xc(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xafba8
callq 0x7a9d0
movsd %xmm0, -0x30(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x40(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x38(%rbp)
cmpl $0x1, -0x8(%rbp)
jl 0xafba6
cmpl $0x20, -0x8(%rbp)
jg 0xafba6
movsd -0x30(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x1ee7c7(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movss %xmm0, 0xb0(%rax)
movslq -0x8(%rbp), %rcx
leaq 0x1ee7aa(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x11, 0xac(%rax)
movl -0x8(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2bcb41(%rip), %rax    # 0x36c54c
orl (%rax), %ecx
leaq 0x2bcb38(%rip), %rax    # 0x36c54c
movl %ecx, (%rax)
movl -0xc(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xafa30
xorps %xmm0, %xmm0
subsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0xafa38
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0xc(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0xafa69
movslq -0x8(%rbp), %rcx
leaq 0x1ee742(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd 0x38(%rax), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0xafa95
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
movaps 0xbf813(%rip), %xmm1    # 0x16f290
pand %xmm1, %xmm0
callq 0x9280
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x1ee6eb(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0xb8(%rax)
movsd -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xafac9
jp 0xafac9
jmp 0xafae5
movl -0x8(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2bca6a(%rip), %rax    # 0x36c544
orl (%rax), %ecx
leaq 0x2bca61(%rip), %rax    # 0x36c544
movl %ecx, (%rax)
movsd -0x38(%rbp), %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x1ee69b(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0xc8(%rax)
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xafb19
jp 0xafb19
jmp 0xafb35
movl -0x8(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2bca1e(%rip), %rax    # 0x36c548
orl (%rax), %ecx
leaq 0x2bca15(%rip), %rax    # 0x36c548
movl %ecx, (%rax)
movl $0x0, -0x4c(%rbp)
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xafb4e
jp 0xafb4e
jmp 0xafb62
movl -0xc(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xafb62
movl -0x4c(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x4c(%rbp)
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xafb74
jp 0xafb74
jmp 0xafb88
movl -0x10(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xafb88
movl -0x4c(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %ecx
movslq -0x8(%rbp), %rdx
leaq 0x1ee5fa(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0xe8(%rax)
jmp 0xafba8
movl -0x4(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xafc31
callq 0x7a510
callq 0x7a510
callq 0x7a510
callq 0x7a510
callq 0x7a9d0
movsd %xmm0, -0x48(%rbp)
cmpl $0x1, -0x8(%rbp)
jl 0xafc2f
cmpl $0x20, -0x8(%rbp)
jg 0xafc2f
movsd -0x48(%rbp), %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x1ee5a3(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0xc0(%rax)
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xafc11
jp 0xafc11
jmp 0xafc2d
movl -0x8(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2bc91e(%rip), %rax    # 0x36c540
orl (%rax), %ecx
leaq 0x2bc915(%rip), %rax    # 0x36c540
movl %ecx, (%rax)
jmp 0xafc2f
jmp 0xafc31
cmpl $0x1, -0x8(%rbp)
jl 0xafca9
cmpl $0x20, -0x8(%rbp)
jg 0xafca9
movl -0x8(%rbp), %edi
cvtsi2ssl -0x18(%rbp), %xmm0
cvtsi2ssl -0x1c(%rbp), %xmm1
callq 0x7d450
movsd -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xafc7d
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdx
leaq 0x1ee525(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x218(%rax)
jmp 0xafc9c
movslq -0x8(%rbp), %rcx
leaq 0x1ee508(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0xffffffff, 0x218(%rax) # imm = 0xFFFFFFFF
leaq 0x2bc7d1(%rip), %rax    # 0x36c474
movl $0x11, (%rax)
movl -0x8(%rbp), %edx
movsd -0x30(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x48(%rbp), %xmm3
movl -0xc(%rbp), %ecx
movl -0x10(%rbp), %r8d
movl -0x4c(%rbp), %r9d
leaq 0x2eb72e(%rip), %rdi    # 0x39b400
leaq 0xd625c(%rip), %rsi     # 0x185f35
movb $0x4, %al
callq 0x9060
leaq 0x1ed889(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xafd0c
leaq 0x1ed87c(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0xd9101(%rip), %rsi     # 0x188dff
leaq 0x2eb6fb(%rip), %rdx    # 0x39b400
movb $0x0, %al
callq 0x9550
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)