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

```asm
<etna_texture_untile>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edx,%ebp
  mov    %ecx,%r10d
  mov    %r8d,%r12d
  mov    0x30(%rsp),%r13d
  mov    0x40(%rsp),%eax
  cmp    $0x4,%eax
  je     L34
  cmp    $0x2,%eax
  je     L84
  cmp    $0x1,%eax
  jne    L59
  and    $0x3fffffff,%r12d
  mov    0x38(%rsp),%r14d
  shr    $0x2,%r14d
  test   %r13d,%r13d
  je     L51
  mov    %edx,%r11d
  neg    %r11d
  lea    0x0(%r13,%rcx,1),%r8d
  lea    (%r9,%rdx,1),%r13d
L111:
  mov    %r10d,%eax
  shr    $0x2,%eax
  imul   %r12d,%eax
  mov    %r10d,%edx
  and    $0x3,%edx
  lea    (%rax,%rdx,4),%ebx
  test   %r9d,%r9d
  je     L80
  mov    %ebp,%eax
L14:
  mov    %eax,%ecx
  shr    $0x2,%ecx
  shl    $0x4,%ecx
  mov    %eax,%edx
  and    $0x3,%edx
  add    %ebx,%edx
  lea    (%rcx,%rdx,1),%edx
  mov    (%rsi,%rdx,4),%ecx
  lea    (%rax,%r11,1),%edx
  mov    %ecx,(%rdi,%rdx,4)
  add    $0x1,%eax
  cmp    %eax,%r13d
  jne    L14
L80:
  add    $0x1,%r10d
  add    %r14d,%r11d
  cmp    %r8d,%r10d
  jne    L111
  jmp    L51
L34:
  and    $0x3fffffff,%r12d
  mov    0x38(%rsp),%r14d
  shr    $0x2,%r14d
  test   %r13d,%r13d
  je     L51
  mov    %edx,%r11d
  neg    %r11d
  add    %ecx,%r13d
  lea    (%r9,%rdx,1),%ebx
L148:
  mov    %r10d,%eax
  shr    $0x2,%eax
  imul   %r12d,%eax
  mov    %r10d,%edx
  and    $0x3,%edx
  lea    (%rax,%rdx,4),%r8d
  test   %r9d,%r9d
  je     L150
  mov    %ebp,%eax
L76:
  mov    %eax,%ecx
  shr    $0x2,%ecx
  shl    $0x4,%ecx
  mov    %eax,%edx
  and    $0x3,%edx
  add    %r8d,%edx
  lea    (%rcx,%rdx,1),%edx
  mov    (%rsi,%rdx,4),%ecx
  lea    (%rax,%r11,1),%edx
  mov    %ecx,(%rdi,%rdx,4)
  add    $0x1,%eax
  cmp    %ebx,%eax
  jne    L76
L150:
  add    $0x1,%r10d
  add    %r14d,%r11d
  cmp    %r10d,%r13d
  jne    L148
L51:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L84:
  and    $0x3fffffff,%r12d
  mov    0x38(%rsp),%r14d
  shr    $0x2,%r14d
  test   %r13d,%r13d
  je     L51
  mov    %edx,%r11d
  neg    %r11d
  lea    0x0(%r13,%rcx,1),%r8d
  lea    (%r9,%rdx,1),%r13d
L168:
  mov    %r10d,%eax
  shr    $0x2,%eax
  imul   %r12d,%eax
  mov    %r10d,%edx
  and    $0x3,%edx
  lea    (%rax,%rdx,4),%ebx
  test   %r9d,%r9d
  je     L98
  mov    %ebp,%eax
L118:
  mov    %eax,%ecx
  shr    $0x2,%ecx
  shl    $0x4,%ecx
  mov    %eax,%edx
  and    $0x3,%edx
  add    %ebx,%edx
  lea    (%rcx,%rdx,1),%edx
  mov    (%rsi,%rdx,4),%ecx
  lea    (%r11,%rax,1),%edx
  mov    %ecx,(%rdi,%rdx,4)
  add    $0x1,%eax
  cmp    %eax,%r13d
  jne    L118
L98:
  add    $0x1,%r10d
  add    %r14d,%r11d
  cmp    %r8d,%r10d
  jne    L168
  jmp    L51
L59:
  mov    %eax,%esi
  lea    D7(%rip),%rdi
  call   <printf@plt>
  jmp    L51
```

tool_calls: name: parse_data
arguments: label: D7
type_guessed: string

tool: D7: etna_texture_tile: unhandled element size %i


assistant: ```c
void etna_texture_untile(void *dest, void *src, unsigned basex, unsigned basey, unsigned src_stride, unsigned width, unsigned height, unsigned dst_stride, unsigned elmtsize) {
  if (elmtsize == 4) {
    src_stride = (src_stride * (4)) / sizeof(uint32_t);
    dst_stride /= sizeof(uint32_t);
    for (unsigned dsty = 0; dsty < height; ++dsty) {
      unsigned srcy = basey + dsty;
      unsigned sy = (srcy / (4)) * src_stride + (srcy % (4)) * (4);
      for (unsigned dstx = 0; dstx < width; ++dstx) {
        unsigned srcx = basex + dstx;
        ((uint32_t *)dest)[dsty * dst_stride + dstx] = ((uint32_t *)src)[sy + (srcx / (4)) * ((4) * (4)) + (srcx % (4))];
      }
    };
  } else if (elmtsize == 2) {
    src_stride = (src_stride * (4)) / sizeof(uint16_t);
    dst_stride /= sizeof(uint16_t);
    for (unsigned dsty = 0; dsty < height; ++dsty) {
      unsigned srcy = basey + dsty;
      unsigned sy = (srcy / (4)) * src_stride + (srcy % (4)) * (4);
      for (unsigned dstx = 0; dstx < width; ++dstx) {
        unsigned srcx = basex + dstx;
        ((uint16_t *)dest)[dsty * dst_stride + dstx] = ((uint16_t *)src)[sy + (srcx / (4)) * ((4) * (4)) + (srcx % (4))];
      }
    };
  } else if (elmtsize == 1) {
    src_stride = (src_stride * (4)) / sizeof(uint8_t);
    dst_stride /= sizeof(uint8_t);
    for (unsigned dsty = 0; dsty < height; ++dsty) {
      unsigned srcy = basey + dsty;
      unsigned sy = (srcy / (4)) * src_stride + (srcy % (4)) * (4);
      for (unsigned dstx = 0; dstx < width; ++dstx) {
        unsigned srcx = basex + dstx;
        ((uint8_t *)dest)[dsty * dst_stride + dstx] = ((uint8_t *)src)[sy + (srcx / (4)) * ((4) * (4)) + (srcx % (4))];
      }
    };
  } else {
    printf("etna_texture_tile: unhandled element size %i\n", elmtsize);
  }
}
```