user: Please show me the C implementation that matches the assembly code listed below:

```asm
<estimate_thresh>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x460,%rsp
  mov    %rdi,-0x438(%rbp)
  mov    %esi,-0x43c(%rbp)
  mov    %edx,-0x440(%rbp)
  mov    %ecx,-0x444(%rbp)
  mov    %r8,-0x450(%rbp)
  mov    %r9,-0x458(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x418(%rbp)
  jmp    L32
L121:
  mov    -0x418(%rbp),%eax
  cltq
  movl   $0x0,-0x410(%rbp,%rax,4)
  addl   $0x1,-0x418(%rbp)
L32:
  cmpl   $0xff,-0x418(%rbp)
  jle    L121
  movl   $0x0,-0x41c(%rbp)
  jmp    L137
L57:
  movl   $0x1,-0x424(%rbp)
  jmp    L79
L99:
  movl   $0x1,-0x420(%rbp)
  jmp    L62
L96:
  mov    -0x440(%rbp),%eax
  imul   -0x420(%rbp),%eax
  mov    %eax,%edx
  mov    -0x424(%rbp),%eax
  add    %eax,%edx
  mov    -0x43c(%rbp),%eax
  imul   -0x440(%rbp),%eax
  imul   -0x41c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x438(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  mov    -0x410(%rbp,%rdx,4),%edx
  add    $0x1,%edx
  cltq
  mov    %edx,-0x410(%rbp,%rax,4)
  addl   $0x1,-0x420(%rbp)
L62:
  mov    -0x43c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x420(%rbp)
  jl     L96
  addl   $0x1,-0x424(%rbp)
L79:
  mov    -0x440(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x424(%rbp)
  jl     L99
  addl   $0x1,-0x41c(%rbp)
L137:
  mov    -0x41c(%rbp),%eax
  cmp    -0x444(%rbp),%eax
  jl     L57
  mov    -0x43c(%rbp),%edx
  mov    -0x440(%rbp),%eax
  cmp    %eax,%edx
  cmovge %edx,%eax
  mov    %eax,-0x420(%rbp)
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x420(%rbp),%xmm1
  movsd  D12(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,-0x420(%rbp)
  movl   $0xff,-0x418(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x414(%rbp)
  jmp    L1
L115:
  subl   $0x1,-0x418(%rbp)
  cmpl   $0x0,-0x418(%rbp)
  js     L55
  mov    -0x418(%rbp),%eax
  cltq
  mov    -0x410(%rbp,%rax,4),%eax
  add    %eax,-0x414(%rbp)
L1:
  mov    -0x414(%rbp),%eax
  cmp    -0x420(%rbp),%eax
  jl     L115
  jmp    L111
L55:
  nop
L111:
  cmpl   $0x0,-0x418(%rbp)
  jne    L43
  movl   $0xff,-0x418(%rbp)
L43:
  mov    -0x458(%rbp),%rax
  mov    -0x418(%rbp),%edx
  mov    %edx,(%rax)
  movl   $0x0,-0x424(%rbp)
  jmp    L134
L113:
  addl   $0x1,-0x424(%rbp)
  cmpl   $0xff,-0x424(%rbp)
  jg     L159
L134:
  mov    -0x424(%rbp),%eax
  cltq
  mov    -0x410(%rbp,%rax,4),%eax
  test   %eax,%eax
  je     L113
  jmp    L151
L159:
  nop
L151:
  mov    -0x418(%rbp),%edx
  mov    -0x424(%rbp),%eax
  add    %edx,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  D19(%rip),%xmm1
  divsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%edx
  mov    -0x450(%rbp),%rax
  mov    %edx,(%rax)
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L46
  call   <__stack_chk_fail@plt>
L46:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D12
data_type: f64
name: unpack_data
arguments: data_label: D19
data_type: f64

tool: D12: 0.8

tool: D19: 2

assistant: ```c
void estimate_thresh(int *mag, int width, int height, int depth, int *low, int *high) {
  int i, j, d, k, hist[256], count;
  for (k = 0; k < 256; k++)
    hist[k] = 0;
  for (d = 0; d < depth; d++) {
    for (i = 1; i < height - 1; i++) {
      for (j = 1; j < width - 1; j++) {
        hist[mag[((height) * (j) + (i) + (width) * (height) * (d))]]++;
      }
    }
  }
  j = (width < height) ? height : width;
  j = (int)(0.8 * j);
  k = 255;
  count = hist[255];
  while (count < j) {
    k--;
    if (k < 0)
      break;
    count = count + hist[k];
  }
  if (k == 0)
    k = 255;
  *high = k;
  i = 0;
  while (hist[i] == 0) {
    i++;
    if (i > 255)
      break;
  }
  *low = (k + i) / 2.0;
}
```