user: Converte this assembly snippet into its equivalent C code:

```asm
<estimate_thresh>:
  endbr64
  push   %r15
  mov    %rdi,%r10
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %ecx,%ebx
  mov    $0x80,%ecx
  sub    $0x438,%rsp
  mov    %esi,0x8(%rsp)
  lea    0x20(%rsp),%rbp
  mov    %edx,0xc(%rsp)
  mov    %rbp,%rdi
  mov    %r8,0x10(%rsp)
  mov    %r9,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x428(%rsp)
  xor    %eax,%eax
  rep stos %rax,%es:(%rdi)
  test   %ebx,%ebx
  jle    L34
  mov    %esi,%r15d
  movslq %edx,%r14
  lea    -0x1(%rdx),%r11d
  xor    %r13d,%r13d
  imul   %edx,%r15d
  lea    0x0(,%r14,4),%rdi
  xor    %r12d,%r12d
  add    $0x1,%r14
  lea    -0x1(%rsi),%esi
  nopw   0x0(%rax,%rax,1)
L19:
  cmp    $0x1,%r11d
  jle    L83
  movslq %r13d,%rax
  mov    $0x1,%r8d
  add    %r14,%rax
  lea    (%r10,%rax,4),%r9
  cs nopw 0x0(%rax,%rax,1)
L113:
  mov    %r9,%rdx
  mov    $0x1,%eax
  cmp    $0x1,%esi
  jle    L125
  nopl   (%rax)
L51:
  movslq (%rdx),%rcx
  add    $0x1,%eax
  add    %rdi,%rdx
  addl   $0x1,0x20(%rsp,%rcx,4)
  cmp    %esi,%eax
  jne    L51
L125:
  add    $0x1,%r8d
  add    $0x4,%r9
  cmp    %r11d,%r8d
  jne    L113
L83:
  add    $0x1,%r12d
  add    %r15d,%r13d
  cmp    %r12d,%ebx
  jne    L19
L34:
  mov    0x8(%rsp),%ebx
  mov    0xc(%rsp),%eax
  pxor   %xmm0,%xmm0
  mov    $0xff,%ecx
  mov    0x41c(%rsp),%edx
  cmp    %eax,%ebx
  cmovge %ebx,%eax
  cvtsi2sd %eax,%xmm0
  mulsd  D13(%rip),%xmm0
  mov    $0xfe,%eax
  cvttsd2si %xmm0,%esi
  cmp    %edx,%esi
  jg     L115
  jmp    L79
  nopl   0x0(%rax,%rax,1)
L87:
  sub    $0x1,%rax
  jb     L89
L115:
  add    0x0(%rbp,%rax,4),%edx
  mov    %eax,%ecx
  cmp    %edx,%esi
  jg     L87
  test   %eax,%eax
  mov    $0xff,%eax
  cmove  %eax,%ecx
L79:
  mov    0x18(%rsp),%rax
  mov    %ecx,(%rax)
  xor    %eax,%eax
  jmp    L77
  nopl   (%rax)
L86:
  add    $0x1,%rax
  cmp    $0x100,%rax
  je     L9
L77:
  mov    0x0(%rbp,%rax,4),%esi
  mov    %eax,%edx
  test   %esi,%esi
  je     L86
L7:
  add    %ecx,%edx
  pxor   %xmm0,%xmm0
  mov    0x10(%rsp),%rbx
  cvtsi2sd %edx,%xmm0
  mulsd  D6(%rip),%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,(%rbx)
  mov    0x428(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L11
  add    $0x438,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L89:
  mov    $0xffffffff,%ecx
  jmp    L79
L9:
  mov    $0x100,%edx
  jmp    L7
L11:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D13
data_type: f64
name: disassemble_data
arguments: label: D6
data_type: byte[8]

tool: D13: 0.8

tool: {"D6": [0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f]}

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