void digestdb_encode(char *text, const unsigned char *bytes) {
  static const char tab[] = "0123456789abcdef";
  const unsigned char *end;
  end = bytes + 16;
  for (; bytes < end; bytes++) {
    unsigned char b;
    b = *bytes;
    *text++ = tab[(b & 0xf0) >> 4];
    *text++ = tab[(b & 0x0f) >> 0];
  }
}


x86 assembly (clang, -O0):
<digestdb_encode>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1192 <digestdb_encode+0x92>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
and    $0xf0,%eax
sar    $0x4,%eax
movslq %eax,%rcx
lea    0xebb(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
movzbl -0x19(%rbp),%eax
and    $0xf,%eax
sar    $0x0,%eax
movslq %eax,%rcx
lea    0xe93(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1118 <digestdb_encode+0x18>
pop    %rbp
ret

x86 assembly (clang, -O2):
<digestdb_encode>:
movzbl (%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
lea    0xeef(%rip),%rax
mov    (%rdx,%rax,1),%dl
mov    %dl,(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x1(%rdi)
movzbl 0x1(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x2(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x3(%rdi)
movzbl 0x2(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x4(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x5(%rdi)
movzbl 0x3(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x6(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x7(%rdi)
movzbl 0x4(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x8(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x9(%rdi)
movzbl 0x5(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0xa(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xb(%rdi)
movzbl 0x6(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0xc(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xd(%rdi)
movzbl 0x7(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0xe(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xf(%rdi)
movzbl 0x8(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x10(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x11(%rdi)
movzbl 0x9(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x12(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x13(%rdi)
movzbl 0xa(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x14(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x15(%rdi)
movzbl 0xb(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x16(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x17(%rdi)
movzbl 0xc(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x18(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x19(%rdi)
movzbl 0xd(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x1a(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x1b(%rdi)
movzbl 0xe(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x1c(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x1d(%rdi)
movzbl 0xf(%rsi),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
mov    (%rdx,%rax,1),%dl
mov    %dl,0x1e(%rdi)
and    $0xf,%ecx
mov    (%rcx,%rax,1),%al
mov    %al,0x1f(%rdi)
ret

LLVM IR (-O0):
@digestdb_encode.tab = internal constant [17 x i8] c"0123456789abcdef\00"
define void @digestdb_encode(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 16
store i8* %8, i8** %5
br label %9
9: ; preds = %34, %2
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = icmp ult i8* %10, %11
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
store i8 %15, i8* %6
%16 = load i8, i8* %6
%17 = zext i8 %16 to i32
%18 = and i32 %17, 240
%19 = ashr i32 %18, 4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
store i8 %22, i8* %23
%25 = load i8, i8* %6
%26 = zext i8 %25 to i32
%27 = and i32 %26, 15
%28 = ashr i32 %27, 0
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
store i8 %31, i8* %32
br label %34
34: ; preds = %13
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
br label %9
37: ; preds = %9
ret void
}

LLVM IR (-O2):
@digestdb_encode.tab = internal unnamed_addr constant [17 x i8] c"0123456789abcdef\00"
define void @digestdb_encode(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = zext i8 %3 to i32
%5 = lshr i32 %4, 4
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %8, i8* %0
%10 = and i32 %4, 15
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %13, i8* %9
%15 = getelementptr inbounds i8, i8* %1, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = lshr i32 %17, 4
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %21, i8* %14
%23 = and i32 %17, 15
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %26, i8* %22
%28 = getelementptr inbounds i8, i8* %1, i64 2
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = lshr i32 %30, 4
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %34, i8* %27
%36 = and i32 %30, 15
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %39, i8* %35
%41 = getelementptr inbounds i8, i8* %1, i64 3
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = lshr i32 %43, 4
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %47, i8* %40
%49 = and i32 %43, 15
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = getelementptr inbounds i8, i8* %0, i64 8
store i8 %52, i8* %48
%54 = getelementptr inbounds i8, i8* %1, i64 4
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = lshr i32 %56, 4
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = getelementptr inbounds i8, i8* %0, i64 9
store i8 %60, i8* %53
%62 = and i32 %56, 15
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = getelementptr inbounds i8, i8* %0, i64 10
store i8 %65, i8* %61
%67 = getelementptr inbounds i8, i8* %1, i64 5
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = lshr i32 %69, 4
%71 = zext i32 %70 to i64
%72 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %71
%73 = load i8, i8* %72
%74 = getelementptr inbounds i8, i8* %0, i64 11
store i8 %73, i8* %66
%75 = and i32 %69, 15
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %76
%78 = load i8, i8* %77
%79 = getelementptr inbounds i8, i8* %0, i64 12
store i8 %78, i8* %74
%80 = getelementptr inbounds i8, i8* %1, i64 6
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = lshr i32 %82, 4
%84 = zext i32 %83 to i64
%85 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %84
%86 = load i8, i8* %85
%87 = getelementptr inbounds i8, i8* %0, i64 13
store i8 %86, i8* %79
%88 = and i32 %82, 15
%89 = zext i32 %88 to i64
%90 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %89
%91 = load i8, i8* %90
%92 = getelementptr inbounds i8, i8* %0, i64 14
store i8 %91, i8* %87
%93 = getelementptr inbounds i8, i8* %1, i64 7
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = lshr i32 %95, 4
%97 = zext i32 %96 to i64
%98 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %97
%99 = load i8, i8* %98
%100 = getelementptr inbounds i8, i8* %0, i64 15
store i8 %99, i8* %92
%101 = and i32 %95, 15
%102 = zext i32 %101 to i64
%103 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %102
%104 = load i8, i8* %103
%105 = getelementptr inbounds i8, i8* %0, i64 16
store i8 %104, i8* %100
%106 = getelementptr inbounds i8, i8* %1, i64 8
%107 = load i8, i8* %106
%108 = zext i8 %107 to i32
%109 = lshr i32 %108, 4
%110 = zext i32 %109 to i64
%111 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %110
%112 = load i8, i8* %111
%113 = getelementptr inbounds i8, i8* %0, i64 17
store i8 %112, i8* %105
%114 = and i32 %108, 15
%115 = zext i32 %114 to i64
%116 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %115
%117 = load i8, i8* %116
%118 = getelementptr inbounds i8, i8* %0, i64 18
store i8 %117, i8* %113
%119 = getelementptr inbounds i8, i8* %1, i64 9
%120 = load i8, i8* %119
%121 = zext i8 %120 to i32
%122 = lshr i32 %121, 4
%123 = zext i32 %122 to i64
%124 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %123
%125 = load i8, i8* %124
%126 = getelementptr inbounds i8, i8* %0, i64 19
store i8 %125, i8* %118
%127 = and i32 %121, 15
%128 = zext i32 %127 to i64
%129 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %128
%130 = load i8, i8* %129
%131 = getelementptr inbounds i8, i8* %0, i64 20
store i8 %130, i8* %126
%132 = getelementptr inbounds i8, i8* %1, i64 10
%133 = load i8, i8* %132
%134 = zext i8 %133 to i32
%135 = lshr i32 %134, 4
%136 = zext i32 %135 to i64
%137 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %136
%138 = load i8, i8* %137
%139 = getelementptr inbounds i8, i8* %0, i64 21
store i8 %138, i8* %131
%140 = and i32 %134, 15
%141 = zext i32 %140 to i64
%142 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %141
%143 = load i8, i8* %142
%144 = getelementptr inbounds i8, i8* %0, i64 22
store i8 %143, i8* %139
%145 = getelementptr inbounds i8, i8* %1, i64 11
%146 = load i8, i8* %145
%147 = zext i8 %146 to i32
%148 = lshr i32 %147, 4
%149 = zext i32 %148 to i64
%150 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %149
%151 = load i8, i8* %150
%152 = getelementptr inbounds i8, i8* %0, i64 23
store i8 %151, i8* %144
%153 = and i32 %147, 15
%154 = zext i32 %153 to i64
%155 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %154
%156 = load i8, i8* %155
%157 = getelementptr inbounds i8, i8* %0, i64 24
store i8 %156, i8* %152
%158 = getelementptr inbounds i8, i8* %1, i64 12
%159 = load i8, i8* %158
%160 = zext i8 %159 to i32
%161 = lshr i32 %160, 4
%162 = zext i32 %161 to i64
%163 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %162
%164 = load i8, i8* %163
%165 = getelementptr inbounds i8, i8* %0, i64 25
store i8 %164, i8* %157
%166 = and i32 %160, 15
%167 = zext i32 %166 to i64
%168 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %167
%169 = load i8, i8* %168
%170 = getelementptr inbounds i8, i8* %0, i64 26
store i8 %169, i8* %165
%171 = getelementptr inbounds i8, i8* %1, i64 13
%172 = load i8, i8* %171
%173 = zext i8 %172 to i32
%174 = lshr i32 %173, 4
%175 = zext i32 %174 to i64
%176 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %175
%177 = load i8, i8* %176
%178 = getelementptr inbounds i8, i8* %0, i64 27
store i8 %177, i8* %170
%179 = and i32 %173, 15
%180 = zext i32 %179 to i64
%181 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %180
%182 = load i8, i8* %181
%183 = getelementptr inbounds i8, i8* %0, i64 28
store i8 %182, i8* %178
%184 = getelementptr inbounds i8, i8* %1, i64 14
%185 = load i8, i8* %184
%186 = zext i8 %185 to i32
%187 = lshr i32 %186, 4
%188 = zext i32 %187 to i64
%189 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %188
%190 = load i8, i8* %189
%191 = getelementptr inbounds i8, i8* %0, i64 29
store i8 %190, i8* %183
%192 = and i32 %186, 15
%193 = zext i32 %192 to i64
%194 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %193
%195 = load i8, i8* %194
%196 = getelementptr inbounds i8, i8* %0, i64 30
store i8 %195, i8* %191
%197 = getelementptr inbounds i8, i8* %1, i64 15
%198 = load i8, i8* %197
%199 = zext i8 %198 to i32
%200 = lshr i32 %199, 4
%201 = zext i32 %200 to i64
%202 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %201
%203 = load i8, i8* %202
%204 = getelementptr inbounds i8, i8* %0, i64 31
store i8 %203, i8* %196
%205 = and i32 %199, 15
%206 = zext i32 %205 to i64
%207 = getelementptr inbounds [17 x i8], [17 x i8]* @digestdb_encode.tab, i64 0, i64 %206
%208 = load i8, i8* %207
store i8 %208, i8* %204
ret void
}