// File: /workspace/github_cpp_makefile_star2_O1/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 0x27d4d0(%rip), %eax    # 0x379d80
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0xfcebd
movq -0x38(%rbp), %r15
testl %r15d, %r15d
jle 0xfc910
leaq (,%r15,8), %rbx
leaq 0x35610b(%rip), %rdi    # 0x4529e0
leaq 0x27d4b4(%rip), %rsi    # 0x379d90
movq %rbx, %rdx
callq 0x92b0
leaq 0x356405(%rip), %rdi    # 0x452cf0
leaq 0x27d7ae(%rip), %rsi    # 0x37a0a0
movq %rbx, %rdx
callq 0x92b0
leaq 0x3566ff(%rip), %rdi    # 0x453000
leaq 0x357358(%rip), %rsi    # 0x453c60
movq %rbx, %rdx
callq 0x92b0
xorl %eax, %eax
movl %eax, 0x357338(%rip)    # 0x453c50
movl %eax, 0x35732e(%rip)    # 0x453c4c
movl %eax, 0x357324(%rip)    # 0x453c48
cmpl $0x18, %r15d
movl $0x18, %ebx
cmovll %r15d, %ebx
cmpl $0x1a, %r15d
movl $0x19, %r14d
cmovgel %r15d, %r14d
addl $-0x18, %r14d
leaq 0x141a56(%rip), %rax    # 0x23e3a0
movq (%rax), %rdi
testq %rdi, %rdi
je 0xfc965
leaq 0x38e41(%rip), %rsi     # 0x13579a
movl %r14d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x9560
movl %r14d, %eax
movq %rax, -0x58(%rbp)
movl %ebx, %r15d
leaq 0x35606a(%rip), %r9     # 0x4529e0
leaq 0x356373(%rip), %r10    # 0x452cf0
leaq 0x35667c(%rip), %r11    # 0x453000
leaq 0x3572d5(%rip), %r13    # 0x453c60
leaq 0x27d70e(%rip), %r12    # 0x37a0a0
leaq 0x27d3f7(%rip), %r14    # 0x379d90
xorl %ebx, %ebx
leaq 0x1419fe(%rip), %rax    # 0x23e3a0
movq (%rax), %rdi
testq %rdi, %rdi
je 0xfc9d0
leal 0x1(%rbx), %edx
leaq 0x38e0c(%rip), %rsi     # 0x1357c0
xorl %eax, %eax
callq 0x9560
leaq 0x35663e(%rip), %r11    # 0x453000
leaq 0x356327(%rip), %r10    # 0x452cf0
leaq 0x356010(%rip), %r9     # 0x4529e0
xorl %eax, %eax
movl %eax, 0x357590(%rip)    # 0x453f68
movl %eax, 0x27d3a6(%rip)    # 0x379d84
movl %eax, 0x27d39c(%rip)    # 0x379d80
cmpl $0x0, -0x38(%rbp)
jle 0xfcae4
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
leaq (%rax,%rbx), %rdi
cmpl $0x5f, %ecx
jg 0xfca3e
movsd (%r9,%rdi,8), %xmm0
movslq %ecx, %r8
movsd %xmm0, (%r14,%r8,8)
testl %ecx, %ecx
jle 0xfca3c
movl %ecx, %r8d
incq %r8
movsd -0x10(%r14,%r8,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfca3c
movsd %xmm1, -0x8(%r14,%r8,8)
movsd %xmm0, -0x10(%r14,%r8,8)
decq %r8
cmpq $0x1, %r8
jg 0xfca18
incl %ecx
cmpl $0x5f, %edx
jg 0xfca82
movsd (%r10,%rdi,8), %xmm0
movslq %edx, %r8
movsd %xmm0, (%r12,%r8,8)
testl %edx, %edx
jle 0xfca80
movl %edx, %r8d
incq %r8
movsd -0x10(%r12,%r8,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfca80
movsd %xmm1, -0x8(%r12,%r8,8)
movsd %xmm0, -0x10(%r12,%r8,8)
decq %r8
cmpq $0x1, %r8
jg 0xfca5c
incl %edx
cmpl $0x5f, %esi
jg 0xfcac6
movsd (%r11,%rdi,8), %xmm0
movslq %esi, %rdi
movsd %xmm0, (%r13,%rdi,8)
testl %esi, %esi
jle 0xfcac4
movl %esi, %edi
incq %rdi
movsd -0x10(%r13,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfcac4
movsd %xmm1, -0x8(%r13,%rdi,8)
movsd %xmm0, -0x10(%r13,%rdi,8)
decq %rdi
cmpq $0x1, %rdi
jg 0xfcaa0
incl %esi
incq %rax
cmpq %r15, %rax
jne 0xfc9f6
movl %ecx, 0x27d2a8(%rip)    # 0x379d80
movl %edx, 0x27d2a6(%rip)    # 0x379d84
movl %esi, 0x357484(%rip)    # 0x453f68
xorl %edi, %edi
callq 0xfc6dd
movl 0x27d28f(%rip), %eax    # 0x379d80
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0xc568(%rip), %xmm0     # 0x109068
movsd %xmm0, 0x355e78(%rip)   # 0x452980
cvttsd2si %xmm0, %edx
decl %eax
cmpl %edx, %eax
jle 0xfcbec
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, 0x355e43(%rip)   # 0x452988
movslq 0x3570fc(%rip), %rax    # 0x453c48
cmpq $0x5f, %rax
jg 0xfcb8b
leaq 0x3567c7(%rip), %rsi    # 0x453320
movsd %xmm0, (%rsi,%rax,8)
testl %eax, %eax
jle 0xfcb89
movq %rax, %rcx
incq %rcx
movsd -0x10(%rsi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfcb89
movsd %xmm1, -0x8(%rsi,%rcx,8)
movsd %xmm0, -0x10(%rsi,%rcx,8)
decq %rcx
cmpq $0x1, %rcx
jg 0xfcb68
incl %eax
movl %eax, 0x3570b7(%rip)    # 0x453c48
movsd 0x355e1f(%rip), %xmm1   # 0x4529b8
addsd %xmm0, %xmm1
movsd %xmm1, 0x355e13(%rip)   # 0x4529b8
leaq 0x1417f4(%rip), %rax    # 0x23e3a0
movq (%rax), %rdi
testq %rdi, %rdi
je 0xfcbec
mulsd 0xc59c(%rip), %xmm0     # 0x109158
leaq 0x23e72d(%rip), %rax    # 0x33b2f0
movsd (%rax), %xmm1
mulsd 0x2eef1(%rip), %xmm1    # 0x12bac0
addsd %xmm0, %xmm1
leaq 0x2103de(%rip), %rax    # 0x30cfb8
divsd (%rax), %xmm1
leaq 0x38bed(%rip), %rsi     # 0x1357d2
movb $0x2, %al
callq 0x9560
movl 0x27d192(%rip), %eax    # 0x379d84
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
mulsd 0xc467(%rip), %xmm3     # 0x109068
movsd %xmm3, 0x355d77(%rip)   # 0x452980
cvttsd2si %xmm3, %esi
decl %eax
cmpl %esi, %eax
leaq 0x355dc8(%rip), %r9     # 0x4529e0
leaq 0x3560d1(%rip), %r10    # 0x452cf0
leaq 0x3563da(%rip), %r11    # 0x453000
jle 0xfcd5a
movslq %esi, %rax
movsd (%r12,%rax,8), %xmm0
movsd 0x8(%r12,%rax,8), %xmm1
subsd %xmm0, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %esi, %xmm2
subsd %xmm2, %xmm3
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
movsd %xmm3, 0x355d35(%rip)   # 0x452990
movslq 0x356fea(%rip), %rax    # 0x453c4c
cmpq $0x5f, %rax
jg 0xfcca1
leaq 0x3569c1(%rip), %rdx    # 0x453630
movsd %xmm3, (%rdx,%rax,8)
testl %eax, %eax
jle 0xfcc9f
movq %rax, %rcx
incq %rcx
movsd -0x10(%rdx,%rcx,8), %xmm0
ucomisd %xmm3, %xmm0
jbe 0xfcc9f
movsd %xmm0, -0x8(%rdx,%rcx,8)
movsd %xmm3, -0x10(%rdx,%rcx,8)
decq %rcx
cmpq $0x1, %rcx
jg 0xfcc7e
incl %eax
movl %eax, 0x356fa5(%rip)    # 0x453c4c
movsd 0x355d11(%rip), %xmm0   # 0x4529c0
addsd %xmm3, %xmm0
movsd %xmm0, 0x355d05(%rip)   # 0x4529c0
leaq 0x1416de(%rip), %rax    # 0x23e3a0
movq (%rax), %rcx
testq %rcx, %rcx
je 0xfcd5a
movsd 0xc482(%rip), %xmm1     # 0x109158
mulsd %xmm1, %xmm3
movsd %xmm3, -0x48(%rbp)
leaq 0x23e612(%rip), %rax    # 0x33b2f8
movsd (%rax), %xmm0
mulsd 0x2edce(%rip), %xmm0    # 0x12bac0
addsd %xmm3, %xmm0
leaq 0x2102bb(%rip), %rax    # 0x30cfb8
divsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd 0x355c7a(%rip), %xmm0   # 0x452988
mulsd %xmm1, %xmm0
divsd %xmm1, %xmm0
movl %esi, -0x2c(%rbp)
movq %rcx, -0x40(%rbp)
callq 0x9710
movsd -0x50(%rbp), %xmm1
mulsd %xmm0, %xmm1
movq -0x40(%rbp), %rdi
leaq 0x38ab9(%rip), %rsi     # 0x1357ef
movl -0x2c(%rbp), %edx
movsd -0x48(%rbp), %xmm0
movb $0x2, %al
callq 0x9560
leaq 0x3562b4(%rip), %r11    # 0x453000
leaq 0x355f9d(%rip), %r10    # 0x452cf0
leaq 0x355c86(%rip), %r9     # 0x4529e0
movl 0x357208(%rip), %eax    # 0x453f68
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0xc2f9(%rip), %xmm0     # 0x109068
movsd %xmm0, 0x355c09(%rip)   # 0x452980
cvttsd2si %xmm0, %edx
decl %eax
cmpl %edx, %eax
jle 0xfce5e
movslq %edx, %rax
movsd (%r13,%rax,8), %xmm1
movsd 0x8(%r13,%rax,8), %xmm2
subsd %xmm1, %xmm2
xorps %xmm3, %xmm3
cvtsi2sd %edx, %xmm3
subsd %xmm3, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x355be3(%rip)   # 0x452998
movslq 0x356e94(%rip), %rax    # 0x453c50
cmpq $0x5f, %rax
jg 0xfcdfb
leaq 0x356b77(%rip), %rsi    # 0x453940
movsd %xmm0, (%rsi,%rax,8)
testl %eax, %eax
jle 0xfcdf9
movq %rax, %rcx
incq %rcx
movsd -0x10(%rsi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfcdf9
movsd %xmm1, -0x8(%rsi,%rcx,8)
movsd %xmm0, -0x10(%rsi,%rcx,8)
decq %rcx
cmpq $0x1, %rcx
jg 0xfcdd8
incl %eax
movl %eax, 0x356e4f(%rip)    # 0x453c50
movsd 0x355bbf(%rip), %xmm1   # 0x4529c8
addsd %xmm0, %xmm1
movsd %xmm1, 0x355bb3(%rip)   # 0x4529c8
leaq 0x141584(%rip), %rax    # 0x23e3a0
movq (%rax), %rdi
testq %rdi, %rdi
je 0xfce5e
movapd %xmm0, %xmm1
leaq 0x23e4d1(%rip), %rax    # 0x33b300
subsd (%rax), %xmm1
mulsd 0xea5d(%rip), %xmm1     # 0x10b898
leaq 0x389ca(%rip), %rsi     # 0x13580c
movb $0x2, %al
callq 0x9560
leaq 0x3561b0(%rip), %r11    # 0x453000
leaq 0x355e99(%rip), %r10    # 0x452cf0
leaq 0x355b82(%rip), %r9     # 0x4529e0
leaq 0x14153b(%rip), %rax    # 0x23e3a0
movq (%rax), %rcx
testq %rcx, %rcx
je 0xfce98
movl $0x2, %esi
movl $0x1, %edx
leaq 0x349ff(%rip), %rdi     # 0x13187d
callq 0x9750
leaq 0x356176(%rip), %r11    # 0x453000
leaq 0x355e5f(%rip), %r10    # 0x452cf0
leaq 0x355b48(%rip), %r9     # 0x4529e0
movsd 0x355b30(%rip), %xmm0   # 0x4529d0
addsd 0xc1c8(%rip), %xmm0     # 0x109070
movsd %xmm0, 0x355b20(%rip)   # 0x4529d0
incq %rbx
cmpq -0x58(%rbp), %rbx
jne 0xfc99b
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq