// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: analyze_hours()
void analyze_hours()
{
int i;
int j;
int k;
int interval;

   if(hour_lats == 0) return;

   // copy hourly medians to working array
   for(i=0; i<hour_lats; i++) {
      lat_bins[i] = lat_hr_bins[i];
      lon_bins[i] = lon_hr_bins[i];
      alt_bins[i] = alt_hr_bins[i];
   }

   minute_lats = minute_lons = minute_alts = 0;

   k = hour_lats;
   if(k > 24) k = 24;   // the size of the intervals we are analyzing (should be 24 hours)
   j = hour_lats - 24;
   if(j < 1) j = 1;     // the number of overlapping 24 hour intervals we have

   if(lla_file) fprintf(lla_file, "#\n# Processing %d %d hour intervals:\n", j, k);

   for(interval=0; interval<j; interval++) {
      if(lla_file) fprintf(lla_file, "#\n# Interval %d:\n", interval+1);

      hour_lats = hour_lons = hour_alts = 0;
      for(i=0; i<k; i++) {    // sort the interval's data into the median arrays
         hour_lats = add_to_bin(lat_bins[interval+i], lat_hr_bins, hour_lats);
         hour_lons = add_to_bin(lon_bins[interval+i], lon_hr_bins, hour_lons);
         hour_alts = add_to_bin(alt_bins[interval+i], alt_hr_bins, hour_alts);
      }

      show_precise_info(0);

      // calculate the weighted median of the 24 hour lat/lon/alt data
      interp = (double) hour_lats * LAT_HR_TURN;
      i = (int) interp;
      if(i < (hour_lats-1)) {
         xlat = (lat_hr_bins[i+1]-lat_hr_bins[i]) * (interp-(double)i);
         xlat += lat_hr_bins[i];
         minute_lats = add_to_bin(xlat, lat_min_bins, minute_lats);
         best_lat += xlat;
         if(lla_file) fprintf(lla_file, "# BEST %d: lat:%14.9f  %.9f\n",  i, xlat*RAD_TO_DEG, (xlat*RAD_TO_DEG-LAT_REF)/ANGLE_SCALE);
      }

      interp = (double) hour_lons * LON_HR_TURN;
      i = (int) interp;
      if(i < (hour_lons-1)) {
         xlon = (lon_hr_bins[i+1]-lon_hr_bins[i]) * (interp-(double)i);
         xlon += lon_hr_bins[i];
         minute_lons = add_to_bin(xlon, lon_min_bins, minute_lons);
         best_lon += xlon;
         if(lla_file) fprintf(lla_file, "# BEST %d: lon:%14.9f  %.9f\n",  i, xlon*RAD_TO_DEG, (xlon*RAD_TO_DEG-LON_REF)/ANGLE_SCALE*COS_FACTOR(xlat*RAD_TO_DEG));
      }

      interp = (double) hour_alts * ALT_HR_TURN;
      i = (int) interp;
      if(i < (hour_alts-1)) {
         xalt = (alt_hr_bins[i+1]-alt_hr_bins[i]) * (interp-(double)i);
         xalt += alt_hr_bins[i];
         minute_alts = add_to_bin(xalt, alt_min_bins, minute_alts);
         best_alt += xalt;
         if(lla_file) fprintf(lla_file, "# BEST %d: alt:%14.9f  %.9f\n",  i, xalt,  (xalt-ALT_REF)*FEET_PER_METER);
      }
      if(lla_file) fprintf(lla_file, "#\n");

      ++best_count;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
cmpl $0x0, 0x27c741(%rip)    # 0x3d8fc0
jne 0x15c886
jmp 0x15cefd
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x27c72a(%rip), %eax    # 0x3d8fc0
jge 0x15c903
movslq -0x4(%rbp), %rcx
leaq 0x27c72d(%rip), %rax    # 0x3d8fd0
movsd (%rax,%rcx,8), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x35563d(%rip), %rax    # 0x4b1ef0
movsd %xmm0, (%rax,%rcx,8)
movslq -0x4(%rbp), %rcx
leaq 0x27ca1d(%rip), %rax    # 0x3d92e0
movsd (%rax,%rcx,8), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x35592d(%rip), %rax    # 0x4b2200
movsd %xmm0, (%rax,%rcx,8)
movslq -0x4(%rbp), %rcx
leaq 0x35688d(%rip), %rax    # 0x4b3170
movsd (%rax,%rcx,8), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x355c1d(%rip), %rax    # 0x4b2510
movsd %xmm0, (%rax,%rcx,8)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x15c88d
movl $0x0, 0x356853(%rip)    # 0x4b3160
movl $0x0, 0x356845(%rip)    # 0x4b315c
movl $0x0, 0x356837(%rip)    # 0x4b3158
movl 0x27c699(%rip), %eax    # 0x3d8fc0
movl %eax, -0xc(%rbp)
cmpl $0x18, -0xc(%rbp)
jle 0x15c937
movl $0x18, -0xc(%rbp)
movl 0x27c683(%rip), %eax    # 0x3d8fc0
subl $0x18, %eax
movl %eax, -0x8(%rbp)
cmpl $0x1, -0x8(%rbp)
jge 0x15c950
movl $0x1, -0x8(%rbp)
leaq 0x140c29(%rip), %rax    # 0x29d580
cmpq $0x0, (%rax)
je 0x15c97b
leaq 0x140c1c(%rip), %rax    # 0x29d580
movq (%rax), %rdi
movl -0x8(%rbp), %edx
movl -0xc(%rbp), %ecx
leaq 0x3baa8(%rip), %rsi     # 0x19841c
movb $0x0, %al
callq 0x9550
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x15cefd
leaq 0x140beb(%rip), %rax    # 0x29d580
cmpq $0x0, (%rax)
je 0x15c9b9
leaq 0x140bde(%rip), %rax    # 0x29d580
movq (%rax), %rdi
movl -0x10(%rbp), %edx
addl $0x1, %edx
leaq 0x3ba90(%rip), %rsi     # 0x198442
movb $0x0, %al
callq 0x9550
movl $0x0, 0x356ab5(%rip)    # 0x4b3478
movl $0x0, 0x27c5f7(%rip)    # 0x3d8fc4
movl $0x0, 0x27c5e9(%rip)    # 0x3d8fc0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x15ca7f
movl -0x10(%rbp), %eax
addl -0x4(%rbp), %eax
movslq %eax, %rcx
leaq 0x3554f6(%rip), %rax    # 0x4b1ef0
movsd (%rax,%rcx,8), %xmm0
movl 0x27c5bb(%rip), %esi    # 0x3d8fc0
leaq 0x27c5c4(%rip), %rdi    # 0x3d8fd0
callq 0x15c580
movl %eax, 0x27c5a9(%rip)    # 0x3d8fc0
movl -0x10(%rbp), %eax
addl -0x4(%rbp), %eax
movslq %eax, %rcx
leaq 0x3557d9(%rip), %rax    # 0x4b2200
movsd (%rax,%rcx,8), %xmm0
movl 0x27c592(%rip), %esi    # 0x3d8fc4
leaq 0x27c8a7(%rip), %rdi    # 0x3d92e0
callq 0x15c580
movl %eax, 0x27c580(%rip)    # 0x3d8fc4
movl -0x10(%rbp), %eax
addl -0x4(%rbp), %eax
movslq %eax, %rcx
leaq 0x355abc(%rip), %rax    # 0x4b2510
movsd (%rax,%rcx,8), %xmm0
movl 0x356a19(%rip), %esi    # 0x4b3478
leaq 0x35670a(%rip), %rdi    # 0x4b3170
callq 0x15c580
movl %eax, 0x356a07(%rip)    # 0x4b3478
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x15c9de
xorl %edi, %edi
callq 0x15c630
cvtsi2sdl 0x27c532(%rip), %xmm0 # 0x3d8fc0
movsd 0x125fa(%rip), %xmm1    # 0x16f090
mulsd %xmm1, %xmm0
movsd %xmm0, 0x3553ee(%rip)   # 0x4b1e90
cvttsd2si 0x3553e6(%rip), %eax # 0x4b1e90
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl 0x27c50a(%rip), %ecx    # 0x3d8fc0
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x15cbe2
movl -0x4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x27c4ff(%rip), %rax    # 0x3d8fd0
movsd (%rax,%rcx,8), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x27c4ef(%rip), %rax    # 0x3d8fd0
subsd (%rax,%rcx,8), %xmm0
movsd 0x3553a2(%rip), %xmm1   # 0x4b1e90
cvtsi2sdl -0x4(%rbp), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x355395(%rip)   # 0x4b1e98
movslq -0x4(%rbp), %rcx
leaq 0x27c4c2(%rip), %rax    # 0x3d8fd0
movsd (%rax,%rcx,8), %xmm0
addsd 0x35537d(%rip), %xmm0   # 0x4b1e98
movsd %xmm0, 0x355375(%rip)   # 0x4b1e98
movsd 0x35536d(%rip), %xmm0   # 0x4b1e98
movl 0x356627(%rip), %esi    # 0x4b3158
leaq 0x355cf8(%rip), %rdi    # 0x4b2830
callq 0x15c580
movl %eax, 0x356615(%rip)    # 0x4b3158
movsd 0x35534d(%rip), %xmm0   # 0x4b1e98
addsd 0x355375(%rip), %xmm0   # 0x4b1ec8
movsd %xmm0, 0x35536d(%rip)   # 0x4b1ec8
leaq 0x140a1e(%rip), %rax    # 0x29d580
cmpq $0x0, (%rax)
je 0x15cbe0
leaq 0x140a11(%rip), %rax    # 0x29d580
movq (%rax), %rdi
movl -0x4(%rbp), %edx
movsd 0x12603(%rip), %xmm0    # 0x16f180
mulsd 0x355313(%rip), %xmm0   # 0x4b1e98
movsd 0x35530b(%rip), %xmm1   # 0x4b1e98
movsd 0x125eb(%rip), %xmm2    # 0x16f180
leaq 0x23d934(%rip), %rax    # 0x39a4d0
mulsd (%rax), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
movsd 0x125c1(%rip), %xmm3    # 0x16f180
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
leaq 0x20f5ca(%rip), %rax    # 0x36c198
divsd (%rax), %xmm1
leaq 0x3b87b(%rip), %rsi     # 0x198454
movb $0x2, %al
callq 0x9550
jmp 0x15cbe2
cvtsi2sdl 0x27c3da(%rip), %xmm0 # 0x3d8fc4
movsd 0x1249e(%rip), %xmm1    # 0x16f090
mulsd %xmm1, %xmm0
movsd %xmm0, 0x355292(%rip)   # 0x4b1e90
cvttsd2si 0x35528a(%rip), %eax # 0x4b1e90
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl 0x27c3b2(%rip), %ecx    # 0x3d8fc4
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x15cd8c
movl -0x4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x27c6b3(%rip), %rax    # 0x3d92e0
movsd (%rax,%rcx,8), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x27c6a3(%rip), %rax    # 0x3d92e0
subsd (%rax,%rcx,8), %xmm0
movsd 0x355246(%rip), %xmm1   # 0x4b1e90
cvtsi2sdl -0x4(%rbp), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x355241(%rip)   # 0x4b1ea0
movslq -0x4(%rbp), %rcx
leaq 0x27c676(%rip), %rax    # 0x3d92e0
movsd (%rax,%rcx,8), %xmm0
addsd 0x355229(%rip), %xmm0   # 0x4b1ea0
movsd %xmm0, 0x355221(%rip)   # 0x4b1ea0
movsd 0x355219(%rip), %xmm0   # 0x4b1ea0
movl 0x3564cf(%rip), %esi    # 0x4b315c
leaq 0x355eac(%rip), %rdi    # 0x4b2b40
callq 0x15c580
movl %eax, 0x3564bd(%rip)    # 0x4b315c
movsd 0x3551f9(%rip), %xmm0   # 0x4b1ea0
addsd 0x355221(%rip), %xmm0   # 0x4b1ed0
movsd %xmm0, 0x355219(%rip)   # 0x4b1ed0
leaq 0x1408c2(%rip), %rax    # 0x29d580
cmpq $0x0, (%rax)
je 0x15cd8a
leaq 0x1408b1(%rip), %rax    # 0x29d580
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x1c(%rbp)
movsd 0x1249c(%rip), %xmm0    # 0x16f180
mulsd 0x3551b4(%rip), %xmm0   # 0x4b1ea0
movsd %xmm0, -0x18(%rbp)
movsd 0x3551a7(%rip), %xmm0   # 0x4b1ea0
movsd 0x1247f(%rip), %xmm1    # 0x16f180
leaq 0x23d7d0(%rip), %rax    # 0x39a4d8
mulsd (%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x12455(%rip), %xmm2    # 0x16f180
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
leaq 0x20f45e(%rip), %rax    # 0x36c198
divsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x12435(%rip), %xmm0    # 0x16f180
mulsd 0x355145(%rip), %xmm0   # 0x4b1e98
movsd 0x12425(%rip), %xmm1    # 0x16f180
divsd %xmm1, %xmm0
callq 0x96f0
movsd -0x30(%rbp), %xmm1
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %edx
movaps %xmm0, %xmm2
movsd -0x18(%rbp), %xmm0
mulsd %xmm2, %xmm1
leaq 0x3b6ee(%rip), %rsi     # 0x198471
movb $0x2, %al
callq 0x9550
jmp 0x15cd8c
cvtsi2sdl 0x3566e4(%rip), %xmm0 # 0x4b3478
movsd 0x122f4(%rip), %xmm1    # 0x16f090
mulsd %xmm1, %xmm0
movsd %xmm0, 0x3550e8(%rip)   # 0x4b1e90
cvttsd2si 0x3550e0(%rip), %eax # 0x4b1e90
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl 0x3566bc(%rip), %ecx    # 0x4b3478
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x15ceb2
movl -0x4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x356399(%rip), %rax    # 0x4b3170
movsd (%rax,%rcx,8), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x356389(%rip), %rax    # 0x4b3170
subsd (%rax,%rcx,8), %xmm0
movsd 0x35509c(%rip), %xmm1   # 0x4b1e90
cvtsi2sdl -0x4(%rbp), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x35509f(%rip)   # 0x4b1ea8
movslq -0x4(%rbp), %rcx
leaq 0x35635c(%rip), %rax    # 0x4b3170
movsd (%rax,%rcx,8), %xmm0
addsd 0x355087(%rip), %xmm0   # 0x4b1ea8
movsd %xmm0, 0x35507f(%rip)   # 0x4b1ea8
movsd 0x355077(%rip), %xmm0   # 0x4b1ea8
movl 0x356329(%rip), %esi    # 0x4b3160
leaq 0x356012(%rip), %rdi    # 0x4b2e50
callq 0x15c580
movl %eax, 0x356317(%rip)    # 0x4b3160
movsd 0x355057(%rip), %xmm0   # 0x4b1ea8
addsd 0x35507f(%rip), %xmm0   # 0x4b1ed8
movsd %xmm0, 0x355077(%rip)   # 0x4b1ed8
leaq 0x140718(%rip), %rax    # 0x29d580
cmpq $0x0, (%rax)
je 0x15ceb0
leaq 0x14070b(%rip), %rax    # 0x29d580
movq (%rax), %rdi
movl -0x4(%rbp), %edx
movsd 0x355025(%rip), %xmm0   # 0x4b1ea8
movsd 0x35501d(%rip), %xmm1   # 0x4b1ea8
leaq 0x23d64e(%rip), %rax    # 0x39a4e0
subsd (%rax), %xmm1
movsd 0x14792(%rip), %xmm2    # 0x171630
mulsd %xmm2, %xmm1
leaq 0x3b5e5(%rip), %rsi     # 0x19848e
movb $0x2, %al
callq 0x9550
jmp 0x15ceb2
leaq 0x1406c7(%rip), %rax    # 0x29d580
cmpq $0x0, (%rax)
je 0x15ced7
leaq 0x1406ba(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x37599(%rip), %rsi     # 0x194469
movb $0x0, %al
callq 0x9550
movsd 0x12189(%rip), %xmm0    # 0x16f068
addsd 0x354ff9(%rip), %xmm0   # 0x4b1ee0
movsd %xmm0, 0x354ff1(%rip)   # 0x4b1ee0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x15c982
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)