user: Demonstrate the C code that generates the assembly output below:

```asm
<writebmp>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %esi,-0x4c(%rbp)
  mov    %edx,-0x50(%rbp)
  mov    %rcx,-0x58(%rbp)
  cmpq   $0x0,-0x58(%rbp)
  je     L43
  mov    -0x48(%rbp),%rax
  lea    D1(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fopen@plt>
  cltq
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L43
  movl   $0x36,-0x2c(%rbp)
  mov    -0x4c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  and    $0xfffffffc,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  imul   -0x50(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x2c(%rbp),%edx
  mov    -0x24(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x20(%rbp)
  movq   $0x0,-0x10(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x42,%edi
  call   <fputc@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x4d,%edi
  call   <fputc@plt>
  mov    -0x20(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int16@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int16@plt>
  mov    -0x2c(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x28,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x4c(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x50(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int16@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x18,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int16@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x24(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x2e23,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x2e23,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <write_le_int32@plt>
  mov    -0x28(%rbp),%eax
  cltq
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  je     L39
  mov    -0x28(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x0,-0x30(%rbp)
  jmp    L41
L29:
  mov    -0x4c(%rbp),%eax
  imul   -0x30(%rbp),%eax
  mov    %eax,%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  mov    %eax,-0x1c(%rbp)
  movl   $0x0,-0x34(%rbp)
  jmp    L32
L5:
  mov    -0x1c(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  add    $0x2,%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    -0x34(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  mov    -0x1c(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  add    $0x1,%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    -0x34(%rbp),%edx
  add    $0x1,%edx
  movslq %edx,%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  mov    -0x1c(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    -0x34(%rbp),%edx
  add    $0x2,%edx
  movslq %edx,%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x3,-0x34(%rbp)
L32:
  mov    -0x34(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L5
  mov    -0x28(%rbp),%eax
  movslq %eax,%rsi
  mov    -0x18(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %rax,%rdi
  call   <fwrite@plt>
  addl   $0x1,-0x30(%rbp)
L41:
  mov    -0x30(%rbp),%eax
  cmp    -0x50(%rbp),%eax
  jl     L29
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L39:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fclose@plt>
L43:
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: label: D1
datatype: string

tool: D1: wb

assistant: ```c
signed int writebmp(char *filename, signed int xs, signed int ys, unsigned char *img) {
  if (!(img == ((unsigned char *)((void *)0)))) {
    struct _IO_FILE$link44 *dfile;
    dfile = fopen(filename, "wb");
    if (!(dfile == ((struct _IO_FILE$link44 *)((void *)0)))) {
      signed int i;
      signed int y;
      signed int imgdataoffset = 14 + 40;
      signed int rowsz = xs * 3 + 3 & -4;
      signed int imgdatasize = rowsz * ys;
      signed int filesize = imgdataoffset + imgdatasize;
      unsigned char *rowbuf = (unsigned char *)((void *)0);
      fputc(66, dfile);
      fputc(77, dfile);
      write_le_int32(dfile, filesize);
      write_le_int16(dfile, 0);
      write_le_int16(dfile, 0);
      write_le_int32(dfile, imgdataoffset);
      write_le_int32(dfile, 40);
      write_le_int32(dfile, xs);
      write_le_int32(dfile, ys);
      write_le_int16(dfile, 1);
      write_le_int16(dfile, 24);
      write_le_int32(dfile, 0);
      write_le_int32(dfile, imgdatasize);
      write_le_int32(dfile, 11811);
      write_le_int32(dfile, 11811);
      write_le_int32(dfile, 0);
      write_le_int32(dfile, 0);
      void *return_value_malloc$1;
      return_value_malloc$1 = malloc((unsigned long int)rowsz);
      rowbuf = (unsigned char *)return_value_malloc$1;
      if (!(rowbuf == ((unsigned char *)((void *)0)))) {
        memset((void *)rowbuf, 0, (unsigned long int)rowsz);
        y = 0;
        while (!(y >= ys)) {
          signed int addr = xs * 3 * y;
          i = 0;
          while (!(i >= rowsz)) {
            rowbuf[(signed long int)i] = img[(signed long int)(addr + i + 2)];
            rowbuf[(signed long int)(i + 1)] = img[(signed long int)(addr + i + 1)];
            rowbuf[(signed long int)(i + 2)] = img[(signed long int)(addr + i)];
            i = i + 3;
          }
          fwrite((const void *)rowbuf, (unsigned long int)rowsz, (unsigned long int)1, dfile);
          y = y + 1;
        }
        free((void *)rowbuf);
      }
      fclose(dfile);
    }
  }
  return 0;
}
```