user: 请将以下的汇编代码转换成C语言代码:

```asm
<halveImage_short>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,%r13d
  mov    %esi,0x10(%rsp)
  mov    %edx,%r14d
  mov    %rcx,%r12
  mov    %r8,%rbx
  mov    %r9d,%ebp
  cmp    $0x1,%esi
  je     L2
  cmp    $0x1,%edx
  je     L2
  mov    0x10(%rsp),%edi
  mov    %edi,%r9d
  shr    $0x1f,%r9d
  add    %edi,%r9d
  sar    %r9d
  mov    %edx,%eax
  shr    $0x1f,%eax
  add    %edx,%eax
  sar    %eax
  mov    %eax,0x14(%rsp)
  imul   0x68(%rsp),%edi
  mov    0x60(%rsp),%eax
  sub    %edi,%eax
  cmpl   $0x0,0x70(%rsp)
  je     L148
  cmp    $0x1,%r14d
  jle    L147
  lea    -0x1(%r13),%edx
  add    $0x1,%rdx
  lea    0x0(,%rdx,4),%r10
  movslq %ebp,%rbp
  imul   %rbp,%rdx
  mov    %rdx,0x8(%rsp)
  mov    $0x0,%r11d
  movslq 0x68(%rsp),%rdi
  movslq 0x60(%rsp),%rsi
  cltq
  add    %rsi,%rax
  mov    %rax,0x18(%rsp)
  jmp    L140
L2:
  mov    0x10(%rsp),%r15d
  cmp    $0x1,%r15d
  setne  %dil
  cmp    $0x1,%r14d
  setne  %al
  or     %eax,%edi
  movzbl %dil,%edi
  call   <assert@plt>
  sub    $0x8,%rsp
  mov    0x78(%rsp),%eax
  push   %rax
  mov    0x78(%rsp),%eax
  push   %rax
  mov    0x78(%rsp),%eax
  push   %rax
  mov    %ebp,%r9d
  mov    %rbx,%r8
  mov    %r12,%rcx
  mov    %r14d,%edx
  mov    %r15d,%esi
  mov    %r13d,%edi
  call   <halve1Dimage_short@plt>
  add    $0x20,%rsp
L147:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L148:
  cmp    $0x1,%r14d
  jle    L147
  lea    -0x1(%r13),%edx
  add    $0x1,%rdx
  lea    0x0(,%rdx,4),%rdi
  movslq %ebp,%rbp
  imul   %rbp,%rdx
  mov    %rdx,%r15
  mov    0x70(%rsp),%r8d
  movslq 0x68(%rsp),%rsi
  movslq 0x60(%rsp),%r10
  cltq
  add    %r10,%rax
  mov    %rax,0x8(%rsp)
  jmp    L89
L164:
  mov    (%rdx,%rsi,1),%eax
  add    (%rdx),%eax
  add    (%rdx,%r10,1),%eax
  lea    (%rdx,%rsi,1),%rcx
  add    (%rcx,%r10,1),%eax
  lea    0x5(%rax),%ecx
  add    $0x2,%eax
  cmovns %eax,%ecx
  sar    $0x2,%ecx
  mov    %ecx,(%rbx)
  add    $0x4,%rbx
  add    %rbp,%rdx
  cmp    %r11,%rbx
  jne    L164
  add    %r15,%r12
  mov    %r11,%rbx
L57:
  add    %rsi,%r12
  add    $0x1,%r14d
  cmp    %r14d,%r9d
  jle    L106
L196:
  lea    (%rbx,%rdi,1),%r11
  mov    %r12,%rdx
  test   %r13d,%r13d
  jg     L164
  jmp    L57
L106:
  add    0x8(%rsp),%r12
  add    $0x1,%r8d
  cmp    %r8d,0x14(%rsp)
  jle    L147
L89:
  mov    0x70(%rsp),%r14d
  cmpl   $0x1,0x10(%rsp)
  jg     L196
  jmp    L106
L193:
  mov    0x4(%rdx),%eax
  shl    $0x8,%eax
  or     (%rdx),%eax
  mov    0x4(%rdx,%rdi,1),%r8d
  shl    $0x8,%r8d
  or     (%rdx,%rdi,1),%r8d
  add    %r8d,%eax
  mov    0x4(%rdx,%rsi,1),%r8d
  shl    $0x8,%r8d
  or     (%rdx,%rsi,1),%r8d
  add    %eax,%r8d
  lea    (%rdx,%rdi,1),%r14
  mov    0x4(%r14,%rsi,1),%eax
  shl    $0x8,%eax
  or     (%r14,%rsi,1),%eax
  add    %r8d,%eax
  lea    0x5(%rax),%r8d
  add    $0x2,%eax
  cmovs  %r8d,%eax
  sar    $0x2,%eax
  mov    %eax,(%rbx)
  add    $0x4,%rbx
  add    %rbp,%rdx
  cmp    %rcx,%rbx
  jne    L193
  add    0x8(%rsp),%r12
  mov    %rcx,%rbx
L46:
  add    %rdi,%r12
  add    $0x1,%r15d
  cmp    %r15d,%r9d
  jle    L163
L172:
  lea    (%rbx,%r10,1),%rcx
  mov    %r12,%rdx
  test   %r13d,%r13d
  jg     L193
  jmp    L46
L163:
  add    0x18(%rsp),%r12
  add    $0x1,%r11d
  cmp    %r11d,0x14(%rsp)
  jle    L147
L140:
  mov    $0x0,%r15d
  cmpl   $0x1,0x10(%rsp)
  jg     L172
  jmp    L163
```

assistant: ```c
void halveImage_short(GLint components, GLuint width, GLuint height, const GLshort *datain, GLshort *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes) {
  int i, j, k;
  int newwidth, newheight;
  int padBytes;
  GLshort *s;
  const char *t;
  if (width == 1 || height == 1) {
    assert(!(width == 1 && height == 1));
    halve1Dimage_short(components, width, height, datain, dataout, element_size, ysize, group_size, myswap_bytes);
    return;
  }
  newwidth = width / 2;
  newheight = height / 2;
  padBytes = ysize - (width * group_size);
  s = dataout;
  t = (const char *)datain;
  if (!myswap_bytes)
    for (i = 0; i < newheight; i++) {
      for (j = 0; j < newwidth; j++) {
        for (k = 0; k < components; k++) {
          s[0] = (*(const GLshort *)t + *(const GLshort *)(t + group_size) + *(const GLshort *)(t + ysize) + *(const GLshort *)(t + ysize + group_size) + 2) / 4;
          s++;
          t += element_size;
        }
        t += group_size;
      }
      t += padBytes;
      t += ysize;
    }
  else
    for (i = 0; i < newheight; i++) {
      for (j = 0; j < newwidth; j++) {
        for (k = 0; k < components; k++) {
          GLushort b;
          GLint buf;
          b = (GLushort)(((GLushort)((const GLubyte *)(t))[1]) << 8 | ((const GLubyte *)(t))[0]);
          buf = *(const GLshort *)&b;
          b = (GLushort)(((GLushort)((const GLubyte *)(t + group_size))[1]) << 8 | ((const GLubyte *)(t + group_size))[0]);
          buf += *(const GLshort *)&b;
          b = (GLushort)(((GLushort)((const GLubyte *)(t + ysize))[1]) << 8 | ((const GLubyte *)(t + ysize))[0]);
          buf += *(const GLshort *)&b;
          b = (GLushort)(((GLushort)((const GLubyte *)(t + ysize + group_size))[1]) << 8 | ((const GLubyte *)(t + ysize + group_size))[0]);
          buf += *(const GLshort *)&b;
          s[0] = (GLshort)((buf + 2) / 4);
          s++;
          t += element_size;
        }
        t += group_size;
      }
      t += padBytes;
      t += ysize;
    }
}
```