#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 uint8_t;

/* Variables and functions */
char *malloc(int);
int /*<<< orphan*/ md5(int *, size_t, int *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
size_t strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
char *hashword(char *plaintext) {
  size_t len;
  int i;
  uint8_t result[16];
  char *ret = (char *)malloc(sizeof(char) * 33);
  memset(ret, '\0', 33);
  char *filler = malloc(sizeof(char) * 33);
  len = strlen(plaintext);
  for (i = 0; i < 1000000; i++)
    md5((uint8_t *)plaintext, len, result);
  for (i = 0; i < 16; i++) {
    sprintf(filler, "%2.2x", result[i]);
    strncat(ret, filler, 33);
    printf("current hash: %s\n", ret);
  }
  return ret;
}


x86 assembly (clang, -O0):
<hashword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x21,%edi
call   1070 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1050 <memset@plt>
mov    $0x21,%edi
call   1070 <malloc@plt>
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xf4240,-0x14(%rbp)
jge    11e8 <hashword+0x78>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1090 <md5@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bc <hashword+0x4c>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1241 <hashword+0xd1>
mov    -0x70(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%edx
lea    0xdf4(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    $0x21,%edx
call   1060 <strncat@plt>
mov    -0x68(%rbp),%rsi
lea    0xdd8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ef <hashword+0x7f>
mov    -0x68(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashword>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%r15
mov    $0x21,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1050 <memset@plt>
mov    $0x21,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
mov    $0xf4240,%ebx
mov    %rsp,%r13
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1090 <md5@plt>
add    $0xffffffff,%ebx
jne    11c0 <hashword+0x50>
xor    %ebx,%ebx
lea    0xe24(%rip),%r15
lea    0xe23(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rsp,%rbx,4),%edx
mov    %rbp,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x21,%edx
call   1060 <strncat@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x10,%rbx
jne    11f0 <hashword+0x80>
mov    %r14,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%2.2x\00"
@.str.1 = [18 x i8] c"current hash: %s\0A\00"
define i8* @hashword(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca [16 x i32]
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %2
%8 = call i8* @malloc(i32 33)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = call i32 @memset(i8* %9, i8 signext 0, i32 33)
%11 = call i8* @malloc(i32 33)
store i8* %11, i8** %7
%12 = load i8*, i8** %2
%13 = call i64 @strlen(i8* %12)
store i64 %13, i64* %3
store i32 0, i32* %4
br label %14
14: ; preds = %23, %1
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 1000000
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i8*, i8** %2
%19 = bitcast i8* %18 to i32*
%20 = load i64, i64* %3
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
%22 = call i32 @md5(i32* %19, i64 %20, i32* %21)
br label %23
23: ; preds = %17
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %14
26: ; preds = %14
store i32 0, i32* %4
br label %27
27: ; preds = %42, %26
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 16
br i1 %29, label %30, label %45
30: ; preds = %27
%31 = load i8*, i8** %7
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = load i8*, i8** %6
%38 = load i8*, i8** %7
%39 = call i32 @strncat(i8* %37, i8* %38, i32 33)
%40 = load i8*, i8** %6
%41 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %30
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %27
45: ; preds = %27
%46 = load i8*, i8** %6
ret i8* %46
}

LLVM IR (-O2):
@.str = [6 x i8] c"%2.2x\00"
@.str.1 = [18 x i8] c"current hash: %s\0A\00"
define i8* @hashword(i8* %0) {
%2 = alloca [16 x i32]
%3 = bitcast [16 x i32]* %2 to i8*
%4 = tail call dereferenceable_or_null(33) i8* @malloc(i32 33)
%5 = tail call i32 @memset(i8* %4, i8 signext 0, i32 33)
%6 = tail call dereferenceable_or_null(33) i8* @malloc(i32 33)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = bitcast i8* %0 to i32*
%9 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
br label %10
10: ; preds = %1, %10
%11 = phi i32 [ 0, %1 ], [ %13, %10 ]
%12 = call i32 @md5(i32* %8, i64 %7, i32* %9)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, 1000000
br i1 %14, label %15, label %10
15: ; preds = %10, %15
%16 = phi i64 [ %22, %15 ], [ 0, %10 ]
%17 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = call i32 @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 @strncat(i8* %4, i8* %6, i32 33)
%21 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%22 = add nuw nsw i64 %16, 1
%23 = icmp eq i64 %22, 16
br i1 %23, label %24, label %15
24: ; preds = %15
ret i8* %4
}