#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 _mem4(unsigned int *);
unsigned int _rotl(unsigned int, int);
unsigned int _shrmb(unsigned int, unsigned int);
unsigned int _unpkhu4(unsigned int);
unsigned int _unpklu4(unsigned int);
void horizontal_line_4_5_scale_c64(const unsigned char *source,
                                   unsigned int source_width,
                                   unsigned char *dest,
                                   unsigned int dest_width) {
  unsigned i;
  unsigned int ba, cb, dc, ed;
  unsigned char *restrict des = dest;
  unsigned int *restrict src = (unsigned int *)source;
  unsigned int const_51_205, const_102_154, const_205_51, const_154_102;
  unsigned int src_current, src_next;
  (void)dest_width;
  const_51_205 = 0x3300CD00;
  const_205_51 = 0xCD003300;
  const_102_154 = 0x66009A00;
  const_154_102 = 0x9A006600;
  src_current = _mem4(src);
  for (i = 0; i < source_width - 4; i += 4) {
    src_next = _mem4(src++);
    ba = _unpklu4(src_current);
    cb = _unpkhu4(_rotl(src_current, 8));
    dc = _unpkhu4(src_current);
    ed = _unpkhu4(_shrmb(src_next, src_current));
    des[0] = src_current & 0xff;
    des[1] = _dotprsu2(ba, const_205_51);
    des[2] = _dotprsu2(cb, const_154_102);
    des[3] = _dotprsu2(dc, const_102_154);
    des[4] = _dotprsu2(ed, const_51_205);
    des += 5;
    src_current = src_next;
  }
  ba = _unpklu4(src_current);
  cb = _unpkhu4(_rotl(src_current, 8));
  dc = _unpkhu4(src_current);
  des[0] = src_current & 0xff;
  des[1] = _dotprsu2(ba, const_205_51);
  des[2] = _dotprsu2(cb, const_154_102);
  des[3] = _dotprsu2(dc, const_102_154);
  des[4] = src_current & 0xff;
}


x86 assembly (clang, -O0):
<horizontal_line_4_5_scale_c64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%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    -0x40(%rbp),%rdi
call   1030 <_mem4@plt>
mov    %eax,-0x54(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x4,%ecx
cmp    %ecx,%eax
jae    129f <horizontal_line_4_5_scale_c64+0x13f>
mov    -0x40(%rbp),%rdi
mov    %rdi,%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
call   1030 <_mem4@plt>
mov    %eax,-0x58(%rbp)
mov    -0x54(%rbp),%edi
call   1060 <_unpklu4@plt>
mov    %eax,-0x24(%rbp)
mov    -0x54(%rbp),%edi
mov    $0x8,%esi
call   1050 <_rotl@plt>
mov    %eax,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,-0x28(%rbp)
mov    -0x54(%rbp),%edi
call   1040 <_unpkhu4@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x58(%rbp),%edi
mov    -0x54(%rbp),%esi
call   1080 <_shrmb@plt>
mov    %eax,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,-0x30(%rbp)
mov    -0x54(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x4c(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x2c(%rbp),%edi
mov    -0x48(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x30(%rbp),%edi
mov    -0x44(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x38(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x38(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x20(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x20(%rbp)
jmp    11b5 <horizontal_line_4_5_scale_c64+0x55>
mov    -0x54(%rbp),%edi
call   1060 <_unpklu4@plt>
mov    %eax,-0x24(%rbp)
mov    -0x54(%rbp),%edi
mov    $0x8,%esi
call   1050 <_rotl@plt>
mov    %eax,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,-0x28(%rbp)
mov    -0x54(%rbp),%edi
call   1040 <_unpkhu4@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x54(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x4c(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x2c(%rbp),%edi
mov    -0x48(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x54(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x4(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<horizontal_line_4_5_scale_c64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <_mem4@plt>
mov    %eax,%r15d
add    $0xfffffffc,%ebp
je     125a <horizontal_line_4_5_scale_c64+0xfa>
xor    %r13d,%r13d
mov    %ebp,(%rsp)
mov    %rbx,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%ebp
lea    (%rbx,%r13,1),%rdi
call   1030 <_mem4@plt>
mov    %eax,%ebx
mov    %eax,0xc(%rsp)
mov    %r15d,%edi
call   1060 <_unpklu4@plt>
mov    %eax,0x8(%rsp)
mov    %r15d,%edi
mov    $0x8,%esi
call   1050 <_rotl@plt>
mov    %eax,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,0x4(%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
call   1080 <_shrmb@plt>
mov    %eax,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,%r12d
mov    %bpl,(%r14)
mov    0x8(%rsp),%edi
mov    $0xcd003300,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x1(%r14)
mov    %r15d,%edi
mov    0x10(%rsp),%rbx
mov    $0x9a006600,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x2(%r14)
mov    0x4(%rsp),%edi
mov    (%rsp),%ebp
mov    $0x66009a00,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x3(%r14)
mov    %r12d,%edi
mov    0xc(%rsp),%r15d
mov    $0x3300cd00,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x4(%r14)
add    $0x5,%r14
add    $0x4,%r13
cmp    %ebp,%r13d
jb     11a0 <horizontal_line_4_5_scale_c64+0x40>
mov    %r15d,%edi
call   1060 <_unpklu4@plt>
mov    %eax,%ebp
mov    %r15d,%edi
mov    $0x8,%esi
call   1050 <_rotl@plt>
mov    %eax,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,%r12d
mov    %r15d,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,%ebx
mov    %r15b,(%r14)
mov    %ebp,%edi
mov    $0xcd003300,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x1(%r14)
mov    %r12d,%edi
mov    $0x9a006600,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x2(%r14)
mov    %ebx,%edi
mov    $0x66009a00,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x3(%r14)
mov    %r15b,0x4(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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