void RGB32toRGB444_ROW2X_SHRINK(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 = src_dx >> 1;
  register int step = dest_dx;
  if (count) {
    do {
      register unsigned int da_rgb;
      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)));
      *(unsigned short *)(d2) = da_rgb;
      d2 += 2;
      register unsigned int sb_rgb;
      sb_rgb = *(unsigned short *)(d1);
      da_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 *)(d12) = da_rgb;
      d12 += 2;
      do {
        s += 4;
      } while ((limit -= step) >= 0);
      limit += src_dx;
    } while (--count);
  }
}


x86 assembly (clang, -O0):
<RGB32toRGB444_ROW2X_SHRINK>:
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    -0x2c(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     124d <RGB32toRGB444_ROW2X_SHRINK+0x14d>
jmp    115f <RGB32toRGB444_ROW2X_SHRINK+0x5f>
mov    -0x50(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
and    $0xf0,%eax
shl    $0x4,%eax
mov    -0x64(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
and    $0xf0,%ecx
shl    $0x0,%ecx
or     %ecx,%eax
mov    -0x64(%rbp),%ecx
shr    $0x0,%ecx
and    $0xff,%ecx
and    $0xf0,%ecx
shr    $0x4,%ecx
or     %ecx,%eax
mov    %eax,-0x60(%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    -0x38(%rbp),%rax
movzwl (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    -0x60(%rbp),%eax
xor    -0x68(%rbp),%eax
shr    $0x1,%eax
and    $0x777,%eax
mov    -0x60(%rbp),%ecx
and    -0x68(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x38(%rbp)
mov    -0x60(%rbp),%eax
mov    %ax,%cx
mov    -0x40(%rbp),%rax
mov    %cx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x40(%rbp)
mov    -0x50(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x50(%rbp)
mov    -0x5c(%rbp),%ecx
mov    -0x58(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x58(%rbp)
cmp    $0x0,%eax
jge    120d <RGB32toRGB444_ROW2X_SHRINK+0x10d>
mov    -0x2c(%rbp),%eax
add    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
jne    115f <RGB32toRGB444_ROW2X_SHRINK+0x5f>
jmp    124d <RGB32toRGB444_ROW2X_SHRINK+0x14d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<RGB32toRGB444_ROW2X_SHRINK>:
push   %rbp
push   %rbx
test   %ecx,%ecx
je     117d <RGB32toRGB444_ROW2X_SHRINK+0x7d>
mov    %r9d,%eax
sar    %eax
mov    %ecx,%r10d
xchg   %ax,%ax
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
mov    %r11w,(%rdx)
movzwl (%rdi),%ebx
mov    %r11d,%ebp
xor    %ebx,%ebp
shr    %ebp
and    $0x777,%ebp
and    %ebx,%r11d
add    %ebp,%r11d
mov    %r11w,(%rsi)
cs nopw 0x0(%rax,%rax,1)
add    $0x4,%r8
sub    %ecx,%eax
jns    1160 <RGB32toRGB444_ROW2X_SHRINK+0x60>
add    $0x2,%rdx
add    $0x2,%rdi
add    $0x2,%rsi
add    %r9d,%eax
add    $0xffffffff,%r10d
jne    1110 <RGB32toRGB444_ROW2X_SHRINK+0x10>
pop    %rbx
pop    %rbp
ret

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

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