// File: /workspace/github_cpp_makefile_star2_O2/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:
movl 0x27c8e0(%rip), %eax    # 0x363d80
testl %eax, %eax
je 0xe7955
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
shlq $0x3, %rdx
cmpq %rcx, %rdx
je 0xe750b
leaq 0x27c8cc(%rip), %rsi    # 0x363d90
movsd (%rcx,%rsi), %xmm0
leaq 0x355430(%rip), %rsi    # 0x43c900
movsd %xmm0, (%rcx,%rsi)
leaq 0x27cbc4(%rip), %rsi    # 0x3640a0
movsd (%rcx,%rsi), %xmm0
leaq 0x355728(%rip), %rsi    # 0x43cc10
movsd %xmm0, (%rcx,%rsi)
leaq 0x35668c(%rip), %rsi    # 0x43db80
movsd (%rcx,%rsi), %xmm0
leaq 0x355a20(%rip), %rsi    # 0x43cf20
movsd %xmm0, (%rcx,%rsi)
addq $0x8, %rcx
jmp 0xe74b8
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
andl $0x0, 0x35664d(%rip)    # 0x43db70
andl $0x0, 0x356642(%rip)    # 0x43db6c
andl $0x0, 0x356637(%rip)    # 0x43db68
cmpl $0x18, %eax
pushq $0x18
popq %r15
cmovll %eax, %r15d
cmpl $0x1a, %eax
pushq $0x19
popq %rbx
cmovgel %eax, %ebx
addl $-0x18, %ebx
leaq 0x140e51(%rip), %r14    # 0x2283a0
movq (%r14), %rdi
testq %rdi, %rdi
je 0xe756a
leaq 0x3824c(%rip), %rsi     # 0x11f7aa
movl %ebx, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x9560
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
movl %ebx, %eax
movq %rax, -0x48(%rbp)
shlq $0x3, %r15
movq $0x0, -0x38(%rbp)
xorl %ebx, %ebx
cmpq -0x48(%rbp), %rbx
je 0xe7947
movq (%r14), %rdi
testq %rdi, %rdi
je 0xe75aa
leal 0x1(%rbx), %edx
leaq 0x3822d(%rip), %rsi     # 0x11f7d0
xorl %eax, %eax
callq 0x9560
movq %rbx, -0x50(%rbp)
andl $0x0, 0x3568d3(%rip)    # 0x43de88
andl $0x0, 0x27c7c8(%rip)    # 0x363d84
andl $0x0, 0x27c7bd(%rip)    # 0x363d80
xorl %r12d, %r12d
xorl %eax, %eax
xorl %ebx, %ebx
xorl %r14d, %r14d
cmpq %r12, %r15
je 0xe765a
movq %r15, %r13
movl %eax, -0x30(%rbp)
movq -0x38(%rbp), %rax
leaq (%rax,%r12), %r15
leaq 0x355315(%rip), %rax    # 0x43c900
movsd (%rax,%r15), %xmm0
leaq 0x27c798(%rip), %rdi    # 0x363d90
movl %r14d, %esi
callq 0xe7291
movl %eax, %r14d
movl %eax, 0x27c777(%rip)    # 0x363d80
leaq 0x355600(%rip), %rax    # 0x43cc10
movsd (%rax,%r15), %xmm0
leaq 0x27ca83(%rip), %rdi    # 0x3640a0
movl %ebx, %esi
callq 0xe7291
movl %eax, %ebx
movl %eax, 0x27c758(%rip)    # 0x363d84
leaq 0x3558ed(%rip), %rax    # 0x43cf20
movsd (%rax,%r15), %xmm0
movq %r13, %r15
leaq 0x35653d(%rip), %rdi    # 0x43db80
movl -0x30(%rbp), %esi
callq 0xe7291
movl %eax, 0x356837(%rip)    # 0x43de88
addq $0x8, %r12
jmp 0xe75cd
xorl %edi, %edi
callq 0xe72ca
movl 0x27c719(%rip), %eax    # 0x363d80
cvtsi2sd %eax, %xmm0
mulsd 0xb9f5(%rip), %xmm0     # 0xf3068
movsd %xmm0, 0x355225(%rip)   # 0x43c8a0
cvttsd2si %xmm0, %r13d
decl %eax
cmpl %r13d, %eax
leaq 0x140d14(%rip), %r14    # 0x2283a0
jle 0xe773d
movslq %r13d, %rax
leaq 0x27c6f4(%rip), %rcx    # 0x363d90
movsd (%rcx,%rax,8), %xmm3
movsd 0x8(%rcx,%rax,8), %xmm1
subsd %xmm3, %xmm1
cvtsi2sd %r13d, %xmm2
subsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd %xmm0, 0x3551df(%rip)   # 0x43c8a8
movl 0x356499(%rip), %esi    # 0x43db68
leaq 0x355b6a(%rip), %rdi    # 0x43d240
callq 0xe7291
movsd -0x30(%rbp), %xmm0
movl %eax, 0x356482(%rip)    # 0x43db68
movsd 0x3551ea(%rip), %xmm1   # 0x43c8d8
addsd %xmm0, %xmm1
movsd %xmm1, 0x3551de(%rip)   # 0x43c8d8
movq (%r14), %rdi
testq %rdi, %rdi
je 0xe773d
mulsd 0xba56(%rip), %xmm0     # 0xf3160
leaq 0x23dbdf(%rip), %rax    # 0x3252f0
movsd (%rax), %xmm1
mulsd 0x2e3b3(%rip), %xmm1    # 0x115ad0
addsd %xmm0, %xmm1
leaq 0x20f890(%rip), %rax    # 0x2f6fb8
divsd (%rax), %xmm1
leaq 0x380af(%rip), %rsi     # 0x11f7e2
movl %r13d, %edx
movb $0x2, %al
callq 0x9560
movl 0x27c641(%rip), %eax    # 0x363d84
cvtsi2sd %eax, %xmm0
mulsd 0xb919(%rip), %xmm0     # 0xf3068
movsd %xmm0, 0x355149(%rip)   # 0x43c8a0
cvttsd2si %xmm0, %r13d
decl %eax
cmpl %r13d, %eax
jle 0xe7846
movslq %r13d, %rax
leaq 0x27c92f(%rip), %rcx    # 0x3640a0
movsd (%rcx,%rax,8), %xmm3
movsd 0x8(%rcx,%rax,8), %xmm1
subsd %xmm3, %xmm1
cvtsi2sd %r13d, %xmm2
subsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd %xmm0, 0x355112(%rip)   # 0x43c8b0
movl 0x3563c8(%rip), %esi    # 0x43db6c
leaq 0x355da5(%rip), %rdi    # 0x43d550
callq 0xe7291
movsd -0x30(%rbp), %xmm2
movl %eax, 0x3563b1(%rip)    # 0x43db6c
movsd 0x35511d(%rip), %xmm0   # 0x43c8e0
addsd %xmm2, %xmm0
movsd %xmm0, 0x355111(%rip)   # 0x43c8e0
movq (%r14), %rbx
testq %rbx, %rbx
je 0xe7846
movsd 0xb981(%rip), %xmm1     # 0xf3160
mulsd %xmm1, %xmm2
movsd %xmm2, -0x30(%rbp)
leaq 0x23db09(%rip), %rax    # 0x3252f8
movsd (%rax), %xmm0
mulsd 0x2e2d5(%rip), %xmm0    # 0x115ad0
addsd %xmm2, %xmm0
leaq 0x20f7b2(%rip), %rax    # 0x2f6fb8
divsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x355091(%rip), %xmm0   # 0x43c8a8
mulsd %xmm1, %xmm0
divsd %xmm1, %xmm0
callq 0x9710
movsd -0x40(%rbp), %xmm1
mulsd %xmm0, %xmm1
movq %rbx, %rdi
leaq 0x37fc8(%rip), %rsi     # 0x11f7ff
movl %r13d, %edx
movsd -0x30(%rbp), %xmm0
movb $0x2, %al
callq 0x9560
movl 0x35663c(%rip), %eax    # 0x43de88
cvtsi2sd %eax, %xmm0
mulsd 0xb810(%rip), %xmm0     # 0xf3068
movsd %xmm0, 0x355040(%rip)   # 0x43c8a0
cvttsd2si %xmm0, %ebx
decl %eax
cmpl %ebx, %eax
jle 0xe7904
movslq %ebx, %rax
leaq 0x356308(%rip), %rcx    # 0x43db80
movsd (%rcx,%rax,8), %xmm3
movsd 0x8(%rcx,%rax,8), %xmm1
subsd %xmm3, %xmm1
cvtsi2sd %ebx, %xmm2
subsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd %xmm0, 0x355014(%rip)   # 0x43c8b8
movl 0x3562c6(%rip), %esi    # 0x43db70
leaq 0x355faf(%rip), %rdi    # 0x43d860
callq 0xe7291
movsd -0x30(%rbp), %xmm0
movl %eax, 0x3562af(%rip)    # 0x43db70
movsd 0x35501f(%rip), %xmm1   # 0x43c8e8
addsd %xmm0, %xmm1
movsd %xmm1, 0x355013(%rip)   # 0x43c8e8
movq (%r14), %rdi
testq %rdi, %rdi
je 0xe791e
movapd %xmm0, %xmm1
leaq 0x23da18(%rip), %rax    # 0x325300
subsd (%rax), %xmm1
mulsd 0xe02c(%rip), %xmm1     # 0xf5920
leaq 0x37f21(%rip), %rsi     # 0x11f81c
movl %ebx, %edx
movb $0x2, %al
callq 0x9560
movq (%r14), %rcx
testq %rcx, %rcx
je 0xe791e
leaq 0x33f7a(%rip), %rdi     # 0x11b88d
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x9750
movsd 0x354fca(%rip), %xmm0   # 0x43c8f0
addsd 0xb742(%rip), %xmm0     # 0xf3070
movsd %xmm0, 0x354fba(%rip)   # 0x43c8f0
movq -0x50(%rbp), %rbx
incq %rbx
addq $0x8, -0x38(%rbp)
jmp 0xe7587
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq