// File: /workspace/github_cpp_makefile_star2_O2/MITRECND[P]snugglefish/src/nGramBase.cpp
// Function: snugglefish::nGramBase::nGramBase(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
nGramBase::nGramBase( uint32_t ngramLength, string indexFileName)
    {

    if(ngramLength == 3 || ngramLength == 4){
        this->ngramLength = ngramLength;
        this->maxNgram = (uint64_t) (1) << (8*ngramLength);
    }
    else {
        throw std::runtime_error("Ngram len must be 3 or 4");
    }



    size_t pos;
    string baseFileName = indexFileName;
    // Check to see if the index file ends with any of the extentions we use
    // And if so, remove them to get the base filename
    pos = baseFileName.rfind( NGRAM_FILE_EXTENSION );
    // Make sure that it is at the end of the string
    if(pos == (baseFileName.size() - 6)){
        baseFileName = baseFileName.substr(0, pos);
    } else{
        pos = baseFileName.rfind( INDEX_FILE_EXTENSION );
        if(pos == (baseFileName.size() - 6)){
            baseFileName = baseFileName.substr(0, pos);
        } else{
            pos = baseFileName.rfind( FILEID_FILE_EXTENSION );
            if(pos == (baseFileName.size() - 6)){
            baseFileName = baseFileName.substr(0, pos);
            }
        }
    }


    this->baseFileName = baseFileName;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
leaq 0x18(%rdi), %rax
movq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
leaq 0x8(%rdi), %rbx
movb $0x0, 0x18(%rdi)
leal -0x3(%rsi), %eax
cmpl $0x1, %eax
ja 0x7e47
movb %sil, 0x28(%rdi)
shll $0x3, %esi
pushq $0x1
popq %rax
movl %esi, %ecx
shlq %cl, %rax
movq %rax, 0x30(%rdi)
leaq -0x38(%rbp), %rdi
movq %rdx, %rsi
callq 0x6370
leaq 0x3970(%rip), %rsi      # 0xb6ec
leaq -0x38(%rbp), %rdi
pushq $-0x1
popq %rdx
callq 0x6470
movq -0x30(%rbp), %rcx
addq $-0x6, %rcx
cmpq %rcx, %rax
jne 0x7da9
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x62a0
jmp 0x7e0f
leaq 0x3943(%rip), %rsi      # 0xb6f3
leaq -0x38(%rbp), %rdi
pushq $-0x1
popq %rdx
callq 0x6470
movq -0x30(%rbp), %rcx
addq $-0x6, %rcx
cmpq %rcx, %rax
jne 0x7ddd
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x62a0
jmp 0x7e0f
leaq 0x3916(%rip), %rsi      # 0xb6fa
leaq -0x38(%rbp), %rdi
pushq $-0x1
popq %rdx
callq 0x6470
movq -0x30(%rbp), %rcx
addq $-0x6, %rcx
cmpq %rcx, %rax
jne 0x7e27
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x62a0
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %r14
movq %r14, %rsi
callq 0x6310
movq %r14, %rdi
callq 0x60f0
leaq -0x38(%rbp), %rsi
movq %rbx, %rdi
callq 0x6150
leaq -0x38(%rbp), %rdi
callq 0x60f0
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x6120
movq %rax, %r15
leaq 0x387a(%rip), %rsi      # 0xb6d3
movq %rax, %rdi
callq 0x60c0
movq 0x7188(%rip), %rsi      # 0xeff0
movq 0x7139(%rip), %rdx      # 0xefa8
movq %r15, %rdi
callq 0x6480
jmp 0x7e91
jmp 0x7e91
jmp 0x7e91
jmp 0x7e8c
movq %rax, %r14
movq %r15, %rdi
callq 0x61d0
jmp 0x7e9d
movq %rax, %r14
jmp 0x7e9d
movq %rax, %r14
leaq -0x38(%rbp), %rdi
callq 0x60f0
movq %rbx, %rdi
callq 0x60f0
movq %r14, %rdi
callq 0x64b0
nopl (%rax)