user: Converte this assembly snippet into its equivalent C code:

```asm
<RGB24toRGB32>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %edx,0x18(%rsp)
  mov    %ecx,%r12d
  mov    %r8d,0x10(%rsp)
  mov    %r9d,%ebp
  mov    0x90(%rsp),%r15
  mov    0xa8(%rsp),%r13d
  mov    0xb0(%rsp),%r14d
  mov    0xc0(%rsp),%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x34(%rsp),%rax
  push   %rax
  lea    0x38(%rsp),%rax
  push   %rax
  mov    0xd8(%rsp),%eax
  push   %rax
  push   %rbx
  mov    0xd8(%rsp),%eax
  push   %rax
  push   %r14
  push   %r13
  mov    0xd8(%rsp),%eax
  push   %rax
  mov    0xd8(%rsp),%eax
  push   %rax
  push   %r15
  mov    0xd8(%rsp),%eax
  push   %rax
  mov    0xd8(%rsp),%eax
  push   %rax
  call   <chk_args@plt>
  add    $0x60,%rsp
  test   %eax,%eax
  je     L29
  test   %r13d,%r13d
  js     L283
L134:
  test   %r12d,%r12d
  js     L320
L354:
  mov    0x30(%rsp),%eax
  cmp    $0x1,%eax
  je     L358
  cmp    $0x2,%eax
  jne    L124
  cmpl   $0x2,0x34(%rsp)
  jne    L82
  lea    (%r14,%r14,2),%eax
  movslq %eax,%rdx
  mov    %r13d,%eax
  imul   0xb8(%rsp),%eax
  cltq
  add    %rdx,%rax
  add    %r15,%rax
  mov    0x10(%rsp),%edx
  shl    $0x2,%edx
  movslq %edx,%rdx
  imul   %r12d,%ebp
  movslq %ebp,%rcx
  lea    (%rdx,%rcx,1),%rbp
  add    0x8(%rsp),%rbp
  cmpl   $0x0,0xc8(%rsp)
  jle    L43
  lea    0x0(,%rbx,8),%edi
  mov    %edi,0x8(%rsp)
  movslq %edi,%rdx
  neg    %rdx
  mov    %rdx,0x10(%rsp)
  movslq %r13d,%r13
  lea    (%rbx,%rbx,2),%edx
  movslq %edx,%rdx
  sub    %rdx,%r13
  mov    %r13,0x20(%rsp)
  lea    (%r12,%r12,1),%edx
  movslq %edx,%rdi
  mov    %rdi,0x18(%rsp)
  mov    $0x0,%r13d
  mov    %r14d,%r15d
  and    $0x3,%r15d
  lea    0x1(%r14,%rbx,1),%r14d
  movslq %r12d,%rdi
  mov    %rdi,0x28(%rsp)
  jmp    L115
L283:
  mov    0xa0(%rsp),%eax
  sub    $0x1,%eax
  imul   %r13d,%eax
  cltq
  sub    %rax,%r15
  jmp    L134
L320:
  mov    0x18(%rsp),%eax
  sub    $0x1,%eax
  imul   %r12d,%eax
  cltq
  sub    %rax,0x8(%rsp)
  jmp    L354
L358:
  mov    $0xffffffff,%eax
  cmpl   $0x1,0x34(%rsp)
  jne    L69
  lea    (%r14,%r14,2),%eax
  cltq
  mov    %r13d,%edx
  imul   0xb8(%rsp),%edx
  movslq %edx,%rdx
  add    %rdx,%rax
  add    %r15,%rax
  mov    0x10(%rsp),%r8d
  shl    $0x2,%r8d
  movslq %r8d,%r8
  mov    %ebp,%edx
  imul   %r12d,%edx
  movslq %edx,%rdx
  add    %rdx,%r8
  add    0x8(%rsp),%r8
  cmpl   $0x0,0x88(%rsp)
  jle    L71
  mov    0x80(%rsp),%ebx
  lea    0x0(,%rbx,4),%ecx
  mov    %ebx,%edx
  sub    %ecx,%edx
  add    %r13d,%edx
  movslq %edx,%r15
  sub    %ecx,%r12d
  movslq %r12d,%rbx
  mov    %rbx,0x8(%rsp)
  mov    $0x0,%ebx
  mov    %r14d,%ebp
  and    $0x3,%ebp
  mov    0x80(%rsp),%edi
  lea    0x1(%rdi,%r14,1),%r10d
  mov    %r15,0x10(%rsp)
  mov    %edi,%r13d
  mov    0x88(%rsp),%r15d
  jmp    L37
L341:
  mov    %rax,%r9
  jmp    L241
L311:
  mov    %r13d,%edi
L154:
  cmp    $0x3,%edi
  jle    L341
  lea    -0x4(%rdi),%r12d
  shr    $0x2,%r12d
  lea    0x1(%r12),%r11d
  mov    %r11d,%r11d
  lea    (%r11,%r11,2),%rdx
  lea    (%rax,%rdx,4),%r9
  mov    %r8,%rsi
L290:
  mov    (%rax),%ecx
  mov    0x4(%rax),%edx
  mov    %ecx,%r14d
  and    $0xffffff,%r14d
  mov    %r14d,(%rsi)
  shr    $0x18,%ecx
  mov    %edx,%r14d
  shl    $0x8,%r14d
  or     %r14d,%ecx
  and    $0xffffff,%ecx
  mov    %ecx,0x4(%rsi)
  mov    0x8(%rax),%ecx
  shr    $0x10,%edx
  mov    %ecx,%r14d
  shl    $0x10,%r14d
  or     %r14d,%edx
  and    $0xffffff,%edx
  mov    %edx,0x8(%rsi)
  shr    $0x8,%ecx
  mov    %ecx,0xc(%rsi)
  add    $0x10,%rsi
  add    $0xc,%rax
  cmp    %r9,%rax
  jne    L290
  shl    $0x4,%r11
  add    %r11,%r8
  neg    %r12d
  lea    -0x4(%rdi,%r12,4),%edi
L241:
  test   %edi,%edi
  je     L141
  mov    %edi,%eax
  lea    (%r8,%rax,4),%rsi
  mov    %r8,%rcx
  mov    %r9,%rdx
L356:
  movzbl 0x1(%rdx),%eax
  shl    $0x8,%eax
  movzbl 0x2(%rdx),%r11d
  shl    $0x10,%r11d
  or     %r11d,%eax
  movzbl (%rdx),%r11d
  or     %r11d,%eax
  mov    %eax,(%rcx)
  add    $0x4,%rcx
  add    $0x3,%rdx
  cmp    %rsi,%rcx
  jne    L356
  lea    -0x1(%rdi),%eax
  add    $0x1,%rax
  lea    (%r8,%rax,4),%r8
  lea    (%rax,%rax,2),%rax
  add    %rax,%r9
L141:
  mov    0x10(%rsp),%rax
  add    %r9,%rax
  add    0x8(%rsp),%r8
  add    $0x1,%ebx
  cmp    %ebx,%r15d
  je     L123
L37:
  test   %ebp,%ebp
  je     L311
  mov    %r13d,%edi
  test   %r13d,%r13d
  je     L311
L415:
  movzbl 0x1(%rax),%edx
  shl    $0x8,%edx
  movzbl 0x2(%rax),%ecx
  shl    $0x10,%ecx
  or     %ecx,%edx
  movzbl (%rax),%ecx
  or     %ecx,%edx
  mov    %edx,(%r8)
  add    $0x4,%r8
  add    $0x3,%rax
  mov    %r10d,%edx
  sub    %edi,%edx
  sub    $0x1,%edi
  test   $0x3,%dl
  je     L154
  test   %edi,%edi
  jne    L415
  jmp    L154
L383:
  mov    %rax,%r12
  jmp    L209
L350:
  mov    %ebx,%edi
L6:
  cmp    $0x3,%edi
  jle    L383
  lea    -0x4(%rdi),%r9d
  shr    $0x2,%r9d
  lea    0x1(%r9),%r8d
  mov    %r8d,%r8d
  lea    (%r8,%r8,2),%rdx
  lea    (%rax,%rdx,4),%r12
  mov    %rbp,%rdx
L58:
  mov    (%rax),%esi
  mov    0x4(%rax),%ecx
  mov    %esi,%r10d
  and    $0xffffff,%r10d
  mov    %r10d,(%rdx)
  mov    %r10d,0x4(%rdx)
  shr    $0x18,%esi
  mov    %ecx,%r10d
  shl    $0x8,%r10d
  or     %r10d,%esi
  and    $0xffffff,%esi
  mov    %esi,0x8(%rdx)
  mov    %esi,0xc(%rdx)
  mov    0x8(%rax),%esi
  shr    $0x10,%ecx
  mov    %esi,%r10d
  shl    $0x10,%r10d
  or     %r10d,%ecx
  and    $0xffffff,%ecx
  mov    %ecx,0x10(%rdx)
  mov    %ecx,0x14(%rdx)
  shr    $0x8,%esi
  mov    %esi,0x18(%rdx)
  mov    %esi,0x1c(%rdx)
  add    $0x20,%rdx
  add    $0xc,%rax
  cmp    %r12,%rax
  jne    L58
  shl    $0x5,%r8
  add    %r8,%rbp
  neg    %r9d
  lea    -0x4(%rdi,%r9,4),%edi
L209:
  test   %edi,%edi
  je     L162
  mov    %edi,%eax
  lea    0x0(%rbp,%rax,8),%rsi
  mov    %rbp,%rcx
  mov    %r12,%rdx
L249:
  movzbl 0x1(%rdx),%eax
  shl    $0x8,%eax
  movzbl 0x2(%rdx),%r8d
  shl    $0x10,%r8d
  or     %r8d,%eax
  movzbl (%rdx),%r8d
  or     %r8d,%eax
  mov    %eax,(%rcx)
  mov    %eax,0x4(%rcx)
  add    $0x8,%rcx
  add    $0x3,%rdx
  cmp    %rsi,%rcx
  jne    L249
  lea    -0x1(%rdi),%eax
  add    $0x1,%rax
  lea    0x0(%rbp,%rax,8),%rbp
  lea    (%rax,%rax,2),%rax
  add    %rax,%r12
L162:
  add    0x10(%rsp),%rbp
  mov    0x28(%rsp),%rax
  lea    0x0(%rbp,%rax,1),%rdi
  mov    0x8(%rsp),%edx
  mov    %rbp,%rsi
  call   <memcpy@plt>
  mov    0x20(%rsp),%rax
  add    %r12,%rax
  add    0x18(%rsp),%rbp
  add    $0x1,%r13d
  cmp    %r13d,0xc8(%rsp)
  je     L299
L115:
  test   %r15d,%r15d
  je     L350
  mov    %ebx,%edi
  test   %ebx,%ebx
  je     L350
L284:
  movzbl 0x1(%rax),%edx
  shl    $0x8,%edx
  movzbl 0x2(%rax),%ecx
  shl    $0x10,%ecx
  or     %ecx,%edx
  movzbl (%rax),%ecx
  or     %ecx,%edx
  mov    %edx,0x0(%rbp)
  mov    %edx,0x4(%rbp)
  add    $0x8,%rbp
  add    $0x3,%rax
  mov    %r14d,%edx
  sub    %edi,%edx
  sub    $0x1,%edi
  test   $0x3,%dl
  je     L6
  test   %edi,%edi
  jne    L284
  jmp    L6
L29:
  mov    $0xffffffff,%eax
  jmp    L69
L71:
  mov    $0x0,%eax
  jmp    L69
L123:
  mov    $0x0,%eax
  jmp    L69
L124:
  mov    $0xffffffff,%eax
  jmp    L69
L82:
  mov    $0xffffffff,%eax
  jmp    L69
L43:
  mov    $0x0,%eax
  jmp    L69
L299:
  mov    $0x0,%eax
L69:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L223
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L223:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int RGB24toRGB32(unsigned char *dest_ptr, int dest_width, int dest_height, int dest_pitch, int dest_x, int dest_y, int dest_dx, int dest_dy, unsigned char *src_ptr, int src_width, int src_height, int src_pitch, int src_x, int src_y, int src_dx, int src_dy) {
  int scale_x, scale_y;
  if (!chk_args(dest_ptr, dest_width, dest_height, dest_pitch, dest_x, dest_y, dest_dx, dest_dy, src_ptr, src_width, src_height, src_pitch, src_x, src_y, src_dx, src_dy, &scale_x, &scale_y))
    return -1;
  if (src_pitch < 0)
    src_ptr -= (src_height - 1) * src_pitch;
  if (dest_pitch < 0)
    dest_ptr -= (dest_height - 1) * dest_pitch;
  if (scale_x == 1 && scale_y == 1) {
    unsigned char *s, *d;
    register int i;
    s = src_ptr + src_x * 3 + src_y * src_pitch;
    d = dest_ptr + dest_x * 4 + dest_y * dest_pitch;
    for (i = 0; i < dest_dy; i++) {
      register int sx = src_x, ddx = dest_dx;
      while ((sx & 3) && ddx) {
        *(unsigned int *)d = (unsigned int)s[0] | (s[1] << 8) | (s[2] << 16);
        d += 4;
        s += 3;
        sx++;
        ddx--;
      }
      while (ddx >= 4) {
        register unsigned int a, b;
        a = *(unsigned int *)s;
        b = *(unsigned int *)(s + 4);
        *(unsigned int *)d = a & 0x00FFFFFF;
        *(unsigned int *)(d + 4) = ((a >> 24) | (b << 8)) & 0x00FFFFFF;
        a = *(unsigned int *)(s + 8);
        *(unsigned int *)(d + 8) = ((b >> 16) | (a << 16)) & 0x00FFFFFF;
        *(unsigned int *)(d + 12) = a >> 8;
        d += 4 * 4;
        s += 3 * 4;
        ddx -= 4;
      }
      while (ddx) {
        *(unsigned int *)d = (unsigned int)s[0] | (s[1] << 8) | (s[2] << 16);
        d += 4;
        s += 3;
        ddx--;
      }
      s += src_pitch - dest_dx * 3;
      d += dest_pitch - dest_dx * 4;
    }
    return 0;
  }
  if (scale_x == 2 && scale_y == 2) {
    unsigned char *s, *d;
    register int i;
    s = src_ptr + src_x * 3 + src_y * src_pitch;
    d = dest_ptr + dest_x * 4 + dest_y * dest_pitch;
    for (i = 0; i < src_dy; i++) {
      register int sx = src_x, sdx = src_dx;
      while ((sx & 3) && sdx) {
        register unsigned int a;
        a = (unsigned int)s[0] | (s[1] << 8) | (s[2] << 16);
        *(unsigned int *)d = a;
        *(unsigned int *)(d + 4) = a;
        d += 2 * 4;
        s += 3;
        sx++;
        sdx--;
      }
      while (sdx >= 4) {
        register unsigned int a, b, c;
        a = *(unsigned int *)s;
        b = *(unsigned int *)(s + 4);
        c = a & 0x00FFFFFF;
        *(unsigned int *)(d) = c;
        *(unsigned int *)(d + 4) = c;
        c = ((a >> 24) | (b << 8)) & 0x00FFFFFF;
        *(unsigned int *)(d + 2 * 4) = c;
        *(unsigned int *)(d + 3 * 4) = c;
        a = *(unsigned int *)(s + 8);
        c = ((b >> 16) | (a << 16)) & 0x00FFFFFF;
        *(unsigned int *)(d + 4 * 4) = c;
        *(unsigned int *)(d + 5 * 4) = c;
        c = a >> 8;
        *(unsigned int *)(d + 6 * 4) = c;
        *(unsigned int *)(d + 7 * 4) = c;
        d += 4 * 2 * 4;
        s += 4 * 3;
        sdx -= 4;
      }
      while (sdx) {
        register unsigned int a;
        a = (unsigned int)s[0] | (s[1] << 8) | (s[2] << 16);
        *(unsigned int *)d = a;
        *(unsigned int *)(d + 4) = a;
        d += 2 * 4;
        s += 3;
        sdx--;
      }
      s -= src_dx * 3;
      d -= src_dx * 2 * 4;
      memcpy(d + dest_pitch, d, src_dx * 2 * 4);
      s += src_pitch;
      d += dest_pitch * 2;
    }
    return 0;
  }
  return -1;
}
```