// File: 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
movq %rsp, %rbp
subq $0x630, %rsp            # imm = 0x630
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x8090
leaq -0x70(%rbp), %rdi
callq 0x80b0
leaq -0xa0(%rbp), %rdi
callq 0x80b0
movq -0x10(%rbp), %rsi
leaq -0x2a8(%rbp), %rdi
movl $0x8, %edx
callq 0x3480
jmp 0x7300
movq -0x2a8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x2a8(%rbp,%rax), %rdi
callq 0x3130
movb %al, -0x581(%rbp)
jmp 0x7320
movb -0x581(%rbp), %al
testb $0x1, %al
jne 0x732c
jmp 0x7371
movq $0x0, -0x8(%rbp)
movl $0x1, -0x2b8(%rbp)
jmp 0x7890
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2b0(%rbp)
movl %eax, -0x2b4(%rbp)
jmp 0x78d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2b0(%rbp)
movl %eax, -0x2b4(%rbp)
jmp 0x78c7
leaq -0x2d8(%rbp), %rdi
callq 0x33b0
leaq -0x2f8(%rbp), %rdi
callq 0x33b0
leaq -0x318(%rbp), %rdi
callq 0x33b0
leaq -0x2a8(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x3390
movq %rax, -0x590(%rbp)
jmp 0x73b1
movq -0x590(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x3390
movq %rax, -0x598(%rbp)
jmp 0x73cd
movq -0x598(%rbp), %rdi
leaq -0x318(%rbp), %rsi
callq 0x3390
movq %rax, -0x5a0(%rbp)
jmp 0x73e9
movq -0x5a0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3370
movb %al, -0x5a1(%rbp)
jmp 0x7407
movb -0x5a1(%rbp), %al
testb $0x1, %al
jne 0x7416
jmp 0x7550
leaq 0x7d69(%rip), %rsi      # 0xf186
leaq -0x318(%rbp), %rdi
callq 0x80d0
movb %al, -0x5a2(%rbp)
jmp 0x7431
movb -0x5a2(%rbp), %al
testb $0x1, %al
jne 0x7440
jmp 0x74e9
cmpq $0x0, -0x18(%rbp)
jne 0x7473
leaq -0x2d8(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x8100
jmp 0x7473
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2b0(%rbp)
movl %eax, -0x2b4(%rbp)
jmp 0x786a
leaq -0xa0(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x8130
movq %rax, -0x5b0(%rbp)
jmp 0x748f
movq -0x5b0(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x8210
jmp 0x74a4
leaq -0xa0(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x8130
jmp 0x74b9
leaq -0x70(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x8130
movq %rax, -0x5b8(%rbp)
jmp 0x74d2
movq -0x5b8(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x8210
jmp 0x74e7
jmp 0x754b
leaq 0x7c9e(%rip), %rsi      # 0xf18e
leaq -0x318(%rbp), %rdi
callq 0x80d0
movb %al, -0x5b9(%rbp)
jmp 0x7504
movb -0x5b9(%rbp), %al
testb $0x1, %al
jne 0x7510
jmp 0x7532
cmpq $0x0, -0x18(%rbp)
jne 0x7532
leaq -0x40(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
leaq -0x2f8(%rbp), %rdx
callq 0x8280
jmp 0x7530
jmp 0x7549
movq 0xfab7(%rip), %rdi      # 0x16ff0
leaq 0x7c53(%rip), %rsi      # 0xf193
callq 0x3290
jmp 0x7547
jmp 0x7549
jmp 0x754b
jmp 0x7395
leaq -0x321(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x5d0(%rbp)
callq 0x8300
movq -0x5d0(%rbp), %rdi
movq %rax, -0x340(%rbp)
callq 0x8330
movq %rax, -0x348(%rbp)
movq -0x340(%rbp), %rdi
movq -0x348(%rbp), %rsi
callq 0x7900
movq %rax, -0x5c8(%rbp)
jmp 0x75a7
movq -0x5c8(%rbp), %rax
movq %rax, -0x338(%rbp)
leaq -0x338(%rbp), %rdi
callq 0x8360
movq %rax, -0x330(%rbp)
movq -0x330(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x7940
movq %rax, -0x5d8(%rbp)
jmp 0x75e5
movq -0x5d8(%rbp), %rax
movq %rax, -0x358(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x7764
movq -0x18(%rbp), %rsi
leaq -0x560(%rbp), %rdi
movl $0x8, %edx
callq 0x3480
jmp 0x7615
movq -0x560(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x560(%rbp,%rax), %rdi
callq 0x3130
movb %al, -0x5d9(%rbp)
jmp 0x7635
movb -0x5d9(%rbp), %al
testb $0x1, %al
jne 0x7641
jmp 0x767b
movq $0x0, -0x8(%rbp)
movl $0x1, -0x2b8(%rbp)
jmp 0x7743
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2b0(%rbp)
movl %eax, -0x2b4(%rbp)
leaq -0x560(%rbp), %rdi
callq 0x3090
jmp 0x786a
jmp 0x767d
leaq -0x560(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x3390
movq %rax, -0x5e8(%rbp)
jmp 0x7699
movq -0x5e8(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x3390
movq %rax, -0x5f0(%rbp)
jmp 0x76b5
movq -0x5f0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3370
movb %al, -0x5f1(%rbp)
jmp 0x76d3
movb -0x5f1(%rbp), %al
testb $0x1, %al
jne 0x76df
jmp 0x7739
movq -0x20(%rbp), %rax
movq %rax, -0x608(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x8460
movq %rax, -0x600(%rbp)
jmp 0x7703
movq -0x600(%rbp), %rsi
movq -0x608(%rbp), %rdi
callq 0x8380
movq %rax, -0x610(%rbp)
jmp 0x771f
movq -0x610(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x8540
jmp 0x7734
jmp 0x767d
movl $0x0, -0x2b8(%rbp)
leaq -0x560(%rbp), %rdi
callq 0x3090
movl -0x2b8(%rbp), %eax
testl %eax, %eax
jne 0x7844
jmp 0x775f
jmp 0x782f
leaq -0x40(%rbp), %rax
movq %rax, -0x568(%rbp)
movq -0x568(%rbp), %rdi
callq 0x8580
movq %rax, -0x570(%rbp)
movq -0x568(%rbp), %rdi
callq 0x85b0
movq %rax, -0x578(%rbp)
leaq -0x570(%rbp), %rdi
leaq -0x578(%rbp), %rsi
callq 0x85e0
testb $0x1, %al
jne 0x77ae
jmp 0x782d
leaq -0x570(%rbp), %rdi
callq 0x8620
movq %rax, -0x580(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x620(%rbp)
movq -0x28(%rbp), %rdi
movq -0x580(%rbp), %rsi
callq 0x8460
movq %rax, -0x618(%rbp)
jmp 0x77e5
movq -0x618(%rbp), %rsi
movq -0x620(%rbp), %rdi
callq 0x8380
movq %rax, -0x628(%rbp)
jmp 0x7801
movq -0x628(%rbp), %rdi
movq -0x580(%rbp), %rsi
addq $0x20, %rsi
callq 0x8540
jmp 0x781a
jmp 0x781c
leaq -0x570(%rbp), %rdi
callq 0x8640
jmp 0x7795
jmp 0x782f
movq -0x358(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x2b8(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x3190
leaq -0x2f8(%rbp), %rdi
callq 0x3190
leaq -0x2d8(%rbp), %rdi
callq 0x3190
jmp 0x7890
leaq -0x318(%rbp), %rdi
callq 0x3190
leaq -0x2f8(%rbp), %rdi
callq 0x3190
leaq -0x2d8(%rbp), %rdi
callq 0x3190
jmp 0x78c7
leaq -0x2a8(%rbp), %rdi
callq 0x3090
leaq -0xa0(%rbp), %rdi
callq 0x8660
leaq -0x70(%rbp), %rdi
callq 0x8660
leaq -0x40(%rbp), %rdi
callq 0x8680
movq -0x8(%rbp), %rax
addq $0x630, %rsp            # imm = 0x630
popq %rbp
retq
leaq -0x2a8(%rbp), %rdi
callq 0x3090
leaq -0xa0(%rbp), %rdi
callq 0x8660
leaq -0x70(%rbp), %rdi
callq 0x8660
leaq -0x40(%rbp), %rdi
callq 0x8680
movq -0x2b0(%rbp), %rdi
callq 0x3450
nopl (%rax)