#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_4_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_102_154, const_205_51, const_154_102;
  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 * 3];
  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 * 3];
    src++;
    des[dest_pitch] = _dotprsu2(ba, const_205_51);
    des[dest_pitch * 2] = _dotprsu2(cb, const_154_102);
    des[dest_pitch * 3] = _dotprsu2(dc, const_102_154);
    des[dest_pitch * 4] = (unsigned char)d;
    des++;
  }
}


x86 assembly (clang, -O0):
<last_vertical_band_4_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   $0xcd003300,-0x48(%rbp)
movl   $0x66009a00,-0x44(%rbp)
movl   $0x9a006600,-0x4c(%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   $0x3,-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    129f <last_vertical_band_4_5_scale_c64+0x17f>
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   $0x3,-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    -0x48(%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    -0x4c(%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    -0x30(%rbp),%edi
mov    -0x44(%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    -0x24(%rbp),%eax
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    11a6 <last_vertical_band_4_5_scale_c64+0x86>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<last_vertical_band_4_5_scale_c64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,0x18(%rsp)
test   %edx,%edx
je     1266 <last_vertical_band_4_5_scale_c64+0x146>
mov    %rsi,%rdi
mov    %edi,%eax
lea    (%rsi,%rsi,1),%ecx
lea    (%rsi,%rsi,2),%esi
mov    0x18(%rsp),%rbp
mov    0x0(%rbp,%rcx,1),%r9b
mov    0x0(%rbp,%rax,1),%bl
mov    0x0(%rbp,%rsi,1),%r12b
mov    0x0(%rbp),%r8b
shl    $0x2,%edi
add    %rbp,%rdi
mov    %rdi,0x40(%rsp)
add    %rbp,%rsi
add    $0x1,%rsi
mov    %rsi,0x38(%rsp)
lea    0x1(%rbp,%rcx,1),%rcx
mov    %rcx,0x30(%rsp)
lea    0x1(%rbp,%rax,1),%rax
mov    %rax,0x28(%rsp)
mov    %edx,%eax
mov    %rax,0x20(%rsp)
xor    %r15d,%r15d
mov    0x38(%rsp),%r14
nopw   0x0(%rax,%rax,1)
movzbl %bl,%ebp
movzbl %r9b,%ebx
movzbl %r8b,%esi
movzbl %r12b,%r12d
mov    %ebp,%edi
call   1030 <_pack2@plt>
mov    %eax,%r13d
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <_pack2@plt>
mov    %eax,0x10(%rsp)
mov    %r12d,%edi
mov    %ebx,%esi
call   1030 <_pack2@plt>
mov    %eax,0x14(%rsp)
mov    0x18(%rsp),%rax
movzbl 0x1(%rax,%r15,1),%eax
mov    %al,0xf(%rsp)
mov    0x28(%rsp),%rbp
movzbl 0x0(%rbp,%r15,1),%eax
mov    %al,0xe(%rsp)
mov    0x30(%rsp),%rbx
movzbl (%rbx,%r15,1),%eax
mov    %al,0xd(%rsp)
movzbl (%r14,%r15,1),%r12d
mov    %r13d,%edi
mov    $0xcd003300,%esi
call   1040 <_dotprsu2@plt>
mov    %al,-0x1(%rbp,%r15,1)
mov    0x10(%rsp),%edi
mov    $0x9a006600,%esi
call   1040 <_dotprsu2@plt>
mov    %al,-0x1(%rbx,%r15,1)
mov    0x14(%rsp),%edi
mov    $0x66009a00,%esi
call   1040 <_dotprsu2@plt>
movzbl 0xe(%rsp),%ebx
movzbl 0xf(%rsp),%r8d
movzbl 0xd(%rsp),%r9d
mov    %al,-0x1(%r14,%r15,1)
mov    0x40(%rsp),%rax
mov    %r12b,(%rax,%r15,1)
add    $0x1,%r15
cmp    %r15d,0x20(%rsp)
jne    11a0 <last_vertical_band_4_5_scale_c64+0x80>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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