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

```asm
<lace_compat_string_byte_translate>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x2a0,%rsp
  mov    %rdi,-0x278(%rbp)
  mov    %rsi,-0x280(%rbp)
  mov    %rdx,-0x288(%rbp)
  mov    %rcx,-0x290(%rbp)
  mov    %r8,-0x298(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x268(%rbp)
  jmp    L8
L56:
  mov    -0x268(%rbp),%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x288(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x218(%rbp)
  mov    -0x268(%rbp),%edx
  mov    -0x280(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x25c(%rbp)
  cmpq   $0xff,-0x218(%rbp)
  jbe    L14
  mov    $0x0,%eax
  jmp    L96
L14:
  mov    -0x218(%rbp),%rax
  mov    %eax,%edx
  mov    -0x25c(%rbp),%eax
  mov    %dl,-0x210(%rbp,%rax,1)
  mov    -0x268(%rbp),%eax
  mov    %eax,%edx
  mov    -0x25c(%rbp),%eax
  mov    %dl,-0x110(%rbp,%rax,1)
  addl   $0x1,-0x268(%rbp)
L8:
  mov    -0x268(%rbp),%edx
  mov    -0x280(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L56
  cmpq   $0x0,-0x290(%rbp)
  jne    L77
  lea    D10(%rip),%rax
  mov    %rax,-0x290(%rbp)
L77:
  cmpq   $0x0,-0x298(%rbp)
  jne    L85
  lea    D10(%rip),%rax
  mov    %rax,-0x298(%rbp)
L85:
  mov    -0x290(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x230(%rbp)
  mov    -0x298(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x228(%rbp)
  movq   $0x0,-0x248(%rbp)
  mov    -0x230(%rbp),%rax
  mov    %rax,-0x258(%rbp)
  mov    -0x280(%rbp),%rdx
  mov    -0x278(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcspn@plt>
  mov    %rax,-0x250(%rbp)
  jmp    L53
L81:
  mov    -0x248(%rbp),%rdx
  mov    -0x250(%rbp),%rax
  add    %rax,%rdx
  mov    -0x278(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x260(%rbp)
  mov    -0x260(%rbp),%eax
  movzbl -0x210(%rbp,%rax,1),%eax
  movzbl %al,%edx
  mov    -0x250(%rbp),%rax
  add    %rdx,%rax
  add    %rax,-0x258(%rbp)
  mov    -0x250(%rbp),%rdx
  mov    -0x248(%rbp),%rax
  add    %rdx,%rax
  add    $0x1,%rax
  mov    %rax,-0x248(%rbp)
  mov    -0x278(%rbp),%rdx
  mov    -0x248(%rbp),%rax
  add    %rax,%rdx
  mov    -0x280(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <strcspn@plt>
  mov    %rax,-0x250(%rbp)
L53:
  mov    -0x248(%rbp),%rdx
  mov    -0x250(%rbp),%rax
  add    %rax,%rdx
  mov    -0x278(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L81
  mov    -0x250(%rbp),%rdx
  mov    -0x228(%rbp),%rax
  add    %rdx,%rax
  add    %rax,-0x258(%rbp)
  mov    -0x258(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x220(%rbp)
  movq   $0x0,-0x238(%rbp)
  mov    -0x230(%rbp),%rax
  mov    %rax,-0x258(%rbp)
  mov    -0x230(%rbp),%rdx
  mov    -0x290(%rbp),%rcx
  mov    -0x220(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x280(%rbp),%rdx
  mov    -0x278(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcspn@plt>
  mov    %rax,-0x240(%rbp)
  jmp    L39
L79:
  mov    -0x238(%rbp),%rdx
  mov    -0x240(%rbp),%rax
  add    %rax,%rdx
  mov    -0x278(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x264(%rbp)
  mov    -0x278(%rbp),%rdx
  mov    -0x238(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x220(%rbp),%rdx
  mov    -0x258(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x240(%rbp),%rax
  mov    %rax,%rdx
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x264(%rbp),%eax
  movzbl -0x210(%rbp,%rax,1),%eax
  movzbl %al,%edx
  mov    -0x264(%rbp),%eax
  movzbl -0x110(%rbp,%rax,1),%eax
  movzbl %al,%eax
  lea    0x0(,%rax,8),%rcx
  mov    -0x288(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  mov    -0x258(%rbp),%rsi
  mov    -0x240(%rbp),%rcx
  add    %rcx,%rsi
  mov    -0x220(%rbp),%rcx
  add    %rsi,%rcx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x240(%rbp),%rdx
  mov    -0x238(%rbp),%rax
  add    %rdx,%rax
  add    $0x1,%rax
  mov    %rax,-0x238(%rbp)
  mov    -0x264(%rbp),%eax
  movzbl -0x210(%rbp,%rax,1),%eax
  movzbl %al,%edx
  mov    -0x240(%rbp),%rax
  add    %rdx,%rax
  add    %rax,-0x258(%rbp)
  mov    -0x278(%rbp),%rdx
  mov    -0x238(%rbp),%rax
  add    %rax,%rdx
  mov    -0x280(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <strcspn@plt>
  mov    %rax,-0x240(%rbp)
L39:
  mov    -0x238(%rbp),%rdx
  mov    -0x240(%rbp),%rax
  add    %rax,%rdx
  mov    -0x278(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L79
  mov    -0x278(%rbp),%rdx
  mov    -0x238(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x220(%rbp),%rdx
  mov    -0x258(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x240(%rbp),%rax
  mov    %rax,%rdx
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x240(%rbp),%rax
  add    %rax,-0x258(%rbp)
  mov    -0x220(%rbp),%rdx
  mov    -0x258(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x228(%rbp),%rdx
  mov    -0x298(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x228(%rbp),%rax
  add    %rax,-0x258(%rbp)
  mov    -0x220(%rbp),%rdx
  mov    -0x258(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x220(%rbp),%rax
L96:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L31
  call   <__stack_chk_fail@plt>
L31:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D10
type: string

tool: 

assistant: ```c
char *lace_compat_string_byte_translate(const char *haystack, const char *needles, const char *const *replacements, const char *lhs, const char *rhs) {
  unsigned char replacement_length_lut[256];
  unsigned char replacement_index_lut[256];
  size_t lhs_length, rhs_length;
  char *dst;
  size_t offset;
  {
    unsigned i;
    for (i = 0; needles[i] != '\0'; ++i) {
      size_t n = strlen(replacements[i]);
      const unsigned needle = (unsigned)needles[i];
      if (n >= 256) {
        return NULL;
      }
      replacement_length_lut[needle] = (unsigned char)n;
      replacement_index_lut[needle] = (unsigned char)i;
    }
    if (!lhs) {
      lhs = "";
    }
    if (!rhs) {
      rhs = "";
    }
    lhs_length = strlen(lhs);
    rhs_length = strlen(rhs);
  }
  {
    size_t n;
    size_t i = 0;
    offset = lhs_length;
    for (n = strcspn(haystack, needles); haystack[i + n] != '\0'; n = strcspn(&haystack[i], needles)) {
      const unsigned needle = (unsigned)haystack[i + n];
      offset += n + replacement_length_lut[needle];
      i += n + 1;
    }
    offset += n + rhs_length;
  }
  dst = (char *)malloc(offset + 1);
  {
    size_t n;
    size_t i = 0;
    offset = lhs_length;
    memcpy(dst, lhs, lhs_length);
    for (n = strcspn(haystack, needles); haystack[i + n] != '\0'; n = strcspn(&haystack[i], needles)) {
      const unsigned needle = (unsigned)haystack[i + n];
      memcpy(&dst[offset], &haystack[i], n);
      memcpy(&dst[offset + n], replacements[replacement_index_lut[needle]], replacement_length_lut[needle]);
      i += n + 1;
      offset += n + replacement_length_lut[needle];
    }
    memcpy(&dst[offset], &haystack[i], n);
    offset += n;
    memcpy(&dst[offset], rhs, rhs_length);
    offset += rhs_length;
    dst[offset] = '\0';
  }
  return dst;
}
```