// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: draw_az_levels()
void draw_az_levels()
{
int first_az;
int az;
int x0, y0;
int x1, y1;
int x2, y2;
float r;
float max_db;
float max_weighted_db;
int color;

   // show signal level vesus azimuth
   first_az = (-1);
   max_db = max_weighted_db = 0.0F;

   for(x0=0; x0<360; x0++) {  // find max db values
      if(db_az_sum[x0] && db_az_count[x0]) {
         r = db_az_sum[x0] / db_az_count[x0];
         if(r > max_db) {
            max_db = r;
            if(first_az < 0) first_az = x0;
         }
      }
      if(db_weighted_az_sum[x0] && db_az_count[x0]) {
         r = db_weighted_az_sum[x0] / db_az_count[x0];
         if(r > max_weighted_db) {
            max_weighted_db = r;
         }
      }
   }
   if(first_az < 0) return;
   if(max_db == 0.0F) return;
   if(max_weighted_db == 0.0F) return;

   db_az_count[360] = db_az_count[0];
   db_az_sum[360] = db_az_sum[0];

   if(db_az_count[first_az] == 0) r = 0.0;
   else if(plot_signals == 1)     r = (db_az_sum[first_az] / db_az_count[first_az]) / max_db;
   else                           r = (db_weighted_az_sum[first_az] / db_az_count[first_az]) / max_weighted_db;
   if(r > 1.0F) r = 1.0F;
   x0 = x1 = AZEL_X - (int) (r * cos360(0+90) * AZEL_RADIUS);
   y0 = y1 = AZEL_Y - (int) (r * sin360(0+90) * AZEL_RADIUS);

   for(az=0; az<=360; az+=1) {
      if(db_az_count[az] && db_az_sum[az]) {
         if(plot_signals == 1) r = (db_az_sum[az] / db_az_count[az]) / max_db;
         else                  r = (db_weighted_az_sum[az] / db_az_count[az]) / max_weighted_db;
         if(r >= 1.0F) r = 1.0F;
         color = GREEN;
      }
      else color = BLUE;

      x2 = AZEL_X - (int) (r * cos360(az+90) * AZEL_RADIUS);
      y2 = AZEL_Y - (int) (r * sin360(az+90) * AZEL_RADIUS);

      line(x1,y1, x2,y2, color);
      x1 = x2;
      y1 = y2;
   }

   line(x0,y0, x1,y1, LEVEL_COLOR);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x28(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x168, -0xc(%rbp)      # imm = 0x168
jge 0x1588f9
movslq -0xc(%rbp), %rcx
leaq 0x78612(%rip), %rax     # 0x1d0e10
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x15880f
jp 0x15880f
jmp 0x158875
movslq -0xc(%rbp), %rcx
leaq 0x79156(%rip), %rax     # 0x1d1970
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x15882b
jp 0x15882b
jmp 0x158875
movslq -0xc(%rbp), %rcx
leaq 0x785da(%rip), %rax     # 0x1d0e10
movss (%rax,%rcx,4), %xmm0
movslq -0xc(%rbp), %rcx
leaq 0x7912a(%rip), %rax     # 0x1d1970
divss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
ucomiss -0x28(%rbp), %xmm0
jbe 0x158873
movss -0x24(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
cmpl $0x0, -0x4(%rbp)
jge 0x158871
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x158873
jmp 0x158875
movslq -0xc(%rbp), %rcx
leaq 0x78b40(%rip), %rax     # 0x1d13c0
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x158891
jp 0x158891
jmp 0x1588e9
movslq -0xc(%rbp), %rcx
leaq 0x790d4(%rip), %rax     # 0x1d1970
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1588ad
jp 0x1588ad
jmp 0x1588e9
movslq -0xc(%rbp), %rcx
leaq 0x78b08(%rip), %rax     # 0x1d13c0
movss (%rax,%rcx,4), %xmm0
movslq -0xc(%rbp), %rcx
leaq 0x790a8(%rip), %rax     # 0x1d1970
divss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
ucomiss -0x2c(%rbp), %xmm0
jbe 0x1588e7
movss -0x24(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
jmp 0x1588e9
jmp 0x1588eb
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1587e6
cmpl $0x0, -0x4(%rbp)
jge 0x158904
jmp 0x158d33
movss -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x158918
jp 0x158918
jmp 0x158d33
movss -0x2c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x15892c
jp 0x15892c
jmp 0x158d33
leaq 0x7903d(%rip), %rax     # 0x1d1970
movss (%rax), %xmm0
leaq 0x79032(%rip), %rax     # 0x1d1970
movss %xmm0, 0x5a0(%rax)
leaq 0x784c3(%rip), %rax     # 0x1d0e10
movss (%rax), %xmm0
leaq 0x784b8(%rip), %rax     # 0x1d0e10
movss %xmm0, 0x5a0(%rax)
movslq -0x4(%rbp), %rcx
leaq 0x79005(%rip), %rax     # 0x1d1970
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x158984
jp 0x158984
xorps %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x1589eb
leaq 0x121c6a(%rip), %rax    # 0x27a5f5
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x1589bf
movslq -0x4(%rbp), %rcx
leaq 0x78472(%rip), %rax     # 0x1d0e10
movss (%rax,%rcx,4), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x78fc2(%rip), %rax     # 0x1d1970
divss (%rax,%rcx,4), %xmm0
divss -0x28(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x1589e9
movslq -0x4(%rbp), %rcx
leaq 0x789f6(%rip), %rax     # 0x1d13c0
movss (%rax,%rcx,4), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x78f96(%rip), %rax     # 0x1d1970
divss (%rax,%rcx,4), %xmm0
divss -0x2c(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x1589eb
movss -0x24(%rbp), %xmm0
movss 0x18f44(%rip), %xmm1    # 0x17193c
ucomiss %xmm1, %xmm0
jbe 0x158a0a
movss 0x18f37(%rip), %xmm0    # 0x17193c
movss %xmm0, -0x24(%rbp)
leaq 0x241b6f(%rip), %rax    # 0x39a580
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movss -0x24(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movsd 0x16660(%rip), %xmm0    # 0x16f088
movsd 0x2a100(%rip), %xmm1    # 0x182b30
callq 0x94d0
movsd 0x16743(%rip), %xmm1    # 0x16f180
divsd %xmm1, %xmm0
callq 0x96f0
movaps %xmm0, %xmm1
movss -0x40(%rbp), %xmm0
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm0
leaq 0x241b0f(%rip), %rax    # 0x39a56c
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x3c(%rbp), %eax
leaq 0x241b05(%rip), %rdx    # 0x39a578
subl (%rdx), %ecx
cvtsi2ss %ecx, %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movl %eax, -0xc(%rbp)
leaq 0x241af4(%rip), %rax    # 0x39a584
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movss -0x24(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movsd 0x165e1(%rip), %xmm0    # 0x16f088
movsd 0x2a081(%rip), %xmm1    # 0x182b30
callq 0x94d0
movsd 0x166c4(%rip), %xmm1    # 0x16f180
divsd %xmm1, %xmm0
callq 0x9080
movaps %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm0
leaq 0x241a90(%rip), %rax    # 0x39a56c
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x34(%rbp), %eax
leaq 0x241a86(%rip), %rdx    # 0x39a578
subl (%rdx), %ecx
cvtsi2ss %ecx, %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
subl %ecx, %eax
movl %eax, -0x18(%rbp)
movl %eax, -0x10(%rbp)
movl $0x0, -0x8(%rbp)
cmpl $0x168, -0x8(%rbp)      # imm = 0x168
jg 0x158d1c
movslq -0x8(%rbp), %rcx
leaq 0x78e49(%rip), %rax     # 0x1d1970
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x158b3b
jp 0x158b3b
jmp 0x158be7
movslq -0x8(%rbp), %rcx
leaq 0x782ca(%rip), %rax     # 0x1d0e10
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x158b5a
jp 0x158b5a
jmp 0x158be7
leaq 0x121a94(%rip), %rax    # 0x27a5f5
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x158b95
movslq -0x8(%rbp), %rcx
leaq 0x7829c(%rip), %rax     # 0x1d0e10
movss (%rax,%rcx,4), %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x78dec(%rip), %rax     # 0x1d1970
divss (%rax,%rcx,4), %xmm0
divss -0x28(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x158bbf
movslq -0x8(%rbp), %rcx
leaq 0x78820(%rip), %rax     # 0x1d13c0
movss (%rax,%rcx,4), %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x78dc0(%rip), %rax     # 0x1d1970
divss (%rax,%rcx,4), %xmm0
divss -0x2c(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
movss 0x18d70(%rip), %xmm1    # 0x17193c
ucomiss %xmm1, %xmm0
jb 0x158bde
movss 0x18d63(%rip), %xmm0    # 0x17193c
movss %xmm0, -0x24(%rbp)
movl $0xa, -0x30(%rbp)
jmp 0x158bee
movl $0x9, -0x30(%rbp)
leaq 0x24198b(%rip), %rax    # 0x39a580
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movss -0x24(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movl -0x8(%rbp), %eax
addl $0x5a, %eax
cvtsi2sd %eax, %xmm0
movsd 0x29f1a(%rip), %xmm1    # 0x182b30
callq 0x94d0
movsd 0x1655d(%rip), %xmm1    # 0x16f180
divsd %xmm1, %xmm0
callq 0x96f0
movaps %xmm0, %xmm1
movss -0x50(%rbp), %xmm0
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm0
leaq 0x241929(%rip), %rax    # 0x39a56c
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x4c(%rbp), %eax
leaq 0x24191f(%rip), %rdx    # 0x39a578
subl (%rdx), %ecx
cvtsi2ss %ecx, %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
leaq 0x241911(%rip), %rax    # 0x39a584
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movss -0x24(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
movl -0x8(%rbp), %eax
addl $0x5a, %eax
cvtsi2sd %eax, %xmm0
movsd 0x29e9c(%rip), %xmm1    # 0x182b30
callq 0x94d0
movsd 0x164df(%rip), %xmm1    # 0x16f180
divsd %xmm1, %xmm0
callq 0x9080
movaps %xmm0, %xmm1
movss -0x48(%rbp), %xmm0
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm0
leaq 0x2418ab(%rip), %rax    # 0x39a56c
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x44(%rbp), %eax
leaq 0x2418a1(%rip), %rdx    # 0x39a578
subl (%rdx), %ecx
cvtsi2ss %ecx, %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
subl %ecx, %eax
movl %eax, -0x20(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x30(%rbp), %eax
movzbl %al, %r8d
callq 0x109c0
movl -0x1c(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x158b0f
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl $0x9, %r8d
callq 0x109c0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)