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

```asm
<us3tensor>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  sub    %r8,%r9
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %r15,%rbp
  push   %rbx
  sub    %rdx,%rbp
  lea    0x1(%r9),%rbx
  add    $0x1,%rbp
  sub    $0x28,%rsp
  mov    %rsi,0x8(%rsp)
  sub    %rdi,%rsi
  mov    %rsi,%rcx
  mov    %r8,0x10(%rsp)
  add    $0x1,%rcx
  lea    0x0(,%rcx,8),%rdi
  mov    %rcx,(%rsp)
  call   <malloc@plt>
  mov    (%rsp),%rcx
  test   %rax,%rax
  mov    %rax,%r14
  je     L89
L34:
  imul   %rbp,%rcx
  lea    0x0(,%r13,8),%rax
  mov    %r14,%rsi
  sub    %rax,%rsi
  mov    %rsi,(%rsp)
  lea    0x0(,%rcx,8),%rdi
  mov    %rcx,0x18(%rsp)
  call   <malloc@plt>
  mov    0x18(%rsp),%rcx
  test   %rax,%rax
  mov    %rax,(%r14)
  je     L84
L73:
  lea    0x0(,%r12,8),%r8
  mov    %rcx,%rdi
  sub    %r8,%rax
  imul   %rbx,%rdi
  mov    %r8,0x18(%rsp)
  mov    %rax,(%r14)
  shl    $0x2,%rdi
  call   <malloc@plt>
  mov    (%r14),%rdi
  mov    0x18(%rsp),%r8
  mov    %rax,%rcx
  lea    (%rdi,%r8,1),%rax
  mov    %rcx,(%rax)
  test   %rcx,%rcx
  je     L25
L1:
  mov    0x10(%rsp),%r9
  add    $0x1,%r12
  shl    $0x2,%r9
  sub    %r9,%rcx
  mov    %rcx,(%rax)
  cmp    %r12,%r15
  jl     L54
  lea    0x0(,%rbx,4),%r9
  lea    (%rdi,%r15,8),%rdi
  nopl   0x0(%rax)
L42:
  mov    (%rax),%rcx
  add    $0x8,%rax
  add    %r9,%rcx
  mov    %rcx,(%rax)
  cmp    %rax,%rdi
  jne    L42
L54:
  cmp    %r13,0x8(%rsp)
  jle    L36
  lea    0x0(,%rbp,8),%rdi
  mov    (%rsp),%rax
  mov    0x8(%rsp),%rsi
  mov    %r14,%r10
  imul   %rbx,%rbp
  lea    0x0(,%r15,8),%r11
  shl    $0x2,%rbx
  lea    0x0(,%rbp,4),%r9
  lea    (%rax,%rsi,8),%rbp
  nopl   0x0(%rax)
L119:
  mov    (%r10),%rdx
  mov    (%rdx,%r8,1),%rsi
  lea    (%rdx,%rdi,1),%rcx
  lea    (%rcx,%r8,1),%rax
  mov    %rcx,0x8(%r10)
  add    %r11,%rcx
  add    %r9,%rsi
  mov    %rsi,(%rax)
  cmp    %r12,%r15
  jl     L52
  nopl   0x0(%rax)
L49:
  mov    (%rax),%rdx
  add    $0x8,%rax
  add    %rbx,%rdx
  mov    %rdx,(%rax)
  cmp    %rcx,%rax
  jne    L49
L52:
  add    $0x8,%r10
  cmp    %r10,%rbp
  jne    L119
L36:
  mov    (%rsp),%rax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L89:
  lea    D5(%rip),%rdi
  call   <nrerror@plt>
  mov    (%rsp),%rcx
  jmp    L34
L25:
  lea    D23(%rip),%rdi
  call   <nrerror@plt>
  mov    (%r14),%rdi
  mov    0x18(%rsp),%r8
  lea    (%rdi,%r8,1),%rax
  mov    (%rax),%rcx
  jmp    L1
L84:
  lea    D10(%rip),%rdi
  call   <nrerror@plt>
  mov    (%r14),%rax
  mov    0x18(%rsp),%rcx
  jmp    L73
```

tool_calls: name: unpack_data
arguments: label: D5
type_infered: string
name: unpack_data
arguments: label: D23
type_infered: string
name: unpack_data
arguments: label: D10
type_infered: string

tool: D5: allocation failure 1 in us3tensor()

tool: D23: allocation failure 3 in s3tensor()

tool: D10: allocation failure 2 in us3tensor()

assistant: ```c
ushort ***us3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh) {
  long i, j, nrow = nrh - nrl + 1, ncol = nch - ncl + 1, ndep = ndh - ndl + 1;
  ushort ***t;
  t = (ushort ***)malloc((size_t)((nrow + 0) * sizeof(ushort **)));
  if (!t)
    nrerror("allocation failure 1 in us3tensor()");
  t += 0;
  t -= nrl;
  t[nrl] = (ushort **)malloc((size_t)((nrow * ncol + 0) * sizeof(ushort *)));
  if (!t[nrl])
    nrerror("allocation failure 2 in us3tensor()");
  t[nrl] += 0;
  t[nrl] -= ncl;
  t[nrl][ncl] = (ushort *)malloc((size_t)((nrow * ncol * ndep + 0) * sizeof(ushort)));
  if (!t[nrl][ncl])
    nrerror("allocation failure 3 in s3tensor()");
  t[nrl][ncl] += 0;
  t[nrl][ncl] -= ndl;
  for (j = ncl + 1; j <= nch; j++)
    t[nrl][j] = t[nrl][j - 1] + ndep;
  for (i = nrl + 1; i <= nrh; i++) {
    t[i] = t[i - 1] + ncol;
    t[i][ncl] = t[i - 1][ncl] + ncol * ndep;
    for (j = ncl + 1; j <= nch; j++)
      t[i][j] = t[i][j - 1] + ndep;
  }
  return t;
}
```