#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 game {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int hashVal(char *, int *);
struct game *insertGame(struct game *, char *);
int /*<<< orphan*/ queryImport(struct game **, int *);
struct game **importData(FILE *ifp, int *sizePtr) {
  int i, hash = 0;
  char temp[30];
  struct game **newcab;
  ifp = fopen("gamelist.txt", "r");
  fscanf(ifp, "%d", &sizePtr);
  newcab = (struct game **)calloc((int)sizePtr, sizeof(struct game *));
  for (i = 0; i < (int)sizePtr; i++) {
    fscanf(ifp, "%s", &temp);
    hash = hashVal(temp, sizePtr);
    newcab[hash] = insertGame(newcab[hash], temp);
  }
  fclose(ifp);
  queryImport(newcab, sizePtr);
  return newcab;
}


x86 assembly (clang, -O0):
<importData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe72(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x10(%rbp),%rax
mov    %eax,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    %ecx,%eax
jge    1236 <importData+0xc6>
mov    -0x8(%rbp),%rdi
lea    0xe29(%rip),%rsi
lea    -0x40(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <hashVal@plt>
mov    %eax,-0x18(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x40(%rbp),%rsi
call   1090 <insertGame@plt>
mov    %rax,%rdx
mov    -0x48(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cf <importData+0x5f>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <queryImport@plt>
mov    -0x48(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<importData>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,0x8(%rsp)
lea    0xe76(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe6f(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x8(%rsp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,%r13
cmpl   $0x0,0x8(%rsp)
jle    121b <importData+0xab>
lea    0xe44(%rip),%r15
lea    0x10(%rsp),%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x8(%rsp),%rsi
mov    %r12,%rdi
call   1030 <hashVal@plt>
movslq %eax,%rbx
mov    0x0(%r13,%rbx,8),%rdi
mov    %r12,%rsi
call   1090 <insertGame@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jl     11e0 <importData+0x70>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%rsi
mov    %r13,%rdi
call   1070 <queryImport@plt>
mov    %r13,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.game = type { i32 }
@.str = [13 x i8] c"gamelist.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%s\00"
define %struct.game** @importData(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [30 x i8]
%8 = alloca %struct.game**
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %6
%9 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %3
%10 = load i32*, i32** %3
%11 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32** %4)
%12 = load i32*, i32** %4
%13 = ptrtoint i32* %12 to i32
%14 = call i64 @calloc(i32 %13, i32 8)
%15 = inttoptr i64 %14 to %struct.game**
store %struct.game** %15, %struct.game*** %8
store i32 0, i32* %5
br label %16
16: ; preds = %38, %2
%17 = load i32, i32* %5
%18 = load i32*, i32** %4
%19 = ptrtoint i32* %18 to i32
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %41
21: ; preds = %16
%22 = load i32*, i32** %3
%23 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), [30 x i8]* %7)
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%25 = load i32*, i32** %4
%26 = call i32 @hashVal(i8* %24, i32* %25)
store i32 %26, i32* %6
%27 = load %struct.game**, %struct.game*** %8
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds %struct.game*, %struct.game** %27, i64 %29
%31 = load %struct.game*, %struct.game** %30
%32 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%33 = call %struct.game* @insertGame(%struct.game* %31, i8* %32)
%34 = load %struct.game**, %struct.game*** %8
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds %struct.game*, %struct.game** %34, i64 %36
store %struct.game* %33, %struct.game** %37
br label %38
38: ; preds = %21
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %16
41: ; preds = %16
%42 = load i32*, i32** %3
%43 = call i32 @fclose(i32* %42)
%44 = load %struct.game**, %struct.game*** %8
%45 = load i32*, i32** %4
%46 = call i32 @queryImport(%struct.game** %44, i32* %45)
%47 = load %struct.game**, %struct.game*** %8
ret %struct.game** %47
}

LLVM IR (-O2):
%struct.game = type { i32 }
@.str = [13 x i8] c"gamelist.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%s\00"
define %struct.game** @importData(i32* nocapture readnone %0, i32* %1) {
%3 = alloca i32*
%4 = alloca [30 x i8]
store i32* %1, i32** %3
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32** %3)
%8 = load i32*, i32** %3
%9 = ptrtoint i32* %8 to i64
%10 = trunc i64 %9 to i32
%11 = call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to %struct.game**
%13 = load i32*, i32** %3
%14 = ptrtoint i32* %13 to i64
%15 = trunc i64 %14 to i32
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %2, %17
%18 = phi i32 [ %26, %17 ], [ 0, %2 ]
%19 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), [30 x i8]* %4)
%20 = load i32*, i32** %3
%21 = call i32 @hashVal(i8* %5, i32* %20)
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds %struct.game*, %struct.game** %12, i64 %22
%24 = load %struct.game*, %struct.game** %23
%25 = call %struct.game* @insertGame(%struct.game* %24, i8* %5)
store %struct.game* %25, %struct.game** %23
%26 = add nuw nsw i32 %18, 1
%27 = load i32*, i32** %3
%28 = ptrtoint i32* %27 to i64
%29 = trunc i64 %28 to i32
%30 = icmp slt i32 %26, %29
br i1 %30, label %17, label %31
31: ; preds = %17, %2
%32 = call i32 @fclose(i32* %6)
%33 = load i32*, i32** %3
%34 = call i32 @queryImport(%struct.game** %12, i32* %33)
ret %struct.game** %12
}