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

```asm
<ERR_error_string_n>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0xf8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  call   <ERR_GET_LIB@plt>
  mov    %r12,%rdi
  mov    %rax,%r14
  call   <ERR_GET_FUNC@plt>
  mov    %r12,%rdi
  mov    %rax,0x8(%rsp)
  call   <ERR_GET_REASON@plt>
  mov    %r12,%rdi
  mov    %rax,0x10(%rsp)
  call   <ERR_lib_error_string@plt>
  mov    %r12,%rdi
  mov    %rax,%r13
  call   <ERR_func_error_string@plt>
  mov    %r12,%rdi
  mov    %rax,%r15
  call   <ERR_reason_error_string@plt>
  mov    %rax,%r10
  test   %r13,%r13
  je     L86
  test   %r15,%r15
  je     L63
L93:
  test   %r10,%r10
  je     L20
L45:
  test   %r13,%r13
  lea    0x20(%rsp),%rax
  mov    %r12,%rcx
  mov    %rbx,%rsi
  cmove  %rax,%r13
  sub    $0x8,%rsp
  lea    D39(%rip),%rdx
  xor    %eax,%eax
  push   %r10
  mov    %r15,%r9
  mov    %rbp,%rdi
  mov    %r13,%r8
  call   <BIO_snprintf@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  pop    %rcx
  lea    -0x1(%rbx),%rdx
  pop    %rsi
  cmp    $0x4,%rbx
  jbe    L61
  cmp    %rdx,%rax
  je     L125
L61:
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L8
  add    $0xf8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L125:
  lea    -0x5(%rbp,%rbx,1),%rbx
  lea    0x0(%rbp,%rdx,1),%r12
L122:
  mov    $0x3a,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L38
  cmp    %rbx,%rax
  jbe    L104
L38:
  movb   $0x3a,(%rbx)
  mov    %rbx,%rax
L104:
  add    $0x1,%rbx
  lea    0x1(%rax),%rbp
  cmp    %rbx,%r12
  jne    L122
  jmp    L61
  cs nopw 0x0(%rax,%rax,1)
L86:
  mov    %rax,0x18(%rsp)
  lea    0x20(%rsp),%rdi
  mov    %r14,%rcx
  xor    %eax,%eax
  lea    D21(%rip),%rdx
  mov    $0x40,%esi
  call   <BIO_snprintf@plt>
  mov    0x18(%rsp),%r10
  test   %r15,%r15
  jne    L93
  xchg   %ax,%ax
L63:
  mov    0x8(%rsp),%rcx
  lea    0x60(%rsp),%r15
  lea    D29(%rip),%rdx
  xor    %eax,%eax
  mov    $0x40,%esi
  mov    %r15,%rdi
  mov    %r10,0x18(%rsp)
  call   <BIO_snprintf@plt>
  mov    0x18(%rsp),%r10
  test   %r10,%r10
  jne    L45
  nopl   0x0(%rax,%rax,1)
L20:
  lea    0xa0(%rsp),%r14
  mov    0x10(%rsp),%rcx
  lea    D1(%rip),%rdx
  xor    %eax,%eax
  mov    $0x40,%esi
  mov    %r14,%rdi
  call   <BIO_snprintf@plt>
  mov    %r14,%r10
  jmp    L45
L8:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D39
type: string
name: extract_symbolic_data
arguments: label: D21
type: string
name: extract_symbolic_data
arguments: label: D29
type: string
name: extract_symbolic_data
arguments: label: D1
type: string

tool: D39: error:%08lX:%s:%s:%s

tool: D21: lib(%lu)

tool: D29: func(%lu)

tool: D1: reason(%lu)

assistant: ```c
void ERR_error_string_n(unsigned long e, char *buf, size_t len) {
  char lsbuf[64], fsbuf[64], rsbuf[64];
  const char *ls, *fs, *rs;
  unsigned long l, f, r;
  l = ERR_GET_LIB(e);
  f = ERR_GET_FUNC(e);
  r = ERR_GET_REASON(e);
  ls = ERR_lib_error_string(e);
  fs = ERR_func_error_string(e);
  rs = ERR_reason_error_string(e);
  if (ls == NULL)
    BIO_snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l);
  if (fs == NULL)
    BIO_snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f);
  if (rs == NULL)
    BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
  BIO_snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls ? ls : lsbuf, fs ? fs : fsbuf, rs ? rs : rsbuf);
  if (strlen(buf) == len - 1) {
    if (len > 4) {
      int i;
      char *s = buf;
      for (i = 0; i < 4; i++) {
        char *colon = strchr(s, ':');
        if (colon == NULL || colon > &buf[len - 1] - 4 + i) {
          colon = &buf[len - 1] - 4 + i;
          *colon = ':';
        }
        s = colon + 1;
      }
    }
  }
}
```