user: 请从给定的汇编指令推导出C源代码:

```asm
<scale_volume_image_box>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %rdi,0x40(%rsp)
  mov    %esi,0x28(%rsp)
  mov    %edx,0x64(%rsp)
  mov    %ecx,0x7c(%rsp)
  mov    %r8,0x38(%rsp)
  mov    %r9d,0x2c(%rsp)
  movss  %xmm0,0x5c(%rsp)
  cmpl   $0x0,0xe8(%rsp)
  jne    L247
  test   %ecx,%ecx
  jle    L103
  mov    0xd0(%rsp),%eax
  shr    $0x1f,%eax
  add    0xd0(%rsp),%eax
  sar    %eax
  mov    %eax,0x74(%rsp)
  mov    0x2c(%rsp),%esi
  mov    %esi,%eax
  shr    $0x1f,%eax
  add    %esi,%eax
  sar    %eax
  mov    %eax,0x60(%rsp)
  mov    %esi,%eax
  imul   0xd0(%rsp),%esi
  mov    %esi,0x70(%rsp)
  mov    %eax,%esi
  imul   0xe0(%rsp),%eax
  cltq
  mov    %rax,0x20(%rsp)
  lea    0x1(%rsi),%eax
  imul   0xe0(%rsp),%eax
  cltq
  mov    %rax,0x30(%rsp)
  mov    0xd8(%rsp),%eax
  shr    $0x1f,%eax
  add    0xd8(%rsp),%eax
  sar    %eax
  mov    %eax,0x6c(%rsp)
  mov    0xe8(%rsp),%eax
  mov    %eax,0x68(%rsp)
  mov    0x7c(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0x1c(%rsp)
  mov    0xe0(%rsp),%r12d
  movslq 0xe0(%rsp),%rax
  mov    %rax,0x48(%rsp)
  mov    %r12,%rbx
  mov    0x40(%rsp),%r12
  jmp    L93
L247:
  movss  D9(%rip),%xmm0
  divss  0x5c(%rsp),%xmm0
  movss  %xmm0,0x1c(%rsp)
  mov    0x7c(%rsp),%ebx
  test   %ebx,%ebx
  jle    L103
  mov    0xd0(%rsp),%eax
  shr    $0x1f,%eax
  add    0xd0(%rsp),%eax
  sar    %eax
  mov    %eax,0x8c(%rsp)
  mov    0x2c(%rsp),%esi
  mov    %esi,%eax
  shr    $0x1f,%eax
  add    %esi,%eax
  sar    %eax
  mov    %eax,0x78(%rsp)
  mov    %esi,%eax
  imul   0xd0(%rsp),%esi
  mov    %esi,0x88(%rsp)
  mov    %eax,%esi
  imul   0xe0(%rsp),%eax
  cltq
  mov    %rax,0x10(%rsp)
  lea    0x1(%rsi),%eax
  imul   0xe0(%rsp),%eax
  movslq %eax,%r15
  mov    0xd8(%rsp),%eax
  shr    $0x1f,%eax
  add    0xd8(%rsp),%eax
  sar    %eax
  mov    %eax,0x84(%rsp)
  movl   $0x0,0x80(%rsp)
  lea    -0x1(%rbx),%eax
  mov    %eax,0x58(%rsp)
  jmp    L137
L76:
  cmpl   $0x0,0xe0(%rsp)
  jle    L81
  mov    0xe0(%rsp),%eax
  mov    %rax,0x48(%rsp)
  add    %rbx,%rax
  mov    %rax,0x8(%rsp)
  mov    0x40(%rsp),%r13
  pxor   %xmm1,%xmm1
  cvtss2sd 0x5c(%rsp),%xmm1
  movsd  %xmm1,(%rsp)
L14:
  movzbl (%rbx),%edi
  movsd  (%rsp),%xmm0
  mov    $0x1,%eax
  call   <gamma_correct@plt>
  mov    %eax,%r12d
  movzbl 0x0(%rbp),%edi
  movsd  (%rsp),%xmm0
  mov    $0x1,%eax
  call   <gamma_correct@plt>
  add    %eax,%r12d
  movslq 0xe0(%rsp),%r14
  movzbl (%rbx,%r14,1),%edi
  movsd  (%rsp),%xmm0
  mov    $0x1,%eax
  call   <gamma_correct@plt>
  add    %eax,%r12d
  movzbl 0x0(%rbp,%r14,1),%edi
  movsd  (%rsp),%xmm0
  mov    $0x1,%eax
  call   <gamma_correct@plt>
  lea    (%r12,%rax,1),%r14d
  mov    0x10(%rsp),%r12
  movzbl (%rbx,%r12,1),%edi
  movsd  (%rsp),%xmm0
  mov    $0x1,%eax
  call   <gamma_correct@plt>
  add    %eax,%r14d
  movzbl 0x0(%rbp,%r12,1),%edi
  movsd  (%rsp),%xmm0
  mov    $0x1,%eax
  call   <gamma_correct@plt>
  add    %eax,%r14d
  movzbl (%rbx,%r15,1),%edi
  movsd  (%rsp),%xmm0
  mov    $0x1,%eax
  call   <gamma_correct@plt>
  add    %eax,%r14d
  movzbl 0x0(%rbp,%r15,1),%edi
  movsd  (%rsp),%xmm0
  mov    $0x1,%eax
  call   <gamma_correct@plt>
  pxor   %xmm0,%xmm0
  cvtss2sd 0x1c(%rsp),%xmm0
  lea    (%r14,%rax,1),%edi
  sar    $0x3,%edi
  mov    $0x1,%eax
  call   <gamma_correct@plt>
  add    $0x1,%r13
  mov    %al,-0x1(%r13)
  add    $0x1,%rbx
  add    $0x1,%rbp
  cmp    0x8(%rsp),%rbx
  jne    L14
  mov    0x48(%rsp),%rsi
  add    %rsi,0x40(%rsp)
L81:
  addl   $0x1,0x20(%rsp)
  mov    0x20(%rsp),%eax
  mov    0x2c(%rsp),%ebx
  add    %ebx,0x30(%rsp)
  cmp    %eax,0x28(%rsp)
  je     L158
L100:
  mov    0x30(%rsp),%eax
  cltd
  idivl  0x28(%rsp)
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  mov    0x50(%rsp),%esi
  lea    (%rsi,%rax,1),%ebx
  imul   0xe0(%rsp),%ebx
  movslq %ebx,%rbx
  mov    0x38(%rsp),%rsi
  add    %rsi,%rbx
  mov    %rsi,%rbp
  mov    0x54(%rsp),%ecx
  cmp    %ecx,0x58(%rsp)
  jle    L76
  add    0x60(%rsp),%eax
  imul   0xe0(%rsp),%eax
  cltq
  lea    (%rsi,%rax,1),%rbp
  jmp    L76
L158:
  addl   $0x1,0x68(%rsp)
  mov    0x68(%rsp),%eax
  mov    0xd0(%rsp),%ebx
  add    %ebx,0x6c(%rsp)
  cmp    %eax,0x64(%rsp)
  je     L21
L239:
  mov    0x6c(%rsp),%eax
  cltd
  idivl  0x64(%rsp)
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  cmpl   $0x0,0x28(%rsp)
  jle    L158
  imul   0x2c(%rsp),%eax
  mov    0x74(%rsp),%esi
  add    %eax,%esi
  mov    %esi,0x50(%rsp)
  add    0x70(%rsp),%eax
  mov    %eax,0x60(%rsp)
  mov    0x78(%rsp),%eax
  mov    %eax,0x30(%rsp)
  movl   $0x0,0x20(%rsp)
  jmp    L100
L21:
  addl   $0x1,0x80(%rsp)
  mov    0x80(%rsp),%eax
  mov    0xd8(%rsp),%ebx
  add    %ebx,0x84(%rsp)
  cmp    %eax,0x7c(%rsp)
  je     L103
L137:
  mov    0x84(%rsp),%eax
  cltd
  idivl  0x7c(%rsp)
  lea    -0x1(%rax),%esi
  test   %esi,%esi
  mov    $0x0,%eax
  cmovns %esi,%eax
  mov    %eax,0x54(%rsp)
  cmpl   $0x0,0x64(%rsp)
  jle    L21
  mov    0x88(%rsp),%esi
  imul   %esi,%eax
  mov    %eax,0x74(%rsp)
  add    %esi,%eax
  mov    %eax,0x70(%rsp)
  mov    0x8c(%rsp),%eax
  mov    %eax,0x6c(%rsp)
  movl   $0x0,0x68(%rsp)
  jmp    L239
L96:
  cmpl   $0x0,0xe0(%rsp)
  jle    L37
  mov    $0x0,%eax
  mov    0x48(%rsp),%rdx
  lea    (%rsi,%rdx,1),%r14
  mov    0x20(%rsp),%rcx
  lea    (%rsi,%rcx,1),%r13
  mov    0x30(%rsp),%r8
  lea    (%rsi,%r8,1),%r11
  lea    (%rdi,%rdx,1),%r10
  lea    (%rdi,%rcx,1),%r9
  add    %rdi,%r8
L50:
  movzbl (%r14,%rax,1),%edx
  movzbl (%rsi,%rax,1),%ecx
  add    %ecx,%edx
  movzbl 0x0(%r13,%rax,1),%ecx
  add    %ecx,%edx
  movzbl (%r11,%rax,1),%ecx
  add    %ecx,%edx
  movzbl (%r10,%rax,1),%ecx
  movzbl (%rdi,%rax,1),%r15d
  add    %r15d,%ecx
  movzbl (%r9,%rax,1),%r15d
  add    %r15d,%ecx
  movzbl (%r8,%rax,1),%r15d
  add    %r15d,%ecx
  add    %ecx,%edx
  sar    $0x3,%edx
  mov    %dl,(%r12,%rax,1)
  add    $0x1,%rax
  cmp    %rbx,%rax
  jne    L50
  add    %rbx,%r12
L37:
  add    $0x1,%ebp
  mov    0x2c(%rsp),%esi
  add    %esi,(%rsp)
  cmp    %ebp,0x28(%rsp)
  je     L90
L204:
  mov    (%rsp),%eax
  cltd
  idivl  0x28(%rsp)
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  mov    0x8(%rsp),%esi
  add    %eax,%esi
  imul   0xe0(%rsp),%esi
  movslq %esi,%rsi
  mov    0x38(%rsp),%rdx
  add    %rdx,%rsi
  mov    %rdx,%rdi
  mov    0x10(%rsp),%r10d
  cmp    %r10d,0x1c(%rsp)
  jle    L96
  add    0x40(%rsp),%eax
  imul   0xe0(%rsp),%eax
  cltq
  lea    (%rdx,%rax,1),%rdi
  jmp    L96
L90:
  addl   $0x1,0x50(%rsp)
  mov    0x50(%rsp),%eax
  mov    0xd0(%rsp),%edx
  add    %edx,0x54(%rsp)
  cmp    %eax,0x64(%rsp)
  je     L201
L207:
  mov    0x54(%rsp),%eax
  cltd
  idivl  0x64(%rsp)
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  cmpl   $0x0,0x28(%rsp)
  jle    L90
  imul   0x2c(%rsp),%eax
  mov    0x58(%rsp),%esi
  add    %eax,%esi
  mov    %esi,0x8(%rsp)
  add    0x5c(%rsp),%eax
  mov    %eax,0x40(%rsp)
  mov    0x60(%rsp),%eax
  mov    %eax,(%rsp)
  mov    0xe8(%rsp),%ebp
  jmp    L204
L201:
  addl   $0x1,0x68(%rsp)
  mov    0x68(%rsp),%eax
  mov    0xd8(%rsp),%edx
  add    %edx,0x6c(%rsp)
  cmp    %eax,0x7c(%rsp)
  je     L103
L93:
  mov    0x6c(%rsp),%eax
  cltd
  idivl  0x7c(%rsp)
  lea    -0x1(%rax),%esi
  test   %esi,%esi
  mov    $0x0,%eax
  cmovns %esi,%eax
  mov    %eax,0x10(%rsp)
  cmpl   $0x0,0x64(%rsp)
  jle    L201
  mov    0x70(%rsp),%esi
  imul   %esi,%eax
  mov    %eax,0x58(%rsp)
  add    %esi,%eax
  mov    %eax,0x5c(%rsp)
  mov    0x74(%rsp),%eax
  mov    %eax,0x54(%rsp)
  mov    0xe8(%rsp),%eax
  mov    %eax,0x50(%rsp)
  jmp    L207
L103:
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D9
data_type: f32

tool: D9: 1

assistant: ```c
void scale_volume_image_box(unsigned char *dst, int dw, int dh, int dd, unsigned char *src, int sw, int sh, int sd, int bpp, int gc, float gamma) {
  int n, x, y, z, v;
  int ix, iy, iz;
  unsigned char *s1, *s2, *d = dst;
  float invgamma;
  if (gc) {
    invgamma = 1.0 / gamma;
    for (z = 0; z < dd; ++z) {
      iz = ((z * sd + sd / 2) / dd) - 1;
      if (iz < 0)
        iz = 0;
      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;
          s1 = src + ((iz * (sw * sh)) + (iy * sw) + ix) * bpp;
          if (iz < dd - 1)
            s2 = src + (((iz + 1) * (sw * sh)) + (iy * sw) + ix) * bpp;
          else
            s2 = src;
          for (n = 0; n < bpp; ++n) {
            v = (gamma_correct(s1[0], gamma) + gamma_correct(s2[0], gamma) + gamma_correct(s1[bpp], gamma) + gamma_correct(s2[bpp], gamma) + gamma_correct(s1[sw * bpp], gamma) + gamma_correct(s2[sw * bpp], gamma) + gamma_correct(s1[(sw + 1) * bpp], gamma) + gamma_correct(s2[(sw + 1) * bpp], gamma)) >> 3;
            *d++ = gamma_correct(v, invgamma);
            ++s1;
            ++s2;
          }
        }
      }
    }
  } else {
    for (z = 0; z < dd; ++z) {
      iz = ((z * sd + sd / 2) / dd) - 1;
      if (iz < 0)
        iz = 0;
      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;
          s1 = src + ((iz * (sw * sh)) + (iy * sw) + ix) * bpp;
          if (iz < dd - 1)
            s2 = src + (((iz + 1) * (sw * sh)) + (iy * sw) + ix) * bpp;
          else
            s2 = src;
          for (n = 0; n < bpp; ++n) {
            v = ((s1[0] + s1[bpp] + s1[sw * bpp] + s1[(sw + 1) * bpp]) + (s2[0] + s2[bpp] + s2[sw * bpp] + s2[(sw + 1) * bpp])) >> 3;
            *d++ = v;
            ++s1;
            ++s2;
          }
        }
      }
    }
  }
}
```