// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x40, %rsp
leaq 0x8(%rdi), %rbx
leaq 0x18(%rdi), %r12
movq %r12, 0x8(%rdi)
movq $0x0, 0x10(%rdi)
movb $0x0, 0x18(%rdi)
leal -0x3(%rsi), %eax
cmpl $0x1, %eax
ja 0x786f
movb %sil, 0x28(%rdi)
shll $0x3, %esi
movl $0x1, %eax
movl %esi, %ecx
shlq %cl, %rax
movq %rax, 0x30(%rdi)
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq -0x40(%rbp), %rdi
callq 0x7096
leaq 0x3f82(%rip), %rsi      # 0xb6ec
leaq -0x40(%rbp), %r14
movl $0x6, %ecx
movq %r14, %rdi
movq $-0x1, %rdx
callq 0x5380
movq 0x8(%r14), %rcx
addq $-0x6, %rcx
cmpq %rcx, %rax
jne 0x77a3
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x52a0
jmp 0x7819
leaq 0x3f49(%rip), %rsi      # 0xb6f3
movl $0x6, %ecx
movq %r14, %rdi
movq $-0x1, %rdx
callq 0x5380
movq 0x8(%r14), %rcx
addq $-0x6, %rcx
cmpq %rcx, %rax
jne 0x77df
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x52a0
jmp 0x7819
leaq 0x3f14(%rip), %rsi      # 0xb6fa
movl $0x6, %ecx
movq %r14, %rdi
movq $-0x1, %rdx
callq 0x5380
movq 0x8(%r14), %rcx
addq $-0x6, %rcx
cmpq %rcx, %rax
jne 0x7841
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x52a0
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %r14
movq %r14, %rsi
callq 0x5320
movq (%r14), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x7841
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x5290
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x5140
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x7862
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x5290
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x5110
movq %rax, %r15
leaq 0x3e50(%rip), %rsi      # 0xb6d3
movq %rax, %rdi
callq 0x50d0
movq 0x775e(%rip), %rsi      # 0xeff0
movq 0x770f(%rip), %rdx      # 0xefa8
movq %r15, %rdi
callq 0x54b0
jmp 0x78b6
jmp 0x78b6
jmp 0x78b6
jmp 0x78d0
movq %rax, %r14
movq %r15, %rdi
callq 0x51d0
jmp 0x78d3
movq %rax, %r14
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x78d3
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x5290
jmp 0x78d3
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x78e7
movq (%r12), %rsi
incq %rsi
callq 0x5290
movq %r14, %rdi
callq 0x54e0
nop