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

```asm
<qc_imag_bay2rgb_ip>:
  endbr64
  push   %r15
  lea    -0x2(%r9),%eax
  mov    %rdx,%r15
  push   %r14
  push   %r13
  movslq %esi,%r13
  push   %r12
  lea    (%rdi,%r13,1),%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %r8d,%ebx
  sub    $0x2,%ebx
  sub    $0xd8,%rsp
  movzbl (%r12),%r8d
  mov    %rdx,0x50(%rsp)
  mov    %eax,%edx
  mov    0x110(%rsp),%r14d
  shr    $0x1f,%edx
  mov    %ecx,0x60(%rsp)
  add    %edx,%eax
  movzbl 0x1(%rdi),%edx
  mov    %esi,0x48(%rsp)
  sar    %eax
  mov    %r13,0x58(%rsp)
  mov    %eax,0x9c(%rsp)
  lea    (%rsi,%rsi,1),%eax
  mov    %r14d,%esi
  mov    %eax,0x20(%rsp)
  lea    (%rcx,%rcx,1),%eax
  movzbl (%rdi),%ecx
  mov    %r15,%rdi
  mov    %eax,0x30(%rsp)
  xor    %eax,%eax
  mov    %r12,0x90(%rsp)
  call   <qc_imag_writergb@plt>
  movslq %r14d,%rax
  lea    0x1(%rbp),%rsi
  mov    %r12,0x28(%rsp)
  add    %rax,%r15
  mov    %rax,(%rsp)
  lea    (%r14,%r14,1),%eax
  cltq
  mov    %rsi,0x10(%rsp)
  mov    %rax,0x8(%rsp)
  mov    %r13,%rax
  add    $0x1,%rax
  mov    %r15,0x38(%rsp)
  mov    %rax,0x40(%rsp)
  mov    %ebx,%eax
  shr    $0x1f,%eax
  add    %ebx,%eax
  mov    $0xaaaaaaab,%ebx
  sar    %eax
  sub    $0x1,%eax
  mov    %rax,0x70(%rsp)
  add    %rax,%rax
  mov    %rax,0x18(%rsp)
  add    $0x3,%rax
  add    %rax,%rbp
  mov    %rax,0xc8(%rsp)
  mov    %rbp,%rax
  mov    %r15,%rbp
  mov    %rsi,%r15
  mov    %rax,%r13
  nopw   0x0(%rax,%rax,1)
L17:
  movzbl 0x2(%r12),%eax
  movzbl (%r15),%edx
  mov    %rbp,%rdi
  mov    %r14d,%esi
  movzbl (%r12),%r8d
  movzbl -0x1(%r15),%ecx
  add    $0x2,%r15
  add    $0x2,%r12
  add    %eax,%r8d
  movzbl -0x1(%r15),%eax
  shr    %r8d
  add    %eax,%ecx
  movzbl -0x1(%r12),%eax
  add    %eax,%ecx
  xor    %eax,%eax
  imul   %rbx,%rcx
  shr    $0x21,%rcx
  call   <qc_imag_writergb@plt>
  movzbl (%r15),%eax
  movzbl -0x2(%r15),%edx
  mov    %r14d,%esi
  movzbl -0x1(%r15),%ecx
  movzbl (%r12),%r8d
  add    %eax,%edx
  mov    (%rsp),%rax
  shr    %edx
  lea    0x0(%rbp,%rax,1),%rdi
  xor    %eax,%eax
  call   <qc_imag_writergb@plt>
  add    0x8(%rsp),%rbp
  cmp    %r13,%r15
  jne    L17
  mov    0x70(%rsp),%rax
  mov    0x10(%rsp),%rsi
  mov    0x58(%rsp),%rbp
  mov    0x8(%rsp),%rbx
  lea    0x1(%rax),%rdx
  mov    %rsi,%rax
  mov    0x38(%rsp),%rdi
  add    0x40(%rsp),%rsi
  imul   %rdx,%rbx
  lea    (%rdx,%rdx,1),%r12
  add    %r12,%rax
  mov    %r12,0xb0(%rsp)
  movzbl -0x1(%rax),%edx
  movzbl (%rax,%rbp,1),%ecx
  add    %rbx,%rdi
  mov    %rbx,0xa8(%rsp)
  add    %edx,%ecx
  movzbl (%rax),%edx
  mov    0x18(%rsp),%rax
  shr    %ecx
  movzbl (%rsi,%rax,1),%r8d
  mov    %r14d,%esi
  xor    %eax,%eax
  call   <qc_imag_writergb@plt>
  movslq 0x20(%rsp),%rsi
  mov    (%rsp),%rdi
  mov    %rbp,%rax
  movslq 0x60(%rsp),%rdx
  mov    0x50(%rsp),%r10
  mov    0x18(%rsp),%rcx
  mov    0x48(%rsp),%r15d
  mov    %rsi,0x40(%rsp)
  mov    %rdi,%rsi
  add    %rdx,%r10
  add    %rdx,%rsi
  mov    %rdx,0x10(%rsp)
  movslq 0x30(%rsp),%rdx
  add    %rcx,%rax
  neg    %r15d
  add    %rbx,%rdi
  add    %rsi,%rbx
  mov    %rdx,0x68(%rsp)
  mov    %rax,%rdx
  mov    0x90(%rsp),%rax
  movslq %r15d,%r11
  lea    0x1(%r11),%r9
  mov    %r10,0xa0(%rsp)
  add    %rax,%rdx
  mov    %r11,0x60(%rsp)
  mov    %rdx,0x48(%rsp)
  mov    %rax,%rdx
  lea    0x1(%rax,%r12,1),%rax
  mov    %rax,0x18(%rsp)
  lea    0x2(%r11,%rcx,1),%rax
  add    %r9,%rdx
  mov    %rax,0xb8(%rsp)
  mov    0x9c(%rsp),%eax
  mov    %r9,0xc0(%rsp)
  mov    %eax,0x98(%rsp)
  lea    0x0(%rbp,%rbp,2),%rax
  mov    %rsi,0x20(%rsp)
  mov    %rdx,0x50(%rsp)
  mov    %rdi,0x78(%rsp)
  mov    %rbx,0x80(%rsp)
  mov    %r10,0x30(%rsp)
  mov    %rax,0x88(%rsp)
  nopl   0x0(%rax)
L36:
  mov    0x28(%rsp),%rsi
  mov    0x60(%rsp),%rax
  mov    0x58(%rsp),%r12
  mov    0x50(%rsp),%r13
  movzbl (%rsi,%rax,1),%ecx
  movzbl 0x1(%rsi),%eax
  mov    %rsi,%rbx
  mov    %rsi,0x38(%rsp)
  movzbl 0x0(%r13),%edx
  mov    0x30(%rsp),%rbp
  lea    0x1(%rbx),%r15
  add    %eax,%ecx
  movzbl (%rsi,%r12,1),%eax
  movzbl (%rsi),%r8d
  mov    %rbp,%rdi
  add    %eax,%ecx
  mov    $0xaaaaaaab,%eax
  imul   %rax,%rcx
  movzbl 0x1(%rsi,%r12,1),%eax
  mov    %r14d,%esi
  add    %eax,%edx
  xor    %eax,%eax
  shr    $0x21,%rcx
  shr    %edx
  call   <qc_imag_writergb@plt>
  mov    0x40(%rsp),%rax
  movzbl (%rbx),%r8d
  mov    %r14d,%esi
  mov    0x10(%rsp),%rdi
  movzbl (%rbx,%r12,1),%ecx
  movzbl (%rbx,%rax,1),%eax
  movzbl 0x1(%rbx,%r12,1),%edx
  add    %r12,%rbx
  add    %rbp,%rdi
  add    %eax,%r8d
  xor    %eax,%eax
  shr    %r8d
  call   <qc_imag_writergb@plt>
  mov    (%rsp),%rax
  add    %rbp,%rax
  mov    %rax,%rbp
  mov    %r12,%rax
  mov    %rbx,%r12
  add    %rbx,%rax
  mov    %rax,0x28(%rsp)
  mov    %rax,%rbx
  mov    %r13,%rax
  mov    %r12,%r13
  mov    %r15,%r12
  mov    %rax,%r15
  nopl   (%rax)
L7:
  movzbl 0x1(%r12),%eax
  movzbl (%r15),%edx
  mov    %rbp,%rdi
  mov    %r14d,%esi
  movzbl -0x1(%r12),%r8d
  movzbl (%r12),%ecx
  add    %eax,%r8d
  movzbl 0x1(%r13),%eax
  shr    %r8d
  add    %eax,%edx
  xor    %eax,%eax
  shr    %edx
  call   <qc_imag_writergb@plt>
  movzbl 0x2(%r12),%eax
  movzbl (%r12),%ecx
  mov    %r14d,%esi
  movzbl (%r15),%edx
  movzbl 0x1(%r12),%r8d
  add    %eax,%ecx
  movzbl 0x1(%r15),%eax
  add    %eax,%ecx
  movzbl 0x2(%r13),%eax
  add    %eax,%ecx
  movzbl 0x2(%r15),%eax
  shr    $0x2,%ecx
  add    %eax,%edx
  movzbl 0x1(%r13),%eax
  add    %eax,%edx
  movzbl 0x3(%r13),%eax
  add    %eax,%edx
  mov    (%rsp),%rax
  shr    $0x2,%edx
  lea    (%rax,%rbp,1),%rdi
  xor    %eax,%eax
  call   <qc_imag_writergb@plt>
  movzbl 0x1(%r12),%eax
  movzbl -0x1(%r12),%r8d
  mov    %r14d,%esi
  movzbl 0x1(%rbx),%ecx
  movzbl 0x1(%r13),%edx
  add    %eax,%r8d
  movzbl (%rbx),%eax
  add    %eax,%r8d
  movzbl 0x2(%rbx),%eax
  add    %eax,%r8d
  movzbl 0x0(%r13),%eax
  shr    $0x2,%r8d
  add    %eax,%ecx
  movzbl (%r12),%eax
  add    %eax,%ecx
  movzbl 0x2(%r13),%eax
  add    %eax,%ecx
  mov    0x10(%rsp),%rax
  shr    $0x2,%ecx
  lea    0x0(%rbp,%rax,1),%rdi
  xor    %eax,%eax
  call   <qc_imag_writergb@plt>
  movzbl 0x1(%r12),%r8d
  movzbl 0x2(%rbx),%eax
  mov    %r14d,%esi
  movzbl 0x1(%r13),%edx
  movzbl 0x2(%r13),%ecx
  add    %eax,%r8d
  movzbl 0x3(%r13),%eax
  shr    %r8d
  add    %eax,%edx
  mov    0x20(%rsp),%rax
  shr    %edx
  lea    0x0(%rbp,%rax,1),%rdi
  xor    %eax,%eax
  call   <qc_imag_writergb@plt>
  add    $0x2,%r12
  add    0x8(%rsp),%rbp
  add    $0x2,%r15
  add    $0x2,%r13
  add    $0x2,%rbx
  cmp    0x18(%rsp),%r12
  jne    L7
  movzbl (%r12),%ecx
  mov    %r12,%r15
  mov    0x28(%rsp),%r12
  mov    %r14d,%esi
  mov    0x70(%rsp),%rbp
  mov    0x48(%rsp),%r13
  mov    %r12,%rax
  sub    0x88(%rsp),%rax
  mov    0x30(%rsp),%rbx
  movzbl 0x3(%rax,%rbp,2),%edx
  movzbl 0x3(%r13),%eax
  mov    0x78(%rsp),%rdi
  add    %eax,%edx
  mov    0x38(%rsp),%rax
  add    %rbx,%rdi
  shr    %edx
  movzbl 0x2(%rax,%rbp,2),%r8d
  xor    %eax,%eax
  call   <qc_imag_writergb@plt>
  mov    0x38(%rsp),%rax
  movzbl (%r15),%ecx
  mov    %r14d,%esi
  mov    0x80(%rsp),%rdi
  movzbl 0x3(%r13),%edx
  movzbl 0x2(%rax,%rbp,2),%r8d
  movzbl 0x2(%r12,%rbp,2),%eax
  add    %rbx,%rdi
  add    %eax,%r8d
  movzbl 0x2(%r13),%eax
  shr    %r8d
  add    %eax,%ecx
  movzbl 0x3(%r12,%rbp,2),%eax
  add    %eax,%ecx
  mov    $0xaaaaaaab,%eax
  imul   %rax,%rcx
  xor    %eax,%eax
  shr    $0x21,%rcx
  call   <qc_imag_writergb@plt>
  mov    0x68(%rsp),%rax
  add    %rax,%rbx
  mov    0x40(%rsp),%rax
  add    %rax,0x50(%rsp)
  mov    %rbx,0x30(%rsp)
  add    %rax,%r13
  add    %rax,%r15
  subl   $0x1,0x98(%rsp)
  mov    %r13,0x48(%rsp)
  mov    %r15,0x18(%rsp)
  jne    L36
  mov    0x9c(%rsp),%eax
  mov    0x40(%rsp),%rbx
  mov    %r14d,%esi
  mov    $0xaaaaaaab,%r12d
  lea    -0x1(%rax),%ebp
  mov    0x90(%rsp),%rax
  add    $0x1,%rbp
  imul   %rbp,%rbx
  imul   0x68(%rsp),%rbp
  add    0xa0(%rsp),%rbp
  mov    %rbp,%rdi
  add    %rbx,%rax
  mov    0xc0(%rsp),%rbx
  mov    %rax,%r15
  mov    %rax,0x20(%rsp)
  add    %rax,%rbx
  mov    0x60(%rsp),%rax
  movzbl (%r15),%r8d
  movzbl (%rbx),%edx
  movzbl (%r15,%rax,1),%ecx
  movzbl 0x1(%r15),%eax
  add    %eax,%ecx
  xor    %eax,%eax
  shr    %ecx
  call   <qc_imag_writergb@plt>
  add    (%rsp),%rbp
  mov    %r15,%rax
  lea    0x1(%r15),%r15
  mov    %rbp,%r13
  mov    %rbp,0x18(%rsp)
  mov    0xc8(%rsp),%rbp
  mov    %r15,0x10(%rsp)
  add    %rax,%rbp
  mov    %rbx,%rax
  mov    %r13,%rbx
  mov    %rbp,%r13
  mov    %rax,%rbp
  xchg   %ax,%ax
L35:
  movzbl 0x1(%r15),%eax
  movzbl -0x1(%r15),%r8d
  mov    %rbx,%rdi
  mov    %r14d,%esi
  movzbl (%r15),%ecx
  movzbl 0x0(%rbp),%edx
  add    $0x2,%r15
  add    $0x2,%rbp
  add    %eax,%r8d
  xor    %eax,%eax
  shr    %r8d
  call   <qc_imag_writergb@plt>
  movzbl (%r15),%eax
  movzbl -0x2(%rbp),%edx
  mov    %r14d,%esi
  movzbl -0x2(%r15),%ecx
  movzbl -0x1(%r15),%r8d
  add    %eax,%ecx
  movzbl -0x1(%rbp),%eax
  add    %eax,%ecx
  movzbl 0x0(%rbp),%eax
  imul   %r12,%rcx
  add    %eax,%edx
  mov    (%rsp),%rax
  shr    %edx
  lea    (%rbx,%rax,1),%rdi
  shr    $0x21,%rcx
  xor    %eax,%eax
  call   <qc_imag_writergb@plt>
  add    0x8(%rsp),%rbx
  cmp    %r13,%r15
  jne    L35
  mov    0x20(%rsp),%rax
  mov    0xb8(%rsp),%rsi
  mov    0x10(%rsp),%r13
  add    0xb0(%rsp),%r13
  movzbl 0x1(%rax,%rsi,1),%edx
  movzbl 0x0(%r13),%ecx
  mov    %r14d,%esi
  xor    %eax,%eax
  mov    0x18(%rsp),%rdi
  movzbl -0x1(%r13),%r8d
  add    0xa8(%rsp),%rdi
  add    $0xd8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1050 <qc_imag_writergb@plt>
```

assistant: ```c
void qc_imag_bay2rgb_ip(unsigned char *bay, int bay_line, unsigned char *rgb, int rgb_line, int columns, int rows, int bpp) {
  unsigned char *cur_bay, *cur_rgb;
  int bay_line2, rgb_line2;
  int total_columns;
  unsigned char red, green, blue;
  unsigned int column_cnt, row_cnt;
  total_columns = (columns - 2) / 2;
  row_cnt = (rows - 2) / 2;
  bay_line2 = 2 * bay_line;
  rgb_line2 = 2 * rgb_line;
  qc_imag_writergb(rgb, bpp, bay[1], bay[0], bay[bay_line]);
  cur_bay = bay + 1;
  cur_rgb = rgb + bpp;
  column_cnt = total_columns;
  do {
    green = ((unsigned int)cur_bay[-1] + cur_bay[1] + cur_bay[bay_line]) / 3;
    blue = ((unsigned int)cur_bay[bay_line - 1] + cur_bay[bay_line + 1]) / 2;
    qc_imag_writergb(cur_rgb, bpp, cur_bay[0], green, blue);
    red = ((unsigned int)cur_bay[0] + cur_bay[2]) / 2;
    qc_imag_writergb(cur_rgb + bpp, bpp, red, cur_bay[1], cur_bay[bay_line + 1]);
    cur_bay += 2;
    cur_rgb += 2 * bpp;
  } while (--column_cnt);
  green = ((unsigned int)cur_bay[-1] + cur_bay[bay_line]) / 2;
  qc_imag_writergb(cur_rgb, bpp, cur_bay[0], green, cur_bay[bay_line - 1]);
  bay += bay_line;
  rgb += rgb_line;
  do {
    red = ((unsigned int)bay[-bay_line + 1] + bay[bay_line + 1]) / 2;
    green = ((unsigned int)bay[-bay_line] + bay[1] + bay[bay_line]) / 3;
    qc_imag_writergb(rgb + 0, bpp, red, green, bay[0]);
    blue = ((unsigned int)bay[0] + bay[bay_line2]) / 2;
    qc_imag_writergb(rgb + rgb_line, bpp, bay[bay_line + 1], bay[bay_line], blue);
    cur_bay = bay + 1;
    cur_rgb = rgb + bpp;
    column_cnt = total_columns;
    do {
      red = ((unsigned int)cur_bay[-bay_line] + cur_bay[bay_line]) / 2;
      blue = ((unsigned int)cur_bay[-1] + cur_bay[1]) / 2;
      qc_imag_writergb(cur_rgb + 0, bpp, red, cur_bay[0], blue);
      red = ((unsigned int)cur_bay[-bay_line] + cur_bay[-bay_line + 2] + cur_bay[bay_line] + cur_bay[bay_line + 2]) / 4;
      green = ((unsigned int)cur_bay[0] + cur_bay[2] + cur_bay[-bay_line + 1] + cur_bay[bay_line + 1]) / 4;
      qc_imag_writergb(cur_rgb + bpp, bpp, red, green, cur_bay[1]);
      green = ((unsigned int)cur_bay[0] + cur_bay[bay_line2] + cur_bay[bay_line - 1] + cur_bay[bay_line + 1]) / 4;
      blue = ((unsigned int)cur_bay[-1] + cur_bay[1] + cur_bay[bay_line2 - 1] + cur_bay[bay_line2 + 1]) / 4;
      qc_imag_writergb(cur_rgb + rgb_line, bpp, cur_bay[bay_line], green, blue);
      red = ((unsigned int)cur_bay[bay_line] + cur_bay[bay_line + 2]) / 2;
      blue = ((unsigned int)cur_bay[1] + cur_bay[bay_line2 + 1]) / 2;
      qc_imag_writergb(cur_rgb + rgb_line + bpp, bpp, red, cur_bay[bay_line + 1], blue);
      cur_bay += 2;
      cur_rgb += 2 * bpp;
    } while (--column_cnt);
    red = ((unsigned int)cur_bay[-bay_line] + cur_bay[bay_line]) / 2;
    qc_imag_writergb(cur_rgb, bpp, red, cur_bay[0], cur_bay[-1]);
    green = ((unsigned int)cur_bay[0] + cur_bay[bay_line - 1] + cur_bay[bay_line2]) / 3;
    blue = ((unsigned int)cur_bay[-1] + cur_bay[bay_line2 - 1]) / 2;
    qc_imag_writergb(cur_rgb + rgb_line, bpp, cur_bay[bay_line], green, blue);
    bay += bay_line2;
    rgb += rgb_line2;
  } while (--row_cnt);
  green = ((unsigned int)bay[-bay_line] + bay[1]) / 2;
  qc_imag_writergb(rgb, bpp, bay[-bay_line + 1], green, bay[0]);
  cur_bay = bay + 1;
  cur_rgb = rgb + bpp;
  column_cnt = total_columns;
  do {
    blue = ((unsigned int)cur_bay[-1] + cur_bay[1]) / 2;
    qc_imag_writergb(cur_rgb, bpp, cur_bay[-bay_line], cur_bay[0], blue);
    red = ((unsigned int)cur_bay[-bay_line] + cur_bay[-bay_line + 2]) / 2;
    green = ((unsigned int)cur_bay[0] + cur_bay[-bay_line + 1] + cur_bay[2]) / 3;
    qc_imag_writergb(cur_rgb + bpp, bpp, red, green, cur_bay[1]);
    cur_bay += 2;
    cur_rgb += 2 * bpp;
  } while (--column_cnt);
  qc_imag_writergb(cur_rgb, bpp, cur_bay[-bay_line], cur_bay[0], cur_bay[-1]);
}
```