#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ qc_imag_writergb(unsigned char *, int, unsigned char,
                                    unsigned char, unsigned char);
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);
}


x86 assembly (clang, -O0):
<qc_imag_bay2rgb_horip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x44(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x50(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%dl
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%r8
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl (%rax,%r8,1),%r8d
call   1030 <qc_imag_writergb@plt>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%dl
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%r8
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl (%rax,%r8,1),%r8d
call   1030 <qc_imag_writergb@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq 0x10(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rax
movzbl -0x1(%rax),%eax
mov    -0x30(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
add    %ecx,%eax
shr    $0x1,%eax
mov    %al,-0x46(%rbp)
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x30(%rbp),%rcx
mov    -0xc(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
shr    $0x1,%eax
mov    %al,-0x47(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x10(%rbp),%esi
mov    -0x30(%rbp),%rax
mov    (%rax),%cl
mov    -0x46(%rbp),%al
movzbl %cl,%edx
movzbl %al,%ecx
movzbl -0x47(%rbp),%r8d
call   1030 <qc_imag_writergb@plt>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
mov    -0x30(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
add    %ecx,%eax
shr    $0x1,%eax
mov    %al,-0x45(%rbp)
mov    -0x38(%rbp),%rdi
movslq 0x10(%rbp),%rax
add    %rax,%rdi
mov    0x10(%rbp),%esi
mov    -0x45(%rbp),%dl
mov    -0x30(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%r8d
add    $0x1,%r8d
movslq %r8d,%r8
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl (%rax,%r8,1),%r8d
call   1030 <qc_imag_writergb@plt>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x30(%rbp),%rcx
mov    -0xc(%rbp),%edx
add    $0x2,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
shr    $0x1,%eax
mov    %al,-0x46(%rbp)
mov    -0x38(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    0x10(%rbp),%esi
mov    -0x30(%rbp),%rax
mov    (%rax),%cl
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rdx
mov    (%rax,%rdx,1),%al
movzbl %cl,%edx
movzbl %al,%ecx
movzbl -0x47(%rbp),%r8d
call   1030 <qc_imag_writergb@plt>
mov    -0x38(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
movslq 0x10(%rbp),%rax
add    %rax,%rdi
mov    0x10(%rbp),%esi
mov    -0x45(%rbp),%dl
mov    -0x30(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%r8d
add    $0x1,%r8d
movslq %r8d,%r8
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl (%rax,%r8,1),%r8d
call   1030 <qc_imag_writergb@plt>
mov    -0x30(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
mov    0x10(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x4c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
jne    11e2 <qc_imag_bay2rgb_horip+0xd2>
mov    -0x38(%rbp),%rdi
mov    0x10(%rbp),%esi
mov    -0x30(%rbp),%rax
mov    (%rax),%dl
mov    -0x30(%rbp),%rax
mov    -0x1(%rax),%cl
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%r8d
sub    $0x1,%r8d
movslq %r8d,%r8
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl (%rax,%r8,1),%r8d
call   1030 <qc_imag_writergb@plt>
mov    -0x38(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    0x10(%rbp),%esi
mov    -0x30(%rbp),%rax
mov    (%rax),%dl
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%r8d
sub    $0x1,%r8d
movslq %r8d,%r8
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl (%rax,%r8,1),%r8d
call   1030 <qc_imag_writergb@plt>
mov    -0x3c(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x40(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x50(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x50(%rbp)
cmp    $0x0,%eax
jne    1162 <qc_imag_bay2rgb_horip+0x52>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qc_imag_bay2rgb_horip>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdx,%rbx
mov    0xb0(%rsp),%ebp
mov    %r8d,%eax
add    $0xfffffffe,%eax
shr    $0x1f,%eax
lea    (%r8,%rax,1),%r14d
add    $0xfffffffe,%r14d
sar    %r14d
mov    %r9d,%edx
shr    $0x1f,%edx
add    %r9d,%edx
sar    %edx
movslq %esi,%r8
add    %esi,%esi
movslq %ecx,%rax
mov    %rax,0x10(%rsp)
add    %ecx,%ecx
movslq %ebp,%rbp
lea    0x0(%rbp,%rbp,1),%eax
cltq
mov    %rax,0x68(%rsp)
movslq %esi,%rax
mov    %rax,0x40(%rsp)
movslq %ecx,%rax
mov    %rax,0x38(%rsp)
mov    %rbp,0x48(%rsp)
lea    (%rbx,%rbp,2),%r15
lea    (%r8,%rdi,1),%rax
lea    0x1(%r8,%rdi,1),%r13
mov    %r8,0x50(%rsp)
mov    %rdi,(%rsp)
lea    (%r8,%rdi,1),%rcx
add    $0x2,%rcx
mov    %r14,0x70(%rsp)
nopl   0x0(%rax)
mov    %r13,0x28(%rsp)
mov    %rax,0x30(%rsp)
mov    %rcx,0x8(%rsp)
mov    %edx,0x24(%rsp)
mov    (%rsp),%rbp
movzbl 0x1(%rbp),%edx
movzbl 0x0(%rbp),%ecx
mov    0x50(%rsp),%r12
movzbl 0x0(%rbp,%r12,1),%r8d
mov    %rbx,%rdi
mov    0x48(%rsp),%r13
mov    %r13d,%esi
call   1030 <qc_imag_writergb@plt>
mov    0x10(%rsp),%rax
lea    (%rbx,%rax,1),%rdi
movzbl 0x1(%rbp),%edx
movzbl 0x0(%rbp),%ecx
movzbl 0x0(%rbp,%r12,1),%r8d
mov    %r13d,%esi
call   1030 <qc_imag_writergb@plt>
mov    %rbx,0x60(%rsp)
lea    (%rbx,%r13,1),%rbp
xor    %r12d,%r12d
mov    %r15,0x58(%rsp)
mov    %r15,%r13
nopl   (%rax)
mov    %rbp,0x18(%rsp)
mov    (%rsp),%rbp
movzbl 0x0(%rbp,%r12,2),%eax
movzbl 0x2(%rbp,%r12,2),%ecx
add    %eax,%ecx
shr    %ecx
mov    0x30(%rsp),%rax
movzbl (%rax,%r12,2),%eax
mov    0x8(%rsp),%rdx
movzbl (%rdx,%r12,2),%r15d
add    %eax,%r15d
shr    %r15d
movzbl 0x1(%rbp,%r12,2),%edx
mov    0x18(%rsp),%rdi
mov    0xb0(%rsp),%ebx
mov    %ebx,%esi
mov    %r15d,%r8d
call   1030 <qc_imag_writergb@plt>
movzbl 0x1(%rbp,%r12,2),%eax
movzbl 0x3(%rbp,%r12,2),%r14d
add    %eax,%r14d
shr    %r14d
movzbl 0x2(%rbp,%r12,2),%ecx
mov    0x8(%rsp),%rax
movzbl (%rax,%r12,2),%r8d
mov    %r13,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
call   1030 <qc_imag_writergb@plt>
mov    0x28(%rsp),%rax
movzbl (%rax,%r12,2),%ecx
mov    %r13,%rbx
mov    0x10(%rsp),%r13
mov    0x18(%rsp),%rax
lea    (%rax,%r13,1),%rdi
movzbl 0x1(%rbp,%r12,2),%edx
mov    0xb0(%rsp),%esi
mov    %r15d,%r8d
call   1030 <qc_imag_writergb@plt>
lea    (%rbx,%r13,1),%rdi
mov    %rbx,%r13
movzbl 0x2(%rbp,%r12,2),%ecx
mov    0x8(%rsp),%rax
movzbl (%rax,%r12,2),%r8d
mov    0xb0(%rsp),%esi
mov    %r14d,%edx
mov    0x70(%rsp),%r14
call   1030 <qc_imag_writergb@plt>
mov    0x18(%rsp),%rbp
mov    0x68(%rsp),%rax
add    %rax,%rbp
add    %rax,%r13
add    $0x1,%r12
cmp    %r12d,%r14d
jne    1210 <qc_imag_bay2rgb_horip+0x100>
mov    (%rsp),%rbx
movzbl 0x1(%rbx,%r12,2),%edx
movzbl (%rbx,%r12,2),%ecx
mov    0x30(%rsp),%r15
movzbl (%r15,%r12,2),%r8d
mov    %rbp,%rdi
mov    0xb0(%rsp),%esi
call   1030 <qc_imag_writergb@plt>
add    0x10(%rsp),%rbp
movzbl 0x1(%rbx,%r12,2),%edx
mov    0x28(%rsp),%r13
movzbl 0x0(%r13,%r12,2),%ecx
movzbl (%r15,%r12,2),%r8d
mov    %r15,%r12
mov    %rbp,%rdi
mov    0xb0(%rsp),%esi
call   1030 <qc_imag_writergb@plt>
mov    0x40(%rsp),%rax
add    %rax,%rbx
mov    %rbx,(%rsp)
mov    0x60(%rsp),%rbx
mov    0x38(%rsp),%rcx
add    %rcx,%rbx
mov    0x58(%rsp),%r15
add    %rcx,%r15
add    %rax,%r13
mov    %r12,%rsi
add    %rax,%rsi
mov    0x8(%rsp),%rcx
add    %rax,%rcx
mov    0x24(%rsp),%edx
add    $0xffffffff,%edx
mov    %rsi,%rax
jne    11a0 <qc_imag_bay2rgb_horip+0x90>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @qc_imag_bay2rgb_horip(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i8
%21 = alloca i8
%22 = alloca i8
%23 = alloca i32
%24 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%25 = load i32, i32* %12
%26 = sub nsw i32 %25, 2
%27 = sdiv i32 %26, 2
store i32 %27, i32* %19
%28 = load i32, i32* %13
%29 = sdiv i32 %28, 2
store i32 %29, i32* %24
%30 = load i32, i32* %9
%31 = mul nsw i32 2, %30
store i32 %31, i32* %17
%32 = load i32, i32* %11
%33 = mul nsw i32 2, %32
store i32 %33, i32* %18
br label %34
34: ; preds = %245, %7
%35 = load i8*, i8** %10
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i32, i32* %14
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = load i8*, i8** %8
%42 = getelementptr inbounds i8, i8* %41, i64 0
%43 = load i8, i8* %42
%44 = load i8*, i8** %8
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = call i32 @qc_imag_writergb(i8* %36, i32 %37, i8 zeroext %40, i8 zeroext %43, i8 zeroext %48)
%50 = load i8*, i8** %10
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i32, i32* %14
%55 = load i8*, i8** %8
%56 = getelementptr inbounds i8, i8* %55, i64 1
%57 = load i8, i8* %56
%58 = load i8*, i8** %8
%59 = getelementptr inbounds i8, i8* %58, i64 0
%60 = load i8, i8* %59
%61 = load i8*, i8** %8
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
%65 = load i8, i8* %64
%66 = call i32 @qc_imag_writergb(i8* %53, i32 %54, i8 zeroext %57, i8 zeroext %60, i8 zeroext %65)
%67 = load i8*, i8** %8
%68 = getelementptr inbounds i8, i8* %67, i64 1
store i8* %68, i8** %15
%69 = load i8*, i8** %10
%70 = load i32, i32* %14
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
store i8* %72, i8** %16
%73 = load i32, i32* %19
store i32 %73, i32* %23
br label %74
74: ; preds = %196, %34
%75 = load i8*, i8** %15
%76 = getelementptr inbounds i8, i8* %75, i64 -1
%77 = load i8, i8* %76
%78 = zext i8 %77 to i32
%79 = load i8*, i8** %15
%80 = getelementptr inbounds i8, i8* %79, i64 1
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = add i32 %78, %82
%84 = udiv i32 %83, 2
%85 = trunc i32 %84 to i8
store i8 %85, i8* %21
%86 = load i8*, i8** %15
%87 = load i32, i32* %9
%88 = sub nsw i32 %87, 1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %86, i64 %89
%91 = load i8, i8* %90
%92 = zext i8 %91 to i32
%93 = load i8*, i8** %15
%94 = load i32, i32* %9
%95 = add nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %93, i64 %96
%98 = load i8, i8* %97
%99 = zext i8 %98 to i32
%100 = add i32 %92, %99
%101 = udiv i32 %100, 2
%102 = trunc i32 %101 to i8
store i8 %102, i8* %22
%103 = load i8*, i8** %16
%104 = getelementptr inbounds i8, i8* %103, i64 0
%105 = load i32, i32* %14
%106 = load i8*, i8** %15
%107 = getelementptr inbounds i8, i8* %106, i64 0
%108 = load i8, i8* %107
%109 = load i8, i8* %21
%110 = load i8, i8* %22
%111 = call i32 @qc_imag_writergb(i8* %104, i32 %105, i8 zeroext %108, i8 zeroext %109, i8 zeroext %110)
%112 = load i8*, i8** %15
%113 = getelementptr inbounds i8, i8* %112, i64 0
%114 = load i8, i8* %113
%115 = zext i8 %114 to i32
%116 = load i8*, i8** %15
%117 = getelementptr inbounds i8, i8* %116, i64 2
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = add i32 %115, %119
%121 = udiv i32 %120, 2
%122 = trunc i32 %121 to i8
store i8 %122, i8* %20
%123 = load i8*, i8** %16
%124 = load i32, i32* %14
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i8, i8* %123, i64 %125
%127 = load i32, i32* %14
%128 = load i8, i8* %20
%129 = load i8*, i8** %15
%130 = getelementptr inbounds i8, i8* %129, i64 1
%131 = load i8, i8* %130
%132 = load i8*, i8** %15
%133 = load i32, i32* %9
%134 = add nsw i32 %133, 1
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds i8, i8* %132, i64 %135
%137 = load i8, i8* %136
%138 = call i32 @qc_imag_writergb(i8* %126, i32 %127, i8 zeroext %128, i8 zeroext %131, i8 zeroext %137)
%139 = load i8*, i8** %15
%140 = load i32, i32* %9
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i8, i8* %139, i64 %141
%143 = load i8, i8* %142
%144 = zext i8 %143 to i32
%145 = load i8*, i8** %15
%146 = load i32, i32* %9
%147 = add nsw i32 %146, 2
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i8, i8* %145, i64 %148
%150 = load i8, i8* %149
%151 = zext i8 %150 to i32
%152 = add i32 %144, %151
%153 = udiv i32 %152, 2
%154 = trunc i32 %153 to i8
store i8 %154, i8* %21
%155 = load i8*, i8** %16
%156 = load i32, i32* %11
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i8, i8* %155, i64 %157
%159 = load i32, i32* %14
%160 = load i8*, i8** %15
%161 = getelementptr inbounds i8, i8* %160, i64 0
%162 = load i8, i8* %161
%163 = load i8*, i8** %15
%164 = load i32, i32* %9
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds i8, i8* %163, i64 %165
%167 = load i8, i8* %166
%168 = load i8, i8* %22
%169 = call i32 @qc_imag_writergb(i8* %158, i32 %159, i8 zeroext %162, i8 zeroext %167, i8 zeroext %168)
%170 = load i8*, i8** %16
%171 = load i32, i32* %11
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i8, i8* %170, i64 %172
%174 = load i32, i32* %14
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds i8, i8* %173, i64 %175
%177 = load i32, i32* %14
%178 = load i8, i8* %20
%179 = load i8*, i8** %15
%180 = getelementptr inbounds i8, i8* %179, i64 1
%181 = load i8, i8* %180
%182 = load i8*, i8** %15
%183 = load i32, i32* %9
%184 = add nsw i32 %183, 1
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds i8, i8* %182, i64 %185
%187 = load i8, i8* %186
%188 = call i32 @qc_imag_writergb(i8* %176, i32 %177, i8 zeroext %178, i8 zeroext %181, i8 zeroext %187)
%189 = load i8*, i8** %15
%190 = getelementptr inbounds i8, i8* %189, i64 2
store i8* %190, i8** %15
%191 = load i32, i32* %14
%192 = mul nsw i32 2, %191
%193 = load i8*, i8** %16
%194 = sext i32 %192 to i64
%195 = getelementptr inbounds i8, i8* %193, i64 %194
store i8* %195, i8** %16
br label %196
196: ; preds = %74
%197 = load i32, i32* %23
%198 = add i32 %197, -1
store i32 %198, i32* %23
%199 = icmp ne i32 %198, 0
br i1 %199, label %74, label %200
200: ; preds = %196
%201 = load i8*, i8** %16
%202 = getelementptr inbounds i8, i8* %201, i64 0
%203 = load i32, i32* %14
%204 = load i8*, i8** %15
%205 = getelementptr inbounds i8, i8* %204, i64 0
%206 = load i8, i8* %205
%207 = load i8*, i8** %15
%208 = getelementptr inbounds i8, i8* %207, i64 -1
%209 = load i8, i8* %208
%210 = load i8*, i8** %15
%211 = load i32, i32* %9
%212 = sub nsw i32 %211, 1
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds i8, i8* %210, i64 %213
%215 = load i8, i8* %214
%216 = call i32 @qc_imag_writergb(i8* %202, i32 %203, i8 zeroext %206, i8 zeroext %209, i8 zeroext %215)
%217 = load i8*, i8** %16
%218 = load i32, i32* %11
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds i8, i8* %217, i64 %219
%221 = load i32, i32* %14
%222 = load i8*, i8** %15
%223 = getelementptr inbounds i8, i8* %222, i64 0
%224 = load i8, i8* %223
%225 = load i8*, i8** %15
%226 = load i32, i32* %9
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds i8, i8* %225, i64 %227
%229 = load i8, i8* %228
%230 = load i8*, i8** %15
%231 = load i32, i32* %9
%232 = sub nsw i32 %231, 1
%233 = sext i32 %232 to i64
%234 = getelementptr inbounds i8, i8* %230, i64 %233
%235 = load i8, i8* %234
%236 = call i32 @qc_imag_writergb(i8* %220, i32 %221, i8 zeroext %224, i8 zeroext %229, i8 zeroext %235)
%237 = load i32, i32* %17
%238 = load i8*, i8** %8
%239 = sext i32 %237 to i64
%240 = getelementptr inbounds i8, i8* %238, i64 %239
store i8* %240, i8** %8
%241 = load i32, i32* %18
%242 = load i8*, i8** %10
%243 = sext i32 %241 to i64
%244 = getelementptr inbounds i8, i8* %242, i64 %243
store i8* %244, i8** %10
br label %245
245: ; preds = %200
%246 = load i32, i32* %24
%247 = add i32 %246, -1
store i32 %247, i32* %24
%248 = icmp ne i32 %247, 0
br i1 %248, label %34, label %249
249: ; preds = %245
ret void
}

LLVM IR (-O2):
define void @qc_imag_bay2rgb_horip(i8* nocapture %0, i32 %1, i8* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = add nsw i32 %4, -2
%9 = sdiv i32 %8, 2
%10 = sdiv i32 %5, 2
%11 = shl nsw i32 %1, 1
%12 = shl nsw i32 %3, 1
%13 = sext i32 %1 to i64
%14 = sext i32 %3 to i64
%15 = sext i32 %6 to i64
%16 = add nsw i32 %1, -1
%17 = sext i32 %16 to i64
%18 = add nsw i32 %1, 1
%19 = sext i32 %18 to i64
%20 = shl nsw i32 %6, 1
%21 = sext i32 %20 to i64
%22 = sext i32 %11 to i64
%23 = sext i32 %12 to i64
br label %24
24: ; preds = %88, %7
%25 = phi i8* [ %2, %7 ], [ %102, %88 ]
%26 = phi i8* [ %0, %7 ], [ %101, %88 ]
%27 = phi i32 [ %10, %7 ], [ %103, %88 ]
%28 = getelementptr inbounds i8, i8* %26, i64 1
%29 = load i8, i8* %28
%30 = load i8, i8* %26
%31 = getelementptr inbounds i8, i8* %26, i64 %13
%32 = load i8, i8* %31
%33 = tail call i32 @qc_imag_writergb(i8* %25, i32 %6, i8 zeroext %29, i8 zeroext %30, i8 zeroext %32)
%34 = getelementptr inbounds i8, i8* %25, i64 %14
%35 = load i8, i8* %28
%36 = load i8, i8* %26
%37 = load i8, i8* %31
%38 = tail call i32 @qc_imag_writergb(i8* %34, i32 %6, i8 zeroext %35, i8 zeroext %36, i8 zeroext %37)
%39 = getelementptr inbounds i8, i8* %25, i64 %15
br label %40
40: ; preds = %40, %24
%41 = phi i8* [ %39, %24 ], [ %85, %40 ]
%42 = phi i8* [ %28, %24 ], [ %66, %40 ]
%43 = phi i32 [ %9, %24 ], [ %86, %40 ]
%44 = getelementptr inbounds i8, i8* %42, i64 -1
%45 = load i8, i8* %44
%46 = zext i8 %45 to i16
%47 = getelementptr inbounds i8, i8* %42, i64 1
%48 = load i8, i8* %47
%49 = zext i8 %48 to i16
%50 = add nuw nsw i16 %49, %46
%51 = lshr i16 %50, 1
%52 = trunc i16 %51 to i8
%53 = getelementptr inbounds i8, i8* %42, i64 %17
%54 = load i8, i8* %53
%55 = zext i8 %54 to i16
%56 = getelementptr inbounds i8, i8* %42, i64 %19
%57 = load i8, i8* %56
%58 = zext i8 %57 to i16
%59 = add nuw nsw i16 %58, %55
%60 = lshr i16 %59, 1
%61 = trunc i16 %60 to i8
%62 = load i8, i8* %42
%63 = tail call i32 @qc_imag_writergb(i8* %41, i32 %6, i8 zeroext %62, i8 zeroext %52, i8 zeroext %61)
%64 = load i8, i8* %42
%65 = zext i8 %64 to i16
%66 = getelementptr inbounds i8, i8* %42, i64 2
%67 = load i8, i8* %66
%68 = zext i8 %67 to i16
%69 = add nuw nsw i16 %68, %65
%70 = lshr i16 %69, 1
%71 = trunc i16 %70 to i8
%72 = getelementptr inbounds i8, i8* %41, i64 %15
%73 = load i8, i8* %47
%74 = load i8, i8* %56
%75 = tail call i32 @qc_imag_writergb(i8* %72, i32 %6, i8 zeroext %71, i8 zeroext %73, i8 zeroext %74)
%76 = getelementptr inbounds i8, i8* %42, i64 %13
%77 = load i8, i8* %76
%78 = getelementptr inbounds i8, i8* %41, i64 %14
%79 = load i8, i8* %42
%80 = tail call i32 @qc_imag_writergb(i8* %78, i32 %6, i8 zeroext %79, i8 zeroext %77, i8 zeroext %61)
%81 = getelementptr inbounds i8, i8* %78, i64 %15
%82 = load i8, i8* %47
%83 = load i8, i8* %56
%84 = tail call i32 @qc_imag_writergb(i8* %81, i32 %6, i8 zeroext %71, i8 zeroext %82, i8 zeroext %83)
%85 = getelementptr inbounds i8, i8* %41, i64 %21
%86 = add i32 %43, -1
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %40
88: ; preds = %40
%89 = getelementptr inbounds i8, i8* %42, i64 1
%90 = load i8, i8* %66
%91 = load i8, i8* %89
%92 = getelementptr inbounds i8, i8* %66, i64 %17
%93 = load i8, i8* %92
%94 = tail call i32 @qc_imag_writergb(i8* %85, i32 %6, i8 zeroext %90, i8 zeroext %91, i8 zeroext %93)
%95 = getelementptr inbounds i8, i8* %85, i64 %14
%96 = load i8, i8* %66
%97 = getelementptr inbounds i8, i8* %66, i64 %13
%98 = load i8, i8* %97
%99 = load i8, i8* %92
%100 = tail call i32 @qc_imag_writergb(i8* %95, i32 %6, i8 zeroext %96, i8 zeroext %98, i8 zeroext %99)
%101 = getelementptr inbounds i8, i8* %26, i64 %22
%102 = getelementptr inbounds i8, i8* %25, i64 %23
%103 = add i32 %27, -1
%104 = icmp eq i32 %103, 0
br i1 %104, label %105, label %24
105: ; preds = %88
ret void
}