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

```asm
<i3tensor>:
  endbr64
  push   %r15
  mov    %rsi,%rax
  sub    %r8,%r9
  mov    %rcx,%r15
  push   %r14
  sub    %rdi,%rax
  push   %r13
  mov    %rdi,%r13
  lea    0x10(,%rax,8),%edi
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  sub    %rdx,%r12
  mov    %rdx,%rbp
  push   %rbx
  lea    0x1(%r9),%rbx
  add    $0x1,%r12
  sub    $0x38,%rsp
  mov    %rsi,0x8(%rsp)
  lea    0x1(%rax),%rsi
  mov    %r8,0x18(%rsp)
  mov    %rsi,0x10(%rsp)
  call   <malloc@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L18
L93:
  mov    0x10(%rsp),%r10
  mov    $0x1,%eax
  sub    %r13,%rax
  imul   %r12,%r10
  lea    (%r14,%rax,8),%rax
  mov    %rax,(%rsp)
  lea    0x8(,%r10,8),%edi
  mov    %r10,0x10(%rsp)
  call   <malloc@plt>
  mov    0x10(%rsp),%r10
  test   %rax,%rax
  mov    %rax,0x8(%r14)
  mov    %rax,%rcx
  je     L38
L101:
  lea    0x0(,%rbp,8),%r8
  mov    %rcx,%rax
  mov    %rcx,0x28(%rsp)
  sub    %r8,%rax
  imul   %rbx,%r10
  mov    %r8,0x20(%rsp)
  lea    0x8(%rax),%r9
  mov    %r9,0x8(%r14)
  lea    0x4(,%r10,4),%edi
  mov    %r9,0x10(%rsp)
  call   <malloc@plt>
  mov    0x28(%rsp),%rcx
  mov    0x10(%rsp),%r9
  test   %rax,%rax
  mov    0x20(%rsp),%r8
  mov    %rax,0x8(%rcx)
  je     L71
L114:
  lea    (%r9,%r8,1),%rdi
  mov    $0x1,%eax
  sub    0x18(%rsp),%rax
  add    $0x1,%rbp
  mov    (%rdi),%rcx
  lea    (%rcx,%rax,4),%rcx
  mov    %rcx,(%rdi)
  cmp    %rbp,%r15
  jl     L96
  lea    0x0(,%rbx,4),%r10
  lea    0x8(%r9,%r8,1),%rax
  lea    0x8(%r9,%r15,8),%rdi
  nopw   0x0(%rax,%rax,1)
L64:
  add    %r10,%rcx
  add    $0x8,%rax
  mov    %rcx,-0x8(%rax)
  cmp    %rdi,%rax
  jne    L64
L96:
  cmp    %r13,0x8(%rsp)
  jle    L62
  lea    0x0(,%r12,8),%r11
  mov    (%rsp),%rax
  mov    0x8(%rsp),%rsi
  lea    0x8(%r14),%rdi
  imul   %rbx,%r12
  lea    0x0(,%rbp,8),%r14
  shl    $0x2,%rbx
  lea    (%rax,%rsi,8),%r10
  lea    0x0(,%r12,4),%r9
  lea    0x0(,%r15,8),%r12
  lea    0x8(%r12),%r13
  nopl   0x0(%rax)
L28:
  mov    (%rdi),%rax
  mov    (%rax,%r8,1),%rdx
  lea    (%rax,%r11,1),%rcx
  mov    %rcx,0x8(%rdi)
  add    %r9,%rdx
  mov    %rdx,(%rcx,%r8,1)
  cmp    %rbp,%r15
  jl     L34
  mov    0x8(%rax,%r12,1),%rdx
  lea    (%rcx,%r14,1),%rax
  add    %r13,%rcx
  nop
L27:
  add    %rbx,%rdx
  add    $0x8,%rax
  mov    %rdx,-0x8(%rax)
  cmp    %rax,%rcx
  jne    L27
L34:
  add    $0x8,%rdi
  cmp    %rdi,%r10
  jne    L28
L62:
  mov    (%rsp),%rax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L18:
  lea    D0(%rip),%rdi
  xor    %eax,%eax
  call   <nrerror@plt>
  jmp    L93
L71:
  lea    D17(%rip),%rdi
  mov    %r8,0x10(%rsp)
  call   <nrerror@plt>
  mov    0x8(%r14),%r9
  mov    0x10(%rsp),%r8
  jmp    L114
L38:
  lea    D11(%rip),%rdi
  xor    %eax,%eax
  call   <nrerror@plt>
  mov    0x8(%r14),%rcx
  mov    0x10(%rsp),%r10
  jmp    L101
```

tool_calls: name: parse_data
arguments: data_label: D0
type_infered: string
name: parse_data
arguments: data_label: D17
type_infered: string
name: parse_data
arguments: data_label: D11
type_infered: string

tool: D0: allocation failure 1 in i3tensor()

tool: D17: allocation failure 3 in i3tensor()

tool: D11: allocation failure 2 in i3tensor()

assistant: ```c
int ***i3tensor(nrl, nrh, ncl, nch, ndl, ndh)
long nch, ncl, ndh, ndl, nrh, nrl;
{
  long i, j, nrow = nrh - nrl + 1, ncol = nch - ncl + 1, ndep = ndh - ndl + 1;
  int ***t;
  t = (int ***)malloc((unsigned int)((nrow + 1) * sizeof(int **)));
  if (!t)
    nrerror("allocation failure 1 in i3tensor()");
  t += 1;
  t -= nrl;
  t[nrl] = (int **)malloc((unsigned int)((nrow * ncol + 1) * sizeof(int *)));
  if (!t[nrl])
    nrerror("allocation failure 2 in i3tensor()");
  t[nrl] += 1;
  t[nrl] -= ncl;
  t[nrl][ncl] = (int *)malloc((unsigned int)((nrow * ncol * ndep + 1) * sizeof(int)));
  if (!t[nrl][ncl])
    nrerror("allocation failure 3 in i3tensor()");
  t[nrl][ncl] += 1;
  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;
}
```