// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movl %edi, -0x78(%rbp)
callq 0x51c47
movl %eax, %r12d
movzbl %al, %ebx
callq 0x51c47
movl %eax, %r15d
movzbl %al, %r14d
callq 0x51c47
movb %al, -0x29(%rbp)
movzbl %al, %eax
movl %eax, -0x7c(%rbp)
callq 0x51c47
callq 0x51c63
movw %ax, -0x54(%rbp)
callq 0x51c63
movw %ax, -0x52(%rbp)
xorl %r13d, %r13d
xorpd %xmm2, %xmm2
movl %ebx, %eax
movq %rax, -0x88(%rbp)
xorpd %xmm1, %xmm1
testb $0x40, %r14b
je 0x74aa1
callq 0x51e6f
movsd %xmm0, -0x50(%rbp)
callq 0x51e6f
movsd %xmm0, -0x38(%rbp)
callq 0x51e6f
movsd %xmm0, -0x70(%rbp)
callq 0x51e6f
movsd %xmm0, -0x40(%rbp)
callq 0x51e6f
movsd -0x50(%rbp), %xmm0
leal -0x1(%r12), %eax
cmpb $0x1f, %al
ja 0x74a41
movl %r14d, -0x44(%rbp)
imulq $0x348, -0x88(%rbp), %r13 # imm = 0x348
leaq 0x1b4681(%rip), %r14    # 0x228fb0
leaq (%r14,%r13), %rax
movq %rax, -0x90(%rbp)
movl $0x1, 0x1c(%r14,%r13)
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%r14,%r13)
movl %ebx, %edi
callq 0xca4da
leaq 0x2829f0(%rip), %rcx    # 0x2f734c
orl %eax, (%rcx)
movl %ebx, %edi
callq 0x559ba
xorpd %xmm1, %xmm1
xorps %xmm0, %xmm0
subsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x28(%r14,%r13)
movsd %xmm0, -0x70(%rbp)
ucomisd %xmm1, %xmm0
jne 0x74985
jnp 0x74999
movl %ebx, %edi
callq 0xca4da
xorpd %xmm1, %xmm1
leaq 0x2829ad(%rip), %rcx    # 0x2f7344
orl %eax, (%rcx)
movsd -0x38(%rbp), %xmm2
movq -0x90(%rbp), %rcx
movsd %xmm2, 0x38(%rcx)
ucomisd %xmm1, %xmm2
movl -0x44(%rbp), %r14d
movsd -0x50(%rbp), %xmm0
jne 0x749bb
jnp 0x749dc
movl %ebx, %edi
callq 0xca4da
movsd -0x38(%rbp), %xmm2
movsd -0x50(%rbp), %xmm0
leaq 0x282975(%rip), %rcx    # 0x2f7348
orl %eax, (%rcx)
movq -0x90(%rbp), %rcx
movsd -0x40(%rbp), %xmm1
movsd %xmm1, 0x30(%rcx)
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm1
jne 0x749f2
jnp 0x74a17
movl %ebx, %edi
callq 0xca4da
xorpd %xmm3, %xmm3
movsd -0x38(%rbp), %xmm2
movsd -0x50(%rbp), %xmm0
leaq 0x282932(%rip), %rcx    # 0x2f7340
orl %eax, (%rcx)
movq -0x90(%rbp), %rcx
movapd %xmm2, %xmm1
cmpneqsd %xmm3, %xmm1
movq %xmm1, %r13
andl $0x1, %r13d
movl %r14d, %eax
shll $0x5, %eax
shll $0x6, %r13d
andl %eax, %r13d
movl %r13d, 0x68(%rcx)
movsd -0x70(%rbp), %xmm1
jmp 0x74a4e
xorl %r13d, %r13d
movsd -0x70(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
leaq 0x2b17cb(%rip), %rdi    # 0x326220
leaq 0x98137(%rip), %rsi     # 0x10cb93
movl %ebx, %edx
movsd -0x40(%rbp), %xmm3
movl %r14d, %ecx
movl -0x7c(%rbp), %r8d
movl %r13d, %r9d
movb $0x4, %al
callq 0x9060
leaq 0x1b3915(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x74a98
leaq 0x9af95(%rip), %rsi     # 0x10fa1f
leaq 0x2b178f(%rip), %rdx    # 0x326220
xorl %eax, %eax
callq 0x9560
xorpd %xmm2, %xmm2
movsd -0x50(%rbp), %xmm1
movsd %xmm1, -0x50(%rbp)
testb $0x1, %r15b
jne 0x74ab8
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
jmp 0x74c42
callq 0x51e6f
movsd %xmm0, -0x38(%rbp)
callq 0x51e6f
movsd %xmm0, -0x70(%rbp)
callq 0x51e6f
leal -0x1(%r12), %eax
cmpb $0x1f, %al
ja 0x74b58
movsd %xmm0, -0x40(%rbp)
movl %r14d, -0x44(%rbp)
cvtsd2ss -0x38(%rbp), %xmm0
imulq $0x348, -0x88(%rbp), %rax # imm = 0x348
leaq 0x1b44b6(%rip), %rcx    # 0x228fb0
leaq (%rcx,%rax), %r14
movss %xmm0, 0xb0(%rcx,%rax)
movl $0x11, 0xac(%rcx,%rax)
movl %ebx, %edi
callq 0xca4da
leaq 0x28284c(%rip), %rcx    # 0x2f736c
orl %eax, (%rcx)
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
subsd -0x70(%rbp), %xmm1
testb $0x20, %r15b
jne 0x74b67
xorps %xmm0, %xmm0
testb $0x10, %r15b
je 0x74b4a
andpd 0x7e64a(%rip), %xmm1    # 0xf3190
movapd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
xorpd %xmm1, %xmm1
subsd %xmm0, %xmm1
jmp 0x74b8a
movsd -0x70(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
jmp 0x74c42
movsd -0x40(%rbp), %xmm0
addsd 0x38(%r14), %xmm0
testb $0x10, %r15b
jne 0x74b86
andq $0x0, 0xb8(%r14)
xorpd %xmm1, %xmm1
jmp 0x74bc9
movapd %xmm0, %xmm2
movsd %xmm1, 0xb8(%r14)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x74b9f
jnp 0x74bc5
movl %ebx, %edi
movapd %xmm1, -0x70(%rbp)
movsd %xmm2, -0x40(%rbp)
callq 0xca4da
movapd -0x70(%rbp), %xmm1
leaq 0x2827a8(%rip), %rcx    # 0x2f7364
orl %eax, (%rcx)
movsd -0x40(%rbp), %xmm0
jmp 0x74bc9
movapd %xmm2, %xmm0
movsd -0x38(%rbp), %xmm2
movsd %xmm0, 0xc8(%r14)
xorl %eax, %eax
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm0
jne 0x74be5
jnp 0x74c1b
movl %ebx, %edi
movapd %xmm1, -0x70(%rbp)
movsd %xmm0, -0x40(%rbp)
callq 0xca4da
xorpd %xmm3, %xmm3
movsd -0x40(%rbp), %xmm0
movapd -0x70(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
leaq 0x282758(%rip), %rcx    # 0x2f7368
orl %eax, (%rcx)
movl -0x44(%rbp), %eax
shll $0x4, %eax
andl $0x40, %eax
movl %eax, %ecx
orl $0x10, %ecx
ucomisd %xmm3, %xmm0
movl %eax, %r13d
cmovnel %ecx, %r13d
cmovpl %ecx, %r13d
testb $0x4, -0x29(%rbp)
cmovel %eax, %r13d
movl %r13d, 0xe8(%r14)
movl -0x44(%rbp), %r14d
testb $0x2, -0x78(%rbp)
movsd %xmm2, -0x38(%rbp)
movapd %xmm1, -0x70(%rbp)
movsd %xmm0, -0x40(%rbp)
jne 0x74c69
decb %r12b
xorpd %xmm3, %xmm3
cmpb $0x1f, %r12b
jbe 0x74cd4
jmp 0x74d2d
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51c47
callq 0x51e6f
movapd %xmm0, %xmm3
decb %r12b
cmpb $0x1f, %r12b
ja 0x74d2d
imulq $0x348, -0x88(%rbp), %rax # imm = 0x348
leaq 0x1b430b(%rip), %rcx    # 0x228fb0
movsd %xmm3, 0xc0(%rcx,%rax)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm3
jne 0x74cba
jnp 0x74cd4
movl %ebx, %edi
movsd %xmm3, -0x78(%rbp)
callq 0xca4da
movsd -0x78(%rbp), %xmm3
leaq 0x28268e(%rip), %rcx    # 0x2f7360
orl %eax, (%rcx)
movsd %xmm3, -0x78(%rbp)
movswl -0x52(%rbp), %eax
cvtsi2ss %eax, %xmm0
movswl -0x54(%rbp), %eax
cvtsi2ss %eax, %xmm1
movl %ebx, %edi
callq 0x53b74
movsd -0x78(%rbp), %xmm3
imulq $0x348, -0x88(%rbp), %rax # imm = 0x348
xorps %xmm0, %xmm0
movsd -0x50(%rbp), %xmm1
ucomisd %xmm0, %xmm1
pushq $-0x1
popq %rcx
cmoval %ebx, %ecx
leaq 0x1b4297(%rip), %rdx    # 0x228fb0
movl %ecx, 0x218(%rdx,%rax)
leaq 0x28256d(%rip), %rax    # 0x2f7294
movl $0x11, (%rax)
leaq 0x2b14ec(%rip), %rdi    # 0x326220
leaq 0x97eb2(%rip), %rsi     # 0x10cbed
movl %ebx, %edx
movsd -0x38(%rbp), %xmm0
movaps -0x70(%rbp), %xmm1
movsd -0x40(%rbp), %xmm2
movl %r14d, %ecx
movl -0x7c(%rbp), %r8d
movl %r13d, %r9d
movb $0x4, %al
callq 0x9060
leaq 0x1b362d(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x74d8e
leaq 0x9acad(%rip), %rsi     # 0x10fa1f
leaq 0x2b14a7(%rip), %rdx    # 0x326220
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9560
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq