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

```asm
<chroma_smooth_3x3>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x108,%rsp
  mov    %edi,0x54(%rsp)
  mov    %rcx,0x78(%rsp)
  mov    %r9,0x80(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xf8(%rsp)
  xor    %eax,%eax
  lea    -0x5(%rsi),%eax
  mov    %eax,0x90(%rsp)
  cmp    $0x4,%eax
  jle    L58
  lea    -0x4(%rdi),%eax
  mov    %eax,0x14(%rsp)
  cmp    $0x4,%eax
  jle    L58
  lea    (%rdi,%rdi,1),%esi
  lea    0x0(,%rdi,4),%ecx
  movl   $0x4,0x50(%rsp)
  mov    %r8,%r13
  mov    %esi,%eax
  mov    %esi,0x94(%rsp)
  add    %edi,%eax
  mov    %ecx,0x48(%rsp)
  mov    %eax,0x70(%rsp)
  add    %eax,%eax
  mov    %eax,0x6c(%rsp)
  lea    0x0(,%rdi,8),%eax
  sub    %edi,%eax
  mov    %esi,0x74(%rsp)
  mov    %eax,0x68(%rsp)
  movslq %esi,%rax
  mov    %rax,0x88(%rsp)
  mov    %ecx,%eax
  add    %edi,%eax
  cltq
  mov    %rax,0x60(%rsp)
  movslq %ecx,%rax
  mov    %rax,0x58(%rsp)
  lea    0x10(%rdx),%rax
  mov    %rax,0x98(%rsp)
  lea    0xa0(%rsp),%rax
  mov    %rax,0x18(%rsp)
  nopw   0x0(%rax,%rax,1)
L60:
  mov    0x54(%rsp),%eax
  add    0x48(%rsp),%eax
  movl   $0x4,0x10(%rsp)
  mov    0x60(%rsp),%rbx
  mov    0x58(%rsp),%rsi
  mov    %eax,0x4c(%rsp)
  mov    0x98(%rsp),%rax
  lea    (%rax,%rbx,4),%r15
  lea    (%rax,%rsi,4),%rax
  mov    %rax,(%rsp)
  movslq 0x74(%rsp),%rax
  sub    %rbx,%rax
  shl    $0x2,%rax
  mov    %rax,0x40(%rsp)
  movslq 0x70(%rsp),%rax
  sub    %rbx,%rax
  shl    $0x2,%rax
  mov    %rax,0x38(%rsp)
  movslq 0x6c(%rsp),%rax
  sub    %rbx,%rax
  shl    $0x2,%rax
  mov    %rax,0x30(%rsp)
  movslq 0x68(%rsp),%rax
  sub    %rbx,%rax
  shl    $0x2,%rax
  mov    %rax,0x28(%rsp)
  jmp    L98
L75:
  addl   $0x2,0x10(%rsp)
  add    $0x8,%r15
  mov    0x10(%rsp),%eax
  addq   $0x8,(%rsp)
  cmp    %eax,0x14(%rsp)
  jle    L15
L98:
  mov    (%rsp),%rdi
  movslq (%r15),%rdx
  movslq 0x4(%rdi),%rax
  mov    0x0(%r13,%rdx,4),%r12d
  add    0x0(%r13,%rax,4),%r12d
  cmp    $0x1ffff,%r12d
  jle    L75
  mov    0x40(%rsp),%rax
  mov    0x18(%rsp),%rsi
  mov    %r15,%r8
  lea    (%r15,%rax,1),%rbp
  mov    0x38(%rsp),%rax
  lea    (%r15,%rax,1),%rbx
  lea    0xd0(%rsp),%rax
  mov    %rax,0x20(%rsp)
  mov    %rax,%r11
  mov    0x30(%rsp),%rax
  lea    (%r15,%rax,1),%r10
  mov    0x28(%rsp),%rax
  lea    (%r15,%rax,1),%r9
  lea    0xc4(%rsp),%rax
  mov    %rax,0x8(%rsp)
L92:
  movslq -0x4(%rbp),%rdx
  movslq -0x8(%rbx),%rax
  add    $0x8,%rbp
  add    $0x8,%rbx
  movslq -0x4(%rdi),%r14
  movslq -0x4(%r8),%rcx
  add    $0x8,%rdi
  add    $0x8,%r8
  add    $0xc,%rsi
  add    $0xc,%r11
  add    $0x8,%r10
  add    $0x8,%r9
  mov    0x0(%r13,%rax,4),%eax
  add    0x0(%r13,%rdx,4),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %eax,%edx
  movslq -0xc(%rbx),%rax
  sar    %edx
  mov    0x0(%r13,%rax,4),%eax
  sub    %edx,%eax
  movd   %eax,%xmm0
  movslq -0x10(%r8),%rax
  mov    0x0(%r13,%rax,4),%eax
  add    0x0(%r13,%r14,4),%eax
  mov    %eax,%r14d
  shr    $0x1f,%r14d
  add    %eax,%r14d
  mov    %r14d,%eax
  movslq -0x10(%rbp),%r14
  sar    %eax
  mov    0x0(%r13,%r14,4),%r14d
  sub    %edx,%r14d
  movslq -0x10(%rdi),%rdx
  movd   %r14d,%xmm1
  mov    0x0(%r13,%rdx,4),%edx
  sub    %eax,%edx
  movd   %edx,%xmm2
  punpckldq %xmm2,%xmm1
  movq   %xmm1,-0xc(%rsi)
  mov    0x0(%r13,%rcx,4),%edx
  sub    %eax,%edx
  movd   %edx,%xmm3
  punpckldq %xmm3,%xmm0
  movq   %xmm0,-0xc(%r11)
  movslq -0xc(%r10),%rax
  movslq -0x10(%r9),%rdx
  movslq -0xc(%r9),%rcx
  mov    0x0(%r13,%rdx,4),%edx
  add    0x0(%r13,%rax,4),%edx
  mov    %edx,%eax
  shr    $0x1f,%eax
  add    %edx,%eax
  movslq -0x10(%r10),%rdx
  sar    %eax
  mov    0x0(%r13,%rdx,4),%edx
  sub    %eax,%edx
  mov    %edx,-0x4(%rsi)
  mov    0x0(%r13,%rcx,4),%edx
  sub    %eax,%edx
  mov    %edx,-0x4(%r11)
  cmp    0x8(%rsp),%rsi
  jne    L92
  mov    0x18(%rsp),%rdi
  sar    %r12d
  call   <opt_med9@plt>
  mov    0x20(%rsp),%rdi
  mov    %eax,%ebx
  call   <opt_med9@plt>
  add    %r12d,%ebx
  cmp    $0x8000,%ebx
  jle    L75
  add    %eax,%r12d
  cmp    $0x8000,%r12d
  jle    L75
  movslq %ebx,%rax
  mov    $0x1bfffc,%edx
  mov    0x10(%rsp),%edi
  mov    0x48(%rsp),%ecx
  shl    $0x2,%rax
  cmp    $0x6ffff,%ebx
  mov    0x80(%rsp),%rsi
  mov    0x140(%rsp),%ebx
  cmovge %rdx,%rax
  add    %edi,%ecx
  movslq %ecx,%rcx
  add    (%rsi,%rax,1),%ebx
  mov    %ebx,%eax
  mov    0x78(%rsp),%rbx
  mov    %eax,(%rbx,%rcx,4)
  movslq %r12d,%rax
  mov    0x4c(%rsp),%ecx
  shl    $0x2,%rax
  cmp    $0x6ffff,%r12d
  cmovge %rdx,%rax
  lea    0x1(%rdi,%rcx,1),%edx
  mov    0x140(%rsp),%ecx
  movslq %edx,%rdx
  add    (%rsi,%rax,1),%ecx
  mov    %ecx,(%rbx,%rdx,4)
  jmp    L75
  nopl   0x0(%rax)
L15:
  mov    0x4c(%rsp),%eax
  add    0x54(%rsp),%eax
  mov    0x88(%rsp),%rbx
  addl   $0x2,0x50(%rsp)
  mov    %eax,0x48(%rsp)
  mov    0x50(%rsp),%esi
  mov    0x94(%rsp),%eax
  add    %rbx,0x60(%rsp)
  add    %eax,0x74(%rsp)
  add    %eax,0x70(%rsp)
  add    %eax,0x6c(%rsp)
  add    %eax,0x68(%rsp)
  add    %rbx,0x58(%rsp)
  cmp    %esi,0x90(%rsp)
  jg     L60
L58:
  mov    0xf8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L73
  add    $0x108,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L73:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void chroma_smooth_3x3(int w, int h, uint32_t *inp, uint32_t *out, int *raw2ev, int *ev2raw, int black) {
  int x, y;
  for (y = 4; y < h - 5; y += 2) {
    for (x = 4; x < w - 4; x += 2) {
      int g1 = inp[x + 1 + y * w];
      int g2 = inp[x + (y + 1) * w];
      int ge = (raw2ev[g1] + raw2ev[g2]) / 2;
      if (ge < 2 * 32768)
        continue;
      int i, j;
      int k = 0;
      int med_r[9];
      int med_b[9];
      for (i = -2; i <= 2; i += 2) {
        for (j = -2; j <= 2; j += 2) {
          int r = inp[x + i + (y + j) * w];
          int g1 = inp[x + i + 1 + (y + j) * w];
          int g2 = inp[x + i + (y + j + 1) * w];
          int b = inp[x + i + 1 + (y + j + 1) * w];
          int ge = (raw2ev[g1] + raw2ev[g2]) / 2;
          med_r[k] = raw2ev[r] - ge;
          med_b[k] = raw2ev[b] - ge;
          k++;
        }
      }
      int dr = opt_med9(med_r);
      int db = opt_med9(med_b);
      if (ge + dr <= 32768)
        continue;
      if (ge + db <= 32768)
        continue;
      out[x + y * w] = ev2raw[(((((((ge + dr)) < ((14 * 32768 - 1))) ? ((ge + dr)) : ((14 * 32768 - 1)))) > ((0))) ? (((((ge + dr)) < ((14 * 32768 - 1))) ? ((ge + dr)) : ((14 * 32768 - 1)))) : ((0)))] + black;
      out[x + 1 + (y + 1) * w] = ev2raw[(((((((ge + db)) < ((14 * 32768 - 1))) ? ((ge + db)) : ((14 * 32768 - 1)))) > ((0))) ? (((((ge + db)) < ((14 * 32768 - 1))) ? ((ge + db)) : ((14 * 32768 - 1)))) : ((0)))] + black;
    }
  }
}
```