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

```asm
<convert_image_to_DXT5>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xe8,%rsp
  mov    %rdi,0x20(%rsp)
  mov    %esi,%r14d
  mov    %esi,0x38(%rsp)
  mov    %edx,%esi
  mov    %edx,0x6c(%rsp)
  mov    %ecx,0x58(%rsp)
  mov    %fs:0x28,%rdx
  mov    %rdx,0xd8(%rsp)
  xor    %edx,%edx
  movl   $0x0,(%r8)
  test   %r14d,%r14d
  jle    L144
  mov    %ecx,%r15d
  test   %esi,%esi
  jle    L144
  lea    -0x1(%rcx),%edx
  cmp    $0x3,%edx
  ja     L25
  test   %rdi,%rdi
  je     L25
  cmp    $0x2,%ecx
  setg   0x53(%rsp)
  mov    %ecx,%edx
  xor    $0x1,%edx
  mov    %edx,%ebp
  and    $0x1,%ebp
  mov    %edx,%ebx
  and    $0x1,%ebx
  lea    0x3(%r14),%edi
  sar    $0x2,%edi
  lea    0x3(%rsi),%edx
  sar    $0x2,%edx
  imul   %edx,%edi
  shl    $0x4,%edi
  mov    %edi,(%r8)
  call   <malloc@plt>
  mov    %rax,0x70(%rsp)
  mov    %rax,0x60(%rsp)
  lea    0x0(,%r15,4),%eax
  mov    %eax,0x48(%rsp)
  imul   %r14d,%eax
  mov    %eax,0x7c(%rsp)
  imul   %r14d,%r15d
  mov    %r15d,0x28(%rsp)
  lea    -0x4(,%r14,4),%eax
  and    $0xfffffff0,%eax
  test   %r14d,%r14d
  mov    $0x0,%edx
  cmovg  %eax,%edx
  mov    %edx,0x78(%rsp)
  movl   $0x0,0x4c(%rsp)
  movl   $0x0,0x68(%rsp)
  movl   $0x0,0x5c(%rsp)
  mov    $0x1,%eax
  sub    %ebx,%eax
  mov    %ebp,%r14d
  mov    %eax,%r15d
  jmp    L213
L203:
  movslq %r11d,%rcx
  add    0x8(%rsp),%rcx
  add    0x20(%rsp),%rcx
  movslq %r9d,%r8
  lea    0x0(%r13,%r8,1),%rdx
  add    0x10(%rsp),%r8
L55:
  movzbl (%rcx),%eax
  mov    %al,(%rdx)
  movzbl (%rcx,%rsi,1),%eax
  mov    %al,0x1(%rdx)
  movzbl (%rcx,%rsi,2),%eax
  mov    %al,0x2(%rdx)
  mov    %r14d,%eax
  mulb   -0x1(%rcx,%rdi,1)
  sub    %r12d,%eax
  mov    %al,0x3(%rdx)
  add    %rdi,%rcx
  add    $0x4,%rdx
  cmp    %r8,%rdx
  jne    L55
  lea    0x4(%r15,%r9,1),%r9d
L211:
  cmp    $0x3,%ebx
  jg     L209
  movslq %r9d,%rdx
  lea    0x0(%r13,%rdx,1),%rax
  add    0x18(%rsp),%rdx
L147:
  movzbl 0x90(%rsp),%ecx
  mov    %cl,(%rax)
  movzbl 0x91(%rsp),%ecx
  mov    %cl,0x1(%rax)
  movzbl 0x92(%rsp),%ecx
  mov    %cl,0x2(%rax)
  movzbl 0x93(%rsp),%ecx
  mov    %cl,0x3(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L147
  lea    0x4(%rbp,%r9,1),%r9d
L209:
  add    $0x1,%r10d
  add    0x28(%rsp),%r11d
  cmp    %r10d,0x4(%rsp)
  je     L10
L111:
  test   %ebx,%ebx
  jg     L203
  jmp    L211
L117:
  mov    $0x0,%r9d
  jmp    L253
L10:
  mov    0x40(%rsp),%rbp
L253:
  cmpl   $0x3,0x4(%rsp)
  jg     L89
  movslq %r9d,%rax
  lea    0xa0(%rsp,%rax,1),%rcx
  mov    %r9d,%eax
  sub    0x54(%rsp),%eax
  lea    0x40(%rax),%esi
  jmp    L13
L165:
  add    $0x10,%r9d
  add    $0x10,%rcx
  cmp    %esi,%r9d
  je     L89
L13:
  lea    -0x10(%rcx),%rax
L231:
  movzbl 0x90(%rsp),%edx
  mov    %dl,(%rax)
  movzbl 0x91(%rsp),%edx
  mov    %dl,0x1(%rax)
  movzbl 0x92(%rsp),%edx
  mov    %dl,0x2(%rax)
  movzbl 0x93(%rsp),%edx
  mov    %dl,0x3(%rax)
  add    $0x4,%rax
  cmp    %rcx,%rax
  jne    L231
  jmp    L165
L89:
  lea    0x88(%rsp),%rsi
  lea    0x90(%rsp),%rdi
  call   <compress_DDS_alpha_block@plt>
  mov    0x30(%rsp),%rax
  lea    0x8(%rax),%rbx
L163:
  movzbl (%rax),%edx
  mov    %dl,(%rax,%rbp,1)
  add    $0x1,%rax
  cmp    %rbx,%rax
  jne    L163
  lea    0x88(%rsp),%rdx
  lea    0x90(%rsp),%rsi
  mov    $0x4,%edi
  call   <compress_DDS_color_block@plt>
  mov    0x30(%rsp),%rax
L172:
  movzbl (%rax),%edx
  mov    %dl,0x8(%rax,%rbp,1)
  add    $0x1,%rax
  cmp    %rax,%rbx
  jne    L172
  add    $0x10,%rbp
  mov    0x48(%rsp),%ebx
  add    %ebx,0x3c(%rsp)
  mov    0x38(%rsp),%ebx
  cmp    %ebx,0x2c(%rsp)
  jge    L129
L83:
  addl   $0x4,0x2c(%rsp)
  mov    0x2c(%rsp),%eax
  mov    0x38(%rsp),%edi
  lea    0x4(%rdi),%ebx
  sub    %eax,%ebx
  cmp    %edi,%eax
  mov    $0x4,%eax
  cmovl  %eax,%ebx
  cmpl   $0x0,0x4(%rsp)
  jle    L117
  lea    -0x1(%rbx),%r15d
  mov    %r15d,%ecx
  shl    $0x2,%r15d
  mov    $0x3,%r13d
  sub    %ebx,%r13d
  mov    %r13d,%edx
  lea    0x0(,%r13,4),%r8d
  mov    0x4c(%rsp),%r11d
  mov    $0x0,%r9d
  mov    $0x0,%r10d
  movslq 0x58(%rsp),%rdi
  movslq 0x3c(%rsp),%rax
  mov    %rax,0x8(%rsp)
  lea    0x90(%rsp),%r13
  lea    0x94(%rsp),%rax
  lea    (%rax,%rcx,4),%rsi
  mov    %rsi,0x10(%rsp)
  movzbl 0x53(%rsp),%esi
  lea    (%rax,%rdx,4),%rax
  mov    %rax,0x18(%rsp)
  mov    %rbp,0x40(%rsp)
  mov    %r8d,%ebp
  jmp    L111
L129:
  mov    %r12d,%r15d
  mov    0x78(%rsp),%eax
  mov    0x68(%rsp),%ebx
  lea    0x10(%rax,%rbx,1),%eax
  mov    %eax,0x68(%rsp)
  addl   $0x4,0x5c(%rsp)
  mov    0x5c(%rsp),%eax
  mov    0x7c(%rsp),%edi
  add    %edi,0x4c(%rsp)
  cmp    %eax,0x6c(%rsp)
  jle    L148
L213:
  mov    0x6c(%rsp),%ebx
  mov    %ebx,%eax
  mov    0x5c(%rsp),%edi
  sub    %edi,%eax
  lea    0x4(%rdi),%edx
  cmp    %edx,%ebx
  mov    $0x4,%ebx
  cmovg  %ebx,%eax
  mov    %eax,%ebx
  mov    %eax,0x4(%rsp)
  lea    0x88(%rsp),%rax
  mov    %rax,0x30(%rsp)
  mov    0x70(%rsp),%rdx
  sub    %rax,%rdx
  movslq 0x68(%rsp),%rax
  lea    (%rdx,%rax,1),%rbp
  shl    $0x4,%ebx
  mov    %ebx,0x54(%rsp)
  movl   $0x0,0x3c(%rsp)
  movl   $0x0,0x2c(%rsp)
  mov    %r15d,%r12d
  jmp    L83
L144:
  movq   $0x0,0x60(%rsp)
  jmp    L148
L25:
  movq   $0x0,0x60(%rsp)
L148:
  mov    0xd8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L186
  mov    0x60(%rsp),%rax
  add    $0xe8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L186:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned char *convert_image_to_DXT5(const unsigned char *const uncompressed, int width, int height, int channels, int *out_size) {
  unsigned char *compressed;
  int i, j, x, y;
  unsigned char ublock[16 * 4];
  unsigned char cblock[8];
  int index = 0, chan_step = 1;
  int block_count = 0, has_alpha;
  *out_size = 0;
  if ((width < 1) || (height < 1) || (NULL == uncompressed) || (channels < 1) || (channels > 4)) {
    return NULL;
  }
  if (channels < 3) {
    chan_step = 0;
  }
  has_alpha = 1 - (channels & 1);
  *out_size = ((width + 3) >> 2) * ((height + 3) >> 2) * 16;
  compressed = (unsigned char *)malloc(*out_size);
  for (j = 0; j < height; j += 4) {
    for (i = 0; i < width; i += 4) {
      int idx = 0;
      int mx = 4, my = 4;
      if (j + 4 >= height) {
        my = height - j;
      }
      if (i + 4 >= width) {
        mx = width - i;
      }
      for (y = 0; y < my; ++y) {
        for (x = 0; x < mx; ++x) {
          ublock[idx++] = uncompressed[(j + y) * width * channels + (i + x) * channels];
          ublock[idx++] = uncompressed[(j + y) * width * channels + (i + x) * channels + chan_step];
          ublock[idx++] = uncompressed[(j + y) * width * channels + (i + x) * channels + chan_step + chan_step];
          ublock[idx++] = has_alpha * uncompressed[(j + y) * width * channels + (i + x) * channels + channels - 1] + (1 - has_alpha) * 255;
        }
        for (x = mx; x < 4; ++x) {
          ublock[idx++] = ublock[0];
          ublock[idx++] = ublock[1];
          ublock[idx++] = ublock[2];
          ublock[idx++] = ublock[3];
        }
      }
      for (y = my; y < 4; ++y) {
        for (x = 0; x < 4; ++x) {
          ublock[idx++] = ublock[0];
          ublock[idx++] = ublock[1];
          ublock[idx++] = ublock[2];
          ublock[idx++] = ublock[3];
        }
      }
      compress_DDS_alpha_block(ublock, cblock);
      for (x = 0; x < 8; ++x) {
        compressed[index++] = cblock[x];
      }
      ++block_count;
      compress_DDS_color_block(4, ublock, cblock);
      for (x = 0; x < 8; ++x) {
        compressed[index++] = cblock[x];
      }
    }
  }
  return compressed;
}
```