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

```asm
<image_rgb48be_from_rgb96f>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,%ebx
  mov    %esi,%ebp
  mov    %rdx,%r12
  mov    %edi,%eax
  imul   %esi,%eax
  lea    (%rax,%rax,2),%edi
  add    %edi,%edi
  movslq %edi,%rdi
  call   <malloc@plt>
  mov    %rax,%r14
  test   %ebp,%ebp
  jle    L22
  lea    (%rbx,%rbx,2),%eax
  add    %eax,%eax
  mov    %eax,0x14(%rsp)
  mov    $0x0,%r13d
  mov    $0x0,%r10d
  mov    $0x0,%r11d
  lea    -0x1(%rbx),%eax
  mov    %rax,0x18(%rsp)
  lea    0x6(%r14),%r15
  movss  D9(%rip),%xmm0
  mov    %ebx,0x10(%rsp)
  jmp    L37
L28:
  lea    (%r10,%r10,2),%eax
  cltq
  lea    (%r12,%rax,4),%rsi
  movslq %r13d,%rax
  add    %r14,%rax
  movslq %r10d,%rdx
  add    0x18(%rsp),%rdx
  lea    (%rdx,%rdx,2),%rdx
  lea    (%r15,%rdx,2),%r9
L43:
  movaps %xmm0,%xmm1
  mulss  0x4(%rsi),%xmm1
  cvttss2si %xmm1,%ecx
  movaps %xmm0,%xmm1
  mulss  0x8(%rsi),%xmm1
  cvttss2si %xmm1,%edi
  mov    %edi,0xc(%rsp)
  movaps %xmm0,%xmm1
  mulss  (%rsi),%xmm1
  cvttss2si %xmm1,%ebx
  test   %ebx,%ebx
  mov    $0x0,%r8d
  cmovs  %r8d,%ebx
  mov    $0xffff,%r8d
  cmp    %r8d,%ebx
  cmovg  %r8d,%ebx
  movzbl %bh,%edx
  mov    %dl,(%rax)
  mov    %bl,0x1(%rax)
  test   %ecx,%ecx
  mov    $0x0,%edi
  cmovs  %edi,%ecx
  mov    $0xffff,%edi
  cmp    %edi,%ecx
  cmovg  %edi,%ecx
  movzbl %ch,%ebx
  mov    %bl,0x2(%rax)
  mov    %cl,0x3(%rax)
  mov    0xc(%rsp),%edi
  test   %edi,%edi
  mov    $0x0,%ecx
  mov    %edi,%edx
  cmovs  %ecx,%edx
  mov    $0xffff,%ecx
  cmp    %ecx,%edx
  cmovg  %ecx,%edx
  movzbl %dh,%ebx
  mov    %bl,0x4(%rax)
  mov    %dl,0x5(%rax)
  add    $0xc,%rsi
  add    $0x6,%rax
  cmp    %r9,%rax
  jne    L43
L31:
  add    $0x1,%r11d
  add    0x10(%rsp),%r10d
  add    0x14(%rsp),%r13d
  cmp    %r11d,%ebp
  je     L22
L37:
  cmpl   $0x0,0x10(%rsp)
  jg     L28
  jmp    L31
L22:
  mov    %r14,%rax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D9
datatype: byte[4]

tool: {"D9": [0x00,0xff,0x7f,0x47]}

assistant: ```c
unsigned char *image_rgb48be_from_rgb96f(signed int xres, signed int yres, float *fimg) {
  signed int x;
  signed int y;
  signed int R;
  signed int G;
  signed int B;
  unsigned char *img;
  void *return_value_malloc$1;
  return_value_malloc$1 = malloc((unsigned long int)(xres * yres * 6));
  img = (unsigned char *)return_value_malloc$1;
  y = 0;
  while (!(y >= yres)) {
    x = 0;
    while (!(x >= xres)) {
      signed int faddr = (xres * y + x) * 3;
      signed int iaddr = faddr * 2;
      R = (signed int)(fimg[(signed long int)faddr] * 65535.000000f);
      G = (signed int)(fimg[(signed long int)(faddr + 1)] * 65535.000000f);
      B = (signed int)(fimg[(signed long int)(faddr + 2)] * 65535.000000f);
      if (R > 65535)
        R = 65535;
      if (R < 0)
        R = 0;
      img[(signed long int)iaddr] = (unsigned char)(R >> 8 & 255);
      img[(signed long int)(iaddr + 1)] = (unsigned char)(R & 255);
      if (G > 65535)
        G = 65535;
      if (G < 0)
        G = 0;
      img[(signed long int)(iaddr + 2)] = (unsigned char)(G >> 8 & 255);
      img[(signed long int)(iaddr + 3)] = (unsigned char)(G & 255);
      if (B > 65535)
        B = 65535;
      if (B < 0)
        B = 0;
      img[(signed long int)(iaddr + 4)] = (unsigned char)(B >> 8 & 255);
      img[(signed long int)(iaddr + 5)] = (unsigned char)(B & 255);
      x = x + 1;
    }
    y = y + 1;
  }
  return img;
}
```