user: Converte this assembly snippet into its equivalent C code:

```asm
<swh_geoc2d>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  lea    D75(%rip),%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rsi,0x10(%rsp)
  lea    0x2c(%rsp),%r13
  mov    %rdi,%rsi
  lea    0x20(%rsp),%r12
  mov    %r13,%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  call   <strcpy@plt>
  mov    %r12,%rdx
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <strtok_r@plt>
  test   %rax,%rax
  je     L36
  lea    D40(%rip),%r14
  mov    %rax,%r13
  mov    %rax,%rdi
  mov    %r14,%rsi
  call   <strspn@plt>
  mov    %r13,%rdi
  mov    %rax,%rbx
  call   <strlen@plt>
  cmp    %rax,%rbx
  jne    L36
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %eax,%edi
  mov    %eax,%ebx
  not    %edi
  shr    $0x1f,%edi
  call   <assert@plt>
  mov    %r12,%rdx
  mov    %rbp,%rsi
  xor    %edi,%edi
  call   <strtok_r@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L36
  lea    D4(%rip),%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L115
L56:
  movl   $0x1,0x1c(%rsp)
  mov    $0x5a,%r15d
L91:
  xor    %edi,%edi
  cmp    %ebx,%r15d
  setge  %dil
  call   <assert@plt>
  mov    %r12,%rdx
  mov    %rbp,%rsi
  xor    %edi,%edi
  call   <strtok_r@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L36
  mov    %rax,%rdi
  mov    %r14,%rsi
  call   <strspn@plt>
  mov    %r13,%rdi
  mov    %rax,0x8(%rsp)
  call   <strlen@plt>
  cmp    %rax,0x8(%rsp)
  jne    L36
  mov    %r13,%rdi
  call   <atoi@plt>
  xor    %edi,%edi
  cmp    $0x3b,%eax
  mov    %eax,%r13d
  setbe  %dil
  cmp    %ebx,%r15d
  jne    L170
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
L170:
  call   <assert@plt>
  mov    %r12,%rdx
  mov    %rbp,%rsi
  xor    %edi,%edi
  call   <strtok_r@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L36
  mov    %rax,%rdi
  mov    %r14,%rsi
  call   <strspn@plt>
  mov    %r12,%rdi
  mov    %rax,%rbp
  call   <strlen@plt>
  cmp    %rax,%rbp
  jne    L36
  mov    %r12,%rdi
  call   <atoi@plt>
  xor    %edi,%edi
  cmp    $0x3b,%eax
  mov    %eax,%ebp
  setbe  %dil
  cmp    %ebx,%r15d
  jne    L177
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
L177:
  call   <assert@plt>
  pxor   %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  mov    0x1c(%rsp),%eax
  cvtsi2sd %r13d,%xmm0
  mulsd  D47(%rip),%xmm0
  cvtsi2sd %ebx,%xmm1
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %ebp,%xmm1
  mulsd  D74(%rip),%xmm1
  addsd  %xmm1,%xmm0
  test   %eax,%eax
  je     L146
L176:
  mov    0x10(%rsp),%rax
  movsd  %xmm0,(%rax)
  xor    %eax,%eax
L41:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L94
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L115:
  lea    D64(%rip),%rsi
  mov    %r13,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L56
  lea    D35(%rip),%rsi
  mov    %r13,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L136
L105:
  movl   $0x0,0x1c(%rsp)
  mov    $0xb4,%r15d
  jmp    L91
  nop
L146:
  xorpd  D26(%rip),%xmm0
  jmp    L176
  nopw   0x0(%rax,%rax,1)
L136:
  lea    D69(%rip),%rsi
  mov    %r13,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L105
  nopl   0x0(%rax)
L36:
  mov    $0xffffffff,%eax
  jmp    L41
L94:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D75
type_infered: string
name: retrieve_data
arguments: data_tag: D40
type_infered: string
name: retrieve_data
arguments: data_tag: D4
type_infered: string
name: retrieve_data
arguments: data_tag: D47
type_infered: byte[8]
name: retrieve_data
arguments: data_tag: D74
type_infered: byte[8]
name: retrieve_data
arguments: data_tag: D64
type_infered: string
name: retrieve_data
arguments: data_tag: D35
type_infered: string
name: retrieve_data
arguments: data_tag: D26
type_infered: byte[16]
name: retrieve_data
arguments: data_tag: D69
type_infered: string

tool: D75: :

tool: D40: 0123456789

tool: D4: N

tool: {"D47": [0x11,0x11,0x11,0x11,0x11,0x11,0x91,0x3f]}

tool: {"D74": [0xdf,0xbc,0x9a,0x78,0x56,0x34,0x32,0x3f]}

tool: D64: E

tool: D35: S

tool: {"D26": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: D69: W

assistant: ```c
int swh_geoc2d(const char *coord, double *ret) {
  int deg, dir, min, sec, degmax;
  char *ptr, buf[12];
  strcpy(buf, coord);
  char *saveptr;
  ptr = strtok_r(buf, ":", &saveptr);
  if (ptr == NULL || strspn(ptr, "0123456789") != strlen(ptr))
    return -1;
  else
    deg = atoi(ptr);
  assert(deg >= 0);
  ptr = strtok_r(NULL, ":", &saveptr);
  if (ptr == NULL)
    return -1;
  else {
    if (strcmp(ptr, "N") == 0 || strcmp(ptr, "E") == 0) {
      degmax = 90;
      dir = 1;
    } else if (strcmp(ptr, "S") == 0 || strcmp(ptr, "W") == 0) {
      degmax = 180;
      dir = 0;
    } else
      return -1;
  }
  assert(deg <= degmax);
  ptr = strtok_r(NULL, ":", &saveptr);
  if (ptr == NULL || strspn(ptr, "0123456789") != strlen(ptr))
    return -1;
  else
    min = atoi(ptr);
  assert(deg == degmax ? min == 0 : min >= 0 && min <= 59);
  ptr = strtok_r(NULL, ":", &saveptr);
  if (ptr == NULL || strspn(ptr, "0123456789") != strlen(ptr))
    return -1;
  else
    sec = atoi(ptr);
  assert(deg == degmax ? sec == 0 : sec >= 0 && sec <= 59);
  *ret = (double)(dir ? (deg + ((1.0 / 60) * min) + ((1.0 / 3600) * sec)) : -(deg + ((1.0 / 60) * min) + ((1.0 / 3600) * sec)));
  return 0;
}
```