#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint8_t;
typedef int uint64_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ bzero(int *, int);
int /*<<< orphan*/ md5_compress(int *, int, int *);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
void md5_hash(uint8_t *message, uint64_t len, uint32_t *hash) {
  hash[0] = 0x67452301;
  hash[1] = 0xEFCDAB89;
  hash[2] = 0x98BADCFE;
  hash[3] = 0x10325476;
  md5_compress(hash, len / 64, message);
  uint32_t blockbuff[16];
  uint8_t *byteptr = (uint8_t *)blockbuff;
  int left = len % 64;
  memcpy(byteptr, message + len - left, left);
  byteptr[left] = 0x80;
  left++;
  if (64 - left >= 8)
    bzero(byteptr + left, 56 - left);
  else {
    memset(byteptr + left, 0, 64 - left);
    md5_compress(hash, 1, blockbuff);
    bzero(blockbuff, 56);
  }
  blockbuff[14] = (uint32_t)(len << 3);
  blockbuff[15] = (uint32_t)(len >> 29);
  md5_compress(hash, 1, blockbuff);
}


x86 assembly (clang, -O0):
<md5_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x67452301,(%rax)
mov    -0x18(%rbp),%rax
movl   $0xefcdab89,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0x98badcfe,0x8(%rax)
mov    -0x18(%rbp),%rax
movl   $0x10325476,0xc(%rax)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%rdx
call   1060 <md5_compress@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %edx,-0x6c(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x6c(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x6c(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x68(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movl   $0x80,(%rax,%rcx,4)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
mov    $0x40,%eax
sub    -0x6c(%rbp),%eax
cmp    $0x8,%eax
jl     1223 <md5_hash+0xe3>
mov    -0x68(%rbp),%rdi
movslq -0x6c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    $0x38,%esi
sub    -0x6c(%rbp),%esi
call   1050 <bzero@plt>
jmp    1261 <md5_hash+0x121>
mov    -0x68(%rbp),%rdi
movslq -0x6c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    $0x40,%edx
sub    -0x6c(%rbp),%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rdx
mov    $0x1,%esi
call   1060 <md5_compress@plt>
lea    -0x60(%rbp),%rdi
mov    $0x38,%esi
call   1050 <bzero@plt>
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x1d,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rdx
mov    $0x1,%esi
call   1060 <md5_compress@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5_hash>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r14
mov    %esi,%r12d
mov    %rdi,%r15
movaps 0xea2(%rip),%xmm0
movups %xmm0,(%rdx)
lea    0x3f(%r12),%ebx
test   %esi,%esi
cmovns %esi,%ebx
mov    %ebx,%esi
sar    $0x6,%esi
mov    %rdx,%rdi
mov    %r15,%rdx
call   1060 <md5_compress@plt>
and    $0xffffffc0,%ebx
mov    %r12d,%ebp
sub    %ebx,%ebp
movslq %r12d,%r13
lea    (%r15,%r13,4),%rsi
movslq %ebp,%r15
lea    0x0(,%r15,4),%rax
sub    %rax,%rsi
mov    %rsp,%rdi
mov    %r15d,%edx
call   1040 <memcpy@plt>
movl   $0x80,(%rsp,%r15,4)
neg    %ebx
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
cmp    $0x37,%r15d
jg     11c9 <md5_hash+0x89>
cltq
lea    (%rsp,%rax,4),%rdi
mov    $0x37,%esi
sub    %ebp,%esi
jmp    11f8 <md5_hash+0xb8>
mov    $0x3f,%edx
sub    %ebp,%edx
mov    %eax,%eax
lea    (%rsp,%rax,4),%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rsp,%rbx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1060 <md5_compress@plt>
mov    %rbx,%rdi
mov    $0x38,%esi
call   1050 <bzero@plt>
lea    0x0(,%r12,8),%eax
mov    %eax,0x38(%rsp)
sar    $0x1d,%r12d
mov    %r12d,0x3c(%rsp)
mov    %rsp,%rdx
mov    %r14,%rdi
mov    $0x1,%esi
call   1060 <md5_compress@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @md5_hash(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca [16 x i32]
%8 = alloca i32*
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%10 = load i32*, i32** %6
%11 = getelementptr inbounds i32, i32* %10, i64 0
store i32 1732584193, i32* %11
%12 = load i32*, i32** %6
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32 -271733879, i32* %13
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i64 2
store i32 -1732584194, i32* %15
%16 = load i32*, i32** %6
%17 = getelementptr inbounds i32, i32* %16, i64 3
store i32 271733878, i32* %17
%18 = load i32*, i32** %6
%19 = load i32, i32* %5
%20 = sdiv i32 %19, 64
%21 = load i32*, i32** %4
%22 = call i32 @md5_compress(i32* %18, i32 %20, i32* %21)
%23 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
store i32* %23, i32** %8
%24 = load i32, i32* %5
%25 = srem i32 %24, 64
store i32 %25, i32* %9
%26 = load i32*, i32** %8
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = sub i64 0, %32
%34 = getelementptr inbounds i32, i32* %30, i64 %33
%35 = load i32, i32* %9
%36 = call i32 @memcpy(i32* %26, i32* %34, i32 %35)
%37 = load i32*, i32** %8
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
store i32 128, i32* %40
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
%43 = load i32, i32* %9
%44 = sub nsw i32 64, %43
%45 = icmp sge i32 %44, 8
br i1 %45, label %46, label %54
46: ; preds = %3
%47 = load i32*, i32** %8
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %47, i64 %49
%51 = load i32, i32* %9
%52 = sub nsw i32 56, %51
%53 = call i32 @bzero(i32* %50, i32 %52)
br label %67
54: ; preds = %3
%55 = load i32*, i32** %8
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
%59 = load i32, i32* %9
%60 = sub nsw i32 64, %59
%61 = call i32 @memset(i32* %58, i32 0, i32 %60)
%62 = load i32*, i32** %6
%63 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%64 = call i32 @md5_compress(i32* %62, i32 1, i32* %63)
%65 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%66 = call i32 @bzero(i32* %65, i32 56)
br label %67
67: ; preds = %54, %46
%68 = load i32, i32* %5
%69 = shl i32 %68, 3
%70 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 14
store i32 %69, i32* %70
%71 = load i32, i32* %5
%72 = ashr i32 %71, 29
%73 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 15
store i32 %72, i32* %73
%74 = load i32*, i32** %6
%75 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%76 = call i32 @md5_compress(i32* %74, i32 1, i32* %75)
ret void
}

LLVM IR (-O2):
define void @md5_hash(i32* %0, i32 %1, i32* %2) {
%4 = alloca [16 x i32]
%5 = bitcast i32* %2 to <4 x i32>*
store <4 x i32> <i32 1732584193, i32 -271733879, i32 -1732584194, i32 271733878>, <4 x i32>* %5
%6 = sdiv i32 %1, 64
%7 = tail call i32 @md5_compress(i32* %2, i32 %6, i32* %0)
%8 = bitcast [16 x i32]* %4 to i8*
%9 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%10 = srem i32 %1, 64
%11 = sext i32 %1 to i64
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = sext i32 %10 to i64
%14 = sub nsw i64 0, %13
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = call i32 @memcpy(i32* %9, i32* %15, i32 %10)
%17 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 %13
store i32 128, i32* %17
%18 = add nsw i32 %10, 1
%19 = icmp slt i32 %10, 56
br i1 %19, label %20, label %25
20: ; preds = %3
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 %21
%23 = sub nsw i32 55, %10
%24 = call i32 @bzero(i32* %22, i32 %23)
br label %32
25: ; preds = %3
%26 = sub nuw nsw i32 63, %10
%27 = zext i32 %18 to i64
%28 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 %27
%29 = call i32 @memset(i32* %28, i32 0, i32 %26)
%30 = call i32 @md5_compress(i32* %2, i32 1, i32* %9)
%31 = call i32 @bzero(i32* %9, i32 56)
br label %32
32: ; preds = %25, %20
%33 = shl i32 %1, 3
%34 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 14
store i32 %33, i32* %34
%35 = ashr i32 %1, 29
%36 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 15
store i32 %35, i32* %36
%37 = call i32 @md5_compress(i32* %2, i32 1, i32* %9)
ret void
}