user: Translate the below assembly code into C programming language:

```asm
<mat_prod>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %esi,0x14(%rsp)
  mov    %edx,%ebp
  mov    %rcx,0x28(%rsp)
  mov    %r9d,%ebx
  cmp    %r8d,%edx
  jne    L94
L57:
  cmpq   $0x0,0x18(%rsp)
  je     L68
  cmpq   $0x0,0x28(%rsp)
  je     L68
L74:
  mov    0x14(%rsp),%edi
  imul   %ebx,%edi
  shl    $0x2,%edi
  call   <malloc@plt>
  mov    %rax,0x20(%rsp)
  test   %rax,%rax
  je     L52
L128:
  cmpl   $0x0,0x14(%rsp)
  jle    L87
  movslq %ebx,%r10
  shl    $0x2,%r10
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0xc(%rsp)
  mov    $0x0,%r15d
  lea    -0x1(%rbp),%eax
  mov    %rax,0x30(%rsp)
  mov    0x18(%rsp),%rax
  add    $0x4,%rax
  mov    %rax,0x38(%rsp)
  jmp    L54
L94:
  lea    D10(%rip),%rdi
  call   <die@plt>
  jmp    L57
L68:
  lea    D12(%rip),%rdi
  call   <die@plt>
  jmp    L74
L52:
  lea    D21(%rip),%rdi
  call   <die@plt>
  jmp    L128
L109:
  movslq 0xc(%rsp),%rax
  mov    0x20(%rsp),%rsi
  lea    (%rsi,%rax,4),%r11
  mov    0x28(%rsp),%r13
  movslq 0x10(%rsp),%rax
  mov    0x18(%rsp),%rsi
  lea    (%rsi,%rax,4),%r14
  add    0x30(%rsp),%rax
  mov    0x38(%rsp),%rdi
  lea    (%rdi,%rax,4),%r9
  mov    $0x0,%r12d
L19:
  mov    %r11,%rdi
  movl   $0x0,(%r11)
  test   %ebp,%ebp
  jle    L83
  mov    %r13,%rsi
  mov    %r14,%rcx
L29:
  mov    (%rcx),%eax
  imul   (%rsi),%eax
  add    (%rdi),%eax
  movslq %eax,%rdx
  imul   $0x3ee4f99d,%rdx,%rdx
  sar    $0x27,%rdx
  mov    %eax,%r8d
  sar    $0x1f,%r8d
  sub    %r8d,%edx
  imul   $0x209,%edx,%edx
  sub    %edx,%eax
  mov    %eax,(%rdi)
  add    $0x4,%rcx
  add    %r10,%rsi
  cmp    %r9,%rcx
  jne    L29
L83:
  add    $0x1,%r12d
  add    $0x4,%r11
  add    $0x4,%r13
  cmp    %r12d,%ebx
  jne    L19
L119:
  add    $0x1,%r15d
  add    %ebx,0xc(%rsp)
  add    %ebp,0x10(%rsp)
  cmp    %r15d,0x14(%rsp)
  je     L87
L54:
  test   %ebx,%ebx
  jg     L109
  jmp    L119
L87:
  mov    0x20(%rsp),%rax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: read_data
arguments: data_label: D10
type_infered: string
name: read_data
arguments: data_label: D12
type_infered: string
name: read_data
arguments: data_label: D21
type_infered: string

tool: D10: tried to multiply matrices with mismatched dimensions.

tool: D12: tried to matrix-multiply a null pointer.

tool: D21: malloc fail.

assistant: ```c
int *mat_prod(int x[], int xrows, int xcols, int y[], int yrows, int ycols) {
  int i;
  int j;
  int k;
  int *z;
  if (xcols != yrows) {
    die("tried to multiply matrices with mismatched dimensions.");
  }
  if ((x == NULL) || (y == NULL)) {
    die("tried to matrix-multiply a null pointer.");
  }
  z = malloc(xrows * ycols * sizeof(int));
  if (z == NULL) {
    die("malloc fail.");
  }
  for (i = 0; i < xrows; i++) {
    for (j = 0; j < ycols; j++) {
      z[i * ycols + j] = 0;
      for (k = 0; k < xcols; k++) {
        z[i * ycols + j] += x[i * xcols + k] * y[k * ycols + j];
        z[i * ycols + j] %= 521;
      }
    }
  }
  return z;
}
```