// File: /workspace/github_cpp_makefile_star2_O1/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 0x31268
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 0x31271
cmpl $0x2d, %eax
je 0x31259
cmpl $0x2b, %eax
jne 0x3126c
cmpb $0x2b, 0x1(%r14)
je 0x31260
cmpb $0x2d, %al
jne 0x3126c
cmpb $0x2d, 0x1(%r14)
jne 0x3126c
incq %r14
xorl %r12d, %r12d
jmp 0x3127b
xorps %xmm0, %xmm0
retq
movb $0x1, %r12b
jmp 0x3127b
xorl %r12d, %r12d
leaq 0xf00b5(%rip), %r14     # 0x121330
movq %r14, %rdi
movl $0x61, %esi
callq 0x9100
movq %rax, %r15
testq %rax, %rax
jne 0x312a2
movq %r14, %rdi
movl $0x41, %esi
callq 0x9100
testq %rax, %rax
je 0x31302
leaq 0x2dc017(%rip), %rax    # 0x30d2c0
cmpl $0x0, (%rax)
je 0x31302
leaq 0x12ca7b(%rip), %rax    # 0x15dd30
movsd 0x428(%rax), %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
jne 0x312c9
jnp 0x31302
movsd 0x510(%rax), %xmm1
ucomisd %xmm0, %xmm1
jne 0x312d9
jnp 0x31302
movsd 0x408(%rax), %xmm0
divsd %xmm2, %xmm0
leaq 0x30a004(%rip), %rcx    # 0x33b2f0
movsd %xmm0, (%rcx)
testl %ebx, %ebx
je 0x31345
movsd 0x4f0(%rax), %xmm0
divsd %xmm1, %xmm0
jmp 0x31345
testq %r15, %r15
jne 0x3131d
movq %r14, %rdi
movl $0x41, %esi
callq 0x9100
testq %rax, %rax
je 0x313ba
testl %ebx, %ebx
je 0x3132a
leaq 0x2dbcb0(%rip), %rax    # 0x30cfd8
jmp 0x31331
leaq 0x2dbc9f(%rip), %rax    # 0x30cfd0
movsd (%rax), %xmm0
mulsd 0xda4e3(%rip), %xmm0    # 0x10b820
divsd 0xda4d3(%rip), %xmm0    # 0x10b818
testb %r12b, %r12b
jne 0x313b1
testl %ebx, %ebx
je 0x31383
leaq 0x2dbc73(%rip), %rax    # 0x30cfc8
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 0x309f7b(%rip), %rax    # 0x33b2f8
movapd %xmm3, %xmm0
jmp 0x3138a
leaq 0x309f66(%rip), %rax    # 0x33b2f0
leaq 0x2dbc27(%rip), %rcx    # 0x30cfb8
mulsd (%rcx), %xmm0
mulsd 0xda56b(%rip), %xmm0    # 0x10b908
addsd (%rax), %xmm0
mulsd 0xda477(%rip), %xmm0    # 0x10b820
divsd 0xda467(%rip), %xmm0    # 0x10b818
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movl $0x64, %esi
callq 0x9100
testq %rax, %rax
jne 0x31426
movq %r14, %rdi
movl $0x6d, %esi
callq 0x9100
testq %rax, %rax
jne 0x31426
movq %r14, %rdi
movl $0x73, %esi
callq 0x9100
testq %rax, %rax
jne 0x31426
movq %r14, %rdi
movl $0x44, %esi
callq 0x9100
testq %rax, %rax
jne 0x31426
movq %r14, %rdi
movl $0x4d, %esi
callq 0x9100
testq %rax, %rax
jne 0x31426
movq %r14, %rdi
movl $0x53, %esi
callq 0x9100
testq %rax, %rax
je 0x31433
movq %r14, %rdi
callq 0x310ec
jmp 0x31345
movq %r14, %rdi
callq 0x9470
jmp 0x31345