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

```asm
<writeIntArrtoFile>:
  endbr64
  push   %r15
  push   %r14
  mov    %rcx,%r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %rsi,%r12
  lea    D32(%rip),%rsi
  push   %rbp
  push   %rbx
  mov    %r8d,%ebx
  sub    $0x38,%rsp
  mov    %r9d,(%rsp)
  mov    0x70(%rsp),%rbp
  mov    %rdi,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D10(%rip),%rdi
  mov    %rax,%r15
  mov    %rax,%rcx
  call   <fwrite@plt>
  mov    %r15,%rcx
  mov    $0x11,%edx
  mov    $0x1,%esi
  lea    D0(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbp,%rdx
  mov    %r15,%rdi
  xor    %eax,%eax
  lea    D42(%rip),%rsi
  call   <fprintf@plt>
  mov    (%rsp),%ecx
  mov    %ebx,%edx
  mov    %r15,%rdi
  lea    D23(%rip),%rsi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    (%rsp),%r8d
  test   %r8d,%r8d
  jle    L22
  test   %ebx,%ebx
  jle    L22
  movq   $0x0,0x8(%rsp)
  mov    %rbx,%rbp
  movslq %r8d,%rax
  shl    $0x4,%rbp
  shl    $0x2,%rax
  sub    %rbx,%rbp
  mov    %rax,0x10(%rsp)
  lea    0x27(%rsp),%rbx
  shl    $0x5,%rbp
  mov    %rbp,(%rsp)
  nopl   0x0(%rax,%rax,1)
L18:
  mov    0x8(%rsp),%rbp
  nopl   (%rax)
L25:
  mov    (%r12,%rbp,1),%eax
  mov    %r15,%rcx
  mov    $0x1,%edx
  mov    %rbx,%rdi
  mov    $0x1,%esi
  mov    %al,0x27(%rsp)
  call   <fwrite@plt>
  mov    0x0(%r13,%rbp,1),%eax
  mov    %r15,%rcx
  mov    %rbx,%rdi
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %al,0x27(%rsp)
  call   <fwrite@plt>
  mov    (%r14,%rbp,1),%eax
  mov    %r15,%rcx
  mov    %rbx,%rdi
  mov    $0x1,%edx
  mov    $0x1,%esi
  add    $0x1e0,%rbp
  mov    %al,0x27(%rsp)
  call   <fwrite@plt>
  cmp    (%rsp),%rbp
  jne    L25
  addq   $0x4,0x8(%rsp)
  mov    0x8(%rsp),%rax
  addq   $0x4,(%rsp)
  cmp    0x10(%rsp),%rax
  jne    L18
L22:
  mov    %r15,%rdi
  call   <fclose@plt>
  mov    0x18(%rsp),%rsi
  lea    D54(%rip),%rdi
  call   <printf@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L0
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L0:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D32
datatype: string
name: parse_data
arguments: label: D10
datatype: string
name: parse_data
arguments: label: D0
datatype: string
name: parse_data
arguments: label: D42
datatype: string
name: parse_data
arguments: label: D23
datatype: string
name: parse_data
arguments: label: D54
datatype: string

tool: D32: w

tool: D10: P6 


tool: D0: # Filtered Image


tool: D42: # initial image:  %s


tool: D23: %ld %ld 
255


tool: D54: output image %s successfully written



assistant: ```c
void writeIntArrtoFile(char *outfilename, int C1[80][120], int C2[80][120], int C3[80][120], int nx, int ny, char *in) {
  int i, j;
  unsigned char byte;
  FILE *outimage = fopen(outfilename, "w");
  fprintf(outimage, "P6 \n");
  fprintf(outimage, "# Filtered Image\n");
  fprintf(outimage, "# initial image:  %s\n", in);
  fprintf(outimage, "%ld %ld \n255\n", nx, ny);
  for (j = 0; j < ny; j++)
    for (i = 0; i < nx; i++) {
      byte = (unsigned char)(C1[i][j]);
      fwrite(&byte, sizeof(unsigned char), 1, outimage);
      byte = (unsigned char)(C2[i][j]);
      fwrite(&byte, sizeof(unsigned char), 1, outimage);
      byte = (unsigned char)(C3[i][j]);
      fwrite(&byte, sizeof(unsigned char), 1, outimage);
    }
  fclose(outimage);
  printf("output image %s successfully written\n\n", outfilename);
}
```