// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl 0x27cd92(%rip), %eax    # 0x379d80
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0xfd5ef
movq -0x38(%rbp), %r15
testl %r15d, %r15d
jle 0xfd04e
leaq (,%r15,8), %rbx
leaq 0x3558ed(%rip), %rdi    # 0x452900
leaq 0x27cd76(%rip), %rsi    # 0x379d90
movq %rbx, %rdx
callq 0x92b0
leaq 0x355be7(%rip), %rdi    # 0x452c10
leaq 0x27d070(%rip), %rsi    # 0x37a0a0
movq %rbx, %rdx
callq 0x92b0
leaq 0x355ee1(%rip), %rdi    # 0x452f20
leaq 0x356b3a(%rip), %rsi    # 0x453b80
movq %rbx, %rdx
callq 0x92b0
xorl %eax, %eax
movl %eax, 0x356b1a(%rip)    # 0x453b70
movl %eax, 0x356b10(%rip)    # 0x453b6c
movl %eax, 0x356b06(%rip)    # 0x453b68
cmpl $0x18, %r15d
movl $0x18, %ebx
cmovll %r15d, %ebx
cmpl $0x1a, %r15d
movl $0x19, %r14d
cmovgel %r15d, %r14d
addl $-0x18, %r14d
leaq 0x141318(%rip), %rax    # 0x23e3a0
movq (%rax), %rdi
testq %rdi, %rdi
je 0xfd0aa
leaq 0x387f3(%rip), %rsi     # 0x13588a
movl %r14d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x9560
leaq 0x1412f6(%rip), %rax    # 0x23e3a0
movl %r14d, %ecx
movq %rcx, -0x58(%rbp)
movq (%rax), %rdi
movl %ebx, %r15d
leaq 0x355842(%rip), %r9     # 0x452900
leaq 0x355b4b(%rip), %r10    # 0x452c10
leaq 0x355e54(%rip), %r11    # 0x452f20
leaq 0x356aad(%rip), %r12    # 0x453b80
leaq 0x27cfc6(%rip), %r13    # 0x37a0a0
leaq 0x27ccaf(%rip), %r14    # 0x379d90
xorl %ebx, %ebx
testq %rdi, %rdi
je 0xfd10e
leal 0x1(%rbx), %edx
leaq 0x387be(%rip), %rsi     # 0x1358b0
xorl %eax, %eax
callq 0x9560
leaq 0x355e20(%rip), %r11    # 0x452f20
leaq 0x355b09(%rip), %r10    # 0x452c10
leaq 0x3557f2(%rip), %r9     # 0x452900
xorl %eax, %eax
movl %eax, 0x356d72(%rip)    # 0x453e88
movl %eax, 0x27cc68(%rip)    # 0x379d84
movl %eax, 0x27cc5e(%rip)    # 0x379d80
cmpl $0x0, -0x38(%rbp)
jle 0xfd222
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
leaq (%rax,%rbx), %rdi
cmpl $0x5f, %ecx
jg 0xfd17c
movsd (%r9,%rdi,8), %xmm0
movslq %ecx, %r8
movsd %xmm0, (%r14,%r8,8)
testl %ecx, %ecx
jle 0xfd17a
movl %ecx, %r8d
incq %r8
movsd -0x10(%r14,%r8,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfd17a
movsd %xmm1, -0x8(%r14,%r8,8)
movsd %xmm0, -0x10(%r14,%r8,8)
decq %r8
cmpq $0x1, %r8
ja 0xfd156
incl %ecx
cmpl $0x5f, %edx
jg 0xfd1c1
movsd (%r10,%rdi,8), %xmm0
movslq %edx, %r8
movsd %xmm0, (%r13,%r8,8)
testl %edx, %edx
jle 0xfd1bf
movl %edx, %r8d
incq %r8
movsd -0x10(%r13,%r8,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfd1bf
movsd %xmm1, -0x8(%r13,%r8,8)
movsd %xmm0, -0x10(%r13,%r8,8)
decq %r8
cmpq $0x1, %r8
ja 0xfd19b
incl %edx
cmpl $0x5f, %esi
jg 0xfd204
movsd (%r11,%rdi,8), %xmm0
movslq %esi, %rdi
movsd %xmm0, (%r12,%rdi,8)
testl %esi, %esi
jle 0xfd202
movl %esi, %edi
incq %rdi
movsd -0x10(%r12,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfd202
movsd %xmm1, -0x8(%r12,%rdi,8)
movsd %xmm0, -0x10(%r12,%rdi,8)
decq %rdi
cmpq $0x1, %rdi
ja 0xfd1de
incl %esi
incq %rax
cmpq %r15, %rax
jne 0xfd134
movl %ecx, 0x27cb6a(%rip)    # 0x379d80
movl %edx, 0x27cb68(%rip)    # 0x379d84
movl %esi, 0x356c66(%rip)    # 0x453e88
xorl %edi, %edi
callq 0xfce1f
movl 0x27cb51(%rip), %eax    # 0x379d80
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0xbe2a(%rip), %xmm0     # 0x109068
movsd %xmm0, 0x35565a(%rip)   # 0x4528a0
cvttsd2si %xmm0, %edx
decl %eax
cmpl %edx, %eax
leaq 0x14114b(%rip), %rsi    # 0x23e3a0
jle 0xfd331
movslq %edx, %rax
movsd (%r14,%rax,8), %xmm1
movsd 0x8(%r14,%rax,8), %xmm2
subsd %xmm1, %xmm2
xorps %xmm3, %xmm3
cvtsi2sd %edx, %xmm3
subsd %xmm3, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x35561e(%rip)   # 0x4528a8
movslq 0x3568d7(%rip), %rax    # 0x453b68
cmpq $0x5f, %rax
jg 0xfd2d0
leaq 0x355fa2(%rip), %rdi    # 0x453240
movsd %xmm0, (%rdi,%rax,8)
testl %eax, %eax
jle 0xfd2ce
movq %rax, %rcx
incq %rcx
movsd -0x10(%rdi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfd2ce
movsd %xmm1, -0x8(%rdi,%rcx,8)
movsd %xmm0, -0x10(%rdi,%rcx,8)
decq %rcx
cmpq $0x1, %rcx
ja 0xfd2ad
incl %eax
movl %eax, 0x356892(%rip)    # 0x453b68
movsd 0x3555fa(%rip), %xmm1   # 0x4528d8
addsd %xmm0, %xmm1
movsd %xmm1, 0x3555ee(%rip)   # 0x4528d8
movq (%rsi), %rdi
testq %rdi, %rdi
je 0xfd331
mulsd 0xbe66(%rip), %xmm0     # 0x109160
leaq 0x23dfef(%rip), %rax    # 0x33b2f0
movsd (%rax), %xmm1
mulsd 0x2e893(%rip), %xmm1    # 0x12bba0
addsd %xmm0, %xmm1
leaq 0x20fca0(%rip), %rax    # 0x30cfb8
divsd (%rax), %xmm1
leaq 0x3859f(%rip), %rsi     # 0x1358c2
movb $0x2, %al
callq 0x9560
leaq 0x14106f(%rip), %rsi    # 0x23e3a0
movl 0x27ca4d(%rip), %eax    # 0x379d84
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
mulsd 0xbd22(%rip), %xmm3     # 0x109068
movsd %xmm3, 0x355552(%rip)   # 0x4528a0
cvttsd2si %xmm3, %r8d
decl %eax
cmpl %r8d, %eax
leaq 0x356501(%rip), %rdi    # 0x453860
jle 0xfd488
movslq %r8d, %rax
movsd (%r13,%rax,8), %xmm0
movsd 0x8(%r13,%rax,8), %xmm1
subsd %xmm0, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %r8d, %xmm2
subsd %xmm2, %xmm3
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
movsd %xmm3, 0x35551a(%rip)   # 0x4528b0
movslq 0x3567cf(%rip), %rax    # 0x453b6c
cmpq $0x5f, %rax
jg 0xfd3dc
leaq 0x3561a6(%rip), %rdx    # 0x453550
movsd %xmm3, (%rdx,%rax,8)
testl %eax, %eax
jle 0xfd3da
movq %rax, %rcx
incq %rcx
movsd -0x10(%rdx,%rcx,8), %xmm0
ucomisd %xmm3, %xmm0
jbe 0xfd3da
movsd %xmm0, -0x8(%rdx,%rcx,8)
movsd %xmm3, -0x10(%rdx,%rcx,8)
decq %rcx
cmpq $0x1, %rcx
ja 0xfd3b9
incl %eax
movl %eax, 0x35678a(%rip)    # 0x453b6c
movsd 0x3554f6(%rip), %xmm0   # 0x4528e0
addsd %xmm3, %xmm0
movsd %xmm0, 0x3554ea(%rip)   # 0x4528e0
movq (%rsi), %rax
testq %rax, %rax
je 0xfd488
movsd 0xbd56(%rip), %xmm1     # 0x109160
mulsd %xmm1, %xmm3
movsd %xmm3, -0x40(%rbp)
movq %rax, -0x50(%rbp)
leaq 0x23deda(%rip), %rax    # 0x33b2f8
movsd (%rax), %xmm0
mulsd 0x2e776(%rip), %xmm0    # 0x12bba0
addsd %xmm3, %xmm0
leaq 0x20fb83(%rip), %rax    # 0x30cfb8
divsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd 0x355462(%rip), %xmm0   # 0x4528a8
mulsd %xmm1, %xmm0
divsd %xmm1, %xmm0
movl %r8d, -0x2c(%rbp)
callq 0x9710
movsd -0x48(%rbp), %xmm1
mulsd %xmm0, %xmm1
movq -0x50(%rbp), %rdi
leaq 0x38474(%rip), %rsi     # 0x1358df
movl -0x2c(%rbp), %edx
movsd -0x40(%rbp), %xmm0
movb $0x2, %al
callq 0x9560
leaq 0x3563df(%rip), %rdi    # 0x453860
leaq 0x140f18(%rip), %rsi    # 0x23e3a0
movl 0x3569fa(%rip), %eax    # 0x453e88
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0xbbcb(%rip), %xmm0     # 0x109068
movsd %xmm0, 0x3553fb(%rip)   # 0x4528a0
cvttsd2si %xmm0, %edx
decl %eax
cmpl %edx, %eax
jle 0xfd583
movslq %edx, %rax
movsd (%r12,%rax,8), %xmm1
movsd 0x8(%r12,%rax,8), %xmm2
subsd %xmm1, %xmm2
xorps %xmm3, %xmm3
cvtsi2sd %edx, %xmm3
subsd %xmm3, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x3553d6(%rip)   # 0x4528b8
movslq 0x356687(%rip), %rax    # 0x453b70
cmpq $0x5f, %rax
jle 0xfd4f8
leaq 0x35540a(%rip), %r9     # 0x452900
jmp 0xfd531
movsd %xmm0, (%rdi,%rax,8)
testl %eax, %eax
leaq 0x3553fa(%rip), %r9     # 0x452900
jle 0xfd52f
movq %rax, %rcx
incq %rcx
movsd -0x10(%rdi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfd52f
movsd %xmm1, -0x8(%rdi,%rcx,8)
movsd %xmm0, -0x10(%rdi,%rcx,8)
decq %rcx
cmpq $0x1, %rcx
ja 0xfd50e
incl %eax
movl %eax, 0x356639(%rip)    # 0x453b70
movsd 0x3553a9(%rip), %xmm1   # 0x4528e8
addsd %xmm0, %xmm1
movsd %xmm1, 0x35539d(%rip)   # 0x4528e8
movq (%rsi), %rdi
testq %rdi, %rdi
je 0xfd5eb
movapd %xmm0, %xmm1
leaq 0x23dd9e(%rip), %rax    # 0x33b300
subsd (%rax), %xmm1
mulsd 0xe33a(%rip), %xmm1     # 0x10b8a8
leaq 0x38387(%rip), %rsi     # 0x1358fc
movb $0x2, %al
callq 0x9560
leaq 0x140e1d(%rip), %rsi    # 0x23e3a0
movq (%rsi), %rcx
testq %rcx, %rcx
je 0xfd5ad
movl $0x2, %esi
movl $0x1, %edx
leaq 0x343d1(%rip), %rdi     # 0x13196d
callq 0x9750
leaq 0x140df8(%rip), %rax    # 0x23e3a0
movq (%rax), %rdi
jmp 0xfd5af
xorl %edi, %edi
leaq 0x35534a(%rip), %r9     # 0x452900
movsd 0x355332(%rip), %xmm0   # 0x4528f0
addsd 0xbaaa(%rip), %xmm0     # 0x109070
movsd %xmm0, 0x355322(%rip)   # 0x4528f0
incq %rbx
cmpq -0x58(%rbp), %rbx
leaq 0x355634(%rip), %r10    # 0x452c10
leaq 0x35593d(%rip), %r11    # 0x452f20
jne 0xfd0e3
jmp 0xfd5ef
xorl %edi, %edi
jmp 0xfd5b6
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq