#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 md5_from_file(char *, unsigned char *);
int /*<<< orphan*/ md5_num2str(unsigned char *, char *);
int /*<<< orphan*/ printf(char *, char *);
char *md5sum_file(char *path, char *md5sum) {
  unsigned char md5num[16] = {'\0'};
  if (md5_from_file(path, md5num) == -1) {
    printf("ERROR: failed to md5 from file %s\n", path);
    return NULL;
  }
  md5_num2str(md5num, md5sum);
  return md5sum;
}


x86 assembly (clang, -O0):
<md5sum_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <md5_from_file@plt>
cmp    $0xffffffff,%eax
jne    1193 <md5sum_file+0x53>
mov    -0x10(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a8 <md5sum_file+0x68>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <md5_num2str@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5sum_file>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
call   1050 <md5_from_file@plt>
cmp    $0xffffffff,%eax
je     115e <md5sum_file+0x2e>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <md5_num2str@plt>
jmp    116f <md5sum_file+0x3f>
lea    0xe9b(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [35 x i8] c"ERROR: failed to md5 from file %s\0A\00"
define i8* @md5sum_file(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [16 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = bitcast [16 x i8]* %6 to i8*
%8 = load i8*, i8** %4
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%10 = call i32 @md5_from_file(i8* %8, i8* %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %13)
store i8* null, i8** %3
br label %20
15: ; preds = %2
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %5
%18 = call i32 @md5_num2str(i8* %16, i8* %17)
%19 = load i8*, i8** %5
store i8* %19, i8** %3
br label %20
20: ; preds = %15, %12
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
@.str = [35 x i8] c"ERROR: failed to md5 from file %s\0A\00"
define i8* @md5sum_file(i8* %0, i8* %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = call i32 @md5_from_file(i8* %0, i8* %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %11
9: ; preds = %2
%10 = call i32 @md5_num2str(i8* %4, i8* %1)
br label %11
11: ; preds = %9, %7
%12 = phi i8* [ null, %7 ], [ %1, %9 ]
ret i8* %12
}