// File: /workspace/github_c_makefile_star2_O2/perdisci[P]LSH/lsh.cpp
// Function: rp::LSH::load_ngrams_from_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int)
set<string> LSH::load_ngrams_from_file(const string file_name, const unsigned ngram_len) {
        
        const unsigned n = ngram_len;
        set<string> ngrams_set;
        
        std::ifstream f(file_name);
        string line;
        string prev_line;
        
        
        vector<string> last_ngram;
        while(std::getline(f,line)) {
            
            boost::trim(line);
            if(line.length()==0)
                continue;
            
            if(n>1 && !last_ngram.empty()) {
                string last_ngram_str;
                for(int i=1; i<last_ngram.size(); i++)
                    last_ngram_str += last_ngram[i] + " ";
                line = last_ngram_str + line;
            }
            else if(!prev_line.empty())
                line = prev_line + " " + line;
            
            vector<string> tokens;
            boost::algorithm::split(tokens,line,boost::algorithm::is_space());
            
            if(tokens.size() >= n) {
                for(int i=0; i<tokens.size()-n+1; i++) {
                    string ngram;
                    for(int j=i; j<(i+n); j++)
                        ngram += tokens[j] + " ";
                    boost::trim(ngram);
                    ngrams_set.insert(ngram);
                }
                
                vector<string>::const_iterator last = tokens.end();
                vector<string>::const_iterator first = tokens.end() - n;
                last_ngram = vector<string>(first,last);
                prev_line = string();
            }
            else {
                prev_line = line;
                last_ngram = vector<string>();
            }
            
        }
        
        return std::move(ngrams_set);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movl %edx, %ebx
movq %rdi, 0x70(%rsp)
leaq 0xf8(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x120(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x6500
leaq 0xc0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x40(%rsp), %r13
andq $0x0, 0x10(%r13)
xorps %xmm0, %xmm0
movaps %xmm0, (%r13)
movl %ebx, %eax
movq %rax, 0x38(%rsp)
negq %rax
leaq 0xb0(%rsp), %r15
movq %rsp, %r14
leaq 0xd0(%rsp), %r12
leaq 0x60(%rsp), %rbp
shlq $0x5, %rax
movq %rax, 0x78(%rsp)
movq %rbx, 0x80(%rsp)
leaq 0x120(%rsp), %rdi
movq %r15, %rsi
callq 0x6080
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xcfa4
movq %r14, %rdi
callq 0x6640
movq %r15, %rdi
movq %r14, %rsi
callq 0xddf7
movq %r14, %rdi
callq 0x6460
cmpq $0x0, 0xb8(%rsp)
je 0xcc82
cmpl $0x2, %ebx
jb 0xcd41
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rax
cmpq %rax, %rsi
je 0xcd41
leaq 0x10(%rsp), %rcx
movq %rcx, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
pushq $0x20
popq %r15
pushq $0x1
popq %rbp
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0xcd8e
addq %r15, %rsi
movq %r12, %rdi
leaq 0x4441(%rip), %rdx      # 0x11157
callq 0x801d
movq %r14, %rdi
movq %r12, %rsi
callq 0x6630
movq %r12, %rdi
callq 0x6658
incq %rbp
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rax
addq $0x20, %r15
jmp 0xccf9
cmpq $0x0, 0x98(%rsp)
je 0xcdc4
movq %r12, %rdi
leaq 0x90(%rsp), %rsi
leaq 0x43f9(%rip), %rdx      # 0x11157
callq 0x801d
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x7f88
movq %r15, %rdi
movq %r14, %rsi
callq 0x63b0
movq %r14, %rdi
callq 0x6658
movq %r12, %rdi
callq 0x6658
jmp 0xcdc4
movq %r12, %rdi
movq %r14, %rsi
leaq 0xb0(%rsp), %r15
movq %r15, %rdx
callq 0xde40
movq %r15, %rdi
movq %r12, %rsi
callq 0x63b0
movq %r12, %rdi
callq 0x6658
movq %r14, %rdi
callq 0x6658
leaq 0x60(%rsp), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq %r14, %rdi
callq 0x6640
movq %rbp, %rdi
movq %r14, %rsi
callq 0xdf00
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
pushq $0x1
popq %rcx
callq 0xde78
leaq 0x68(%rsp), %rdi
callq 0x6460
movq %r14, %rdi
callq 0x6460
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rdx
movq %rdx, %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq 0x38(%rsp), %rcx
jae 0xce5a
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq 0x61a0
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x10130
movq %r14, %rdi
callq 0x74e0
jmp 0xcf95
xorl %esi, %esi
xorl %r13d, %r13d
movq %rdx, %rcx
subq %rax, %rcx
sarq $0x5, %rcx
subq 0x38(%rsp), %rcx
incq %rcx
cmpq %r13, %rcx
jbe 0xcf3d
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
addl %r13d, %ebx
movq %rsi, 0x88(%rsp)
movq %rsi, %rbp
movq %r13, %r15
cmpq %rbx, %r15
jae 0xced7
movq 0x20(%rsp), %rsi
addq %rbp, %rsi
movq %r12, %rdi
leaq 0x42a1(%rip), %rdx      # 0x11157
callq 0x801d
movq %r14, %rdi
movq %r12, %rsi
callq 0x6630
movq %r12, %rdi
callq 0x6658
incq %r15
addq $0x20, %rbp
jmp 0xce9f
movq %r12, %rdi
callq 0x6640
movq %r14, %rdi
movq %r12, %rsi
callq 0xddf7
movq %r12, %rdi
callq 0x6460
leaq 0xf0(%rsp), %rdi
movq %r14, %rsi
callq 0xffa4
movq %r14, %rdi
callq 0x6658
incq %r13
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rdx
movq 0x88(%rsp), %rsi
addq $0x20, %rsi
movq 0x80(%rsp), %rbx
leaq 0xb0(%rsp), %r15
leaq 0x60(%rsp), %rbp
jmp 0xce5f
movq 0x78(%rsp), %rax
leaq (%rdx,%rax), %rsi
movq %r14, %rdi
movq %r12, %rcx
callq 0xdf18
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x10130
movq %r14, %rdi
callq 0x74e0
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0x63b0
movq %r14, %rdi
callq 0x6658
leaq 0x20(%rsp), %rdi
callq 0x74e0
jmp 0xcc82
movq 0x70(%rsp), %rbx
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0xf8(%rsp), %rsi
callq 0xe188
leaq 0x40(%rsp), %rdi
callq 0x74e0
leaq 0x90(%rsp), %rdi
callq 0x6658
leaq 0xb0(%rsp), %rdi
callq 0x6658
leaq 0x120(%rsp), %rdi
callq 0x60d0
leaq 0xf0(%rsp), %rdi
callq 0x792e
movq %rbx, %rax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0xd0e9
jmp 0xd05e
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
jmp 0xd076
jmp 0xd059
jmp 0xd02b
movq %rax, %rbx
jmp 0xd0ae
movq %rax, %rbx
jmp 0xd042
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x6460
movq %rsp, %rdi
callq 0x6460
jmp 0xd0ae
movq %rax, %rbx
movq %rsp, %rdi
callq 0x6460
jmp 0xd0b8
movq %rax, %rbx
jmp 0xd0b8
movq %rax, %rbx
jmp 0xd073
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x6658
movq %rsp, %rdi
callq 0x6658
jmp 0xd0b8
jmp 0xd0a3
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x6460
jmp 0xd0a6
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x6658
jmp 0xd0a6
movq %rax, %rbx
movq %rsp, %rdi
callq 0x6658
leaq 0x20(%rsp), %rdi
callq 0x74e0
leaq 0x40(%rsp), %rdi
callq 0x74e0
leaq 0x90(%rsp), %rdi
callq 0x6658
leaq 0xb0(%rsp), %rdi
callq 0x6658
leaq 0x120(%rsp), %rdi
callq 0x60d0
leaq 0xf0(%rsp), %rdi
callq 0x792e
movq %rbx, %rdi
callq 0x65a0