// File: /workspace/github_cpp_makefile_star2_O1/aalto-speech[P]ftk/src/substrings.cc
// Function: get_substrings(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, float, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, float>>>&, bool)
int get_substrings(const string &infname,
                   unsigned int maxlen,
                   map<string,float> &substrs,
                   bool utf8) {

    ifstream infile(infname);
    if (!infile) {
        cerr << "Something went wrong opening the input file." << endl;
        exit(1);
    }

    float count;
    string line, word;

    while (getline(infile, line)) {
        stringstream ss(line);
        ss >> count;
        ss >> word;

        vector<unsigned int> char_positions;
        get_character_positions(word, char_positions, utf8);

        for (unsigned int i=0; i<char_positions.size()-1; i++)
            for (unsigned int j=i+1; j<char_positions.size() && j-i <= maxlen; j++) {
                unsigned int start_pos = char_positions[i];
                unsigned int end_pos = char_positions[j];
                substrs[word.substr(start_pos, end_pos-start_pos)] += count;
            }
    }

    infile.close();
    return substrs.size();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movl %ecx, -0x58(%rbp)
movq %rdx, -0x88(%rbp)
movl %esi, -0x54(%rbp)
movq %rdi, %rsi
leaq -0x2d0(%rbp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x45a0
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x2b0(%rbp,%rax)
jne 0x54ac
leaq -0xb8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x98(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0xc8(%rbp), %r14
leaq -0x458(%rbp), %r15
leaq -0x50(%rbp), %r12
leaq -0x80(%rbp), %r13
movq -0x2d0(%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4670
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5445
movq %r15, %rdi
movq %r14, %rsi
movl $0x18, %edx
callq 0x4580
movq %r15, %rdi
leaq -0x60(%rbp), %rsi
callq 0x46f0
movq %r15, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x4450
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
cmpb $0x0, -0x58(%rbp)
je 0x5223
movq -0x50(%rbp), %rax
cmpq %rax, -0x48(%rbp)
je 0x51fb
movq %rax, -0x48(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x52b0
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x52bc
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x64bc
movq -0x50(%rbp), %rax
cmpq %rax, -0x48(%rbp)
je 0x5252
movq %rax, -0x48(%rbp)
movl $0x0, -0x2c(%rbp)
cmpq $-0x1, -0x78(%rbp)
je 0x5298
xorl %eax, %eax
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x5278
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x5284
movq %r12, %rdi
leaq -0x2c(%rbp), %rdx
callq 0x619e
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x2c(%rbp)
movq -0x78(%rbp), %rcx
incq %rcx
cmpq %rax, %rcx
ja 0x5262
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x532a
callq 0x4350
jmp 0x532a
movq %r12, %rdi
leaq -0x2c(%rbp), %rdx
callq 0x6066
movl $0x0, -0x2c(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0x532a
xorl %eax, %eax
movq -0xa8(%rbp), %rcx
movb (%rcx,%rax), %dl
movl $0x1, %ecx
testb %dl, %dl
jns 0x52f7
movl $0x4, %ecx
cmpb $-0x11, %dl
ja 0x52f7
cmpb $-0x20, %dl
movl $0x2, %ecx
sbbl $-0x1, %ecx
addl %eax, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x5312
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x531e
movq %r12, %rdi
leaq -0x2c(%rbp), %rdx
callq 0x619e
movl -0x2c(%rbp), %eax
cmpq %rax, -0xa0(%rbp)
ja 0x52cf
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rax
subq %rdi, %rax
cmpq $0x4, %rax
je 0x5402
xorl %r14d, %r14d
xorl %ebx, %ebx
movl %ebx, %r12d
leal 0x1(%r12), %ebx
cmpl $0x0, -0x54(%rbp)
je 0x53e4
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbx, %rcx
jbe 0x53e4
movl $0x2, %r15d
movq %rbx, %rcx
movl (%rax,%r14,4), %edx
movl (%rax,%rcx,4), %ecx
movss -0x60(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
subl %edx, %ecx
movq %r13, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x43b0
movq -0x88(%rbp), %rdi
movq %r13, %rsi
callq 0x5f2c
movss -0x5c(%rbp), %xmm0
addss (%rax), %xmm0
movss %xmm0, (%rax)
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x53c3
callq 0x4350
cmpl -0x54(%rbp), %r15d
ja 0x53e4
leal (%r12,%r15), %ecx
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
incl %r15d
cmpq %rcx, %rdx
ja 0x5373
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rax
subq %rdi, %rax
sarq $0x2, %rax
decq %rax
movq %rbx, %r14
cmpq %rbx, %rax
ja 0x5344
testq %rdi, %rdi
je 0x540c
callq 0x4350
leaq -0x458(%rbp), %r15
movq %r15, %rdi
movq 0x30b73(%rip), %rsi     # 0x35f90
callq 0x42c0
leaq -0x3d8(%rbp), %rdi
callq 0x4110
leaq -0x2d0(%rbp), %rbx
leaq -0xc8(%rbp), %r14
leaq -0x50(%rbp), %r12
jmp 0x5175
leaq -0x2d0(%rbp), %rdi
callq 0x40a0
movq -0x88(%rbp), %rax
movq 0x28(%rax), %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x5474
callq 0x4350
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x548c
callq 0x4350
leaq -0x2d0(%rbp), %rdi
callq 0x40c0
movl %ebx, %eax
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30b35(%rip), %rdi     # 0x35fe8
leaq 0x22b66(%rip), %rsi     # 0x28020
movl $0x2c, %edx
callq 0x4400
movq 0x30b1d(%rip), %rdi     # 0x35fe8
callq 0x4180
movl $0x1, %edi
callq 0x4420
movq %rax, %rbx
jmp 0x556d
jmp 0x54ed
jmp 0x550d
jmp 0x54ed
movq %rax, %rbx
jmp 0x551e
movq %rax, %rbx
jmp 0x553d
jmp 0x550d
jmp 0x54f6
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x5510
callq 0x4350
jmp 0x5510
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x551e
callq 0x4350
movq 0x30a6b(%rip), %rsi     # 0x35f90
leaq -0x458(%rbp), %rdi
callq 0x42c0
leaq -0x3d8(%rbp), %rdi
callq 0x4110
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x5555
callq 0x4350
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x556d
callq 0x4350
leaq -0x2d0(%rbp), %rdi
callq 0x40c0
movq %rbx, %rdi
callq 0x4640