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

```asm
<__int32_t_encode_array>:
  endbr64
  lea    0x0(,%r8,4),%r9d
  cmp    %edx,%r9d
  jg     L32
  test   %r8d,%r8d
  jle    L81
  movslq %r8d,%r11
  movslq %esi,%r10
  push   %rbx
  mov    %r8d,%edx
  shl    $0x2,%r11
  lea    (%rdi,%r10,4),%rax
  lea    (%r10,%r11,1),%rbx
  lea    (%rdi,%rbx,4),%rbx
  cmp    %rbx,%rcx
  setae  %bl
  add    %rcx,%r11
  cmp    %r11,%rax
  setae  %r11b
  or     %r11b,%bl
  je     L88
  cmp    $0x1,%r8d
  je     L88
  lea    -0x1(%r8),%r11d
  cmp    $0x2,%r11d
  jbe    L27
  mov    %r8d,%r11d
  movdqa D15(%rip),%xmm5
  mov    %rcx,%rdx
  shr    $0x2,%r11d
  sub    $0x1,%r11d
  shl    $0x4,%r11
  lea    0x10(%rcx,%r11,1),%r11
  nopl   0x0(%rax,%rax,1)
L47:
  movdqu (%rdx),%xmm2
  add    $0x10,%rdx
  add    $0x40,%rax
  movdqa %xmm2,%xmm0
  movdqa %xmm2,%xmm1
  movdqa %xmm2,%xmm4
  psrld  $0x18,%xmm0
  psrad  $0x10,%xmm1
  pand   %xmm5,%xmm2
  psrad  $0x8,%xmm4
  pand   %xmm5,%xmm1
  movdqa %xmm0,%xmm3
  pand   %xmm5,%xmm4
  punpckldq %xmm4,%xmm3
  punpckhdq %xmm4,%xmm0
  movdqa %xmm1,%xmm4
  punpckldq %xmm2,%xmm4
  punpckhdq %xmm2,%xmm1
  movdqa %xmm3,%xmm2
  punpckldq %xmm4,%xmm2
  punpckhdq %xmm4,%xmm3
  movups %xmm2,-0x40(%rax)
  movdqa %xmm0,%xmm2
  punpckhdq %xmm1,%xmm0
  punpckldq %xmm1,%xmm2
  movups %xmm3,-0x30(%rax)
  movups %xmm2,-0x20(%rax)
  movups %xmm0,-0x10(%rax)
  cmp    %rdx,%r11
  jne    L47
  mov    %r8d,%r11d
  and    $0xfffffffc,%r11d
  mov    %r11d,%eax
  lea    (%rsi,%r11,4),%esi
  cmp    %r11d,%r8d
  je     L24
  mov    %r8d,%edx
  sub    %r11d,%edx
  cmp    $0x1,%edx
  je     L16
L106:
  movq   (%rcx,%r11,4),%xmm2
  lea    (%r10,%r11,4),%r8
  movq   D15(%rip),%xmm3
  lea    (%rdi,%r8,4),%r8
  movdqa %xmm2,%xmm0
  movdqa %xmm2,%xmm1
  movdqa %xmm2,%xmm4
  psrld  $0x18,%xmm0
  psrad  $0x10,%xmm1
  pand   %xmm3,%xmm2
  psrad  $0x8,%xmm4
  pand   %xmm3,%xmm1
  pand   %xmm3,%xmm4
  movdqa %xmm0,%xmm3
  punpckldq %xmm4,%xmm3
  punpckldq %xmm4,%xmm0
  movdqa %xmm1,%xmm4
  punpckldq %xmm2,%xmm4
  punpckldq %xmm2,%xmm1
  movdqa %xmm3,%xmm2
  pshufd $0xe,%xmm0,%xmm0
  pshufd $0xe,%xmm1,%xmm1
  punpckldq %xmm4,%xmm2
  movq   %xmm2,(%r8)
  punpckldq %xmm4,%xmm3
  movdqa %xmm0,%xmm2
  punpckldq %xmm1,%xmm0
  pshufd $0xe,%xmm3,%xmm3
  punpckldq %xmm1,%xmm2
  pshufd $0xe,%xmm0,%xmm0
  movq   %xmm3,0x8(%r8)
  movq   %xmm2,0x10(%r8)
  movq   %xmm0,0x18(%r8)
  mov    %edx,%r8d
  and    $0xfffffffe,%r8d
  lea    (%rsi,%r8,4),%esi
  add    %r8d,%eax
  cmp    %r8d,%edx
  je     L24
L16:
  cltq
  movslq %esi,%rsi
  mov    (%rcx,%rax,4),%eax
  mov    %eax,%edx
  mov    %eax,%ecx
  movzbl %ah,%ebx
  movzbl %al,%eax
  sar    $0x10,%edx
  shr    $0x18,%ecx
  movd   %ebx,%xmm1
  movd   %eax,%xmm6
  movzbl %dl,%edx
  movd   %ecx,%xmm0
  punpckldq %xmm6,%xmm1
  movd   %edx,%xmm7
  punpckldq %xmm7,%xmm0
  punpcklqdq %xmm1,%xmm0
  movups %xmm0,(%rdi,%rsi,4)
L24:
  mov    %r9d,%eax
  pop    %rbx
  ret
  nopl   0x0(%rax)
L88:
  lea    -0x1(%r8),%eax
  sub    %r10,%rcx
  lea    0x4(%r10,%rax,4),%r8
  mov    %r10,%rax
  nop
L83:
  mov    (%rcx,%rax,1),%edx
  mov    %edx,%ebx
  mov    %edx,%esi
  shr    $0x18,%ebx
  sar    $0x10,%esi
  movd   %ebx,%xmm0
  movzbl %sil,%esi
  movzbl %dh,%ebx
  movzbl %dl,%edx
  movd   %ebx,%xmm1
  movd   %edx,%xmm6
  movd   %esi,%xmm7
  punpckldq %xmm6,%xmm1
  punpckldq %xmm7,%xmm0
  punpcklqdq %xmm1,%xmm0
  movups %xmm0,(%rdi,%rax,4)
  add    $0x4,%rax
  cmp    %r8,%rax
  jne    L83
  mov    %r9d,%eax
  pop    %rbx
  ret
L32:
  mov    $0xffffffff,%r9d
L81:
  mov    %r9d,%eax
  ret
L27:
  xor    %r11d,%r11d
  xor    %eax,%eax
  jmp    L106
```

tool_calls: name: read_data
arguments: data_tag: D15
type_guessed: byte[16]

tool: {"D15": [0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00]}

assistant: ```c
int __int32_t_encode_array(void *_buf, int offset, int maxlen, const int32_t *p, int elements) {
  int total_size = sizeof(int32_t) * elements;
  uint8_t *buf = (uint8_t *)_buf;
  int pos = offset;
  int element;
  if (maxlen < total_size)
    return -1;
  const uint32_t *unsigned_p = (const uint32_t *)p;
  for (element = 0; element < elements; element++) {
    const uint32_t v = unsigned_p[element];
    buf[pos++] = (v >> 24) & 0xff;
    buf[pos++] = (v >> 16) & 0xff;
    buf[pos++] = (v >> 8) & 0xff;
    buf[pos++] = (v & 0xff);
  }
  return total_size;
}
```