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

```asm
<ConvertSubstituteRE>:
  endbr64
  test   %rdi,%rdi
  je     L254
  push   %r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %rsi,%rsi
  je     L260
  movzbl (%rdi),%ebx
  mov    %rdi,%rbp
  lea    0x1(%rdi),%r13
  mov    %rsi,%r12
  lea    -0x1(%rdx),%r15d
  test   %bl,%bl
  jne    L277
  jmp    L82
  nopl   0x0(%rax)
L206:
  cmp    $0x26,%bl
  je     L111
L251:
  mov    %r12,%rdx
  movslq %r15d,%rax
  sub    %r14,%rdx
  cmp    %rax,%rdx
  jge    L82
  movzbl %bl,%edi
  mov    $0x1,%esi
  call   <literal_escape@plt>
  test   %al,%al
  je     L67
  movb   $0x5c,(%r12)
  cmp    $0x30,%al
  je     L266
  mov    %al,0x1(%r12)
  mov    %r13,%rbp
  add    $0x2,%r12
  nopl   0x0(%rax)
L210:
  movzbl 0x0(%rbp),%ebx
  lea    0x1(%rbp),%r13
  test   %bl,%bl
  je     L82
L277:
  cmp    $0x5c,%bl
  jne    L206
  movzbl 0x1(%rbp),%eax
  and    $0xffffffdf,%eax
  cmp    $0x4c,%al
  je     L71
  cmp    $0x55,%al
  jne    L200
L71:
  movb   $0x5c,(%r12)
  movzbl 0x1(%rbp),%eax
  lea    0x2(%r12),%rdx
  mov    %al,0x1(%r12)
  test   %al,%al
  je     L27
  movzbl 0x2(%rbp),%ebx
  lea    0x3(%rbp),%r13
  cmp    $0x26,%bl
  je     L284
  cmp    $0x5c,%bl
  jne    L30
L227:
  movzbl 0x0(%r13),%edi
  lea    0x1(%r13),%rbp
  cmp    $0x30,%dil
  je     L94
  lea    -0x31(%rdi),%eax
  cmp    $0x8,%al
  ja     L65
L39:
  movb   $0x5c,(%rdx)
  movzbl 0x0(%r13),%eax
  lea    0x2(%rdx),%r12
  lea    0x1(%rbp),%r13
  mov    %al,0x1(%rdx)
  movzbl 0x0(%rbp),%ebx
  test   %bl,%bl
  jne    L277
L82:
  movb   $0x0,(%r12)
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L284:
  mov    %rdx,%r12
L111:
  movb   $0x26,(%r12)
  mov    %r13,%rbp
  add    $0x1,%r12
  jmp    L210
  nopl   0x0(%rax)
L67:
  mov    %bl,(%r12)
  mov    %r13,%rbp
  add    $0x1,%r12
  jmp    L210
  nopl   0x0(%rax,%rax,1)
L94:
  movb   $0x26,(%rdx)
  lea    0x1(%rdx),%r12
  jmp    L210
  nopl   0x0(%rax)
L200:
  mov    %r12,%rdx
  jmp    L227
  nopl   0x0(%rax,%rax,1)
L266:
  mov    %ebx,%eax
  movb   $0x30,0x1(%r12)
  mov    %r13,%rbp
  add    $0x5,%r12
  shr    $0x6,%al
  add    $0x30,%eax
  mov    %al,-0x3(%r12)
  mov    %ebx,%eax
  and    $0x7,%ebx
  shr    $0x3,%al
  add    $0x30,%ebx
  and    $0x7,%eax
  mov    %bl,-0x1(%r12)
  add    $0x30,%eax
  mov    %al,-0x2(%r12)
  jmp    L210
  nopw   0x0(%rax,%rax,1)
L65:
  xor    %esi,%esi
  mov    %rdx,0x8(%rsp)
  call   <literal_escape@plt>
  mov    0x8(%rsp),%rdx
  test   %al,%al
  jne    L39
  movzbl 0x0(%r13),%eax
  lea    0x1(%rdx),%r12
  test   %al,%al
  jne    L211
  movb   $0x5c,(%rdx)
  mov    %r13,%rbp
  jmp    L210
  nopl   0x0(%rax)
L211:
  mov    %al,(%rdx)
  jmp    L210
  nop
L30:
  mov    %rdx,%r12
  jmp    L251
L260:
  add    $0x18,%rsp
  lea    D13(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1070 <reg_error@plt>
L27:
  mov    %rdx,%r12
  jmp    L82
L254:
  lea    D13(%rip),%rdi
  jmp    1070 <reg_error@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D13
data_type: string

tool: D13: NULL parm to `ConvertSubstituteRE'

assistant: ```c
void ConvertSubstituteRE(const char *source, char *dest, int max) {
  register unsigned char *src;
  register unsigned char *dst;
  register unsigned char c;
  register unsigned char test;
  if (source == NULL || dest == NULL) {
    reg_error("NULL parm to `ConvertSubstituteRE\'");
    return;
  }
  src = (unsigned char *)source;
  dst = (unsigned char *)dest;
  while ((c = *src++) != '\0') {
    if (c == '\\') {
      if (*src == 'u' || *src == 'U' || *src == 'l' || *src == 'L') {
        *dst++ = '\\';
        c = *src++;
        *dst++ = c;
        if (c == '\0') {
          break;
        } else {
          c = *src++;
        }
      }
    }
    if (c == '&') {
      *dst++ = '&';
    } else if (c == '\\') {
      if (*src == '0') {
        *dst++ = '&';
        src++;
      } else if ('1' <= *src && *src <= '9') {
        *dst++ = '\\';
        *dst++ = *src++;
      } else if ((test = literal_escape(*src, 0)) != '\0') {
        *dst++ = '\\';
        *dst++ = *src++;
      } else if (*src == '\0') {
        *dst++ = '\\';
      } else {
        *dst++ = *src++;
      }
    } else {
      if (((char *)dst - (char *)dest) >= (max - 1)) {
        break;
      } else {
        if ((test = literal_escape(c, 1))) {
          *dst++ = '\\';
          if (test == '0') {
            test = c;
            *dst++ = '0';
            *dst++ = ('0' + (test / 64));
            test -= (test / 64) * 64;
            *dst++ = ('0' + (test / 8));
            test -= (test / 8) * 8;
            *dst++ = ('0' + test);
          } else {
            *dst++ = test;
          }
        } else {
          *dst++ = c;
        }
      }
    }
  }
  *dst = '\0';
}
```