// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: log_signal(float, float, float, int)
void log_signal(float azf, float elf, float sig_level, int amu_flag)
{
int az, ell;

   // record sat signal strength data in the various arrays

   az  = (int) (azf+0.50F);
   ell = (int) (elf+0.50F);
   if((az < 0) || (az > 360)) return;
   if((ell < 0) || (ell > 90)) return;
   if((az == 0) && (ell == 0)) return;  // probably a bogus fix, ignore

   if(sig_level < 1.00F) {  // don't let zero signal levels spoil the average
return;  // fixes problems at high latitudes with receivers that report sigs of sats below the elevation mask
      if(db_3d_count[az][ell] > 0.0) return; // only log one of them
   }

   if((rcvr_type == TSIP_RCVR) && amu_flag) {  // convert AMU values to dBc values
      sig_level = amu_to_dbc(sig_level);
   }

   if((MAX_AVG_COUNT > 0.0F) && (db_az_count[az] > MAX_AVG_COUNT)) {
      db_weighted_az_sum[az] -= (db_weighted_az_sum[az] / db_az_count[az]);
      db_weighted_az_sum[az] += (sig_level * ((90.0F-(float)ell)/90.0F));

      db_az_sum[az] -= (db_az_sum[az] / db_az_count[az]);
      db_az_sum[az] += sig_level;
   }
   else {
      db_weighted_az_sum[az] += (sig_level * ((90.0F-(float)ell)/90.0F));
      db_az_sum[az] += sig_level;
      db_az_count[az] += 1.0F;
   }

   if((MAX_AVG_COUNT > 0.0) && (db_el_count[ell] > MAX_AVG_COUNT)) {
      db_el_sum[ell] -= (db_el_sum[ell] / db_el_count[ell]);
      db_el_sum[ell] += sig_level;
   }
   else {
      db_el_sum[ell] += sig_level;
      db_el_count[ell] += 1.0F;
   }

   if(ell > max_el[az]) max_el[az] = ell;
   if(ell < min_el[az]) min_el[az] = ell;

   if(0) {  // track peak signal
      if(sig_level > db_3d_sum[az][ell]) db_3d_sum[az][ell] = sig_level;
      db_3d_count[az][ell] = 1.0F;
   }
   else {   // track average signal
      if(db_3d_count[az][ell] < 1.0F) {   // first signal level seen at this location
         db_3d_sum[az][ell] = sig_level;
         db_3d_count[az][ell] = 1.0F;
      }
      else if((MAX_AVG_COUNT > 0.0F) && (db_3d_count[az][ell] > MAX_AVG_COUNT)) {  // keep map fresh by averaging last 10 readings
         db_3d_sum[az][ell] -= (db_3d_sum[az][ell] / db_3d_count[az][ell]);  // remove current average
         db_3d_sum[az][ell] += sig_level;                                    // add in new reading
      }
      else {  // calculate average signal level
         db_3d_sum[az][ell] += sig_level;
         db_3d_count[az][ell] += 1.0F;
      }
   }

   ++signal_length;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movss 0x13a4a(%rip), %xmm3    # 0x10d078
addss %xmm3, %xmm0
cvttss2si %xmm0, %ecx
addss %xmm3, %xmm1
cvttss2si %xmm1, %eax
cmpl $0x169, %ecx            # imm = 0x169
setae %dl
cmpl $0x5b, %eax
setae %sil
orb %dl, %sil
jne 0xf97c5
movl %ecx, %edx
orl %eax, %edx
sete %dl
movss 0x13a06(%rip), %xmm0    # 0x10d06c
ucomiss %xmm2, %xmm0
ja 0xf97c5
testb %dl, %dl
jne 0xf97c5
testl %edi, %edi
je 0xf96ce
leaq 0x11f24e(%rip), %rdx    # 0x2188d0
cmpq $0x1, (%rdx)
jne 0xf96ce
xorps %xmm1, %xmm1
ucomiss %xmm2, %xmm1
ja 0xf96d1
ucomiss 0x33159(%rip), %xmm2    # 0x12c7f0
jae 0xf96b6
mulss 0x139af(%rip), %xmm2    # 0x10d050
cvttss2si %xmm2, %edx
movslq %edx, %rdx
leaq 0x77191(%rip), %rsi     # 0x170840
movss (%rsi,%rdx,4), %xmm1
jmp 0xf96d1
addss 0x33136(%rip), %xmm2    # 0x12c7f4
divss 0x13996(%rip), %xmm2    # 0x10d05c
addss 0x3312a(%rip), %xmm2    # 0x12c7f8
movaps %xmm2, %xmm1
xorps %xmm2, %xmm2
cvtsi2ss %eax, %xmm2
movss 0x139a4(%rip), %xmm3    # 0x10d084
movaps %xmm3, %xmm4
subss %xmm2, %xmm4
divss %xmm3, %xmm4
movl %ecx, %ecx
leaq 0x78aec(%rip), %rdx     # 0x1721e0
mulss %xmm1, %xmm4
addss (%rdx,%rcx,4), %xmm4
movss %xmm4, (%rdx,%rcx,4)
leaq 0x78527(%rip), %rdx     # 0x171c30
movss (%rdx,%rcx,4), %xmm2
addss %xmm1, %xmm2
movss %xmm2, (%rdx,%rcx,4)
leaq 0x79072(%rip), %rdx     # 0x172790
movss (%rdx,%rcx,4), %xmm2
addss %xmm0, %xmm2
movss %xmm2, (%rdx,%rcx,4)
movl %eax, %edx
leaq 0x7960b(%rip), %rsi     # 0x172d40
movss (%rsi,%rdx,4), %xmm2
addss %xmm1, %xmm2
movss %xmm2, (%rsi,%rdx,4)
leaq 0x79766(%rip), %rsi     # 0x172eb0
movss (%rsi,%rdx,4), %xmm2
addss %xmm0, %xmm2
movss %xmm2, (%rsi,%rdx,4)
leaq 0x77f21(%rip), %rsi     # 0x171680
cmpl %eax, (%rsi,%rcx,4)
jge 0xf9767
movl %eax, (%rsi,%rcx,4)
leaq 0x77962(%rip), %rsi     # 0x1710d0
cmpl %eax, (%rsi,%rcx,4)
jle 0xf9776
movl %eax, (%rsi,%rcx,4)
imulq $0x16c, %rcx, %rcx      # imm = 0x16C
leaq 0x999ec(%rip), %rax     # 0x193170
addq %rcx, %rax
leaq (%rax,%rdx,4), %rax
addq 0x56866(%rip), %rcx     # 0x14fff8
movss (%rax), %xmm2
ucomiss %xmm2, %xmm0
leaq (%rcx,%rdx,4), %rcx
jbe 0xf97a5
movss %xmm1, (%rcx)
jmp 0xf97b8
addss (%rcx), %xmm1
movss %xmm1, (%rcx)
addss 0x138b7(%rip), %xmm2    # 0x10d06c
movaps %xmm2, %xmm0
movss %xmm0, (%rax)
leaq 0x241b19(%rip), %rax    # 0x33b2dc
incl (%rax)
popq %rbp
retq