// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/indexSet.cpp
// Function: snugglefish::indexSet::create(unsigned int)
void indexSet::create(ngram_t_numfiles nFiles){
    if (indexFile || nGramFile){//Already opened?
        throw runtime_error("Error opening index or ngram file");
    }

    //Create the Files
    //First create the filenames
    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);

    this->indexFile = new file(indexFileName.c_str());
    this->nGramFile = new file(nGramFileName.c_str());

    if(indexFile->exists() || nGramFile->exists()){ //Already exist?
       throw runtime_error("index file or ngram file already exists"); 
    }

    indexFile->create();
    nGramFile->create();

    
    this->endian_check = ENDIAN_CHECK;
    this->version = VERSION;

    //Write standard header
    indexFile->write((uint8_t*) (&(this->endian_check)), ENDIAN_CHECK_FIELD);
    indexFile->write((uint8_t*) (&(this->version)), VERSION_FIELD);
    indexFile->write((uint8_t*) (&(this->ngramLength)), NGRAM_SIZE_FIELD);
    indexFile->write((uint8_t*) (&nFiles), INDEX_HEADER_NUM_FILES_FIELD);

    offset = 0; //Offset in the ngramfile

    writable = true;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movl %esi, -0x24(%rbp)
cmpq $0x0, (%rdi)
jne 0x9e2d
movq %rdi, %rbx
cmpq $0x0, 0x8(%rdi)
jne 0x9e2d
leaq -0x58(%rbp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb %al, (%r12)
leaq 0x28(%rbx), %rsi
leaq -0x48(%rbp), %rdi
callq 0x5140
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5140
movl 0x58(%rbx), %ecx
leaq 0x1bdb(%rip), %rdx      # 0xb8a6
leaq -0x90(%rbp), %rdi
movl $0x1e, %esi
xorl %eax, %eax
callq 0x5430
leaq 0x1a0e(%rip), %rsi      # 0xb6f3
leaq -0x68(%rbp), %rdi
callq 0x5550
leaq -0x90(%rbp), %rsi
movq %rax, %rdi
callq 0x5550
leaq 0x19e8(%rip), %rsi      # 0xb6ec
leaq -0x48(%rbp), %rdi
callq 0x5550
leaq -0x90(%rbp), %rsi
movq %rax, %rdi
callq 0x5550
movl $0x40, %edi
callq 0x5280
movq %rax, %r14
movq -0x68(%rbp), %rsi
movl $0x10000000, %edx       # imm = 0x10000000
movq %rax, %rdi
callq 0x92e8
movq %r14, (%rbx)
movl $0x40, %edi
callq 0x5280
movq %rax, %r14
movq -0x48(%rbp), %rsi
movl $0x10000000, %edx       # imm = 0x10000000
movq %rax, %rdi
callq 0x92e8
movq %r14, 0x8(%rbx)
movq (%rbx), %rdi
callq 0x9af0
testb %al, %al
jne 0x9e5f
movq 0x8(%rbx), %rdi
callq 0x9af0
testb %al, %al
jne 0x9e5f
movq (%rbx), %rdi
movl $0x1ed, %esi            # imm = 0x1ED
callq 0x94a6
movq 0x8(%rbx), %rdi
movl $0x1ed, %esi            # imm = 0x1ED
callq 0x94a6
leaq 0x4c(%rbx), %rsi
movl $0x1234567, 0x4c(%rbx)  # imm = 0x1234567
movb $0x1, 0x50(%rbx)
movq (%rbx), %rdi
movl $0x4, %edx
callq 0x9942
leaq 0x50(%rbx), %rsi
movq (%rbx), %rdi
movl $0x1, %edx
callq 0x9942
movq (%rbx), %rdi
leaq 0x51(%rbx), %rsi
movl $0x1, %edx
callq 0x9942
movq (%rbx), %rdi
leaq -0x24(%rbp), %rsi
movl $0x4, %edx
callq 0x9942
movq $0x0, 0x60(%rbx)
movb $0x1, 0x48(%rbx)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x9e0b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x5290
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x9e20
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x5290
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x5110
movq %rax, %r14
leaq 0x1a43(%rip), %rsi      # 0xb884
movq %rax, %rdi
callq 0x50d0
movq 0x51a0(%rip), %rsi      # 0xeff0
movq 0x5151(%rip), %rdx      # 0xefa8
movq %r14, %rdi
callq 0x54b0
movl $0x10, %edi
callq 0x5110
movq %rax, %r14
leaq 0x1a38(%rip), %rsi      # 0xb8ab
movq %rax, %rdi
callq 0x50d0
movq 0x516e(%rip), %rsi      # 0xeff0
movq 0x511f(%rip), %rdx      # 0xefa8
movq %r14, %rdi
callq 0x54b0
movq %rax, %rbx
movq %r14, %rdi
callq 0x51d0
jmp 0x9ec4
jmp 0x9ea0
movq %rax, %rbx
movl $0x40, %esi
movq %r14, %rdi
callq 0x5290
jmp 0x9ec4
movq %rax, %rbx
movq %r14, %rdi
callq 0x51d0
jmp 0x9eee
jmp 0x9ec1
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x9ed9
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x5290
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x9eee
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x5290
movq %rbx, %rdi
callq 0x54e0