user: Converte this assembly snippet into its equivalent C code:

```asm
<i3tensor>:
  endbr64
  push   %r15
  mov    %rsi,%rax
  sub    %r8,%r9
  push   %r14
  sub    %rdi,%rax
  mov    %rcx,%r14
  push   %r13
  mov    %rdi,%r13
  lea    0x10(,%rax,8),%edi
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %rcx,%rbp
  push   %rbx
  sub    %rdx,%rbp
  lea    0x1(%r9),%rbx
  add    $0x1,%rbp
  sub    $0x38,%rsp
  mov    %rsi,0x8(%rsp)
  lea    0x1(%rax),%rsi
  mov    %r8,0x18(%rsp)
  mov    %rsi,0x10(%rsp)
  call   <malloc@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L1
L19:
  mov    0x10(%rsp),%r10
  mov    $0x1,%eax
  sub    %r13,%rax
  imul   %rbp,%r10
  lea    (%r15,%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(%r15)
  mov    %rax,%r9
  je     L37
L115:
  imul   %rbx,%r10
  lea    0x0(,%r12,8),%r8
  mov    %r9,%rax
  mov    %r9,0x28(%rsp)
  sub    %r8,%rax
  mov    %r8,0x20(%rsp)
  lea    0x8(%rax),%rcx
  lea    0x4(,%r10,4),%edi
  mov    %rcx,0x8(%r15)
  mov    %rcx,0x10(%rsp)
  call   <malloc@plt>
  mov    0x28(%rsp),%r9
  mov    0x10(%rsp),%rcx
  test   %rax,%rax
  mov    0x20(%rsp),%r8
  mov    %rax,0x8(%r9)
  je     L22
L10:
  lea    (%rcx,%r8,1),%rax
  mov    $0x1,%edi
  add    $0x1,%r12
  sub    0x18(%rsp),%rdi
  shl    $0x2,%rdi
  add    %rdi,(%rax)
  cmp    %r12,%r14
  jl     L66
  lea    0x0(,%rbx,4),%r9
  lea    (%rcx,%r14,8),%rdi
  nopl   0x0(%rax)
L52:
  mov    (%rax),%rcx
  add    $0x8,%rax
  add    %r9,%rcx
  mov    %rcx,(%rax)
  cmp    %rax,%rdi
  jne    L52
L66:
  cmp    %r13,0x8(%rsp)
  jle    L85
  lea    0x0(,%rbp,8),%rdi
  mov    (%rsp),%rax
  lea    0x8(%r15),%r10
  mov    0x8(%rsp),%rsi
  imul   %rbx,%rbp
  lea    0x0(,%r14,8),%r11
  shl    $0x2,%rbx
  lea    0x0(,%rbp,4),%r9
  lea    (%rax,%rsi,8),%rbp
  nopw   0x0(%rax,%rax,1)
L109:
  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,%r14
  jl     L67
  nopl   0x0(%rax)
L87:
  mov    (%rax),%rdx
  add    $0x8,%rax
  add    %rbx,%rdx
  mov    %rdx,(%rax)
  cmp    %rcx,%rax
  jne    L87
L67:
  add    $0x8,%r10
  cmp    %r10,%rbp
  jne    L109
L85:
  mov    (%rsp),%rax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L1:
  lea    D0(%rip),%rdi
  xor    %eax,%eax
  call   <nrerror@plt>
  jmp    L19
L22:
  lea    D25(%rip),%rdi
  mov    %r8,0x10(%rsp)
  call   <nrerror@plt>
  mov    0x8(%r15),%rcx
  mov    0x10(%rsp),%r8
  jmp    L10
L37:
  lea    D19(%rip),%rdi
  xor    %eax,%eax
  call   <nrerror@plt>
  mov    0x8(%r15),%r9
  mov    0x10(%rsp),%r10
  jmp    L115
```

tool_calls: name: unpack_data
arguments: tag: D0
datatype: string
name: unpack_data
arguments: tag: D25
datatype: string
name: unpack_data
arguments: tag: D19
datatype: string

tool: D0: allocation failure 1 in i3tensor()

tool: D25: allocation failure 3 in i3tensor()

tool: D19: 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;
}
```