user: 请将以下的汇编代码转换成C语言代码:

```asm
<range>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %rcx,-0x60(%rbp)
  mov    %r8,-0x68(%rbp)
  mov    %r9d,-0x6c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x6c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x6c(%rbp),%eax
  imul   %eax,%eax
  mov    %eax,-0x38(%rbp)
  mov    -0x38(%rbp),%eax
  cltq
  add    %rax,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  movl   $0xfa,-0x20(%rbp)
  movl   $0x10,-0x1c(%rbp)
  cmpq   $0x4,-0x68(%rbp)
  jne    L40
  movl   $0xa,-0x20(%rbp)
  movl   $0x3,-0x1c(%rbp)
L40:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L37
L59:
  mov    -0x28(%rbp),%ecx
  movslq %ecx,%rax
  imul   $0x66666667,%rax,%rax
  shr    $0x20,%rax
  sar    $0x2,%eax
  mov    %ecx,%esi
  sar    $0x1f,%esi
  sub    %esi,%eax
  mov    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  sub    %eax,%ecx
  mov    %ecx,%edx
  test   %edx,%edx
  jne    L167
  mov    -0x28(%rbp),%eax
  mov    %eax,%esi
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L167:
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L117
L149:
  movl   $0x0,-0x2c(%rbp)
  mov    -0x18(%rbp),%eax
  neg    %eax
  mov    %eax,-0x34(%rbp)
  jmp    L86
L38:
  mov    -0x18(%rbp),%eax
  neg    %eax
  mov    %eax,-0x30(%rbp)
  jmp    L98
L161:
  mov    -0x28(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x24(%rbp),%ecx
  mov    -0x30(%rbp),%eax
  add    %ecx,%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x2c(%rbp),%edx
  movslq %edx,%rdx
  lea    (%rdx,%rdx,1),%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  addl   $0x1,-0x2c(%rbp)
  addl   $0x1,-0x30(%rbp)
L98:
  mov    -0x30(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L161
  addl   $0x1,-0x34(%rbp)
L86:
  mov    -0x34(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L38
  lea    -0x38(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sort_elements@plt>
  mov    -0x38(%rbp),%eax
  cltq
  add    %rax,%rax
  lea    -0x2(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  mov    %eax,%edx
  mov    -0x10(%rbp),%rax
  movzwl (%rax),%eax
  sub    %eax,%edx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rcx
  mov    -0x24(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rcx,%rax
  mov    %dx,(%rax)
  addl   $0x1,-0x24(%rbp)
L117:
  mov    -0x24(%rbp),%eax
  cltq
  mov    -0x18(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x60(%rbp),%rdx
  sub    %rcx,%rdx
  cmp    %rdx,%rax
  jl     L149
  addl   $0x1,-0x28(%rbp)
L37:
  mov    -0x28(%rbp),%eax
  cltq
  mov    -0x18(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x58(%rbp),%rdx
  sub    %rcx,%rdx
  cmp    %rdx,%rax
  jl     L59
  cmpl   $0x1,0x10(%rbp)
  jne    L104
  movl   $0x0,-0x28(%rbp)
  jmp    L81
L50:
  movl   $0x0,-0x24(%rbp)
  jmp    L90
L1:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cwtl
  cmp    %eax,0x18(%rbp)
  jge    L9
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x20(%rbp),%edx
  mov    %dx,(%rax)
  jmp    L92
L9:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x1c(%rbp),%edx
  mov    %dx,(%rax)
L92:
  addl   $0x1,-0x24(%rbp)
L90:
  mov    -0x24(%rbp),%eax
  cltq
  cmp    %rax,-0x60(%rbp)
  jg     L1
  addl   $0x1,-0x28(%rbp)
L81:
  mov    -0x28(%rbp),%eax
  cltq
  cmp    %rax,-0x58(%rbp)
  jg     L50
L104:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x1,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L159
  call   <__stack_chk_fail@plt>
L159:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D5
type: string

tool: D5: %4d 

assistant: ```c
int range(the_image, out_image, rows, cols, bits_per_pixel, size, threshold, high)
int high, threshold, size;
short **the_image, **out_image;
long rows, cols, bits_per_pixel;
{
  int a, b, count, i, j, k, new_hi, new_low, length, sd2, sd2p1, ss, width;
  short *elements;
  sd2 = size / 2;
  sd2p1 = sd2 + 1;
  ss = size * size;
  elements = (short *)malloc(ss * sizeof(short));
  new_hi = 250;
  new_low = 16;
  if (bits_per_pixel == 4) {
    new_hi = 10;
    new_low = 3;
  }
  printf("\n");
  for (i = sd2; i < rows - sd2; i++) {
    if ((i % 10) == 0)
      printf("%4d ", i);
    for (j = sd2; j < cols - sd2; j++) {
      count = 0;
      for (a = -sd2; a < sd2p1; a++) {
        for (b = -sd2; b < sd2p1; b++) {
          elements[count] = the_image[i + a][j + b];
          count++;
        }
      }
      sort_elements(elements, &ss);
      out_image[i][j] = elements[ss - 1] - elements[0];
    }
  }
  if (threshold == 1) {
    for (i = 0; i < rows; i++) {
      for (j = 0; j < cols; j++) {
        if (out_image[i][j] > high) {
          out_image[i][j] = new_hi;
        } else {
          out_image[i][j] = new_low;
        }
      }
    }
  }
  free(elements);
  return (1);
}
```