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

```asm
<md_set_file_ext>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %rdi,%rdi
  je     L196
  mov    %rdi,%r15
  mov    %rdx,%rdi
  mov    %rsi,%rbx
  mov    %rdx,%r12
  call   <strlen@plt>
  lea    D19(%rip),%rsi
  mov    %rsi,(%rsp)
  test   %eax,%eax
  jle    L57
  mov    %rbx,%rdi
  call   <strlen@plt>
  lea    D18(%rip),%rsi
  mov    %rsi,(%rsp)
  test   %eax,%eax
  jle    L57
  mov    %r15,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jle    L99
  mov    %r15,%rdi
  call   <strlen@plt>
  sub    $0x1,%eax
  js     L99
  cltq
  jmp    L3
  nopl   0x0(%rax,%rax,1)
L385:
  sub    $0x1,%rax
  test   %eax,%eax
  js     L99
L3:
  cmpb   $0x2e,(%r15,%rax,1)
  mov    %eax,%ebp
  jne    L385
  jmp    L109
  nopl   0x0(%rax,%rax,1)
L196:
  movq   $0x0,(%rsp)
L57:
  mov    (%rsp),%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L99:
  mov    %r15,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jle    L76
  mov    %r15,%rdi
  call   <strlen@plt>
  mov    %eax,%ebp
L109:
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %r12,%rdi
  mov    %eax,%r13d
  call   <strlen@plt>
  lea    0x3(%r13,%rbp,1),%edx
  xor    %ecx,%ecx
  add    %edx,%eax
  mov    %eax,0x8(%rsp)
  mov    %eax,%r14d
L167:
  mov    %r14d,%edi
  mov    %ecx,0xc(%rsp)
  call   <malloc@plt>
  mov    %r12,(%rsp)
  mov    %rax,%r13
  test   %rax,%rax
  je     L57
  test   %r14d,%r14d
  mov    %rax,(%rsp)
  mov    0xc(%rsp),%ecx
  jle    L243
  movslq %r14d,%rdx
  xor    %esi,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    0xc(%rsp),%ecx
L243:
  cmp    $0x1,%ecx
  je     L263
  test   %ebp,%ebp
  jle    L73
  lea    0x1(%r15),%rdi
  mov    %r13,%rsi
  lea    -0x1(%rbp),%eax
  mov    %ebp,%edx
  sub    %rdi,%rsi
  cmp    $0xe,%rsi
  jbe    L21
  cmp    $0x6,%eax
  jbe    L21
  cmp    $0xe,%eax
  jbe    L182
  mov    %ebp,%eax
  mov    %r15,%rdx
  shr    $0x4,%eax
  sub    %r13,%rdx
  sub    $0x1,%eax
  shl    $0x4,%rax
  lea    0x10(%r13,%rax,1),%rcx
  mov    %r13,%rax
  nopl   0x0(%rax)
L336:
  movdqu (%rax,%rdx,1),%xmm0
  add    $0x10,%rax
  movups %xmm0,-0x10(%rax)
  cmp    %rcx,%rax
  jne    L336
  mov    %ebp,%eax
  and    $0xfffffff0,%eax
  mov    %eax,%ecx
  cmp    %eax,%ebp
  je     L73
  mov    %ebp,%edx
  sub    %eax,%edx
  lea    -0x1(%rdx),%esi
  cmp    $0x6,%esi
  jbe    L305
L36:
  mov    (%r15,%rax,1),%rsi
  mov    %rsi,0x0(%r13,%rax,1)
  mov    %edx,%eax
  and    $0xfffffff8,%eax
  add    %eax,%ecx
  cmp    %eax,%edx
  je     L73
L305:
  movslq %ecx,%rax
  movzbl (%r15,%rax,1),%edx
  mov    %dl,0x0(%r13,%rax,1)
  lea    0x1(%rcx),%eax
  cmp    %eax,%ebp
  jle    L73
  cltq
  movzbl (%r15,%rax,1),%edx
  mov    %dl,0x0(%r13,%rax,1)
  lea    0x2(%rcx),%eax
  cmp    %eax,%ebp
  jle    L73
  cltq
  movzbl (%r15,%rax,1),%edx
  mov    %dl,0x0(%r13,%rax,1)
  lea    0x3(%rcx),%eax
  cmp    %eax,%ebp
  jle    L73
  cltq
  movzbl (%r15,%rax,1),%edx
  mov    %dl,0x0(%r13,%rax,1)
  lea    0x4(%rcx),%eax
  cmp    %eax,%ebp
  jle    L73
  cltq
  movzbl (%r15,%rax,1),%edx
  mov    %dl,0x0(%r13,%rax,1)
  lea    0x5(%rcx),%eax
  cmp    %eax,%ebp
  jle    L73
  cltq
  add    $0x6,%ecx
  movzbl (%r15,%rax,1),%edx
  mov    %dl,0x0(%r13,%rax,1)
  cmp    %ecx,%ebp
  jle    L73
  movslq %ecx,%rcx
  movzbl (%r15,%rcx,1),%eax
  mov    %al,0x0(%r13,%rcx,1)
  nopl   (%rax)
L73:
  xor    %r14d,%r14d
  movslq %ebp,%r15
  jmp    L19
  nopl   0x0(%rax,%rax,1)
L270:
  movzbl (%rbx,%r14,1),%ecx
  lea    0x0(%r13,%r14,1),%rax
  add    $0x1,%r14
  mov    %cl,(%rax,%r15,1)
L19:
  mov    %rbx,%rdi
  call   <strlen@plt>
  lea    0x0(%rbp,%r14,1),%ecx
  add    %ebp,%eax
  cmp    %ecx,%eax
  jge    L270
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %rbx,%rdi
  add    %ebp,%eax
  cltq
  movb   $0x2e,0x0(%r13,%rax,1)
  call   <strlen@plt>
  mov    0x8(%rsp),%edx
  lea    0x1(%rbp,%rax,1),%eax
  cmp    %eax,%edx
  jle    L57
  mov    %eax,%r14d
  sub    %ebp,%edx
  cltq
  mov    %edx,0x8(%rsp)
  sub    %ebp,%r14d
  add    %rax,%r13
  jmp    L223
  nopw   0x0(%rax,%rax,1)
L185:
  mov    %rbx,%rdi
  add    $0x1,%r13
  call   <strlen@plt>
  mov    %eax,%r8d
  mov    %r14d,%eax
  add    $0x1,%r14d
  sub    %r8d,%eax
  cltq
  movzbl -0x1(%r12,%rax,1),%eax
  mov    %al,-0x1(%r13)
  cmp    0x8(%rsp),%r14d
  je     L57
L223:
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %rbx,%rdi
  lea    (%rax,%rbp,1),%r15d
  call   <strlen@plt>
  add    %eax,%r15d
  lea    (%r14,%rbp,1),%eax
  cmp    %eax,%r15d
  jge    L185
  jmp    L57
  nopl   (%rax)
L76:
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %r12,%rdi
  mov    %eax,%ebp
  call   <strlen@plt>
  mov    $0x1,%ecx
  lea    0x4(%rbp,%rax,1),%eax
  mov    $0x1,%ebp
  mov    %eax,0x8(%rsp)
  mov    %eax,%r14d
  jmp    L167
  nopl   0x0(%rax)
L263:
  movb   $0x6d,0x0(%r13)
  jmp    L73
  nopw   0x0(%rax,%rax,1)
L21:
  lea    0x1(%r13,%rax,1),%rcx
  sub    %r13,%r15
  mov    %r13,%rax
  nopl   0x0(%rax,%rax,1)
L33:
  movzbl (%r15,%rax,1),%edx
  add    $0x1,%rax
  mov    %dl,-0x1(%rax)
  cmp    %rcx,%rax
  jne    L33
  jmp    L73
L182:
  xor    %eax,%eax
  jmp    L36
```

tool_calls: name: retrieve_data
arguments: label: D19
type_infered: string
name: retrieve_data
arguments: label: D18
type_infered: string

tool: D19: ERR-EXT.txt

tool: D18: ERR-LAB.txt

assistant: ```c
char *md_set_file_ext(char *str, char *lab, char *ext) {
  char *tmp = NULL;
  int tmplen = 0;
  int dotpos = -1;
  int empty = 0;
  int i;
  if (str == NULL) {
    return (NULL);
  }
  if (strlen(ext) < 1) {
    return ("ERR-EXT.txt");
  }
  if (strlen(lab) < 1) {
    return ("ERR-LAB.txt");
  }
  if (strlen(str) >= 1) {
    for (i = (strlen(str) - 1); i >= 0; i--) {
      if (str[i] == '.') {
        dotpos = i;
        break;
      }
    }
  }
  if (dotpos == -1) {
    if (strlen(str) >= 1) {
      dotpos = strlen(str);
      tmplen = strlen(lab) + dotpos + 3 + strlen(ext);
    } else {
      tmplen = strlen(lab) + 4 + strlen(ext);
      dotpos = 1;
      empty = 1;
    }
  } else {
    tmplen = dotpos + strlen(lab) + 3 + strlen(ext);
  }
  if ((tmp = (char *)malloc(tmplen * sizeof(char))) == NULL) {
    return (ext);
  }
  for (i = 0; i < tmplen; i++) {
    tmp[i] = '\0';
  }
  if (empty == 1) {
    tmp[0] = 'm';
  } else {
    for (i = 0; i < dotpos; i++) {
      tmp[i] = str[i];
    }
  }
  for (i = dotpos; i < (dotpos + strlen(lab) + 1); i++) {
    tmp[i] = lab[i - dotpos];
  }
  tmp[dotpos + strlen(lab)] = '.';
  for (i = (dotpos + strlen(lab) + 1); i < tmplen; i++) {
    if (i > dotpos + strlen(ext) + strlen(lab)) {
      break;
    }
    tmp[i] = ext[i - dotpos - strlen(lab) - 1];
  }
  if (tmp == NULL) {
    return (ext);
  } else {
    return (tmp);
  }
}
```