const char *get_md5(unsigned char *binsum) {
  static char buf[33];
  static const char *trans = "0123456789abcdef";
  int i, j;
  for (i = 0, j = 0; i < 16; ++i) {
    buf[j++] = trans[binsum[i] >> 4];
    buf[j++] = trans[binsum[i] & 0xF];
  }
  buf[j] = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<get_md5>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    1196 <get_md5+0x96>
mov    0x2ef9(%rip),%rax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
sar    $0x4,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
movslq %eax,%rcx
lea    0x2eef(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    0x2ec5(%rip),%rax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
movslq %eax,%rcx
lea    0x2ebb(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1116 <get_md5+0x16>
movslq -0x10(%rbp),%rcx
lea    0x2e9f(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e94(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_md5>:
xor    %eax,%eax
lea    0xef7(%rip),%r8
lea    0x2f20(%rip),%rdx
movzbl (%rdi,%rax,1),%esi
shr    $0x4,%rsi
movzbl (%rsi,%r8,1),%ecx
mov    %cl,(%rdx,%rax,2)
movzbl (%rdi,%rax,1),%ecx
and    $0xf,%ecx
movzbl (%rcx,%r8,1),%ecx
mov    %cl,0x1(%rdx,%rax,2)
add    $0x1,%rax
cmp    $0x10,%rax
jne    1110 <get_md5+0x10>
movb   $0x0,0x2f0f(%rip)
lea    0x2ee8(%rip),%rax
ret

LLVM IR (-O0):
@get_md5.buf = internal global [33 x i8] zeroinitializer
@get_md5.trans = internal global i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0)
@.str = [17 x i8] c"0123456789abcdef\00"
define i8* @get_md5(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %39, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 16
br i1 %7, label %8, label %42
8: ; preds = %5
%9 = load i8*, i8** @get_md5.trans
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = ashr i32 %15, 4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %9, i64 %17
%19 = load i8, i8* %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds [33 x i8], [33 x i8]* @get_md5.buf, i64 0, i64 %22
store i8 %19, i8* %23
%24 = load i8*, i8** @get_md5.trans
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = and i32 %30, 15
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %24, i64 %32
%34 = load i8, i8* %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds [33 x i8], [33 x i8]* @get_md5.buf, i64 0, i64 %37
store i8 %34, i8* %38
br label %39
39: ; preds = %8
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %5
42: ; preds = %5
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [33 x i8], [33 x i8]* @get_md5.buf, i64 0, i64 %44
store i8 0, i8* %45
ret i8* getelementptr inbounds ([33 x i8], [33 x i8]* @get_md5.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@get_md5.buf = internal global [33 x i8] zeroinitializer
@.str = [17 x i8] c"0123456789abcdef\00"
define i8* @get_md5(i8* nocapture %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %20, %2 ]
%4 = phi i64 [ 0, %1 ], [ %18, %2 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %3
%6 = load i8, i8* %5
%7 = lshr i8 %6, 4
%8 = zext i8 %7 to i64
%9 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = or i64 %4, 1
%12 = getelementptr inbounds [33 x i8], [33 x i8]* @get_md5.buf, i64 0, i64 %4
store i8 %10, i8* %12
%13 = load i8, i8* %5
%14 = and i8 %13, 15
%15 = zext i8 %14 to i64
%16 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = add nuw nsw i64 %4, 2
%19 = getelementptr inbounds [33 x i8], [33 x i8]* @get_md5.buf, i64 0, i64 %11
store i8 %17, i8* %19
%20 = add nuw nsw i64 %3, 1
%21 = icmp eq i64 %20, 16
br i1 %21, label %22, label %2
22: ; preds = %2
store i8 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @get_md5.buf, i64 0, i64 32)
ret i8* getelementptr inbounds ([33 x i8], [33 x i8]* @get_md5.buf, i64 0, i64 0)
}