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

```asm
<Tcl_ConvertCountedElement>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %ecx,-0x20(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L158
  cmpl   $0xffffffff,-0x1c(%rbp)
  jne    L158
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x1c(%rbp)
L158:
  cmpq   $0x0,-0x18(%rbp)
  je     L171
  cmpl   $0x0,-0x1c(%rbp)
  jne    L82
L171:
  mov    -0x10(%rbp),%rax
  movb   $0x7b,(%rax)
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movb   $0x7d,(%rax)
  mov    -0x10(%rbp),%rax
  add    $0x2,%rax
  movb   $0x0,(%rax)
  mov    $0x2,%eax
  jmp    L119
L82:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x20(%rbp),%eax
  and    $0x2,%eax
  test   %eax,%eax
  je     L65
  mov    -0x20(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  jne    L65
  mov    -0x10(%rbp),%rax
  movb   $0x7b,(%rax)
  addq   $0x1,-0x10(%rbp)
  jmp    L374
L77:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x18(%rbp)
  addq   $0x1,-0x10(%rbp)
L374:
  mov    -0x18(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jne    L77
  mov    -0x10(%rbp),%rax
  movb   $0x7d,(%rax)
  addq   $0x1,-0x10(%rbp)
  jmp    L316
L65:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x7b,%al
  jne    L350
  mov    -0x10(%rbp),%rax
  movb   $0x5c,(%rax)
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movb   $0x7b,(%rax)
  addq   $0x2,-0x10(%rbp)
  addq   $0x1,-0x18(%rbp)
  orl    $0x4,-0x20(%rbp)
  jmp    L350
L226:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    $0x7d,%eax
  je     L302
  cmp    $0x7d,%eax
  jg     L40
  cmp    $0x7b,%eax
  je     L302
  cmp    $0x7b,%eax
  jg     L40
  cmp    $0x5d,%eax
  jg     L40
  cmp    $0x5b,%eax
  jge    L336
  cmp    $0x3b,%eax
  jg     L40
  cmp    $0xc,%eax
  jge    L283
  cmp    $0xb,%eax
  je     L341
  cmp    $0xb,%eax
  jg     L40
  cmp    $0x9,%eax
  je     L8
  cmp    $0xa,%eax
  je     L81
  jmp    L40
L283:
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%rdx
  mov    %rdx,%rax
  movabs $0x800001500000000,%rdx
  and    %rax,%rdx
  test   %rdx,%rdx
  setne  %dl
  test   %dl,%dl
  jne    L336
  mov    %rax,%rdx
  and    $0x2000,%edx
  test   %rdx,%rdx
  setne  %dl
  test   %dl,%dl
  jne    L129
  and    $0x1000,%eax
  test   %rax,%rax
  setne  %al
  test   %al,%al
  jne    L213
  jmp    L40
L336:
  mov    -0x10(%rbp),%rax
  movb   $0x5c,(%rax)
  addq   $0x1,-0x10(%rbp)
  jmp    L40
L302:
  mov    -0x20(%rbp),%eax
  and    $0x4,%eax
  test   %eax,%eax
  je     L19
  mov    -0x10(%rbp),%rax
  movb   $0x5c,(%rax)
  addq   $0x1,-0x10(%rbp)
  jmp    L19
L213:
  mov    -0x10(%rbp),%rax
  movb   $0x5c,(%rax)
  addq   $0x1,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movb   $0x66,(%rax)
  addq   $0x1,-0x10(%rbp)
  jmp    L294
L81:
  mov    -0x10(%rbp),%rax
  movb   $0x5c,(%rax)
  addq   $0x1,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movb   $0x6e,(%rax)
  addq   $0x1,-0x10(%rbp)
  jmp    L294
L129:
  mov    -0x10(%rbp),%rax
  movb   $0x5c,(%rax)
  addq   $0x1,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movb   $0x72,(%rax)
  addq   $0x1,-0x10(%rbp)
  jmp    L294
L8:
  mov    -0x10(%rbp),%rax
  movb   $0x5c,(%rax)
  addq   $0x1,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movb   $0x74,(%rax)
  addq   $0x1,-0x10(%rbp)
  jmp    L294
L341:
  mov    -0x10(%rbp),%rax
  movb   $0x5c,(%rax)
  addq   $0x1,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movb   $0x76,(%rax)
  addq   $0x1,-0x10(%rbp)
  jmp    L294
L19:
  nop
L40:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x10(%rbp)
L294:
  addq   $0x1,-0x18(%rbp)
L350:
  mov    -0x18(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jne    L226
L316:
  mov    -0x10(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x10(%rbp),%rax
  sub    -0x28(%rbp),%rax
L119:
  leave
  ret
```

assistant: ```c
int Tcl_ConvertCountedElement(src, length, dst, flags) const char *src;
int length;
char *dst;
int flags;
{
  char *p = dst;
  const char *lastChar;
  if (src && length == -1) {
    length = strlen(src);
  }
  if ((src == 0) || (length == 0)) {
    p[0] = '{';
    p[1] = '}';
    p[2] = 0;
    return 2;
  }
  lastChar = src + length;
  if ((flags & 2) && !(flags & 1)) {
    *p = '{';
    p++;
    for (; src != lastChar; src++, p++) {
      *p = *src;
    }
    *p = '}';
    p++;
  } else {
    if (*src == '{') {
      p[0] = '\\';
      p[1] = '{';
      p += 2;
      src++;
      flags |= 4;
    }
    for (; src != lastChar; src++) {
      switch (*src) {
      case ']':
      case '[':
      case '$':
      case ';':
      case ' ':
      case '\\':
      case '"':
        *p = '\\';
        p++;
        break;
      case '{':
      case '}':
        if (flags & 4) {
          *p = '\\';
          p++;
        }
        break;
      case '\f':
        *p = '\\';
        p++;
        *p = 'f';
        p++;
        continue;
      case '\n':
        *p = '\\';
        p++;
        *p = 'n';
        p++;
        continue;
      case '\r':
        *p = '\\';
        p++;
        *p = 'r';
        p++;
        continue;
      case '\t':
        *p = '\\';
        p++;
        *p = 't';
        p++;
        continue;
      case '\v':
        *p = '\\';
        p++;
        *p = 'v';
        p++;
        continue;
      }
      *p = *src;
      p++;
    }
  }
  *p = '\0';
  return p - dst;
}
```