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

```asm
<WriteBMP32>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %edx,-0x64(%rbp)
  mov    %ecx,-0x68(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x58(%rbp),%rax
  lea    D4(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x38(%rbp)
  movl   $0x1,-0x44(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jne    L34
  mov    $0xffffffff,%eax
  jmp    L68
L34:
  mov    -0x64(%rbp),%eax
  imul   -0x68(%rbp),%eax
  shl    $0x2,%eax
  mov    %eax,-0x40(%rbp)
  mov    -0x40(%rbp),%eax
  add    $0x36,%eax
  mov    %eax,-0x3c(%rbp)
  lea    -0x30(%rbp),%rax
  mov    $0xe,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movb   $0x42,-0x30(%rbp)
  movb   $0x4d,-0x2f(%rbp)
  lea    -0x30(%rbp),%rax
  add    $0x2,%rax
  mov    -0x44(%rbp),%edx
  mov    -0x3c(%rbp),%edi
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0x6,%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x0,%edi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0xa,%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x36,%edi
  call   <bwrite_endian@plt>
  mov    -0x38(%rbp),%rdx
  lea    -0x30(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0xe,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fwrite@plt>
  lea    -0x30(%rbp),%rax
  mov    $0x28,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x44(%rbp),%edx
  lea    -0x30(%rbp),%rax
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x28,%edi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0x4,%rax
  mov    -0x44(%rbp),%edx
  mov    -0x64(%rbp),%edi
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0x8,%rax
  mov    -0x44(%rbp),%edx
  mov    -0x68(%rbp),%edi
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0xc,%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x2,%esi
  mov    $0x1,%edi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0xe,%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x2,%esi
  mov    $0x20,%edi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0x10,%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x0,%edi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0x14,%rax
  mov    -0x44(%rbp),%edx
  mov    -0x40(%rbp),%edi
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0x18,%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x10000,%edi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0x1c,%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x10000,%edi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0x20,%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x1000000,%edi
  call   <bwrite_endian@plt>
  lea    -0x30(%rbp),%rax
  add    $0x24,%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%ecx
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x0,%edi
  call   <bwrite_endian@plt>
  mov    -0x38(%rbp),%rdx
  lea    -0x30(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x28,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fwrite@plt>
  movb   $0x0,-0x30(%rbp)
  mov    -0x68(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x48(%rbp)
  jmp    L12
L21:
  movl   $0x0,-0x4c(%rbp)
  jmp    L57
L40:
  mov    -0x48(%rbp),%eax
  imul   -0x64(%rbp),%eax
  mov    %eax,%edx
  mov    -0x4c(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rax,%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  lea    0x2(%rax),%rdi
  mov    -0x38(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    -0x48(%rbp),%eax
  imul   -0x64(%rbp),%eax
  mov    %eax,%edx
  mov    -0x4c(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rax,%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  lea    0x1(%rax),%rdi
  mov    -0x38(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    -0x48(%rbp),%eax
  imul   -0x64(%rbp),%eax
  mov    %eax,%edx
  mov    -0x4c(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rax,%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdi
  mov    -0x38(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    -0x38(%rbp),%rdx
  lea    -0x30(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fwrite@plt>
  addl   $0x1,-0x4c(%rbp)
L57:
  mov    -0x4c(%rbp),%eax
  cmp    -0x64(%rbp),%eax
  jl     L40
  subl   $0x1,-0x48(%rbp)
L12:
  cmpl   $0x0,-0x48(%rbp)
  jns    L21
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
L68:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D4
datatype: string

tool: D4: wb

assistant: ```c
int WriteBMP32(const char *fname, unsigned char (*data)[3], int w, int h) {
  FILE *fp = fopen(fname, "wb");
  int Endian = 1;
  unsigned char buffer[40];
  ulong fileSize;
  ulong imageSize;
  int x, y;
  if (!fp)
    return -1;
  imageSize = 4 * w * h;
  fileSize = 14 + 40 + imageSize;
  memset(buffer, 0x00, 14);
  buffer[0] = 66;
  buffer[1] = 77;
  bwrite_endian(fileSize, 4, buffer + 2, Endian);
  bwrite_endian(0, 4, buffer + 6, Endian);
  bwrite_endian(54, 4, buffer + 10, Endian);
  fwrite(buffer, 1, 14, fp);
  memset(buffer, 0x00, 40);
  bwrite_endian(40, 4, buffer + 0, Endian);
  bwrite_endian(w, 4, buffer + 4, Endian);
  bwrite_endian(h, 4, buffer + 8, Endian);
  bwrite_endian(1, 2, buffer + 12, Endian);
  bwrite_endian(32, 2, buffer + 14, Endian);
  bwrite_endian(0, 4, buffer + 16, Endian);
  bwrite_endian(imageSize, 4, buffer + 20, Endian);
  bwrite_endian(0x10000, 4, buffer + 24, Endian);
  bwrite_endian(0x10000, 4, buffer + 28, Endian);
  bwrite_endian(0x1000000, 4, buffer + 32, Endian);
  bwrite_endian(0, 4, buffer + 36, Endian);
  fwrite(buffer, 1, 40, fp);
  buffer[0] = 0;
  for (y = h - 1; y >= 0; --y) {
    for (x = 0; x < w; ++x) {
      fwrite(&data[x + y * w][2], 1, 1, fp);
      fwrite(&data[x + y * w][1], 1, 1, fp);
      fwrite(&data[x + y * w][0], 1, 1, fp);
      fwrite(buffer, 1, 1, fp);
    }
  }
  fclose(fp);
  return 0;
}
```