#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 */
struct lineFile {
  int dummy;
};
struct hash {
  int dummy;
};
typedef int /*<<< orphan*/ row;

/* Variables and functions */
int /*<<< orphan*/ cloneString(char *);
int /*<<< orphan*/ hashAdd(struct hash *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ lineFileClose(struct lineFile **);
scalar_t__ lineFileNextRow(struct lineFile *, char **, int);
struct lineFile *lineFileOpen(char *, int);
struct hash *newHashExt(int /*<<< orphan*/, int);
struct hash *md5FileHash(char *fileName) {
  struct lineFile *lf = lineFileOpen(fileName, 1);
  char *row[2];
  struct hash *hash = newHashExt(0, 1);
  while (lineFileNextRow(lf, row, (sizeof(row) / sizeof((row)[0]))))
    hashAdd(hash, row[1], cloneString(row[0]));
  lineFileClose(&lf);
  return hash;
}


x86 assembly (clang, -O0):
<md5FileHash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1080 <lineFileOpen@plt>
mov    %rax,-0x10(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <newHashExt@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x2,%edx
call   1030 <lineFileNextRow@plt>
cmp    $0x0,%rax
je     11d7 <md5FileHash+0x77>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <cloneString@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1070 <hashAdd@plt>
jmp    118e <md5FileHash+0x2e>
lea    -0x10(%rbp),%rdi
call   1040 <lineFileClose@plt>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5FileHash>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x1,%esi
call   1080 <lineFileOpen@plt>
mov    %rax,%r12
mov    %rax,0x10(%rsp)
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <newHashExt@plt>
mov    %rax,%r14
mov    %rsp,%rsi
mov    %r12,%rdi
mov    $0x2,%edx
call   1030 <lineFileNextRow@plt>
test   %rax,%rax
je     11e0 <md5FileHash+0x80>
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rsp),%rdi
mov    0x8(%rsp),%rbx
call   1060 <cloneString@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <hashAdd@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <lineFileNextRow@plt>
test   %rax,%rax
jne    11b0 <md5FileHash+0x50>
lea    0x10(%rsp),%rdi
call   1040 <lineFileClose@plt>
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.hash = type { i32 }
%struct.lineFile = type { i32 }
define %struct.hash* @md5FileHash(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.lineFile*
%4 = alloca [2 x i8*]
%5 = alloca %struct.hash*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call %struct.lineFile* @lineFileOpen(i8* %6, i32 1)
store %struct.lineFile* %7, %struct.lineFile** %3
%8 = call %struct.hash* @newHashExt(i32 0, i32 1)
store %struct.hash* %8, %struct.hash** %5
br label %9
9: ; preds = %14, %1
%10 = load %struct.lineFile*, %struct.lineFile** %3
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%12 = call i64 @lineFileNextRow(%struct.lineFile* %10, i8** %11, i32 2)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = load %struct.hash*, %struct.hash** %5
%16 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @cloneString(i8* %19)
%21 = call i32 @hashAdd(%struct.hash* %15, i8* %17, i32 %20)
br label %9
22: ; preds = %9
%23 = call i32 @lineFileClose(%struct.lineFile** %3)
%24 = load %struct.hash*, %struct.hash** %5
ret %struct.hash* %24
}

LLVM IR (-O2):
%struct.hash = type { i32 }
%struct.lineFile = type { i32 }
define %struct.hash* @md5FileHash(i8* %0) {
%2 = alloca %struct.lineFile*
%3 = alloca [2 x i8*]
%4 = bitcast %struct.lineFile** %2 to i8*
%5 = tail call %struct.lineFile* @lineFileOpen(i8* %0, i32 1)
store %struct.lineFile* %5, %struct.lineFile** %2
%6 = bitcast [2 x i8*]* %3 to i8*
%7 = tail call %struct.hash* @newHashExt(i32 0, i32 1)
%8 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
%9 = call i64 @lineFileNextRow(%struct.lineFile* %5, i8** %8, i32 2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %1
%12 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 1
br label %13
13: ; preds = %11, %13
%14 = load i8*, i8** %12
%15 = load i8*, i8** %8
%16 = call i32 @cloneString(i8* %15)
%17 = call i32 @hashAdd(%struct.hash* %7, i8* %14, i32 %16)
%18 = call i64 @lineFileNextRow(%struct.lineFile* %5, i8** %8, i32 2)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %13
20: ; preds = %13, %1
%21 = call i32 @lineFileClose(%struct.lineFile** %2)
ret %struct.hash* %7
}