user: 请从给定的汇编指令推导出C源代码:

```asm
<gms_establish_filenames>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  mov    %rdx,(%rsp)
  mov    %rcx,0x8(%rsp)
  test   %rdi,%rdi
  je     L92
  test   %rsi,%rsi
  je     L92
  test   %rdx,%rdx
  setne  %al
  xor    %edi,%edi
  test   %rcx,%rcx
  setne  %dil
  and    %eax,%edi
  jmp    L56
  xchg   %ax,%ax
L92:
  xor    %edi,%edi
L56:
  call   <assert@plt>
  mov    %r12,%rdi
  lea    D53(%rip),%r13
  call   <strlen@plt>
  lea    0x1(%rax),%rdi
  call   <gms_malloc@plt>
  mov    %r12,%rsi
  mov    %rax,%rbp
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  cmp    $0x4,%rax
  ja     L72
L117:
  lea    0x5(%rax),%rdi
  lea    D20(%rip),%r15
  call   <gms_malloc@plt>
  mov    %rbp,%rsi
  mov    %rax,%r12
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  mov    %r12,%rdi
  mov    %r15,%rsi
  call   <fopen@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  je     L54
L0:
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    0x5(%rax),%rdi
  call   <gms_malloc@plt>
  mov    %rbp,%rsi
  mov    %rax,%r13
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    D56(%rip),%rsi
  mov    %r13,%rdi
  call   <strcat@plt>
  mov    %r13,%rdi
  mov    %r15,%rsi
  call   <fopen@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  je     L166
L14:
  call   <fclose@plt>
L35:
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    0x5(%rax),%rdi
  call   <gms_malloc@plt>
  mov    %rbp,%rsi
  mov    %rax,%r14
  mov    %rax,%rdi
  call   <strcpy@plt>
  lea    D10(%rip),%rsi
  mov    %r14,%rdi
  call   <strcat@plt>
  mov    %r14,%rdi
  mov    %r15,%rsi
  call   <fopen@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  je     L149
L137:
  call   <fclose@plt>
L1:
  mov    (%rsp),%rax
  mov    %r12,(%rbx)
  mov    %r13,(%rax)
  mov    0x8(%rsp),%rax
  mov    %r14,(%rax)
L168:
  add    $0x18,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10d0 <free@plt>
L72:
  lea    -0x4(%rbp,%rax,1),%rdi
  mov    %r13,%rsi
  call   <gms_strcasecmp@plt>
  test   %rax,%rax
  jne    L172
L80:
  mov    %rbp,%rdi
  call   <strlen@plt>
  movb   $0x0,-0x4(%rbp,%rax,1)
L38:
  mov    %rbp,%rdi
  call   <strlen@plt>
  jmp    L117
L54:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  lea    D30(%rip),%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  mov    %r12,%rdi
  mov    %r15,%rsi
  call   <fopen@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  jne    L0
  mov    (%rsp),%rax
  movq   $0x0,(%rbx)
  mov    %r12,%rdi
  movq   $0x0,(%rax)
  mov    0x8(%rsp),%rax
  movq   $0x0,(%rax)
  call   <free@plt>
  jmp    L168
  nopl   0x0(%rax)
L166:
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <strcpy@plt>
  lea    D83(%rip),%rsi
  mov    %r13,%rdi
  call   <strcat@plt>
  mov    %r13,%rdi
  mov    %r15,%rsi
  call   <fopen@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  jne    L14
  mov    %r13,%rdi
  xor    %r13d,%r13d
  call   <free@plt>
  jmp    L35
  nopl   0x0(%rax)
L149:
  mov    %rbp,%rsi
  mov    %r14,%rdi
  call   <strcpy@plt>
  lea    D31(%rip),%rsi
  mov    %r14,%rdi
  call   <strcat@plt>
  mov    %r14,%rdi
  mov    %r15,%rsi
  call   <fopen@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  jne    L137
  mov    %r14,%rdi
  xor    %r14d,%r14d
  call   <free@plt>
  jmp    L1
  nopl   0x0(%rax)
L172:
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    D56(%rip),%rsi
  lea    -0x4(%rbp,%rax,1),%rdi
  call   <gms_strcasecmp@plt>
  test   %rax,%rax
  je     L80
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    D10(%rip),%rsi
  lea    -0x4(%rbp,%rax,1),%rdi
  call   <gms_strcasecmp@plt>
  test   %rax,%rax
  je     L80
  jmp    L38
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D53
type: string
name: extract_symbolic_data
arguments: data_label: D20
type: string
name: extract_symbolic_data
arguments: data_label: D56
type: string
name: extract_symbolic_data
arguments: data_label: D10
type: string
name: extract_symbolic_data
arguments: data_label: D30
type: string
name: extract_symbolic_data
arguments: data_label: D83
type: string
name: extract_symbolic_data
arguments: data_label: D31
type: string

tool: D53: .MAG

tool: D20: rb

tool: D56: .GFX

tool: D10: .HNT

tool: D30: .mag

tool: D83: .gfx

tool: D31: .hnt

assistant: ```c
void gms_establish_filenames(char *name, char **text, char **graphics, char **hints) {
  char *base, *text_file, *graphics_file, *hints_file;
  FILE *stream;
  assert(name && text && graphics && hints);
  base = gms_malloc(strlen(name) + 1);
  strcpy(base, name);
  if (strlen(base) > strlen(".XXX")) {
    if (gms_strcasecmp(base + strlen(base) - strlen(".MAG"), ".MAG") == 0 || gms_strcasecmp(base + strlen(base) - strlen(".GFX"), ".GFX") == 0 || gms_strcasecmp(base + strlen(base) - strlen(".HNT"), ".HNT") == 0)
      base[strlen(base) - strlen(".XXX")] = '\0';
  }
  text_file = gms_malloc(strlen(base) + strlen(".MAG") + 1);
  strcpy(text_file, base);
  strcat(text_file, ".MAG");
  stream = fopen(text_file, "rb");
  if (!stream) {
    strcpy(text_file, base);
    strcat(text_file, ".mag");
    stream = fopen(text_file, "rb");
    if (!stream) {
      *text = NULL;
      *graphics = NULL;
      *hints = NULL;
      free(text_file);
      free(base);
      return;
    }
  }
  if (stream)
    fclose(stream);
  graphics_file = gms_malloc(strlen(base) + strlen(".GFX") + 1);
  strcpy(graphics_file, base);
  strcat(graphics_file, ".GFX");
  stream = fopen(graphics_file, "rb");
  if (!stream) {
    strcpy(graphics_file, base);
    strcat(graphics_file, ".gfx");
    stream = fopen(graphics_file, "rb");
    if (!stream) {
      free(graphics_file);
      graphics_file = NULL;
    }
  }
  if (stream)
    fclose(stream);
  hints_file = gms_malloc(strlen(base) + strlen(".HNT") + 1);
  strcpy(hints_file, base);
  strcat(hints_file, ".HNT");
  stream = fopen(hints_file, "rb");
  if (!stream) {
    strcpy(hints_file, base);
    strcat(hints_file, ".hnt");
    stream = fopen(hints_file, "rb");
    if (!stream) {
      free(hints_file);
      hints_file = NULL;
    }
  }
  if (stream)
    fclose(stream);
  *text = text_file;
  *graphics = graphics_file;
  *hints = hints_file;
  free(base);
}
```