#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 */

/* Variables and functions */
int /*<<< orphan*/ MD5hash(unsigned char *, void const *, size_t);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned char);
void MD5hex(void *dest, const void *orig, size_t len) {
  unsigned char tmp[16];
  MD5hash(tmp, orig, len);
  for (int i = 0; i < 16; i++) {
    snprintf((char *)dest + (i * 2), 255, "%.2x", tmp[i]);
  }
}


x86 assembly (clang, -O0):
<MD5hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <MD5hash@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x10,-0x34(%rbp)
jge    118d <MD5hex+0x6d>
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
movslq -0x34(%rbp),%rax
mov    $0xff,%esi
lea    0xe8b(%rip),%rdx
movzbl -0x30(%rbp,%rax,1),%ecx
call   1040 <snprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    114c <MD5hex+0x2c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MD5hex>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1030 <MD5hash@plt>
movzbl (%rsp),%ecx
lea    0xec3(%rip),%r14
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x2(%rbx),%rdi
movzbl 0x1(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x4(%rbx),%rdi
movzbl 0x2(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x6(%rbx),%rdi
movzbl 0x3(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x8(%rbx),%rdi
movzbl 0x4(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0xa(%rbx),%rdi
movzbl 0x5(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0xc(%rbx),%rdi
movzbl 0x6(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0xe(%rbx),%rdi
movzbl 0x7(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x10(%rbx),%rdi
movzbl 0x8(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x12(%rbx),%rdi
movzbl 0x9(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x14(%rbx),%rdi
movzbl 0xa(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x16(%rbx),%rdi
movzbl 0xb(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x18(%rbx),%rdi
movzbl 0xc(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x1a(%rbx),%rdi
movzbl 0xd(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
lea    0x1c(%rbx),%rdi
movzbl 0xe(%rsp),%ecx
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
add    $0x1e,%rbx
movzbl 0xf(%rsp),%ecx
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <snprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%.2x\00"
define void @MD5hex(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [16 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = call i32 @MD5hash(i8* %9, i8* %10, i64 %11)
store i32 0, i32* %8
br label %13
13: ; preds = %27, %3
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 16
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = load i32, i32* %8
%19 = mul nsw i32 %18, 2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @snprintf(i8* %21, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %25)
br label %27
27: ; preds = %16
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %13
30: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.2x\00"
define void @MD5hex(i8* %0, i8* %1, i64 %2) {
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = call i32 @MD5hash(i8* %5, i8* %1, i64 %2)
%7 = load i8, i8* %5
%8 = call i32 @snprintf(i8* %0, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %7)
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 1
%11 = load i8, i8* %10
%12 = call i32 @snprintf(i8* %9, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %11)
%13 = getelementptr inbounds i8, i8* %0, i64 4
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 2
%15 = load i8, i8* %14
%16 = call i32 @snprintf(i8* %13, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %15)
%17 = getelementptr inbounds i8, i8* %0, i64 6
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 3
%19 = load i8, i8* %18
%20 = call i32 @snprintf(i8* %17, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %19)
%21 = getelementptr inbounds i8, i8* %0, i64 8
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 4
%23 = load i8, i8* %22
%24 = call i32 @snprintf(i8* %21, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %23)
%25 = getelementptr inbounds i8, i8* %0, i64 10
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 5
%27 = load i8, i8* %26
%28 = call i32 @snprintf(i8* %25, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %27)
%29 = getelementptr inbounds i8, i8* %0, i64 12
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 6
%31 = load i8, i8* %30
%32 = call i32 @snprintf(i8* %29, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %31)
%33 = getelementptr inbounds i8, i8* %0, i64 14
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 7
%35 = load i8, i8* %34
%36 = call i32 @snprintf(i8* %33, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %35)
%37 = getelementptr inbounds i8, i8* %0, i64 16
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 8
%39 = load i8, i8* %38
%40 = call i32 @snprintf(i8* %37, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %39)
%41 = getelementptr inbounds i8, i8* %0, i64 18
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 9
%43 = load i8, i8* %42
%44 = call i32 @snprintf(i8* %41, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %43)
%45 = getelementptr inbounds i8, i8* %0, i64 20
%46 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 10
%47 = load i8, i8* %46
%48 = call i32 @snprintf(i8* %45, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %47)
%49 = getelementptr inbounds i8, i8* %0, i64 22
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 11
%51 = load i8, i8* %50
%52 = call i32 @snprintf(i8* %49, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %51)
%53 = getelementptr inbounds i8, i8* %0, i64 24
%54 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 12
%55 = load i8, i8* %54
%56 = call i32 @snprintf(i8* %53, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %55)
%57 = getelementptr inbounds i8, i8* %0, i64 26
%58 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 13
%59 = load i8, i8* %58
%60 = call i32 @snprintf(i8* %57, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %59)
%61 = getelementptr inbounds i8, i8* %0, i64 28
%62 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 14
%63 = load i8, i8* %62
%64 = call i32 @snprintf(i8* %61, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %63)
%65 = getelementptr inbounds i8, i8* %0, i64 30
%66 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 15
%67 = load i8, i8* %66
%68 = call i32 @snprintf(i8* %65, i32 255, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %67)
ret void
}