#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 */
unsigned char _dotprsu2(unsigned int, unsigned int);
unsigned int _pack2(unsigned int, unsigned int);
void vertical_band_3_5_scale_c64(unsigned char *dest, unsigned int dest_pitch,
                                 unsigned int dest_width) {
  unsigned int i;
  unsigned int a, b, c, d;
  unsigned int ba, cb, dc;
  unsigned char *restrict src = dest;
  unsigned char *restrict des = dest;
  unsigned int const_51_205, const_102_154, const_205_51, const_154_102;
  const_51_205 = 0x3300CD00;
  const_205_51 = 0xCD003300;
  const_102_154 = 0x66009A00;
  const_154_102 = 0x9A006600;
  a = src[0];
  b = src[dest_pitch];
  c = src[dest_pitch * 2];
  d = src[dest_pitch * 5];
  src++;
  for (i = 0; i < dest_width; i++) {
    ba = _pack2(b, a);
    cb = _pack2(c, b);
    dc = _pack2(d, c);
    a = src[0];
    b = src[dest_pitch];
    c = src[dest_pitch * 2];
    d = src[dest_pitch * 5];
    src++;
    des[dest_pitch] = _dotprsu2(ba, const_154_102);
    des[dest_pitch * 2] = _dotprsu2(cb, const_51_205);
    des[dest_pitch * 3] = _dotprsu2(cb, const_205_51);
    des[dest_pitch * 4] = _dotprsu2(dc, const_102_154);
    des++;
  }
}


x86 assembly (clang, -O0):
<vertical_band_3_5_scale_c64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x3300cd00,-0x44(%rbp)
movl   $0xcd003300,-0x4c(%rbp)
movl   $0x66009a00,-0x48(%rbp)
movl   $0x9a006600,-0x50(%rbp)
mov    -0x38(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x38(%rbp),%rax
mov    -0xc(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
imul   $0x5,-0xc(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    12ae <vertical_band_3_5_scale_c64+0x18e>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <_pack2@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <_pack2@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <_pack2@plt>
mov    %eax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x38(%rbp),%rax
mov    -0xc(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
imul   $0x5,-0xc(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1040 <_dotprsu2@plt>
mov    %al,%dl
mov    -0x40(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%edi
mov    -0x44(%rbp),%esi
call   1040 <_dotprsu2@plt>
mov    %al,%dl
mov    -0x40(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%edi
mov    -0x4c(%rbp),%esi
call   1040 <_dotprsu2@plt>
mov    %al,%dl
mov    -0x40(%rbp),%rax
imul   $0x3,-0xc(%rbp),%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%edi
mov    -0x48(%rbp),%esi
call   1040 <_dotprsu2@plt>
mov    %al,%dl
mov    -0x40(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ad <vertical_band_3_5_scale_c64+0x8d>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vertical_band_3_5_scale_c64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,0x10(%rsp)
test   %edx,%edx
je     1284 <vertical_band_3_5_scale_c64+0x164>
mov    %rsi,%rdi
mov    %edi,%r8d
lea    (%rsi,%rsi,1),%ecx
lea    (%rsi,%rsi,4),%esi
mov    0x10(%rsp),%rbp
mov    0x0(%rbp,%rcx,1),%r12b
mov    0x0(%rbp,%r8,1),%bl
mov    0x0(%rbp,%rsi,1),%r10b
mov    0x0(%rbp),%r9b
lea    (%rdi,%rdi,2),%eax
shl    $0x2,%edi
add    %rbp,%rdi
mov    %rdi,0x40(%rsp)
add    %rbp,%rax
mov    %rax,0x38(%rsp)
add    %rbp,%rcx
add    $0x1,%rcx
mov    %rcx,0x30(%rsp)
lea    0x1(%rbp,%r8,1),%rax
mov    %rax,0x28(%rsp)
lea    0x1(%rbp,%rsi,1),%rax
mov    %rax,0x20(%rsp)
mov    %edx,%eax
mov    %rax,0x18(%rsp)
xor    %r14d,%r14d
mov    0x28(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl %bl,%ebp
movzbl %r12b,%ebx
movzbl %r9b,%esi
movzbl %r10b,%r12d
mov    %ebp,%edi
call   1030 <_pack2@plt>
mov    %eax,%r13d
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <_pack2@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %ebx,%esi
call   1030 <_pack2@plt>
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%rax
movzbl 0x1(%rax,%r14,1),%eax
mov    %al,0xb(%rsp)
movzbl (%r15,%r14,1),%eax
mov    %al,0x9(%rsp)
mov    0x30(%rsp),%rbx
movzbl (%rbx,%r14,1),%eax
mov    %al,0xa(%rsp)
mov    0x20(%rsp),%rax
movzbl (%rax,%r14,1),%r12d
mov    %r13d,%edi
mov    $0x9a006600,%esi
call   1040 <_dotprsu2@plt>
mov    %al,-0x1(%r15,%r14,1)
mov    %ebp,%edi
mov    $0x3300cd00,%esi
call   1040 <_dotprsu2@plt>
mov    %al,-0x1(%rbx,%r14,1)
mov    %ebp,%edi
mov    $0xcd003300,%esi
call   1040 <_dotprsu2@plt>
mov    0x38(%rsp),%rcx
mov    %al,(%rcx,%r14,1)
mov    0xc(%rsp),%edi
mov    $0x66009a00,%esi
call   1040 <_dotprsu2@plt>
mov    %r12d,%r10d
movzbl 0x9(%rsp),%ebx
movzbl 0xb(%rsp),%r9d
movzbl 0xa(%rsp),%r12d
mov    0x40(%rsp),%rcx
mov    %al,(%rcx,%r14,1)
add    $0x1,%r14
cmp    %r14d,0x18(%rsp)
jne    11b0 <vertical_band_3_5_scale_c64+0x90>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @vertical_band_3_5_scale_c64(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%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 i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%21 = load i8*, i8** %4
store i8* %21, i8** %15
%22 = load i8*, i8** %4
store i8* %22, i8** %16
store i32 855690496, i32* %17
store i32 -855624960, i32* %19
store i32 1711315456, i32* %18
store i32 -1711249920, i32* %20
%23 = load i8*, i8** %15
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
store i32 %26, i32* %8
%27 = load i8*, i8** %15
%28 = load i32, i32* %5
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
store i32 %32, i32* %9
%33 = load i8*, i8** %15
%34 = load i32, i32* %5
%35 = mul i32 %34, 2
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
store i32 %39, i32* %10
%40 = load i8*, i8** %15
%41 = load i32, i32* %5
%42 = mul i32 %41, 5
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
store i32 %46, i32* %11
%47 = load i8*, i8** %15
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %15
store i32 0, i32* %7
br label %49
49: ; preds = %122, %3
%50 = load i32, i32* %7
%51 = load i32, i32* %6
%52 = icmp ult i32 %50, %51
br i1 %52, label %53, label %125
53: ; preds = %49
%54 = load i32, i32* %9
%55 = load i32, i32* %8
%56 = call i32 @_pack2(i32 %54, i32 %55)
store i32 %56, i32* %12
%57 = load i32, i32* %10
%58 = load i32, i32* %9
%59 = call i32 @_pack2(i32 %57, i32 %58)
store i32 %59, i32* %13
%60 = load i32, i32* %11
%61 = load i32, i32* %10
%62 = call i32 @_pack2(i32 %60, i32 %61)
store i32 %62, i32* %14
%63 = load i8*, i8** %15
%64 = getelementptr inbounds i8, i8* %63, i64 0
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
store i32 %66, i32* %8
%67 = load i8*, i8** %15
%68 = load i32, i32* %5
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
store i32 %72, i32* %9
%73 = load i8*, i8** %15
%74 = load i32, i32* %5
%75 = mul i32 %74, 2
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
store i32 %79, i32* %10
%80 = load i8*, i8** %15
%81 = load i32, i32* %5
%82 = mul i32 %81, 5
%83 = zext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %80, i64 %83
%85 = load i8, i8* %84
%86 = zext i8 %85 to i32
store i32 %86, i32* %11
%87 = load i8*, i8** %15
%88 = getelementptr inbounds i8, i8* %87, i32 1
store i8* %88, i8** %15
%89 = load i32, i32* %12
%90 = load i32, i32* %20
%91 = call zeroext i8 @_dotprsu2(i32 %89, i32 %90)
%92 = load i8*, i8** %16
%93 = load i32, i32* %5
%94 = zext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %92, i64 %94
store i8 %91, i8* %95
%96 = load i32, i32* %13
%97 = load i32, i32* %17
%98 = call zeroext i8 @_dotprsu2(i32 %96, i32 %97)
%99 = load i8*, i8** %16
%100 = load i32, i32* %5
%101 = mul i32 %100, 2
%102 = zext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %99, i64 %102
store i8 %98, i8* %103
%104 = load i32, i32* %13
%105 = load i32, i32* %19
%106 = call zeroext i8 @_dotprsu2(i32 %104, i32 %105)
%107 = load i8*, i8** %16
%108 = load i32, i32* %5
%109 = mul i32 %108, 3
%110 = zext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %107, i64 %110
store i8 %106, i8* %111
%112 = load i32, i32* %14
%113 = load i32, i32* %18
%114 = call zeroext i8 @_dotprsu2(i32 %112, i32 %113)
%115 = load i8*, i8** %16
%116 = load i32, i32* %5
%117 = mul i32 %116, 4
%118 = zext i32 %117 to i64
%119 = getelementptr inbounds i8, i8* %115, i64 %118
store i8 %114, i8* %119
%120 = load i8*, i8** %16
%121 = getelementptr inbounds i8, i8* %120, i32 1
store i8* %121, i8** %16
br label %122
122: ; preds = %53
%123 = load i32, i32* %7
%124 = add i32 %123, 1
store i32 %124, i32* %7
br label %49
125: ; preds = %49
ret void
}

LLVM IR (-O2):
define void @vertical_band_3_5_scale_c64(i8* nocapture %0, i32 %1, i32 %2) {
%4 = zext i32 %1 to i64
%5 = shl i32 %1, 1
%6 = zext i32 %5 to i64
%7 = mul i32 %1, 5
%8 = zext i32 %7 to i64
%9 = icmp eq i32 %2, 0
br i1 %9, label %54, label %10
10: ; preds = %3
%11 = getelementptr inbounds i8, i8* %0, i64 %6
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 %4
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %0, i64 %8
%16 = load i8, i8* %15
%17 = load i8, i8* %0
%18 = mul i32 %1, 3
%19 = zext i32 %18 to i64
%20 = shl i32 %1, 2
%21 = zext i32 %20 to i64
br label %22
22: ; preds = %10, %22
%23 = phi i8 [ %12, %10 ], [ %41, %22 ]
%24 = phi i8 [ %14, %10 ], [ %39, %22 ]
%25 = phi i8* [ %0, %10 ], [ %29, %22 ]
%26 = phi i32 [ 0, %10 ], [ %52, %22 ]
%27 = phi i8 [ %17, %10 ], [ %37, %22 ]
%28 = phi i8 [ %16, %10 ], [ %43, %22 ]
%29 = getelementptr inbounds i8, i8* %25, i64 1
%30 = zext i8 %24 to i32
%31 = zext i8 %23 to i32
%32 = zext i8 %27 to i32
%33 = zext i8 %28 to i32
%34 = tail call i32 @_pack2(i32 %30, i32 %32)
%35 = tail call i32 @_pack2(i32 %31, i32 %30)
%36 = tail call i32 @_pack2(i32 %33, i32 %31)
%37 = load i8, i8* %29
%38 = getelementptr inbounds i8, i8* %29, i64 %4
%39 = load i8, i8* %38
%40 = getelementptr inbounds i8, i8* %29, i64 %6
%41 = load i8, i8* %40
%42 = getelementptr inbounds i8, i8* %29, i64 %8
%43 = load i8, i8* %42
%44 = tail call zeroext i8 @_dotprsu2(i32 %34, i32 -1711249920)
%45 = getelementptr inbounds i8, i8* %25, i64 %4
store i8 %44, i8* %45
%46 = tail call zeroext i8 @_dotprsu2(i32 %35, i32 855690496)
%47 = getelementptr inbounds i8, i8* %25, i64 %6
store i8 %46, i8* %47
%48 = tail call zeroext i8 @_dotprsu2(i32 %35, i32 -855624960)
%49 = getelementptr inbounds i8, i8* %25, i64 %19
store i8 %48, i8* %49
%50 = tail call zeroext i8 @_dotprsu2(i32 %36, i32 1711315456)
%51 = getelementptr inbounds i8, i8* %25, i64 %21
store i8 %50, i8* %51
%52 = add nuw i32 %26, 1
%53 = icmp eq i32 %52, %2
br i1 %53, label %54, label %22
54: ; preds = %22, %3
ret void
}