// File: MITRECND[P]snugglefish/src/indexSet.cpp
// Function: snugglefish::indexSet::open()
void indexSet::open(){
    string indexFileName, nGramFileName;
    indexFileName = nGramFileName = this->fileBase;
    char number_string[FILE_NUM_BUFFER_SIZE];
    snprintf(number_string, FILE_NUM_BUFFER_SIZE, FILE_NUM_SPRINTF_STRING, this->count);

    indexFileName.append(INDEX_FILE_EXTENSION).append(number_string);
    nGramFileName.append(NGRAM_FILE_EXTENSION).append(number_string);

    indexFile = new file(indexFileName.c_str());

    if(!indexFile->exists()){
        throw runtime_error("index file does not exist");
    }

    nGramFile = new file(nGramFileName.c_str());

    if (!nGramFile->exists()){
        throw runtime_error("index file does not exist");
    }

    indexFile->open('r');
    nGramFile->open('r');

    indexMap = indexFile->mmap();
    nGramMap = nGramFile->mmap();

    indexEntries = indexMap + INDEX_HEADER_SIZE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xe470
leaq -0x48(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0xe470
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdi
addq $0x28, %rsi
callq 0xe040
movq %rax, -0x88(%rbp)
jmp 0x18cc3
movq -0x88(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xe040
jmp 0x18cd5
movq -0x98(%rbp), %rax
movl 0x58(%rax), %ecx
leaq 0x1bc0(%rip), %rdx      # 0x1a8a6
xorl %eax, %eax
leaq -0x80(%rbp), %rdi
movl $0x1e, %esi
callq 0xe520
leaq 0x19f6(%rip), %rsi      # 0x1a6f3
leaq -0x28(%rbp), %rdi
callq 0xe640
movq %rax, -0xa0(%rbp)
jmp 0x18d0f
movq -0xa0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xe640
jmp 0x18d21
leaq 0x19c4(%rip), %rsi      # 0x1a6ec
leaq -0x48(%rbp), %rdi
callq 0xe640
movq %rax, -0xa8(%rbp)
jmp 0x18d3a
movq -0xa8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xe640
jmp 0x18d4c
movl $0x40, %edi
callq 0xe300
movq %rax, -0xb0(%rbp)
jmp 0x18d5f
leaq -0x28(%rbp), %rdi
callq 0xe120
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
movl $0x10000000, %edx       # imm = 0x10000000
callq 0x17aa0
jmp 0x18d7e
movq -0x98(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, (%rax)
movq (%rax), %rdi
callq 0x18650
movb %al, -0xb1(%rbp)
jmp 0x18d9f
movb -0xb1(%rbp), %al
testb $0x1, %al
jne 0x18e43
jmp 0x18daf
movl $0x10, %edi
callq 0xe170
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
leaq 0x1b06(%rip), %rsi      # 0x1a8d3
callq 0xe100
jmp 0x18dd4
movq -0xc0(%rbp), %rdi
movq 0x820e(%rip), %rsi      # 0x20ff0
movq 0x81bf(%rip), %rdx      # 0x20fa8
callq 0xe5b0
jmp 0x18ff4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x18fd9
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x40, %esi
callq 0xe310
jmp 0x18fd9
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0xe230
jmp 0x18fd9
movl $0x40, %edi
callq 0xe300
movq %rax, -0xc8(%rbp)
jmp 0x18e56
leaq -0x48(%rbp), %rdi
callq 0xe120
movq -0xc8(%rbp), %rdi
movq %rax, %rsi
movl $0x10000000, %edx       # imm = 0x10000000
callq 0x17aa0
jmp 0x18e75
movq -0x98(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq 0x8(%rax), %rdi
callq 0x18650
movb %al, -0xc9(%rbp)
jmp 0x18e98
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x18f2b
jmp 0x18ea8
movl $0x10, %edi
callq 0xe170
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd8(%rbp)
leaq 0x1a0d(%rip), %rsi      # 0x1a8d3
callq 0xe100
jmp 0x18ecd
movq -0xd8(%rbp), %rdi
movq 0x8115(%rip), %rsi      # 0x20ff0
movq 0x80c6(%rip), %rdx      # 0x20fa8
callq 0xe5b0
jmp 0x18ff4
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x40, %esi
callq 0xe310
jmp 0x18fd9
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0xe230
jmp 0x18fd9
movq -0x98(%rbp), %rax
movq (%rax), %rdi
movl $0x72, %esi
callq 0x17e80
jmp 0x18f41
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x72, %esi
callq 0x17e80
jmp 0x18f58
movq -0x98(%rbp), %rax
movq (%rax), %rdi
callq 0x18110
movq %rax, -0xe0(%rbp)
jmp 0x18f70
movq -0x98(%rbp), %rax
movq -0xe0(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq 0x8(%rax), %rdi
callq 0x18110
movq %rax, -0xe8(%rbp)
jmp 0x18f94
movq -0x98(%rbp), %rax
movq -0xe8(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq 0x10(%rax), %rcx
addq $0x4, %rcx
addq $0x1, %rcx
addq $0x1, %rcx
addq $0x4, %rcx
movq %rcx, 0x20(%rax)
leaq -0x48(%rbp), %rdi
callq 0xe1d0
leaq -0x28(%rbp), %rdi
callq 0xe1d0
addq $0xf0, %rsp
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0xe1d0
leaq -0x28(%rbp), %rdi
callq 0xe1d0
movq -0x50(%rbp), %rdi
callq 0xe5d0
nopw %cs:(%rax,%rax)