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

```asm
<qc_imag_bay2rgb_horip>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x40(%rbp)
  mov    %r8d,-0x4c(%rbp)
  mov    %r9d,-0x50(%rbp)
  mov    -0x4c(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x50(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x20(%rbp)
  mov    -0x3c(%rbp),%eax
  add    %eax,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x40(%rbp),%eax
  add    %eax,%eax
  mov    %eax,-0x14(%rbp)
L19:
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x48(%rbp),%rax
  mov    %esi,%r8d
  mov    0x10(%rbp),%esi
  mov    %rax,%rdi
  call   <qc_imag_writergb@plt>
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x40(%rbp),%ecx
  movslq %ecx,%rdi
  mov    -0x48(%rbp),%rcx
  add    %rcx,%rdi
  mov    %esi,%r8d
  mov    %edx,%ecx
  mov    %eax,%edx
  mov    0x10(%rbp),%esi
  call   <qc_imag_writergb@plt>
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x10(%rbp)
  mov    0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x24(%rbp)
L17:
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    %edx,%eax
  shr    %eax
  mov    %al,-0x27(%rbp)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x1(%rax),%rcx
  mov    -0x10(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    %edx,%eax
  shr    %eax
  mov    %al,-0x26(%rbp)
  movzbl -0x26(%rbp),%esi
  movzbl -0x27(%rbp),%ecx
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x8(%rbp),%rax
  mov    %esi,%r8d
  mov    0x10(%rbp),%esi
  mov    %rax,%rdi
  call   <qc_imag_writergb@plt>
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x10(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    %edx,%eax
  shr    %eax
  mov    %al,-0x25(%rbp)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  movzbl -0x25(%rbp),%eax
  mov    0x10(%rbp),%ecx
  movslq %ecx,%rdi
  mov    -0x8(%rbp),%rcx
  add    %rcx,%rdi
  mov    %esi,%r8d
  mov    %edx,%ecx
  mov    %eax,%edx
  mov    0x10(%rbp),%esi
  call   <qc_imag_writergb@plt>
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x2(%rax),%rcx
  mov    -0x10(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    %edx,%eax
  shr    %eax
  mov    %al,-0x27(%rbp)
  movzbl -0x26(%rbp),%esi
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x40(%rbp),%ecx
  movslq %ecx,%rdi
  mov    -0x8(%rbp),%rcx
  add    %rcx,%rdi
  mov    %esi,%r8d
  mov    %edx,%ecx
  mov    %eax,%edx
  mov    0x10(%rbp),%esi
  call   <qc_imag_writergb@plt>
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  movzbl -0x25(%rbp),%eax
  mov    -0x40(%rbp),%ecx
  movslq %ecx,%rdi
  mov    0x10(%rbp),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  mov    -0x8(%rbp),%rcx
  add    %rcx,%rdi
  mov    %esi,%r8d
  mov    %edx,%ecx
  mov    %eax,%edx
  mov    0x10(%rbp),%esi
  call   <qc_imag_writergb@plt>
  addq   $0x2,-0x10(%rbp)
  mov    0x10(%rbp),%eax
  add    %eax,%eax
  cltq
  add    %rax,-0x8(%rbp)
  subl   $0x1,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jne    L17
  mov    -0x3c(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x8(%rbp),%rax
  mov    %esi,%r8d
  mov    0x10(%rbp),%esi
  mov    %rax,%rdi
  call   <qc_imag_writergb@plt>
  mov    -0x3c(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0x40(%rbp),%ecx
  movslq %ecx,%rdi
  mov    -0x8(%rbp),%rcx
  add    %rcx,%rdi
  mov    %esi,%r8d
  mov    %edx,%ecx
  mov    %eax,%edx
  mov    0x10(%rbp),%esi
  call   <qc_imag_writergb@plt>
  mov    -0x18(%rbp),%eax
  cltq
  add    %rax,-0x38(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  add    %rax,-0x48(%rbp)
  subl   $0x1,-0x20(%rbp)
  cmpl   $0x0,-0x20(%rbp)
  jne    L19
  nop
  nop
  leave
  ret
```

assistant: ```c
void qc_imag_bay2rgb_horip(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;
  bay_line2 = 2 * bay_line;
  rgb_line2 = 2 * rgb_line;
  do {
    qc_imag_writergb(rgb + 0, bpp, bay[1], bay[0], bay[bay_line]);
    qc_imag_writergb(rgb + rgb_line, 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]) / 2;
      blue = ((unsigned int)cur_bay[bay_line - 1] + cur_bay[bay_line + 1]) / 2;
      qc_imag_writergb(cur_rgb + 0, 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]);
      green = ((unsigned int)cur_bay[bay_line] + cur_bay[bay_line + 2]) / 2;
      qc_imag_writergb(cur_rgb + rgb_line, bpp, cur_bay[0], cur_bay[bay_line], blue);
      qc_imag_writergb(cur_rgb + rgb_line + bpp, bpp, red, cur_bay[1], cur_bay[bay_line + 1]);
      cur_bay += 2;
      cur_rgb += 2 * bpp;
    } while (--column_cnt);
    qc_imag_writergb(cur_rgb + 0, bpp, cur_bay[0], cur_bay[-1], cur_bay[bay_line - 1]);
    qc_imag_writergb(cur_rgb + rgb_line, bpp, cur_bay[0], cur_bay[bay_line], cur_bay[bay_line - 1]);
    bay += bay_line2;
    rgb += rgb_line2;
  } while (--row_cnt);
}
```