// File: 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
subq $0x20, %rsp
movss %xmm0, -0x4(%rbp)
movss %xmm1, -0x8(%rbp)
movss %xmm2, -0xc(%rbp)
movl %edi, -0x10(%rbp)
movss 0x1a11e(%rip), %xmm0    # 0x171940
addss -0x4(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x14(%rbp)
movss 0x1a10a(%rip), %xmm0    # 0x171940
addss -0x8(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x157851
cmpl $0x168, -0x14(%rbp)     # imm = 0x168
jle 0x157856
jmp 0x157a9f
cmpl $0x0, -0x18(%rbp)
jl 0x157862
cmpl $0x5a, -0x18(%rbp)
jle 0x157867
jmp 0x157a9f
cmpl $0x0, -0x14(%rbp)
jne 0x157878
cmpl $0x0, -0x18(%rbp)
jne 0x157878
jmp 0x157a9f
movss 0x1a0bc(%rip), %xmm0    # 0x17193c
ucomiss -0xc(%rbp), %xmm0
jbe 0x15788b
jmp 0x157a9f
leaq 0x12021e(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x1578ad
cmpl $0x0, -0x10(%rbp)
je 0x1578ad
movss -0xc(%rbp), %xmm0
callq 0x154b60
movss %xmm0, -0xc(%rbp)
movss -0xc(%rbp), %xmm0
cvtsi2ssl -0x18(%rbp), %xmm1
movss 0x1a091(%rip), %xmm2    # 0x171950
subss %xmm1, %xmm2
movss 0x1a085(%rip), %xmm1    # 0x171950
divss %xmm1, %xmm2
movslq -0x14(%rbp), %rcx
leaq 0x79ae6(%rip), %rax     # 0x1d13c0
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
leaq 0x79ad2(%rip), %rax     # 0x1d13c0
movss %xmm0, (%rax,%rcx,4)
movss -0xc(%rbp), %xmm0
movslq -0x14(%rbp), %rcx
leaq 0x7950d(%rip), %rax     # 0x1d0e10
addss (%rax,%rcx,4), %xmm0
leaq 0x79501(%rip), %rax     # 0x1d0e10
movss %xmm0, (%rax,%rcx,4)
movslq -0x14(%rbp), %rcx
movss 0x1a01c(%rip), %xmm0    # 0x17193c
leaq 0x7a049(%rip), %rax     # 0x1d1970
addss (%rax,%rcx,4), %xmm0
leaq 0x7a03d(%rip), %rax     # 0x1d1970
movss %xmm0, (%rax,%rcx,4)
movss -0xc(%rbp), %xmm0
movslq -0x18(%rbp), %rcx
leaq 0x7a5d8(%rip), %rax     # 0x1d1f20
addss (%rax,%rcx,4), %xmm0
leaq 0x7a5cc(%rip), %rax     # 0x1d1f20
movss %xmm0, (%rax,%rcx,4)
movslq -0x18(%rbp), %rcx
movss 0x19fd7(%rip), %xmm0    # 0x17193c
leaq 0x7a724(%rip), %rax     # 0x1d2090
addss (%rax,%rcx,4), %xmm0
leaq 0x7a718(%rip), %rax     # 0x1d2090
movss %xmm0, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
movslq -0x14(%rbp), %rdx
leaq 0x78ed5(%rip), %rcx     # 0x1d0860
cmpl (%rcx,%rdx,4), %eax
jle 0x1579a1
movl -0x18(%rbp), %edx
movslq -0x14(%rbp), %rcx
leaq 0x78ec2(%rip), %rax     # 0x1d0860
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
movslq -0x14(%rbp), %rdx
leaq 0x78901(%rip), %rcx     # 0x1d02b0
cmpl (%rcx,%rdx,4), %eax
jge 0x1579c5
movl -0x18(%rbp), %edx
movslq -0x14(%rbp), %rcx
leaq 0x788ee(%rip), %rax     # 0x1d02b0
movl %edx, (%rax,%rcx,4)
movslq -0x14(%rbp), %rcx
leaq 0x9a980(%rip), %rax     # 0x1f2350
imulq $0x16c, %rcx, %rcx      # imm = 0x16C
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
movss 0x19f56(%rip), %xmm0    # 0x17193c
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x157a37
movss -0xc(%rbp), %xmm0
movslq -0x14(%rbp), %rcx
leaq 0x7a804(%rip), %rax     # 0x1d2200
imulq $0x16c, %rcx, %rcx      # imm = 0x16C
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movslq -0x14(%rbp), %rcx
leaq 0x9a936(%rip), %rax     # 0x1f2350
imulq $0x16c, %rcx, %rcx      # imm = 0x16C
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
movss 0x19f0c(%rip), %xmm0    # 0x17193c
movss %xmm0, (%rax,%rcx,4)
jmp 0x157a8a
movss -0xc(%rbp), %xmm0
movslq -0x14(%rbp), %rcx
leaq 0x7a7b9(%rip), %rax     # 0x1d2200
imulq $0x16c, %rcx, %rcx      # imm = 0x16C
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
addss (%rax,%rcx,4), %xmm0
movss %xmm0, (%rax,%rcx,4)
movslq -0x14(%rbp), %rcx
leaq 0x9a8e6(%rip), %rax     # 0x1f2350
imulq $0x16c, %rcx, %rcx      # imm = 0x16C
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
movss 0x19ebc(%rip), %xmm0    # 0x17193c
addss (%rax,%rcx,4), %xmm0
movss %xmm0, (%rax,%rcx,4)
leaq 0x242a2b(%rip), %rax    # 0x39a4bc
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x242a1f(%rip), %rax    # 0x39a4bc
movl %ecx, (%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)