void compress016(unsigned char *out, unsigned char *in) {
  int times;
  int i, j;
  for (i = 0; i < 16; i++) {
    times = 0x8;
    in[i] = '0';
    for (j = 0; j < 4; j++) {
      in[i] += (*out++) * times;
      times /= 2;
    }
  }
}


x86 assembly (clang, -O0):
<compress016>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jge    1197 <compress016+0x97>
movl   $0x8,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1184 <compress016+0x84>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%esi
imul   -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
add    %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <compress016+0x37>
jmp    1189 <compress016+0x89>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1113 <compress016+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<compress016>:
lea    0x40(%rdi),%rax
cmp    %rsi,%rax
jbe    115c <compress016+0x5c>
lea    0x10(%rsi),%rax
cmp    %rdi,%rax
jbe    115c <compress016+0x5c>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x30,(%rsi,%rax,1)
movzbl (%rdi,%rax,4),%ecx
shl    $0x3,%cl
add    $0x30,%cl
mov    %cl,(%rsi,%rax,1)
movzbl 0x1(%rdi,%rax,4),%edx
shl    $0x2,%dl
add    %cl,%dl
mov    %dl,(%rsi,%rax,1)
movzbl 0x2(%rdi,%rax,4),%ecx
add    %cl,%cl
add    %dl,%cl
mov    %cl,(%rsi,%rax,1)
add    0x3(%rdi,%rax,4),%cl
mov    %cl,(%rsi,%rax,1)
add    $0x1,%rax
cmp    $0x10,%rax
jne    1120 <compress016+0x20>
ret
movaps 0xe9d(%rip),%xmm0
movups %xmm0,(%rsi)
movdqu (%rdi),%xmm15
movdqu 0x10(%rdi),%xmm13
movdqu 0x20(%rdi),%xmm7
movdqu 0x30(%rdi),%xmm5
movdqa 0xe8d(%rip),%xmm1
movdqa %xmm5,%xmm0
pand   %xmm1,%xmm0
movdqa %xmm7,%xmm4
pand   %xmm1,%xmm4
packuswb %xmm0,%xmm4
movdqa %xmm13,%xmm0
pand   %xmm1,%xmm0
pand   %xmm15,%xmm1
packuswb %xmm0,%xmm1
packuswb %xmm4,%xmm1
pxor   %xmm4,%xmm4
movdqa %xmm5,%xmm0
punpckhbw %xmm4,%xmm0
movdqa %xmm0,-0x18(%rsp)
pshufd $0xe8,%xmm0,%xmm0
pshuflw $0xd4,%xmm0,%xmm0
movdqa %xmm5,%xmm10
punpcklbw %xmm4,%xmm10
pshufd $0xe8,%xmm10,%xmm6
pshuflw $0xd4,%xmm6,%xmm6
punpckldq %xmm0,%xmm6
movdqa %xmm7,%xmm11
punpckhbw %xmm4,%xmm11
pshufd $0xe8,%xmm11,%xmm0
pshuflw $0xed,%xmm0,%xmm0
movdqa %xmm7,%xmm12
punpcklbw %xmm4,%xmm12
pshufd $0xe8,%xmm12,%xmm2
pshuflw $0xed,%xmm2,%xmm2
punpckldq %xmm0,%xmm2
packuswb %xmm6,%xmm2
movdqa %xmm13,%xmm9
punpckhbw %xmm4,%xmm9
pshufd $0xe8,%xmm9,%xmm0
pshuflw $0xd4,%xmm0,%xmm8
movdqa %xmm13,%xmm14
punpcklbw %xmm4,%xmm14
pshufd $0xe8,%xmm14,%xmm6
pshuflw $0xd4,%xmm6,%xmm0
punpckldq %xmm8,%xmm0
movdqa %xmm15,%xmm8
punpckhbw %xmm4,%xmm8
movdqa %xmm15,%xmm6
punpcklbw %xmm4,%xmm6
pshufd $0xe8,%xmm8,%xmm4
pshuflw $0xed,%xmm4,%xmm3
pshufd $0xe8,%xmm6,%xmm4
pshuflw $0xed,%xmm4,%xmm4
punpckldq %xmm3,%xmm4
packuswb %xmm0,%xmm4
shufps $0xcc,%xmm2,%xmm4
movdqa 0xda0(%rip),%xmm0
pand   %xmm0,%xmm5
pshuflw $0xe7,%xmm5,%xmm2
pshufhw $0xe7,%xmm2,%xmm2
pshufd $0x24,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
pand   %xmm0,%xmm7
pshuflw $0xe7,%xmm7,%xmm3
pshufhw $0xe7,%xmm3,%xmm3
pshufd $0xe8,%xmm3,%xmm3
pshuflw $0xb1,%xmm3,%xmm3
packuswb %xmm2,%xmm3
pand   %xmm0,%xmm13
pand   %xmm0,%xmm15
pshuflw $0xe7,%xmm13,%xmm0
pshufhw $0xe7,%xmm0,%xmm0
pshufd $0x24,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
pshuflw $0xe7,%xmm15,%xmm2
pshufhw $0xe7,%xmm2,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pshuflw $0xb1,%xmm2,%xmm2
packuswb %xmm0,%xmm2
shufps $0xcc,%xmm3,%xmm2
pshufd $0xe7,-0x18(%rsp),%xmm0
pshuflw $0x74,%xmm0,%xmm0
pshufd $0xe7,%xmm10,%xmm3
pshuflw $0x74,%xmm3,%xmm3
punpckldq %xmm0,%xmm3
pshufd $0xe7,%xmm11,%xmm0
pshuflw $0xe7,%xmm0,%xmm0
pshufd $0xe7,%xmm12,%xmm5
pshuflw $0xe7,%xmm5,%xmm5
punpckldq %xmm0,%xmm5
packuswb %xmm3,%xmm5
pshufd $0xe7,%xmm9,%xmm0
pshuflw $0x74,%xmm0,%xmm0
pshufd $0xe7,%xmm14,%xmm3
pshuflw $0x74,%xmm3,%xmm3
punpckldq %xmm0,%xmm3
pshufd $0xe7,%xmm8,%xmm0
pshuflw $0xe7,%xmm0,%xmm0
pshufd $0xe7,%xmm6,%xmm6
pshuflw $0xe7,%xmm6,%xmm6
punpckldq %xmm0,%xmm6
packuswb %xmm3,%xmm6
shufps $0xcc,%xmm5,%xmm6
psllw  $0x3,%xmm1
pand   0xcbf(%rip),%xmm1
paddb  %xmm2,%xmm2
paddb  %xmm1,%xmm2
paddb  %xmm6,%xmm2
paddb  0xc7b(%rip),%xmm2
psllw  $0x2,%xmm4
pand   0xcae(%rip),%xmm4
paddb  %xmm4,%xmm2
movdqu %xmm2,(%rsi)
ret

LLVM IR (-O0):
define void @compress016(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
br label %8
8: ; preds = %40, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %43
11: ; preds = %8
store i32 8, i32* %5
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 48, i8* %15
store i32 0, i32* %7
br label %16
16: ; preds = %36, %11
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 4
br i1 %18, label %19, label %39
19: ; preds = %16
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
%22 = load i8, i8* %20
%23 = zext i8 %22 to i32
%24 = load i32, i32* %5
%25 = mul nsw i32 %23, %24
%26 = load i8*, i8** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = add nsw i32 %31, %25
%33 = trunc i32 %32 to i8
store i8 %33, i8* %29
%34 = load i32, i32* %5
%35 = sdiv i32 %34, 2
store i32 %35, i32* %5
br label %36
36: ; preds = %19
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %16
39: ; preds = %16
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %8
43: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @compress016(i8* nocapture %0, i8* nocapture %1) {
%3 = getelementptr i8, i8* %1, i64 16
%4 = getelementptr i8, i8* %0, i64 64
%5 = icmp ugt i8* %4, %1
%6 = icmp ugt i8* %3, %0
%7 = and i1 %5, %6
br i1 %7, label %24, label %8
8: ; preds = %2
%9 = bitcast i8* %1 to <16 x i8>*
store <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8>* %9
%10 = bitcast i8* %0 to <64 x i8>*
%11 = load <64 x i8>, <64 x i8>* %10
%12 = shufflevector <64 x i8> %11, <64 x i8> poison, <16 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28, i32 32, i32 36, i32 40, i32 44, i32 48, i32 52, i32 56, i32 60>
%13 = shufflevector <64 x i8> %11, <64 x i8> poison, <16 x i32> <i32 1, i32 5, i32 9, i32 13, i32 17, i32 21, i32 25, i32 29, i32 33, i32 37, i32 41, i32 45, i32 49, i32 53, i32 57, i32 61>
%14 = shufflevector <64 x i8> %11, <64 x i8> poison, <16 x i32> <i32 2, i32 6, i32 10, i32 14, i32 18, i32 22, i32 26, i32 30, i32 34, i32 38, i32 42, i32 46, i32 50, i32 54, i32 58, i32 62>
%15 = shufflevector <64 x i8> %11, <64 x i8> poison, <16 x i32> <i32 3, i32 7, i32 11, i32 15, i32 19, i32 23, i32 27, i32 31, i32 35, i32 39, i32 43, i32 47, i32 51, i32 55, i32 59, i32 63>
%16 = shl <16 x i8> %12, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
%17 = add <16 x i8> %16, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%18 = shl <16 x i8> %13, <i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2>
%19 = add <16 x i8> %18, %17
%20 = shl <16 x i8> %14, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%21 = add <16 x i8> %20, %19
%22 = add <16 x i8> %15, %21
%23 = bitcast i8* %1 to <16 x i8>*
store <16 x i8> %22, <16 x i8>* %23
br label %45
24: ; preds = %2, %24
%25 = phi i64 [ %43, %24 ], [ 0, %2 ]
%26 = phi i8* [ %40, %24 ], [ %0, %2 ]
%27 = getelementptr inbounds i8, i8* %1, i64 %25
store i8 48, i8* %27
%28 = getelementptr inbounds i8, i8* %26, i64 1
%29 = load i8, i8* %26
%30 = shl i8 %29, 3
%31 = add i8 %30, 48
store i8 %31, i8* %27
%32 = getelementptr inbounds i8, i8* %26, i64 2
%33 = load i8, i8* %28
%34 = shl i8 %33, 2
%35 = add i8 %34, %31
store i8 %35, i8* %27
%36 = getelementptr inbounds i8, i8* %26, i64 3
%37 = load i8, i8* %32
%38 = shl i8 %37, 1
%39 = add i8 %38, %35
store i8 %39, i8* %27
%40 = getelementptr inbounds i8, i8* %26, i64 4
%41 = load i8, i8* %36
%42 = add i8 %41, %39
store i8 %42, i8* %27
%43 = add nuw nsw i64 %25, 1
%44 = icmp eq i64 %43, 16
br i1 %44, label %45, label %24
45: ; preds = %24, %8
ret void
}