// File: /workspace/github_cpp_makefile_star2_O1/millanek[P]Dsuite/Dsuite_common.cpp
// Function: assignTreeLevelsAndLinkToTaxa(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<int, std::allocator<int>>, 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, std::vector<int, std::allocator<int>>>>>&, std::vector<int, std::allocator<int>>&)
void assignTreeLevelsAndLinkToTaxa(string& treeLine, std::map<string,std::vector<int>>& taxaToLoc, std::vector<int>& levels) {
    // First take care of any branch lengths
    std::regex branchLengths(":.*?(?=,|\\))");
    treeLine = std::regex_replace(treeLine,branchLengths,"");
    //std::cerr << line << std::endl;

    // Now process the tree
    levels.assign(treeLine.length(),0); int currentLevel = 0;
    std::vector<string> treeTaxonNames;
    string currentTaxonName = "";
    int lastBegin = 0;
    for (int i = 0; i < treeLine.length(); ++i) {
        if (treeLine[i] == '(') {
            currentLevel++; levels[i] = currentLevel;
        } else if (treeLine[i] == ')') {
            currentLevel--; levels[i] = currentLevel;
            if (currentTaxonName != "") {
                if (taxaToLoc.count(currentTaxonName) == 1) { duplicateTreeValueError(currentTaxonName); }
                treeTaxonNames.push_back(currentTaxonName);
                taxaToLoc[currentTaxonName].push_back(lastBegin);
                taxaToLoc[currentTaxonName].push_back(i-1);
                currentTaxonName = "";
            }
        } else if (treeLine[i] == ',') {
            levels[i] = currentLevel;
            if (currentTaxonName != "") {
                treeTaxonNames.push_back(currentTaxonName);
                taxaToLoc[currentTaxonName].push_back(lastBegin);
                taxaToLoc[currentTaxonName].push_back(i-1);
                currentTaxonName = "";
            }
        } else {
            if (currentTaxonName == "")
                lastBegin = i;
            levels[i] = currentLevel;
            currentTaxonName += treeLine[i];
        }
    }
    //print_vector(treeTaxonNames, std::cout,'\n');
    //print_vector(treeLevels, std::cout,' ');
    //for (std::map<string,std::vector<int>>::iterator i = treeTaxonNamesToLoc.begin(); i != treeTaxonNamesToLoc.end(); i++) {
    //    std::cout << i->first << "\t" << i->second[0] << "\t" << i->second[1] << "\t" << treeLevels[i->second[0]] << "\t" << treeLevels[i->second[1]] << std::endl;
    //}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x6c79(%rip), %rsi      # 0x42fd1
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movl $0x10, %edx
callq 0x27444
leaq 0x20(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
movl $0x0, (%rsp)
leaq 0x6c19(%rip), %r8       # 0x42fb1
leaq 0x10(%rsp), %rdi
movq %r12, %rcx
xorl %r9d, %r9d
callq 0x323e9
leaq 0x10(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x7520
movq (%r12), %rdi
cmpq %r13, %rdi
je 0x3c3ce
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7420
movq 0x8(%r15), %rsi
leaq 0x10(%rsp), %rdx
movl $0x0, (%rdx)
movq %rbx, %rdi
callq 0x164b8
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
leaq 0x10(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x6bac(%rip), %rdx      # 0x42fb1
movq %rdx, %rsi
callq 0x88ba
movl $0x0, 0x8(%rsp)
cmpq $0x0, 0x8(%r15)
je 0x3c61d
leaq 0x8(%r14), %rax
movq %rax, 0x50(%rsp)
xorl %ebp, %ebp
leaq 0x10(%rsp), %r13
xorl %r12d, %r12d
movq (%r15), %rax
movzbl (%rax,%rbp), %eax
cmpl $0x2c, %eax
je 0x3c4d0
cmpl $0x29, %eax
je 0x3c460
cmpl $0x28, %eax
jne 0x3c520
incl %r12d
movq (%rbx), %rax
movl %r12d, (%rax,%rbp,4)
jmp 0x3c610
decl %r12d
movq (%rbx), %rax
movl %r12d, (%rax,%rbp,4)
movq %r13, %rdi
leaq 0x6b3d(%rip), %rsi      # 0x42fb1
callq 0x70f0
testl %eax, %eax
je 0x3c610
movq %r14, %rdi
movq %r13, %rsi
callq 0x3cf60
cmpq 0x50(%rsp), %rax
jne 0x3c65c
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0xd92e
movq %r14, %rdi
movq %r13, %rsi
callq 0xd6d8
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x3c5b2
movl 0x8(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x3c5bf
movq (%rbx), %rax
movl %r12d, (%rax,%rbp,4)
movq %r13, %rdi
leaq 0x6ad0(%rip), %rsi      # 0x42fb1
callq 0x70f0
testl %eax, %eax
je 0x3c610
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0xd92e
movq %r14, %rdi
movq %r13, %rsi
callq 0xd6d8
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x3c552
movl 0x8(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x3c55f
movq %r13, %rdi
leaq 0x6a87(%rip), %rsi      # 0x42fb1
callq 0x70f0
testl %eax, %eax
jne 0x3c537
movl %ebp, 0x8(%rsp)
movq (%rbx), %rax
movl %r12d, (%rax,%rbp,4)
movq (%r15), %rax
movsbl (%rax,%rbp), %esi
movq %r13, %rdi
callq 0x7390
jmp 0x3c610
movq %rax, %rdi
leaq 0x8(%rsp), %rdx
callq 0x20690
movq %r14, %rdi
movq %r13, %rsi
callq 0xd6d8
leal -0x1(%rbp), %ecx
movl %ecx, 0xc(%rsp)
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x3c58a
leal -0x1(%rbp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x3c597
movq %rax, %rdi
leaq 0xc(%rsp), %rdx
callq 0xf5e6
movq 0x18(%rsp), %rdx
movq %r13, %rdi
xorl %esi, %esi
leaq 0x6a09(%rip), %rcx      # 0x42fb1
xorl %r8d, %r8d
callq 0x7640
jmp 0x3c610
movq %rax, %rdi
leaq 0x8(%rsp), %rdx
callq 0x20690
movq %r14, %rdi
movq %r13, %rsi
callq 0xd6d8
leal -0x1(%rbp), %ecx
movl %ecx, 0xc(%rsp)
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x3c5ea
leal -0x1(%rbp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x3c5f7
movq %rax, %rdi
leaq 0xc(%rsp), %rdx
callq 0xf5e6
movq 0x18(%rsp), %rdx
movq %r13, %rdi
xorl %esi, %esi
leaq 0x69a9(%rip), %rcx      # 0x42fb1
xorl %r8d, %r8d
callq 0x7640
incq %rbp
cmpq %rbp, 0x8(%r15)
ja 0x3c433
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3c639
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7420
leaq 0x30(%rsp), %rdi
callq 0xd250
leaq 0x58(%rsp), %rdi
callq 0x27760
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rdi
callq 0x3c210
movq %rax, %rbx
jmp 0x3c6b1
movq %rax, %rbx
jmp 0x3c6bb
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3c6bb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7420
jmp 0x3c6bb
jmp 0x3c692
jmp 0x3c692
jmp 0x3c692
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3c6b1
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7420
leaq 0x30(%rsp), %rdi
callq 0xd250
leaq 0x58(%rsp), %rdi
callq 0x27760
movq %rbx, %rdi
callq 0x7740