user: What is the c source code of the assembly code below?

```asm
<to_octets>:
  endbr64
  push   %r15
  push   %r14
  mov    %esi,%r14d
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  mov    $0xff,%eax
  cmp    %eax,%esi
  cmovle %esi,%eax
  test   %eax,%eax
  lea    0xf(%rax),%ebx
  mov    %eax,0x8(%rsp)
  cmovns %eax,%ebx
  sar    $0x4,%ebx
  add    $0x2,%ebx
  imul   $0x39,%ebx,%ebx
  add    $0x1,%ebx
  mov    %ebx,%edi
  call   <oml_malloc@plt>
  movb   $0x0,0x20(%rsp)
  mov    %rax,%r12
  test   %rax,%rax
  je     L46
  mov    %rax,%rdi
  xor    %ecx,%ecx
  lea    D49(%rip),%rdx
  mov    %ebx,%esi
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %eax,%r13d
  test   %r14d,%r14d
  jle    L185
  movl   $0x0,0x4(%rsp)
  mov    $0x1,%r15d
  movl   $0x1,0xc(%rsp)
  jmp    L22
  nopl   0x0(%rax)
L109:
  test   $0x7,%dl
  je     L55
  and    $0x3,%edx
  je     L59
L15:
  add    $0x1,%r15
L22:
  movzbl -0x1(%rbp,%r15,1),%ecx
  movslq %r13d,%rdi
  mov    %ebx,%esi
  xor    %eax,%eax
  sub    %r13d,%esi
  add    %r12,%rdi
  lea    D1(%rip),%rdx
  call   <snprintf@plt>
  movzbl -0x1(%rbp,%r15,1),%edi
  lea    0x0(%r13,%rax,1),%r14d
  call   <isprint@plt>
  mov    %r14d,%r13d
  mov    %rax,%r11
  mov    $0x2e,%eax
  test   %r11,%r11
  je     L186
  movzbl -0x1(%rbp,%r15,1),%eax
L186:
  movslq 0x4(%rsp),%rdx
  mov    %al,0x10(%rsp,%rdx,1)
  mov    %r15d,%edx
  cmp    %r15d,0x8(%rsp)
  jle    L185
  movslq %r14d,%rax
  mov    %ebx,%esi
  lea    (%r12,%rax,1),%rdi
  mov    %r15d,%eax
  sub    %r14d,%esi
  and    $0xf,%eax
  mov    %eax,0x4(%rsp)
  jne    L109
  mov    0xc(%rsp),%r8d
  lea    0x10(%rsp),%rcx
  lea    D11(%rip),%rdx
  lea    0x1(%r8),%eax
  mov    %eax,0xc(%rsp)
  xor    %eax,%eax
  call   <snprintf@plt>
  lea    (%r14,%rax,1),%r13d
  jmp    L15
  nopl   0x0(%rax,%rax,1)
L185:
  mov    0x4(%rsp),%eax
  test   %eax,%eax
  je     L46
  lea    0x1(%rax),%r15d
  cmp    $0xf,%eax
  je     L160
  lea    D52(%rip),%r14
  lea    D78(%rip),%rbp
  jmp    L112
  nopl   (%rax)
L56:
  mov    %rbp,%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  add    %eax,%r13d
L157:
  add    $0x1,%r15d
  cmp    $0x10,%r15d
  je     L160
L112:
  mov    %ebx,%esi
  movslq %r13d,%rdi
  sub    %r13d,%esi
  add    %r12,%rdi
  test   $0x7,%r15b
  je     L57
  test   $0x3,%r15b
  je     L56
  mov    %r14,%rdx
  xor    %eax,%eax
  add    $0x1,%r15d
  call   <snprintf@plt>
  add    %eax,%r13d
  cmp    $0x10,%r15d
  jne    L112
L160:
  mov    %ebx,%esi
  movslq %r13d,%rdi
  lea    0x10(%rsp),%rcx
  xor    %eax,%eax
  sub    %r13d,%esi
  add    %r12,%rdi
  movb   $0x0,0x20(%rsp)
  lea    D87(%rip),%rdx
  call   <snprintf@plt>
L46:
  movslq %ebx,%rbx
  movb   $0x0,-0x1(%r12,%rbx,1)
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  add    $0x38,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L57:
  lea    D15(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  add    %eax,%r13d
  jmp    L157
  xchg   %ax,%ax
L55:
  lea    D52(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  lea    (%r14,%rax,1),%r13d
  jmp    L15
  nopw   0x0(%rax,%rax,1)
L59:
  lea    D71(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  lea    (%r14,%rax,1),%r13d
  jmp    L15
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D49
type: string
name: read_data
arguments: tag: D1
type: string
name: read_data
arguments: tag: D11
type: string
name: read_data
arguments: tag: D52
type: string
name: read_data
arguments: tag: D78
type: string
name: read_data
arguments: tag: D87
type: string
name: read_data
arguments: tag: D15
type: string
name: read_data
arguments: tag: D71
type: string

tool: D49:    0 1 2 3  4 5 6 7   8 9 a b  c d e f  0123456789abcdef
%2x 

tool: D1: %02x

tool: D11:  %s
%2x 

tool: D52:   

tool: D78:    

tool: D87:  %s

tool: D15:     

tool: D71:  

assistant: ```c
char *to_octets(unsigned char *buf, int len) {
  const int octet_width = 2;
  const int columns = 16;
  len = (len > 0xff) ? 0xff : len;
  const int rows = len / columns + 2;
  const int rowlength = (octet_width * columns + 7 + 1 + columns + 1);
  const int outlength = rows * rowlength + 1;
  char *out = oml_malloc(outlength);
  char strrep[columns + 1];
  int n = 0, i, col, rw = 0;
  strrep[columns] = 0;
  if (out) {
    n += snprintf(out, outlength - n, "   0 1 2 3  4 5 6 7   8 9 a b  c d e f  0123456789abcdef\n%2x ", rw++);
    for (i = 0; i < len; i++) {
      col = i % columns;
      if (i == 0) {
        while (0)
          ;
      } else if (col == 0) {
        n += snprintf(&out[n], outlength - n, " %s\n%2x ", strrep, rw++);
      } else if (0 == (col % 8)) {
        n += snprintf(&out[n], outlength - n, "  ");
      } else if (0 == (col % 4)) {
        n += snprintf(&out[n], outlength - n, " ");
      }
      n += snprintf(&out[n], outlength - n, "%02x", (unsigned int)buf[i]);
      if (isprint(buf[i])) {
        strrep[col] = buf[i];
      } else {
        strrep[col] = '.';
      }
    }
    if (col != 0) {
      while (++col < columns) {
        if (0 == (col % 8)) {
          n += snprintf(&out[n], outlength - n, "    ");
        } else if (0 == (col % 4)) {
          n += snprintf(&out[n], outlength - n, "   ");
        } else {
          n += snprintf(&out[n], outlength - n, "  ");
        }
      }
      strrep[col] = 0;
      n += snprintf(&out[n], outlength - n, " %s", strrep);
    }
  }
  out[outlength - 1] = 0;
  return out;
}
```