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

```asm
<Extend>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %esi,%r11d
  mov    %edx,%eax
  mov    %ecx,%r13d
  mov    %r8d,-0x24(%rsp)
  mov    0x38(%rsp),%ebx
  mov    %esi,%r10d
  imul   %edx,%r10d
  test   %ecx,%ecx
  jle    L606
  lea    -0x1(%rsi),%r14d
  mov    %r10d,%ecx
  sub    %esi,%ecx
  test   %r8d,%r8d
  mov    $0x0,%edx
  cmovg  %ecx,%edx
  mov    %edx,-0xc(%rsp)
  lea    -0x1(%r13),%esi
  mov    %esi,-0x18(%rsp)
L361:
  mov    -0x24(%rsp),%esi
  lea    -0x1(%rsi),%edx
  test   %esi,%esi
  mov    $0xffffffff,%r8d
  cmovs  %esi,%r8d
  add    $0x1,%r8d
  test   %esi,%esi
  cmovg  %edx,%r8d
  imul   %r11d,%r8d
  test   %r13d,%r13d
  js     L215
  lea    -0x1(%r11),%ecx
  mov    %ecx,%edx
  shr    $0x1f,%edx
  add    %ecx,%edx
  sar    %edx
  mov    %edx,-0x30(%rsp)
L680:
  cmpl   $0x0,-0x24(%rsp)
  js     L356
  lea    -0x1(%rax),%edx
  mov    %edx,%eax
  shr    $0x1f,%eax
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x10(%rsp)
L313:
  test   %r10d,%r10d
  jle    L256
  mov    %r9,%rax
  lea    -0x1(%r10),%edx
  lea    0x8(%r9,%rdx,8),%rdx
L30:
  movq   $0x0,(%rax)
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L30
  test   %ebx,%ebx
  jne    L113
  mov    -0xc(%rsp),%esi
  mov    %esi,-0x2c(%rsp)
  mov    %r14d,-0x10(%rsp)
  lea    (%rsi,%r14,1),%eax
  cltq
  lea    (%r9,%rax,8),%r13
  mov    %r8d,%eax
  sub    %esi,%eax
  mov    %eax,-0x24(%rsp)
  movslq %r11d,%rax
  shl    $0x3,%rax
  mov    %rax,-0x20(%rsp)
  mov    -0x18(%rsp),%eax
  mov    %eax,-0x14(%rsp)
  lea    (%rax,%r11,1),%r15d
  mov    %rdi,%r12
  mov    %r10d,-0x28(%rsp)
  jmp    L372
L215:
  mov    %r11d,%edx
  shr    $0x1f,%edx
  add    %r11d,%edx
  sar    %edx
  mov    %edx,-0x30(%rsp)
  jmp    L680
L356:
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x10(%rsp)
  jmp    L313
L33:
  lea    (%rbx,%r11,1),%eax
  cmp    %ebx,%eax
  jle    L339
  mov    -0x14(%rsp),%esi
  sub    -0x10(%rsp),%esi
  mov    %r15d,%ebp
  sub    %ebx,%ebp
  mov    %r12,%rdx
  mov    -0x18(%rsp),%eax
  mov    -0x24(%rsp),%ecx
  mov    %ecx,%edi
  neg    %edi
  cmovs  %ecx,%edi
  mov    -0xc(%rsp),%ecx
  sub    %edi,%ecx
  mov    %ecx,%r10d
  neg    %r10d
  cmovs  %ecx,%r10d
  jmp    L480
L159:
  mov    %esi,%edx
  neg    %edx
  cmovs  %esi,%edx
  mov    %r14d,%edi
  sub    %edx,%edi
  mov    %edi,%edx
  neg    %edx
  cmovs  %edi,%edx
  add    %r8d,%edx
  movslq %edx,%rdx
  lea    (%r9,%rdx,8),%rdx
  movsd  (%rdx),%xmm0
  subsd  (%rcx),%xmm0
  movsd  %xmm0,(%rdx)
  movsd  (%rcx),%xmm0
  addsd  %xmm0,%xmm0
  addsd  0x0(%rbp),%xmm0
  movsd  %xmm0,0x0(%rbp)
L314:
  add    $0x1,%eax
  add    $0x8,%rcx
  add    $0x1,%esi
  cmp    %r10d,%eax
  je     L339
L633:
  test   %eax,%eax
  js     L159
  cmp    %eax,%r11d
  jle    L159
  mov    -0x30(%rsp),%edi
  lea    (%rax,%rdi,1),%edx
  movslq %edx,%rdx
  lea    (%r9,%rdx,8),%rdx
  movsd  (%rdx),%xmm0
  addsd  (%rcx),%xmm0
  movsd  %xmm0,(%rdx)
  jmp    L314
L131:
  mov    %esi,%ecx
  neg    %ecx
  cmovs  %esi,%ecx
  mov    %r14d,%edi
  sub    %ecx,%edi
  mov    %edi,%ecx
  neg    %ecx
  cmovs  %edi,%ecx
  add    %r10d,%ecx
  movslq %ecx,%rcx
  lea    (%r9,%rcx,8),%rcx
  movsd  (%rcx),%xmm0
  subsd  (%rdx),%xmm0
  movsd  %xmm0,(%rcx)
  movsd  (%rdx),%xmm0
  addsd  %xmm0,%xmm0
  addsd  0x0(%r13),%xmm0
  movsd  %xmm0,0x0(%r13)
L340:
  add    $0x1,%eax
  add    $0x8,%rdx
  add    $0x1,%esi
  cmp    %eax,%ebp
  je     L339
L480:
  test   %eax,%eax
  js     L131
  cmp    %eax,%r11d
  jle    L131
  lea    (%r10,%rax,1),%ecx
  movslq %ecx,%rcx
  lea    (%r9,%rcx,8),%rcx
  movsd  (%rcx),%xmm0
  subsd  (%rdx),%xmm0
  movsd  %xmm0,(%rcx)
  mov    -0x2c(%rsp),%edi
  lea    (%rax,%rdi,1),%ecx
  movslq %ecx,%rcx
  lea    (%r9,%rcx,8),%rcx
  movsd  (%rdx),%xmm0
  addsd  %xmm0,%xmm0
  addsd  (%rcx),%xmm0
  movsd  %xmm0,(%rcx)
  jmp    L340
L339:
  add    %r11d,%ebx
  add    %r11d,%r8d
  add    %r11d,-0x24(%rsp)
  add    -0x20(%rsp),%r12
  add    %r11d,%r15d
  cmp    %ebx,-0x28(%rsp)
  jle    L359
L372:
  test   %r8d,%r8d
  js     L33
  cmp    %r8d,-0x28(%rsp)
  jle    L33
  lea    (%rbx,%r11,1),%eax
  cmp    %ebx,%eax
  jle    L339
  mov    %r8d,-0x30(%rsp)
  mov    -0x10(%rsp),%edi
  lea    (%rdi,%r8,1),%eax
  cltq
  lea    (%r9,%rax,8),%rbp
  mov    -0x14(%rsp),%esi
  sub    %edi,%esi
  mov    %r15d,%r10d
  sub    %ebx,%r10d
  mov    %r12,%rcx
  mov    -0x18(%rsp),%eax
  jmp    L633
L113:
  mov    %r8d,%eax
  neg    %eax
  cmovns %eax,%r8d
  mov    %r8d,%eax
  mov    %r8d,-0x28(%rsp)
  mov    -0x18(%rsp),%ebx
  mov    %ebx,%r8d
  neg    %r8d
  cmovs  %ebx,%r8d
  mov    -0xc(%rsp),%ebx
  mov    %ebx,%ebp
  sub    %eax,%ebp
  sub    %r10d,%ebx
  mov    %ebx,-0x2c(%rsp)
  cmp    %eax,%r10d
  jle    L403
  lea    (%r8,%r8,1),%r10d
  lea    (%r8,%r14,1),%ecx
  mov    %ecx,%edx
  sub    %r10d,%edx
  lea    -0x1(%rdx),%ebx
  mov    %ebx,-0x8(%rsp)
  mov    -0x30(%rsp),%ebx
  lea    (%rbx,%rbx,1),%edx
  mov    %ecx,%ebx
  sub    %edx,%ebx
  mov    %ebx,-0x20(%rsp)
  mov    %r14d,%esi
  sub    %r11d,%esi
  sub    %ecx,%r10d
  lea    0x1(%r14,%r10,1),%r15d
  mov    %r15d,-0x4(%rsp)
  lea    (%rsi,%r14,1),%r12d
  sub    %ecx,%edx
  add    %edx,%r12d
  sub    %r14d,%ebx
  mov    %ebx,-0x14(%rsp)
  jmp    L125
L257:
  mov    -0x8(%rsp),%ecx
  mov    %ecx,%r10d
  mov    %r15d,%eax
  neg    %eax
  cmovns %eax,%r15d
  mov    %ebp,%ebx
  neg    %ebx
  cmovs  %ebp,%ebx
  cmp    %esi,%ecx
  jle    L266
  mov    %r8d,-0x18(%rsp)
  mov    -0x4(%rsp),%r8d
  jmp    L196
L535:
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  add    %r15d,%eax
  cltq
  lea    (%r9,%rax,8),%rcx
  mov    %r10d,%edx
L626:
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  add    %ebx,%eax
  cltq
  movsd  (%rdi,%rax,8),%xmm0
  addsd  %xmm0,%xmm0
  addsd  (%rcx),%xmm0
  movsd  %xmm0,(%rcx)
  sub    $0x1,%edx
  cmp    %esi,%edx
  jne    L626
L527:
  sub    $0x1,%r10d
  cmp    %esi,%r10d
  jle    L47
L196:
  lea    (%r8,%r10,1),%edx
  cmp    %r10d,%esi
  jl     L535
  jmp    L527
L47:
  mov    -0x18(%rsp),%r8d
L266:
  sub    %r11d,%ebp
  cmp    -0x2c(%rsp),%ebp
  jle    L403
L125:
  mov    -0x28(%rsp),%eax
  lea    (%rax,%rbp,1),%r15d
  mov    %r14d,%edx
  sub    %r8d,%edx
  cmp    %r8d,%r11d
  jle    L579
  mov    %r15d,%ebx
  neg    %ebx
  cmovs  %r15d,%ebx
  mov    %ebp,%r10d
  neg    %r10d
  cmovs  %ebp,%r10d
L198:
  lea    (%r8,%rdx,1),%ecx
  mov    %ecx,%eax
  neg    %eax
  cmovs  %ecx,%eax
  add    %ebx,%eax
  cltq
  lea    (%r9,%rax,8),%rcx
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  add    %r10d,%eax
  cltq
  movsd  (%rcx),%xmm0
  addsd  (%rdi,%rax,8),%xmm0
  movsd  %xmm0,(%rcx)
  sub    $0x1,%edx
  cmp    %esi,%edx
  jg     L198
L579:
  test   %r13d,%r13d
  je     L266
  cmp    %r8d,-0x30(%rsp)
  je     L257
  cmp    %esi,-0x20(%rsp)
  jle    L266
  mov    %r14d,%edx
  mov    %r15d,%eax
  neg    %eax
  cmovns %eax,%r15d
  mov    %ebp,%ebx
  neg    %ebx
  cmovs  %ebp,%ebx
  mov    %esi,-0x18(%rsp)
  mov    -0x14(%rsp),%esi
L371:
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  add    %r15d,%eax
  cltq
  lea    (%r9,%rax,8),%r10
  lea    (%rsi,%rdx,1),%ecx
  mov    %ecx,%eax
  neg    %eax
  cmovs  %ecx,%eax
  add    %ebx,%eax
  cltq
  movsd  (%r10),%xmm0
  subsd  (%rdi,%rax,8),%xmm0
  movsd  %xmm0,(%r10)
  sub    $0x1,%edx
  cmp    %r12d,%edx
  jne    L371
  mov    -0x18(%rsp),%esi
  jmp    L266
L28:
  sub    %r11d,%ebp
  cmp    %ebp,-0x2c(%rsp)
  jge    L359
L145:
  mov    -0x28(%rsp),%eax
  lea    (%rax,%rbp,1),%r12d
  mov    %r14d,%edx
  sub    %r8d,%edx
  cmp    %r8d,%r11d
  jle    L390
  mov    %r12d,%r10d
  neg    %r10d
  cmovs  %r12d,%r10d
  mov    %ebp,%esi
  neg    %esi
  cmovs  %ebp,%esi
L329:
  lea    (%r8,%rdx,1),%ecx
  mov    %ecx,%eax
  neg    %eax
  cmovs  %ecx,%eax
  add    %r10d,%eax
  cltq
  lea    (%r9,%rax,8),%rcx
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  add    %esi,%eax
  cltq
  movsd  (%rcx),%xmm0
  subsd  (%rdi,%rax,8),%xmm0
  movsd  %xmm0,(%rcx)
  sub    $0x1,%edx
  cmp    %ebx,%edx
  jg     L329
L390:
  test   %r13d,%r13d
  je     L28
  cmp    %r8d,-0x30(%rsp)
  je     L28
  cmp    %ebx,-0x24(%rsp)
  jle    L28
  mov    %r14d,%edx
  mov    %r12d,%eax
  neg    %eax
  cmovns %eax,%r12d
  mov    %ebp,%r10d
  neg    %r10d
  cmovs  %ebp,%r10d
  mov    %r8d,-0x18(%rsp)
  mov    -0x20(%rsp),%r8d
L567:
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  add    %r12d,%eax
  cltq
  lea    (%r9,%rax,8),%rsi
  lea    (%r8,%rdx,1),%ecx
  mov    %ecx,%eax
  neg    %eax
  cmovs  %ecx,%eax
  add    %r10d,%eax
  cltq
  movsd  (%rsi),%xmm0
  subsd  (%rdi,%rax,8),%xmm0
  movsd  %xmm0,(%rsi)
  sub    $0x1,%edx
  cmp    %r15d,%edx
  jne    L567
  mov    -0x18(%rsp),%r8d
  jmp    L28
L534:
  add    %eax,%eax
  mov    -0xc(%rsp),%ebx
  mov    %ebx,%ecx
  sub    %eax,%ecx
  add    -0x28(%rsp),%ecx
  sub    %r11d,%ecx
  mov    -0x2c(%rsp),%r10d
  cmp    %r10d,%ecx
  jle    L359
  mov    -0x30(%rsp),%eax
  add    %eax,%eax
  lea    (%r8,%r14,1),%edx
  mov    %edx,%esi
  sub    %eax,%esi
  sub    $0x1,%esi
  mov    %esi,-0x24(%rsp)
  mov    %ecx,-0x28(%rsp)
  sub    %ecx,%ebx
  mov    %ebx,-0x18(%rsp)
  mov    %r14d,%esi
  sub    %r11d,%esi
  sub    %edx,%eax
  lea    0x1(%r14,%rax,1),%r15d
  mov    %r14d,-0x2c(%rsp)
  mov    %r10d,%r14d
  jmp    L345
L260:
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  add    %ebp,%eax
  cltq
  lea    (%r9,%rax,8),%rcx
  mov    %ebx,%edx
L166:
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  add    %r10d,%eax
  cltq
  movsd  (%rdi,%rax,8),%xmm0
  addsd  %xmm0,%xmm0
  addsd  (%rcx),%xmm0
  movsd  %xmm0,(%rcx)
  sub    $0x1,%edx
  cmp    %esi,%edx
  jne    L166
L493:
  sub    $0x1,%ebx
  cmp    %esi,%ebx
  jle    L603
L602:
  lea    (%r15,%rbx,1),%edx
  cmp    %ebx,%esi
  jl     L260
  jmp    L493
L603:
  sub    %r11d,%r12d
  cmp    %r14d,%r12d
  jle    L419
L254:
  mov    -0x2c(%rsp),%edx
  sub    %r8d,%edx
  cmp    %r8d,%r11d
  jle    L157
  mov    %r12d,%r10d
  neg    %r10d
  cmovs  %r12d,%r10d
L171:
  lea    (%r8,%rdx,1),%ecx
  mov    %ecx,%eax
  neg    %eax
  cmovs  %ecx,%eax
  add    %ebp,%eax
  cltq
  lea    (%r9,%rax,8),%rcx
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  add    %r10d,%eax
  cltq
  movsd  (%rdi,%rax,8),%xmm0
  addsd  %xmm0,%xmm0
  addsd  (%rcx),%xmm0
  movsd  %xmm0,(%rcx)
  sub    $0x1,%edx
  cmp    %esi,%edx
  jg     L171
L157:
  test   %r13d,%r13d
  je     L603
  cmp    %r8d,-0x30(%rsp)
  jne    L603
  mov    -0x24(%rsp),%eax
  mov    %eax,%ebx
  mov    %r12d,%r10d
  neg    %r10d
  cmovs  %r12d,%r10d
  cmp    %esi,%eax
  jg     L602
  jmp    L603
L419:
  sub    %r11d,-0x28(%rsp)
  mov    -0x28(%rsp),%eax
  cmp    %r14d,%eax
  jle    L359
L345:
  mov    -0x18(%rsp),%eax
  mov    -0x28(%rsp),%ebx
  add    %ebx,%eax
  mov    %ebx,%r12d
  mov    %eax,%ebp
  neg    %ebp
  cmovs  %eax,%ebp
  cmp    %ebx,%r14d
  jl     L254
  jmp    L419
L256:
  test   %ebx,%ebx
  je     L359
  mov    %r8d,%eax
  neg    %eax
  cmovns %eax,%r8d
  mov    %r8d,-0x28(%rsp)
  mov    -0x18(%rsp),%eax
  mov    %eax,%r8d
  neg    %r8d
  cmovs  %eax,%r8d
  mov    -0xc(%rsp),%eax
  sub    %r10d,%eax
  mov    %eax,-0x2c(%rsp)
L403:
  cmpl   $0x0,-0x24(%rsp)
  je     L359
  mov    -0x10(%rsp),%eax
  imul   %r11d,%eax
  mov    -0x28(%rsp),%ebx
  cmp    %ebx,%eax
  je     L534
  add    %eax,%eax
  mov    -0xc(%rsp),%r15d
  mov    %r15d,%esi
  sub    %eax,%esi
  add    %ebx,%esi
  cmp    %esi,-0x2c(%rsp)
  jge    L359
  mov    -0x30(%rsp),%eax
  lea    (%rax,%rax,1),%edx
  lea    (%r8,%r14,1),%ecx
  mov    %ecx,%r10d
  sub    %edx,%r10d
  mov    %r10d,-0x24(%rsp)
  mov    %esi,%ebp
  sub    %esi,%r15d
  mov    %r15d,-0x28(%rsp)
  mov    %r14d,%ebx
  sub    %r11d,%ebx
  lea    (%rbx,%r14,1),%esi
  sub    %ecx,%edx
  lea    (%rsi,%rdx,1),%r15d
  sub    %r14d,%r10d
  mov    %r10d,-0x20(%rsp)
  jmp    L145
L606:
  mov    %r10d,%ecx
  sub    %esi,%ecx
  cmpl   $0x0,-0x24(%rsp)
  mov    $0x0,%edx
  cmovg  %ecx,%edx
  mov    %edx,-0xc(%rsp)
  test   %r13d,%r13d
  mov    $0xffffffff,%edx
  cmovs  %r13d,%edx
  lea    0x1(%rdx),%esi
  mov    %esi,-0x18(%rsp)
  mov    $0x0,%r14d
  jmp    L361
L359:
  mov    $0x0,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int Extend(filt, x_dim, y_dim, x_pos, y_pos, result, r_or_e)
register double *filt, *result;
register int x_dim;
int y_dim, x_pos, y_pos, r_or_e;
{
  int filt_sz = x_dim * y_dim;
  register int y_filt, x_filt, y_res, x_res, y_tmp, x_tmp;
  register int x_base = (x_pos > 0) ? (x_dim - 1) : 0;
  register int y_base = x_dim * ((y_pos > 0) ? (y_dim - 1) : 0);
  int x_overhang = (x_pos > 0) ? (x_pos - 1) : ((x_pos < 0) ? (x_pos + 1) : 0);
  int y_overhang = x_dim * ((y_pos > 0) ? (y_pos - 1) : ((y_pos < 0) ? (y_pos + 1) : 0));
  int mx_pos = (x_pos < 0) ? (x_dim / 2) : ((x_dim - 1) / 2);
  int my_pos = x_dim * ((y_pos < 0) ? (y_dim / 2) : ((y_dim - 1) / 2));
  int i;
  for (i = 0; i < filt_sz; i++)
    result[i] = 0.0;
  if (r_or_e == 0)
    for (y_filt = 0, y_res = y_overhang; y_filt < filt_sz; y_filt += x_dim, y_res += x_dim)
      if ((y_res >= 0) && (y_res < filt_sz))
        for (x_filt = y_filt, x_res = x_overhang; x_filt < y_filt + x_dim; x_filt++, x_res++)
          if ((x_res >= 0) && (x_res < x_dim))
            result[y_res + x_res] += filt[x_filt];
          else {
            result[y_res + (((x_base - (((x_res - x_base) >= 0) ? (x_res - x_base) : (-(x_res - x_base)))) >= 0) ? (x_base - (((x_res - x_base) >= 0) ? (x_res - x_base) : (-(x_res - x_base)))) : (-(x_base - (((x_res - x_base) >= 0) ? (x_res - x_base) : (-(x_res - x_base))))))] -= filt[x_filt];
            result[y_res + x_base] += 2 * filt[x_filt];
          }
      else
        for (x_filt = y_filt, x_res = x_overhang; x_filt < y_filt + x_dim; x_filt++, x_res++)
          if ((x_res >= 0) && (x_res < x_dim)) {
            result[(((y_base - (((y_res - y_base) >= 0) ? (y_res - y_base) : (-(y_res - y_base)))) >= 0) ? (y_base - (((y_res - y_base) >= 0) ? (y_res - y_base) : (-(y_res - y_base)))) : (-(y_base - (((y_res - y_base) >= 0) ? (y_res - y_base) : (-(y_res - y_base)))))) + x_res] -= filt[x_filt];
            result[y_base + x_res] += 2 * filt[x_filt];
          } else {
            result[(((y_base - (((y_res - y_base) >= 0) ? (y_res - y_base) : (-(y_res - y_base)))) >= 0) ? (y_base - (((y_res - y_base) >= 0) ? (y_res - y_base) : (-(y_res - y_base)))) : (-(y_base - (((y_res - y_base) >= 0) ? (y_res - y_base) : (-(y_res - y_base)))))) + (((x_base - (((x_res - x_base) >= 0) ? (x_res - x_base) : (-(x_res - x_base)))) >= 0) ? (x_base - (((x_res - x_base) >= 0) ? (x_res - x_base) : (-(x_res - x_base)))) : (-(x_base - (((x_res - x_base) >= 0) ? (x_res - x_base) : (-(x_res - x_base))))))] -= filt[x_filt];
            result[y_base + x_base] += 2 * filt[x_filt];
          }
  else {
    y_overhang = (((y_overhang) >= 0) ? (y_overhang) : (-(y_overhang)));
    x_overhang = (((x_overhang) >= 0) ? (x_overhang) : (-(x_overhang)));
    for (y_res = y_base, y_filt = y_base - y_overhang; y_filt > y_base - filt_sz; y_filt -= x_dim, y_res -= x_dim) {
      for (x_res = x_base, x_filt = x_base - x_overhang; x_filt > x_base - x_dim; x_res--, x_filt--)
        result[(((y_res) >= 0) ? (y_res) : (-(y_res))) + (((x_res) >= 0) ? (x_res) : (-(x_res)))] += filt[(((y_filt) >= 0) ? (y_filt) : (-(y_filt))) + (((x_filt) >= 0) ? (x_filt) : (-(x_filt)))];
      if (x_pos != 0)
        if (x_overhang != mx_pos)
          for (x_res = x_base, x_filt = x_base - 2 * mx_pos + x_overhang; x_filt > x_base - x_dim; x_res--, x_filt--)
            result[(((y_res) >= 0) ? (y_res) : (-(y_res))) + (((x_res) >= 0) ? (x_res) : (-(x_res)))] -= filt[(((y_filt) >= 0) ? (y_filt) : (-(y_filt))) + (((x_filt) >= 0) ? (x_filt) : (-(x_filt)))];
        else
          for (x_res = x_base, x_filt = x_base - 2 * mx_pos + x_overhang - 1; x_filt > x_base - x_dim; x_res--, x_filt--)
            for (x_tmp = x_filt; x_tmp > x_base - x_dim; x_tmp--)
              result[(((y_res) >= 0) ? (y_res) : (-(y_res))) + (((x_res) >= 0) ? (x_res) : (-(x_res)))] += 2 * filt[(((y_filt) >= 0) ? (y_filt) : (-(y_filt))) + (((x_tmp) >= 0) ? (x_tmp) : (-(x_tmp)))];
    }
    if (y_pos != 0)
      if (y_overhang != my_pos)
        for (y_res = y_base, y_filt = y_base - 2 * my_pos + y_overhang; y_filt > y_base - filt_sz; y_filt -= x_dim, y_res -= x_dim) {
          for (x_res = x_base, x_filt = x_base - x_overhang; x_filt > x_base - x_dim; x_res--, x_filt--)
            result[(((y_res) >= 0) ? (y_res) : (-(y_res))) + (((x_res) >= 0) ? (x_res) : (-(x_res)))] -= filt[(((y_filt) >= 0) ? (y_filt) : (-(y_filt))) + (((x_filt) >= 0) ? (x_filt) : (-(x_filt)))];
          if ((x_pos != 0) && (x_overhang != mx_pos))
            for (x_res = x_base, x_filt = x_base - 2 * mx_pos + x_overhang; x_filt > x_base - x_dim; x_res--, x_filt--)
              result[(((y_res) >= 0) ? (y_res) : (-(y_res))) + (((x_res) >= 0) ? (x_res) : (-(x_res)))] -= filt[(((y_filt) >= 0) ? (y_filt) : (-(y_filt))) + (((x_filt) >= 0) ? (x_filt) : (-(x_filt)))];
        }
      else
        for (y_res = y_base, y_filt = y_base - 2 * my_pos + y_overhang - x_dim; y_filt > y_base - filt_sz; y_res -= x_dim, y_filt -= x_dim)
          for (y_tmp = y_filt; y_tmp > y_base - filt_sz; y_tmp -= x_dim) {
            for (x_res = x_base, x_filt = x_base - x_overhang; x_filt > x_base - x_dim; x_res--, x_filt--)
              result[(((y_res) >= 0) ? (y_res) : (-(y_res))) + (((x_res) >= 0) ? (x_res) : (-(x_res)))] += 2 * filt[(((y_tmp) >= 0) ? (y_tmp) : (-(y_tmp))) + (((x_filt) >= 0) ? (x_filt) : (-(x_filt)))];
            if ((x_pos != 0) && (x_overhang == mx_pos))
              for (x_res = x_base, x_filt = x_base - 2 * mx_pos + x_overhang - 1; x_filt > x_base - x_dim; x_res--, x_filt--)
                for (x_tmp = x_filt; x_tmp > x_base - x_dim; x_tmp--)
                  result[(((y_res) >= 0) ? (y_res) : (-(y_res))) + (((x_res) >= 0) ? (x_res) : (-(x_res)))] += 2 * filt[(((y_tmp) >= 0) ? (y_tmp) : (-(y_tmp))) + (((x_tmp) >= 0) ? (x_tmp) : (-(x_tmp)))];
          }
  }
  return (0);
}
```