#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char const);
int /*<<< orphan*/ strcat(char *, char *);
void md5_num2str(const unsigned char *md5num, char *md5str) {
  char tmp[8] = {'\0'};
  int i;
  memset(md5str, 0, 40);
  for (i = 0; i < 16; i++) {
    sprintf(tmp, "%02x", md5num[i]);
    strcat(md5str, tmp);
  }
  md5str[32] = '\0';
}


x86 assembly (clang, -O0):
<md5_num2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11a8 <md5_num2str+0x78>
lea    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
lea    0xe7c(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <md5_num2str+0x37>
mov    -0x10(%rbp),%rax
movb   $0x0,0x20(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5_num2str>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movq   $0x0,(%rsp)
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
movzbl (%r14),%edx
lea    0xea0(%rip),%r12
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0x1(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0x2(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0x3(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0x4(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0x5(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0x6(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0x7(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0x8(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0x9(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0xa(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0xb(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0xc(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0xd(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0xe(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movzbl 0xf(%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
movb   $0x0,0x20(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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