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

```asm
<generate_scaling>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x64(%rbp)
  mov    %rsi,-0x70(%rbp)
  mov    %edx,-0x68(%rbp)
  mov    %rcx,-0x78(%rbp)
  mov    -0x64(%rbp),%eax
  sub    $0x8,%eax
  mov    %eax,-0x40(%rbp)
  mov    -0x64(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x3c(%rbp)
  movl   $0x0,-0x5c(%rbp)
  jmp    L98
L76:
  mov    -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x78(%rbp),%rax
  add    %rax,%rdx
  mov    -0x70(%rbp),%rax
  mov    0x4(%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x5c(%rbp)
L98:
  mov    -0x70(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x40(%rbp),%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  cmp    %eax,-0x5c(%rbp)
  jl     L76
  movl   $0x0,-0x58(%rbp)
  jmp    L92
L104:
  mov    -0x58(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x58(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    0x4(%rax),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x58(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x58(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    0x4(%rax),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x18(%rbp),%eax
  sub    -0x20(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x14(%rbp),%eax
  sub    -0x1c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x10(%rbp),%eax
  sar    %eax
  add    $0x10000,%eax
  cltd
  idivl  -0x10(%rbp)
  mov    %eax,%edx
  mov    -0xc(%rbp),%eax
  imul   %edx,%eax
  mov    %eax,-0x8(%rbp)
  movl   $0x0,-0x54(%rbp)
  jmp    L103
L107:
  mov    -0x54(%rbp),%eax
  imul   -0x8(%rbp),%eax
  add    $0x8000,%eax
  sar    $0x10,%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x20(%rbp),%edx
  mov    -0x54(%rbp),%eax
  add    %eax,%edx
  mov    -0x40(%rbp),%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x78(%rbp),%rax
  add    %rax,%rdx
  mov    -0x4(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x54(%rbp)
L103:
  mov    -0x54(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L107
  addl   $0x1,-0x58(%rbp)
L92:
  mov    -0x68(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x58(%rbp)
  jl     L104
  mov    -0x68(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x40(%rbp),%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x50(%rbp)
  jmp    L66
L84:
  mov    -0x68(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    -0x50(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x78(%rbp),%rdx
  add    %rcx,%rdx
  mov    0x4(%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x50(%rbp)
L66:
  mov    -0x50(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jl     L84
  mov    -0x40(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x38(%rbp)
  mov    -0x38(%rbp),%eax
  sar    %eax
  mov    %eax,-0x34(%rbp)
  movl   $0x0,-0x4c(%rbp)
  jmp    L125
L137:
  mov    -0x4c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x40(%rbp),%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x30(%rbp)
  mov    -0x4c(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x40(%rbp),%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    -0x30(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  movl   $0x0,-0x48(%rbp)
  jmp    L131
L21:
  mov    -0x30(%rbp),%edx
  mov    -0x48(%rbp),%eax
  add    %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x78(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x30(%rbp),%ecx
  mov    -0x48(%rbp),%edx
  add    %ecx,%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x78(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edx
  sub    %edx,%eax
  mov    %eax,-0x24(%rbp)
  movl   $0x1,-0x44(%rbp)
  jmp    L90
L15:
  mov    -0x30(%rbp),%edx
  mov    -0x48(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x78(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%esi
  mov    -0x24(%rbp),%eax
  imul   -0x44(%rbp),%eax
  mov    %eax,%edx
  mov    -0x34(%rbp),%eax
  add    %eax,%edx
  mov    -0x40(%rbp),%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%ecx
  mov    -0x30(%rbp),%edx
  mov    -0x48(%rbp),%eax
  add    %eax,%edx
  mov    -0x44(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x78(%rbp),%rax
  add    %rdx,%rax
  lea    (%rsi,%rcx,1),%edx
  mov    %edx,(%rax)
  addl   $0x1,-0x44(%rbp)
L90:
  mov    -0x44(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jl     L15
  mov    -0x38(%rbp),%eax
  add    %eax,-0x48(%rbp)
L131:
  mov    -0x48(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L21
  addl   $0x1,-0x4c(%rbp)
L125:
  mov    -0x68(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x4c(%rbp)
  jl     L137
  nop
  nop
  pop    %rbp
  ret
```

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);
      }
    }
  }
}
```