LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/changliu00[P]ascii-animation/ascii-anim.cpp
// Function: Scale::act(Obj*)
void Scale::act(Obj* p) {
	if(tlim.first < TimeNow && TimeNow < tlim.second) {
		if(motor_type == Type::incre) p->scale(motor(TimeNow - tlim.first));
		else {
			state2 = motor(TimeNow - tlim.first);
			p->scale(state2 / state1);
			state1 = state2;
		}
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movss 0x8(%rdi), %xmm1
movss 0xdd97(%rip), %xmm0     # 0x151d4
ucomiss %xmm1, %xmm0
jbe 0x74ba
movq %rdi, %r14
movss 0xc(%rdi), %xmm2
ucomiss %xmm0, %xmm2
jbe 0x74ba
movq %rsi, %rbx
cmpl $0x0, 0x30(%r14)
subss %xmm1, %xmm0
je 0x749a
movss %xmm0, 0x4(%rsp)
cmpq $0x0, 0x20(%r14)
je 0x74c2
leaq 0x10(%r14), %rdi
leaq 0x4(%rsp), %rsi
callq *0x28(%r14)
movss %xmm0, 0x38(%r14)
divss 0x34(%r14), %xmm0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x58(%rax)
movss 0x38(%r14), %xmm0
movss %xmm0, 0x34(%r14)
jmp 0x74ba
movss %xmm0, (%rsp)
cmpq $0x0, 0x20(%r14)
je 0x74c2
leaq 0x10(%r14), %rdi
movq %rsp, %rsi
callq *0x28(%r14)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x58(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x30a0
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/snugglefish.cpp
// Function: cpu_count()
uint32_t cpu_count(){
    long procs = -1;

    //This only works on some *nixes TODO figure out which systems don't support this call
    procs = sysconf(_SC_NPROCESSORS_ONLN);
    if (procs < 1){
        cerr << "Unable to get CPU count, defaulting to 1 -- Error: " 
             << strerror(errno) << endl;
        return 1;
    }
    return (uint32_t) procs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl $0x54, %edi
callq 0x5180
testq %rax, %rax
jg 0x58e4
movq 0x978b(%rip), %rbx      # 0xefe8
leaq 0x581c(%rip), %rsi      # 0xb080
movl $0x33, %edx
movq %rbx, %rdi
callq 0x52c0
callq 0x5050
movl (%rax), %edi
callq 0x50a0
testq %rax, %rax
je 0x58a1
movq %rax, %r14
movq %rax, %rdi
callq 0x50f0
movq 0x9754(%rip), %rdi      # 0xefe8
movq %r14, %rsi
movq %rax, %rdx
callq 0x52c0
jmp 0x58b8
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x54a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51a0
movl $0x1, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/snugglefish.cpp
// Function: handler(int)
void handler(int sig) {
  void *array[10];
  int size;

  // get void*'s for all entries on the stack
  size = backtrace(array, 10);

  // print out all the frames to stderr
  fprintf(stderr, "Error: signal %d:\n", sig);
  backtrace_symbols_fd(array, size, 2);
  exit(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x58, %rsp
movl %edi, %ebx
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x53e0
movl %eax, %r15d
movq 0x96a5(%rip), %rax      # 0xefb8
movq (%rax), %rdi
leaq 0x5797(%rip), %rsi      # 0xb0b4
movl %ebx, %edx
xorl %eax, %eax
callq 0x53a0
movq %r14, %rdi
movl %r15d, %esi
movl $0x2, %edx
callq 0x5420
movl $0x1, %edi
callq 0x5300
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/snugglefish.cpp
// Function: search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int, unsigned int)
vector<string>* search(string indexFileName, string searchString, uint32_t ngramSize, uint32_t threads){
	vector<string>* ret;
	nGramSearch searcher(ngramSize, indexFileName, threads);
    vector<uint64_t>* ngrams = searcher.stringToNGrams(searchString);
	ret = searcher.searchNGrams(*ngrams);

    delete ngrams;
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %ecx, %r14d
movl %edx, %r15d
movq %rsi, %rbx
leaq -0x70(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %r12
movq %r12, %rdi
callq 0x7090
leaq -0xd0(%rbp), %rdi
movl %r15d, %esi
movq %r12, %rdx
movl %r14d, %ecx
callq 0x7a4a
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x6a65
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x5290
leaq -0x50(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %rdi
callq 0x7090
leaq -0xd0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x7be2
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r14, %rdi
je 0x6aa8
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x5290
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x7010
leaq -0xd0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x7cac
movq %rax, %r14
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x6adc
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x5290
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x6af0
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x5290
movl $0x18, %esi
movq %rbx, %rdi
callq 0x5290
leaq -0xd0(%rbp), %rdi
callq 0x7b98
movq %r14, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x6b6a
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
jmp 0x6b46
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r14, %rdi
je 0x6b6a
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x5290
jmp 0x6b6a
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x6b76
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x5290
jmp 0x6b76
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x7b98
movq %rbx, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/snugglefish.cpp
// Function: printStats(snugglefish::nGramIndex*, unsigned long, unsigned long)
void printStats(nGramIndex* indexer, uint64_t processed, uint64_t listsize){
    uint64_t total;
    uint64_t session;
    uint64_t indexes;
    bool flushing;
    indexer->getStats(total, session, indexes, flushing);

    uint64_t percent = ((double) processed / listsize) * 100;

    cerr << "\r";
    cerr << "Processed: " << percent << "% -- " << processed << "/" << listsize;

    if(flushing){
        cerr << " (Flushing ... )"; 
    }else{
        cerr << "                "; 
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r15
leaq -0x48(%rbp), %rsi
leaq -0x40(%rbp), %rdx
leaq -0x38(%rbp), %rcx
leaq -0x29(%rbp), %r14
movq %r14, %r8
callq 0x8a98
movq %r15, %xmm0
movq 0x4496(%rip), %xmm1     # 0xb050
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x449a(%rip), %xmm2     # 0xb060
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %rbx, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
mulsd 0x4475(%rip), %xmm3     # 0xb070
cvttsd2si %xmm3, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x4469(%rip), %xmm3     # 0xb078
cvttsd2si %xmm3, %r13
andq %rcx, %r13
orq %rax, %r13
movq 0x83c7(%rip), %r12      # 0xefe8
leaq 0x4a17(%rip), %rsi      # 0xb63f
movl $0x1, %edx
movq %r12, %rdi
callq 0x52c0
leaq 0x4a05(%rip), %rsi      # 0xb641
movl $0xb, %edx
movq %r12, %rdi
callq 0x52c0
movq %r12, %rdi
movq %r13, %rsi
callq 0x5190
movq %rax, %r13
leaq 0x49ef(%rip), %rsi      # 0xb64d
movl $0x5, %edx
movq %rax, %rdi
callq 0x52c0
movq %r13, %rdi
movq %r15, %rsi
callq 0x5190
movq %rax, %r15
leaq 0x49d3(%rip), %rsi      # 0xb653
movl $0x1, %edx
movq %rax, %rdi
callq 0x52c0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5190
leaq 0x49b6(%rip), %rax      # 0xb655
leaq 0x49c0(%rip), %rsi      # 0xb666
cmpb $0x0, (%r14)
cmovneq %rax, %rsi
movl $0x10, %edx
movq %r12, %rdi
callq 0x52c0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/snugglefish.cpp
// Function: indexerThread(void*)
void* indexerThread(void* input){
    mi_data* midata = (mi_data*) input;
    nGramIndex* ngramindex = (nGramIndex*) midata->ngramindex;
    fileIndexer indexer(midata->ngramSize);

    while(1){
        pthread_mutex_lock(& midata->filesMutex);
        if (midata->queue >= midata->fileList->size()){
            pthread_mutex_unlock(& midata->filesMutex);
            break;
        }
        uint32_t i = midata->queue++; 
        pthread_mutex_unlock(& midata->filesMutex); 

        try{
            vector<uint32_t>* processedFile = indexer.processFile((*(midata->fileList))[i].c_str());
            if(processedFile != 0){
                pthread_mutex_lock(& midata->nGramIndexMutex);
                ngramindex->addNGrams(processedFile, (*(midata->fileList))[i]);
                pthread_mutex_unlock(& midata->nGramIndexMutex);
            }
        }catch(exception& e){
            cout << "Error in thread:" << e.what() << endl;
            handler(SIGSEGV);
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movq %rax, -0x50(%rbp)
movzbl 0x18(%rdi), %esi
leaq -0x70(%rbp), %rdi
callq 0x8b14
leaq 0x20(%rbx), %r15
movq %r15, %rdi
callq 0x53d0
movl 0x8(%rbx), %r13d
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x5, %rcx
cmpq %r13, %rcx
jbe 0x6dcf
leaq 0x48(%rbx), %r12
movl %r13d, %eax
incl %eax
movl %eax, 0x8(%rbx)
movq %r15, %rdi
callq 0x5200
movq (%rbx), %rax
movq (%rax), %rax
shlq $0x5, %r13
movq (%rax,%r13), %rsi
leaq -0x70(%rbp), %rdi
callq 0x8b94
movq %rax, %r14
testq %rax, %rax
je 0x6da9
movq %r12, %rdi
callq 0x53d0
movq (%rbx), %rax
movq (%rax), %rax
leaq -0x38(%rbp), %rcx
movq %rcx, -0x48(%rbp)
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
addq %rsi, %rdx
leaq -0x48(%rbp), %rdi
callq 0x7090
movq -0x50(%rbp), %rdi
movq %r14, %rsi
leaq -0x48(%rbp), %rdx
callq 0x87cc
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x6da1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x5290
movq %r12, %rdi
callq 0x5200
movq %r15, %rdi
callq 0x53d0
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
movl 0x8(%rbx), %r13d
sarq $0x5, %rcx
movl %r13d, %eax
cmpq %r13, %rcx
ja 0x6d21
movq %r15, %rdi
callq 0x5200
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r14
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x6e0f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x5290
jmp 0x6e0f
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0x6e6a
movq %rbx, %rdi
callq 0x50e0
movq %rax, %rbx
movq 0x8189(%rip), %rdi      # 0xefb0
leaq 0x4849(%rip), %rsi      # 0xb677
movl $0x10, %edx
callq 0x52c0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq 0x8168(%rip), %rdi      # 0xefb0
movq %rax, %rsi
callq 0x5270
movq %rax, %rdi
callq 0x5100
movl $0xb, %edi
callq 0x58e9
movq %rax, %rbx
callq 0x5460
movq %rbx, %rdi
callq 0x54e0
movq %rax, %rdi
callq 0x7002
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramSearch.cpp
// Function: snugglefish::nGramSearch::nGramSearch(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
nGramSearch::nGramSearch( uint32_t ngramLength, string indexFileName)
    :nGramBase(ngramLength, indexFileName),numThreads(1) {

    masterFile = new smFile(baseFileName, ngramLength);

    if (!masterFile->exists()){
        //some error
    }else{
        masterFile->open('r');
    }


    numIndexFiles = masterFile->getNumIndexFiles();
    numFiles = masterFile->getNumFiles();
}

// 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 0x7090
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x7710
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x7957
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x5290
movl $0x1, 0x38(%rbx)
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 0x7090
movzbl %r14b, %edx
leaq -0x40(%rbp), %rsi
movq %r15, %rdi
callq 0xa240
movq %r15, 0x40(%rbx)
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x79b1
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x5290
movq 0x40(%rbx), %rdi
callq 0x9af0
testb %al, %al
je 0x79cc
movq 0x40(%rbx), %rdi
movl $0x72, %esi
callq 0xa438
movq 0x40(%rbx), %rax
movl 0x48(%rax), %ecx
movl %ecx, 0x48(%rbx)
movl 0x4c(%rax), %eax
movl %eax, 0x4c(%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 0x7a06
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x5290
jmp 0x7a06
movq %rax, %r14
movl $0x58, %esi
movq %r15, %rdi
callq 0x5290
jmp 0x7a26
movq %rax, %r14
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
jne 0x7a36
jmp 0x7a42
movq %rax, %r14
movq 0x8(%rbx), %rdi
addq $0x18, %rbx
movq %rbx, %r12
cmpq %rbx, %rdi
je 0x7a42
movq (%r12), %rsi
incq %rsi
callq 0x5290
movq %r14, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramSearch.cpp
// Function: snugglefish::nGramSearch::nGramSearch(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int)
nGramSearch::nGramSearch( uint32_t ngramLength, string indexFileName, uint32_t threads)
    :nGramBase(ngramLength, indexFileName),numThreads(threads) {

    masterFile = new smFile(baseFileName, ngramLength);

    if (!masterFile->exists()){
        //some error
    }else{
        masterFile->open('r');
    }


    numIndexFiles = masterFile->getNumIndexFiles();
    numFiles = masterFile->getNumFiles();
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %r15d
movl %esi, %r14d
movq %rdi, %rbx
leaq -0x58(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %r12
movq %r12, %rdi
callq 0x7090
movq %rbx, %rdi
movl %r14d, %esi
movq %r12, %rdx
callq 0x7710
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x7aa5
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x5290
movl %r15d, 0x38(%rbx)
movl $0x58, %edi
callq 0x5280
movq %rax, %r15
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq -0x48(%rbp), %rdi
callq 0x7090
movzbl %r14b, %edx
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0xa240
movq %r15, 0x40(%rbx)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x7afc
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x5290
movq 0x40(%rbx), %rdi
callq 0x9af0
testb %al, %al
je 0x7b17
movq 0x40(%rbx), %rdi
movl $0x72, %esi
callq 0xa438
movq 0x40(%rbx), %rax
movl 0x48(%rax), %ecx
movl %ecx, 0x48(%rbx)
movl 0x4c(%rax), %eax
movl %eax, 0x4c(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x7b53
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x5290
jmp 0x7b53
movq %rax, %r14
movl $0x58, %esi
movq %r15, %rdi
callq 0x5290
jmp 0x7b73
movq %rax, %r14
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
jne 0x7b83
jmp 0x7b8f
movq %rax, %r14
movq 0x8(%rbx), %rdi
addq $0x18, %rbx
movq %rbx, %r13
cmpq %rbx, %rdi
je 0x7b8f
movq (%r13), %rsi
incq %rsi
callq 0x5290
movq %r14, %rdi
callq 0x54e0
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramSearch.cpp
// Function: snugglefish::nGramSearch::stringToNGrams(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<uint64_t>* nGramSearch::stringToNGrams(string searchString){
    uint64_t nGram;
    vector <uint64_t>* ngrams = new vector<uint64_t>;


    for(size_t i = 0; i + ngramLength - 1 < searchString.length(); i++){
        nGram = 0;
        for(size_t j = 0; j < ngramLength; j++){
	    // (1 << (8*j)) is equivalent to pow(256,j)
            nGram += (unsigned char)searchString[i+j] * (1 << (8*j));
        }
        ngrams->push_back(nGram);
    }

    return ngrams;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0x18, %edi
callq 0x5280
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movzbl 0x28(%r14), %eax
leaq -0x1(%rax), %rcx
cmpq 0x8(%rbx), %rcx
jae 0x7c9a
xorl %r13d, %r13d
leaq -0x30(%rbp), %r12
movq $0x0, -0x30(%rbp)
testq %rax, %rax
je 0x7c5f
movq -0x30(%rbp), %rdx
movq (%rbx), %rsi
addq %r13, %rsi
shlq $0x3, %rax
xorl %ecx, %ecx
movzbl (%rsi), %edi
shll %cl, %edi
movslq %edi, %rdi
addq %rdi, %rdx
movq %rdx, -0x30(%rbp)
addq $0x8, %rcx
incq %rsi
cmpq %rcx, %rax
jne 0x7c44
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x7c7a
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r15)
jmp 0x7c85
movq %r15, %rdi
movq %r12, %rdx
callq 0x83ba
leaq 0x1(%r13), %rcx
movzbl 0x28(%r14), %eax
addq %rax, %r13
cmpq 0x8(%rbx), %r13
movq %rcx, %r13
jb 0x7c27
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramSearch.cpp
// Function: snugglefish::nGramSearch::orderNGrams[abi:cxx11](snugglefish::indexSet*, std::vector<unsigned long, std::allocator<unsigned long>> const&)
list< pair<uint64_t, size_t> > nGramSearch::orderNGrams(indexSet* index, const vector<uint64_t> & nGramQuery){
    bool nomatch = false;
    list< pair<uint64_t, size_t> > queryList;
    for(uint32_t j = 0; j < nGramQuery.size(); j++){
        size_t numfiles = index->getNGramCount(nGramQuery[j]);
        //index_entry* index_table = (index_entry*) (indexEntries + (nGramQuery[j] * (INDEX_ENTRY_SIZE)));

        if(numfiles == 0){
            nomatch = true;
            break;
            //No Files Match
        }

        if(queryList.empty()){
            queryList.push_back(pair<uint64_t,size_t>(nGramQuery[j], numfiles));
        }else{
            bool placed = false;
            for (list< pair<uint64_t, size_t> >::iterator it = queryList.begin(); 
              it != queryList.end(); it++ ){
                if((*it).second > numfiles){
                    queryList.insert(it, pair<uint64_t, size_t>(nGramQuery[j], numfiles));
                    placed = true;
                    break;
                }
            }
            if (!placed){
                queryList.push_back(pair<uint64_t,size_t>(nGramQuery[j], numfiles));
            }
        }
    }

    if (nomatch){
        queryList.clear();
    }

    return queryList;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, -0x40(%rbp)
movq %rdi, %rbx
movq %rdi, 0x8(%rdi)
movq %rdi, (%rdi)
movq $0x0, 0x10(%rdi)
movq (%rdx), %rax
cmpq %rax, 0x8(%rdx)
je 0x81ae
movq %rdx, %r14
xorl %r15d, %r15d
movq $0x0, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq (%rax,%r15,8), %rsi
movq -0x40(%rbp), %rdi
callq 0xa20e
movq %rax, %r12
testq %rax, %rax
je 0x8127
movq (%rbx), %r13
cmpq %rbx, %r13
je 0x812f
cmpq %r12, 0x18(%r13)
ja 0x8155
movq (%r13), %r13
cmpq %rbx, %r13
jne 0x80f7
movq (%r14), %rax
movq (%rax,%r15,8), %r14
movl $0x20, %edi
callq 0x5280
movq %r14, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %rax, %rdi
movq %rbx, %rsi
jmp 0x8174
movb $0x1, %al
movq %rax, -0x38(%rbp)
jmp 0x8181
movq (%r14), %rax
movq (%rax,%r15,8), %r13
movl $0x20, %edi
callq 0x5280
movq %r13, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5060
jmp 0x817d
movq (%r14), %rax
movq (%rax,%r15,8), %r14
movl $0x20, %edi
callq 0x5280
movq %r14, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %rax, %rdi
movq %r13, %rsi
callq 0x5060
movq -0x30(%rbp), %r14
incq 0x10(%rbx)
testq %r12, %r12
je 0x81a0
incl %r15d
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x80da
testb $0x1, -0x38(%rbp)
je 0x81ae
movq %rbx, %rdi
callq 0x837e
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x81c6
jmp 0x81c6
jmp 0x81c6
movq %rax, %r14
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x81e6
movq (%rdi), %r15
movl $0x20, %esi
callq 0x5290
movq %r15, %rdi
cmpq %rbx, %r15
jne 0x81d1
movq %r14, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramIndex.cpp
// Function: snugglefish::nGramIndex::~nGramIndex()
nGramIndex::~nGramIndex(){
    
	this->flushAll();
	for(uint64_t i = 0; i < maxNgram; i++){
		delete this->output_buffer[i].elements;
	}
	delete[] output_buffer;    

    delete masterFile;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
callq 0x878a
cmpq $0x0, 0x30(%rbx)
je 0x8723
xorl %r15d, %r15d
movq 0x40(%rbx), %rax
movq %r15, %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %r14
testq %r14, %r14
je 0x871a
movq (%r14), %rdi
cmpq %r14, %rdi
je 0x870d
movq (%rdi), %r12
movl $0x18, %esi
callq 0x5290
movq %r12, %rdi
cmpq %r14, %r12
jne 0x86f8
movl $0x18, %esi
movq %r14, %rdi
callq 0x5290
incq %r15
cmpq 0x30(%rbx), %r15
jb 0x86db
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x8731
callq 0x5340
movq 0x70(%rbx), %r14
testq %r14, %r14
je 0x874f
movq %r14, %rdi
callq 0xa278
movl $0x58, %esi
movq %r14, %rdi
callq 0x5290
leaq 0x50(%rbx), %rdi
callq 0x6f98
movq 0x8(%rbx), %rdi
addq $0x18, %rbx
cmpq %rbx, %rdi
je 0x8778
movq (%rbx), %rsi
incq %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5290
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0x7002
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramIndex.cpp
// Function: snugglefish::nGramIndex::flushAll()
void nGramIndex::flushAll(){
    flushing = true;
    if(fileNameList.size()){
        ngram_t_indexfcount num_files = fileNameList.size();
        //By updating the master file last, this set can be queried
        //while creating a new index set
        flushIndex(num_files);
        flushMaster();

        numSessionFilesProcessed += num_files;
    }
    flushing = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movb $0x1, 0x69(%rdi)
movq 0x58(%rdi), %r14
subq 0x50(%rdi), %r14
je 0x87c3
sarq $0x5, %r14
movq %rbx, %rdi
movl %r14d, %esi
callq 0x8904
movq %rbx, %rdi
callq 0x8a22
movl %r14d, %eax
addq %rax, 0x80(%rbx)
movb $0x0, 0x69(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramIndex.cpp
// Function: snugglefish::nGramIndex::addNGrams(std::vector<unsigned int, std::allocator<unsigned int>>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void nGramIndex::addNGrams(vector<uint32_t>* nGramList, string filename){
    //POSIX basename may modify argument so create a copy
    char* temp_filename = new char[filename.length() + 1];
    strncpy(temp_filename, filename.c_str(), filename.length() + 1);
    filename = basename(temp_filename);
    delete[] temp_filename;

    ngram_t_fidtype file_id = numFilesProcessed++;
    fileNameList.push_back(filename);

    // Insert ngram into the list, add the new node to the memory usage variable,
    // and check if the maximum memory has been used, and if so, indicate that the
    // nGrams should be flushed to disk
    for(uint32_t i = 0; i < nGramList->size(); i++){
        uint32_t nGram = (*nGramList)[i];
        output_buffer[nGram].elements_size++;
        output_buffer[nGram].elements->push_back(file_id);

        buffer_memory_usage += BUFFER_NODE_SIZE; //Add size of node

        if(buffer_memory_usage >= bufferMax){ 
            flush = true;
        }
    }

    //We cleanup the memory
    delete nGramList;

    if (flush){
        flushAll();
        flush = false;
    }


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rdx), %r13
incq %r13
movq %r13, %rdi
callq 0x5030
movq %rax, %r12
movq (%r15), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x5120
movq %r12, %rdi
callq 0x54c0
movq %rax, %r13
movq 0x8(%r15), %rax
movq %rax, -0x30(%rbp)
movq %r13, %rdi
callq 0x50f0
movq %r15, %rdi
xorl %esi, %esi
movq -0x30(%rbp), %rdx
movq %r13, %rcx
movq %rax, %r8
callq 0x5410
movq %r12, %rdi
callq 0x5340
movq 0x78(%rbx), %r12
leaq 0x1(%r12), %rax
movq %rax, 0x78(%rbx)
leaq 0x50(%rbx), %rdi
movq %r15, %rsi
callq 0x6eb8
movq (%r14), %rdi
cmpq %rdi, 0x8(%r14)
je 0x88c4
movl $0x1, %r13d
xorl %eax, %eax
movl (%rdi,%rax,4), %eax
movq 0x40(%rbx), %rcx
shlq $0x4, %rax
incq (%rcx,%rax)
movq 0x8(%rcx,%rax), %r15
movl $0x18, %edi
callq 0x5280
movl %r12d, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x5060
incq 0x10(%r15)
movq 0x48(%rbx), %rax
addq $0x1c, %rax
movq %rax, 0x48(%rbx)
cmpq 0x38(%rbx), %rax
jb 0x88ab
movb $0x1, 0x68(%rbx)
movl %r13d, %eax
movq (%r14), %rdi
movq 0x8(%r14), %rcx
subq %rdi, %rcx
sarq $0x2, %rcx
incl %r13d
cmpq %rax, %rcx
ja 0x8864
testq %rdi, %rdi
je 0x88d5
movq 0x10(%r14), %rsi
subq %rdi, %rsi
callq 0x5290
movl $0x18, %esi
movq %r14, %rdi
callq 0x5290
cmpb $0x1, 0x68(%rbx)
jne 0x88f4
movq %rbx, %rdi
callq 0x878a
movb $0x0, 0x68(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramIndex.cpp
// Function: snugglefish::nGramIndex::flushIndex(unsigned int)
void nGramIndex::flushIndex(ngram_t_indexfcount num_files){
    //Create the files
    indexSet* tIndex = new indexSet(baseFileName.c_str(), masterFile->getNumIndexFiles(), ngramLength);
    tIndex->create(num_files);

    uint64_t bytes_flushed = 0;

    for(uint32_t i = 0; i < maxNgram; i++){ //iterate through every ngram
        bytes_flushed += output_buffer[i].elements_size * sizeof(ngram_t_fidtype);
        tIndex->addNGrams(i, this->output_buffer[i].elements);
        output_buffer[i].elements_size = 0;

        if (output_buffer[i].elements->size() != 0)
            cout << "Not Zero" << endl;
    }

    buffer_memory_usage = 0;

    tIndex->close();
    delete tIndex;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %r14
movl $0x68, %edi
callq 0x5280
movq %rax, %rbx
movq 0x8(%r14), %rsi
movq 0x70(%r14), %rax
movl 0x48(%rax), %edx
movzbl 0x28(%r14), %ecx
movq %rbx, %rdi
callq 0x9b18
movq %rbx, %rdi
movl %r15d, %esi
callq 0x9c5a
cmpq $0x0, 0x30(%r14)
je 0x89d7
xorl %r13d, %r13d
movq 0x6653(%rip), %r15      # 0xefb0
xorl %r12d, %r12d
movq 0x40(%r14), %rax
shlq $0x4, %r13
movq 0x8(%rax,%r13), %rdx
movq %rbx, %rdi
movl %r12d, %esi
callq 0xa162
movq 0x40(%r14), %rax
movq $0x0, (%rax,%r13)
movq 0x8(%rax,%r13), %rax
cmpq $0x0, 0x10(%rax)
je 0x89cb
movl $0x8, %edx
movq %r15, %rdi
leaq 0x2d62(%rip), %rsi      # 0xb701
callq 0x52c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5260
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51a0
incl %r12d
movq %r12, %r13
cmpq %r12, 0x30(%r14)
ja 0x8960
movq $0x0, 0x48(%r14)
movq %rbx, %rdi
callq 0x9be6
movq %rbx, %rdi
callq 0x9b5c
movl $0x68, %esi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5290
movq %rax, %r14
movl $0x68, %esi
movq %rbx, %rdi
callq 0x5290
movq %r14, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramIndex.cpp
// Function: snugglefish::nGramIndex::flushMaster()
void nGramIndex::flushMaster(){
    //Write FileNames to File ID file
    ngram_t_indexfcount num_files = (ngram_t_indexfcount) fileNameList.size();

    if (!num_files){
        return;
    }

    for(unsigned long i = 0; i < num_files; i++){
        masterFile->addFileId(fileNameList[i].c_str());
    }

    //Clear the vector
    fileNameList.clear();

    //Update filid with new value
    masterFile->updateIndexFileCount(masterFile->getNumIndexFiles() + 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x58(%rdi), %rax
subq 0x50(%rdi), %rax
shrq $0x5, %rax
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
andq %rax, %r15
je 0x8a8e
movq %rdi, %rbx
leaq 0x50(%rdi), %r14
shlq $0x5, %r15
xorl %r12d, %r12d
movq 0x50(%rbx), %rax
movq 0x70(%rbx), %rdi
movq (%rax,%r12), %rsi
callq 0xa544
addq $0x20, %r12
cmpq %r12, %r15
jne 0x8a52
movq 0x50(%rbx), %rsi
movq %r14, %rdi
callq 0x8ac0
movq 0x70(%rbx), %rdi
movl 0x48(%rdi), %esi
incl %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xa59c
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/nGramIndex.cpp
// Function: snugglefish::nGramIndex::getStats(unsigned long&, unsigned long&, unsigned long&, bool&)
void nGramIndex::getStats(uint64_t& totalFiles, uint64_t& sessionFiles, uint64_t& indexFiles, bool& flushing){
    totalFiles = masterFile->getNumFiles();
    sessionFiles = numSessionFilesProcessed;
    indexFiles = masterFile->getNumIndexFiles();
    flushing = this->flushing;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x70(%rdi), %rax
movl 0x4c(%rax), %r9d
movq %r9, (%rsi)
movq 0x80(%rdi), %rsi
movq %rsi, (%rdx)
movl 0x48(%rax), %eax
movq %rax, (%rcx)
movb 0x69(%rdi), %al
movb %al, (%r8)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/fileIndexer.cpp
// Function: snugglefish::fileIndexer::fileIndexer(unsigned char)
fileIndexer::fileIndexer(uint8_t ngramLength):
filesProcessed(0)
{

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

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq $0x0, (%rdi)
leal -0x3(%rsi), %eax
cmpb $0x1, %al
ja 0x8b4f
movq %rdi, %rbx
movzbl %sil, %ecx
movl %ecx, 0x8(%rdi)
shll $0x3, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, 0x10(%rdi)
callq 0x5510
movl %eax, 0x18(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
movl $0x10, %edi
callq 0x5110
movq %rax, %rbx
leaq 0x2ba7(%rip), %rsi      # 0xb70a
movq %rax, %rdi
callq 0x50d0
movq 0x647e(%rip), %rsi      # 0xeff0
movq 0x642f(%rip), %rdx      # 0xefa8
movq %rbx, %rdi
callq 0x54b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x51d0
movq %r14, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/fileIndexer.cpp
// Function: snugglefish::fileIndexer::processNgrams(unsigned char*, unsigned long, bool*)
void fileIndexer::processNgrams(unsigned char* buf, uint64_t fileSize, bool ngramList[]){
    //TODO update with byte array
    uint64_t nGram = 0;
    uint64_t i, j;
    for(i = 0; ((i + this->ngramLength) - 1) < fileSize; i++){
        nGram = 0;
       // creates an ngram using the formula buf[i] + buf[i+1]*256 
       // + buf[i+2]*256*256
        for(j = 0; j < this->ngramLength; j++){
            // (1 <<(8*j)) is equivalent to pow(256,j)
           nGram += (unsigned char)buf[i+j] * (1 << (8*j));
        }
        if(nGram >= this->maxNgram){
            throw std::runtime_error("Ngram greater than maxNgram");
        }
        ngramList[nGram] = 1;
    }

    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rcx, %rax
movl 0x8(%rdi), %r8d
leaq -0x1(%r8), %rcx
cmpq %rdx, %rcx
jae 0x8e2f
movq 0x10(%rdi), %rdi
subq %r8, %rdx
incq %rdx
movq %r8, %r9
shlq $0x3, %r9
xorl %r10d, %r10d
testl %r8d, %r8d
je 0x8e17
movq %rsi, %rbx
xorl %ecx, %ecx
xorl %r11d, %r11d
movzbl (%rbx), %r14d
shll %cl, %r14d
movslq %r14d, %r14
addq %r14, %r11
addq $0x8, %rcx
incq %rbx
cmpq %rcx, %r9
jne 0x8dfc
jmp 0x8e1a
xorl %r11d, %r11d
cmpq %rdi, %r11
jae 0x8e34
movb $0x1, (%rax,%r11)
incq %r10
incq %rsi
cmpq %rdx, %r10
jne 0x8def
popq %rbx
popq %r14
popq %rbp
retq
movl $0x10, %edi
callq 0x5110
movq %rax, %rbx
leaq 0x28fc(%rip), %rsi      # 0xb744
movq %rax, %rdi
callq 0x50d0
movq 0x6199(%rip), %rsi      # 0xeff0
movq 0x614a(%rip), %rdx      # 0xefa8
movq %rbx, %rdi
callq 0x54b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x51d0
movq %r14, %rdi
callq 0x54e0
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/fileIndexer.cpp
// Function: snugglefish::fileIndexer::processNgrams(unsigned char*, unsigned long)
vector<uint32_t>* fileIndexer::processNgrams(unsigned char* buf, uint64_t fileSize){
    map<uint32_t, bool> ngram_map;

    uint32_t nGram = 0;
    uint32_t i, j;

    for(i = 0; ((i + this->ngramLength) - 1) < fileSize; i++){
        nGram = 0;
        for(j = 0; j < this->ngramLength; j++){
            nGram += (unsigned char)buf[i+j] * (1 << (8*j));
        }
        if(nGram >= this->maxNgram){
            throw std::runtime_error("Ngram greater than maxNgram");
        }
        ngram_map.insert(pair<uint32_t,bool>(nGram, true));
    }

    //We should now have a map of ngrams, turn into a sorted vector
    //TODO pre-allocate vector to do this faster
    vector<uint32_t>* ngramVector = new vector<uint32_t>;
    
    for(map<uint32_t,bool>::iterator it = ngram_map.begin(); it != ngram_map.end() ; it++){
        ngramVector->push_back(it->first);
    }

    return ngramVector;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
leaq -0x58(%rbp), %rax
movl $0x0, (%rax)
xorl %r12d, %r12d
movq %r12, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %r12, 0x20(%rax)
movl 0x8(%rdi), %eax
leal -0x1(%rax), %ecx
cmpq %rdx, %rcx
jae 0x8f1e
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq -0x30(%rbp), %r13
testl %eax, %eax
je 0x8ee9
movl %eax, %edx
shlq $0x3, %rdx
xorl %ecx, %ecx
movl %r12d, %esi
xorl %eax, %eax
movl %esi, %edi
movzbl (%r14,%rdi), %edi
shll %cl, %edi
addl %edi, %eax
incl %esi
addq $0x8, %rcx
cmpq %rcx, %rdx
jne 0x8ed1
jmp 0x8eeb
xorl %eax, %eax
movl %eax, %ecx
cmpq %rcx, 0x10(%r15)
jbe 0x8f95
movl %eax, -0x30(%rbp)
movb $0x1, -0x2c(%rbp)
leaq -0x60(%rbp), %rdi
movq %r13, %rsi
callq 0x918c
leal 0x1(%r12), %ecx
movl 0x8(%r15), %eax
addl %eax, %r12d
cmpq %rbx, %r12
movl %ecx, %r12d
jb 0x8ec0
movl $0x18, %edi
callq 0x5280
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq -0x48(%rbp), %r14
leaq -0x58(%rbp), %r15
cmpq %r15, %r14
je 0x8f7a
leaq 0x20(%r14), %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x8f62
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x8f6a
movq %rbx, %rdi
callq 0x904c
movq %r14, %rdi
callq 0x51b0
movq %rax, %r14
cmpq %r15, %rax
jne 0x8f46
leaq -0x60(%rbp), %rdi
callq 0x8fee
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x5110
movq %rax, %r14
leaq 0x279b(%rip), %rsi      # 0xb744
movq %rax, %rdi
callq 0x50d0
movq 0x6038(%rip), %rsi      # 0xeff0
movq 0x5fe9(%rip), %rdx      # 0xefa8
movq %r14, %rdi
callq 0x54b0
jmp 0x8fda
jmp 0x8fda
jmp 0x8fda
movq %rax, %rbx
movq %r14, %rdi
callq 0x51d0
jmp 0x8fdd
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x8fee
movq %rbx, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/file.cpp
// Function: snugglefish::file::file(char const*, unsigned long)
file::file(const char* fileName, size_t buffersize){
    this->bufferparam = buffersize;

    this->buffer = NULL;
    this->buffersize = 0;
    this->bufferused = 0;

    this->fd = 0;
    this->mmapFile = 0;
    this->size = 0;

    this->filename = (char*) malloc(sizeof(char) * (strlen(fileName) + 1));
    strncpy(this->filename, fileName, strlen(fileName) + 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rdx, 0x38(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rdi)
movups %xmm0, 0x1c(%rdi)
movups %xmm0, 0x28(%rdi)
movq %rsi, %rdi
callq 0x50f0
leaq 0x1(%rax), %rdi
callq 0x5360
movq %rax, %r15
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x50f0
leaq 0x1(%rax), %rdx
movq %r15, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5120
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/file.cpp
// Function: snugglefish::file::~file()
file::~file(){
    //File Descriptor is not zero
    if(this->fd){
        this->close();
    }
    
    if (this->filename != NULL){
        free(this->filename);
    }

    if (this->buffer){
        free(this->buffer);
        this->buffer = NULL;
        this->buffersize = this->bufferused = 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0xc(%rdi)
je 0x935b
movq %rbx, %rdi
callq 0x9398
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x9368
callq 0x52f0
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x9388
addq $0x20, %rbx
callq 0x52f0
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rdi
callq 0x7002
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/file.cpp
// Function: snugglefish::file::close()
bool file::close(){
    if (!this->fd){ // already closed?
        return true;
    }

    this->flush(); 

    //Close the mmap if opened
    if (this->mmapFile){
        munmap(this->mmapFile, this->size); 
        this->mmapFile = 0;
        this->size = 0;
    }

    //Free the write buffer if allocated
    if (this->buffer){
        free(this->buffer);
        this->buffer = NULL;
        this->buffersize = this->bufferused = 0;
    }

    int32_t retval = ::close(this->fd);
    if(retval){//non zero
        cerr << "Error Closing File: " << this->filename << " -- Error: " << strerror(errno) << endl;
        throw runtime_error("Closing File");
    }

    this->fd = 0;

    return true;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
cmpl $0x0, 0xc(%rdi)
je 0x93fe
movq %rdi, %rbx
callq 0x9832
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x93ca
leaq 0x10(%rbx), %r14
movq 0x18(%rbx), %rsi
callq 0x5170
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x93eb
leaq 0x20(%rbx), %r14
callq 0x52f0
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movl 0xc(%rbx), %edi
callq 0x5560
testl %eax, %eax
jne 0x9405
movl $0x0, 0xc(%rbx)
movb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq
movq 0x5bdc(%rip), %r14      # 0xefe8
leaq 0x23dc(%rip), %rsi      # 0xb7ef
movl $0x14, %edx
movq %r14, %rdi
callq 0x52c0
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x5270
movq %rax, %rbx
leaq 0x1c73(%rip), %rsi      # 0xb0a8
movl $0xb, %edx
movq %rax, %rdi
callq 0x52c0
callq 0x5050
movl (%rax), %edi
callq 0x50a0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5270
movq %rax, %rdi
callq 0x5100
movl $0x10, %edi
callq 0x5110
movq %rax, %rbx
leaq 0x238f(%rip), %rsi      # 0xb804
movq %rax, %rdi
callq 0x50d0
movq 0x5b6c(%rip), %rsi      # 0xeff0
movq 0x5b1d(%rip), %rdx      # 0xefa8
movq %rbx, %rdi
callq 0x54b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x51d0
movq %r14, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/file.cpp
// Function: snugglefish::file::create(unsigned int)
bool file::create(mode_t filemode){

    if (this->bufferparam > 0){
        this->buffersize = this->bufferparam;
        this->buffer = (char*) malloc(buffersize);
    }
    this->fd = ::open(this->filename, O_RDWR | O_CREAT, filemode);
    this->readonly = false;

    if (this->fd <= 0){
        cerr << "Unable to Create File: " << filename << " -- Error: " << strerror(errno) << endl;
        throw runtime_error("Creating File");
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
movq 0x38(%rdi), %rdi
testq %rdi, %rdi
je 0x94c9
movq %rdi, 0x28(%rbx)
callq 0x5360
movq %rax, 0x20(%rbx)
movq (%rbx), %rdi
movl $0x42, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x51e0
movl %eax, 0xc(%rbx)
movb $0x0, 0x8(%rbx)
testl %eax, %eax
jle 0x94ed
movb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq
movq 0x5af4(%rip), %r14      # 0xefe8
leaq 0x2265(%rip), %rsi      # 0xb760
movl $0x17, %edx
movq %r14, %rdi
callq 0x52c0
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x5270
movq %rax, %rbx
leaq 0x1b8b(%rip), %rsi      # 0xb0a8
movl $0xb, %edx
movq %rax, %rdi
callq 0x52c0
callq 0x5050
movl (%rax), %edi
callq 0x50a0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5270
movq %rax, %rdi
callq 0x5100
movl $0x10, %edi
callq 0x5110
movq %rax, %rbx
leaq 0x221b(%rip), %rsi      # 0xb778
movq %rax, %rdi
callq 0x50d0
movq 0x5a84(%rip), %rsi      # 0xeff0
movq 0x5a35(%rip), %rdx      # 0xefa8
movq %rbx, %rdi
callq 0x54b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x51d0
movq %r14, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/file.cpp
// Function: snugglefish::file::open(char)
bool file::open(char readwrite){
    switch (readwrite){
        case 'r':
        {    
            this->fd = ::open(this->filename, O_RDONLY);
            this->size = this->get_size();
            this->readonly = true;
            break;
        }
        case 'w':
        {
            if (this->bufferparam > 0){
                this->buffersize = this->bufferparam;
                this->buffer = (char*) malloc(buffersize);
            }
            this->fd = ::open(this->filename, O_RDWR);
            this->readonly = false;
            break;
        }
        default:
            throw runtime_error("Unrecognized read/write mode");
            break;
    }

    if (this->fd <= 0){
        cerr << "Error Opening File: " << this->filename << " -- Error: " << strerror(errno) << endl;
        throw runtime_error("Opening File");
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x77, %esi
je 0x95c6
cmpl $0x72, %esi
jne 0x967c
movq (%rbx), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x51e0
movl %eax, 0xc(%rbx)
movq %rbx, %rdi
callq 0x96c4
movq %rax, 0x18(%rbx)
movb $0x1, %r14b
jmp 0x95f1
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x95dc
movq %rdi, 0x28(%rbx)
callq 0x5360
movq %rax, 0x20(%rbx)
movq (%rbx), %rdi
xorl %r14d, %r14d
movl $0x2, %esi
xorl %eax, %eax
callq 0x51e0
movl %eax, 0xc(%rbx)
movb %r14b, 0x8(%rbx)
cmpl $0x0, 0xc(%rbx)
jle 0x9602
movb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq
movq 0x59df(%rip), %r14      # 0xefe8
leaq 0x2193(%rip), %rsi      # 0xb7a3
movl $0x14, %edx
movq %r14, %rdi
callq 0x52c0
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x5270
movq %rax, %rbx
leaq 0x1a76(%rip), %rsi      # 0xb0a8
movl $0xb, %edx
movq %rax, %rdi
callq 0x52c0
callq 0x5050
movl (%rax), %edi
callq 0x50a0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5270
movq %rax, %rdi
callq 0x5100
movl $0x10, %edi
callq 0x5110
movq %rax, %rbx
leaq 0x2146(%rip), %rsi      # 0xb7b8
movq %rax, %rdi
callq 0x50d0
jmp 0x9698
movl $0x10, %edi
callq 0x5110
movq %rax, %rbx
leaq 0x20f6(%rip), %rsi      # 0xb786
movq %rax, %rdi
callq 0x50d0
movq 0x5951(%rip), %rsi      # 0xeff0
movq 0x5902(%rip), %rdx      # 0xefa8
movq %rbx, %rdi
callq 0x54b0
jmp 0x96b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x51d0
movq %r14, %rdi
callq 0x54e0
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/file.cpp
// Function: snugglefish::file::get_size()
const size_t file::get_size(){
    struct stat st;
    size_t filesize = 0;
    if (stat(this->filename, &st) == 0){
       filesize = st.st_size;
    }else{
        throw runtime_error("Statting File");
    } 

    return filesize;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq (%rdi), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x5250
testl %eax, %eax
jne 0x96f5
movq -0x70(%rbp), %rax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movl $0x10, %edi
callq 0x5110
movq %rax, %rbx
leaq 0x216d(%rip), %rsi      # 0xb876
movq %rax, %rdi
callq 0x50d0
movq 0x58d8(%rip), %rsi      # 0xeff0
movq 0x5889(%rip), %rdx      # 0xefa8
movq %rbx, %rdi
callq 0x54b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x51d0
movq %r14, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/file.cpp
// Function: snugglefish::file::mmap()
uint8_t* file::mmap(){
    //Open the file first 
    if (this->fd == 0)
        this->open('r');

    if (!this->size)
        return NULL;

    this->mmapFile = (uint8_t*) ::mmap(NULL, this->size, PROT_READ, MAP_SHARED, this->fd, 0);

    if(this->mmapFile == MAP_FAILED){
        cerr << "Error Loading Map for File : " << this->filename<< " -- Error: " << strerror(errno) << endl;
        throw runtime_error("Loading Map");
    }

    return this->mmapFile;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0xc(%rdi)
jne 0x9757
movq %rbx, %rdi
movl $0x72, %esi
callq 0x958e
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x9818
movl 0xc(%rbx), %r8d
xorl %edi, %edi
movl $0x1, %edx
movl $0x1, %ecx
xorl %r9d, %r9d
callq 0x54f0
movq %rax, 0x10(%rbx)
cmpq $-0x1, %rax
jne 0x981a
movq 0x5857(%rip), %r14      # 0xefe8
leaq 0x202d(%rip), %rsi      # 0xb7c5
movl $0x1d, %edx
movq %r14, %rdi
callq 0x52c0
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x5270
movq %rax, %rbx
leaq 0x18ee(%rip), %rsi      # 0xb0a8
movl $0xb, %edx
movq %rax, %rdi
callq 0x52c0
callq 0x5050
movl (%rax), %edi
callq 0x50a0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5270
movq %rax, %rdi
callq 0x5100
movl $0x10, %edi
callq 0x5110
movq %rax, %rbx
leaq 0x1fe9(%rip), %rsi      # 0xb7e3
movq %rax, %rdi
callq 0x50d0
movq 0x57e7(%rip), %rsi      # 0xeff0
movq 0x5798(%rip), %rdx      # 0xefa8
movq %rbx, %rdi
callq 0x54b0
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x51d0
movq %r14, %rdi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/file.cpp
// Function: snugglefish::file::flush()
bool file::flush(){
    if(this->readonly){
        return true;
    }

    if (this->bufferused){
        lseek(this->fd, 0, SEEK_END);
        this->real_write(this->fd, (uint8_t*) this->buffer, this->bufferused * sizeof(char));
        this->bufferused = 0;
    }

    return true;
}

// Assembly:
cmpb $0x0, 0x8(%rdi)
jne 0x9878
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq $0x0, 0x30(%rdi)
je 0x9872
movl 0xc(%rbx), %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0x5540
movl 0xc(%rbx), %esi
movq 0x20(%rbx), %rdx
movq 0x30(%rbx), %rcx
movq %rbx, %rdi
callq 0x987c
movq $0x0, 0x30(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
movb $0x1, %al
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/MITRECND[P]snugglefish/src/file.cpp
// Function: snugglefish::file::real_write(int, unsigned char*, unsigned long)
bool file::real_write(int fd, uint8_t* data, size_t length){
        ssize_t written = ::write(fd, data, length); 
        if (written == -1){//TODO what if partial write?
            cerr << "Unable to write to file: " << this->filename << " -- Error: " << strerror(errno) << endl;
            throw runtime_error("Write Error");
        }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl %esi, %edi
movq %rdx, %rsi
movq %rcx, %rdx
callq 0x50b0
cmpq $-0x1, %rax
je 0x98a0
movb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq
movq 0x5741(%rip), %r14      # 0xefe8
leaq 0x1f63(%rip), %rsi      # 0xb811
movl $0x19, %edx
movq %r14, %rdi
callq 0x52c0
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x5270
movq %rax, %rbx
leaq 0x17d8(%rip), %rsi      # 0xb0a8
movl $0xb, %edx
movq %rax, %rdi
callq 0x52c0
callq 0x5050
movl (%rax), %edi
callq 0x50a0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5270
movq %rax, %rdi
callq 0x5100
movl $0x10, %edi
callq 0x5110
movq %rax, %rbx
leaq 0x1f1b(%rip), %rsi      # 0xb82b
movq %rax, %rdi
callq 0x50d0
movq 0x56d1(%rip), %rsi      # 0xeff0
movq 0x5682(%rip), %rdx      # 0xefa8
movq %rbx, %rdi
callq 0x54b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x51d0
movq %r14, %rdi
callq 0x54e0
nop