#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 last_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;
  unsigned int ba, cb;
  unsigned char *restrict src = dest;
  unsigned char *restrict des = dest;
  unsigned int const_51_205, const_205_51, const_154_102;
  const_51_205 = 0x3300CD00;
  const_205_51 = 0xCD003300;
  const_154_102 = 0x9A006600;
  a = src[0];
  b = src[dest_pitch];
  c = src[dest_pitch * 2];
  src++;
  for (i = 0; i < dest_width; ++i) {
    ba = _pack2(b, a);
    cb = _pack2(c, b);
    a = src[0];
    b = src[dest_pitch];
    c = src[dest_pitch * 2];
    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] = (unsigned char)(c);
    des++;
  }
}


x86 assembly (clang, -O0):
<last_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,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x3300cd00,-0x3c(%rbp)
movl   $0xcd003300,-0x40(%rbp)
movl   $0x9a006600,-0x44(%rbp)
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    126f <last_vertical_band_3_5_scale_c64+0x14f>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <_pack2@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <_pack2@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x44(%rbp),%esi
call   1040 <_dotprsu2@plt>
mov    %al,%dl
mov    -0x38(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1040 <_dotprsu2@plt>
mov    %al,%dl
mov    -0x38(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1040 <_dotprsu2@plt>
mov    %al,%dl
mov    -0x38(%rbp),%rax
imul   $0x3,-0xc(%rbp),%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
mov    %al,%dl
mov    -0x38(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1195 <last_vertical_band_3_5_scale_c64+0x75>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<last_vertical_band_3_5_scale_c64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,0x8(%rsp)
test   %edx,%edx
je     122e <last_vertical_band_3_5_scale_c64+0x10e>
mov    %esi,%eax
lea    (%rsi,%rsi,1),%ecx
mov    0x8(%rsp),%rdi
mov    (%rdi,%rax,1),%r8b
mov    (%rdi,%rcx,1),%r13b
mov    (%rdi),%bl
lea    (%rsi,%rsi,2),%ebp
shl    $0x2,%esi
add    %rdi,%rsi
mov    %rsi,0x30(%rsp)
add    %rdi,%rbp
mov    %rbp,0x28(%rsp)
add    %rdi,%rcx
add    $0x1,%rcx
mov    %rcx,0x20(%rsp)
lea    0x1(%rdi,%rax,1),%rax
mov    %rax,0x18(%rsp)
mov    %edx,%eax
mov    %rax,0x10(%rsp)
xor    %r14d,%r14d
mov    0x20(%rsp),%r15
nopw   0x0(%rax,%rax,1)
movzbl %r8b,%ebp
movzbl %bl,%esi
movzbl %r13b,%ebx
mov    %ebp,%edi
call   1030 <_pack2@plt>
mov    %eax,%r12d
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <_pack2@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rax
movzbl 0x1(%rax,%r14,1),%eax
mov    %al,0x7(%rsp)
mov    0x18(%rsp),%rbp
movzbl 0x0(%rbp,%r14,1),%eax
mov    %al,0x6(%rsp)
movzbl (%r15,%r14,1),%r13d
mov    %r12d,%edi
mov    $0x9a006600,%esi
call   1040 <_dotprsu2@plt>
mov    %al,-0x1(%rbp,%r14,1)
mov    %ebx,%edi
mov    $0x3300cd00,%esi
call   1040 <_dotprsu2@plt>
mov    %al,-0x1(%r15,%r14,1)
mov    %ebx,%edi
mov    $0xcd003300,%esi
call   1040 <_dotprsu2@plt>
movzbl 0x7(%rsp),%ebx
movzbl 0x6(%rsp),%r8d
mov    0x28(%rsp),%rcx
mov    %al,(%rcx,%r14,1)
mov    0x30(%rsp),%rax
mov    %r13b,(%rax,%r14,1)
add    $0x1,%r14
cmp    %r14d,0x10(%rsp)
jne    1190 <last_vertical_band_3_5_scale_c64+0x70>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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