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

```asm
<core_max_pool>:
  endbr64
  push   %r15
  mov    %r8,%r15
  push   %r14
  mov    %edi,%r14d
  push   %r13
  push   %r12
  push   %rbp
  mov    %r9d,%ebp
  push   %rbx
  sub    $0x158,%rsp
  mov    %rcx,0x30(%rsp)
  mov    0x190(%rsp),%ecx
  mov    %rsi,0x18(%rsp)
  mov    %rdx,0x20(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x148(%rsp)
  xor    %eax,%eax
  lea    0x100(%rsp),%rax
  mov    %rax,0x10(%rsp)
  test   %edi,%edi
  jle    L69
  lea    -0x1(%rdi),%edx
  lea    0x104(%rsp,%rdx,4),%rdx
  nopl   0x0(%rax,%rax,1)
L71:
  mov    %ecx,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L71
L69:
  mov    0x10(%rsp),%rsi
  mov    %r14d,%edi
  lea    0x40(%rsp),%r13
  call   <size_from_shape2@plt>
  mov    0x30(%rsp),%rsi
  mov    %r14d,%edi
  mov    %eax,0xc(%rsp)
  call   <size_from_shape2@plt>
  mov    %r13,%rsi
  mov    %r14d,%edi
  mov    %eax,%ebx
  call   <indices_reset@plt>
  test   %ebx,%ebx
  jle    L91
  lea    -0x1(%rbx),%eax
  mov    %r15,0x28(%rsp)
  lea    0x4(%r15,%rax,4),%rax
  lea    0xc0(%rsp),%r15
  mov    %rax,0x38(%rsp)
  mov    %r15,%r12
  mov    %r14d,%r15d
  mov    %ebp,%r14d
  mov    %r13,%rbp
  nopl   0x0(%rax)
L93:
  mov    %r12,%rsi
  mov    %r15d,%edi
  call   <indices_reset@plt>
  mov    0xc(%rsp),%eax
  movss  D15(%rip),%xmm0
  test   %eax,%eax
  jle    L29
  movsd  D19(%rip),%xmm2
  movl   $0x0,0x8(%rsp)
  movslq %r15d,%r13
  mov    %rbp,%rax
  lea    0x80(%rsp),%rbx
  mov    %r14d,%ebp
  mov    %r13,%r14
  mov    %r15d,%r13d
  movsd  %xmm2,(%rsp)
  mov    %r12,%r15
  mov    %rax,%r12
  nopl   0x0(%rax)
L16:
  xor    %eax,%eax
  test   %r13d,%r13d
  jle    L75
  nopw   0x0(%rax,%rax,1)
L14:
  mov    (%r12,%rax,4),%edx
  imul   %ebp,%edx
  add    (%r15,%rax,4),%edx
  mov    %edx,(%rbx,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%r14
  jne    L14
L75:
  mov    0x18(%rsp),%rsi
  mov    %rbx,%rdx
  mov    %r13d,%edi
  call   <cnnc_inline_idxs_to_pos@plt>
  test   %eax,%eax
  js     L22
  mov    0x20(%rsp),%rcx
  cltq
  pxor   %xmm0,%xmm0
  cvtss2sd (%rcx,%rax,4),%xmm0
  maxsd  (%rsp),%xmm0
  movsd  %xmm0,(%rsp)
L22:
  mov    0x10(%rsp),%rsi
  mov    %r15,%rdx
  mov    %r13d,%edi
  call   <indices_inc@plt>
  addl   $0x1,0x8(%rsp)
  mov    0x8(%rsp),%eax
  cmp    %eax,0xc(%rsp)
  jne    L16
  mov    %ebp,%r14d
  pxor   %xmm0,%xmm0
  mov    %r12,%rbp
  mov    %r15,%r12
  mov    %r13d,%r15d
  cvtsd2ss (%rsp),%xmm0
L29:
  mov    0x28(%rsp),%rbx
  mov    0x30(%rsp),%rsi
  mov    %rbp,%rdx
  mov    %r15d,%edi
  movss  %xmm0,(%rbx)
  call   <indices_inc@plt>
  mov    %rbx,%rax
  add    $0x4,%rax
  mov    %rax,0x28(%rsp)
  cmp    %rax,0x38(%rsp)
  jne    L93
L91:
  mov    0x148(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  add    $0x158,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L4:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D15
datatype: byte[4]
name: disassemble_data
arguments: tag: D19
datatype: byte[8]

tool: {"D15": [0xca,0xf2,0x49,0xf1]}

tool: {"D19": [0xea,0x8c,0xa0,0x39,0x59,0x3e,0x29,0xc6]}

assistant: ```c
void core_max_pool(int rank, int *input_shape, float *input_ptr, int *output_shape, float *output_ptr, int tile_by, int pool_by) {
  int i, j, k, pool_size, output_size, pos;
  int output_idx[16], input_idx[16], pool_idx[16], pool_shape[16];
  double max;
  for (i = 0; i < rank; i++) {
    pool_shape[i] = pool_by;
  }
  pool_size = size_from_shape2(rank, pool_shape);
  output_size = size_from_shape2(rank, output_shape);
  indices_reset(rank, output_idx);
  for (i = 0; i < output_size; i++) {
    max = -1e30;
    indices_reset(rank, pool_idx);
    for (j = 0; j < pool_size; j++) {
      for (k = 0; k < rank; k++) {
        input_idx[k] = output_idx[k] * tile_by + pool_idx[k];
      }
      pos = cnnc_inline_idxs_to_pos(rank, input_shape, input_idx);
      if (pos >= 0 && input_ptr[pos] > max) {
        max = input_ptr[pos];
      }
      indices_inc(rank, pool_shape, pool_idx);
    }
    output_ptr[i] = max;
    indices_inc(rank, output_shape, output_idx);
  }
  return;
}
```