#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ add_to_string(char *, char const *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ initialize_string(char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int system(char *);
void md5(char *variable, const char *path) {
  int status_code = system("which md5sum >/dev/null 2>&1");
  if (status_code == 0) {
    char command[1024 + 1024 + 2];
    initialize_string(command);
    add_to_string(command, "md5sum ");
    add_to_string(command, path);
    FILE *stream = popen(command, "r");
    if (stream != NULL) {
      fgets(variable, 32, stream);
      pclose(stream);
    }
  }
}


x86 assembly (clang, -O0):
<md5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe86(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1209 <md5+0xa9>
lea    -0x820(%rbp),%rdi
call   1070 <initialize_string@plt>
lea    -0x820(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1060 <add_to_string@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <add_to_string@plt>
lea    -0x820(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x828(%rbp)
cmpq   $0x0,-0x828(%rbp)
je     1204 <md5+0xa4>
mov    -0x8(%rbp),%rdi
mov    -0x828(%rbp),%rdx
mov    $0x20,%esi
call   1050 <fgets@plt>
mov    -0x828(%rbp),%rdi
call   1040 <pclose@plt>
jmp    1209 <md5+0xa9>
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5>:
push   %r15
push   %r14
push   %rbx
sub    $0x810,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe87(%rip),%rdi
call   1030 <system@plt>
test   %eax,%eax
jne    11d6 <md5+0x76>
mov    %rsp,%r15
mov    %r15,%rdi
call   1070 <initialize_string@plt>
lea    0xe89(%rip),%rsi
mov    %r15,%rdi
call   1060 <add_to_string@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <add_to_string@plt>
lea    0xe77(%rip),%rsi
mov    %r15,%rdi
call   1080 <popen@plt>
test   %rax,%rax
je     11d6 <md5+0x76>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x20,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1040 <pclose@plt>
add    $0x810,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"which md5sum >/dev/null 2>&1\00"
@.str.1 = [8 x i8] c"md5sum \00"
@.str.2 = [2 x i8] c"r\00"
define void @md5(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [2050 x i8]
%7 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %2
%12 = getelementptr inbounds [2050 x i8], [2050 x i8]* %6, i64 0, i64 0
%13 = call i32 @initialize_string(i8* %12)
%14 = getelementptr inbounds [2050 x i8], [2050 x i8]* %6, i64 0, i64 0
%15 = call i32 @add_to_string(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds [2050 x i8], [2050 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = call i32 @add_to_string(i8* %16, i8* %17)
%19 = getelementptr inbounds [2050 x i8], [2050 x i8]* %6, i64 0, i64 0
%20 = call i32* @popen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %20, i32** %7
%21 = load i32*, i32** %7
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %29
23: ; preds = %11
%24 = load i8*, i8** %3
%25 = load i32*, i32** %7
%26 = call i32 @fgets(i8* %24, i32 32, i32* %25)
%27 = load i32*, i32** %7
%28 = call i32 @pclose(i32* %27)
br label %29
29: ; preds = %23, %11
br label %30
30: ; preds = %29, %2
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"which md5sum >/dev/null 2>&1\00"
@.str.1 = [8 x i8] c"md5sum \00"
@.str.2 = [2 x i8] c"r\00"
define void @md5(i8* %0, i8* %1) {
%3 = alloca [2050 x i8]
%4 = tail call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %2
%7 = getelementptr inbounds [2050 x i8], [2050 x i8]* %3, i64 0, i64 0
%8 = call i32 @initialize_string(i8* %7)
%9 = call i32 @add_to_string(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @add_to_string(i8* %7, i8* %1)
%11 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %6
%14 = call i32 @fgets(i8* %0, i32 32, i32* %11)
%15 = call i32 @pclose(i32* %11)
br label %16
16: ; preds = %13, %6
br label %17
17: ; preds = %16, %2
ret void
}