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

```asm
<atari_name>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  jmp    L304
L193:
  addq   $0x1,-0x10(%rbp)
L100:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <is_separator@plt>
  test   %rax,%rax
  je     L69
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L193
L69:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L312
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <is_separator@plt>
  test   %rax,%rax
  jne    L312
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  jmp    L312
L159:
  addq   $0x1,-0x10(%rbp)
L312:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L304
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <is_separator@plt>
  test   %rax,%rax
  je     L159
L304:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L182
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L100
L182:
  movl   $0x0,-0x20(%rbp)
  movl   $0x0,-0x1c(%rbp)
  jmp    L289
L226:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x21(%rbp)
  cmpb   $0x0,-0x21(%rbp)
  je     L42
  cmpb   $0x2e,-0x21(%rbp)
  jne    L27
  cmpl   $0x0,-0x1c(%rbp)
  jne    L27
  movl   $0x8,-0x20(%rbp)
  movl   $0x1,-0x1c(%rbp)
  jmp    L289
L27:
  cmpl   $0x7,-0x20(%rbp)
  jle    L230
  cmpl   $0x0,-0x1c(%rbp)
  jne    L230
  jmp    L289
L230:
  cmpl   $0xa,-0x20(%rbp)
  jg     L175
  movsbl -0x21(%rbp),%eax
  mov    %eax,%edi
  call   <is_separator@plt>
  test   %rax,%rax
  jne    L131
  cmpb   $0x60,-0x21(%rbp)
  jle    L173
  cmpb   $0x7a,-0x21(%rbp)
  jg     L173
  movzbl -0x21(%rbp),%eax
  lea    -0x20(%rax),%ecx
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  jmp    L270
L173:
  cmpb   $0x40,-0x21(%rbp)
  jle    L319
  cmpb   $0x5a,-0x21(%rbp)
  jle    L237
L319:
  cmpb   $0x2f,-0x21(%rbp)
  jle    L144
  cmpb   $0x39,-0x21(%rbp)
  jg     L144
L237:
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  movzbl -0x21(%rbp),%eax
  mov    %al,(%rdx)
  jmp    L270
L144:
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x5f,(%rax)
L270:
  addl   $0x1,-0x20(%rbp)
L289:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L226
  jmp    L127
L42:
  nop
  jmp    L127
L175:
  nop
  jmp    L127
L131:
  nop
L127:
  mov    -0x8(%rbp),%rax
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D6
type: string

tool: D6:            

assistant: ```c
char *atari_name(const char *fname) {
  char *out = strdup("           ");
  const char *in, *p;
  in = p = fname;
  while (p[0] && p[1]) {
    while (is_separator(p[0]) && p[1])
      p++;
    if (p[0] && !is_separator(p[0]))
      in = p;
    while (p[0] && !is_separator(p[0]))
      p++;
  }
  int pos = 0, dot = 0;
  while (*in) {
    char c = *in++;
    if (!c)
      break;
    else if (c == '.' && !dot) {
      pos = 8;
      dot = 1;
      continue;
    } else if (pos > 7 && !dot)
      continue;
    else if (pos > 10)
      break;
    else if (is_separator(c))
      break;
    else if (c >= 'a' && c <= 'z')
      out[pos] = c - 'a' + 'A';
    else if ((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))
      out[pos] = c;
    else
      out[pos] = '_';
    pos++;
  }
  return out;
}
```