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

/* Variables and functions */
int /*<<< orphan*/ md5_signature(unsigned char *, unsigned long,
                                 unsigned char *);
uint32_t hash_md5(const char *key, size_t key_length) {
  unsigned char results[16];
  md5_signature((unsigned char *)key, (unsigned long)key_length, results);
  return ((uint32_t)(results[3] & 0xFF) << 24) |
         ((uint32_t)(results[2] & 0xFF) << 16) |
         ((uint32_t)(results[1] & 0xFF) << 8) | (results[0] & 0xFF);
}


x86 assembly (clang, -O0):
<hash_md5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <md5_signature@plt>
movzbl -0x1d(%rbp),%eax
and    $0xff,%eax
shl    $0x18,%eax
movzbl -0x1e(%rbp),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
movzbl -0x1f(%rbp),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl -0x20(%rbp),%ecx
and    $0xff,%ecx
or     %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_md5>:
sub    $0x18,%rsp
mov    %rsp,%rdx
call   1030 <md5_signature@plt>
mov    (%rsp),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @hash_md5(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [16 x i8]
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i8*, i8** %3
%7 = load i64, i64* %4
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%9 = call i32 @md5_signature(i8* %6, i64 %7, i8* %8)
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 3
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = and i32 %12, 255
%14 = shl i32 %13, 24
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 2
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = and i32 %17, 255
%19 = shl i32 %18, 16
%20 = or i32 %14, %19
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 1
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = and i32 %23, 255
%25 = shl i32 %24, 8
%26 = or i32 %20, %25
%27 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = and i32 %29, 255
%31 = or i32 %26, %30
ret i32 %31
}

LLVM IR (-O2):
define i32 @hash_md5(i8* %0, i64 %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = call i32 @md5_signature(i8* %0, i64 %1, i8* %4)
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 3
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = shl nuw i32 %8, 24
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 2
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = shl nuw nsw i32 %12, 16
%14 = or i32 %13, %9
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = shl nuw nsw i32 %17, 8
%19 = or i32 %14, %18
%20 = load i8, i8* %4
%21 = zext i8 %20 to i32
%22 = or i32 %19, %21
ret i32 %22
}