#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
char *hio_md5(char const *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char fhash[40];
  char *hptr;
  hptr = fhash;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <file to get md5sum of>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  memset(fhash, '\0', 40);
  hptr = hio_md5((const char *)argv[1]);
  if (fhash == NULL) {
    printf("Could not calculate the hash.\n");
    exit(EXIT_FAILURE);
  }
  printf("final hash = %s\n", hptr);
  free(hptr);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b2 <main+0x52>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe61(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <hio_md5@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    11a9 <main+0x49>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
mov    0x8(%rbx),%rdi
call   1040 <hio_md5@plt>
mov    %rax,%rbx
lea    0xe94(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe44(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: %s <file to get md5sum of>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [17 x i8] c"final hash = %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [40 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
store i8* %8, i8** %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%21 = call i32 @memset(i8* %20, i8 signext 0, i32 40)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i8* @hio_md5(i8* %24)
store i8* %25, i8** %7
%26 = load i8*, i8** %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %7
%29 = call i32 @free(i8* %28)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: %s <file to get md5sum of>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [17 x i8] c"final hash = %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [40 x i8]
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = call i32 @memset(i8* %4, i8 signext 0, i32 40)
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i8* @hio_md5(i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @free(i8* %16)
ret i32 0
}