// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: calc_lla_span(int)
double calc_lla_span(int force_show)
{
double lat_dist, lon_dist;
double max_dist;
static int last_sec = (-99);

   // return the maximum span distance of lat or lon in meters or feet

if(0) {
   if(lat == 0.0) return LLA_SPAN;
   if(lon == 0.0) return LLA_SPAN;
   if(min_q_lat == 0.0) return LLA_SPAN;
   if(min_q_lon == 0.0) return LLA_SPAN;
   if(max_q_lat == 0.0) return LLA_SPAN;
   if(max_q_lon == 0.0) return LLA_SPAN;
}

   lat_dist = greatcircle(min_q_lat,lon, max_q_lat,lon) * DEG_TO_RAD * 1000.0;  // lat span in meters
   lon_dist = greatcircle(lat,min_q_lon, lat,max_q_lon) * DEG_TO_RAD * 1000.0;  // lon span in meters
   lat_dist = fabs(lat_dist);
   lon_dist = fabs(lon_dist);

   max_dist = lat_dist;
   if(lon_dist > max_dist) max_dist = lon_dist;  // max span dist of lat/lon
   if(angle_units) {
      if(angle_units[0] == 'f') max_dist *= FEET_PER_METER;
      else if(angle_units[0] == 'l') max_dist *= LG_PER_METER;  // linguini per meter
   }
   max_dist /= ((double) LLA_DIVISIONS / 2.0);  // scale to LLA plot size
   max_dist = (double) (int) (max_dist+1.0);    // round up to next integer

   if(force_show || (last_sec != pri_seconds)) {  // rate limit the screen updates
      last_sec = pri_seconds;
if(autoscale_lla && show_debug_info) {
   sprintf(debug_text, "lat_d: %.9f  lon_d:%.9f  span:%.9f  %s/div", lat_dist,lon_dist,max_dist, alt_scale); //llascale
   sprintf(debug_text2, "lat:%.9f %.9f (%.9f)   lon:%.9f %.9f (%.9f)", min_q_lat,max_q_lat,max_q_lat-min_q_lat,  min_q_lon,max_q_lon,max_q_lon-min_q_lon); //llascale
}
      show_mouse_lla();
   }
   return max_dist;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
leaq 0x210e7e(%rip), %rax    # 0x36c1e0
movsd (%rax), %xmm0
leaq 0x210e4b(%rip), %rax    # 0x36c1b8
movsd (%rax), %xmm1
leaq 0x210e70(%rip), %rax    # 0x36c1e8
movsd (%rax), %xmm2
leaq 0x210e35(%rip), %rax    # 0x36c1b8
movsd (%rax), %xmm3
callq 0x13f830
movsd 0x162fc(%rip), %xmm1    # 0x171690
mulsd %xmm1, %xmm0
movsd 0x13c90(%rip), %xmm1    # 0x16f030
mulsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
leaq 0x210e00(%rip), %rax    # 0x36c1b0
movsd (%rax), %xmm0
leaq 0x210e35(%rip), %rax    # 0x36c1f0
movsd (%rax), %xmm1
leaq 0x210dea(%rip), %rax    # 0x36c1b0
movsd (%rax), %xmm2
leaq 0x210e27(%rip), %rax    # 0x36c1f8
movsd (%rax), %xmm3
callq 0x13f830
movsd 0x162ae(%rip), %xmm1    # 0x171690
mulsd %xmm1, %xmm0
movsd 0x13c42(%rip), %xmm1    # 0x16f030
mulsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x10(%rbp), %xmm0
movaps 0x13e8d(%rip), %xmm1    # 0x16f290
pand %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x18(%rbp), %xmm0
movaps 0x13e78(%rip), %xmm1    # 0x16f290
pand %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x18(%rbp), %xmm0
ucomisd -0x20(%rbp), %xmm0
jbe 0x15b441
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
leaq 0x210d58(%rip), %rax    # 0x36c1a0
cmpq $0x0, (%rax)
je 0x15b49c
leaq 0x210d4b(%rip), %rax    # 0x36c1a0
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x66, %eax
jne 0x15b474
movsd 0x161c8(%rip), %xmm0    # 0x171630
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x15b49a
leaq 0x210d25(%rip), %rax    # 0x36c1a0
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x6c, %eax
jne 0x15b498
movsd 0x27caa(%rip), %xmm0    # 0x183138
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x15b49a
jmp 0x15b49c
movsd -0x20(%rbp), %xmm0
movsd 0x13cb7(%rip), %xmm1    # 0x16f160
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd 0x13bae(%rip), %xmm0    # 0x16f068
addsd -0x20(%rbp), %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x20(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x15b4e7
movl 0x7494c(%rip), %eax     # 0x1cfe24
leaq 0x211201(%rip), %rcx    # 0x36c6e0
cmpl (%rcx), %eax
je 0x15b5b6
leaq 0x2111f2(%rip), %rax    # 0x36c6e0
movl (%rax), %eax
movl %eax, 0x7492e(%rip)     # 0x1cfe24
leaq 0x23ef97(%rip), %rax    # 0x39a494
cmpl $0x0, (%rax)
je 0x15b5b1
leaq 0x11c597(%rip), %rax    # 0x277aa4
cmpb $0x0, (%rax)
je 0x15b5b1
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x20(%rbp), %xmm2
leaq 0x210c5c(%rip), %rax    # 0x36c188
movq (%rax), %rdx
leaq 0x24264a(%rip), %rdi    # 0x39db80
leaq 0x3ccc3(%rip), %rsi     # 0x198200
movb $0x3, %al
callq 0x9060
leaq 0x210c95(%rip), %rax    # 0x36c1e0
movsd (%rax), %xmm0
leaq 0x210c92(%rip), %rax    # 0x36c1e8
movsd (%rax), %xmm1
leaq 0x210c87(%rip), %rax    # 0x36c1e8
movsd (%rax), %xmm2
leaq 0x210c74(%rip), %rax    # 0x36c1e0
subsd (%rax), %xmm2
leaq 0x210c79(%rip), %rax    # 0x36c1f0
movsd (%rax), %xmm3
leaq 0x210c76(%rip), %rax    # 0x36c1f8
movsd (%rax), %xmm4
leaq 0x210c6b(%rip), %rax    # 0x36c1f8
movsd (%rax), %xmm5
leaq 0x210c58(%rip), %rax    # 0x36c1f0
subsd (%rax), %xmm5
leaq 0x24272d(%rip), %rdi    # 0x39dcd0
leaq 0x3cc81(%rip), %rsi     # 0x19822b
movb $0x6, %al
callq 0x9060
callq 0x15b1f0
movsd -0x20(%rbp), %xmm0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)