user: 请从给定的汇编指令推导出C源代码：

```asm
<scale_internal>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  push   %r13
  mov    %edi,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  lea    (%r8,%r8,1),%esi
  sub    $0xb8,%rsp
  mov    0xf0(%rsp),%rax
  mov    %edx,0x28(%rsp)
  mov    %r8d,0x30(%rsp)
  mov    %r9d,0x70(%rsp)
  mov    %rax,0x58(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xa8(%rsp)
  xor    %eax,%eax
  cmp    %ebx,%esi
  je     L21
L177:
  mov    0x70(%rsp),%edi
  pxor   %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  mov    0x30(%rsp),%eax
  cvtsi2ssl 0x28(%rsp),%xmm0
  pxor   %xmm2,%xmm2
  movss  D126(%rip),%xmm7
  cvtsi2ss %edi,%xmm1
  cvtsi2ss %eax,%xmm2
  divss  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ss %ebx,%xmm1
  divss  %xmm2,%xmm1
  mulss  %xmm1,%xmm7
  movss  %xmm1,0x78(%rsp)
  movss  %xmm7,0x7c(%rsp)
  movss  D126(%rip),%xmm7
  mulss  %xmm0,%xmm7
  movss  %xmm7,0x88(%rsp)
  test   %edi,%edi
  jle    L219
  imul   %r13d,%eax
  pxor   %xmm7,%xmm7
  lea    -0x1(%r13),%ebp
  mov    %r13d,%r12d
  movl   $0x0,0x74(%rsp)
  cvtss2sd %xmm0,%xmm7
  and    $0xfffffffc,%r12d
  mov    %ebp,%r9d
  movl   $0x0,0x40(%rsp)
  mov    %eax,0x8c(%rsp)
  movslq %r13d,%rax
  movsd  %xmm7,0x80(%rsp)
  shl    $0x2,%rax
  mov    %rax,0x48(%rsp)
L199:
  pxor   %xmm0,%xmm0
  mov    0x28(%rsp),%edi
  cvtsi2sdl 0x40(%rsp),%xmm0
  addsd  D34(%rip),%xmm0
  mulsd  0x80(%rsp),%xmm0
  cvtsd2ss %xmm0,%xmm0
  cmp    %edi,0x70(%rsp)
  jge    L243
  movss  0x88(%rsp),%xmm7
  movaps %xmm7,%xmm9
  addss  %xmm0,%xmm9
  subss  %xmm7,%xmm0
  movss  %xmm0,0x34(%rsp)
L249:
  mov    0x30(%rsp),%eax
  test   %eax,%eax
  jle    L22
  movslq 0x74(%rsp),%rax
  mov    0x58(%rsp),%rsi
  movl   $0x0,0x2c(%rsp)
  pxor   %xmm7,%xmm7
  cvtss2sd 0x78(%rsp),%xmm7
  movsd  %xmm7,0x50(%rsp)
  mov    %rax,%rdi
  lea    (%rsi,%rax,4),%rax
  mov    %rax,0x38(%rsp)
  mov    %edi,0x44(%rsp)
L261:
  pxor   %xmm8,%xmm8
  cvtsi2sdl 0x2c(%rsp),%xmm8
  addsd  D34(%rip),%xmm8
  mulsd  0x50(%rsp),%xmm8
  cvtsd2ss %xmm8,%xmm8
  cmp    %ebx,0x30(%rsp)
  jge    L273
  movss  0x7c(%rsp),%xmm7
  movaps %xmm7,%xmm4
  addss  %xmm8,%xmm4
  subss  %xmm7,%xmm8
L198:
  pxor   %xmm0,%xmm0
  mov    %r9d,0xc(%rsp)
  lea    0x90(%rsp),%r14
  movaps %xmm0,0x90(%rsp)
  movss  0x34(%rsp),%xmm0
  movss  %xmm9,0x8(%rsp)
  movss  %xmm4,0x14(%rsp)
  movss  %xmm8,0x10(%rsp)
  call   <floor@plt>
  movss  0x34(%rsp),%xmm6
  movss  0x8(%rsp),%xmm9
  pxor   %xmm5,%xmm5
  mov    0xc(%rsp),%r9d
  mov    %eax,%r10d
  comiss %xmm6,%xmm9
  movaps %xmm6,%xmm7
  jbe    L182
  movss  0x10(%rsp),%xmm8
  movss  0x14(%rsp),%xmm4
  nopl   0x0(%rax)
L322:
  mov    0x28(%rsp),%edi
  movaps %xmm7,%xmm0
  pxor   %xmm7,%xmm7
  lea    (%rdi,%r10,1),%eax
  add    $0x1,%r10d
  cltd
  cvtsi2ss %r10d,%xmm7
  idiv   %edi
  comiss %xmm9,%xmm7
  mov    %edx,%ebp
  jbe    L203
  movaps %xmm9,%xmm6
  subss  %xmm0,%xmm6
L299:
  movaps %xmm8,%xmm0
  mov    %r9d,0x20(%rsp)
  mov    %r10d,0xc(%rsp)
  movss  %xmm5,0x1c(%rsp)
  movss  %xmm9,0x18(%rsp)
  movss  %xmm4,0x14(%rsp)
  movss  %xmm7,0x10(%rsp)
  movss  %xmm8,0x8(%rsp)
  movss  %xmm6,0x24(%rsp)
  call   <floor@plt>
  movss  0x14(%rsp),%xmm4
  mov    0xc(%rsp),%r10d
  movss  0x8(%rsp),%xmm8
  movss  0x10(%rsp),%xmm7
  mov    %eax,%edi
  movss  0x18(%rsp),%xmm9
  movss  0x1c(%rsp),%xmm5
  comiss %xmm8,%xmm4
  mov    0x20(%rsp),%r9d
  jbe    L18
  imul   %ebx,%ebp
  movss  0x24(%rsp),%xmm6
  movaps %xmm8,%xmm1
  jmp    L191
  nopl   0x0(%rax,%rax,1)
L68:
  movaps %xmm4,%xmm0
  subss  %xmm2,%xmm0
L132:
  mulss  %xmm6,%xmm0
  add    %ebp,%edx
  imul   %r13d,%edx
  addss  %xmm0,%xmm5
  test   %r13d,%r13d
  jle    L212
  cmp    $0x2,%r9d
  jbe    L2
  movslq %edx,%rax
  movaps %xmm0,%xmm3
  movups (%r15,%rax,4),%xmm2
  shufps $0x0,%xmm3,%xmm3
  mulps  %xmm3,%xmm2
  addps  0x90(%rsp),%xmm2
  movaps %xmm2,0x90(%rsp)
  cmp    %r13d,%r12d
  je     L212
  mov    %r12d,%ecx
  mov    %r12d,%eax
L240:
  mov    %r13d,%esi
  sub    %ecx,%esi
  cmp    $0x1,%esi
  je     L256
  movslq %edx,%r11
  lea    (%r14,%rcx,4),%r8
  movaps %xmm0,%xmm2
  add    %r11,%rcx
  shufps $0xe0,%xmm2,%xmm2
  movq   (%r15,%rcx,4),%xmm3
  mov    %esi,%ecx
  and    $0xfffffffe,%ecx
  mulps  %xmm2,%xmm3
  movq   (%r8),%xmm2
  add    %ecx,%eax
  addps  %xmm3,%xmm2
  movlps %xmm2,(%r8)
  cmp    %ecx,%esi
  je     L212
L256:
  movslq %eax,%rcx
  add    %edx,%eax
  cltq
  mulss  (%r15,%rax,4),%xmm0
  addss  0x90(%rsp,%rcx,4),%xmm0
  movss  %xmm0,0x90(%rsp,%rcx,4)
L212:
  comiss %xmm1,%xmm4
  jbe    L18
L191:
  lea    (%rdi,%rbx,1),%eax
  movaps %xmm1,%xmm2
  pxor   %xmm1,%xmm1
  add    $0x1,%edi
  cvtsi2ss %edi,%xmm1
  cltd
  idiv   %ebx
  comiss %xmm4,%xmm1
  ja     L68
  movaps %xmm1,%xmm0
  subss  %xmm2,%xmm0
  jmp    L132
  nopl   (%rax)
L18:
  comiss %xmm7,%xmm9
  ja     L322
L182:
  test   %r13d,%r13d
  jle    L307
  cvtss2sd %xmm5,%xmm5
  cmp    $0x2,%r9d
  jbe    L220
  movaps 0x90(%rsp),%xmm7
  movhps %xmm7,0x60(%rsp)
  cvtps2pd 0x60(%rsp),%xmm1
  cvtps2pd 0x90(%rsp),%xmm0
  addpd  D34(%rip),%xmm1
  movapd %xmm5,%xmm2
  mov    0x38(%rsp),%rax
  addpd  D34(%rip),%xmm0
  unpcklpd %xmm2,%xmm2
  divpd  %xmm2,%xmm1
  divpd  %xmm2,%xmm0
  cvtpd2ps %xmm1,%xmm1
  cvtpd2ps %xmm0,%xmm0
  movlhps %xmm1,%xmm0
  movups %xmm0,(%rax)
  mov    %r12d,%eax
  cmp    %r13d,%r12d
  je     L307
L94:
  movslq %eax,%rcx
  pxor   %xmm0,%xmm0
  mov    0x44(%rsp),%edi
  mov    0x58(%rsp),%rsi
  cvtss2sd 0x90(%rsp,%rcx,4),%xmm0
  lea    0x1(%rax),%ecx
  addsd  D34(%rip),%xmm0
  lea    (%rdi,%rax,1),%edx
  movslq %edx,%rdx
  divsd  %xmm5,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,(%rsi,%rdx,4)
  cmp    %ecx,%r13d
  jle    L307
  lea    (%rdi,%rcx,1),%edx
  pxor   %xmm0,%xmm0
  movslq %ecx,%rcx
  add    $0x2,%eax
  cvtss2sd 0x90(%rsp,%rcx,4),%xmm0
  movslq %edx,%rdx
  addsd  D34(%rip),%xmm0
  divsd  %xmm5,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,(%rsi,%rdx,4)
  cmp    %eax,%r13d
  jle    L307
  lea    (%rdi,%rax,1),%edx
  pxor   %xmm0,%xmm0
  cltq
  cvtss2sd 0x90(%rsp,%rax,4),%xmm0
  movslq %edx,%rdx
  addsd  D34(%rip),%xmm0
  divsd  %xmm5,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,(%rsi,%rdx,4)
L307:
  addl   $0x1,0x2c(%rsp)
  mov    0x48(%rsp),%rsi
  add    %r13d,0x44(%rsp)
  mov    0x2c(%rsp),%eax
  add    %rsi,0x38(%rsp)
  cmp    %eax,0x30(%rsp)
  jne    L261
L22:
  addl   $0x1,0x40(%rsp)
  mov    0x8c(%rsp),%esi
  mov    0x40(%rsp),%eax
  add    %esi,0x74(%rsp)
  cmp    %eax,0x70(%rsp)
  jne    L199
L219:
  mov    0xa8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L97
  add    $0xb8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L2:
  xor    %ecx,%ecx
  xor    %eax,%eax
  jmp    L240
  nopl   0x0(%rax)
L203:
  movaps %xmm7,%xmm6
  subss  %xmm0,%xmm6
  jmp    L299
L273:
  movss  D126(%rip),%xmm4
  addss  %xmm8,%xmm4
  subss  D126(%rip),%xmm8
  jmp    L198
L220:
  xor    %eax,%eax
  jmp    L94
L243:
  movss  D126(%rip),%xmm9
  addss  %xmm0,%xmm9
  subss  D126(%rip),%xmm0
  movss  %xmm0,0x34(%rsp)
  jmp    L249
L21:
  lea    (%r9,%r9,1),%edx
  cmp    0x28(%rsp),%edx
  jne    L177
  mov    0xa8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L97
  mov    0x58(%rsp),%r8
  add    $0xb8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <halveImage@plt>
L97:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D126
type_infered: f32
name: unpack_data
arguments: label: D34
type_infered: f32[4]

tool: D126: 0.5

tool: {"D34": [0.0,1.75,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;
      }
    }
  }
}
```