#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 const *, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
void md5_hash(const uint8_t *message, uint32_t len, uint32_t hash[4]) {
  hash[0] = UINT32_C(0x67452301);
  hash[1] = UINT32_C(0xEFCDAB89);
  hash[2] = UINT32_C(0x98BADCFE);
  hash[3] = UINT32_C(0x10325476);
  uint32_t i;
  for (i = 0; len - i >= 64; i += 64)
    md5_compress(hash, (uint32_t *)(message + i));
  uint32_t block[16];
  uint8_t *byteBlock = (uint8_t *)block;
  uint32_t 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    -0xc(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    $0x40,%eax
jl     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   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r12
mov    %esi,%r14d
mov    %rdi,%r15
mov    $0x67452301,%edi
call   1050 <UINT32_C@plt>
mov    %eax,(%r12)
mov    $0xefcdab89,%edi
call   1050 <UINT32_C@plt>
mov    %eax,0x4(%r12)
mov    $0x98badcfe,%edi
call   1050 <UINT32_C@plt>
mov    %eax,0x8(%r12)
mov    $0x10325476,%edi
call   1050 <UINT32_C@plt>
mov    %eax,0xc(%r12)
cmp    $0x40,%r14d
jl     11db <md5_hash+0x9b>
mov    %r14d,%ebp
xor    %r13d,%r13d
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <md5_compress@plt>
add    $0x100,%rbx
add    $0xffffffffffffffc0,%r13
lea    0x0(%rbp,%r13,1),%eax
cmp    $0x3f,%eax
jg     11b0 <md5_hash+0x70>
mov    %r13,%rax
neg    %rax
add    %r14d,%r13d
jmp    11e0 <md5_hash+0xa0>
xor    %eax,%eax
mov    %r14d,%r13d
lea    (%r15,%rax,4),%rsi
mov    %rsp,%rdi
mov    %r13d,%edx
call   1040 <memcpy@plt>
movslq %r13d,%rax
movl   $0x80,(%rsp,%rax,4)
mov    $0x3f,%edx
sub    %eax,%edx
lea    (%rsp,%rax,4),%rdi
add    $0x4,%rdi
cmp    $0x8,%edx
jl     1219 <md5_hash+0xd9>
mov    $0x37,%edx
sub    %r13d,%edx
xor    %esi,%esi
jmp    1238 <md5_hash+0xf8>
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rsp,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <md5_compress@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1030 <memset@plt>
lea    0x0(,%r14,8),%eax
mov    %eax,0x38(%rsp)
sar    $0x1d,%r14d
mov    %r14d,0x3c(%rsp)
mov    %rsp,%rsi
mov    %r12,%rdi
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 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* %5
%25 = load i32, i32* %7
%26 = sub nsw i32 %24, %25
%27 = icmp sge i32 %26, 64
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 sgt i32 %1, 63
br i1 %12, label %13, label %23
13: ; preds = %3, %13
%14 = phi i64 [ %17, %13 ], [ 0, %3 ]
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = tail call i32 @md5_compress(i32* %2, i32* %15)
%17 = add nuw nsw i64 %14, 64
%18 = trunc i64 %17 to i32
%19 = sub nsw i32 %1, %18
%20 = icmp sgt i32 %19, 63
br i1 %20, label %13, label %21
21: ; preds = %13
%22 = and i64 %17, 4294967232
br label %23
23: ; preds = %21, %3
%24 = phi i64 [ 0, %3 ], [ %22, %21 ]
%25 = phi i32 [ %1, %3 ], [ %19, %21 ]
%26 = bitcast [16 x i32]* %4 to i8*
%27 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%28 = getelementptr inbounds i32, i32* %0, i64 %24
%29 = call i32 @memcpy(i32* %27, i32* %28, i32 %25)
%30 = sext i32 %25 to i64
%31 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 %30
store i32 128, i32* %31
%32 = add nsw i32 %25, 1
%33 = sub i32 63, %25
%34 = icmp sgt i32 %33, 7
%35 = sext i32 %32 to i64
%36 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 %35
br i1 %34, label %37, label %40
37: ; preds = %23
%38 = sub i32 55, %25
%39 = call i32 @memset(i32* %36, i32 0, i32 %38)
br label %44
40: ; preds = %23
%41 = call i32 @memset(i32* %36, i32 0, i32 %33)
%42 = call i32 @md5_compress(i32* %2, i32* %27)
%43 = call i32 @memset(i32* %27, i32 0, i32 56)
br label %44
44: ; preds = %40, %37
%45 = shl i32 %1, 3
%46 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 14
store i32 %45, i32* %46
%47 = ashr i32 %1, 29
%48 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 15
store i32 %47, i32* %48
%49 = call i32 @md5_compress(i32* %2, i32* %27)
ret void
}