// File: jkingan[P]ladyheather/heathgps.cpp
// Function: find_sat_changes()
void find_sat_changes()
{
int prn, j;
int sats_changed;

   // see if the satellite constellation has changed
   // Also converts sat_count from number of visible sats to tracked sats.

   for(prn=1; prn<=MAX_PRN; prn++) {  // save old tracking list
      last_const[prn] = this_const[prn];
      this_const[prn] = 0;
   }

   j = 0;
   sat_count = track_count = vis_count = 0;
   sats_changed = 0;
   for(prn=1; prn<=MAX_PRN; prn++) { 
      if(sat[prn].level_msg == 0x00) continue;
//    if(++j > max_sats) break;

      if(sat[prn].tracking > 0) {
         this_const[prn] = 1;
         if(last_const[prn] != this_const[prn]) ++sats_changed;
         ++sat_count;
         ++track_count;
         ++vis_count;
         have_count = 100;
      }
      else if(sat[prn].tracking < 0) {
         ++track_count;
      }
   }
   if(lte_lite && (have_sawtooth == 0)) sat_count = jackson_sat_count;

   if(sats_changed) {
      if(sat_count > SAT_COUNT_MASK) new_const = (SAT_COUNT_MASK | CONST_CHANGE);
      else                           new_const = (sat_count | CONST_CHANGE);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl $0x1, -0x4(%rbp)
cmpl $0x3e7, -0x4(%rbp)      # imm = 0x3E7
jg 0x821ca
movslq -0x4(%rbp), %rcx
leaq 0x34d551(%rip), %rax    # 0x3cf6f0
movb (%rax,%rcx), %dl
movslq -0x4(%rbp), %rcx
leaq 0x34d933(%rip), %rax    # 0x3cfae0
movb %dl, (%rax,%rcx)
movslq -0x4(%rbp), %rcx
leaq 0x34d535(%rip), %rax    # 0x3cf6f0
movb $0x0, (%rax,%rcx)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x8218b
movl $0x0, -0x8(%rbp)
leaq 0x21bf0c(%rip), %rax    # 0x29e0e4
movl $0x0, (%rax)
leaq 0x21befb(%rip), %rax    # 0x29e0e0
movl $0x0, (%rax)
leaq 0x21befa(%rip), %rax    # 0x29e0ec
movl $0x0, (%rax)
movl $0x0, -0xc(%rbp)
movl $0x1, -0x4(%rbp)
cmpl $0x3e7, -0x4(%rbp)      # imm = 0x3E7
jg 0x82322
movslq -0x4(%rbp), %rcx
leaq 0x21bf72(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jne 0x82233
jmp 0x82314
movslq -0x4(%rbp), %rcx
leaq 0x21bf52(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cmpl $0x0, 0x218(%rax)
jle 0x822dd
movslq -0x4(%rbp), %rcx
leaq 0x34d490(%rip), %rax    # 0x3cf6f0
movb $0x1, (%rax,%rcx)
movslq -0x4(%rbp), %rcx
leaq 0x34d871(%rip), %rax    # 0x3cfae0
movzbl (%rax,%rcx), %eax
movslq -0x4(%rbp), %rdx
leaq 0x34d472(%rip), %rcx    # 0x3cf6f0
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x8228f
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x21be56(%rip), %rax    # 0x29e0ec
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x21be4a(%rip), %rax    # 0x29e0ec
movl %ecx, (%rax)
leaq 0x21be35(%rip), %rax    # 0x29e0e0
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x21be29(%rip), %rax    # 0x29e0e0
movl %ecx, (%rax)
leaq 0x21be24(%rip), %rax    # 0x29e0e4
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x21be18(%rip), %rax    # 0x29e0e4
movl %ecx, (%rax)
leaq 0x2ea223(%rip), %rax    # 0x36c4f8
movl $0x64, (%rax)
jmp 0x82312
movslq -0x4(%rbp), %rcx
leaq 0x21bea8(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cmpl $0x0, 0x218(%rax)
jge 0x82310
leaq 0x21bdde(%rip), %rax    # 0x29e0e0
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x21bdd2(%rip), %rax    # 0x29e0e0
movl %ecx, (%rax)
jmp 0x82312
jmp 0x82314
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x82206
leaq 0x1f7e87(%rip), %rax    # 0x27a1b0
cmpl $0x0, (%rax)
je 0x8234c
leaq 0x2ea26f(%rip), %rax    # 0x36c5a4
cmpl $0x0, (%rax)
jne 0x8234c
leaq 0x21bdaf(%rip), %rax    # 0x29e0f0
movl (%rax), %ecx
leaq 0x21bda2(%rip), %rax    # 0x29e0ec
movl %ecx, (%rax)
cmpl $0x0, -0xc(%rbp)
je 0x8238a
leaq 0x21bd93(%rip), %rax    # 0x29e0ec
cmpl $0xff, (%rax)
jle 0x82370
leaq 0x21bdc0(%rip), %rax    # 0x29e128
movl $0x8ff, (%rax)          # imm = 0x8FF
jmp 0x82388
leaq 0x21bd75(%rip), %rax    # 0x29e0ec
movl (%rax), %ecx
orl $0x800, %ecx            # imm = 0x800
leaq 0x21bda2(%rip), %rax    # 0x29e128
movl %ecx, (%rax)
jmp 0x8238a
popq %rbp
retq
nopl (%rax)