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

```asm
<reduce_flow>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,%rbx
  mov    %rsi,0x10(%rsp)
  mov    %edx,%edi
  mov    %ecx,%ebp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  movss  D5(%rip),%xmm0
  movss  %xmm0,0x20(%rsp)
  movss  D18(%rip),%xmm1
  movss  %xmm1,0x24(%rsp)
  movss  %xmm0,0x28(%rsp)
  movss  %xmm1,0x2c(%rsp)
  movl   $0x3e800000,0x30(%rsp)
  movss  %xmm1,0x34(%rsp)
  movss  %xmm0,0x38(%rsp)
  movss  %xmm1,0x3c(%rsp)
  movss  %xmm0,0x40(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2ss %edx,%xmm0
  mulss  D108(%rip),%xmm0
  movaps %xmm0,%xmm3
  movss  D75(%rip),%xmm2
  movaps %xmm0,%xmm1
  andps  %xmm2,%xmm1
  movss  D34(%rip),%xmm4
  ucomiss %xmm1,%xmm4
  jbe    L165
  cvttss2si %xmm0,%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movaps %xmm1,%xmm3
  cmpnless %xmm0,%xmm3
  movss  D72(%rip),%xmm4
  andps  %xmm4,%xmm3
  subss  %xmm3,%xmm1
  andnps %xmm0,%xmm2
  movaps %xmm1,%xmm3
  orps   %xmm2,%xmm3
L165:
  cvttss2si %xmm3,%eax
  mov    %eax,0xc(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2ss %ebp,%xmm0
  mulss  D108(%rip),%xmm0
  movaps %xmm0,%xmm3
  movss  D75(%rip),%xmm2
  movaps %xmm0,%xmm1
  andps  %xmm2,%xmm1
  movss  D34(%rip),%xmm4
  ucomiss %xmm1,%xmm4
  jbe    L42
  cvttss2si %xmm0,%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movaps %xmm1,%xmm3
  cmpnless %xmm0,%xmm3
  movss  D72(%rip),%xmm4
  andps  %xmm4,%xmm3
  subss  %xmm3,%xmm1
  andnps %xmm0,%xmm2
  movaps %xmm1,%xmm3
  orps   %xmm2,%xmm3
L42:
  cvttss2si %xmm3,%eax
  mov    %eax,0x1c(%rsp)
  cmp    $0x2,%ebp
  jle    L74
  lea    -0x3(%rbp),%eax
  and    $0xfffffffe,%eax
  mov    %eax,0x18(%rsp)
  movl   $0x0,0x8(%rsp)
  mov    $0x0,%r15d
  lea    -0x3(%rdi),%eax
  and    $0xfffffffe,%eax
  add    $0x5,%eax
  mov    %eax,0x4(%rsp)
  lea    0x44(%rsp),%r14
  movss  D108(%rip),%xmm2
  jmp    L140
L111:
  add    $0x1,%r9d
  add    $0xc,%r10
  cmp    %r14,%r10
  je     L155
L118:
  mov    %r9d,%eax
  cltd
  idiv   %ebp
  imul   %edi,%edx
  mov    %edx,%r8d
  mov    %r10,%rsi
  mov    %r12d,%ecx
L158:
  mov    %ecx,%eax
  cltd
  idiv   %edi
  add    %r8d,%edx
  movslq %edx,%rdx
  movss  (%rbx,%rdx,4),%xmm0
  mulss  (%rsi),%xmm0
  addss  %xmm0,%xmm1
  add    $0x1,%ecx
  add    $0x4,%rsi
  cmp    %r11d,%ecx
  jne    L158
  jmp    L111
L155:
  mulss  %xmm2,%xmm1
  movss  %xmm1,0x0(%r13)
  add    $0x2,%r11d
  add    $0x2,%r12d
  add    $0x4,%r13
  cmp    0x4(%rsp),%r11d
  je     L39
L94:
  lea    0x20(%rsp),%r10
  mov    %r15d,%r9d
  pxor   %xmm1,%xmm1
  jmp    L118
L39:
  lea    0x2(%r15),%eax
  mov    0xc(%rsp),%ecx
  add    %ecx,0x8(%rsp)
  cmp    0x18(%rsp),%r15d
  je     L74
  mov    %eax,%r15d
L140:
  cmp    $0x2,%edi
  jle    L39
  movslq 0x8(%rsp),%rax
  mov    0x10(%rsp),%rsi
  lea    (%rsi,%rax,4),%r13
  mov    $0x0,%r12d
  mov    $0x3,%r11d
  jmp    L94
L74:
  test   $0x1,%dil
  jne    L68
  mov    0x1c(%rsp),%esi
  test   %esi,%esi
  jle    L68
  movslq 0xc(%rsp),%rcx
  shl    $0x2,%rcx
  mov    0x10(%rsp),%rax
  add    %rcx,%rax
  mov    $0x0,%edx
L116:
  movss  -0x8(%rax),%xmm0
  movss  %xmm0,-0x4(%rax)
  add    $0x1,%edx
  add    %rcx,%rax
  cmp    %edx,%esi
  jne    L116
L68:
  test   $0x1,%bpl
  jne    L29
  mov    0xc(%rsp),%ebx
  test   %ebx,%ebx
  jle    L29
  mov    0x1c(%rsp),%edx
  sub    $0x2,%edx
  imul   %ebx,%edx
  movslq %edx,%rdx
  mov    0x10(%rsp),%rsi
  lea    (%rsi,%rdx,4),%rax
  lea    -0x1(%rbx),%ecx
  add    %rcx,%rdx
  lea    0x4(%rsi,%rdx,4),%rcx
  movslq %ebx,%rdx
L137:
  movss  (%rax),%xmm0
  movss  %xmm0,(%rax,%rdx,4)
  add    $0x4,%rax
  cmp    %rcx,%rax
  jne    L137
L29:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L152
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L152:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D5
type: f32
name: parse_data
arguments: tag: D18
type: f32
name: parse_data
arguments: tag: D108
type: byte[4]
name: parse_data
arguments: tag: D75
type: byte[4]
name: parse_data
arguments: tag: D34
type: byte[4]
name: parse_data
arguments: tag: D72
type: byte[4]

tool: D5: 0.0625

tool: D18: 0.125

tool: {"D108": [0x00,0x00,0x00,0x3f]}

tool: {"D75": [0xff,0xff,0xff,0x7f]}

tool: {"D34": [0x00,0x00,0x00,0x4b]}

tool: {"D72": [0x00,0x00,0x80,0x3f]}

assistant: ```c
void reduce_flow(input, output, nx, ny) float *input, *output;
int nx, ny;
{
  float filter[3][3] = {{0.0625, 0.125, 0.0625}, {0.125, 0.25, 0.125}, {0.0625, 0.125, 0.0625}};
  float val;
  int i, ii, ir, j, jj, jr;
  int snx, sny, f_off, si, sj;
  int sample = 2, filter_size = 3;
  f_off = (int)floor((filter_size - 1) / 2.0);
  snx = (int)floor(nx / ((float)sample));
  sny = (int)floor(ny / ((float)sample));
  si = 0;
  for (i = 1; i < ny - 1; i = i + 2) {
    sj = 0;
    for (j = 1; j < nx - 1; j = j + 2) {
      val = 0.0;
      for (ii = 0; ii < filter_size; ii++) {
        ir = (i + ii - f_off) % ny;
        for (jj = 0; jj < filter_size; jj++) {
          jr = (j + jj - f_off) % nx;
          val += filter[ii][jj] * input[(int)(ir * nx + jr)];
        }
      }
      output[si * snx + sj] = val / 2.0;
      sj++;
    }
    si++;
  }
  if ((nx % 2) == 0) {
    for (i = 0; i < sny; i++) {
      output[(i * snx) + (snx - 1)] = output[i * snx + (snx - 2)];
    }
  }
  if ((ny % 2) == 0) {
    for (j = 0; j < snx; j++) {
      output[((sny - 1) * snx) + j] = output[(sny - 2) * snx + j];
    }
  }
}
```