user: Please show me the C implementation that matches the assembly code listed below:

```asm
<do_title_expn>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x158,%rsp
  mov    %rdi,-0x148(%rbp)
  mov    %esi,-0x14c(%rbp)
  mov    %rdx,-0x158(%rbp)
  mov    %rcx,-0x160(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  subl   $0x1,-0x14c(%rbp)
  mov    -0x14c(%rbp),%eax
  mov    %eax,-0x130(%rbp)
  movw   $0x0,-0x132(%rbp)
  mov    -0x148(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L220
L140:
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x25,%al
  jne    L192
  cmpw   $0x0,-0x132(%rbp)
  jne    L192
  addq   $0x1,-0x158(%rbp)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L4
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L4:
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x28,%al
  jne    L351
  movl   $0x0,-0x12c(%rbp)
  addq   $0x1,-0x158(%rbp)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L47
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L47:
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    -0x160(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <title_expn_subs@plt>
  mov    %rax,-0x128(%rbp)
  addq   $0x1,-0x158(%rbp)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L213
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L213:
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0x133(%rbp)
  addq   $0x1,-0x158(%rbp)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L180
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L180:
  cmpq   $0x0,-0x128(%rbp)
  je     L93
  jmp    L210
L127:
  cmpl   $0xfe,-0x12c(%rbp)
  jne    L290
  lea    D71(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L290:
  mov    -0x12c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x12c(%rbp)
  mov    -0x158(%rbp),%rdx
  movzbl (%rdx),%edx
  cltq
  mov    %dl,-0x120(%rbp,%rax,1)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  jne    L312
  movw   $0x1,-0x132(%rbp)
  jmp    L414
L312:
  movw   $0x0,-0x132(%rbp)
L414:
  addq   $0x1,-0x158(%rbp)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L210
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L210:
  cmpw   $0x0,-0x132(%rbp)
  jne    L127
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    %al,-0x133(%rbp)
  jne    L127
  mov    -0x12c(%rbp),%eax
  cltq
  movb   $0x0,-0x120(%rbp,%rax,1)
  jmp    L94
L381:
  cmpw   $0x0,-0x132(%rbp)
  je     L115
  movw   $0x0,-0x132(%rbp)
  jmp    L173
L115:
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  jne    L173
  movw   $0x1,-0x132(%rbp)
L173:
  addq   $0x1,-0x158(%rbp)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L94
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L94:
  cmpw   $0x0,-0x132(%rbp)
  jne    L381
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x29,%al
  jne    L381
  jmp    L20
L88:
  cmpw   $0x0,-0x132(%rbp)
  je     L51
  movw   $0x0,-0x132(%rbp)
  jmp    L426
L51:
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  jne    L426
  movw   $0x1,-0x132(%rbp)
L426:
  addq   $0x1,-0x158(%rbp)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L93
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L93:
  cmpw   $0x0,-0x132(%rbp)
  jne    L88
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    %al,-0x133(%rbp)
  jne    L88
  addq   $0x1,-0x158(%rbp)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L37
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
  jmp    L37
L419:
  cmpl   $0xfe,-0x12c(%rbp)
  jne    L279
  lea    D93(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L279:
  mov    -0x12c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x12c(%rbp)
  mov    -0x158(%rbp),%rdx
  movzbl (%rdx),%edx
  cltq
  mov    %dl,-0x120(%rbp,%rax,1)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  jne    L205
  movw   $0x1,-0x132(%rbp)
  jmp    L293
L205:
  movw   $0x0,-0x132(%rbp)
L293:
  addq   $0x1,-0x158(%rbp)
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L37
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L37:
  cmpw   $0x0,-0x132(%rbp)
  jne    L419
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x29,%al
  jne    L419
  mov    -0x12c(%rbp),%eax
  cltq
  movb   $0x0,-0x120(%rbp,%rax,1)
L20:
  mov    -0x14c(%rbp),%eax
  cltq
  mov    -0x130(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  mov    %rax,%rcx
  mov    -0x148(%rbp),%rax
  lea    (%rcx,%rax,1),%rdi
  mov    -0x160(%rbp),%rcx
  lea    -0x120(%rbp),%rdx
  mov    -0x130(%rbp),%eax
  mov    %eax,%esi
  call   <do_title_expn>
  mov    -0x130(%rbp),%ebx
  mov    -0x14c(%rbp),%eax
  cltq
  mov    -0x130(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  mov    %rax,%rcx
  mov    -0x148(%rbp),%rax
  add    %rcx,%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %ebx,%eax
  sub    %edx,%eax
  mov    %eax,-0x130(%rbp)
  jmp    L167
L351:
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    -0x160(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <title_expn_subs@plt>
  mov    %rax,-0x128(%rbp)
  cmpq   $0x0,-0x128(%rbp)
  je     L167
  mov    -0x130(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x128(%rbp),%rcx
  mov    -0x148(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncat@plt>
  mov    -0x130(%rbp),%ebx
  mov    -0x128(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %ebx,%eax
  sub    %edx,%eax
  mov    %eax,-0x130(%rbp)
  jmp    L167
L192:
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  jne    L189
  cmpw   $0x0,-0x132(%rbp)
  jne    L189
  movw   $0x1,-0x132(%rbp)
  jmp    L466
L189:
  mov    -0x14c(%rbp),%eax
  sub    -0x130(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x148(%rbp),%rax
  add    %rax,%rdx
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  mov    -0x14c(%rbp),%eax
  sub    -0x130(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x148(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  subl   $0x1,-0x130(%rbp)
  movw   $0x0,-0x132(%rbp)
  jmp    L466
L167:
  nop
L466:
  addq   $0x1,-0x158(%rbp)
L220:
  cmpl   $0x0,-0x130(%rbp)
  jle    L377
  mov    -0x158(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L140
L377:
  mov    -0x130(%rbp),%eax
  mov    $0x0,%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  mov    %eax,-0x130(%rbp)
  mov    -0x14c(%rbp),%eax
  sub    -0x130(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x148(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  nop
  mov    -0x18(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L356
  call   <__stack_chk_fail@plt>
L356:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: read_data
arguments: label: D73
type_guessed: string
name: read_data
arguments: label: D71
type_guessed: string
name: read_data
arguments: label: D93
type_guessed: string

tool: D73: Unexpected end of title expression

tool: D71: nasted trenary expression too long

tool: D93: trenary 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("nasted trenary 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("trenary 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';
}
```