user: What would the C source look like for the assembly code provided here:

```asm
<bmp_create_bw>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r15
  mov    %rdi,0x8(%rsp)
  mov    %esi,%ebx
  mov    %edx,%r14d
  mov    %rcx,%rbp
  mov    %esi,%eax
  imul   %edx,%eax
  lea    0x36(%rax,%rax,2),%r13d
  mov    %r13d,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  mov    %rax,%rcx
  mov    %r14d,%edx
  mov    %ebx,%esi
  mov    %r15,%rdi
  call   <create_header@plt>
  sub    $0x1,%r14d
  js     L59
  mov    %eax,%r9d
  mov    %r14d,%r10d
  mov    %ebx,%eax
  sar    $0x1f,%eax
  shr    $0x1e,%eax
  lea    (%rbx,%rax,1),%edx
  and    $0x3,%edx
  sub    %edx,%eax
  lea    0x4(%rax),%r15d
  test   $0x3,%bl
  mov    $0x0,%eax
  cmove  %eax,%r15d
  lea    0x7(%rbx),%r14d
  test   %ebx,%ebx
  cmovns %ebx,%r14d
  sar    $0x3,%r14d
  mov    %r10d,%r11d
  imul   %r14d,%r11d
  lea    (%rbx,%rbx,2),%eax
  mov    %eax,0x4(%rsp)
  mov    $0x1,%r8d
  jmp    L14
L36:
  movl   $0xff,(%rsi)
  movl   $0xff,0x4(%rsi)
  movl   $0xff,0x8(%rsi)
L5:
  add    $0x1,%edx
  add    $0xc,%rsi
  cmp    %edx,%ebx
  je     L30
L29:
  lea    0x7(%rdx),%eax
  test   %edx,%edx
  cmovns %edx,%eax
  sar    $0x3,%eax
  add    %edi,%eax
  cltq
  mov    %edx,%ecx
  and    $0x7,%ecx
  mov    %r8d,%r9d
  shl    %cl,%r9d
  mov    %r9d,%ecx
  and    0x0(%rbp,%rax,4),%ecx
  je     L36
  movl   $0x0,(%rsi)
  movl   $0x0,0x4(%rsi)
  movl   $0x0,0x8(%rsi)
  jmp    L5
L30:
  mov    (%rsp),%r9d
  add    0x4(%rsp),%r9d
L61:
  add    %r15d,%r9d
  sub    $0x1,%r10d
  sub    %r14d,%r11d
  cmp    $0xffffffff,%r10d
  je     L59
L14:
  test   %ebx,%ebx
  jle    L61
  mov    %r11d,%edi
  movslq %r9d,%rax
  lea    (%r12,%rax,4),%rsi
  mov    $0x0,%edx
  mov    %r9d,(%rsp)
  jmp    L29
L59:
  lea    D3(%rip),%rsi
  mov    0x8(%rsp),%rdi
  call   <fopen@plt>
  mov    %rax,%rbx
  mov    %rax,%rcx
  mov    %r13d,%edx
  mov    $0x1,%esi
  mov    %r12,%rdi
  call   <fwrite@plt>
  mov    %rbx,%rdi
  call   <fclose@plt>
  mov    %r12,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D3
type_guessed: string

tool: D3: w

assistant: ```c
int bmp_create_bw(char *filename, uint32_t w, uint32_t h, uint8_t *data) {
  FILE *f;
  int index = 0;
  uint32_t filesize = 14 + 40 + w * h * 3;
  uint8_t *filedata = (uint8_t *)malloc(filesize);
  index += create_header(filename, w, h, filedata);
  for (int i = h - 1; i >= 0; i--) {
    for (int j = 0; j < w; j++) {
      uint8_t byte = data[i * (w / 8) + (j / 8)];
      uint8_t mask = 1 << (j % 8);
      if ((byte & mask) != 0) {
        filedata[index + 0] = 0x00;
        filedata[index + 1] = 0x00;
        filedata[index + 2] = 0x00;
      } else {
        filedata[index + 0] = 0xFF;
        filedata[index + 1] = 0xFF;
        filedata[index + 2] = 0xFF;
      }
      index += 3;
    }
    index += (w % 4 != 0) ? 4 - (w % 4) : 0;
  }
  f = fopen(filename, "w");
  fwrite(filedata, 1, filesize, f);
  fclose(f);
  free(filedata);
  return 0;
}
```