// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movl %edi, -0x60(%rbp)
callq 0x587d1
movl %eax, %ebx
cmpl $0x100, %eax            # imm = 0x100
jb 0x800dc
leaq 0x1bee97(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
movl %eax, %r13d
cmpl $0x100, %eax            # imm = 0x100
jb 0x800f5
leaq 0x1bee7e(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
movl %eax, %r15d
cmpl $0x100, %eax            # imm = 0x100
jb 0x8010e
leaq 0x1bee65(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x80124
leaq 0x1bee4f(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
movzbl %bl, %eax
movl %eax, -0x2c(%rbp)
movzbl %r13b, %r14d
movl %r15d, -0x68(%rbp)
movzbl %r15b, %r12d
callq 0x588f0
movw %ax, -0x58(%rbp)
callq 0x588f0
movw %ax, -0x56(%rbp)
xorl %r15d, %r15d
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
testb $0x40, %r13b
je 0x8031e
callq 0x58b86
movsd %xmm0, -0x50(%rbp)
callq 0x58b86
movsd %xmm0, -0x38(%rbp)
callq 0x58b86
movsd %xmm0, -0x48(%rbp)
callq 0x58b86
movsd %xmm0, -0x40(%rbp)
callq 0x58b86
movsd -0x50(%rbp), %xmm0
leal -0x1(%rbx), %eax
cmpb $0x1f, %al
ja 0x802bf
movl %r12d, -0x54(%rbp)
movl %r14d, -0x64(%rbp)
movzbl %bl, %eax
imulq $0x348, %rax, %r15      # imm = 0x348
leaq 0x1bedfe(%rip), %r12    # 0x23efb0
leaq (%r12,%r15), %rax
movq %rax, -0x70(%rbp)
movl $0x1, 0x1c(%r12,%r15)
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%r12,%r15)
movl -0x2c(%rbp), %r14d
movl %r14d, %edi
callq 0xdbb74
leaq 0x28d16b(%rip), %rcx    # 0x30d34c
orl %eax, (%rcx)
movl %r14d, %edi
callq 0x5ced3
xorpd %xmm1, %xmm1
xorps %xmm0, %xmm0
subsd -0x48(%rbp), %xmm0
movsd %xmm0, 0x28(%r12,%r15)
movsd %xmm0, -0x48(%rbp)
ucomisd %xmm1, %xmm0
jne 0x8020b
jnp 0x80220
movl %r14d, %edi
callq 0xdbb74
xorpd %xmm1, %xmm1
leaq 0x28d126(%rip), %rcx    # 0x30d344
orl %eax, (%rcx)
movsd -0x38(%rbp), %xmm2
movq -0x70(%rbp), %r14
movsd %xmm2, 0x38(%r14)
ucomisd %xmm1, %xmm2
movsd -0x50(%rbp), %xmm0
jne 0x8023c
jnp 0x80257
movl -0x2c(%rbp), %edi
callq 0xdbb74
movsd -0x38(%rbp), %xmm2
movsd -0x50(%rbp), %xmm0
leaq 0x28d0f3(%rip), %rcx    # 0x30d348
orl %eax, (%rcx)
movsd -0x40(%rbp), %xmm1
movsd %xmm1, 0x30(%r14)
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm1
movl -0x54(%rbp), %r12d
jne 0x80272
jnp 0x80291
movl -0x2c(%rbp), %edi
callq 0xdbb74
xorpd %xmm3, %xmm3
movsd -0x38(%rbp), %xmm2
movsd -0x50(%rbp), %xmm0
leaq 0x28d0b1(%rip), %rcx    # 0x30d340
orl %eax, (%rcx)
movapd %xmm2, %xmm1
cmpneqsd %xmm3, %xmm1
movq %xmm1, %r15
andl $0x1, %r15d
movl %r13d, %eax
shll $0x5, %eax
shll $0x6, %r15d
andl %eax, %r15d
movl %r15d, 0x68(%r14)
movl -0x64(%rbp), %r14d
movsd -0x48(%rbp), %xmm1
jmp 0x802cc
xorl %r15d, %r15d
movsd -0x48(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
leaq 0x2bbf4d(%rip), %rdi    # 0x33c220
leaq 0xa2891(%rip), %rsi     # 0x122b6b
movl -0x2c(%rbp), %edx
movsd -0x40(%rbp), %xmm3
movl %r14d, %ecx
movl %r12d, %r8d
movl %r15d, %r9d
movb $0x4, %al
callq 0x9060
leaq 0x1be097(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x80316
leaq 0xa56ef(%rip), %rsi     # 0x1259f7
leaq 0x2bbf11(%rip), %rdx    # 0x33c220
xorl %eax, %eax
callq 0x9560
xorps %xmm0, %xmm0
movsd -0x50(%rbp), %xmm1
testb $0x1, %r13b
movsd %xmm1, -0x50(%rbp)
jne 0x8033b
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
movsd %xmm3, -0x48(%rbp)
jmp 0x804b3
callq 0x58b86
movsd %xmm0, -0x38(%rbp)
callq 0x58b86
movsd %xmm0, -0x48(%rbp)
callq 0x58b86
movaps %xmm0, %xmm2
leal -0x1(%rbx), %eax
cmpb $0x1f, %al
ja 0x803d8
movsd %xmm2, -0x40(%rbp)
xorps %xmm0, %xmm0
cvtsd2ss -0x38(%rbp), %xmm0
movzbl %bl, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
leaq 0x1bec34(%rip), %rcx    # 0x23efb0
leaq (%rcx,%rax), %r15
movss %xmm0, 0xb0(%rcx,%rax)
movl $0x11, 0xac(%rcx,%rax)
movl -0x2c(%rbp), %edi
callq 0xdbb74
leaq 0x28cfc9(%rip), %rcx    # 0x30d36c
orl %eax, (%rcx)
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
subsd -0x48(%rbp), %xmm1
testb $0x20, %r13b
jne 0x803e2
xorps %xmm2, %xmm2
testb $0x10, %r13b
je 0x803cc
andpd 0x88db8(%rip), %xmm1    # 0x109180
movapd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0x803f9
sqrtsd %xmm0, %xmm0
jmp 0x803fe
movsd -0x38(%rbp), %xmm0
jmp 0x804b3
testb $0x10, %r13b
je 0x803ec
movapd %xmm1, %xmm0
movsd -0x40(%rbp), %xmm2
addsd 0x38(%r15), %xmm2
jmp 0x8040e
callq 0x9270
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
subsd %xmm0, %xmm3
movapd %xmm3, %xmm0
movl %r12d, -0x54(%rbp)
movsd %xmm0, 0xb8(%r15)
xorpd %xmm3, %xmm3
movsd %xmm0, -0x48(%rbp)
ucomisd %xmm3, %xmm0
movsd %xmm2, -0x40(%rbp)
jne 0x80431
jnp 0x8044b
movl -0x2c(%rbp), %edi
callq 0xdbb74
xorpd %xmm3, %xmm3
movsd -0x40(%rbp), %xmm2
leaq 0x28cf1b(%rip), %rcx    # 0x30d364
orl %eax, (%rcx)
movsd %xmm2, 0xc8(%r15)
xorl %eax, %eax
ucomisd %xmm3, %xmm2
movq %r15, %r12
jne 0x80461
jnp 0x80482
movl -0x2c(%rbp), %edi
callq 0xdbb74
movsd -0x40(%rbp), %xmm2
leaq 0x28cef3(%rip), %rcx    # 0x30d368
orl %eax, (%rcx)
shll $0x4, %r13d
andl $0x40, %r13d
movl %r13d, %eax
movl %eax, %ecx
orl $0x10, %ecx
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
movl %eax, %r15d
cmovnel %ecx, %r15d
cmovpl %ecx, %r15d
testb $0x4, -0x68(%rbp)
cmovel %eax, %r15d
movl %r15d, 0xe8(%r12)
movsd -0x38(%rbp), %xmm0
movl -0x54(%rbp), %r12d
xorpd %xmm3, %xmm3
testb $0x2, -0x60(%rbp)
movl -0x2c(%rbp), %r13d
movsd %xmm0, -0x38(%rbp)
movsd %xmm2, -0x40(%rbp)
je 0x80580
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x804e5
leaq 0x1bea8e(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x804fb
leaq 0x1bea78(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x80511
leaq 0x1bea62(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x80527
leaq 0x1bea4c(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x58b86
movaps %xmm0, %xmm3
leal -0x1(%rbx), %eax
cmpb $0x1f, %al
ja 0x80576
movzbl %bl, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
leaq 0x1bea69(%rip), %rcx    # 0x23efb0
movsd %xmm3, 0xc0(%rcx,%rax)
xorps %xmm0, %xmm0
ucomisd %xmm0, %xmm3
jne 0x8055b
jnp 0x80576
movl %r13d, %edi
movsd %xmm3, -0x60(%rbp)
callq 0xdbb74
movsd -0x60(%rbp), %xmm3
leaq 0x28cdec(%rip), %rcx    # 0x30d360
orl %eax, (%rcx)
movsd -0x38(%rbp), %xmm0
movsd -0x40(%rbp), %xmm2
leal -0x1(%rbx), %eax
cmpb $0x1f, %al
ja 0x805f3
movswl -0x56(%rbp), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movswl -0x58(%rbp), %eax
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
movl %r13d, %edi
movsd %xmm3, -0x60(%rbp)
callq 0x5ad98
movsd -0x60(%rbp), %xmm3
movsd -0x40(%rbp), %xmm2
movzbl %bl, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
xorps %xmm0, %xmm0
movsd -0x50(%rbp), %xmm1
ucomisd %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmoval %r13d, %ecx
leaq 0x1be9d1(%rip), %rdx    # 0x23efb0
movl %ecx, 0x218(%rdx,%rax)
leaq 0x28cca7(%rip), %rax    # 0x30d294
movl $0x11, (%rax)
leaq 0x2bbc26(%rip), %rdi    # 0x33c220
leaq 0xa25c4(%rip), %rsi     # 0x122bc5
movl %r13d, %edx
movsd -0x48(%rbp), %xmm1
movl %r14d, %ecx
movl %r12d, %r8d
movl %r15d, %r9d
movb $0x4, %al
callq 0x9060
leaq 0x1bdd70(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x8064b
leaq 0xa53c8(%rip), %rsi     # 0x1259f7
leaq 0x2bbbea(%rip), %rdx    # 0x33c220
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9560
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq