// File: /workspace/github_cpp_makefile_star2_O2/canzarlab[P]Trajan/src/newick.cpp
// Function: load_dag(char const*, char const*, std::map<newick_node*, std::__cxx11::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::less<newick_node*>, std::allocator<std::pair<newick_node* const, std::__cxx11::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<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>>, newick_node*, 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, newick_node*>>>&)
newick_node* load_dag(const char* f1, const char* f2, mnls& clade, msn& M)
{
    vss S;
    msvs C, P;
    ifstream ef(f1);
    if (!ef)
        return nullptr;

    string n1, n2, s;
    while (ef >> n1 >> n2 >> s)
    {
        if (s == "default")
        {
            if (!f2) swap(n1, n2);
            P[n1].push_back(n2);
            P[n2];
            C[n2].push_back(n1);
        }
        else if (s == "gene" && !f2)
            S.emplace_back(n1, n2);
        else
            cerr << "WARNING: unsupported entry!\n";
    }

    const auto& l = [](const svs& i){return i.second.empty();};
    const string& r = find_if(P.begin(), P.end(), l)->first;
    newick_node* root = load_dag_internal(r, M, C);

    if (f2)
    {
        ifstream lf(f2);
        if (!lf)
            return nullptr;

        while (lf >> n1 >> n2)
            clade[M[n2]].push_back(n1);
    }
    else
        for (const ss& p : S)
            clade[M[p.first]].push_back(p.second);

    return root;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x508, %rsp            # imm = 0x508
movq %rcx, %rbx
movq %rdx, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, %rsi
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0xd0(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0xa0(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x300(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x2350
movq 0x300(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x320(%rsp,%rax)
je 0x3970
xorl %r12d, %r12d
jmp 0x3c20
movq %rbx, 0x30(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0x48(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %edx, %edx
movb %dl, (%rax)
movb %dl, (%rcx)
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %dl, (%rax)
leaq 0x300(%rsp), %r12
leaq 0x58(%rsp), %r13
leaq 0x38(%rsp), %rbp
leaq 0x78(%rsp), %r14
leaq 0x98(%rsp), %rbx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2260
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2260
movq %rax, %rdi
movq %r14, %rsi
callq 0x2260
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3aa5
movq %r14, %rdi
leaq 0x2780(%rip), %rsi      # 0x6186
callq 0x400f
testb %al, %al
je 0x3a60
testq %r15, %r15
jne 0x3a1f
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2160
movq %rbx, %rdi
movq %r13, %rsi
callq 0x401c
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4082
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x401c
leaq 0xc8(%rsp), %rdi
movq %rbp, %rsi
callq 0x401c
movq %rax, %rdi
movq %r13, %rsi
callq 0x4082
jmp 0x39c9
movq %r14, %rdi
leaq 0x2724(%rip), %rsi      # 0x618e
callq 0x400f
testq %r15, %r15
jne 0x3a8d
testb %al, %al
je 0x3a8d
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x40ae
jmp 0x39c9
movq 0x655c(%rip), %rdi      # 0x9ff0
leaq 0x26f8(%rip), %rsi      # 0x6193
callq 0x21d0
jmp 0x39c9
movq 0xb0(%rsp), %rbx
leaq 0xf8(%rsp), %r14
movq 0x30(%rsp), %rbp
leaq 0xa0(%rsp), %rax
cmpq %rax, %rbx
je 0x3afd
leaq 0x20(%rbx), %rsi
movq %r14, %rdi
callq 0x503a
movq 0x118(%rsp), %r12
movq 0x120(%rsp), %r13
movq %r14, %rdi
callq 0x5074
cmpq %r13, %r12
je 0x3afd
movq %rbx, %rdi
callq 0x2140
movq %rax, %rbx
jmp 0x3aba
addq $0x20, %rbx
leaq 0xc8(%rsp), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3cdf
movq %rax, %r12
testq %r15, %r15
je 0x3b5a
leaq 0xf8(%rsp), %rdi
pushq $0x8
popq %rdx
movq %r15, %rsi
callq 0x2350
movq 0xf8(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x118(%rsp,%rax)
je 0x3b9a
leaq 0xf8(%rsp), %rdi
callq 0x2070
xorl %r12d, %r12d
jmp 0x3c02
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x3c02
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x4140
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x40f0
addq $0x20, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x41a6
addq $0x20, %rbx
jmp 0x3b64
leaq 0xf8(%rsp), %rbx
leaq 0x58(%rsp), %r14
leaq 0x38(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq %rax, %rdi
movq %r15, %rsi
callq 0x2260
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3bf5
movq %rbp, %rdi
movq %r15, %rsi
callq 0x4140
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x40f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x41a6
jmp 0x3bac
leaq 0xf8(%rsp), %rdi
callq 0x2070
leaq 0x78(%rsp), %rdi
callq 0x20e0
leaq 0x38(%rsp), %rdi
callq 0x20e0
leaq 0x58(%rsp), %rdi
callq 0x20e0
leaq 0x300(%rsp), %rdi
callq 0x2070
leaq 0x98(%rsp), %rdi
callq 0x42a2
leaq 0xc8(%rsp), %rdi
callq 0x42a2
leaq 0x10(%rsp), %rdi
callq 0x41b2
movq %r12, %rax
addq $0x508, %rsp            # imm = 0x508
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3c85
jmp 0x3c85
movq %rax, %rbx
jmp 0x3cb3
jmp 0x3c85
jmp 0x3c85
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x2070
jmp 0x3c88
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x20e0
leaq 0x38(%rsp), %rdi
callq 0x20e0
leaq 0x58(%rsp), %rdi
callq 0x20e0
leaq 0x300(%rsp), %rdi
callq 0x2070
leaq 0x98(%rsp), %rdi
callq 0x42a2
leaq 0xc8(%rsp), %rdi
callq 0x42a2
leaq 0x10(%rsp), %rdi
callq 0x41b2
movq %rbx, %rdi
callq 0x2330