void MD5_String2binary(const char *string, char *output) {
  unsigned char padding_message[64];
  unsigned char *pstring;
  unsigned int string_byte_len, string_bit_len, copy_len, msg_digest[4];
  unsigned int *A = &msg_digest[0], *B = &msg_digest[1], *C = &msg_digest[2],
               *D = &msg_digest[3];
  int i;
  *A = 0x67452301;
  *B = 0xefcdab89;
  *C = 0x98badcfe;
  *D = 0x10325476;
  string_byte_len = strlen(string);
  pstring = (unsigned char *)string;
  for (i = string_byte_len; 64 <= i; i -= 64, pstring += 64)
    MD5_Round_Calculate(pstring, A, B, C, D);
  copy_len = string_byte_len % 64;
  strncpy((char *)padding_message, (char *)pstring, copy_len);
  memset(padding_message + copy_len, 0, 64 - copy_len);
  padding_message[copy_len] |= 0x80;
  if (56 <= copy_len) {
    MD5_Round_Calculate(padding_message, A, B, C, D);
    memset(padding_message, 0, 56);
  }
  string_bit_len = string_byte_len * 8;
  memcpy(&padding_message[56], &string_bit_len, 4);
  if (4294967295U / 8 < string_byte_len) {
    unsigned int high = (string_byte_len - 4294967295U / 8) * 8;
    memcpy(&padding_message[60], &high, 4);
  } else
    memset(&padding_message[60], 0, 4);
  MD5_Round_Calculate(padding_message, A, B, C, D);
  memcpy(output, msg_digest, 16);
}


x86 assembly (clang, -O0):
<MD5_String2binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x80(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x90(%rbp)
lea    -0x80(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x98(%rbp)
lea    -0x80(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0xa0(%rbp)
mov    -0x88(%rbp),%rax
movl   $0x67452301,(%rax)
mov    -0x90(%rbp),%rax
movl   $0xefcdab89,(%rax)
mov    -0x98(%rbp),%rax
movl   $0x98badcfe,(%rax)
mov    -0xa0(%rbp),%rax
movl   $0x10325476,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    $0x40,%eax
cmp    -0xa4(%rbp),%eax
jg     1234 <MD5_String2binary+0xf4>
mov    -0x58(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x90(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    -0xa0(%rbp),%r8
mov    $0x0,%al
call   1060 <MD5_Round_Calculate@plt>
mov    -0xa4(%rbp),%eax
sub    $0x40,%eax
mov    %eax,-0xa4(%rbp)
mov    -0x58(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x58(%rbp)
jmp    11dc <MD5_String2binary+0x9c>
mov    -0x5c(%rbp),%eax
and    $0x3f,%eax
mov    %eax,-0x64(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x64(%rbp),%eax
mov    %eax,%edx
call   1030 <strncpy@plt>
lea    -0x50(%rbp),%rdi
mov    -0x64(%rbp),%eax
add    %rax,%rdi
mov    $0x40,%eax
sub    -0x64(%rbp),%eax
mov    %eax,%eax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x64(%rbp),%eax
movzbl -0x50(%rbp,%rax,1),%ecx
or     $0x80,%ecx
mov    %cl,-0x50(%rbp,%rax,1)
mov    $0x38,%eax
cmp    -0x64(%rbp),%eax
ja     12c3 <MD5_String2binary+0x183>
lea    -0x50(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x90(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    -0xa0(%rbp),%r8
mov    $0x0,%al
call   1060 <MD5_Round_Calculate@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    -0x5c(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x1fffffff,%eax
cmp    -0x5c(%rbp),%eax
jae    12ff <MD5_String2binary+0x1bf>
mov    -0x5c(%rbp),%eax
sub    $0x1fffffff,%eax
shl    $0x3,%eax
mov    %eax,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1313 <MD5_String2binary+0x1d3>
lea    -0x50(%rbp),%rdi
add    $0x3c,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    -0x50(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x90(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    -0xa0(%rbp),%r8
mov    $0x0,%al
call   1060 <MD5_Round_Calculate@plt>
mov    -0x10(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x78(%rbp),%rcx
mov    %rcx,0x8(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MD5_String2binary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,0x18(%rsp)
mov    %rdi,%rbp
lea    0x4(%rsp),%r13
lea    0x8(%rsp),%r15
lea    0xc(%rsp),%r12
movaps 0xe94(%rip),%xmm0
movaps %xmm0,(%rsp)
call   1040 <strlen@plt>
cmp    $0x40,%eax
mov    %rax,0x10(%rsp)
jl     11b2 <MD5_String2binary+0x72>
lea    0x40(%rax),%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1060 <MD5_Round_Calculate@plt>
add    $0x40,%rbp
add    $0xffffffc0,%ebx
cmp    $0x7f,%ebx
ja     1190 <MD5_String2binary+0x50>
mov    0x10(%rsp),%r14
mov    %r14d,%ebx
and    $0x3f,%ebx
lea    0x20(%rsp),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1030 <strncpy@plt>
lea    (%rsp,%rbx,1),%rdi
add    $0x20,%rdi
mov    $0x40,%edx
sub    %ebx,%edx
xor    %ebp,%ebp
xor    %esi,%esi
call   1050 <memset@plt>
orb    $0x80,0x20(%rsp,%rbx,1)
cmp    $0x38,%ebx
jb     1222 <MD5_String2binary+0xe2>
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1060 <MD5_Round_Calculate@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movq   $0x0,0x50(%rsp)
lea    0x0(,%r14,8),%eax
mov    %eax,0x58(%rsp)
cmp    $0x20000000,%r14d
lea    0x8(,%r14,8),%eax
cmovb  %ebp,%eax
mov    %eax,0x5c(%rsp)
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1060 <MD5_Round_Calculate@plt>
movaps (%rsp),%xmm0
mov    0x18(%rsp),%rax
movups %xmm0,(%rax)
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @MD5_String2binary(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [64 x i8]
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [4 x i32]
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %10, i64 0, i64 0
store i32* %17, i32** %11
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %10, i64 0, i64 1
store i32* %18, i32** %12
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %10, i64 0, i64 2
store i32* %19, i32** %13
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %10, i64 0, i64 3
store i32* %20, i32** %14
%21 = load i32*, i32** %11
store i32 1732584193, i32* %21
%22 = load i32*, i32** %12
store i32 -271733879, i32* %22
%23 = load i32*, i32** %13
store i32 -1732584194, i32* %23
%24 = load i32*, i32** %14
store i32 271733878, i32* %24
%25 = load i8*, i8** %3
%26 = call i64 @strlen(i8* %25)
%27 = trunc i64 %26 to i32
store i32 %27, i32* %7
%28 = load i8*, i8** %3
store i8* %28, i8** %6
%29 = load i32, i32* %7
store i32 %29, i32* %15
br label %30
30: ; preds = %40, %2
%31 = load i32, i32* %15
%32 = icmp sle i32 64, %31
br i1 %32, label %33, label %45
33: ; preds = %30
%34 = load i8*, i8** %6
%35 = load i32*, i32** %11
%36 = load i32*, i32** %12
%37 = load i32*, i32** %13
%38 = load i32*, i32** %14
%39 = call i32 (i8*, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @MD5_Round_Calculate to i32 (i8*, i32*, i32*, i32*, i32*, ...)*)(i8* %34, i32* %35, i32* %36, i32* %37, i32* %38)
br label %40
40: ; preds = %33
%41 = load i32, i32* %15
%42 = sub nsw i32 %41, 64
store i32 %42, i32* %15
%43 = load i8*, i8** %6
%44 = getelementptr inbounds i8, i8* %43, i64 64
store i8* %44, i8** %6
br label %30
45: ; preds = %30
%46 = load i32, i32* %7
%47 = urem i32 %46, 64
store i32 %47, i32* %9
%48 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%49 = load i8*, i8** %6
%50 = load i32, i32* %9
%51 = zext i32 %50 to i64
%52 = call i8* @strncpy(i8* %48, i8* %49, i64 %51)
%53 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%54 = load i32, i32* %9
%55 = zext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i32, i32* %9
%58 = sub i32 64, %57
%59 = zext i32 %58 to i64
%60 = load i32, i32* %9
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = or i32 %64, 128
%66 = trunc i32 %65 to i8
store i8 %66, i8* %62
%67 = load i32, i32* %9
%68 = icmp ule i32 56, %67
br i1 %68, label %69, label %77
69: ; preds = %45
%70 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%71 = load i32*, i32** %11
%72 = load i32*, i32** %12
%73 = load i32*, i32** %13
%74 = load i32*, i32** %14
%75 = call i32 (i8*, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @MD5_Round_Calculate to i32 (i8*, i32*, i32*, i32*, i32*, ...)*)(i8* %70, i32* %71, i32* %72, i32* %73, i32* %74)
%76 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
br label %77
77: ; preds = %69, %45
%78 = load i32, i32* %7
%79 = mul i32 %78, 8
store i32 %79, i32* %8
%80 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 56
%81 = bitcast i32* %8 to i8*
%82 = load i32, i32* %7
%83 = icmp ult i32 536870911, %82
br i1 %83, label %84, label %90
84: ; preds = %77
%85 = load i32, i32* %7
%86 = sub i32 %85, 536870911
%87 = mul i32 %86, 8
store i32 %87, i32* %16
%88 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 60
%89 = bitcast i32* %16 to i8*
br label %92
90: ; preds = %77
%91 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 60
br label %92
92: ; preds = %90, %84
%93 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%94 = load i32*, i32** %11
%95 = load i32*, i32** %12
%96 = load i32*, i32** %13
%97 = load i32*, i32** %14
%98 = call i32 (i8*, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @MD5_Round_Calculate to i32 (i8*, i32*, i32*, i32*, i32*, ...)*)(i8* %93, i32* %94, i32* %95, i32* %96, i32* %97)
%99 = load i8*, i8** %4
%100 = getelementptr inbounds [4 x i32], [4 x i32]* %10, i64 0, i64 0
%101 = bitcast i32* %100 to i8*
ret void
}

LLVM IR (-O2):
define void @MD5_String2binary(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca [64 x i8]
%4 = alloca <4 x i32>
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = bitcast <4 x i32>* %4 to i8*
%7 = getelementptr inbounds <4 x i32>, <4 x i32>* %4, i64 0, i64 0
%8 = getelementptr inbounds <4 x i32>, <4 x i32>* %4, i64 0, i64 1
%9 = getelementptr inbounds <4 x i32>, <4 x i32>* %4, i64 0, i64 2
%10 = getelementptr inbounds <4 x i32>, <4 x i32>* %4, i64 0, i64 3
store <4 x i32> <i32 1732584193, i32 -271733879, i32 -1732584194, i32 271733878>, <4 x i32>* %4
%11 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%12 = trunc i64 %11 to i32
%13 = icmp sgt i32 %12, 63
br i1 %13, label %14, label %21
14: ; preds = %2, %14
%15 = phi i8* [ %19, %14 ], [ %0, %2 ]
%16 = phi i32 [ %18, %14 ], [ %12, %2 ]
%17 = call i32 (i8*, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @MD5_Round_Calculate to i32 (i8*, i32*, i32*, i32*, i32*, ...)*)(i8* %15, i32* %7, i32* %8, i32* %9, i32* %10)
%18 = add nsw i32 %16, -64
%19 = getelementptr inbounds i8, i8* %15, i64 64
%20 = icmp ugt i32 %16, 127
br i1 %20, label %14, label %21
21: ; preds = %14, %2
%22 = phi i8* [ %0, %2 ], [ %19, %14 ]
%23 = and i32 %12, 63
%24 = zext i32 %23 to i64
%25 = call i8* @strncpy(i8* %5, i8* %22, i64 %24)
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %24
%27 = sub nuw nsw i32 64, %23
%28 = zext i32 %27 to i64
%29 = load i8, i8* %26
%30 = or i8 %29, -128
store i8 %30, i8* %26
%31 = icmp ugt i32 %23, 55
br i1 %31, label %32, label %34
32: ; preds = %21
%33 = call i32 (i8*, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @MD5_Round_Calculate to i32 (i8*, i32*, i32*, i32*, i32*, ...)*)(i8* %5, i32* %7, i32* %8, i32* %9, i32* %10)
br label %34
34: ; preds = %32, %21
%35 = shl i32 %12, 3
%36 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 56
%37 = bitcast i8* %36 to i32*
store i32 %35, i32* %37
%38 = icmp ugt i32 %12, 536870911
%39 = add i32 %35, 8
%40 = select i1 %38, i32 %39, i32 0
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 60
%42 = bitcast i8* %41 to i32*
store i32 %40, i32* %42
%43 = call i32 (i8*, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @MD5_Round_Calculate to i32 (i8*, i32*, i32*, i32*, i32*, ...)*)(i8* %5, i32* %7, i32* %8, i32* %9, i32* %10)
ret void
}