// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edi, -0x68(%rbp)
callq 0x587be
movl %eax, %r12d
cmpl $0x100, %eax            # imm = 0x100
jb 0x7ff15
leaq 0x1bf05e(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
movl %eax, %r13d
cmpl $0x100, %eax            # imm = 0x100
jb 0x7ff2e
leaq 0x1bf045(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
movl %eax, %r14d
cmpl $0x100, %eax            # imm = 0x100
jb 0x7ff47
leaq 0x1bf02c(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x7ff5d
leaq 0x1bf016(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
movzbl %r12b, %r15d
movzbl %r13b, %ebx
movl %r14d, -0x7c(%rbp)
movzbl %r14b, %eax
movl %eax, -0x6c(%rbp)
callq 0x588d2
movw %ax, -0x48(%rbp)
callq 0x588d2
movw %ax, -0x46(%rbp)
xorl %r14d, %r14d
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
testb $0x40, %r13b
je 0x80154
callq 0x58b08
movsd %xmm0, -0x40(%rbp)
callq 0x58b08
movsd %xmm0, -0x30(%rbp)
callq 0x58b08
movsd %xmm0, -0x60(%rbp)
callq 0x58b08
movsd %xmm0, -0x38(%rbp)
callq 0x58b08
movsd -0x40(%rbp), %xmm0
leal -0x1(%r12), %eax
cmpb $0x1f, %al
ja 0x800f4
movl %ebx, -0x44(%rbp)
movl %r15d, %eax
imulq $0x348, %rax, %r14      # imm = 0x348
leaq 0x1befc6(%rip), %rbx    # 0x23efb0
leaq (%rbx,%r14), %rax
movq %rax, -0x78(%rbp)
movl $0x1, 0x1c(%rbx,%r14)
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%rbx,%r14)
movl %r15d, %edi
callq 0xdc1dd
leaq 0x28d337(%rip), %rcx    # 0x30d34c
orl %eax, (%rcx)
movl %r15d, %edi
callq 0x5cdab
xorpd %xmm1, %xmm1
xorps %xmm0, %xmm0
subsd -0x60(%rbp), %xmm0
movsd %xmm0, 0x28(%rbx,%r14)
movsd %xmm0, -0x60(%rbp)
ucomisd %xmm1, %xmm0
jne 0x8003f
jnp 0x80054
movl %r15d, %edi
callq 0xdc1dd
xorpd %xmm1, %xmm1
leaq 0x28d2f2(%rip), %rcx    # 0x30d344
orl %eax, (%rcx)
movsd -0x30(%rbp), %xmm2
movq -0x78(%rbp), %rcx
movsd %xmm2, 0x38(%rcx)
ucomisd %xmm1, %xmm2
movsd -0x40(%rbp), %xmm0
jne 0x8006f
jnp 0x8008e
movl %r15d, %edi
callq 0xdc1dd
movsd -0x30(%rbp), %xmm2
movsd -0x40(%rbp), %xmm0
leaq 0x28d2c0(%rip), %rcx    # 0x30d348
orl %eax, (%rcx)
movq -0x78(%rbp), %rcx
movsd -0x38(%rbp), %xmm1
movsd %xmm1, 0x30(%rcx)
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm1
movl -0x44(%rbp), %ebx
jne 0x800a7
jnp 0x800ca
movl %r15d, %edi
callq 0xdc1dd
xorpd %xmm3, %xmm3
movsd -0x30(%rbp), %xmm2
movsd -0x40(%rbp), %xmm0
leaq 0x28d27c(%rip), %rcx    # 0x30d340
orl %eax, (%rcx)
movq -0x78(%rbp), %rcx
movapd %xmm2, %xmm1
cmpneqsd %xmm3, %xmm1
movq %xmm1, %r14
andl $0x1, %r14d
movl %r13d, %eax
shll $0x5, %eax
shll $0x6, %r14d
andl %eax, %r14d
movl %r14d, 0x68(%rcx)
movsd -0x60(%rbp), %xmm1
jmp 0x80101
xorl %r14d, %r14d
movsd -0x60(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
leaq 0x2bc118(%rip), %rdi    # 0x33c220
leaq 0xa2b3c(%rip), %rsi     # 0x122c4b
movl %r15d, %edx
movsd -0x38(%rbp), %xmm3
movl %ebx, %ecx
movl -0x6c(%rbp), %r8d
movl %r14d, %r9d
movb $0x4, %al
callq 0x9060
leaq 0x1be262(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x8014b
leaq 0xa599a(%rip), %rsi     # 0x125ad7
leaq 0x2bc0dc(%rip), %rdx    # 0x33c220
xorl %eax, %eax
callq 0x9560
xorpd %xmm2, %xmm2
movsd -0x40(%rbp), %xmm1
movsd %xmm1, -0x40(%rbp)
testb $0x1, %r13b
jne 0x8016b
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
jmp 0x80304
callq 0x58b08
movsd %xmm0, -0x30(%rbp)
callq 0x58b08
movsd %xmm0, -0x60(%rbp)
callq 0x58b08
leal -0x1(%r12), %eax
cmpb $0x1f, %al
ja 0x80211
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
cvtsd2ss -0x30(%rbp), %xmm0
movl %r15d, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
leaq 0x1bee01(%rip), %rcx    # 0x23efb0
leaq (%rcx,%rax), %r14
movss %xmm0, 0xb0(%rcx,%rax)
movl $0x11, 0xac(%rcx,%rax)
movl %r15d, %edi
callq 0xdc1dd
leaq 0x28d196(%rip), %rcx    # 0x30d36c
orl %eax, (%rcx)
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
subsd -0x60(%rbp), %xmm1
testb $0x20, %r13b
movl %ebx, -0x44(%rbp)
jne 0x80220
xorps %xmm0, %xmm0
testb $0x10, %r13b
je 0x80203
andpd 0x88f91(%rip), %xmm1    # 0x109190
movapd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
xorpd %xmm1, %xmm1
subsd %xmm0, %xmm1
jmp 0x80246
movsd -0x60(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
jmp 0x80304
movsd -0x38(%rbp), %xmm0
addsd 0x38(%r14), %xmm0
testb $0x10, %r13b
jne 0x80242
movq $0x0, 0xb8(%r14)
xorpd %xmm1, %xmm1
jmp 0x80286
movapd %xmm0, %xmm2
movsd %xmm1, 0xb8(%r14)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x8025b
jnp 0x80282
movl %r15d, %edi
movapd %xmm1, -0x60(%rbp)
movsd %xmm2, -0x38(%rbp)
callq 0xdc1dd
movapd -0x60(%rbp), %xmm1
leaq 0x28d0eb(%rip), %rcx    # 0x30d364
orl %eax, (%rcx)
movsd -0x38(%rbp), %xmm0
jmp 0x80286
movapd %xmm2, %xmm0
movsd -0x30(%rbp), %xmm2
movsd %xmm0, 0xc8(%r14)
xorl %eax, %eax
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm0
movq %r14, %rbx
jne 0x802a5
jnp 0x802de
movl %r15d, %edi
movapd %xmm1, -0x60(%rbp)
movsd %xmm0, -0x38(%rbp)
callq 0xdc1dd
xorpd %xmm3, %xmm3
movsd -0x38(%rbp), %xmm0
movapd -0x60(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
leaq 0x28d097(%rip), %rcx    # 0x30d368
orl %eax, (%rcx)
shll $0x4, %r13d
andl $0x40, %r13d
movl %r13d, %eax
movl %eax, %ecx
orl $0x10, %ecx
ucomisd %xmm3, %xmm0
movl %eax, %r14d
cmovnel %ecx, %r14d
cmovpl %ecx, %r14d
testb $0x4, -0x7c(%rbp)
cmovel %eax, %r14d
movl %r14d, 0xe8(%rbx)
movl -0x44(%rbp), %ebx
testb $0x2, -0x68(%rbp)
movsd %xmm2, -0x30(%rbp)
movapd %xmm1, -0x60(%rbp)
movsd %xmm0, -0x38(%rbp)
jne 0x8032f
decb %r12b
xorpd %xmm3, %xmm3
cmpb $0x1f, %r12b
jbe 0x803de
jmp 0x80440
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x80345
leaq 0x1bec2e(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x8035b
leaq 0x1bec18(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x80371
leaq 0x1bec02(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x80387
leaq 0x1bebec(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x58b08
movapd %xmm0, %xmm3
decb %r12b
cmpb $0x1f, %r12b
ja 0x80440
movl %r15d, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
leaq 0x1bec02(%rip), %rcx    # 0x23efb0
movsd %xmm3, 0xc0(%rcx,%rax)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm3
jne 0x803c3
jnp 0x803de
movl %r15d, %edi
movsd %xmm3, -0x68(%rbp)
callq 0xdc1dd
movsd -0x68(%rbp), %xmm3
leaq 0x28cf84(%rip), %rcx    # 0x30d360
orl %eax, (%rcx)
movsd %xmm3, -0x68(%rbp)
movswl -0x46(%rbp), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movswl -0x48(%rbp), %eax
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
movl %r15d, %edi
callq 0x5ace1
movsd -0x68(%rbp), %xmm3
movl %r15d, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
xorps %xmm0, %xmm0
movsd -0x40(%rbp), %xmm1
ucomisd %xmm0, %xmm1
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmoval %r15d, %ecx
leaq 0x1beb84(%rip), %rdx    # 0x23efb0
movl %ecx, 0x218(%rdx,%rax)
leaq 0x28ce5a(%rip), %rax    # 0x30d294
movl $0x11, (%rax)
leaq 0x2bbdd9(%rip), %rdi    # 0x33c220
leaq 0xa2857(%rip), %rsi     # 0x122ca5
movl %r15d, %edx
movsd -0x30(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movl %ebx, %ecx
movl -0x6c(%rbp), %r8d
movl %r14d, %r9d
movb $0x4, %al
callq 0x9060
leaq 0x1bdf1a(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x804a1
leaq 0xa5652(%rip), %rsi     # 0x125ad7
leaq 0x2bbd94(%rip), %rdx    # 0x33c220
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9560
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq