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

```asm
<write_u32sparsetri>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %edi,0x24(%rsp)
  mov    %esi,0x20(%rsp)
  mov    %edx,0x1c(%rsp)
  mov    %rcx,%r14
  mov    %r8,%rdi
  mov    %r8,0x28(%rsp)
  mov    %r9,%r15
  lea    D43(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,0x8(%rsp)
  test   %rax,%rax
  je     L85
L74:
  mov    0x24(%rsp),%r13d
  mov    %r13d,%edx
  lea    D16(%rip),%rbp
  mov    %rbp,%rsi
  mov    0x8(%rsp),%rbx
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    0x20(%rsp),%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    0x1c(%rsp),%r12d
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %r15,%r8
  mov    %r14,%rcx
  mov    %r12d,%edx
  mov    0x20(%rsp),%esi
  mov    %r13d,%edi
  call   <countnnz32tri@plt>
  mov    %eax,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  test   %r13d,%r13d
  jle    L77
  movl   $0x0,0x18(%rsp)
  jmp    L120
L85:
  mov    0x28(%rsp),%rsi
  lea    D9(%rip),%rdi
  call   <yap_sysquit@plt>
  jmp    L74
L114:
  add    $0x1,%rbx
  cmp    %rbx,%rbp
  je     L3
L80:
  mov    (%r14),%rax
  mov    (%rax,%r12,1),%rax
  mov    (%rax,%rbx,8),%r9
  cmp    %r15,%r9
  jle    L114
  mov    %ebx,%r8d
  mov    0x4(%rsp),%ecx
  mov    0x18(%rsp),%edx
  lea    D35(%rip),%rsi
  mov    0x8(%rsp),%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  jmp    L114
L3:
  add    $0x1,%r13
  cmp    0x10(%rsp),%r13
  je     L71
L140:
  mov    %r13d,0x4(%rsp)
  lea    0x0(,%r13,8),%r12
  mov    0x1c(%rsp),%eax
  mov    %eax,%ebp
  mov    $0x0,%ebx
  test   %eax,%eax
  jg     L80
  jmp    L3
L71:
  addl   $0x1,0x18(%rsp)
  mov    0x18(%rsp),%eax
  add    $0x8,%r14
  cmp    %eax,0x24(%rsp)
  je     L77
L120:
  mov    0x20(%rsp),%eax
  test   %eax,%eax
  jle    L71
  mov    %eax,%eax
  mov    %rax,0x10(%rsp)
  mov    $0x0,%r13d
  jmp    L140
L77:
  mov    0x8(%rsp),%rdi
  call   <ferror@plt>
  test   %rax,%rax
  jne    L50
L87:
  mov    0x8(%rsp),%rdi
  call   <fclose@plt>
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L50:
  mov    0x28(%rsp),%rsi
  lea    D34(%rip),%rdi
  call   <yap_sysquit@plt>
  jmp    L87
```

tool_calls: name: read_data
arguments: label: D43
type_guessed: string
name: read_data
arguments: label: D16
type_guessed: string
name: read_data
arguments: label: D9
type_guessed: string
name: read_data
arguments: label: D35
type_guessed: string
name: read_data
arguments: label: D34
type_guessed: string

tool: D43: w

tool: D16: %d


tool: D9: Cannot open file '%s' for write


tool: D35: %d %d %d %u


tool: D34: Error on writing file '%s' 

assistant: ```c
void write_u32sparsetri(int ns, int nr, int nc, uint32_t ***x, char *fname, uint32_t cutoff) {
  FILE *fp = fopen(fname, "w");
  int i, j, k;
  if (!fp)
    yap_sysquit("Cannot open file '%s' for write\n", fname);
  fprintf(fp, "%d\n", ns);
  fprintf(fp, "%d\n", nr);
  fprintf(fp, "%d\n", nc);
  fprintf(fp, "%d\n", countnnz32tri(ns, nr, nc, x, cutoff));
  for (k = 0; k < ns; k++)
    for (i = 0; i < nr; i++)
      for (j = 0; j < nc; j++)
        if (x[k][i][j] > cutoff)
          fprintf(fp, "%d %d %d %u\n", k, i, j, (unsigned)x[k][i][j]);
  if (ferror(fp))
    yap_sysquit("Error on writing file '%s' ", fname);
  fclose(fp);
}
```