// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x453e3
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x4575a
movq -0x18(%rbp), %rdi
callq 0x9850
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0x4540c
movl $0x1, -0x24(%rbp)
leaq 0x1533ac(%rip), %rax    # 0x1987b2
movq %rax, -0x18(%rbp)
jmp 0x45473
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
jne 0x4543a
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2b, %eax
jne 0x4543a
movl $0x1, -0x24(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x45471
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x45468
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0x45468
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x4546f
movl $0x0, -0x24(%rbp)
jmp 0x45471
jmp 0x45473
movq -0x18(%rbp), %rdi
movl $0x61, %esi
callq 0x9100
cmpq $0x0, %rax
jne 0x4549f
movq -0x18(%rbp), %rdi
movl $0x41, %esi
callq 0x9100
cmpq $0x0, %rax
je 0x45566
leaq 0x326ffa(%rip), %rax    # 0x36c4a0
cmpl $0x0, (%rax)
je 0x45566
leaq 0x17786a(%rip), %rax    # 0x1bcd20
movsd 0x428(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x454ce
jp 0x454ce
jmp 0x45566
leaq 0x17784b(%rip), %rax    # 0x1bcd20
movsd 0x510(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x454ea
jp 0x454ea
jmp 0x45566
leaq 0x17782f(%rip), %rax    # 0x1bcd20
movsd 0x408(%rax), %xmm0
leaq 0x177820(%rip), %rax    # 0x1bcd20
divsd 0x428(%rax), %xmm0
leaq 0x354fc1(%rip), %rax    # 0x39a4d0
movsd %xmm0, (%rax)
cmpl $0x0, -0xc(%rbp)
je 0x4553e
leaq 0x177800(%rip), %rax    # 0x1bcd20
movsd 0x4f0(%rax), %xmm0
leaq 0x1777f1(%rip), %rax    # 0x1bcd20
divsd 0x510(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x45561
leaq 0x1777db(%rip), %rax    # 0x1bcd20
movsd 0x408(%rax), %xmm0
leaq 0x1777cc(%rip), %rax    # 0x1bcd20
divsd 0x428(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x4568f
movq -0x18(%rbp), %rdi
movl $0x61, %esi
callq 0x9100
cmpq $0x0, %rax
jne 0x4558e
movq -0x18(%rbp), %rdi
movl $0x41, %esi
callq 0x9100
cmpq $0x0, %rax
je 0x455e3
cmpl $0x0, -0xc(%rbp)
je 0x455ba
movsd 0x129adc(%rip), %xmm0   # 0x16f078
leaq 0x326c15(%rip), %rax    # 0x36c1b8
mulsd (%rax), %xmm0
movsd 0x12c019(%rip), %xmm1   # 0x1715c8
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x455de
movsd 0x129ab6(%rip), %xmm0   # 0x16f078
leaq 0x326be7(%rip), %rax    # 0x36c1b0
mulsd (%rax), %xmm0
movsd 0x12bff3(%rip), %xmm1   # 0x1715c8
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x4568d
movq -0x18(%rbp), %rdi
movl $0x64, %esi
callq 0x9100
cmpq $0x0, %rax
jne 0x4561f
movq -0x18(%rbp), %rdi
movl $0x6d, %esi
callq 0x9100
cmpq $0x0, %rax
jne 0x4561f
movq -0x18(%rbp), %rdi
movl $0x73, %esi
callq 0x9100
cmpq $0x0, %rax
je 0x4562f
movq -0x18(%rbp), %rdi
callq 0x451a0
movsd %xmm0, -0x20(%rbp)
jmp 0x4568b
movq -0x18(%rbp), %rdi
movl $0x44, %esi
callq 0x9100
cmpq $0x0, %rax
jne 0x4566b
movq -0x18(%rbp), %rdi
movl $0x4d, %esi
callq 0x9100
cmpq $0x0, %rax
jne 0x4566b
movq -0x18(%rbp), %rdi
movl $0x53, %esi
callq 0x9100
cmpq $0x0, %rax
je 0x4567b
movq -0x18(%rbp), %rdi
callq 0x451a0
movsd %xmm0, -0x20(%rbp)
jmp 0x45689
movq -0x18(%rbp), %rdi
callq 0x9480
movsd %xmm0, -0x20(%rbp)
jmp 0x4568b
jmp 0x4568d
jmp 0x4568f
cmpl $0x0, -0x24(%rbp)
je 0x45750
cmpl $0x0, -0xc(%rbp)
je 0x45702
leaq 0x326b02(%rip), %rax    # 0x36c1a8
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x456b7
jp 0x456b7
jmp 0x456d0
leaq 0x326aea(%rip), %rax    # 0x36c1a8
movsd (%rax), %xmm1
movsd -0x20(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
leaq 0x354e01(%rip), %rax    # 0x39a4d8
movsd (%rax), %xmm1
movsd -0x20(%rbp), %xmm0
leaq 0x326ab1(%rip), %rax    # 0x36c198
mulsd (%rax), %xmm0
movsd 0x12bf9d(%rip), %xmm2   # 0x171690
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x45732
leaq 0x354dc7(%rip), %rax    # 0x39a4d0
movsd (%rax), %xmm1
movsd -0x20(%rbp), %xmm0
leaq 0x326a7f(%rip), %rax    # 0x36c198
mulsd (%rax), %xmm0
movsd 0x12bf6b(%rip), %xmm2   # 0x171690
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd 0x12993e(%rip), %xmm0   # 0x16f078
mulsd -0x20(%rbp), %xmm0
movsd 0x12be81(%rip), %xmm1   # 0x1715c8
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)