#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 uint32_t;

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


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    $0x67452301,%edi
call   1050 <UINT32_C@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    $0xefcdab89,%edi
call   1050 <UINT32_C@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    $0x98badcfe,%edi
call   1050 <UINT32_C@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    $0x10325476,%edi
call   1050 <UINT32_C@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x40,%eax
cmp    -0xc(%rbp),%eax
jg     11da <md5_hash+0x9a>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1060 <md5_compress@plt>
mov    -0x1c(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a5 <md5_hash+0x65>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x1c(%rbp),%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     1252 <md5_hash+0x112>
mov    -0x68(%rbp),%rdi
movslq -0x6c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    $0x38,%edx
sub    -0x6c(%rbp),%edx
xor    %esi,%esi
call   1030 <memset@plt>
jmp    128d <md5_hash+0x14d>
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),%rsi
call   1060 <md5_compress@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1030 <memset@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),%rsi
call   1060 <md5_compress@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5_hash>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rdx,%r14
mov    %esi,%r12d
mov    %rdi,%r15
mov    $0x67452301,%edi
call   1050 <UINT32_C@plt>
mov    %eax,(%r14)
mov    $0xefcdab89,%edi
call   1050 <UINT32_C@plt>
mov    %eax,0x4(%r14)
mov    $0x98badcfe,%edi
call   1050 <UINT32_C@plt>
mov    %eax,0x8(%r14)
mov    $0x10325476,%edi
call   1050 <UINT32_C@plt>
mov    %eax,0xc(%r14)
xor    %eax,%eax
cmp    $0x40,%r12d
jl     11bf <md5_hash+0x7f>
xor    %ebx,%ebx
mov    %r15,%rbp
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <md5_compress@plt>
add    $0x100,%rbp
lea    0x40(%rbx),%eax
sub    $0xffffff80,%ebx
cmp    %r12d,%ebx
mov    %eax,%ebx
jle    11a0 <md5_hash+0x60>
mov    %r12d,%ebp
sub    %eax,%ebp
mov    %eax,%eax
lea    (%r15,%rax,4),%rsi
mov    %rsp,%rdi
mov    %ebp,%edx
call   1040 <memcpy@plt>
movslq %ebp,%rax
movl   $0x80,(%rsp,%rax,4)
mov    $0x3f,%edx
sub    %eax,%edx
lea    (%rsp,%rax,4),%rdi
add    $0x4,%rdi
cmp    $0x8,%edx
jl     11fd <md5_hash+0xbd>
mov    $0x37,%edx
sub    %ebp,%edx
xor    %esi,%esi
jmp    121c <md5_hash+0xdc>
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rsp,%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <md5_compress@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1030 <memset@plt>
lea    0x0(,%r12,8),%eax
mov    %eax,0x38(%rsp)
sar    $0x1d,%r12d
mov    %r12d,0x3c(%rsp)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1060 <md5_compress@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r12
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 i32
%8 = alloca [16 x i32]
%9 = alloca i32*
%10 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%11 = call i32 @UINT32_C(i32 1732584193)
%12 = load i32*, i32** %6
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32 %11, i32* %13
%14 = call i32 @UINT32_C(i32 -271733879)
%15 = load i32*, i32** %6
%16 = getelementptr inbounds i32, i32* %15, i64 1
store i32 %14, i32* %16
%17 = call i32 @UINT32_C(i32 -1732584194)
%18 = load i32*, i32** %6
%19 = getelementptr inbounds i32, i32* %18, i64 2
store i32 %17, i32* %19
%20 = call i32 @UINT32_C(i32 271733878)
%21 = load i32*, i32** %6
%22 = getelementptr inbounds i32, i32* %21, i64 3
store i32 %20, i32* %22
store i32 0, i32* %7
br label %23
23: ; preds = %35, %3
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 64
%26 = load i32, i32* %5
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %38
28: ; preds = %23
%29 = load i32*, i32** %6
%30 = load i32*, i32** %4
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = call i32 @md5_compress(i32* %29, i32* %33)
br label %35
35: ; preds = %28
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 64
store i32 %37, i32* %7
br label %23
38: ; preds = %23
%39 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
store i32* %39, i32** %9
%40 = load i32, i32* %5
%41 = load i32, i32* %7
%42 = sub nsw i32 %40, %41
store i32 %42, i32* %10
%43 = load i32*, i32** %9
%44 = load i32*, i32** %4
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = load i32, i32* %10
%49 = call i32 @memcpy(i32* %43, i32* %47, i32 %48)
%50 = load i32*, i32** %9
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
store i32 128, i32* %53
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
%56 = load i32, i32* %10
%57 = sub nsw i32 64, %56
%58 = icmp sge i32 %57, 8
br i1 %58, label %59, label %67
59: ; preds = %38
%60 = load i32*, i32** %9
%61 = load i32, i32* %10
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
%64 = load i32, i32* %10
%65 = sub nsw i32 56, %64
%66 = call i32 @memset(i32* %63, i32 0, i32 %65)
br label %80
67: ; preds = %38
%68 = load i32*, i32** %9
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %68, i64 %70
%72 = load i32, i32* %10
%73 = sub nsw i32 64, %72
%74 = call i32 @memset(i32* %71, i32 0, i32 %73)
%75 = load i32*, i32** %6
%76 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%77 = call i32 @md5_compress(i32* %75, i32* %76)
%78 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%79 = call i32 @memset(i32* %78, i32 0, i32 56)
br label %80
80: ; preds = %67, %59
%81 = load i32, i32* %5
%82 = shl i32 %81, 3
%83 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 14
store i32 %82, i32* %83
%84 = load i32, i32* %5
%85 = ashr i32 %84, 29
%86 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 15
store i32 %85, i32* %86
%87 = load i32*, i32** %6
%88 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%89 = call i32 @md5_compress(i32* %87, i32* %88)
ret void
}

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