#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*/ md5(unsigned char *, int, unsigned char *);
void md5_hex(char *input, int ilen, char output[32]) {
  static char out[16], hcyf[16] = "0123456789abcdef";
  int i;
  md5((unsigned char *)input, ilen, (unsigned char *)out);
  for (i = 0; i < 16; i++) {
    output[2 * i] = hcyf[(out[i] >> 4) & 15];
    output[2 * i + 1] = hcyf[out[i] & 15];
  }
}


x86 assembly (clang, -O0):
<md5_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0x2f1f(%rip),%rdx
call   1030 <md5@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11b9 <md5_hex+0xa9>
movslq -0x1c(%rbp),%rcx
lea    0x2efe(%rip),%rax
movsbl (%rax,%rcx,1),%eax
sar    $0x4,%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0x2eca(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
movslq -0x1c(%rbp),%rcx
lea    0x2ecc(%rip),%rax
movsbl (%rax,%rcx,1),%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0x2e9b(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113d <md5_hex+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5_hex>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
lea    0x2f22(%rip),%r14
mov    %r14,%rdx
call   1030 <md5@plt>
xor    %eax,%eax
lea    0xed1(%rip),%rcx
nop
movzbl (%rax,%r14,1),%edx
shr    $0x4,%rdx
movzbl (%rdx,%rcx,1),%edx
mov    %dl,(%rbx,%rax,2)
movzbl (%rax,%r14,1),%edx
and    $0xf,%edx
movzbl (%rdx,%rcx,1),%edx
mov    %dl,0x1(%rbx,%rax,2)
add    $0x1,%rax
cmp    $0x10,%rax
jne    1130 <md5_hex+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@md5_hex.out = internal global [16 x i8] zeroinitializer
@md5_hex.hcyf = internal global [16 x i8] c"0123456789abcdef"
define void @md5_hex(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = call i32 @md5(i8* %8, i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @md5_hex.out, i64 0, i64 0))
store i32 0, i32* %7
br label %11
11: ; preds = %45, %3
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 16
br i1 %13, label %14, label %48
14: ; preds = %11
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [16 x i8], [16 x i8]* @md5_hex.out, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = ashr i32 %19, 4
%21 = and i32 %20, 15
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [16 x i8], [16 x i8]* @md5_hex.hcyf, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = load i8*, i8** %6
%26 = load i32, i32* %7
%27 = mul nsw i32 2, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
store i8 %24, i8* %29
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [16 x i8], [16 x i8]* @md5_hex.out, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = and i32 %34, 15
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [16 x i8], [16 x i8]* @md5_hex.hcyf, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = load i8*, i8** %6
%40 = load i32, i32* %7
%41 = mul nsw i32 2, %40
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %39, i64 %43
store i8 %38, i8* %44
br label %45
45: ; preds = %14
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %11
48: ; preds = %11
ret void
}

LLVM IR (-O2):
@md5_hex.out = internal global [16 x i8] zeroinitializer
@md5_hex.hcyf = internal unnamed_addr constant [16 x i8] c"0123456789abcdef"
define void @md5_hex(i8* %0, i32 %1, i8* nocapture writeonly %2) {
%4 = tail call i32 @md5(i8* %0, i32 %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @md5_hex.out, i64 0, i64 0))
br label %5
5: ; preds = %3, %5
%6 = phi i64 [ 0, %3 ], [ %22, %5 ]
%7 = getelementptr inbounds [16 x i8], [16 x i8]* @md5_hex.out, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = lshr i8 %8, 4
%10 = zext i8 %9 to i64
%11 = getelementptr inbounds [16 x i8], [16 x i8]* @md5_hex.hcyf, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = shl nuw nsw i64 %6, 1
%14 = getelementptr inbounds i8, i8* %2, i64 %13
store i8 %12, i8* %14
%15 = load i8, i8* %7
%16 = and i8 %15, 15
%17 = zext i8 %16 to i64
%18 = getelementptr inbounds [16 x i8], [16 x i8]* @md5_hex.hcyf, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = or i64 %13, 1
%21 = getelementptr inbounds i8, i8* %2, i64 %20
store i8 %19, i8* %21
%22 = add nuw nsw i64 %6, 1
%23 = icmp eq i64 %22, 16
br i1 %23, label %24, label %5
24: ; preds = %5
ret void
}