// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
leaq 0x210f06(%rip), %r14    # 0x30d000
movsd (%r14), %xmm0
leaq 0x210ed2(%rip), %rax    # 0x30cfd8
movsd (%rax), %xmm1
leaq 0x210ef7(%rip), %r15    # 0x30d008
movsd (%r15), %xmm2
movaps %xmm1, %xmm3
callq 0xe9fe2
mulsd 0xf7ea(%rip), %xmm0     # 0x10b910
mulsd 0xcf0a(%rip), %xmm0     # 0x109038
movapd %xmm0, -0x40(%rbp)
leaq 0x210e96(%rip), %rax    # 0x30cfd0
movsd (%rax), %xmm0
leaq 0x210ecb(%rip), %r12    # 0x30d010
movsd (%r12), %xmm1
leaq 0x210ec6(%rip), %r13    # 0x30d018
movsd (%r13), %xmm3
movapd %xmm0, %xmm2
callq 0xe9fe2
movapd -0x40(%rbp), %xmm2
movapd %xmm0, %xmm1
mulsd 0xf79e(%rip), %xmm1     # 0x10b910
mulsd 0xcebe(%rip), %xmm1     # 0x109038
movapd 0xd00e(%rip), %xmm0     # 0x109190
andpd %xmm0, %xmm2
andpd %xmm0, %xmm1
movapd %xmm1, %xmm0
maxsd %xmm2, %xmm0
leaq 0x210e27(%rip), %rax    # 0x30cfc0
movq (%rax), %rax
testq %rax, %rax
je 0xfc1c0
movzbl (%rax), %eax
cmpl $0x6c, %eax
je 0xfc1b8
cmpl $0x66, %eax
jne 0xfc1c0
mulsd 0xf6f2(%rip), %xmm0     # 0x10b8a8
jmp 0xfc1c0
mulsd 0x226a0(%rip), %xmm0    # 0x11e860
divsd 0xcf70(%rip), %xmm0     # 0x109138
addsd 0xcea0(%rip), %xmm0     # 0x109070
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
leaq 0x211321(%rip), %rax    # 0x30d500
movl (%rax), %eax
testl %ebx, %ebx
jne 0xfc1f1
cmpl %eax, 0x74a59(%rip)     # 0x170c44
je 0xfc27f
movapd %xmm0, -0x40(%rbp)
movl %eax, 0x74a48(%rip)     # 0x170c44
leaq 0x23f0b1(%rip), %rax    # 0x33b2b4
cmpl $0x0, (%rax)
je 0xfc276
leaq 0x11c6b5(%rip), %rax    # 0x2188c4
cmpb $0x0, (%rax)
je 0xfc276
leaq 0x210d8d(%rip), %rax    # 0x30cfa8
movq (%rax), %rdx
leaq 0x24277b(%rip), %rdi    # 0x33e9a0
leaq 0x39442(%rip), %rsi     # 0x13566e
movapd %xmm2, %xmm0
movaps -0x40(%rbp), %xmm2
movb $0x3, %al
callq 0x9060
movsd (%r14), %xmm0
movsd (%r15), %xmm1
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movsd (%r12), %xmm3
movsd (%r13), %xmm4
movapd %xmm4, %xmm5
subsd %xmm3, %xmm5
leaq 0x242888(%rip), %rdi    # 0x33eaf0
leaq 0x3942a(%rip), %rsi     # 0x135699
movb $0x6, %al
callq 0x9060
callq 0xfbfda
movaps -0x40(%rbp), %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq