void RGB32toRGB444_ROW2X_STRETCH(unsigned char *dest_ptr_1,
                                 unsigned char *dest_ptr_12,
                                 unsigned char *dest_ptr_2, int dest_dx,
                                 unsigned char *src_ptr, int src_dx) {
  register unsigned char *d1 = dest_ptr_1;
  register unsigned char *d12 = dest_ptr_12;
  register unsigned char *d2 = dest_ptr_2;
  register unsigned char *s = src_ptr;
  register int count = dest_dx;
  register int limit = dest_dx >> 1;
  register int step = src_dx;
  if (count) {
    goto start;
    do {
      register unsigned int da_rgb;
      register unsigned int dc_rgb;
      if ((limit -= step) < 0) {
        limit += dest_dx;
      start:
        if (5 == 0) {
          da_rgb = *(unsigned short *)(s);
        } else {
          register unsigned int sa_rgb;
          sa_rgb = *(unsigned int *)(s);
          da_rgb =
              ((8 + 4 < 8)
                   ? (((((16 + 8 < 8) ? ((sa_rgb << ((8 - (16 + 8)) & 0x1F)) &
                                         (0x100 - (1U << (8 - 8))))
                                      : ((sa_rgb >> (((16 + 8) - 8) & 0x1F)) &
                                         (0x100 - (1U << (8 - 8)))))) &
                       (0x100 - (1U << (8 - 4)))) >>
                      ((8 - (8 + 4)) & 0x1F))
                   : (((((16 + 8 < 8) ? ((sa_rgb << ((8 - (16 + 8)) & 0x1F)) &
                                         (0x100 - (1U << (8 - 8))))
                                      : ((sa_rgb >> (((16 + 8) - 8) & 0x1F)) &
                                         (0x100 - (1U << (8 - 8)))))) &
                       (0x100 - (1U << (8 - 4))))
                      << (((8 + 4) - 8) & 0x1F))) |
              ((4 + 4 < 8)
                   ? (((((8 + 8 < 8) ? ((sa_rgb << ((8 - (8 + 8)) & 0x1F)) &
                                        (0x100 - (1U << (8 - 8))))
                                     : ((sa_rgb >> (((8 + 8) - 8) & 0x1F)) &
                                        (0x100 - (1U << (8 - 8)))))) &
                       (0x100 - (1U << (8 - 4)))) >>
                      ((8 - (4 + 4)) & 0x1F))
                   : (((((8 + 8 < 8) ? ((sa_rgb << ((8 - (8 + 8)) & 0x1F)) &
                                        (0x100 - (1U << (8 - 8))))
                                     : ((sa_rgb >> (((8 + 8) - 8) & 0x1F)) &
                                        (0x100 - (1U << (8 - 8)))))) &
                       (0x100 - (1U << (8 - 4))))
                      << (((4 + 4) - 8) & 0x1F))) |
              ((0 + 4 < 8)
                   ? (((((0 + 8 < 8) ? ((sa_rgb << ((8 - (0 + 8)) & 0x1F)) &
                                        (0x100 - (1U << (8 - 8))))
                                     : ((sa_rgb >> (((0 + 8) - 8) & 0x1F)) &
                                        (0x100 - (1U << (8 - 8)))))) &
                       (0x100 - (1U << (8 - 4)))) >>
                      ((8 - (0 + 4)) & 0x1F))
                   : (((((0 + 8 < 8) ? ((sa_rgb << ((8 - (0 + 8)) & 0x1F)) &
                                        (0x100 - (1U << (8 - 8))))
                                     : ((sa_rgb >> (((0 + 8) - 8) & 0x1F)) &
                                        (0x100 - (1U << (8 - 8)))))) &
                       (0x100 - (1U << (8 - 4))))
                      << (((0 + 4) - 8) & 0x1F)));
        }
        s += 4;
        register unsigned int sb_rgb;
        sb_rgb = *(unsigned short *)(d1);
        dc_rgb =
            (((da_rgb ^ sb_rgb) >> 1) & (((1U << (8 + 4 - 1)) - (1U << 8)) |
                                         ((1U << (4 + 4 - 1)) - (1U << 4)) |
                                         ((1U << (0 + 4 - 1)) - (1U << 0)))) +
            (da_rgb & sb_rgb);
      }
      d1 += 2;
      *(unsigned short *)(d2) = da_rgb;
      d2 += 2;
      *(unsigned short *)(d12) = dc_rgb;
      d12 += 2;
    } while (--count);
  }
}


x86 assembly (clang, -O0):
<RGB32toRGB444_ROW2X_STRETCH>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     124d <RGB32toRGB444_ROW2X_STRETCH+0x14d>
jmp    117c <RGB32toRGB444_ROW2X_STRETCH+0x7c>
mov    -0x5c(%rbp),%ecx
mov    -0x58(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x58(%rbp)
cmp    $0x0,%eax
jge    11f8 <RGB32toRGB444_ROW2X_STRETCH+0xf8>
mov    -0x1c(%rbp),%eax
add    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
and    $0xf0,%eax
shl    $0x4,%eax
mov    -0x68(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
and    $0xf0,%ecx
shl    $0x0,%ecx
or     %ecx,%eax
mov    -0x68(%rbp),%ecx
shr    $0x0,%ecx
and    $0xff,%ecx
and    $0xf0,%ecx
shr    $0x4,%ecx
or     %ecx,%eax
mov    %eax,-0x60(%rbp)
mov    -0x50(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rax
movzwl (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x60(%rbp),%eax
xor    -0x6c(%rbp),%eax
shr    $0x1,%eax
and    $0x777,%eax
mov    -0x60(%rbp),%ecx
and    -0x6c(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x64(%rbp)
mov    -0x38(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x38(%rbp)
mov    -0x60(%rbp),%eax
mov    %ax,%cx
mov    -0x48(%rbp),%rax
mov    %cx,(%rax)
mov    -0x48(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x48(%rbp)
mov    -0x64(%rbp),%eax
mov    %ax,%cx
mov    -0x40(%rbp),%rax
mov    %cx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x40(%rbp)
mov    -0x54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
jne    115f <RGB32toRGB444_ROW2X_STRETCH+0x5f>
jmp    124d <RGB32toRGB444_ROW2X_STRETCH+0x14d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<RGB32toRGB444_ROW2X_STRETCH>:
push   %rbp
push   %rbx
test   %ecx,%ecx
je     1188 <RGB32toRGB444_ROW2X_STRETCH+0x88>
mov    %ecx,%r10d
sar    %r10d
mov    %ecx,%eax
mov    (%r8),%r11d
mov    %r11d,%ebx
shr    $0xc,%ebx
and    $0xf00,%ebx
mov    %r11d,%ebp
shr    $0x8,%ebp
and    $0xf0,%ebp
or     %ebx,%ebp
shr    $0x4,%r11d
and    $0xf,%r11d
or     %ebp,%r11d
add    $0x4,%r8
movzwl (%rdi),%ebp
mov    %r11d,%ebx
xor    %ebp,%ebx
shr    %ebx
and    $0x777,%ebx
and    %r11d,%ebp
add    %ebx,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r11w,(%rdx,%rbx,1)
mov    %bp,(%rsi,%rbx,1)
cmp    $0x1,%eax
je     1188 <RGB32toRGB444_ROW2X_STRETCH+0x88>
add    $0x2,%rbx
add    $0xffffffff,%eax
sub    %r9d,%r10d
jns    1160 <RGB32toRGB444_ROW2X_STRETCH+0x60>
add    %ecx,%r10d
add    %rbx,%rdx
add    %rbx,%rsi
add    %rbx,%rdi
jmp    1112 <RGB32toRGB444_ROW2X_STRETCH+0x12>
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @RGB32toRGB444_ROW2X_STRETCH(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%24 = load i8*, i8** %7
store i8* %24, i8** %13
%25 = load i8*, i8** %8
store i8* %25, i8** %14
%26 = load i8*, i8** %9
store i8* %26, i8** %15
%27 = load i8*, i8** %11
store i8* %27, i8** %16
%28 = load i32, i32* %10
store i32 %28, i32* %17
%29 = load i32, i32* %10
%30 = ashr i32 %29, 1
store i32 %30, i32* %18
%31 = load i32, i32* %12
store i32 %31, i32* %19
%32 = load i32, i32* %17
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %101
34: ; preds = %6
br label %45
35: ; No predecessors!
br label %36
36: ; preds = %96, %35
%37 = load i32, i32* %19
%38 = load i32, i32* %18
%39 = sub nsw i32 %38, %37
store i32 %39, i32* %18
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %81
41: ; preds = %36
%42 = load i32, i32* %10
%43 = load i32, i32* %18
%44 = add nsw i32 %43, %42
store i32 %44, i32* %18
br label %45
45: ; preds = %41, %34
%46 = load i8*, i8** %16
%47 = bitcast i8* %46 to i32*
%48 = load i32, i32* %47
store i32 %48, i32* %22
%49 = load i32, i32* %22
%50 = lshr i32 %49, 16
%51 = and i32 %50, 255
%52 = and i32 %51, 240
%53 = shl i32 %52, 4
%54 = load i32, i32* %22
%55 = lshr i32 %54, 8
%56 = and i32 %55, 255
%57 = and i32 %56, 240
%58 = shl i32 %57, 0
%59 = or i32 %53, %58
%60 = load i32, i32* %22
%61 = lshr i32 %60, 0
%62 = and i32 %61, 255
%63 = and i32 %62, 240
%64 = lshr i32 %63, 4
%65 = or i32 %59, %64
store i32 %65, i32* %20
%66 = load i8*, i8** %16
%67 = getelementptr inbounds i8, i8* %66, i64 4
store i8* %67, i8** %16
%68 = load i8*, i8** %13
%69 = bitcast i8* %68 to i16*
%70 = load i16, i16* %69
%71 = zext i16 %70 to i32
store i32 %71, i32* %23
%72 = load i32, i32* %20
%73 = load i32, i32* %23
%74 = xor i32 %72, %73
%75 = lshr i32 %74, 1
%76 = and i32 %75, 1911
%77 = load i32, i32* %20
%78 = load i32, i32* %23
%79 = and i32 %77, %78
%80 = add i32 %76, %79
store i32 %80, i32* %21
br label %81
81: ; preds = %45, %36
%82 = load i8*, i8** %13
%83 = getelementptr inbounds i8, i8* %82, i64 2
store i8* %83, i8** %13
%84 = load i32, i32* %20
%85 = trunc i32 %84 to i16
%86 = load i8*, i8** %15
%87 = bitcast i8* %86 to i16*
store i16 %85, i16* %87
%88 = load i8*, i8** %15
%89 = getelementptr inbounds i8, i8* %88, i64 2
store i8* %89, i8** %15
%90 = load i32, i32* %21
%91 = trunc i32 %90 to i16
%92 = load i8*, i8** %14
%93 = bitcast i8* %92 to i16*
store i16 %91, i16* %93
%94 = load i8*, i8** %14
%95 = getelementptr inbounds i8, i8* %94, i64 2
store i8* %95, i8** %14
br label %96
96: ; preds = %81
%97 = load i32, i32* %17
%98 = add nsw i32 %97, -1
store i32 %98, i32* %17
%99 = icmp ne i32 %98, 0
br i1 %99, label %36, label %100
100: ; preds = %96
br label %101
101: ; preds = %100, %6
ret void
}

LLVM IR (-O2):
define void @RGB32toRGB444_ROW2X_STRETCH(i8* nocapture %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2, i32 %3, i8* nocapture %4, i32 %5) {
%7 = icmp eq i32 %3, 0
br i1 %7, label %56, label %8
8: ; preds = %6
%9 = ashr i32 %3, 1
br label %15
10: ; preds = %43
%11 = sub nsw i32 %44, %5
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %43
13: ; preds = %10
%14 = add nsw i32 %11, %3
br label %15
15: ; preds = %8, %13
%16 = phi i32 [ %14, %13 ], [ %9, %8 ]
%17 = phi i32 [ %54, %13 ], [ %3, %8 ]
%18 = phi i8* [ %32, %13 ], [ %4, %8 ]
%19 = phi i8* [ %51, %13 ], [ %2, %8 ]
%20 = phi i8* [ %53, %13 ], [ %1, %8 ]
%21 = phi i8* [ %49, %13 ], [ %0, %8 ]
%22 = bitcast i8* %18 to i32*
%23 = load i32, i32* %22
%24 = lshr i32 %23, 12
%25 = and i32 %24, 3840
%26 = lshr i32 %23, 8
%27 = and i32 %26, 240
%28 = or i32 %25, %27
%29 = lshr i32 %23, 4
%30 = and i32 %29, 15
%31 = or i32 %28, %30
%32 = getelementptr inbounds i8, i8* %18, i64 4
%33 = bitcast i8* %21 to i16*
%34 = load i16, i16* %33
%35 = zext i16 %34 to i32
%36 = xor i32 %31, %35
%37 = lshr i32 %36, 1
%38 = and i32 %37, 1911
%39 = and i32 %31, %35
%40 = add nuw nsw i32 %38, %39
%41 = trunc i32 %31 to i16
%42 = trunc i32 %40 to i16
br label %43
43: ; preds = %15, %10
%44 = phi i32 [ %16, %15 ], [ %11, %10 ]
%45 = phi i32 [ %17, %15 ], [ %54, %10 ]
%46 = phi i8* [ %19, %15 ], [ %51, %10 ]
%47 = phi i8* [ %20, %15 ], [ %53, %10 ]
%48 = phi i8* [ %21, %15 ], [ %49, %10 ]
%49 = getelementptr inbounds i8, i8* %48, i64 2
%50 = bitcast i8* %46 to i16*
store i16 %41, i16* %50
%51 = getelementptr inbounds i8, i8* %46, i64 2
%52 = bitcast i8* %47 to i16*
store i16 %42, i16* %52
%53 = getelementptr inbounds i8, i8* %47, i64 2
%54 = add nsw i32 %45, -1
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %10
56: ; preds = %43, %6
ret void
}