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

```asm
<etna_texture_untile>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %edx,-0x54(%rbp)
  mov    %ecx,-0x58(%rbp)
  mov    %r8d,-0x5c(%rbp)
  mov    %r9d,-0x60(%rbp)
  cmpl   $0x4,0x20(%rbp)
  jne    L116
  andl   $0x3fffffff,-0x5c(%rbp)
  mov    0x18(%rbp),%eax
  shr    $0x2,%eax
  mov    %eax,0x18(%rbp)
  movl   $0x0,-0x3c(%rbp)
  jmp    L49
L164:
  mov    -0x58(%rbp),%edx
  mov    -0x3c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  shr    $0x2,%eax
  imul   -0x5c(%rbp),%eax
  mov    %eax,%edx
  mov    -0xc(%rbp),%eax
  and    $0x3,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  mov    %eax,-0x8(%rbp)
  movl   $0x0,-0x38(%rbp)
  jmp    L152
L27:
  mov    -0x54(%rbp),%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  shr    $0x2,%eax
  shl    $0x4,%eax
  mov    %eax,%edx
  mov    -0x8(%rbp),%eax
  add    %eax,%edx
  mov    -0x4(%rbp),%eax
  and    $0x3,%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x3c(%rbp),%eax
  imul   0x18(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x38(%rbp)
L152:
  mov    -0x38(%rbp),%eax
  cmp    -0x60(%rbp),%eax
  jb     L27
  addl   $0x1,-0x3c(%rbp)
L49:
  mov    -0x3c(%rbp),%eax
  cmp    0x10(%rbp),%eax
  jb     L164
  jmp    L153
L116:
  cmpl   $0x2,0x20(%rbp)
  jne    L114
  andl   $0x3fffffff,-0x5c(%rbp)
  mov    0x18(%rbp),%eax
  shr    $0x2,%eax
  mov    %eax,0x18(%rbp)
  movl   $0x0,-0x34(%rbp)
  jmp    L71
L147:
  mov    -0x58(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  shr    $0x2,%eax
  imul   -0x5c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%eax
  and    $0x3,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L8
L105:
  mov    -0x54(%rbp),%edx
  mov    -0x30(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x10(%rbp),%eax
  shr    $0x2,%eax
  shl    $0x4,%eax
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%eax
  and    $0x3,%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x34(%rbp),%eax
  imul   0x18(%rbp),%eax
  mov    %eax,%edx
  mov    -0x30(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x30(%rbp)
L8:
  mov    -0x30(%rbp),%eax
  cmp    -0x60(%rbp),%eax
  jb     L105
  addl   $0x1,-0x34(%rbp)
L71:
  mov    -0x34(%rbp),%eax
  cmp    0x10(%rbp),%eax
  jb     L147
  jmp    L153
L114:
  cmpl   $0x1,0x20(%rbp)
  jne    L57
  andl   $0x3fffffff,-0x5c(%rbp)
  mov    0x18(%rbp),%eax
  shr    $0x2,%eax
  mov    %eax,0x18(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L30
L12:
  mov    -0x58(%rbp),%edx
  mov    -0x2c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  shr    $0x2,%eax
  imul   -0x5c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x24(%rbp),%eax
  and    $0x3,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  mov    %eax,-0x20(%rbp)
  movl   $0x0,-0x28(%rbp)
  jmp    L47
L74:
  mov    -0x54(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x1c(%rbp),%eax
  shr    $0x2,%eax
  shl    $0x4,%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  add    %eax,%edx
  mov    -0x1c(%rbp),%eax
  and    $0x3,%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x2c(%rbp),%eax
  imul   0x18(%rbp),%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x28(%rbp)
L47:
  mov    -0x28(%rbp),%eax
  cmp    -0x60(%rbp),%eax
  jb     L74
  addl   $0x1,-0x2c(%rbp)
L30:
  mov    -0x2c(%rbp),%eax
  cmp    0x10(%rbp),%eax
  jb     L12
  jmp    L153
L57:
  mov    0x20(%rbp),%eax
  mov    %eax,%esi
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L153:
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D0
data_type: string

tool: D0: 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);
  }
}
```