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

```asm
<edge_gray_shade_region>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x860,%rsp
  mov    %rdi,-0x828(%rbp)
  mov    %rsi,-0x830(%rbp)
  mov    %rdx,-0x838(%rbp)
  mov    %ecx,-0x83c(%rbp)
  mov    %r8d,%edi
  mov    %r9d,%esi
  mov    0x10(%rbp),%ecx
  mov    0x18(%rbp),%edx
  mov    0x20(%rbp),%eax
  mov    %di,-0x840(%rbp)
  mov    %si,-0x844(%rbp)
  mov    %cx,-0x848(%rbp)
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,-0x850(%rbp)
  mov    %dx,-0x84c(%rbp)
  mov    %ax,-0x854(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x1,-0x83c(%rbp)
  je     L86
  cmpl   $0x2,-0x83c(%rbp)
  je     L86
  cmpl   $0x3,-0x83c(%rbp)
  jne    L244
L86:
  mov    0x28(%rbp),%rcx
  mov    -0x83c(%rbp),%edx
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  push   0x38(%rbp)
  push   0x30(%rbp)
  mov    %rcx,%r9
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <detect_edges@plt>
  add    $0x10,%rsp
L244:
  cmpl   $0x4,-0x83c(%rbp)
  jne    L111
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  sub    $0x8,%rsp
  push   0x38(%rbp)
  mov    %rcx,%r9
  mov    %rdx,%r8
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <quick_edge@plt>
  add    $0x10,%rsp
L111:
  cmpl   $0x5,-0x83c(%rbp)
  jne    L240
  mov    0x38(%rbp),%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  sub    $0x8,%rsp
  push   $0x0
  mov    $0x0,%r9d
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <homogeneity@plt>
  add    $0x10,%rsp
L240:
  cmpl   $0x6,-0x83c(%rbp)
  jne    L218
  mov    0x38(%rbp),%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  sub    $0x8,%rsp
  push   $0x0
  mov    $0x0,%r9d
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <difference_edge@plt>
  add    $0x10,%rsp
L218:
  cmpl   $0x7,-0x83c(%rbp)
  jne    L142
  mov    0x38(%rbp),%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  sub    $0x8,%rsp
  push   $0x0
  mov    $0x0,%r9d
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <contrast_edge@plt>
  add    $0x10,%rsp
L142:
  cmpl   $0x8,-0x83c(%rbp)
  jne    L89
  mov    0x38(%rbp),%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  push   $0x0
  push   $0x0
  mov    $0x3,%r9d
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <gaussian_edge@plt>
  add    $0x10,%rsp
L89:
  cmpl   $0xa,-0x83c(%rbp)
  jne    L212
  mov    0x38(%rbp),%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  push   $0x0
  push   $0x0
  mov    $0x3,%r9d
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <range@plt>
  add    $0x10,%rsp
L212:
  cmpl   $0xb,-0x83c(%rbp)
  jne    L9
  mov    0x38(%rbp),%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  sub    $0x8,%rsp
  push   $0x0
  mov    $0x0,%r9d
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <variance@plt>
  add    $0x10,%rsp
L9:
  movl   $0x0,-0x818(%rbp)
  jmp    L84
L237:
  movl   $0x0,-0x814(%rbp)
  jmp    L33
L138:
  mov    -0x818(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x838(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x814(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x818(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x830(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x814(%rbp),%edx
  movslq %edx,%rdx
  add    %rdx,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  addl   $0x1,-0x814(%rbp)
L33:
  mov    -0x814(%rbp),%eax
  cltq
  cmp    %rax,0x30(%rbp)
  jg     L138
  addl   $0x1,-0x818(%rbp)
L84:
  mov    -0x818(%rbp),%eax
  cltq
  cmp    %rax,0x28(%rbp)
  jg     L237
  lea    -0x810(%rbp),%rax
  mov    $0x100,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <zero_histogram@plt>
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  lea    -0x810(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <calculate_histogram@plt>
  pxor   %xmm1,%xmm1
  cvtss2sd -0x850(%rbp),%xmm1
  movq   %xmm1,%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  lea    -0x81a(%rbp),%rsi
  lea    -0x810(%rbp),%rax
  movq   %rdi,%xmm0
  mov    %rax,%rdi
  mov    $0x1,%eax
  call   <find_cutoff_point@plt>
  movswl -0x84c(%rbp),%ecx
  movzwl -0x81a(%rbp),%eax
  movswl %ax,%edx
  mov    0x28(%rbp),%rdi
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  sub    $0x8,%rsp
  push   0x30(%rbp)
  mov    %rdi,%r9
  mov    %ecx,%r8d
  mov    %edx,%ecx
  mov    $0xff,%edx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <threshold_image_array@plt>
  add    $0x10,%rsp
  cmpw   $0x0,-0x854(%rbp)
  je     L229
  movl   $0x0,-0x818(%rbp)
  jmp    L102
L53:
  movl   $0x0,-0x814(%rbp)
  jmp    L14
L238:
  mov    -0x818(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x838(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x814(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x818(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x830(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x814(%rbp),%edx
  movslq %edx,%rdx
  add    %rdx,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  addl   $0x1,-0x814(%rbp)
L14:
  mov    -0x814(%rbp),%eax
  cltq
  cmp    %rax,0x30(%rbp)
  jg     L238
  addl   $0x1,-0x818(%rbp)
L102:
  mov    -0x818(%rbp),%eax
  cltq
  cmp    %rax,0x28(%rbp)
  jg     L53
  movswl -0x854(%rbp),%ecx
  movswl -0x84c(%rbp),%edx
  mov    0x30(%rbp),%r8
  mov    0x28(%rbp),%rdi
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  mov    %r8,%r9
  mov    %rdi,%r8
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <erode_image_array@plt>
L229:
  mov    -0x830(%rbp),%rdx
  mov    -0x828(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <read_image_array@plt>
  movl   $0x0,-0x818(%rbp)
  jmp    L185
L10:
  movl   $0x0,-0x814(%rbp)
  jmp    L15
L42:
  mov    -0x818(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x838(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x814(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0x84c(%rbp)
  jne    L233
  mov    -0x818(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x830(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x814(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movw   $0xffce,(%rax)
L233:
  addl   $0x1,-0x814(%rbp)
L15:
  mov    -0x814(%rbp),%eax
  cltq
  cmp    %rax,0x30(%rbp)
  jg     L42
  addl   $0x1,-0x818(%rbp)
L185:
  mov    -0x818(%rbp),%eax
  cltq
  cmp    %rax,0x28(%rbp)
  jg     L10
  movswl -0x844(%rbp),%edi
  movswl -0x840(%rbp),%ecx
  movswl -0x848(%rbp),%edx
  mov    0x28(%rbp),%r8
  mov    -0x838(%rbp),%rsi
  mov    -0x830(%rbp),%rax
  sub    $0x8,%rsp
  push   0x30(%rbp)
  mov    %r8,%r9
  mov    %edi,%r8d
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <pixel_grow@plt>
  add    $0x10,%rsp
  mov    $0x1,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L124
  call   <__stack_chk_fail@plt>
L124:
  leave
  ret
```

assistant: ```c
int edge_gray_shade_region(in_name, the_image, out_image, edge_type, min_area, max_area, diff, percent, set_value, erode, rows, cols, bits_per_pixel)
char in_name[];
float percent;
int edge_type;
long bits_per_pixel, cols, rows;
short diff, erode, max_area, min_area, set_value, **the_image, **out_image;
{
  int a, b, count, i, j, k, length, width;
  short cutoff;
  unsigned long histogram[255 + 1];
  if (edge_type == 1 || edge_type == 2 || edge_type == 3)
    detect_edges(the_image, out_image, edge_type, 0, 0, rows, cols, bits_per_pixel);
  if (edge_type == 4) {
    quick_edge(the_image, out_image, 0, 0, rows, cols, bits_per_pixel);
  }
  if (edge_type == 5) {
    homogeneity(the_image, out_image, rows, cols, bits_per_pixel, 0, 0);
  }
  if (edge_type == 6) {
    difference_edge(the_image, out_image, rows, cols, bits_per_pixel, 0, 0);
  }
  if (edge_type == 7) {
    contrast_edge(the_image, out_image, rows, cols, bits_per_pixel, 0, 0);
  }
  if (edge_type == 8) {
    gaussian_edge(the_image, out_image, rows, cols, bits_per_pixel, 3, 0, 0);
  }
  if (edge_type == 10) {
    range(the_image, out_image, rows, cols, bits_per_pixel, 3, 0, 0);
  }
  if (edge_type == 11) {
    variance(the_image, out_image, rows, cols, bits_per_pixel, 0, 0);
  }
  for (i = 0; i < rows; i++)
    for (j = 0; j < cols; j++)
      the_image[i][j] = out_image[i][j];
  zero_histogram(histogram, 255 + 1);
  calculate_histogram(the_image, histogram, rows, cols);
  find_cutoff_point(histogram, percent, &cutoff, rows, cols);
  threshold_image_array(the_image, out_image, 255, cutoff, set_value, rows, cols);
  if (erode != 0) {
    for (i = 0; i < rows; i++)
      for (j = 0; j < cols; j++)
        the_image[i][j] = out_image[i][j];
    erode_image_array(the_image, out_image, set_value, erode, rows, cols);
  }
  read_image_array(in_name, the_image);
  for (i = 0; i < rows; i++)
    for (j = 0; j < cols; j++)
      if (out_image[i][j] == set_value)
        the_image[i][j] = -50;
  pixel_grow(the_image, out_image, diff, min_area, max_area, rows, cols);
  return (1);
}
```