user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<scale_image_bicubic>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x78,%rsp
  mov    %rdi,-0x68(%rbp)
  mov    %esi,-0x6c(%rbp)
  mov    %edx,-0x70(%rbp)
  mov    %rcx,-0x78(%rbp)
  mov    %r8d,-0x7c(%rbp)
  mov    %r9d,-0x80(%rbp)
  movss  %xmm0,-0x84(%rbp)
  mov    -0x6c(%rbp),%eax
  imul   0x10(%rbp),%eax
  mov    %eax,-0x38(%rbp)
  cmpl   $0x0,0x18(%rbp)
  je     L192
  movss  D9(%rip),%xmm0
  divss  -0x84(%rbp),%xmm0
  movss  %xmm0,-0x2c(%rbp)
  movl   $0x0,-0x5c(%rbp)
  jmp    L40
L334:
  cmpl   $0x1,-0x70(%rbp)
  jle    L360
  mov    -0x80(%rbp),%eax
  sub    $0x1,%eax
  imul   -0x5c(%rbp),%eax
  shl    $0x7,%eax
  mov    -0x70(%rbp),%edx
  lea    -0x1(%rdx),%ebx
  cltd
  idiv   %ebx
  mov    %eax,-0x50(%rbp)
  mov    -0x70(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x5c(%rbp)
  jne    L333
  subl   $0x1,-0x50(%rbp)
L333:
  mov    -0x50(%rbp),%eax
  and    $0x7f,%eax
  mov    %eax,-0x48(%rbp)
  sarl   $0x7,-0x50(%rbp)
  jmp    L279
L360:
  movl   $0x0,-0x48(%rbp)
  mov    -0x48(%rbp),%eax
  mov    %eax,-0x50(%rbp)
L279:
  movl   $0x0,-0x60(%rbp)
  jmp    L132
L183:
  cmpl   $0x1,-0x6c(%rbp)
  jle    L181
  mov    -0x7c(%rbp),%eax
  sub    $0x1,%eax
  imul   -0x60(%rbp),%eax
  shl    $0x7,%eax
  mov    -0x6c(%rbp),%edx
  lea    -0x1(%rdx),%ebx
  cltd
  idiv   %ebx
  mov    %eax,-0x54(%rbp)
  mov    -0x6c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x60(%rbp)
  jne    L46
  subl   $0x1,-0x54(%rbp)
L46:
  mov    -0x54(%rbp),%eax
  and    $0x7f,%eax
  mov    %eax,-0x4c(%rbp)
  sarl   $0x7,-0x54(%rbp)
  jmp    L182
L181:
  movl   $0x0,-0x4c(%rbp)
  mov    -0x4c(%rbp),%eax
  mov    %eax,-0x54(%rbp)
L182:
  mov    -0x50(%rbp),%eax
  sub    $0x1,%eax
  imul   -0x7c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x54(%rbp),%eax
  sub    $0x1,%eax
  add    %edx,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x78(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  movl   $0x0,-0x58(%rbp)
  jmp    L32
L55:
  mov    -0x7c(%rbp),%eax
  add    $0x3,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%r13d
  mov    -0x7c(%rbp),%eax
  add    $0x2,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%r12d
  mov    -0x7c(%rbp),%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%ebx
  mov    -0x7c(%rbp),%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    -0x4c(%rbp),%edx
  mov    %edx,%r8d
  mov    %r13d,%ecx
  mov    %r12d,%edx
  mov    %ebx,%esi
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x34(%rbp)
  cmpl   $0x0,-0x50(%rbp)
  jle    L38
  mov    0x10(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%r13d
  mov    0x10(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%r12d
  mov    0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%ebx
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    -0x4c(%rbp),%edx
  mov    %edx,%r8d
  mov    %r13d,%ecx
  mov    %r12d,%edx
  mov    %ebx,%esi
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x40(%rbp)
  jmp    L41
L38:
  mov    -0x34(%rbp),%eax
  mov    %eax,-0x40(%rbp)
L41:
  mov    -0x7c(%rbp),%eax
  add    %eax,%eax
  add    $0x3,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%r13d
  mov    -0x7c(%rbp),%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%r12d
  mov    -0x7c(%rbp),%eax
  add    %eax,%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%ebx
  mov    -0x7c(%rbp),%eax
  imul   0x10(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    -0x4c(%rbp),%edx
  mov    %edx,%r8d
  mov    %r13d,%ecx
  mov    %r12d,%edx
  mov    %ebx,%esi
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x30(%rbp)
  mov    -0x70(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x50(%rbp)
  jge    L218
  mov    -0x7c(%rbp),%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  mov    %eax,%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%r13d
  mov    -0x7c(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  add    $0x2,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%r12d
  mov    -0x7c(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%ebx
  mov    -0x7c(%rbp),%eax
  imul   0x10(%rbp),%eax
  mov    %eax,%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x84(%rbp),%edx
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    -0x4c(%rbp),%edx
  mov    %edx,%r8d
  mov    %r13d,%ecx
  mov    %r12d,%edx
  mov    %ebx,%esi
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x3c(%rbp)
  jmp    L210
L218:
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x3c(%rbp)
L210:
  mov    -0x48(%rbp),%edi
  mov    -0x3c(%rbp),%ecx
  mov    -0x30(%rbp),%edx
  mov    -0x34(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    %edi,%r8d
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x44(%rbp)
  cmpl   $0x0,-0x44(%rbp)
  jns    L298
  movl   $0x0,-0x44(%rbp)
L298:
  cmpl   $0xff,-0x44(%rbp)
  jle    L271
  movl   $0xff,-0x44(%rbp)
L271:
  mov    -0x2c(%rbp),%edx
  mov    -0x44(%rbp),%eax
  movd   %edx,%xmm0
  mov    %eax,%edi
  call   <gamma_correct@plt>
  mov    %eax,%edx
  mov    -0x5c(%rbp),%eax
  imul   -0x38(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x60(%rbp),%eax
  imul   0x10(%rbp),%eax
  add    %eax,%ecx
  mov    -0x58(%rbp),%eax
  add    %ecx,%eax
  movslq %eax,%rcx
  mov    -0x68(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x28(%rbp)
  addl   $0x1,-0x58(%rbp)
L32:
  mov    -0x58(%rbp),%eax
  cmp    0x10(%rbp),%eax
  jl     L55
  addl   $0x1,-0x60(%rbp)
L132:
  mov    -0x60(%rbp),%eax
  cmp    -0x6c(%rbp),%eax
  jl     L183
  addl   $0x1,-0x5c(%rbp)
L40:
  mov    -0x5c(%rbp),%eax
  cmp    -0x70(%rbp),%eax
  jl     L334
  jmp    L212
L192:
  movl   $0x0,-0x5c(%rbp)
  jmp    L374
L369:
  cmpl   $0x1,-0x70(%rbp)
  jle    L164
  mov    -0x80(%rbp),%eax
  sub    $0x1,%eax
  imul   -0x5c(%rbp),%eax
  shl    $0x7,%eax
  mov    -0x70(%rbp),%edx
  lea    -0x1(%rdx),%ebx
  cltd
  idiv   %ebx
  mov    %eax,-0x50(%rbp)
  mov    -0x70(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x5c(%rbp)
  jne    L293
  subl   $0x1,-0x50(%rbp)
L293:
  mov    -0x50(%rbp),%eax
  and    $0x7f,%eax
  mov    %eax,-0x48(%rbp)
  sarl   $0x7,-0x50(%rbp)
  jmp    L362
L164:
  movl   $0x0,-0x48(%rbp)
  mov    -0x48(%rbp),%eax
  mov    %eax,-0x50(%rbp)
L362:
  movl   $0x0,-0x60(%rbp)
  jmp    L357
L286:
  cmpl   $0x1,-0x6c(%rbp)
  jle    L193
  mov    -0x7c(%rbp),%eax
  sub    $0x1,%eax
  imul   -0x60(%rbp),%eax
  shl    $0x7,%eax
  mov    -0x6c(%rbp),%edx
  lea    -0x1(%rdx),%ebx
  cltd
  idiv   %ebx
  mov    %eax,-0x54(%rbp)
  mov    -0x6c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x60(%rbp)
  jne    L201
  subl   $0x1,-0x54(%rbp)
L201:
  mov    -0x54(%rbp),%eax
  and    $0x7f,%eax
  mov    %eax,-0x4c(%rbp)
  sarl   $0x7,-0x54(%rbp)
  jmp    L106
L193:
  movl   $0x0,-0x4c(%rbp)
  mov    -0x4c(%rbp),%eax
  mov    %eax,-0x54(%rbp)
L106:
  mov    -0x50(%rbp),%eax
  sub    $0x1,%eax
  imul   -0x7c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x54(%rbp),%eax
  sub    $0x1,%eax
  add    %edx,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x78(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  movl   $0x0,-0x58(%rbp)
  jmp    L43
L83:
  mov    -0x7c(%rbp),%eax
  add    $0x3,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    -0x7c(%rbp),%eax
  add    $0x2,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x7c(%rbp),%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rsi
  mov    -0x28(%rbp),%rax
  add    %rsi,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x7c(%rbp),%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdi
  mov    -0x28(%rbp),%rax
  add    %rdi,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x4c(%rbp),%edi
  mov    %edi,%r8d
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x34(%rbp)
  cmpl   $0x0,-0x50(%rbp)
  jle    L195
  mov    0x10(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    0x10(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    0x10(%rbp),%eax
  movslq %eax,%rsi
  mov    -0x28(%rbp),%rax
  add    %rsi,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x4c(%rbp),%edi
  mov    %edi,%r8d
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x40(%rbp)
  jmp    L232
L195:
  mov    -0x34(%rbp),%eax
  mov    %eax,-0x40(%rbp)
L232:
  mov    -0x7c(%rbp),%eax
  add    %eax,%eax
  add    $0x3,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    -0x7c(%rbp),%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x7c(%rbp),%eax
  add    %eax,%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rsi
  mov    -0x28(%rbp),%rax
  add    %rsi,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x7c(%rbp),%eax
  imul   0x10(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdi
  mov    -0x28(%rbp),%rax
  add    %rdi,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x4c(%rbp),%edi
  mov    %edi,%r8d
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x30(%rbp)
  mov    -0x70(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x50(%rbp)
  jge    L189
  mov    -0x7c(%rbp),%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  mov    %eax,%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    -0x7c(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  add    $0x2,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x7c(%rbp),%esi
  mov    %esi,%eax
  add    %eax,%eax
  add    %esi,%eax
  add    $0x1,%eax
  imul   0x10(%rbp),%eax
  movslq %eax,%rsi
  mov    -0x28(%rbp),%rax
  add    %rsi,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x7c(%rbp),%eax
  imul   0x10(%rbp),%eax
  mov    %eax,%edi
  mov    %edi,%eax
  add    %eax,%eax
  add    %edi,%eax
  movslq %eax,%rdi
  mov    -0x28(%rbp),%rax
  add    %rdi,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x4c(%rbp),%edi
  mov    %edi,%r8d
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x3c(%rbp)
  jmp    L264
L189:
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x3c(%rbp)
L264:
  mov    -0x48(%rbp),%edi
  mov    -0x3c(%rbp),%ecx
  mov    -0x30(%rbp),%edx
  mov    -0x34(%rbp),%esi
  mov    -0x40(%rbp),%eax
  mov    %edi,%r8d
  mov    %eax,%edi
  call   <icerp@plt>
  mov    %eax,-0x44(%rbp)
  cmpl   $0x0,-0x44(%rbp)
  jns    L203
  movl   $0x0,-0x44(%rbp)
L203:
  cmpl   $0xff,-0x44(%rbp)
  jle    L18
  movl   $0xff,-0x44(%rbp)
L18:
  mov    -0x5c(%rbp),%eax
  imul   -0x38(%rbp),%eax
  mov    %eax,%edx
  mov    -0x60(%rbp),%eax
  imul   0x10(%rbp),%eax
  add    %eax,%edx
  mov    -0x58(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  mov    -0x44(%rbp),%edx
  mov    %dl,(%rax)
  addq   $0x1,-0x28(%rbp)
  addl   $0x1,-0x58(%rbp)
L43:
  mov    -0x58(%rbp),%eax
  cmp    0x10(%rbp),%eax
  jl     L83
  addl   $0x1,-0x60(%rbp)
L357:
  mov    -0x60(%rbp),%eax
  cmp    -0x6c(%rbp),%eax
  jl     L286
  addl   $0x1,-0x5c(%rbp)
L374:
  mov    -0x5c(%rbp),%eax
  cmp    -0x70(%rbp),%eax
  jl     L369
L212:
  nop
  add    $0x78,%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  ret
```

tool_calls: name: retrieve_data
arguments: label: D9
data_type: f32

tool: D9: 1

assistant: ```c
void scale_image_bicubic(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, wx, wy, v;
  int a, b, c, d;
  int dstride = dw * bpp;
  unsigned char *s;
  float invgamma;
  if (gc) {
    invgamma = 1.0 / gamma;
    for (y = 0; y < dh; ++y) {
      if (dh > 1) {
        iy = (((sh - 1) * y) << 7) / (dh - 1);
        if (y == dh - 1)
          --iy;
        wy = iy & 0x7f;
        iy >>= 7;
      } else
        iy = wy = 0;
      for (x = 0; x < dw; ++x) {
        if (dw > 1) {
          ix = (((sw - 1) * x) << 7) / (dw - 1);
          if (x == dw - 1)
            --ix;
          wx = ix & 0x7f;
          ix >>= 7;
        } else
          ix = wx = 0;
        s = src + ((iy - 1) * sw + (ix - 1)) * bpp;
        for (n = 0; n < bpp; ++n) {
          b = icerp(gamma_correct(s[(sw + 0) * bpp], gamma), gamma_correct(s[(sw + 1) * bpp], gamma), gamma_correct(s[(sw + 2) * bpp], gamma), gamma_correct(s[(sw + 3) * bpp], gamma), wx);
          if (iy > 0) {
            a = icerp(gamma_correct(s[0], gamma), gamma_correct(s[bpp], gamma), gamma_correct(s[2 * bpp], gamma), gamma_correct(s[3 * bpp], gamma), wx);
          } else
            a = b;
          c = icerp(gamma_correct(s[(2 * sw + 0) * bpp], gamma), gamma_correct(s[(2 * sw + 1) * bpp], gamma), gamma_correct(s[(2 * sw + 2) * bpp], gamma), gamma_correct(s[(2 * sw + 3) * bpp], gamma), wx);
          if (iy < dh - 1) {
            d = icerp(gamma_correct(s[(3 * sw + 0) * bpp], gamma), gamma_correct(s[(3 * sw + 1) * bpp], gamma), gamma_correct(s[(3 * sw + 2) * bpp], gamma), gamma_correct(s[(3 * sw + 3) * bpp], gamma), wx);
          } else
            d = c;
          v = icerp(a, b, c, d, wy);
          if (v < 0)
            v = 0;
          if (v > 255)
            v = 255;
          dst[(y * dstride) + (x * bpp) + n] = gamma_correct(v, invgamma);
          ++s;
        }
      }
    }
  } else {
    for (y = 0; y < dh; ++y) {
      if (dh > 1) {
        iy = (((sh - 1) * y) << 7) / (dh - 1);
        if (y == dh - 1)
          --iy;
        wy = iy & 0x7f;
        iy >>= 7;
      } else
        iy = wy = 0;
      for (x = 0; x < dw; ++x) {
        if (dw > 1) {
          ix = (((sw - 1) * x) << 7) / (dw - 1);
          if (x == dw - 1)
            --ix;
          wx = ix & 0x7f;
          ix >>= 7;
        } else
          ix = wx = 0;
        s = src + ((iy - 1) * sw + (ix - 1)) * bpp;
        for (n = 0; n < bpp; ++n) {
          b = icerp(s[(sw + 0) * bpp], s[(sw + 1) * bpp], s[(sw + 2) * bpp], s[(sw + 3) * bpp], wx);
          if (iy > 0) {
            a = icerp(s[0], s[bpp], s[2 * bpp], s[3 * bpp], wx);
          } else
            a = b;
          c = icerp(s[(2 * sw + 0) * bpp], s[(2 * sw + 1) * bpp], s[(2 * sw + 2) * bpp], s[(2 * sw + 3) * bpp], wx);
          if (iy < dh - 1) {
            d = icerp(s[(3 * sw + 0) * bpp], s[(3 * sw + 1) * bpp], s[(3 * sw + 2) * bpp], s[(3 * sw + 3) * bpp], wx);
          } else
            d = c;
          v = icerp(a, b, c, d, wy);
          if (v < 0)
            v = 0;
          if (v > 255)
            v = 255;
          dst[(y * dstride) + (x * bpp) + n] = v;
          ++s;
        }
      }
    }
  }
}
```