// File: /workspace/github_cpp_makefile_star2_O3/MITRECND[P]snugglefish/src/nGramIndex.cpp
// Function: snugglefish::nGramIndex::nGramIndex(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
nGramIndex::nGramIndex( uint32_t ngramLength, string indexFileName)
    :nGramBase(ngramLength, indexFileName), bufferMax(MAX_BUFFER_SIZE),
    buffer_memory_usage(0), flush(false), flushing(false) {


    this->maxFileNameLength = DEFAULT_MAX_FILENAME_SIZE;
    
	//allocate output buffer
	this->output_buffer = new buffer_element[maxNgram];
	for(uint64_t i = 0; i < maxNgram; i++){
		this->output_buffer[i].elements_size = 0;
		this->output_buffer[i].elements = new list<ngram_t_fidtype>;
	}

    masterFile = new smFile(baseFileName, ngramLength);

    if (masterFile->exists()){
        masterFile->open('w');
    }else{ //Must create it
        masterFile->create(maxFileNameLength);
    }

    numFilesProcessed = masterFile->getNumFiles();
    numSessionFilesProcessed = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movl %esi, %r14d
movq %rdi, %rbx
leaq -0x50(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %r15
movq %r15, %rdi
callq 0x7096
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x7700
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x8523
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x5290
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x38(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%rbx)
movups %xmm0, 0x58(%rbx)
movw $0x0, 0x68(%rbx)
movw $0x41, (%rbx)
movq 0x30(%rbx), %r12
movq %r12, %rax
shrq $0x3c, %rax
movq %r12, %rcx
shlq $0x4, %rcx
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0x5030
movq %rax, %r15
movq %rax, 0x40(%rbx)
testq %r12, %r12
je 0x85a6
addq $0x8, %r15
movq $0x0, -0x8(%r15)
movl $0x18, %edi
callq 0x5280
movq %rax, 0x8(%rax)
movq %rax, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, (%r15)
addq $0x10, %r15
decq %r12
jne 0x8579
movl $0x58, %edi
callq 0x5280
movq %rax, %r15
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq -0x40(%rbp), %rdi
callq 0x7096
movzbl %r14b, %edx
leaq -0x40(%rbp), %rsi
movq %r15, %rdi
callq 0xa240
movq %r15, 0x70(%rbx)
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x85fd
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x5290
movq 0x70(%rbx), %r15
movq %r15, %rdi
callq 0x9aea
movq 0x70(%rbx), %rdi
testb %al, %al
je 0x8619
movl $0x77, %esi
callq 0xa438
jmp 0x8621
movzwl (%rbx), %esi
callq 0xa2d0
movq 0x70(%rbx), %rax
movl 0x4c(%rax), %eax
movq %rax, 0x78(%rbx)
movq $0x0, 0x80(%rbx)
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x8661
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x5290
jmp 0x8661
movq %rax, %r14
movl $0x58, %esi
movq %r15, %rdi
callq 0x5290
jmp 0x8683
movq %rax, %r14
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
jne 0x869c
jmp 0x86a8
jmp 0x8680
movq %rax, %r14
leaq 0x50(%rbx), %rdi
callq 0x6f9a
movq 0x8(%rbx), %rdi
addq $0x18, %rbx
movq %rbx, %r12
cmpq %rbx, %rdi
je 0x86a8
movq (%r12), %rsi
incq %rsi
callq 0x5290
movq %r14, %rdi
callq 0x54e0