#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ insertToHash(char *, char *);
int /*<<< orphan*/ printf(char *);
char *strtok(char *, char *);
void createHashTable() {
  char *username, *password;
  char *delimiter = ":";
  const char filename[] = "./passwd";
  FILE *file = fopen(filename, "r");
  if (file != NULL) {
    char file_lines[128];
    while (fgets(file_lines, sizeof file_lines, file) != NULL) {
      username = strtok(file_lines, delimiter);
      password = strtok(NULL, "\r");
      insertToHash(username, password);
    }
    fclose(file);
  } else {
    printf("\n Unable to read file.");
  }
  return;
}


x86 assembly (clang, -O0):
<createHashTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    0xe8e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe85(%rip),%rax
mov    %rax,-0x21(%rbp)
mov    0xe83(%rip),%al
mov    %al,-0x19(%rbp)
lea    -0x21(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1215 <createHashTable+0xb5>
jmp    11ae <createHashTable+0x4e>
lea    -0xb0(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x80,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1207 <createHashTable+0xa7>
lea    -0xb0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe21(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <insertToHash@plt>
jmp    11ae <createHashTable+0x4e>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1221 <createHashTable+0xc1>
lea    0xdf3(%rip),%rdi
call   1050 <printf@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createHashTable>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x90,%rsp
movabs $0x6477737361702f2e,%rax
73 77 64
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
lea    0xe81(%rip),%rsi
mov    %rsp,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     1221 <createHashTable+0xc1>
mov    %rax,%r15
lea    0x10(%rsp),%rdi
mov    $0x80,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1208 <createHashTable+0xa8>
lea    0xe44(%rip),%r14
lea    0x10(%rsp),%r13
lea    0xe45(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <insertToHash@plt>
mov    %r13,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11d0 <createHashTable+0x70>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xde7(%rip),%rdi
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@__const.createHashTable.filename = [9 x i8] c"./passwd\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"\0D\00"
@.str.3 = [23 x i8] c"\0A Unable to read file.\00"
define void @createHashTable() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [9 x i8]
%5 = alloca i32*
%6 = alloca [128 x i8]
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %3
%7 = bitcast [9 x i8]* %4 to i8*
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %5
%10 = load i32*, i32** %5
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %29
12: ; preds = %0
br label %13
13: ; preds = %18, %12
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%15 = load i32*, i32** %5
%16 = call i32* @fgets(i8* %14, i32 128, i32* %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %26
18: ; preds = %13
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%20 = load i8*, i8** %3
%21 = call i8* @strtok(i8* %19, i8* %20)
store i8* %21, i8** %1
%22 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %22, i8** %2
%23 = load i8*, i8** %1
%24 = load i8*, i8** %2
%25 = call i32 @insertToHash(i8* %23, i8* %24)
br label %13
26: ; preds = %13
%27 = load i32*, i32** %5
%28 = call i32 @fclose(i32* %27)
br label %31
29: ; preds = %0
%30 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@__const.createHashTable.filename = [9 x i8] c"./passwd\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"\0D\00"
@.str.3 = [23 x i8] c"\0A Unable to read file.\00"
define void @createHashTable() {
%1 = alloca [9 x i8]
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%4 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %18, label %6
6: ; preds = %0
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%8 = call i32* @fgets(i8* %7, i32 128, i32* %4)
%9 = icmp eq i32* %8, null
br i1 %9, label %16, label %10
10: ; preds = %6, %10
%11 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @insertToHash(i8* %11, i8* %12)
%14 = call i32* @fgets(i8* %7, i32 128, i32* %4)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %10
16: ; preds = %10, %6
%17 = call i32 @fclose(i32* %4)
br label %20
18: ; preds = %0
%19 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
ret void
}