#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 MD5_DIGEST_LENGTH;
int /*<<< orphan*/ MD5_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, unsigned char *,
                              int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(unsigned char *);
int getstrmd5(unsigned char *data) {
  MD5_CTX ctx;
  unsigned char md[MD5_DIGEST_LENGTH];
  char buf[64] = {'\0'};
  char tmp[3] = {'\0'};
  int i;
  MD5_Init(&ctx);
  MD5_Update(&ctx, data, strlen(data));
  MD5_Final(md, &ctx);
  for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
    sprintf(tmp, "%02X", md[i]);
    strcat(buf, tmp);
  }
  printf("%s\n", buf);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<getstrmd5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    -0x63(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1060 <memset@plt>
lea    -0xc(%rbp),%rdi
call   1090 <MD5_Init@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
lea    -0xc(%rbp),%rdi
call   10b0 <MD5_Update@plt>
mov    -0x70(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <MD5_Final@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    0x2dae(%rip),%rcx
cmp    (%rcx),%eax
jge    1271 <getstrmd5+0xe1>
mov    -0x70(%rbp),%rax
lea    -0x63(%rbp),%rdi
movslq -0x68(%rbp),%rcx
lea    0xdb3(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   10a0 <sprintf@plt>
lea    -0x60(%rbp),%rdi
lea    -0x63(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1228 <getstrmd5+0x98>
lea    -0x60(%rbp),%rsi
lea    0xd89(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getstrmd5>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%r14
mov    %rsp,-0x38(%rbp)
mov    0x2e41(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,-0x50(%rbp)
movaps %xmm0,-0x60(%rbp)
movaps %xmm0,-0x70(%rbp)
movaps %xmm0,-0x80(%rbp)
movb   $0x0,-0x2a(%rbp)
movw   $0x0,-0x2c(%rbp)
lea    -0x3c(%rbp),%rbx
mov    %rbx,%rdi
call   1080 <MD5_Init@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   10a0 <MD5_Update@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <MD5_Final@plt>
cmpl   $0x0,(%r12)
jle    124b <getstrmd5+0xcb>
mov    %r12,%r14
xor    %r13d,%r13d
lea    -0x2c(%rbp),%rbx
lea    -0x80(%rbp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r15,%r13,1),%edx
mov    %rbx,%rdi
lea    0xdd1(%rip),%rsi
call   1090 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
add    $0x1,%r13
movslq (%r14),%rax
cmp    %rax,%r13
jl     1220 <getstrmd5+0xa0>
lea    0xdb3(%rip),%rdi
lea    -0x80(%rbp),%rsi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    -0x38(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MD5_DIGEST_LENGTH = global i32 0
@.str = [5 x i8] c"%02X\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @getstrmd5(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [64 x i8]
%7 = alloca [3 x i8]
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i32, i32* @MD5_DIGEST_LENGTH
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i8, i64 %10
store i64 %10, i64* %5
%13 = bitcast [64 x i8]* %6 to i8*
%14 = bitcast [3 x i8]* %7 to i8*
%15 = call i32 @MD5_Init(i32* %3)
%16 = load i8*, i8** %2
%17 = load i8*, i8** %2
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @MD5_Update(i32* %3, i8* %16, i32 %18)
%20 = call i32 @MD5_Final(i8* %12, i32* %3)
store i32 0, i32* %8
br label %21
21: ; preds = %35, %1
%22 = load i32, i32* %8
%23 = load i32, i32* @MD5_DIGEST_LENGTH
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %38
25: ; preds = %21
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %12, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %30)
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%34 = call i32 @strcat(i8* %32, i8* %33)
br label %35
35: ; preds = %25
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %21
38: ; preds = %21
%39 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = call i32 (...) @getchar()
%42 = load i8*, i8** %4
ret i32 0
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
@.str = [5 x i8] c"%02X\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @getstrmd5(i8* %0) {
%2 = alloca i32
%3 = alloca [64 x i8]
%4 = alloca [3 x i8]
%5 = bitcast i32* %2 to i8*
%6 = load i32, i32* @MD5_DIGEST_LENGTH
%7 = zext i32 %6 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%12 = call i32 @MD5_Init(i32* %2)
%13 = call i32 @strlen(i8* %0)
%14 = call i32 @MD5_Update(i32* %2, i8* %0, i32 %13)
%15 = call i32 @MD5_Final(i8* %9, i32* %2)
%16 = load i32, i32* @MD5_DIGEST_LENGTH
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %1, %18
%19 = phi i64 [ %24, %18 ], [ 0, %1 ]
%20 = getelementptr inbounds i8, i8* %9, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %21)
%23 = call i32 @strcat(i8* %10, i8* %11)
%24 = add nuw nsw i64 %19, 1
%25 = load i32, i32* @MD5_DIGEST_LENGTH
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %18, label %28
28: ; preds = %18, %1
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%30 = call i32 (...) @getchar()
ret i32 0
}