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

```asm
<scale_internal>:
  endbr64
  push   %r15
  push   %r14
  mov    %esi,%r14d
  lea    (%r8,%r8,1),%esi
  push   %r13
  mov    %edi,%r13d
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    0xd0(%rsp),%rax
  mov    %edx,0x1c(%rsp)
  mov    %r8d,0x24(%rsp)
  mov    %r9d,0x48(%rsp)
  mov    %rax,0x50(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x88(%rsp)
  xor    %eax,%eax
  cmp    %r14d,%esi
  je     L167
L81:
  mov    0x48(%rsp),%esi
  pxor   %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  mov    0x24(%rsp),%eax
  cvtsi2ssl 0x1c(%rsp),%xmm0
  pxor   %xmm2,%xmm2
  movss  D39(%rip),%xmm7
  cvtsi2ss %esi,%xmm1
  cvtsi2ss %eax,%xmm2
  divss  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ss %r14d,%xmm1
  divss  %xmm2,%xmm1
  mulss  %xmm1,%xmm7
  movss  %xmm1,0x5c(%rsp)
  movss  %xmm7,0x60(%rsp)
  movss  D39(%rip),%xmm7
  mulss  %xmm0,%xmm7
  movss  %xmm7,0x64(%rsp)
  test   %esi,%esi
  jle    L191
  imul   %r13d,%eax
  lea    0x70(%rsp),%r15
  pxor   %xmm7,%xmm7
  movl   $0x0,0x4c(%rsp)
  movl   $0x0,0x34(%rsp)
  cvtss2sd %xmm0,%xmm7
  movsd  %xmm7,0x68(%rsp)
  mov    %eax,0x58(%rsp)
  movslq %r13d,%rax
  shl    $0x2,%rax
  mov    %rax,0x38(%rsp)
  mov    %r15,%rax
  mov    %r13d,%r15d
  mov    %r12,%r13
  mov    %rax,%r12
L229:
  pxor   %xmm0,%xmm0
  mov    0x1c(%rsp),%esi
  cvtsi2sdl 0x34(%rsp),%xmm0
  addsd  D38(%rip),%xmm0
  mulsd  0x68(%rsp),%xmm0
  cvtsd2ss %xmm0,%xmm0
  cmp    %esi,0x48(%rsp)
  jge    L216
  movss  0x64(%rsp),%xmm6
  movaps %xmm6,%xmm8
  addss  %xmm0,%xmm8
  subss  %xmm6,%xmm0
  movss  %xmm0,0x30(%rsp)
L172:
  mov    0x24(%rsp),%eax
  test   %eax,%eax
  jle    L105
  movslq 0x4c(%rsp),%rax
  mov    0x50(%rsp),%rsi
  pxor   %xmm6,%xmm6
  mov    %r12,%rbp
  movl   $0x0,0x20(%rsp)
  mov    %r13,%r12
  cvtss2sd 0x5c(%rsp),%xmm6
  mov    %r14d,%r13d
  lea    (%rsi,%rax,4),%rax
  movsd  %xmm6,0x40(%rsp)
  mov    %r15d,%r14d
  mov    %rax,0x28(%rsp)
L223:
  pxor   %xmm7,%xmm7
  cvtsi2sdl 0x20(%rsp),%xmm7
  addsd  D38(%rip),%xmm7
  mulsd  0x40(%rsp),%xmm7
  cvtsd2ss %xmm7,%xmm7
  cmp    %r13d,0x24(%rsp)
  jge    L115
  movss  0x60(%rsp),%xmm6
  movaps %xmm6,%xmm3
  addss  %xmm7,%xmm3
  subss  %xmm6,%xmm7
L195:
  movss  0x30(%rsp),%xmm0
  movss  %xmm8,0x4(%rsp)
  movss  %xmm7,0x8(%rsp)
  movq   $0x0,0x70(%rsp)
  movq   $0x0,0x78(%rsp)
  movss  %xmm3,0xc(%rsp)
  call   <floor@plt>
  movss  0x30(%rsp),%xmm7
  movss  0x4(%rsp),%xmm8
  pxor   %xmm4,%xmm4
  comiss %xmm7,%xmm8
  movaps %xmm7,%xmm6
  jbe    L152
  movss  0xc(%rsp),%xmm3
  movss  0x8(%rsp),%xmm7
  mov    %eax,%r15d
  nopl   0x0(%rax)
L61:
  mov    0x1c(%rsp),%edi
  movaps %xmm6,%xmm0
  pxor   %xmm6,%xmm6
  lea    (%r15,%rdi,1),%eax
  add    $0x1,%r15d
  cltd
  cvtsi2ss %r15d,%xmm6
  idiv   %edi
  comiss %xmm8,%xmm6
  mov    %edx,%ebx
  jbe    L19
  movaps %xmm8,%xmm5
  subss  %xmm0,%xmm5
L27:
  movaps %xmm7,%xmm0
  movss  %xmm4,0x14(%rsp)
  movss  %xmm8,0x10(%rsp)
  movss  %xmm3,0xc(%rsp)
  movss  %xmm6,0x8(%rsp)
  movss  %xmm7,0x4(%rsp)
  movss  %xmm5,0x18(%rsp)
  call   <floor@plt>
  movss  0x4(%rsp),%xmm7
  movss  0xc(%rsp),%xmm3
  movss  0x8(%rsp),%xmm6
  movss  0x10(%rsp),%xmm8
  mov    %eax,%ecx
  comiss %xmm7,%xmm3
  movss  0x14(%rsp),%xmm4
  jbe    L144
  imul   %r13d,%ebx
  movss  0x18(%rsp),%xmm5
  movaps %xmm7,%xmm2
  nop
L211:
  lea    (%rcx,%r13,1),%eax
  movaps %xmm2,%xmm0
  pxor   %xmm2,%xmm2
  add    $0x1,%ecx
  cvtsi2ss %ecx,%xmm2
  cltd
  idiv   %r13d
  comiss %xmm3,%xmm2
  jbe    L34
  movaps %xmm3,%xmm1
  subss  %xmm0,%xmm1
L198:
  mulss  %xmm5,%xmm1
  add    %ebx,%edx
  imul   %r14d,%edx
  addss  %xmm1,%xmm4
  test   %r14d,%r14d
  jle    L220
  movslq %edx,%rdx
  xor    %eax,%eax
  lea    (%r12,%rdx,4),%rdx
L11:
  movss  (%rdx,%rax,4),%xmm0
  mulss  %xmm1,%xmm0
  addss  0x0(%rbp,%rax,4),%xmm0
  movss  %xmm0,0x0(%rbp,%rax,4)
  add    $0x1,%rax
  cmp    %eax,%r14d
  jg     L11
L220:
  comiss %xmm2,%xmm3
  ja     L211
L144:
  comiss %xmm6,%xmm8
  ja     L61
L152:
  test   %r14d,%r14d
  jle    L101
  mov    0x28(%rsp),%rdx
  xor    %eax,%eax
  cvtss2sd %xmm4,%xmm4
L213:
  pxor   %xmm0,%xmm0
  cvtss2sd 0x0(%rbp,%rax,4),%xmm0
  addsd  D38(%rip),%xmm0
  divsd  %xmm4,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,(%rdx,%rax,4)
  add    $0x1,%rax
  cmp    %eax,%r14d
  jg     L213
L101:
  addl   $0x1,0x20(%rsp)
  mov    0x38(%rsp),%rdi
  mov    0x20(%rsp),%eax
  add    %rdi,0x28(%rsp)
  cmp    %eax,0x24(%rsp)
  jne    L223
  mov    %r14d,%r15d
  mov    %r13d,%r14d
  mov    %r12,%r13
  mov    %rbp,%r12
L105:
  addl   $0x1,0x34(%rsp)
  mov    0x58(%rsp),%edi
  mov    0x34(%rsp),%eax
  add    %edi,0x4c(%rsp)
  cmp    %eax,0x48(%rsp)
  jne    L229
L191:
  mov    0x88(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L168
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L34:
  movaps %xmm2,%xmm1
  subss  %xmm0,%xmm1
  jmp    L198
  nopl   0x0(%rax)
L19:
  movaps %xmm6,%xmm5
  subss  %xmm0,%xmm5
  jmp    L27
L115:
  movss  D39(%rip),%xmm3
  addss  %xmm7,%xmm3
  subss  D39(%rip),%xmm7
  jmp    L195
L216:
  movss  D39(%rip),%xmm8
  addss  %xmm0,%xmm8
  subss  D39(%rip),%xmm0
  movss  %xmm0,0x30(%rsp)
  jmp    L172
L167:
  lea    (%r9,%r9,1),%edx
  cmp    0x1c(%rsp),%edx
  jne    L81
  mov    0x88(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L168
  mov    0x50(%rsp),%r8
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <halveImage@plt>
L168:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D39
type_infered: f32
name: unpack_data
arguments: data_tag: D38
type_infered: f32[2]

tool: D39: 0.5

tool: {"D38": [0.0,1.75]}

assistant: ```c
void scale_internal(GLint components, GLint widthin, GLint heightin, const GLushort *datain, GLint widthout, GLint heightout, GLushort *dataout) {
  float x, lowx, highx, convx, halfconvx;
  float y, lowy, highy, convy, halfconvy;
  float xpercent, ypercent;
  float percent;
  float totals[4];
  float area;
  int i, j, k, yint, xint, xindex, yindex;
  int temp;
  if (widthin == widthout * 2 && heightin == heightout * 2) {
    halveImage(components, widthin, heightin, datain, dataout);
    return;
  }
  convy = (float)heightin / heightout;
  convx = (float)widthin / widthout;
  halfconvx = convx / 2;
  halfconvy = convy / 2;
  for (i = 0; i < heightout; i++) {
    y = convy * (i + 0.5);
    if (heightin > heightout) {
      highy = y + halfconvy;
      lowy = y - halfconvy;
    } else {
      highy = y + 0.5;
      lowy = y - 0.5;
    }
    for (j = 0; j < widthout; j++) {
      x = convx * (j + 0.5);
      if (widthin > widthout) {
        highx = x + halfconvx;
        lowx = x - halfconvx;
      } else {
        highx = x + 0.5;
        lowx = x - 0.5;
      }
      totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
      area = 0.0;
      y = lowy;
      yint = floor(y);
      while (y < highy) {
        yindex = (yint + heightin) % heightin;
        if (highy < yint + 1) {
          ypercent = highy - y;
        } else {
          ypercent = yint + 1 - y;
        }
        x = lowx;
        xint = floor(x);
        while (x < highx) {
          xindex = (xint + widthin) % widthin;
          if (highx < xint + 1) {
            xpercent = highx - x;
          } else {
            xpercent = xint + 1 - x;
          }
          percent = xpercent * ypercent;
          area += percent;
          temp = (xindex + (yindex * widthin)) * components;
          for (k = 0; k < components; k++) {
            totals[k] += datain[temp + k] * percent;
          }
          xint++;
          x = xint;
        }
        yint++;
        y = yint;
      }
      temp = (j + (i * widthout)) * components;
      for (k = 0; k < components; k++) {
        dataout[temp + k] = (totals[k] + 0.5) / area;
      }
    }
  }
}
```