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

```asm
<ArrayswapLog>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,%rbp
  mov    %rsi,0x18(%rsp)
  mov    %edx,%r12d
  mov    %ecx,%ebx
  mov    %r8,%r13
  mov    %r9,%r14
  mov    %cx,0x32(%rsp)
  movswl %dx,%r9d
  test   %r9d,%r9d
  jle    L68
  mov    %ecx,%r11d
  movswl %cx,%eax
  lea    -0x1(%rax),%eax
  lea    0x2(%rax,%rax,1),%r10
  mov    %rsi,%rdx
  mov    $0x0,%r8d
  mov    $0x0,%esi
  mov    $0xffffffff,%ecx
  jmp    L3
L9:
  movzwl (%rdx),%eax
  cmp    %ax,%si
  cmovb  %eax,%esi
  cmp    %ax,%cx
  cmova  %eax,%ecx
  add    $0x2,%rdx
  cmp    %rdi,%rdx
  jne    L9
  mov    %rdi,%rdx
L19:
  add    $0x1,%r8d
  cmp    %r9d,%r8d
  je     L40
L3:
  lea    (%rdx,%r10,1),%rdi
  test   %r11w,%r11w
  jg     L9
  jmp    L19
L68:
  mov    $0x0,%esi
  mov    $0xffffffff,%ecx
L40:
  movzwl %si,%r15d
  movzwl %cx,%eax
  mov    %eax,0x8(%rsp)
  mov    %r15d,%edx
  mov    %eax,%esi
  lea    D9(%rip),%rdi
  call   <printf@plt>
  movswq %bx,%rax
  mov    %rax,0x28(%rsp)
  add    %rbp,%rax
  mov    %rax,0x10(%rsp)
  mov    %r12d,%eax
  shr    $0xf,%ax
  add    %r12d,%eax
  sar    %ax
  cmp    $0x1,%r12w
  jle    L48
  add    $0x1,%eax
  cwtl
  mov    %eax,0x34(%rsp)
  mov    %ebx,%eax
  shr    $0xf,%ax
  add    %ebx,%eax
  sar    %ax
  cwtl
  lea    -0x1(%rax),%eax
  add    $0x1,%rax
  lea    (%rax,%rax,1),%rcx
  mov    %rcx,0x20(%rsp)
  shl    $0x3,%rax
  mov    %rax,0x38(%rsp)
  movl   $0x1,0xc(%rsp)
  jmp    L69
L96:
  cmp    %rbp,%r13
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  cmp    %rbx,%r14
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movzwl (%rbx),%edi
  mov    %r15d,%edx
  mov    0x8(%rsp),%esi
  call   <mylog@plt>
  mov    %al,0x0(%rbp)
  cmp    %r12,%r13
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  lea    0x2(%rbx),%rax
  cmp    %rax,%r14
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movzwl 0x2(%rbx),%edi
  mov    %r15d,%edx
  mov    0x8(%rsp),%esi
  call   <mylog@plt>
  mov    %al,(%r12)
  lea    0x1(%r12),%rax
  cmp    %rax,%r13
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  lea    0x4(%rbx),%rax
  cmp    %rax,%r14
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movzwl 0x4(%rbx),%edi
  mov    %r15d,%edx
  mov    0x8(%rsp),%esi
  call   <mylog@plt>
  add    $0x2,%r12
  mov    %al,-0x1(%r12)
  lea    0x1(%rbp),%rax
  cmp    %rax,%r13
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  lea    0x6(%rbx),%rax
  cmp    %rax,%r14
  seta   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  add    $0x8,%rbx
  movzwl -0x2(%rbx),%edi
  mov    %r15d,%edx
  mov    0x8(%rsp),%esi
  call   <mylog@plt>
  add    $0x2,%rbp
  mov    %al,-0x1(%rbp)
  cmp    %rbp,(%rsp)
  jne    L96
  mov    0x20(%rsp),%rcx
  add    %rcx,0x10(%rsp)
  mov    0x38(%rsp),%rcx
  add    %rcx,0x18(%rsp)
L47:
  mov    0x28(%rsp),%rcx
  add    %rcx,%rbp
  add    %rcx,0x10(%rsp)
  addl   $0x1,0xc(%rsp)
  mov    0xc(%rsp),%eax
  cmp    0x34(%rsp),%eax
  je     L48
L69:
  mov    0x20(%rsp),%rax
  add    %rbp,%rax
  mov    %rax,(%rsp)
  mov    0x18(%rsp),%rbx
  mov    0x10(%rsp),%r12
  cmpw   $0x1,0x32(%rsp)
  jg     L96
  jmp    L47
L48:
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: data_label: D9
data_type: string

tool: D9: MinPix %d, MaxPix %d


assistant: ```c
void ArrayswapLog(unsigned char *Imptr1, unsigned short *Imptr2, short height, short width, unsigned char *end1, unsigned short *end2) {
  unsigned short *srcPix, minPix, maxPix;
  int x, y, z;
  double scale;
  unsigned char *Impt1, *Impt2;
  unsigned short *Impt5;
  minPix = 0xFFFF;
  maxPix = 0x0000;
  srcPix = Imptr2;
  for (y = 0; y < height; y++) {
    for (x = 0; x < width; x++, srcPix++) {
      if (*srcPix > maxPix)
        maxPix = *srcPix;
      if (*srcPix < minPix)
        minPix = *srcPix;
    }
  }
  if (maxPix == minPix)
    scale = 0.0;
  else
    scale = 255.0 / (maxPix - minPix);
  printf("MinPix %d, MaxPix %d\n", minPix, maxPix);
  Impt1 = Imptr1;
  Impt2 = Imptr1 + width;
  Impt5 = Imptr2;
  for (y = 1; y <= height / 2; y++) {
    for (z = 1; z <= width / 2; z++) {
      assert(Impt1 < end1);
      assert(Impt5 < end2);
      *Impt1++ = mylog(*Impt5++, minPix, maxPix);
      assert(Impt2 < end1);
      assert(Impt5 < end2);
      *Impt2++ = mylog(*Impt5++, minPix, maxPix);
      assert(Impt2 < end1);
      assert(Impt5 < end2);
      *Impt2++ = mylog(*Impt5++, minPix, maxPix);
      assert(Impt1 < end1);
      assert(Impt5 < end2);
      *Impt1++ = mylog(*Impt5++, minPix, maxPix);
    };
    Impt1 += width;
    Impt2 += width;
  }
}
```