user: Converte this assembly snippet into its equivalent C code:

```asm
<Tcl_ConvertElement>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  mov    %rsi,-0x10(%rbp)
  mov    %edx,-0x14(%rbp)
  mov    -0x10(%rbp),%rbx
  mov    -0x14(%rbp),%eax
  and    $0x2,%eax
  test   %eax,%eax
  je     L122
  mov    -0x14(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  jne    L122
  movb   $0x7b,(%rbx)
  add    $0x1,%rbx
  jmp    L98
L47:
  movzbl (%rdi),%eax
  mov    %al,(%rbx)
  add    $0x1,%rdi
  add    $0x1,%rbx
L98:
  movzbl (%rdi),%eax
  test   %al,%al
  jne    L47
  movb   $0x7d,(%rbx)
  add    $0x1,%rbx
  jmp    L302
L122:
  movzbl (%rdi),%eax
  test   %al,%al
  jne    L259
  movb   $0x5c,(%rbx)
  lea    0x1(%rbx),%rax
  movb   $0x30,(%rax)
  add    $0x2,%rbx
  jmp    L302
L281:
  movzbl (%rdi),%eax
  movsbl %al,%eax
  cmp    $0x7d,%eax
  je     L147
  cmp    $0x7d,%eax
  jg     L299
  cmp    $0x7b,%eax
  je     L147
  cmp    $0x7b,%eax
  jg     L299
  cmp    $0x5d,%eax
  jg     L299
  cmp    $0x5b,%eax
  jge    L20
  cmp    $0x3b,%eax
  jg     L299
  cmp    $0xc,%eax
  jge    L325
  cmp    $0xb,%eax
  je     L174
  cmp    $0xb,%eax
  jg     L299
  cmp    $0x9,%eax
  je     L262
  cmp    $0xa,%eax
  je     L170
  jmp    L299
L325:
  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    L20
  mov    %rax,%rdx
  and    $0x2000,%edx
  test   %rdx,%rdx
  setne  %dl
  test   %dl,%dl
  jne    L290
  and    $0x1000,%eax
  test   %rax,%rax
  setne  %al
  test   %al,%al
  jne    L107
  jmp    L299
L20:
  movb   $0x5c,(%rbx)
  add    $0x1,%rbx
  jmp    L299
L147:
  mov    -0x14(%rbp),%eax
  and    $0x4,%eax
  test   %eax,%eax
  je     L32
  movb   $0x5c,(%rbx)
  add    $0x1,%rbx
  jmp    L32
L107:
  movb   $0x5c,(%rbx)
  add    $0x1,%rbx
  movb   $0x66,(%rbx)
  add    $0x1,%rbx
  jmp    L108
L170:
  movb   $0x5c,(%rbx)
  add    $0x1,%rbx
  movb   $0x6e,(%rbx)
  add    $0x1,%rbx
  jmp    L108
L290:
  movb   $0x5c,(%rbx)
  add    $0x1,%rbx
  movb   $0x72,(%rbx)
  add    $0x1,%rbx
  jmp    L108
L262:
  movb   $0x5c,(%rbx)
  add    $0x1,%rbx
  movb   $0x74,(%rbx)
  add    $0x1,%rbx
  jmp    L108
L174:
  movb   $0x5c,(%rbx)
  add    $0x1,%rbx
  movb   $0x76,(%rbx)
  add    $0x1,%rbx
  jmp    L108
L32:
  nop
L299:
  movzbl (%rdi),%eax
  mov    %al,(%rbx)
  add    $0x1,%rbx
L108:
  add    $0x1,%rdi
L259:
  movzbl (%rdi),%eax
  test   %al,%al
  jne    L281
L302:
  movb   $0x0,(%rbx)
  mov    %rbx,%rax
  sub    -0x10(%rbp),%rax
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int Tcl_ConvertElement(src, dst, flags)
register char *src;
char *dst;
int flags;
{
  register char *p = dst;
  if ((flags & 2) && !(flags & 1)) {
    *p = '{';
    p++;
    for (; *src != 0; src++, p++) {
      *p = *src;
    }
    *p = '}';
    p++;
  } else if (*src == 0) {
    p[0] = '\\';
    p[1] = '0';
    p += 2;
  } else {
    for (; *src != 0; 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;
}
```