user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<RGBE_to_RGBdivA>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %edx,-0x40(%rbp)
  mov    %ecx,-0x44(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  movss  D28(%rip),%xmm0
  movss  %xmm0,-0x24(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  je     L63
  cmpl   $0x0,-0x3c(%rbp)
  jle    L63
  cmpl   $0x0,-0x40(%rbp)
  jg     L68
L63:
  mov    $0x0,%eax
  jmp    L90
L68:
  cmpl   $0x0,-0x44(%rbp)
  je     L22
  mov    -0x40(%rbp),%edx
  mov    -0x3c(%rbp),%ecx
  mov    -0x38(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <find_max_RGBE@plt>
  movaps %xmm0,%xmm1
  movss  D69(%rip),%xmm0
  divss  %xmm1,%xmm0
  movss  %xmm0,-0x24(%rbp)
L22:
  mov    -0x3c(%rbp),%eax
  imul   -0x40(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L52
L138:
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    $0xffffff80,%eax
  mov    %eax,%edi
  mov    D37(%rip),%eax
  movd   %eax,%xmm0
  call   <ldexp@plt>
  movss  -0x24(%rbp),%xmm1
  mulss  %xmm1,%xmm0
  movss  %xmm0,-0x20(%rbp)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movss  -0x20(%rbp),%xmm1
  mulss  %xmm1,%xmm0
  movss  %xmm0,-0x1c(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movss  -0x20(%rbp),%xmm1
  mulss  %xmm1,%xmm0
  movss  %xmm0,-0x18(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movss  -0x20(%rbp),%xmm1
  mulss  %xmm1,%xmm0
  movss  %xmm0,-0x14(%rbp)
  movss  -0x1c(%rbp),%xmm0
  comiss -0x18(%rbp),%xmm0
  jbe    L59
  movss  -0x1c(%rbp),%xmm0
  jmp    L69
L59:
  movss  -0x18(%rbp),%xmm0
L69:
  movss  %xmm0,-0x10(%rbp)
  movss  -0x14(%rbp),%xmm0
  comiss -0x10(%rbp),%xmm0
  jbe    L8
  movss  -0x14(%rbp),%xmm0
  jmp    L131
L8:
  movss  -0x10(%rbp),%xmm0
L131:
  movss  %xmm0,-0x10(%rbp)
  pxor   %xmm0,%xmm0
  ucomiss -0x10(%rbp),%xmm0
  jp     L113
  pxor   %xmm0,%xmm0
  ucomiss -0x10(%rbp),%xmm0
  je     L114
L113:
  movss  D69(%rip),%xmm0
  divss  -0x10(%rbp),%xmm0
  cvttss2si %xmm0,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  cvttss2si %xmm0,%eax
  jmp    L117
L114:
  mov    $0x1,%eax
L117:
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    $0x1,%edx
  test   %eax,%eax
  cmovle %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    $0xff,%edx
  cmp    %edx,%eax
  cmovle %eax,%edx
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  mov    %dl,(%rax)
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movaps %xmm0,%xmm1
  mulss  -0x1c(%rbp),%xmm1
  movss  D20(%rip),%xmm0
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    $0xff,%edx
  cmp    %edx,%eax
  cmovg  %edx,%eax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movaps %xmm0,%xmm1
  mulss  -0x18(%rbp),%xmm1
  movss  D20(%rip),%xmm0
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    $0xff,%edx
  cmp    %edx,%eax
  cmovle %eax,%edx
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  mov    %dl,(%rax)
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movaps %xmm0,%xmm1
  mulss  -0x14(%rbp),%xmm1
  movss  D20(%rip),%xmm0
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    $0xff,%edx
  cmp    %edx,%eax
  cmovle %eax,%edx
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  mov    %dl,(%rax)
  addq   $0x4,-0x8(%rbp)
  subl   $0x1,-0x28(%rbp)
L52:
  cmpl   $0x0,-0x28(%rbp)
  jg     L138
  mov    $0x1,%eax
L90:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_tag: D28
type: byte[4]
name: read_data
arguments: data_tag: D69
type: byte[4]
name: read_data
arguments: data_tag: D37
type: byte[4]
name: read_data
arguments: data_tag: D20
type: byte[4]

tool: {"D28": [0x00,0x00,0x80,0x3f]}

tool: {"D69": [0x00,0x00,0x7f,0x43]}

tool: {"D37": [0x81,0x80,0x80,0x3b]}

tool: {"D20": [0x00,0x00,0x00,0x3f]}

assistant: ```c
int RGBE_to_RGBdivA(unsigned char *image, int width, int height, int rescale_to_max) {
  int i, iv;
  unsigned char *img = image;
  float scale = 1.0f;
  if ((!image) || (width < 1) || (height < 1)) {
    return 0;
  }
  if (rescale_to_max) {
    scale = 255.0f / find_max_RGBE(image, width, height);
  }
  for (i = width * height; i > 0; --i) {
    float r, g, b, e, m;
    e = scale * ldexp(1.0f / 255.0f, (int)(img[3]) - 128);
    r = e * img[0];
    g = e * img[1];
    b = e * img[2];
    m = (r > g) ? r : g;
    m = (b > m) ? b : m;
    iv = (m != 0.0f) ? (int)(255.0f / m) : 1.0f;
    iv = (iv < 1) ? 1 : iv;
    img[3] = (iv > 255) ? 255 : iv;
    iv = (int)(img[3] * r + 0.5f);
    img[0] = (iv > 255) ? 255 : iv;
    iv = (int)(img[3] * g + 0.5f);
    img[1] = (iv > 255) ? 255 : iv;
    iv = (int)(img[3] * b + 0.5f);
    img[2] = (iv > 255) ? 255 : iv;
    img += 4;
  }
  return 1;
}
```