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

```asm
<scale_image_box>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,0x38(%rsp)
  mov    %esi,0x24(%rsp)
  mov    %edx,0x44(%rsp)
  mov    %rcx,0x28(%rsp)
  mov    %r8d,0x20(%rsp)
  mov    %r9d,0x4c(%rsp)
  movss  %xmm0,0x18(%rsp)
  imul   0xa0(%rsp),%esi
  mov    %esi,0x50(%rsp)
  cmpl   $0x0,0xa8(%rsp)
  jne    L111
  test   %edx,%edx
  jle    L65
  mov    0x20(%rsp),%ecx
  mov    %ecx,%eax
  shr    $0x1f,%eax
  add    %ecx,%eax
  sar    %eax
  mov    %eax,0x40(%rsp)
  mov    %ecx,%eax
  imul   0xa0(%rsp),%eax
  movslq %eax,%r15
  lea    0x1(%rcx),%eax
  imul   0xa0(%rsp),%eax
  movslq %eax,%r14
  mov    0x4c(%rsp),%esi
  mov    %esi,%eax
  shr    $0x1f,%eax
  add    %esi,%eax
  sar    %eax
  mov    %eax,0x30(%rsp)
  mov    0xa8(%rsp),%eax
  mov    %eax,0x1c(%rsp)
  movl   $0x0,0x34(%rsp)
  mov    0xa0(%rsp),%r8d
  movslq 0xa0(%rsp),%rax
  mov    %rax,0x8(%rsp)
  mov    %r15,0x10(%rsp)
  mov    0x24(%rsp),%r10d
  mov    0xa0(%rsp),%ebx
L25:
  mov    0x30(%rsp),%eax
  cltd
  idivl  0x44(%rsp)
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  test   %r10d,%r10d
  jle    L127
  imul   0x20(%rsp),%eax
  mov    %eax,0x18(%rsp)
  mov    0x40(%rsp),%r9d
  mov    0x34(%rsp),%ebp
  mov    0xa8(%rsp),%r11d
L7:
  mov    %r9d,%eax
  cltd
  idiv   %r10d
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  mov    0x18(%rsp),%esi
  lea    (%rax,%rsi,1),%ecx
  mov    %ecx,%eax
  imul   %ebx,%eax
  movslq %eax,%rcx
  add    0x28(%rsp),%rcx
  test   %ebx,%ebx
  jle    L72
  mov    $0x0,%eax
  movslq %ebp,%rsi
  add    0x38(%rsp),%rsi
  mov    0x8(%rsp),%rdx
  lea    (%rcx,%rdx,1),%r13
  mov    0x10(%rsp),%rdx
  lea    (%rcx,%rdx,1),%r12
  lea    (%rcx,%r14,1),%rdi
L103:
  movzbl 0x0(%r13,%rax,1),%edx
  movzbl (%rcx,%rax,1),%r15d
  add    %r15d,%edx
  movzbl (%r12,%rax,1),%r15d
  add    %r15d,%edx
  movzbl (%rdi,%rax,1),%r15d
  add    %r15d,%edx
  sar    $0x2,%edx
  mov    %dl,(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    %r8,%rax
  jne    L103
L72:
  add    $0x1,%r11d
  add    0x20(%rsp),%r9d
  add    %ebx,%ebp
  cmp    %r11d,%r10d
  jne    L7
L127:
  addl   $0x1,0x1c(%rsp)
  mov    0x1c(%rsp),%eax
  mov    0x4c(%rsp),%esi
  add    %esi,0x30(%rsp)
  mov    0x50(%rsp),%ecx
  add    %ecx,0x34(%rsp)
  cmp    %eax,0x44(%rsp)
  jne    L25
  jmp    L65
L111:
  movss  D6(%rip),%xmm0
  divss  0x18(%rsp),%xmm0
  movss  %xmm0,0x10(%rsp)
  cmpl   $0x0,0x44(%rsp)
  jle    L65
  mov    0x20(%rsp),%ecx
  mov    %ecx,%eax
  shr    $0x1f,%eax
  add    %ecx,%eax
  sar    %eax
  mov    %eax,0x5c(%rsp)
  mov    %ecx,%eax
  imul   0xa0(%rsp),%eax
  cltq
  mov    %rax,0x8(%rsp)
  lea    0x1(%rcx),%eax
  imul   0xa0(%rsp),%eax
  movslq %eax,%r15
  mov    0x4c(%rsp),%ecx
  mov    %ecx,%eax
  shr    $0x1f,%eax
  add    %ecx,%eax
  sar    %eax
  mov    %eax,0x54(%rsp)
  movl   $0x0,0x58(%rsp)
  movl   $0x0,0x48(%rsp)
  movslq 0xa0(%rsp),%r14
L123:
  mov    0x54(%rsp),%eax
  cltd
  idivl  0x44(%rsp)
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  cmpl   $0x0,0x24(%rsp)
  jle    L33
  imul   0x20(%rsp),%eax
  mov    %eax,0x40(%rsp)
  mov    0x5c(%rsp),%eax
  mov    %eax,0x30(%rsp)
  mov    0x58(%rsp),%eax
  mov    %eax,0x34(%rsp)
  movl   $0x0,0x1c(%rsp)
L11:
  mov    0x30(%rsp),%eax
  cltd
  idivl  0x24(%rsp)
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  mov    0x40(%rsp),%esi
  lea    (%rax,%rsi,1),%ebx
  mov    %ebx,%eax
  imul   0xa0(%rsp),%eax
  movslq %eax,%rbx
  add    0x28(%rsp),%rbx
  cmpl   $0x0,0xa0(%rsp)
  jle    L57
  movslq 0x34(%rsp),%r12
  add    0x38(%rsp),%r12
  mov    0xa0(%rsp),%r13d
  add    %rbx,%r13
L36:
  movzbl (%rbx),%edi
  movss  0x18(%rsp),%xmm0
  call   <gamma_correct@plt>
  mov    %eax,%ebp
  movzbl (%rbx,%r14,1),%edi
  movss  0x18(%rsp),%xmm0
  call   <gamma_correct@plt>
  add    %eax,%ebp
  mov    0x8(%rsp),%rax
  movzbl (%rbx,%rax,1),%edi
  movss  0x18(%rsp),%xmm0
  call   <gamma_correct@plt>
  add    %eax,%ebp
  movzbl (%rbx,%r15,1),%edi
  movss  0x18(%rsp),%xmm0
  call   <gamma_correct@plt>
  lea    0x0(%rbp,%rax,1),%edi
  sar    $0x2,%edi
  movss  0x10(%rsp),%xmm0
  call   <gamma_correct@plt>
  mov    %al,(%r12)
  add    $0x1,%rbx
  add    $0x1,%r12
  cmp    %r13,%rbx
  jne    L36
L57:
  addl   $0x1,0x1c(%rsp)
  mov    0x1c(%rsp),%eax
  mov    0x20(%rsp),%ecx
  add    %ecx,0x30(%rsp)
  mov    0xa0(%rsp),%ecx
  add    %ecx,0x34(%rsp)
  cmp    %eax,0x24(%rsp)
  jne    L11
L33:
  addl   $0x1,0x48(%rsp)
  mov    0x48(%rsp),%eax
  mov    0x4c(%rsp),%esi
  add    %esi,0x54(%rsp)
  mov    0x50(%rsp),%esi
  add    %esi,0x58(%rsp)
  cmp    %eax,0x44(%rsp)
  jne    L123
L65:
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: label: D6
type: byte[4]

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

assistant: ```c
void scale_image_box(unsigned char *dst, int dw, int dh, unsigned char *src, int sw, int sh, int bpp, int gc, float gamma) {
  int x, y, n, ix, iy, v;
  int dstride = dw * bpp;
  unsigned char *s;
  float invgamma;
  if (gc) {
    invgamma = 1.0f / gamma;
    for (y = 0; y < dh; ++y) {
      iy = ((y * sh + sh / 2) / dh) - 1;
      if (iy < 0)
        iy = 0;
      for (x = 0; x < dw; ++x) {
        ix = ((x * sw + sw / 2) / dw) - 1;
        if (ix < 0)
          ix = 0;
        s = src + (iy * sw + ix) * bpp;
        for (n = 0; n < bpp; ++n) {
          v = (gamma_correct(s[0], gamma) + gamma_correct(s[bpp], gamma) + gamma_correct(s[sw * bpp], gamma) + gamma_correct(s[(sw + 1) * bpp], gamma)) >> 2;
          dst[(y * dstride) + (x * bpp) + n] = gamma_correct(v, invgamma);
          ++s;
        }
      }
    }
  } else {
    for (y = 0; y < dh; ++y) {
      iy = ((y * sh + sh / 2) / dh) - 1;
      if (iy < 0)
        iy = 0;
      for (x = 0; x < dw; ++x) {
        ix = ((x * sw + sw / 2) / dw) - 1;
        if (ix < 0)
          ix = 0;
        s = src + (iy * sw + ix) * bpp;
        for (n = 0; n < bpp; ++n) {
          v = (s[0] + s[bpp] + s[sw * bpp] + s[(sw + 1) * bpp]) >> 2;
          dst[(y * dstride) + (x * bpp) + n] = v;
          ++s;
        }
      }
    }
  }
}
```