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

```asm
<fix_edges>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  mov    -0x1c(%rbp),%ecx
  mov    -0x30(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rax,%rsi
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L4
L36:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  shl    $0x3,%rdx
  lea    -0x8(%rdx),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  add    %rdx,%rdx
  sub    $0x2,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  mov    -0x30(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x8(%rbp),%eax
  sub    $0x1,%eax
  movslq %eax,%rsi
  mov    %rdx,%rax
  sub    %rsi,%rax
  add    %rax,%rax
  add    %rcx,%rax
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  shl    $0x3,%rdx
  lea    -0x8(%rdx),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x8(%rbp),%edx
  sub    $0x1,%edx
  movslq %edx,%rsi
  mov    -0x30(%rbp),%rdx
  sub    %rsi,%rdx
  add    %rdx,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  mov    -0x28(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x8(%rbp),%eax
  sub    $0x1,%eax
  movslq %eax,%rcx
  mov    %rdx,%rax
  sub    %rcx,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  sub    $0x1,%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  sub    %rcx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  add    %rdx,%rdx
  sub    $0x2,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  mov    -0x28(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x8(%rbp),%eax
  sub    $0x1,%eax
  movslq %eax,%rcx
  mov    %rdx,%rax
  sub    %rcx,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  mov    -0x30(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x8(%rbp),%eax
  sub    $0x1,%eax
  movslq %eax,%rsi
  mov    %rdx,%rax
  sub    %rsi,%rax
  add    %rax,%rax
  add    %rcx,%rax
  mov    -0x8(%rbp),%edx
  sub    $0x1,%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  sub    %rcx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x8(%rbp),%edx
  sub    $0x1,%edx
  movslq %edx,%rsi
  mov    -0x30(%rbp),%rdx
  sub    %rsi,%rdx
  add    %rdx,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  subl   $0x1,-0x8(%rbp)
L4:
  cmpl   $0x0,-0x8(%rbp)
  jg     L36
  movl   $0x0,-0x8(%rbp)
  jmp    L29
L46:
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x4(%rbp)
  jmp    L22
L35:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x4(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x4(%rbp),%edx
  movslq %edx,%rdx
  add    %rdx,%rdx
  sub    $0x2,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x4(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x30(%rbp),%rax
  sub    %rcx,%rax
  add    %rax,%rax
  sub    $0x2,%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x4(%rbp),%edx
  movslq %edx,%rsi
  mov    -0x30(%rbp),%rdx
  sub    %rsi,%rdx
  add    %rdx,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  subl   $0x1,-0x4(%rbp)
L22:
  cmpl   $0x0,-0x4(%rbp)
  jg     L35
  addl   $0x1,-0x8(%rbp)
L29:
  mov    -0x8(%rbp),%eax
  cltq
  cmp    %rax,-0x28(%rbp)
  jg     L46
  movl   $0x0,-0x4(%rbp)
  jmp    L86
L63:
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L12
L47:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x4(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  shl    $0x3,%rdx
  lea    -0x8(%rdx),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x4(%rbp),%edx
  movslq %edx,%rdx
  add    %rdx,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  sub    %rdx,%rax
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x4(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  sub    %rcx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x4(%rbp),%edx
  movslq %edx,%rdx
  add    %rdx,%rdx
  add    %rcx,%rdx
  movzwl (%rax),%eax
  mov    %ax,(%rdx)
  subl   $0x1,-0x8(%rbp)
L12:
  cmpl   $0x0,-0x8(%rbp)
  jg     L47
  addl   $0x1,-0x4(%rbp)
L86:
  mov    -0x4(%rbp),%eax
  cltq
  cmp    %rax,-0x30(%rbp)
  jg     L63
  mov    $0x1,%eax
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D4
type_guessed: string

tool: D4: 
FIX> rows=%ld cols=%ld w=%d

assistant: ```c
int fix_edges(im, w, rows, cols)
int w;
short **im;
long rows, cols;
{
  int i, j;
  printf("\nFIX> rows=%ld cols=%ld w=%d", rows, cols, w);
  for (i = w; i > 0; i--) {
    im[i - 1][i - 1] = im[i][i];
    im[i - 1][cols - (i - 1)] = im[i][cols - 1 - (i - 1)];
    im[rows - (i - 1)][i - 1] = im[rows - 1 - (i - 1)][i];
    im[rows - (i - 1)][cols - (i - 1)] = im[rows - 1 - (i - 1)][cols - 1 - (i - 1)];
  }
  for (i = 0; i < rows; i++) {
    for (j = w; j > 0; j--) {
      im[i][j - 1] = im[i][j];
      im[i][cols - j] = im[i][cols - j - 1];
    }
  }
  for (j = 0; j < cols; j++) {
    for (i = w; i > 0; i--) {
      im[i - 1][j] = im[i][j];
      im[rows - i][j] = im[rows - i - 1][j];
    }
  }
  return (1);
}
```