user: What would the C source look like for the assembly code provided here?

```asm
<RGB32toBGR32>:
  endbr64
  push   %r15
  mov    %edx,%r15d
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %r9d,%r13d
  push   %r12
  push   %rbp
  mov    %r8d,%ebp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x34(%rsp),%rax
  mov    0xa8(%rsp),%r10d
  mov    0x90(%rsp),%r12
  push   %rax
  lea    0x38(%rsp),%rax
  push   %rax
  mov    0xd8(%rsp),%eax
  push   %rax
  mov    0xd8(%rsp),%eax
  push   %rax
  mov    0xd8(%rsp),%eax
  push   %rax
  mov    0xd8(%rsp),%eax
  push   %rax
  push   %r10
  mov    0xd8(%rsp),%eax
  mov    %r10d,0xe0(%rsp)
  push   %rax
  mov    0xd8(%rsp),%eax
  push   %rax
  push   %r12
  mov    0xd8(%rsp),%eax
  push   %rax
  mov    0xd8(%rsp),%eax
  push   %rax
  call   <chk_args@plt>
  add    $0x60,%rsp
  test   %eax,%eax
  je     L147
  mov    0xa8(%rsp),%r10d
  test   %r10d,%r10d
  jns    L24
  mov    0xa0(%rsp),%eax
  sub    $0x1,%eax
  imul   %r10d,%eax
  cltq
  sub    %rax,%r12
L24:
  test   %ebx,%ebx
  jns    L71
  lea    -0x1(%r15),%edx
  imul   %ebx,%edx
  movslq %edx,%rax
  sub    %rax,%r14
L71:
  mov    0x30(%rsp),%eax
  cmp    $0x1,%eax
  je     L43
  cmp    $0x2,%eax
  jne    L147
  cmpl   $0x2,0x34(%rsp)
  jne    L147
  mov    0xb8(%rsp),%edx
  mov    0xb0(%rsp),%eax
  imul   %ebx,%r13d
  mov    0xc8(%rsp),%ecx
  imul   %r10d,%edx
  shl    $0x2,%eax
  cltq
  movslq %edx,%rdx
  add    %rdx,%rax
  movslq %r13d,%rdx
  add    %rax,%r12
  lea    0x0(,%rbp,4),%eax
  cltq
  add    %rdx,%rax
  lea    (%r14,%rax,1),%rdx
  test   %ecx,%ecx
  jle    L106
  mov    0xc0(%rsp),%eax
  movslq %r10d,%rbp
  xor    %r15d,%r15d
  lea    0x0(,%rax,8),%r14d
  shl    $0x2,%eax
  cltq
  movslq %r14d,%r13
  sub    %rax,%rbp
  lea    (%rbx,%rbx,1),%eax
  neg    %r13
  cltq
  mov    %rbp,0x10(%rsp)
  mov    %r12,%rbp
  mov    %rax,0x8(%rsp)
  movslq %ebx,%rax
  mov    %rax,0x18(%rsp)
  mov    0xc0(%rsp),%eax
  lea    -0x1(%rax),%ebx
  lea    0x1(%rbx),%rax
  mov    %rbx,%r12
  mov    %r15d,%ebx
  lea    0x0(,%rax,8),%rsi
  shl    $0x2,%rax
  mov    %rsi,0x28(%rsp)
  mov    %rax,0x20(%rsp)
  nopl   0x0(%rax,%rax,1)
L45:
  mov    0xc0(%rsp),%eax
  xor    %esi,%esi
  test   %eax,%eax
  je     L9
  nopl   (%rax)
L64:
  mov    0x0(%rbp,%rsi,4),%ecx
  mov    %ecx,%eax
  mov    %ecx,%edi
  and    $0xff00,%ecx
  shl    $0x10,%eax
  shr    $0x10,%edi
  and    $0xff0000,%eax
  movzbl %dil,%edi
  or     %edi,%eax
  or     %ecx,%eax
  mov    %eax,(%rdx,%rsi,8)
  mov    %eax,0x4(%rdx,%rsi,8)
  mov    %rsi,%rax
  add    $0x1,%rsi
  cmp    %r12,%rax
  jne    L64
  add    0x28(%rsp),%rdx
  add    0x20(%rsp),%rbp
L9:
  mov    0x18(%rsp),%rax
  lea    (%rdx,%r13,1),%r15
  mov    %r14d,%edx
  add    $0x1,%ebx
  mov    %r15,%rsi
  lea    (%r15,%rax,1),%rdi
  call   <memcpy@plt>
  mov    0x8(%rsp),%rax
  add    0x10(%rsp),%rbp
  lea    (%r15,%rax,1),%rdx
  cmp    %ebx,0xc8(%rsp)
  jne    L45
L106:
  xor    %eax,%eax
L16:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L38
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L43:
  cmpl   $0x1,0x34(%rsp)
  mov    $0xffffffff,%eax
  jne    L16
  mov    0xb0(%rsp),%eax
  mov    %r13d,%edx
  mov    0x88(%rsp),%r8d
  imul   %ebx,%edx
  lea    0x0(,%rax,4),%esi
  mov    0xb8(%rsp),%eax
  movslq %esi,%rsi
  imul   %r10d,%eax
  movslq %edx,%rdx
  cltq
  add    %rax,%rsi
  lea    0x0(,%rbp,4),%eax
  cltq
  add    %r12,%rsi
  add    %rdx,%rax
  lea    (%r14,%rax,1),%rdi
  test   %r8d,%r8d
  jle    L106
  mov    0x80(%rsp),%eax
  mov    %r10d,%r11d
  mov    0x88(%rsp),%r12d
  xor    %r9d,%r9d
  shl    $0x2,%eax
  sub    %eax,%r11d
  sub    %eax,%ebx
  mov    0x80(%rsp),%eax
  movslq %r11d,%r11
  movslq %ebx,%rbx
  lea    -0x1(%rax),%r8d
  mov    %eax,%ebp
  lea    0x4(,%r8,4),%r10
L70:
  xor    %ecx,%ecx
  test   %ebp,%ebp
  je     L14
  nopl   0x0(%rax)
L143:
  mov    (%rsi,%rcx,4),%edx
  mov    %edx,%eax
  mov    %edx,%r13d
  and    $0xff00,%edx
  shl    $0x10,%eax
  shr    $0x10,%r13d
  and    $0xff0000,%eax
  movzbl %r13b,%r13d
  or     %r13d,%eax
  or     %edx,%eax
  mov    %eax,(%rdi,%rcx,4)
  mov    %rcx,%rax
  add    $0x1,%rcx
  cmp    %r8,%rax
  jne    L143
  add    %r10,%rsi
  add    %r10,%rdi
L14:
  add    $0x1,%r9d
  add    %r11,%rsi
  add    %rbx,%rdi
  cmp    %r9d,%r12d
  jne    L70
  jmp    L106
L147:
  mov    $0xffffffff,%eax
  jmp    L16
L38:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int RGB32toBGR32(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 * 4 + src_y * src_pitch;
    d = dest_ptr + dest_x * 4 + dest_y * dest_pitch;
    for (i = 0; i < dest_dy; i++) {
      register int ddx = dest_dx;
      while (ddx) {
        register unsigned int a;
        a = *(unsigned int *)s;
        *(unsigned int *)d = ((a & 0x000000ff) << 16) | ((a & 0x0000ff00) << 0) | ((a & 0x00ff0000) >> 16);
        s += 4;
        d += 4;
        ddx--;
      }
      s += src_pitch - dest_dx * 4;
      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 * 4 + src_y * src_pitch;
    d = dest_ptr + dest_x * 4 + dest_y * dest_pitch;
    for (i = 0; i < src_dy; i++) {
      register int sdx = src_dx;
      while (sdx) {
        register unsigned int a, c;
        a = *(unsigned int *)s;
        c = ((a & 0x000000ff) << 16) | ((a & 0x0000ff00) << 0) | ((a & 0x00ff0000) >> 16);
        *(unsigned int *)d = c;
        *(unsigned int *)(d + 4) = c;
        d += 2 * 4;
        s += 4;
        sdx--;
      }
      s -= src_dx * 4;
      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;
}
```