#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*/ MDString(unsigned char *, unsigned int, unsigned char *);
int /*<<< orphan*/ sprintf(unsigned char *, char *, unsigned char);
void MDEncode(unsigned char *str, unsigned int nLen, unsigned char *md5str) {
  unsigned char digest[16];
  MDString(str, nLen, digest);
  int i;
  for (i = 0; i < 16; i++) {
    sprintf(&md5str[2 * i], "%02x", digest[i]);
  }
}


x86 assembly (clang, -O0):
<MDEncode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1030 <MDString@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x10,-0x34(%rbp)
jge    1186 <MDEncode+0x66>
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
movslq -0x34(%rbp),%rax
lea    0xe92(%rip),%rsi
movzbl -0x30(%rbp,%rax,1),%edx
call   1040 <sprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    114a <MDEncode+0x2a>
add    $0x40,%rsp
pop    %rbp
ret

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

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