user: 下面的汇编指令对应的C源代码是什么:

```asm
<generate_scaling>:
  endbr64
  push   %r15
  lea    -0x8(%rdi),%r9d
  mov    %edx,%r11d
  mov    %rsi,%r10
  push   %r14
  xor    %eax,%eax
  push   %r13
  push   %r12
  push   %rbp
  mov    $0x1,%ebp
  push   %rbx
  mov    %rcx,%rbx
  mov    (%rsi),%edx
  mov    %edi,%ecx
  shl    %cl,%ebp
  mov    %r9d,%ecx
  shl    %cl,%edx
  mov    %r9d,%ecx
  test   %edx,%edx
  jle    L59
  nopl   0x0(%rax)
L180:
  mov    0x4(%r10),%edx
  mov    %edx,(%rbx,%rax,4)
  mov    (%r10),%edx
  add    $0x1,%rax
  shl    %cl,%edx
  cmp    %eax,%edx
  jg     L180
  mov    %ecx,%r9d
L59:
  lea    -0x1(%r11),%r12d
  test   %r12d,%r12d
  jle    L282
  lea    -0x2(%r11),%eax
  mov    %r10,%r8
  mov    %r9d,%ecx
  lea    0x8(%r10,%rax,8),%r13
  nopw   0x0(%rax,%rax,1)
L131:
  mov    0x8(%r8),%r14d
  mov    (%r8),%esi
  mov    0x4(%r8),%edi
  mov    %r14d,%r9d
  sub    %esi,%r9d
  mov    %r9d,%eax
  sar    %eax
  add    $0x10000,%eax
  cltd
  idiv   %r9d
  mov    0xc(%r8),%edx
  sub    %edi,%edx
  imul   %edx,%eax
  mov    %esi,%edx
  mov    $0x8000,%esi
  test   %r9d,%r9d
  jle    L34
  nopl   0x0(%rax)
L12:
  mov    %edx,%r9d
  mov    %esi,%r15d
  add    $0x1,%edx
  add    %eax,%esi
  shl    %cl,%r9d
  sar    $0x10,%r15d
  movslq %r9d,%r9
  add    %edi,%r15d
  mov    %r15d,(%rbx,%r9,4)
  cmp    %r14d,%edx
  jne    L12
L34:
  add    $0x8,%r8
  cmp    %r13,%r8
  jne    L131
  mov    %ecx,%r9d
L282:
  movslq %r11d,%rdi
  mov    %r9d,%ecx
  shl    $0x3,%rdi
  lea    -0x8(%r10,%rdi,1),%rsi
  mov    (%rsi),%edx
  shl    %cl,%edx
  cmp    %edx,%ebp
  jle    L19
  mov    %ebp,%r8d
  movslq %edx,%r13
  lea    -0x4(%r10,%rdi,1),%r14
  sub    %edx,%r8d
  lea    (%rbx,%r13,4),%rax
  mov    %r8d,%ecx
  add    %r13,%rcx
  lea    (%rbx,%rcx,4),%rcx
  cmp    %rcx,%r14
  setae  %cl
  add    %r10,%rdi
  cmp    %rdi,%rax
  setae  %dil
  or     %dil,%cl
  je     L11
  lea    -0x1(%r8),%ecx
  cmp    $0x2,%ecx
  jbe    L11
  mov    %r8d,%ecx
  movd   0x4(%rsi),%xmm7
  shr    $0x2,%ecx
  sub    $0x1,%ecx
  pshufd $0x0,%xmm7,%xmm0
  shl    $0x4,%rcx
  lea    0x10(%rax,%rcx,1),%rcx
L215:
  movups %xmm0,(%rax)
  add    $0x10,%rax
  cmp    %rcx,%rax
  jne    L215
  mov    %r8d,%eax
  and    $0xfffffffc,%eax
  add    %eax,%edx
  cmp    %r8d,%eax
  je     L19
  mov    0x4(%rsi),%ecx
  movslq %edx,%rax
  mov    %ecx,(%rbx,%rax,4)
  lea    0x1(%rdx),%eax
  cmp    %eax,%ebp
  jle    L19
  cltq
  add    $0x2,%edx
  mov    %ecx,(%rbx,%rax,4)
  lea    0x0(,%rax,4),%rdi
  cmp    %edx,%ebp
  jle    L19
  mov    0x4(%rsi),%eax
  mov    %eax,0x4(%rbx,%rdi,1)
L19:
  mov    $0x1,%eax
  mov    %r9d,%ecx
  shl    %cl,%eax
  mov    %eax,%ebp
  mov    %eax,%r13d
  sar    %ebp
  test   %r12d,%r12d
  jle    L50
  lea    -0x2(%r11),%eax
  lea    -0x3(%r13),%edx
  movd   %ebp,%xmm7
  movslq %r13d,%r14
  lea    0x8(%r10,%rax,8),%rax
  mov    %edx,-0x40(%rsp)
  pshufd $0x0,%xmm7,%xmm8
  movdqa D1(%rip),%xmm7
  mov    %rax,-0x10(%rsp)
  lea    -0x2(%r13),%eax
  lea    0x0(,%r14,4),%r12
  mov    %rax,%rcx
  mov    %eax,-0x30(%rsp)
  shl    $0x2,%rax
  mov    %rax,-0x48(%rsp)
  mov    %ecx,%eax
  and    $0xfffffffc,%ecx
  shr    $0x2,%eax
  lea    0x2(%rcx),%edi
  mov    %r10,-0x28(%rsp)
  sub    $0x1,%eax
  mov    %edi,-0x20(%rsp)
  lea    0x3(%rcx),%edi
  add    $0x1,%rax
  mov    %edi,-0x2c(%rsp)
  shl    $0x4,%rax
  mov    %ecx,-0x3c(%rsp)
  add    $0x4,%ecx
  mov    %rax,-0x38(%rsp)
  movslq %r9d,%rax
  movq   %rax,%xmm6
  lea    -0x4(%rbx,%rdx,4),%rax
  mov    %ecx,-0x1c(%rsp)
  mov    %r9d,%ecx
  mov    %rax,-0x18(%rsp)
  xchg   %ax,%ax
L1:
  mov    -0x28(%rsp),%rax
  mov    (%rax),%edi
  mov    0x8(%rax),%eax
  shl    %cl,%edi
  shl    %cl,%eax
  sub    %edi,%eax
  mov    %edi,-0x50(%rsp)
  mov    %eax,-0x4c(%rsp)
  test   %eax,%eax
  jle    L138
  cmp    $0x1,%r13d
  jle    L138
  movslq -0x50(%rsp),%rax
  xor    %r15d,%r15d
  lea    0x8(,%rax,4),%r11
  lea    (%rbx,%r11,1),%rsi
  xchg   %ax,%ax
L281:
  mov    -0x50(%rsp),%eax
  mov    -0x8(%rsi,%r14,4),%edx
  lea    (%rax,%r15,1),%edi
  mov    -0x8(%rsi),%eax
  sub    %eax,%edx
  lea    0x0(%rbp,%rdx,1),%r8d
  mov    %r8d,%r9d
  sar    %cl,%r9d
  add    %eax,%r9d
  mov    %r9d,-0x4(%rsi)
  cmp    $0x1,%ecx
  je     L132
  mov    -0x48(%rsp),%r9
  lea    -0x8(%r11),%r10
  add    %r11,%r9
  cmp    %r9,%r10
  lea    -0x4(%r11),%r9
  setge  %r10b
  cmp    %r9,%r11
  setge  %r9b
  or     %r10b,%r9b
  je     L70
  cmpl   $0x2,-0x40(%rsp)
  jbe    L70
  movd   %edx,%xmm3
  movd   %eax,%xmm5
  mov    -0x38(%rsp),%rax
  movdqa D16(%rip),%xmm2
  pshufd $0x0,%xmm3,%xmm3
  pshufd $0x0,%xmm5,%xmm5
  movdqa %xmm3,%xmm4
  lea    (%rax,%rsi,1),%r8
  mov    %rsi,%rax
  psrlq  $0x20,%xmm4
  xchg   %ax,%ax
L30:
  movdqa %xmm2,%xmm1
  movdqa %xmm3,%xmm0
  paddd  %xmm7,%xmm2
  add    $0x10,%rax
  pmuludq %xmm1,%xmm0
  psrlq  $0x20,%xmm1
  pmuludq %xmm4,%xmm1
  pshufd $0x8,%xmm0,%xmm0
  pshufd $0x8,%xmm1,%xmm1
  punpckldq %xmm1,%xmm0
  paddd  %xmm8,%xmm0
  psrad  %xmm6,%xmm0
  paddd  %xmm5,%xmm0
  movups %xmm0,-0x10(%rax)
  cmp    %rax,%r8
  jne    L30
  mov    -0x30(%rsp),%r10d
  cmp    %r10d,-0x3c(%rsp)
  je     L132
  mov    -0x20(%rsp),%eax
  lea    (%rax,%rdi,1),%r8d
  imul   %edx,%eax
  movslq %r8d,%r8
  add    %ebp,%eax
  sar    %cl,%eax
  add    -0x8(%rsi),%eax
  mov    %eax,(%rbx,%r8,4)
  mov    -0x2c(%rsp),%eax
  cmp    %r13d,%eax
  jge    L132
  lea    (%rax,%rdi,1),%r8d
  imul   %edx,%eax
  movslq %r8d,%r8
  add    %ebp,%eax
  sar    %cl,%eax
  add    -0x8(%rsi),%eax
  mov    %eax,(%rbx,%r8,4)
  mov    -0x1c(%rsp),%eax
  cmp    %eax,%r13d
  jle    L132
  imul   %eax,%edx
  add    %eax,%edi
  movslq %edi,%rdi
  add    %ebp,%edx
  sar    %cl,%edx
  add    -0x8(%rsi),%edx
  mov    %edx,(%rbx,%rdi,4)
L132:
  add    %r13d,%r15d
  add    %r12,%r11
  add    %r12,%rsi
  cmp    %r15d,-0x4c(%rsp)
  jg     L281
L138:
  addq   $0x8,-0x28(%rsp)
  mov    -0x28(%rsp),%rax
  cmp    -0x10(%rsp),%rax
  jne    L1
L50:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L70:
  mov    -0x18(%rsp),%rdi
  add    %edx,%r8d
  lea    -0x8(%rsi),%r9
  lea    (%rdi,%r11,1),%r10
  mov    %eax,%edi
  jmp    L46
  nopl   0x0(%rax)
L65:
  mov    -0x8(%rsi),%edi
L46:
  mov    %r8d,%eax
  add    $0x4,%r9
  add    %edx,%r8d
  sar    %cl,%eax
  add    %edi,%eax
  mov    %eax,0x4(%r9)
  cmp    %r10,%r9
  jne    L65
  jmp    L132
L11:
  lea    -0x1(%rbp),%ecx
  sub    %edx,%ecx
  lea    (%rcx,%r13,1),%rdx
  lea    0x4(%rbx,%rdx,4),%rcx
L220:
  mov    0x4(%rsi),%edx
  add    $0x4,%rax
  mov    %edx,-0x4(%rax)
  cmp    %rcx,%rax
  jne    L220
  jmp    L19
```

tool_calls: name: read_data
arguments: data_tag: D1
type: byte[16]
name: read_data
arguments: data_tag: D16
type: byte[16]

tool: {"D1": [0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00]}

tool: {"D16": [0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00]}

assistant: ```c
void generate_scaling(const int bitdepth, const uint8_t points[][2], const int num, uint8_t scaling[256]) {
  const int shift_x = bitdepth - 8;
  const int scaling_size = 1 << bitdepth;
  for (int i = 0; i < points[0][0] << shift_x; i++)
    scaling[i] = points[0][1];
  for (int i = 0; i < num - 1; i++) {
    const int bx = points[i][0];
    const int by = points[i][1];
    const int ex = points[i + 1][0];
    const int ey = points[i + 1][1];
    const int dx = ex - bx;
    const int dy = ey - by;
    const int delta = dy * ((0x10000 + (dx >> 1)) / dx);
    for (int x = 0; x < dx; x++) {
      const int v = by + ((x * delta + 0x8000) >> 16);
      scaling[(bx + x) << shift_x] = v;
    }
  }
  for (int i = points[num - 1][0] << shift_x; i < scaling_size; i++)
    scaling[i] = points[num - 1][1];
  const int pad = 1 << shift_x, rnd = pad >> 1;
  for (int i = 0; i < num - 1; i++) {
    const int bx = points[i][0] << shift_x;
    const int ex = points[i + 1][0] << shift_x;
    const int dx = ex - bx;
    for (int x = 0; x < dx; x += pad) {
      const int range = scaling[bx + x + pad] - scaling[bx + x];
      for (int n = 1; n < pad; n++) {
        scaling[bx + x + n] = scaling[bx + x] + ((range * n + rnd) >> shift_x);
      }
    }
  }
}
```