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


x86 assembly (clang, -O0):
<horizontal_line_3_5_scale_c64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jae    1269 <horizontal_line_3_5_scale_c64+0x119>
mov    -0x40(%rbp),%rdi
call   1030 <_mem4@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
call   1060 <_unpklu4@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%edi
mov    $0x8,%esi
call   1050 <_rotl@plt>
mov    %eax,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%edi
call   1040 <_unpkhu4@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%edi
mov    -0x44(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x28(%rbp),%edi
mov    -0x4c(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x2c(%rbp),%edi
mov    -0x48(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x40(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x20(%rbp)
jmp    1199 <horizontal_line_3_5_scale_c64+0x49>
mov    -0x40(%rbp),%rdi
call   1030 <_mem4@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
call   1060 <_unpklu4@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%edi
mov    $0x8,%esi
call   1050 <_rotl@plt>
mov    %eax,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%edi
call   1040 <_unpkhu4@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%edi
mov    -0x44(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x28(%rbp),%edi
mov    -0x4c(%rbp),%esi
call   1070 <_dotprsu2@plt>
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x2c(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x4(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<horizontal_line_3_5_scale_c64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
add    $0xfffffffd,%esi
je     121a <horizontal_line_3_5_scale_c64+0xca>
xor    %r15d,%r15d
mov    %rdi,0x10(%rsp)
mov    %esi,0xc(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
lea    (%rax,%r15,1),%rdi
call   1030 <_mem4@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <_unpklu4@plt>
mov    %eax,%r12d
mov    %ebp,%edi
mov    $0x8,%esi
call   1050 <_rotl@plt>
mov    %eax,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,%r13d
mov    %ebp,%edi
call   1040 <_unpkhu4@plt>
mov    %eax,%r14d
mov    %bpl,(%rbx)
mov    %r12d,%edi
mov    $0x9a006600,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x1(%rbx)
mov    %r13d,%edi
mov    $0x3300cd00,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x2(%rbx)
mov    %r13d,%edi
mov    $0xcd003300,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x3(%rbx)
mov    %r14d,%edi
mov    $0x66009a00,%esi
call   1070 <_dotprsu2@plt>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%rdi
mov    %al,0x4(%rbx)
add    $0x5,%rbx
add    $0x3,%r15
cmp    %esi,%r15d
jb     1180 <horizontal_line_3_5_scale_c64+0x30>
add    %r15,%rdi
call   1030 <_mem4@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <_unpklu4@plt>
mov    %eax,%r14d
mov    %ebp,%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,%r12d
mov    %bpl,(%rbx)
mov    %r14d,%edi
mov    $0x9a006600,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x1(%rbx)
mov    %r15d,%edi
mov    $0x3300cd00,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x2(%rbx)
mov    %r15d,%edi
mov    $0xcd003300,%esi
call   1070 <_dotprsu2@plt>
mov    %al,0x3(%rbx)
mov    %r12b,0x4(%rbx)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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