user: 请将以下的汇编代码转换成C语言代码:

```asm
<tf_makename>:
  endbr64
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    D28(%rip),%rdi
  test   %rdi,%rdi
  je     L101
  call   <free@plt>
L101:
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %rax,%r12
  test   %rbp,%rbp
  je     L293
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    0x3(%r12,%rax,1),%rdi
  call   <malloc@plt>
  cmpb   $0x2f,0x0(%rbp)
  lea    0x1(%rax),%rsi
  mov    %rax,D30(%rip)
  movb   $0x2f,(%rax)
  mov    %rsi,%rdx
  je     L68
  movzbl (%rbx),%ecx
  cmp    $0x2f,%cl
  je     L107
L189:
  test   %cl,%cl
  jne    L345
  jmp    L180
  nopl   (%rax)
L128:
  mov    %cl,(%rdx)
  add    $0x1,%rbx
  movzbl (%rbx),%ecx
  add    $0x1,%rdx
L199:
  test   %cl,%cl
  je     L234
L345:
  cmpb   $0x2f,-0x1(%rdx)
  mov    %rsi,%rdi
  jne    L128
  cmp    $0x2e,%cl
  jne    L128
  cmpb   $0x2e,0x1(%rbx)
  jne    L128
  movzbl 0x2(%rbx),%r8d
  cmp    $0x2f,%r8b
  je     L89
  test   %r8b,%r8b
  jne    L128
L89:
  cmp    %rsi,%rdx
  ja     L216
L91:
  test   %r8b,%r8b
  je     L364
  movzbl 0x3(%rbx),%ecx
  mov    %rdi,%rdx
  add    $0x3,%rbx
  mov    %rsi,%rdi
  jmp    L199
L364:
  mov    %rdi,%rdx
  mov    %rsi,%rdi
  nopl   0x0(%rax)
L234:
  test   %rbp,%rbp
  je     L55
L147:
  cmpb   $0x2f,-0x1(%rdx)
  je     L241
  movb   $0x2f,(%rdx)
  add    $0x1,%rdx
L241:
  movzbl 0x0(%rbp),%ecx
  cmp    $0x2f,%cl
  jne    L296
  movzbl 0x1(%rbp),%ecx
  add    $0x1,%rbp
  test   %cl,%cl
  je     L55
  nop
L99:
  cmpb   $0x2f,-0x1(%rdx)
  mov    %rsi,%rdi
  jne    L36
  cmp    $0x2e,%cl
  je     L1
L36:
  mov    %cl,(%rdx)
  add    $0x1,%rbp
  movzbl 0x0(%rbp),%ecx
  add    $0x1,%rdx
L296:
  test   %cl,%cl
  jne    L99
L55:
  cmp    %rdi,%rdx
  jbe    L250
  xor    %ecx,%ecx
  cmpb   $0x2f,-0x1(%rdx)
  sete   %cl
  sub    %rcx,%rdx
L250:
  movb   $0x0,(%rdx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L1:
  cmpb   $0x2e,0x1(%rbp)
  jne    L36
  movzbl 0x2(%rbp),%r8d
  cmp    $0x2f,%r8b
  je     L349
  test   %r8b,%r8b
  jne    L36
L349:
  cmp    %rsi,%rdx
  ja     L221
L70:
  test   %r8b,%r8b
  je     L284
  movzbl 0x3(%rbp),%ecx
  mov    %rdi,%rdx
  add    $0x3,%rbp
  mov    %rsi,%rdi
  jmp    L296
L68:
  xor    %edi,%edi
L326:
  movzbl 0x1(%rbp),%ecx
  lea    0x1(%rbp),%rbx
  mov    %rdi,%rbp
  test   %cl,%cl
  jne    L345
L180:
  mov    %rsi,%rdi
  test   %rbp,%rbp
  jne    L147
  jmp    L250
  nopl   0x0(%rax,%rax,1)
L293:
  lea    0x3(%rax),%rdi
  call   <malloc@plt>
  movzbl (%rbx),%ecx
  lea    0x1(%rax),%rsi
  mov    %rax,D30(%rip)
  movb   $0x2f,(%rax)
  mov    %rsi,%rdx
  cmp    $0x2f,%cl
  jne    L189
L107:
  mov    %rbp,%rdi
  mov    %rbx,%rbp
  jmp    L326
L284:
  mov    %rdi,%rdx
  mov    %rsi,%rdi
  jmp    L55
L221:
  movb   $0x0,-0x1(%rdx)
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  movzbl 0x2(%rbp),%r8d
  lea    0x1(%rax),%rdi
  mov    D30(%rip),%rax
  lea    0x1(%rax),%rsi
  jmp    L70
L216:
  movb   $0x0,-0x1(%rdx)
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  movzbl 0x2(%rbx),%r8d
  lea    0x1(%rax),%rdi
  mov    D30(%rip),%rax
  lea    0x1(%rax),%rsi
  jmp    L91
```

assistant: ```c
char *tf_makename(const char *dir, const char *filename) {
  static char *buf;
  char *pt;
  if (buf) {
    free(buf);
  }
  buf = malloc(1 + strlen(dir) + 1 + strlen(filename ?: "") + 1);
  pt = buf;
  *pt++ = '/';
  if (filename && *filename == '/') {
    dir = filename;
    filename = 0;
  }
  if (dir[0] == '/') {
    dir++;
  }
  while (*dir) {
    if (pt[-1] == '/' && dir[0] == '.' && dir[1] == '.') {
      if (dir[2] == '/' || dir[2] == 0) {
        if (pt > buf + 1) {
          pt[-1] = 0;
          pt = strrchr(buf, '/') + 1;
        } else {
          pt = buf + 1;
        }
        dir += 2;
        if (*dir) {
          dir++;
        }
        continue;
      }
    }
    *pt++ = *dir++;
  }
  if (filename) {
    if (pt[-1] != '/') {
      *pt++ = '/';
    }
    if (filename[0] == '/') {
      filename++;
    }
    while (*filename) {
      if (pt[-1] == '/' && filename[0] == '.' && filename[1] == '.') {
        if (filename[2] == '/' || filename[2] == 0) {
          if (pt > buf + 1) {
            pt[-1] = 0;
            pt = strrchr(buf, '/') + 1;
          } else {
            pt = buf + 1;
          }
          filename += 2;
          if (*filename) {
            filename++;
          }
          continue;
        }
      }
      *pt++ = *filename++;
    }
  }
  if (pt > buf + 1 && pt[-1] == '/') {
    pt--;
  }
  *pt = 0;
  return buf;
}
```