// File: /workspace/github_c_makefile_star2_O0/antirez[P]stonky/stonky.c
// Function: loadFile
sds *loadFile(char *filename, int *count, int shuffle) {
    FILE *fp = fopen(filename,"r");
    if (fp == NULL) return NULL;

    char buf[1024];
    sds *lines = NULL;
    int num = 0;
    while (fgets(buf,sizeof(buf),fp) != NULL) {
        buf[sizeof(buf)-1] = '\0';
        for (unsigned int i = 0; buf[i] && i < sizeof(buf); i++) {
            if (buf[i] == '\r' || buf[i] == '\n') {
                buf[i] = 0;
                break;
            }
        }
        lines = xrealloc(lines,sizeof(sds)*(num+1));
        lines[num++] = sdsnew(buf);
    }
    fclose(fp);

    /* Shuffle them: since we don't store the symbols in a database,
     * we want to start scanning them in different order at every
     * restart. */
    for (int j = 0; shuffle && j < num; j++) {
        int with = rand() % num;
        sds aux = lines[j];
        lines[j] = lines[with];
        lines[with] = aux;
    }

    if (VerboseMode) printf("%s loaded (%d lines)\n", filename, num);
    *count = num;
    return lines;
}

// Assembly:
subq $0x458, %rsp            # imm = 0x458
movq %rdi, 0x448(%rsp)
movq %rsi, 0x440(%rsp)
movl %edx, 0x43c(%rsp)
movq 0x448(%rsp), %rdi
leaq 0x234b(%rip), %rsi      # 0x15558
callq 0x2290
movq %rax, 0x430(%rsp)
cmpq $0x0, 0x430(%rsp)
jne 0x13236
movq $0x0, 0x450(%rsp)
jmp 0x13401
movq $0x0, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
leaq 0x30(%rsp), %rdi
movq 0x430(%rsp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x2390
cmpq $0x0, %rax
je 0x13325
movb $0x0, 0x42f(%rsp)
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
movsbl 0x30(%rsp,%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0xf(%rsp)
je 0x1329d
movl 0x20(%rsp), %eax
cmpq $0x400, %rax            # imm = 0x400
setb %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x132a7
jmp 0x132dd
movl 0x20(%rsp), %eax
movsbl 0x30(%rsp,%rax), %eax
cmpl $0xd, %eax
je 0x132c3
movl 0x20(%rsp), %eax
movsbl 0x30(%rsp,%rax), %eax
cmpl $0xa, %eax
jne 0x132ce
movl 0x20(%rsp), %eax
movb $0x0, 0x30(%rsp,%rax)
jmp 0x132dd
jmp 0x132d0
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x13278
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0xb3a0
movq %rax, 0x28(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x8630
movq %rax, %rdx
movq 0x28(%rsp), %rax
movl 0x24(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x24(%rsp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x13247
movq 0x430(%rsp), %rdi
callq 0x2250
movl $0x0, 0x1c(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x43c(%rsp)
movb %al, 0xe(%rsp)
je 0x13359
movl 0x1c(%rsp), %eax
cmpl 0x24(%rsp), %eax
setl %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0x13363
jmp 0x133c3
callq 0x20b0
cltd
idivl 0x24(%rsp)
movl %edx, 0x18(%rsp)
movq 0x28(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rax
movslq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x28(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rsp), %rdx
movq 0x28(%rsp), %rax
movslq 0x18(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x1333a
cmpl $0x0, 0x7eea(%rip)      # 0x1b2b4
je 0x133e6
movq 0x448(%rsp), %rsi
movl 0x24(%rsp), %edx
leaq 0x424e(%rip), %rdi      # 0x1762d
movb $0x0, %al
callq 0x2030
movl 0x24(%rsp), %ecx
movq 0x440(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
movq %rax, 0x450(%rsp)
movq 0x450(%rsp), %rax
addq $0x458, %rsp            # imm = 0x458
retq
nopw %cs:(%rax,%rax)