#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 */
typedef int /*<<< orphan*/ MD5_CTX;

/* Variables and functions */
int /*<<< orphan*/ MD5_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
void calc_md5(char *src, char *dst) {
  int i;
  MD5_CTX ctx;
  unsigned char md[16] = {0};
  char temp[3] = {0};
  memset(dst, '\0', 33);
  MD5_Init(&ctx);
  MD5_Update(&ctx, src, strlen(src));
  MD5_Final(md, &ctx);
  for (i = 0; i < 16; i++) {
    sprintf(temp, "%2.2x", md[i]);
    strcat(dst, temp);
  }
}


x86 assembly (clang, -O0):
<calc_md5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x33(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1050 <memset@plt>
lea    -0x18(%rbp),%rdi
call   1070 <MD5_Init@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    -0x18(%rbp),%rdi
call   1090 <MD5_Update@plt>
lea    -0x30(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <MD5_Final@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    122b <calc_md5+0xbb>
lea    -0x33(%rbp),%rdi
movslq -0x14(%rbp),%rax
lea    0xdfa(%rip),%rsi
movzbl -0x30(%rbp,%rax,1),%edx
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x33(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ed <calc_md5+0x7d>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_md5>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x1a(%rsp)
movw   $0x0,0x18(%rsp)
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1050 <memset@plt>
lea    0x1c(%rsp),%r15
mov    %r15,%rdi
call   1070 <MD5_Init@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1090 <MD5_Update@plt>
mov    %rsp,%rdi
mov    %r15,%rsi
call   1030 <MD5_Final@plt>
movzbl (%rsp),%edx
lea    0xe27(%rip),%r15
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0x1(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0x2(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0x3(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0x5(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0x6(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0x7(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0x8(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0x9(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0xa(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0xb(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0xd(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0xe(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movzbl 0xf(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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