// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathui.cpp
// Function: parse_coord(int, char*)
double parse_coord(int lon_flag, char *s)
{
double val;
int adj_flag;

   // convert a lat/lon string to decimal degrees.  The string can either be
   // a decimal number or a string in the format 11d12m30s (no embeded spaces).
   // If a part of the dms format string is not given, it is assumed to be 0.

   if(s == 0) return 0.0;

   strlwr(s);
   if(s[0] == '*') {
      adj_flag = 1;
      s = "0";
   }
   else if((s[0] == '+') && (s[1] == '+')) {
      adj_flag = 1;
      ++s;
   }
   else if((s[0] == '-') && (s[1] == '-')) {
      adj_flag = (-1);
      ++s;
   }
   else adj_flag = 0;

   if( (strchr(s, 'a') || strchr(s, 'A')) && have_lla_queue && plot[ONE].stat_count && plot[TWO].stat_count) {
      precise_lat = plot[ONE].sum_y / plot[ONE].stat_count;
      if(lon_flag) val = plot[TWO].sum_y / plot[TWO].stat_count;
      else         val = plot[ONE].sum_y / plot[ONE].stat_count;
   }
   else if(strchr(s, 'a') || strchr(s, 'A')) {
      if(lon_flag) val = lon * 180.0 / PI;
      else         val = lat * 180.0 / PI;
   }
   else if(strchr(s, 'd') || strchr(s, 'm') || strchr(s, 's')) {  // convert feet to meters
      val = deg_min_sec(s);
   }
   else if(strchr(s, 'D') || strchr(s, 'M') || strchr(s, 'S')) {  // convert feet to meters
      val = deg_min_sec(s);
   }
   else {
      val = atof(s);
   }

   if(adj_flag) {  // add +/- offset in feet or meters to current position
      if(lon_flag) {
         if(cos_factor) val /= cos_factor;
         val = precise_lon + (val * ANGLE_SCALE * DEG_TO_RAD);
      }
      else {
         val = precise_lat + (val * ANGLE_SCALE * DEG_TO_RAD);
      }
      val = val * 180.0 / PI;
   }

   return val;
}

// Assembly:
testq %rsi, %rsi
je 0x2e805
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movl %edi, %ebx
movq %rsi, %rdi
callq 0x986c
movzbl (%r14), %eax
cmpl $0x2a, %eax
je 0x2e818
cmpl $0x2d, %eax
je 0x2e809
cmpl $0x2b, %eax
jne 0x2e800
cmpb $0x2b, 0x1(%r14)
je 0x2e810
movb $0x1, %r12b
jmp 0x2e822
xorps %xmm0, %xmm0
retq
cmpb $0x2d, 0x1(%r14)
jne 0x2e800
incq %r14
xorl %r12d, %r12d
jmp 0x2e822
xorl %r12d, %r12d
leaq 0xdcb36(%rip), %r14     # 0x10b358
pushq $0x61
popq %rsi
movq %r14, %rdi
callq 0x9100
movq %rax, %r15
testq %rax, %rax
je 0x2e846
leaq 0x2c8a84(%rip), %rax    # 0x2f72c0
cmpl $0x0, (%rax)
jne 0x2e862
jmp 0x2e8cf
pushq $0x41
popq %rsi
movq %r14, %rdi
callq 0x9100
testq %rax, %rax
je 0x2e8bb
leaq 0x2c8a63(%rip), %rax    # 0x2f72c0
cmpl $0x0, (%rax)
je 0x2e8bb
leaq 0x1194c7(%rip), %rax    # 0x147d30
movsd 0x428(%rax), %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
jne 0x2e87d
jnp 0x2e8b6
movsd 0x510(%rax), %xmm1
ucomisd %xmm0, %xmm1
jne 0x2e88d
jnp 0x2e8b6
movsd 0x408(%rax), %xmm0
divsd %xmm2, %xmm0
leaq 0x2f6a50(%rip), %rcx    # 0x3252f0
movsd %xmm0, (%rcx)
testl %ebx, %ebx
je 0x2e8f7
movsd 0x4f0(%rax), %xmm0
divsd %xmm1, %xmm0
jmp 0x2e8f7
testq %r15, %r15
jne 0x2e8cf
pushq $0x41
popq %rsi
movq %r14, %rdi
callq 0x9100
testq %rax, %rax
je 0x2e96c
testl %ebx, %ebx
je 0x2e8dc
leaq 0x2c86fe(%rip), %rax    # 0x2f6fd8
jmp 0x2e8e3
leaq 0x2c86ed(%rip), %rax    # 0x2f6fd0
movsd (%rax), %xmm0
mulsd 0xc6fb9(%rip), %xmm0    # 0xf58a8
divsd 0xc6fa9(%rip), %xmm0    # 0xf58a0
testb %r12b, %r12b
jne 0x2e963
testl %ebx, %ebx
je 0x2e935
leaq 0x2c86c1(%rip), %rax    # 0x2f6fc8
movsd (%rax), %xmm1
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
xorpd %xmm3, %xmm3
cmpneqsd %xmm1, %xmm3
andpd %xmm3, %xmm2
andnpd %xmm0, %xmm3
orpd %xmm2, %xmm3
leaq 0x2f69c9(%rip), %rax    # 0x3252f8
movapd %xmm3, %xmm0
jmp 0x2e93c
leaq 0x2f69b4(%rip), %rax    # 0x3252f0
leaq 0x2c8675(%rip), %rcx    # 0x2f6fb8
mulsd (%rcx), %xmm0
mulsd 0xc7039(%rip), %xmm0    # 0xf5988
addsd (%rax), %xmm0
mulsd 0xc6f4d(%rip), %xmm0    # 0xf58a8
divsd 0xc6f3d(%rip), %xmm0    # 0xf58a0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x64
popq %rsi
movq %r14, %rdi
callq 0x9100
testq %rax, %rax
jne 0x2e9cc
pushq $0x6d
popq %rsi
movq %r14, %rdi
callq 0x9100
testq %rax, %rax
jne 0x2e9cc
pushq $0x73
popq %rsi
movq %r14, %rdi
callq 0x9100
testq %rax, %rax
jne 0x2e9cc
pushq $0x44
popq %rsi
movq %r14, %rdi
callq 0x9100
testq %rax, %rax
jne 0x2e9cc
pushq $0x4d
popq %rsi
movq %r14, %rdi
callq 0x9100
testq %rax, %rax
jne 0x2e9cc
pushq $0x53
popq %rsi
movq %r14, %rdi
callq 0x9100
testq %rax, %rax
je 0x2e9d9
movq %r14, %rdi
callq 0x2e6b3
jmp 0x2e8f7
movq %r14, %rdi
callq 0x9470
jmp 0x2e8f7