user: Translate the below assembly code into C programming language:

```asm
<etna_texture_untile>:
  endbr64
  push   %r13
  mov    %edx,%r10d
  mov    %ecx,%r11d
  push   %r12
  push   %rbp
  mov    %r8d,%ebp
  push   %rbx
  mov    0x38(%rsp),%r8d
  mov    0x28(%rsp),%r12d
  mov    0x30(%rsp),%r13d
  cmp    $0x4,%r8d
  je     L132
  cmp    $0x2,%r8d
  je     L57
  cmp    $0x1,%r8d
  jne    L125
  and    $0x3fffffff,%ebp
  shr    $0x2,%r13d
  test   %r12d,%r12d
  je     L53
  test   %r9d,%r9d
  je     L53
  mov    %edx,%ebx
  lea    (%r12,%rcx,1),%r8d
  add    %edx,%r9d
  neg    %ebx
  nop
L14:
  mov    %r11d,%eax
  mov    %r11d,%edx
  shr    $0x2,%eax
  and    $0x3,%edx
  imul   %ebp,%eax
  lea    (%rax,%rdx,4),%r12d
  mov    %r10d,%eax
  cs nopw 0x0(%rax,%rax,1)
L32:
  mov    %eax,%ecx
  mov    %eax,%edx
  shr    $0x2,%ecx
  and    $0x3,%edx
  shl    $0x4,%ecx
  add    %r12d,%edx
  add    %ecx,%edx
  mov    %edx,%edx
  mov    (%rsi,%rdx,4),%ecx
  lea    (%rbx,%rax,1),%edx
  add    $0x1,%eax
  mov    %ecx,(%rdi,%rdx,4)
  cmp    %eax,%r9d
  jne    L32
  add    $0x1,%r11d
  add    %r13d,%ebx
  cmp    %r11d,%r8d
  jne    L14
L53:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L57:
  and    $0x3fffffff,%ebp
  shr    $0x2,%r13d
  test   %r12d,%r12d
  je     L53
  test   %r9d,%r9d
  je     L53
  mov    %edx,%ebx
  lea    (%r12,%rcx,1),%r8d
  add    %edx,%r9d
  neg    %ebx
  nopw   0x0(%rax,%rax,1)
L36:
  mov    %r11d,%eax
  mov    %r11d,%edx
  shr    $0x2,%eax
  and    $0x3,%edx
  imul   %ebp,%eax
  lea    (%rax,%rdx,4),%r12d
  mov    %r10d,%eax
  cs nopw 0x0(%rax,%rax,1)
L45:
  mov    %eax,%ecx
  mov    %eax,%edx
  shr    $0x2,%ecx
  and    $0x3,%edx
  shl    $0x4,%ecx
  add    %r12d,%edx
  add    %ecx,%edx
  mov    %edx,%edx
  mov    (%rsi,%rdx,4),%ecx
  lea    (%rbx,%rax,1),%edx
  add    $0x1,%eax
  mov    %ecx,(%rdi,%rdx,4)
  cmp    %eax,%r9d
  jne    L45
  add    $0x1,%r11d
  add    %r13d,%ebx
  cmp    %r11d,%r8d
  jne    L36
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
L132:
  and    $0x3fffffff,%ebp
  shr    $0x2,%r13d
  test   %r12d,%r12d
  je     L53
  test   %r9d,%r9d
  je     L53
  mov    %edx,%r8d
  add    %ecx,%r12d
  add    %edx,%r9d
  neg    %r8d
  nopl   0x0(%rax,%rax,1)
L135:
  mov    %r11d,%eax
  mov    %r11d,%edx
  shr    $0x2,%eax
  and    $0x3,%edx
  imul   %ebp,%eax
  lea    (%rax,%rdx,4),%ebx
  mov    %r10d,%eax
  nopl   (%rax)
L122:
  mov    %eax,%ecx
  mov    %eax,%edx
  shr    $0x2,%ecx
  and    $0x3,%edx
  shl    $0x4,%ecx
  add    %ebx,%edx
  add    %ecx,%edx
  mov    %edx,%edx
  mov    (%rsi,%rdx,4),%ecx
  lea    (%r8,%rax,1),%edx
  add    $0x1,%eax
  mov    %ecx,(%rdi,%rdx,4)
  cmp    %r9d,%eax
  jne    L122
  add    $0x1,%r11d
  add    %r13d,%r8d
  cmp    %r12d,%r11d
  jne    L135
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L125:
  pop    %rbx
  mov    %r8d,%esi
  lea    D9(%rip),%rdi
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1050 <printf@plt>
```

tool_calls: name: read_data
arguments: tag: D9
datatype: string

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