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

```asm
<do_title_expn>:
  endbr64
  push   %r15
  xor    %r15d,%r15d
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x138,%rsp
  mov    %rcx,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x128(%rsp)
  xor    %eax,%eax
  lea    -0x1(%rsi),%eax
  movb   $0x0,(%rdi)
  mov    %eax,0x4(%rsp)
  mov    %eax,%r13d
  test   %eax,%eax
  jle    L498
L32:
  movzbl (%rbx),%eax
  test   %al,%al
  je     L498
L65:
  lea    0x1(%rbx),%r12
  cmp    $0x25,%al
  je     L557
  cmp    $0x5c,%al
  jne    L518
  test   %r15w,%r15w
  je     L521
L518:
  mov    0x4(%rsp),%edx
  sub    %r13d,%edx
  sub    $0x1,%r13d
  movslq %edx,%rdx
  mov    %al,0x0(%rbp,%rdx,1)
  movb   $0x0,0x1(%rbp,%rdx,1)
L455:
  mov    %r12,%rbx
  test   %r13d,%r13d
  jle    L498
  movzbl (%rbx),%eax
  xor    %r15d,%r15d
  test   %al,%al
  jne    L65
L498:
  xor    %eax,%eax
  test   %r13d,%r13d
  mov    0x4(%rsp),%ebx
  cmovns %r13d,%eax
  sub    %eax,%ebx
  movslq %ebx,%rbx
  movb   $0x0,0x0(%rbp,%rbx,1)
  mov    0x128(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L416
  add    $0x138,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L557:
  test   %r15w,%r15w
  jne    L518
  movsbl 0x1(%rbx),%edi
  test   %dil,%dil
  je     L223
  cmp    $0x28,%dil
  jne    L205
L461:
  movsbl 0x2(%rbx),%edi
  test   %dil,%dil
  je     L83
L579:
  mov    0x18(%rsp),%rsi
  call   <title_expn_subs@plt>
  movzbl 0x3(%rbx),%esi
  mov    %rax,%r11
  test   %sil,%sil
  je     L36
L378:
  cmpb   $0x0,0x4(%rbx)
  lea    0x4(%rbx),%r14
  je     L580
L595:
  xor    %ecx,%ecx
  lea    0x20(%rsp),%r12
  test   %r11,%r11
  jne    L493
  jmp    L185
  nopl   0x0(%rax,%rax,1)
L283:
  add    $0x1,%rcx
L493:
  movslq %ecx,%rax
  test   %r15w,%r15w
  jne    L304
  cmp    %sil,(%r14)
  je     L353
L304:
  cmp    $0xfe,%rcx
  je     L562
L278:
  movzbl (%r14),%eax
  xor    %r15d,%r15d
  cmp    $0x5c,%al
  mov    %al,(%r12,%rcx,1)
  sete   %r15b
  add    $0x1,%r14
  cmpb   $0x0,(%r14)
  jne    L283
  lea    D54(%rip),%rdi
  mov    %rcx,0x10(%rsp)
  mov    %sil,0x8(%rsp)
  call   <fatal@plt>
  mov    0x10(%rsp),%rcx
  movzbl 0x8(%rsp),%esi
  jmp    L283
  nopl   0x0(%rax,%rax,1)
L521:
  mov    $0x1,%r15d
L79:
  mov    %r12,%rbx
  jmp    L32
  xchg   %ax,%ax
L205:
  mov    0x18(%rsp),%rsi
  call   <title_expn_subs@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L29
  lea    -0x1(%r13),%edx
  mov    %rax,%rsi
  mov    %rbp,%rdi
  add    $0x1,%r12
  call   <strncat@plt>
  mov    %r14,%rdi
  call   <strlen@plt>
  sub    %eax,%r13d
  jmp    L455
  nopl   0x0(%rax)
L223:
  lea    D54(%rip),%rdi
  call   <fatal@plt>
  movsbl 0x1(%rbx),%edi
  cmp    $0x28,%dil
  je     L461
  jmp    L205
  nopl   0x0(%rax)
L562:
  lea    D82(%rip),%rdi
  mov    %rcx,0x10(%rsp)
  mov    %sil,0x8(%rsp)
  call   <fatal@plt>
  mov    0x10(%rsp),%rcx
  movzbl 0x8(%rsp),%esi
  jmp    L278
  nopl   (%rax)
L353:
  mov    %r14,%rbx
  movb   $0x0,0x20(%rsp,%rax,1)
  lea    D54(%rip),%r14
  jmp    L202
  nopl   0x0(%rax)
L535:
  lea    0x1(%rbx),%r15
  test   %al,%al
  je     L107
  mov    %eax,%esi
L479:
  mov    %r15,%rbx
L202:
  cmp    $0x29,%sil
  je     L72
L312:
  movzbl 0x1(%rbx),%eax
  cmp    $0x5c,%sil
  jne    L535
  test   %al,%al
  je     L174
L525:
  movzbl 0x2(%rbx),%esi
  lea    0x2(%rbx),%r15
  test   %sil,%sil
  jne    L479
  mov    %r14,%rdi
  call   <fatal@plt>
  movzbl 0x2(%rbx),%esi
  jmp    L479
  nopl   0x0(%rax)
L107:
  mov    %r14,%rdi
  call   <fatal@plt>
  movzbl 0x1(%rbx),%esi
  mov    %r15,%rbx
  cmp    $0x29,%sil
  jne    L312
  nopl   (%rax)
L72:
  movslq 0x4(%rsp),%r14
  movslq %r13d,%rax
  mov    0x18(%rsp),%rcx
  mov    %r12,%rdx
  mov    %r13d,%esi
  lea    0x1(%rbx),%r12
  sub    %rax,%r14
  add    %rbp,%r14
  mov    %r14,%rdi
  call   <do_title_expn>
  mov    %r14,%rdi
  call   <strlen@plt>
  sub    %eax,%r13d
  jmp    L455
  nopl   (%rax)
L174:
  mov    %r14,%rdi
  call   <fatal@plt>
  jmp    L525
  nopw   0x0(%rax,%rax,1)
L29:
  add    $0x1,%r12
  jmp    L79
  nopl   0x0(%rax)
L580:
  lea    D54(%rip),%rdi
  mov    %r11,0x10(%rsp)
  mov    %sil,0x8(%rsp)
  call   <fatal@plt>
  mov    0x10(%rsp),%r11
  movzbl 0x8(%rsp),%esi
  jmp    L595
  nopl   (%rax)
L36:
  lea    D54(%rip),%rdi
  mov    %rax,0x8(%rsp)
  call   <fatal@plt>
  movzbl 0x3(%rbx),%esi
  mov    0x8(%rsp),%r11
  jmp    L378
  nopw   0x0(%rax,%rax,1)
L83:
  lea    D54(%rip),%rdi
  call   <fatal@plt>
  movsbl 0x2(%rbx),%edi
  jmp    L579
  nopl   (%rax)
L185:
  movzbl 0x4(%rbx),%eax
  lea    D54(%rip),%r12
  jmp    L340
  nopl   (%rax)
L229:
  lea    0x1(%r14),%rbx
  test   %cl,%cl
  je     L382
  mov    %ecx,%eax
L206:
  mov    %rbx,%r14
L340:
  cmp    %sil,%al
  je     L226
L137:
  movzbl 0x1(%r14),%ecx
  cmp    $0x5c,%al
  jne    L229
  test   %cl,%cl
  je     L472
L57:
  movzbl 0x2(%r14),%eax
  lea    0x2(%r14),%rbx
  test   %al,%al
  jne    L206
  mov    %r12,%rdi
  mov    %sil,0x8(%rsp)
  call   <fatal@plt>
  movzbl 0x2(%r14),%eax
  movzbl 0x8(%rsp),%esi
  jmp    L206
  nopl   0x0(%rax)
L382:
  mov    %r12,%rdi
  mov    %sil,0x8(%rsp)
  call   <fatal@plt>
  movzbl 0x1(%r14),%eax
  movzbl 0x8(%rsp),%esi
  mov    %rbx,%r14
  cmp    %sil,%al
  jne    L137
L226:
  cmpb   $0x0,0x1(%r14)
  lea    0x1(%r14),%rbx
  je     L288
L565:
  movzbl 0x1(%r14),%ecx
  xor    %r15d,%r15d
  lea    0x20(%rsp),%r12
  jmp    L133
  nopl   (%rax)
L50:
  test   %cl,%cl
  je     L289
L481:
  mov    %r14,%rbx
L133:
  cmp    $0x29,%cl
  je     L106
L171:
  movslq %r15d,%rdx
  add    %r12,%rdx
  cmp    $0xfe,%r15d
  je     L593
L110:
  movzbl (%rbx),%eax
  movzbl 0x1(%rbx),%ecx
  add    $0x1,%r15d
  lea    0x1(%rbx),%r14
  mov    %al,(%rdx)
  cmp    $0x5c,%al
  jne    L50
  add    $0x1,%rdx
  test   %cl,%cl
  je     L452
  mov    %r14,%rbx
  cmp    $0xfe,%r15d
  jne    L110
L593:
  lea    D89(%rip),%rdi
  mov    %rdx,0x8(%rsp)
  call   <fatal@plt>
  mov    0x8(%rsp),%rdx
  jmp    L110
  nopl   0x0(%rax,%rax,1)
L289:
  lea    D54(%rip),%rdi
  call   <fatal@plt>
  movzbl 0x1(%rbx),%ecx
  jmp    L481
  nopw   0x0(%rax,%rax,1)
L452:
  lea    D54(%rip),%rdi
  mov    %r14,%rbx
  call   <fatal@plt>
  jmp    L171
  nopl   0x0(%rax)
L106:
  movslq %r15d,%r15
  movb   $0x0,0x20(%rsp,%r15,1)
  jmp    L72
  xchg   %ax,%ax
L472:
  mov    %r12,%rdi
  mov    %sil,0x8(%rsp)
  call   <fatal@plt>
  movzbl 0x8(%rsp),%esi
  jmp    L57
L288:
  lea    D54(%rip),%rdi
  call   <fatal@plt>
  jmp    L565
L416:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D54
type_infered: string
name: read_data
arguments: tag: D82
type_infered: string
name: read_data
arguments: tag: D89
type_infered: string

tool: D54: Unexpected end of title expression

tool: D82: Nested ternary expression too long

tool: D89: Ternary expression too long

assistant: ```c
void do_title_expn(char *dest, int size, const char *fmt, const struct file_tags *tags) {
  const char *h;
  int free = --size;
  short escape = 0;
  dest[0] = 0;
  while (free > 0 && *fmt) {
    if (*fmt == '%' && !escape) {
      if ((*++fmt) == '\0')
        fatal("Unexpected end of title expression");
      if (*fmt == '(') {
        char separator, expr[256];
        int expr_pos = 0;
        if ((*++fmt) == '\0')
          fatal("Unexpected end of title expression");
        h = title_expn_subs(*fmt, tags);
        if ((*++fmt) == '\0')
          fatal("Unexpected end of title expression");
        separator = *fmt;
        if ((*++fmt) == '\0')
          fatal("Unexpected end of title expression");
        if (h) {
          while (escape || *fmt != separator) {
            if (expr_pos == sizeof(expr) - 2)
              fatal("Nested ternary expression too long");
            expr[expr_pos++] = *fmt;
            if (*fmt == '\\')
              escape = 1;
            else
              escape = 0;
            if ((*++fmt) == '\0')
              fatal("Unexpected end of title expression");
          }
          expr[expr_pos] = '\0';
          while (escape || *fmt != ')') {
            if (escape)
              escape = 0;
            else if (*fmt == '\\')
              escape = 1;
            if ((*++fmt) == '\0')
              fatal("Unexpected end of title expression");
          }
        } else {
          while (escape || *fmt != separator) {
            if (escape)
              escape = 0;
            else if (*fmt == '\\')
              escape = 1;
            if ((*++fmt) == '\0')
              fatal("Unexpected end of title expression");
          }
          if ((*++fmt) == '\0')
            fatal("Unexpected end of title expression");
          while (escape || *fmt != ')') {
            if (expr_pos == sizeof(expr) - 2)
              fatal("Ternary expression too long");
            expr[expr_pos++] = *fmt;
            if (*fmt == '\\')
              escape = 1;
            else
              escape = 0;
            if ((*++fmt) == '\0')
              fatal("Unexpected end of title expression");
          }
          expr[expr_pos] = '\0';
        }
        do_title_expn((dest + size - free), free, expr, tags);
        free -= strlen(dest + size - free);
      } else {
        h = title_expn_subs(*fmt, tags);
        if (h) {
          strncat(dest, h, free - 1);
          free -= strlen(h);
        }
      }
    } else if (*fmt == '\\' && !escape)
      escape = 1;
    else {
      dest[size - free] = *fmt;
      dest[size - free + 1] = 0;
      --free;
      escape = 0;
    }
    fmt++;
  }
  free = free < 0 ? 0 : free;
  dest[size - free] = '\0';
}
```