user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<mpgedit_edit_make_output_filename>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %rcx,-0x60(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x30(%rbp)
  mov    -0x50(%rbp),%rax
  mov    $0x2e,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  je     L111
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L111
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x58(%rbp)
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  mov    %rax,-0x30(%rbp)
  mov    -0x28(%rbp),%rax
  sub    -0x50(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x50(%rbp)
L111:
  cmpq   $0x0,-0x48(%rbp)
  je     L16
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  jmp    L34
L16:
  mov    $0x0,%eax
L34:
  mov    %eax,-0x3c(%rbp)
  cmpq   $0x0,-0x50(%rbp)
  je     L29
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  jmp    L52
L29:
  mov    $0x0,%eax
L52:
  mov    %eax,-0x38(%rbp)
  cmpq   $0x0,-0x58(%rbp)
  je     L137
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  jmp    L132
L137:
  mov    $0x0,%eax
L132:
  mov    %eax,-0x34(%rbp)
  mov    -0x3c(%rbp),%edx
  mov    -0x38(%rbp),%eax
  add    %eax,%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  add    $0x11,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L133
  mov    -0x20(%rbp),%rax
  movb   $0x0,(%rax)
  cmpq   $0x0,-0x48(%rbp)
  je     L42
  mov    -0x48(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x20(%rbp),%rax
  lea    D18(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
L42:
  cmpq   $0x0,-0x50(%rbp)
  je     L138
  mov    -0x50(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
L138:
  cmpq   $0x0,-0x60(%rbp)
  je     L142
  mov    -0x20(%rbp),%rax
  lea    D27(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x60(%rbp),%rax
  mov    (%rax),%edx
  lea    -0x14(%rbp),%rax
  lea    D29(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x14(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x60(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x60(%rbp),%rax
  mov    %edx,(%rax)
L142:
  cmpq   $0x0,-0x58(%rbp)
  je     L133
  mov    -0x20(%rbp),%rax
  lea    D13(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x58(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
L133:
  cmpq   $0x0,-0x30(%rbp)
  je     L148
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L148:
  mov    -0x20(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L134
  call   <__stack_chk_fail@plt>
L134:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D18
type_guessed: string
name: retrieve_data
arguments: data_label: D27
type_guessed: string
name: retrieve_data
arguments: data_label: D29
type_guessed: string
name: retrieve_data
arguments: data_label: D13
type_guessed: string

tool: D18: /

tool: D27: _

tool: D29: %d

tool: D13: .

assistant: ```c
char *mpgedit_edit_make_output_filename(char *dir, char *base, char *ext, int *index) {
  char *file;
  char *cp;
  char *cp2 = NULL;
  int dirlen;
  int baselen;
  int extlen;
  char fmtbuf[12];
  cp = strrchr(base, '.');
  if (cp && cp[1]) {
    ext = cp + 1;
    cp2 = strdup(base);
    cp2[cp - base] = '\0';
    base = cp2;
  }
  dirlen = dir ? strlen(dir) : 0;
  baselen = base ? strlen(base) : 0;
  extlen = ext ? strlen(ext) : 0;
  file = malloc(dirlen + sizeof("/") + baselen + sizeof("_") + 11 + sizeof(".") + extlen);
  if (file) {
    file[0] = '\0';
    if (dir) {
      strcat(file, dir);
      strcat(file, "/");
    }
    if (base) {
      strcat(file, base);
    }
    if (index) {
      strcat(file, "_");
      sprintf(fmtbuf, "%d", *index);
      strcat(file, fmtbuf);
      (*index)++;
    }
    if (ext) {
      strcat(file, ".");
      strcat(file, ext);
    }
  }
  if (cp2) {
    free(cp2);
  }
  return file;
}
```