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

```asm
<write_texture>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  lea    D23(%rip),%rsi
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L112
L28:
  lea    0x14(%rsp),%rcx
  lea    0x10(%rsp),%rdx
  mov    %r12,%rdi
  lea    0xc(%rsp),%rsi
  call   <jpeg_load@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L22
L72:
  mov    0x10(%rsp),%eax
  imul   0xc(%rsp),%eax
  lea    (%rax,%rax,2),%edi
  shl    $0x2,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L94
L12:
  mov    0xc(%rsp),%r8d
  mov    0x10(%rsp),%r9d
  mov    %r8d,%edi
  imul   %r9d,%edi
  test   %edi,%edi
  jle    L83
  lea    (%rdi,%rdi,2),%rdi
  mov    0x14(%rsp),%edx
  mov    %r12,%rax
  lea    0x4(%r12),%rsi
  movss  D24(%rip),%xmm0
  lea    0x8(%r12),%rcx
  lea    (%r12,%rdi,4),%rdi
  jmp    L80
  cs nopw 0x0(%rax,%rax,1)
L17:
  cmp    $0x1,%edx
  je     L116
L159:
  add    $0xc,%rax
  add    $0xc,%rsi
  add    $0xc,%rcx
  cmp    %rax,%rdi
  je     L83
L80:
  cmp    $0x2,%edx
  je     L56
  cmp    $0x3,%edx
  jne    L17
  movzbl (%rbx),%r10d
  pxor   %xmm1,%xmm1
  add    $0x3,%rbx
  cvtsi2ss %r10d,%xmm1
  mulss  %xmm0,%xmm1
  movss  %xmm1,(%rax)
  movzbl -0x2(%rbx),%r10d
  pxor   %xmm1,%xmm1
  cvtsi2ss %r10d,%xmm1
  mulss  %xmm0,%xmm1
  movss  %xmm1,(%rsi)
  movzbl -0x1(%rbx),%r10d
  pxor   %xmm1,%xmm1
  cvtsi2ss %r10d,%xmm1
  mulss  %xmm0,%xmm1
  movss  %xmm1,(%rcx)
  jmp    L159
  nop
L56:
  movzbl (%rbx),%r10d
  pxor   %xmm1,%xmm1
  add    $0x2,%rbx
  cvtsi2ss %r10d,%xmm1
  mulss  %xmm0,%xmm1
  movss  %xmm1,(%rax)
  movzbl -0x1(%rbx),%r10d
  pxor   %xmm1,%xmm1
  cvtsi2ss %r10d,%xmm1
  mulss  %xmm0,%xmm1
  movss  %xmm1,(%rsi)
  movss  %xmm1,(%rcx)
  jmp    L159
  nopl   0x0(%rax,%rax,1)
L116:
  movzbl (%rbx),%r10d
  pxor   %xmm1,%xmm1
  add    $0x1,%rbx
  cvtsi2ss %r10d,%xmm1
  mulss  %xmm0,%xmm1
  movss  %xmm1,(%rax)
  movss  %xmm1,(%rsi)
  movss  %xmm1,(%rcx)
  jmp    L159
  cs nopw 0x0(%rax,%rax,1)
L83:
  xor    %ecx,%ecx
  mov    %r9d,%edx
  mov    %r8d,%esi
  mov    %rbp,%rdi
  call   <RGBE_WriteHeader@plt>
  mov    0x10(%rsp),%ecx
  mov    0xc(%rsp),%edx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <RGBE_WritePixels_RLE@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L38
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L94:
  lea    D11(%rip),%rdi
  call   <printf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L12
  nopl   0x0(%rax,%rax,1)
L22:
  lea    D33(%rip),%rdi
  call   <printf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L72
  nopl   0x0(%rax,%rax,1)
L112:
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L28
L38:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D23
data_type: string
name: unpack_data
arguments: tag: D24
data_type: byte[4]
name: unpack_data
arguments: tag: D11
data_type: string
name: unpack_data
arguments: tag: D33
data_type: string

tool: D23: wb

tool: {"D24": [0x00,0x00,0x80,0x3b]}

tool: D11: muda muda muda!


tool: D33: can't load jpeg file.


assistant: ```c
void write_texture(const char *filename, const char *jpegfile) {
  FILE *fp;
  unsigned char *img;
  int width;
  int height;
  int compos;
  int i;
  int ival;
  int idx;
  float *data;
  float fval;
  fp = fopen(filename, "wb");
  if (!fp)
    exit(-1);
  img = jpeg_load(jpegfile, &width, &height, &compos);
  if (img == NULL) {
    printf("can't load jpeg file.\n");
    exit(-1);
  }
  data = (float *)malloc(sizeof(float) * width * height * 3);
  if (!data) {
    printf("muda muda muda!\n");
    exit(-1);
  }
  for (i = 0; i < width * height; i++) {
    idx = 3 * i;
    switch (compos) {
    case 1:
      data[idx + 0] = (float)(*img++) / (256.0f);
      data[idx + 1] = data[idx + 0];
      data[idx + 2] = data[idx + 1];
      break;
    case 2:
      data[idx + 0] = (float)(*img++) / (256.0f);
      data[idx + 1] = (float)(*img++) / (256.0f);
      data[idx + 2] = data[idx + 1];
      break;
    case 3:
      data[idx + 0] = (float)(*img++) / (256.0f);
      data[idx + 1] = (float)(*img++) / (256.0f);
      data[idx + 2] = (float)(*img++) / (256.0f);
      break;
    }
  }
  RGBE_WriteHeader(fp, width, height, NULL);
  RGBE_WritePixels_RLE(fp, data, width, height);
}
```