#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
char *create_md5_string(unsigned char *md5) {
  char *result = (char *)malloc(33);
  int i;
  for (i = 0; i < 16; i++) {
    sprintf(result + 2 * i, "%02x", *(md5 + i));
  }
  return result;
}


x86 assembly (clang, -O0):
<create_md5_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x21,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1180 <create_md5_string+0x60>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xe97(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1040 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <create_md5_string+0x21>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_md5_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x21,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
movzbl (%r14),%edx
lea    0xec0(%rip),%r15
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x2(%rbx),%rdi
movzbl 0x1(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x4(%rbx),%rdi
movzbl 0x2(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x6(%rbx),%rdi
movzbl 0x3(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x8(%rbx),%rdi
movzbl 0x4(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0xa(%rbx),%rdi
movzbl 0x5(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0xc(%rbx),%rdi
movzbl 0x6(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0xe(%rbx),%rdi
movzbl 0x7(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x10(%rbx),%rdi
movzbl 0x8(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x12(%rbx),%rdi
movzbl 0x9(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x14(%rbx),%rdi
movzbl 0xa(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x16(%rbx),%rdi
movzbl 0xb(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x18(%rbx),%rdi
movzbl 0xc(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x1a(%rbx),%rdi
movzbl 0xd(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x1c(%rbx),%rdi
movzbl 0xe(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0x1e(%rbx),%rdi
movzbl 0xf(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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