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

```asm
<overlapped_adaptive_threshold>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x28,%rsp
  mov    %rdi,-0x88(%rbp)
  mov    %esi,-0x8c(%rbp)
  mov    %rdx,-0x98(%rbp)
  mov    %ecx,-0x90(%rbp)
  mov    %r8d,-0x9c(%rbp)
  mov    %r9d,-0xa0(%rbp)
  mov    -0xa0(%rbp),%eax
  mov    %eax,-0x44(%rbp)
  mov    -0xa0(%rbp),%eax
  mov    %eax,-0x40(%rbp)
  movl   $0x0,-0x70(%rbp)
  jmp    L42
L64:
  movl   $0x0,-0x74(%rbp)
  jmp    L82
L238:
  mov    -0x74(%rbp),%edx
  mov    -0x44(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x6c(%rbp)
  mov    -0x6c(%rbp),%eax
  cmp    -0x90(%rbp),%eax
  jle    L74
  mov    -0x90(%rbp),%eax
  mov    %eax,-0x6c(%rbp)
L74:
  mov    -0x70(%rbp),%edx
  mov    -0x40(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x68(%rbp)
  mov    -0x68(%rbp),%eax
  cmp    -0x9c(%rbp),%eax
  jle    L126
  mov    -0x9c(%rbp),%eax
  mov    %eax,-0x68(%rbp)
L126:
  movl   $0x0,-0x64(%rbp)
  mov    -0x68(%rbp),%eax
  sub    -0x70(%rbp),%eax
  mov    %eax,%edx
  mov    -0x6c(%rbp),%eax
  sub    -0x74(%rbp),%eax
  imul   %edx,%eax
  mov    %eax,-0x3c(%rbp)
  mov    -0x70(%rbp),%eax
  mov    %eax,-0x60(%rbp)
  jmp    L19
L102:
  mov    -0x60(%rbp),%eax
  imul   -0x90(%rbp),%eax
  mov    %eax,%edx
  mov    -0x74(%rbp),%eax
  add    %edx,%eax
  imul   -0x8c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x74(%rbp),%eax
  mov    %eax,-0x5c(%rbp)
  jmp    L21
L135:
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    %eax,-0x64(%rbp)
  mov    -0x8c(%rbp),%eax
  cltq
  add    %rax,-0x30(%rbp)
  addl   $0x1,-0x5c(%rbp)
L21:
  mov    -0x5c(%rbp),%eax
  cmp    -0x6c(%rbp),%eax
  jl     L135
  addl   $0x1,-0x60(%rbp)
L19:
  mov    -0x60(%rbp),%eax
  cmp    -0x68(%rbp),%eax
  jl     L102
  mov    -0x64(%rbp),%eax
  cltd
  idivl  -0x3c(%rbp)
  mov    %eax,-0x58(%rbp)
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x64(%rbp),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x3c(%rbp),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x18(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x38(%rbp)
  mov    -0x70(%rbp),%eax
  mov    %eax,-0x60(%rbp)
  jmp    L237
L154:
  mov    -0x60(%rbp),%eax
  imul   -0x90(%rbp),%eax
  mov    %eax,%edx
  mov    -0x74(%rbp),%eax
  add    %edx,%eax
  imul   -0x8c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x74(%rbp),%eax
  mov    %eax,-0x5c(%rbp)
  jmp    L84
L229:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  subsd  -0x18(%rbp),%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  mulsd  %xmm0,%xmm0
  movsd  -0x38(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x38(%rbp)
  mov    -0x8c(%rbp),%eax
  cltq
  add    %rax,-0x28(%rbp)
  addl   $0x1,-0x5c(%rbp)
L84:
  mov    -0x5c(%rbp),%eax
  cmp    -0x6c(%rbp),%eax
  jl     L229
  addl   $0x1,-0x60(%rbp)
L237:
  mov    -0x60(%rbp),%eax
  cmp    -0x68(%rbp),%eax
  jl     L154
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x3c(%rbp),%xmm1
  movsd  -0x38(%rbp),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x10(%rbp)
  movsd  D5(%rip),%xmm0
  comisd -0x10(%rbp),%xmm0
  jbe    L133
  subl   $0xa,-0x58(%rbp)
L133:
  mov    -0x40(%rbp),%eax
  lea    0x3(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x2,%eax
  mov    %eax,%edx
  mov    -0x70(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x54(%rbp)
  mov    -0x70(%rbp),%edx
  mov    -0x40(%rbp),%eax
  lea    (%rdx,%rax,1),%ecx
  mov    -0x40(%rbp),%eax
  lea    0x3(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x2,%eax
  neg    %eax
  add    %ecx,%eax
  mov    %eax,-0x50(%rbp)
  mov    -0x50(%rbp),%eax
  cmp    -0x68(%rbp),%eax
  jle    L226
  mov    -0x68(%rbp),%eax
  mov    %eax,-0x50(%rbp)
L226:
  cmpl   $0x0,-0x70(%rbp)
  jne    L100
  movl   $0x0,-0x54(%rbp)
L100:
  mov    -0x44(%rbp),%eax
  lea    0x3(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x2,%eax
  mov    %eax,%edx
  mov    -0x74(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4c(%rbp)
  mov    -0x74(%rbp),%edx
  mov    -0x44(%rbp),%eax
  lea    (%rdx,%rax,1),%ecx
  mov    -0x44(%rbp),%eax
  lea    0x3(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x2,%eax
  neg    %eax
  add    %ecx,%eax
  mov    %eax,-0x48(%rbp)
  mov    -0x48(%rbp),%eax
  cmp    -0x6c(%rbp),%eax
  jle    L67
  mov    -0x6c(%rbp),%eax
  mov    %eax,-0x48(%rbp)
L67:
  cmpl   $0x0,-0x74(%rbp)
  jne    L165
  movl   $0x0,-0x4c(%rbp)
L165:
  mov    -0x54(%rbp),%eax
  mov    %eax,-0x60(%rbp)
  jmp    L123
L125:
  mov    -0x60(%rbp),%eax
  imul   -0x90(%rbp),%eax
  mov    %eax,%edx
  mov    -0x4c(%rbp),%eax
  add    %edx,%eax
  imul   -0x8c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x4c(%rbp),%eax
  mov    %eax,-0x5c(%rbp)
  jmp    L176
L43:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  cmp    %eax,-0x58(%rbp)
  jge    L17
  mov    -0x60(%rbp),%eax
  imul   -0x90(%rbp),%eax
  mov    %eax,%edx
  mov    -0x5c(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x98(%rbp),%rax
  add    %rdx,%rax
  movb   $0xff,(%rax)
  jmp    L157
L17:
  mov    -0x60(%rbp),%eax
  imul   -0x90(%rbp),%eax
  mov    %eax,%edx
  mov    -0x5c(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x98(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L157:
  mov    -0x8c(%rbp),%eax
  cltq
  add    %rax,-0x20(%rbp)
  addl   $0x1,-0x5c(%rbp)
L176:
  mov    -0x5c(%rbp),%eax
  cmp    -0x48(%rbp),%eax
  jl     L43
  addl   $0x1,-0x60(%rbp)
L123:
  mov    -0x60(%rbp),%eax
  cmp    -0x50(%rbp),%eax
  jl     L125
  mov    -0x44(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  add    %eax,-0x74(%rbp)
L82:
  mov    -0x74(%rbp),%eax
  cmp    -0x90(%rbp),%eax
  jl     L238
  mov    -0x40(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  add    %eax,-0x70(%rbp)
L42:
  mov    -0x70(%rbp),%eax
  cmp    -0x9c(%rbp),%eax
  jl     L64
  nop
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D5
type_guessed: byte[8]

tool: {"D5": [0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x40]}

assistant: ```c
void overlapped_adaptive_threshold(const unsigned char *source, int source_stride, unsigned char *dest, int width, int height, int tile_size) {
  int x_step = tile_size;
  int y_step = tile_size;
  int x, y;
  for (y = 0; y < height; y += y_step / 2) {
    for (x = 0; x < width; x += x_step / 2) {
      int xxmax, yymax, sum, count, yy, xx;
      int mean;
      double fmean, sd, fsd;
      int ys, ymax, xs, xmax;
      xxmax = x + x_step;
      if (xxmax > width)
        xxmax = width;
      yymax = y + y_step;
      if (yymax > height)
        yymax = height;
      sum = 0;
      count = (yymax - y) * (xxmax - x);
      for (yy = y; yy < yymax; ++yy) {
        const unsigned char *p = source + (yy * width + x) * source_stride;
        for (xx = x; xx < xxmax; ++xx) {
          sum += *p;
          p += source_stride;
        }
      }
      mean = sum / count;
      fmean = (double)sum / (double)count;
      sd = 0;
      for (yy = y; yy < yymax; ++yy) {
        const unsigned char *p = source + (yy * width + x) * source_stride;
        for (xx = x; xx < xxmax; ++xx) {
          double z = *p - fmean;
          sd += z * z;
          p += source_stride;
        }
      }
      fsd = (double)sd / (double)count;
      if (fsd < 100)
        mean -= 10;
      ys = y + y_step / 4;
      ymax = (y + y_step) - y_step / 4;
      if (ymax > yymax)
        ymax = yymax;
      if (y == 0)
        ys = 0;
      xs = x + x_step / 4;
      xmax = (x + x_step) - x_step / 4;
      if (xmax > xxmax)
        xmax = xxmax;
      if (x == 0)
        xs = 0;
      for (yy = ys; yy < ymax; ++yy) {
        const unsigned char *p = source + (yy * width + xs) * source_stride;
        for (xx = xs; xx < xmax; ++xx) {
          if (*p > mean) {
            dest[(yy * width + xx)] = 255;
          } else {
            dest[(yy * width + xx)] = 0;
          }
          p += source_stride;
        }
      }
    }
  }
}
```