// File: /workspace/github_cpp_makefile_star2_O3/canzarlab[P]Trajan/src/match.cpp
// Function: tree::tree(char const*, char const*)
tree(const char* filename, const char* mapname) : n(0), nb(0), r(-1)
    {
        ifstream file(filename), mapfile(mapname);
        if (!file || !mapfile)
            die();

        // map string indices to integers
        int node_idx; string node_name;
        while (mapfile >> node_idx >> node_name)
            m[node_name] = node_idx;
        n = m.size();

        // create reverse mapping
        rm.resize(n);
        for (auto [name, idx] : m)
            rm[idx] = name;

        // nroot[x] == 1 means x is not the root
        vector<int> nroot(MAXN);

        // read from file
        string sa, sb, type;
        while (file >> sa >> sb >> type)
        {
            if (type != "default")
                die();

            // directed edge sb->sa
            int x = m[sa], y = m[sb];
            adj[y].push_back(x);
            nroot[x] = 1;
        }

        // tree too big
        if (m.size() > MAXN)
            die();

        // find root
        for (uint i = 0; i < m.size(); ++i)
        {
            // found the root
            if (!nroot[i])
            {
                // multiple roots
                if (r != -1)
                    die();

                r = i;
            }
        }

        // tree has no root
        if (r == -1)
            die();

        // identify branching nodes
        function<void(int)> mark = [&] (int x)
        {
            for (int y : adj[x])
            {
                // fill the parent table
                par[y] = x;
                mark(y);
            }
            // x is a leaf/branching node - record finishing time
            if (adj[x].size() != 1)
                b[nb++] = x;
        };
        // root has no parent
        par[r] = -1;
        mark(r);

        // too many leaf/branching nodes
        if (nb > MAXLB)
            die();

        // obtain topological ordering
        reverse(b, b + nb);

        // create node->leaf/branching node index mapping
        memset(rb, -1, sizeof rb);
        for (int i = 0; i < nb; ++i)
            rb[b[i]] = i;

        // fill the table of immediate leaf/branching descendant masks
        function<mask(int)> child = [&] (int x)
        {
            mask msk = 0;
            for (int y : adj[x])
                msk |= child(y);

            // x is a leaf/branching node
            if (rb[x] != -1)
            {
                // record leaf/branching children mask
                ch[rb[x]] = msk;
                return in(rb[x]);
            }
            return msk;
        };
        child(r);

        // identify branching ancestors
        function<void(int, mask, int)> branch = [&] (int x, mask m, int p)
        {
            // x is a branching or leaf node
            if (rb[x] != -1)
            {
                // set branching ancestor mask
                ba[rb[x]] = m;
                m |= in(rb[x]);
                // set branching parent
                bp[rb[x]] = p;
                p = x;
            }
            for (int y : adj[x])
                branch(y, m, p);
        };
        branch(r, 0, -1);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x528, %rsp            # imm = 0x528
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x8(%rdi), %r13
movl $0x0, 0x8(%rdi)
movq $0x0, 0x10(%rdi)
movq %r13, 0x18(%rdi)
movq %r13, 0x20(%rdi)
leaq 0x28(%rdi), %r12
leaq 0x30(%rdi), %rax
movq %rax, 0x10(%rsp)
movl $0x5de8, %edx           # imm = 0x5DE8
movq %r12, %rdi
xorl %esi, %esi
callq 0x3150
movl $0xffffffff, 0x5e10(%rbx) # imm = 0xFFFFFFFF
leaq 0x320(%rsp), %rdi
movq %r15, %rsi
movl $0x8, %edx
callq 0x3400
leaq 0x118(%rsp), %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x3400
movq %r12, 0xa8(%rsp)
movq 0x320(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x340(%rsp,%rax)
jne 0x62fa
movq 0x118(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x138(%rsp,%rax)
jne 0x62fa
leaq 0x48(%rbx), %rax
movq %rax, 0xb0(%rsp)
leaq 0x108(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x118(%rsp), %r14
leaq 0x1c(%rsp), %r15
leaq 0xf8(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x3170
movq %rax, %rdi
movq %r12, %rsi
callq 0x3290
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5e42
movl 0x1c(%rsp), %ebp
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6918
movl %ebp, (%rax)
jmp 0x5e0b
movq 0x28(%rbx), %rax
movl %eax, 0x5e08(%rbx)
movslq %eax, %rsi
movq 0x10(%rsp), %rdi
callq 0x6994
movq 0x18(%rbx), %r14
cmpq %r13, %r14
je 0x5ec7
leaq 0x50(%rsp), %rbp
leaq 0x40(%rsp), %r15
movq %rbp, 0x40(%rsp)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x6d46
movslq 0x40(%r14), %rdi
movl %edi, 0x60(%rsp)
shlq $0x5, %rdi
movq 0x10(%rsp), %rax
addq (%rax), %rdi
movq %r15, %rsi
callq 0x3140
movq 0x40(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5eb7
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3230
movq %r14, %rdi
callq 0x31a0
movq %rax, %r14
cmpq %r13, %rax
jne 0x5e6c
movl $0xfa0, %edi            # imm = 0xFA0
callq 0x3220
xorl %r14d, %r14d
movl $0xfa0, %edx            # imm = 0xFA0
movq %rax, 0x8(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x3150
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r14, -0x8(%rax)
movb %r14b, (%rax)
leaq 0xe8(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r14, -0x8(%rax)
movb %r14b, (%rax)
leaq 0xc8(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r14, -0x8(%rax)
movb %r14b, (%rax)
leaq 0x320(%rsp), %rbp
leaq 0x40(%rsp), %r12
leaq 0xd8(%rsp), %r14
leaq 0xb8(%rsp), %r13
leaq 0x61ee(%rip), %r15      # 0xc130
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3290
movq %rax, %rdi
movq %r14, %rsi
callq 0x3290
movq %rax, %rdi
movq %r13, %rsi
callq 0x3290
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5fee
movq %r13, %rdi
movq %r15, %rsi
callq 0x30b0
testl %eax, %eax
jne 0x62bc
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6918
movl (%rax), %eax
movl %eax, 0x20(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6918
movslq (%rax), %rax
leaq (%rax,%rax,2), %rax
movq 0xb0(%rsp), %rcx
leaq (%rcx,%rax,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x5fcd
movl 0x20(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x5fdb
leaq 0x20(%rsp), %rdx
callq 0x7976
movl 0x20(%rsp), %eax
cltq
movq 0x8(%rsp), %rcx
movl $0x1, (%rcx,%rax,4)
jmp 0x5f42
movq 0xa8(%rsp), %rax
movq (%rax), %rcx
cmpq $0x3e8, %rcx            # imm = 0x3E8
ja 0x6319
movl 0x5e10(%rbx), %eax
testq %rcx, %rcx
movq 0x8(%rsp), %r12
je 0x6038
xorl %edx, %edx
cmpl $0x0, (%r12,%rdx,4)
jne 0x6030
cmpl $-0x1, %eax
jne 0x62db
movl %edx, 0x5e10(%rbx)
movl %edx, %eax
incq %rdx
cmpq %rdx, %rcx
jne 0x6018
cmpl $-0x1, %eax
je 0x6338
movq %rbx, 0x20(%rsp)
leaq 0x20(%rsp), %rdi
movq %rdi, 0x28(%rsp)
leaq 0x1031(%rip), %rcx      # 0x7088
movq %rcx, 0x38(%rsp)
leaq 0x102b(%rip), %rcx      # 0x708e
movq %rcx, 0x30(%rsp)
cltq
movl $0xffffffff, 0x5f14(%rbx,%rax,4) # imm = 0xFFFFFFFF
movl 0x5e10(%rbx), %eax
leaq 0x88(%rsp), %r14
movl %eax, (%r14)
movq %r14, %rsi
callq 0x70b6
movslq 0x5e0c(%rbx), %r15
cmpq $0x41, %r15
jge 0x6357
leaq 0x5e14(%rbx), %rcx
testl %r15d, %r15d
setne %dl
leaq (%rbx,%r15,4), %rax
addq $0x5e10, %rax           # imm = 0x5E10
cmpq %rcx, %rax
seta %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x60eb
leaq 0x5e18(%rbx), %rcx
movl -0x4(%rcx), %edx
movl (%rax), %esi
movl %esi, -0x4(%rcx)
movl %edx, (%rax)
addq $-0x4, %rax
leaq 0x4(%rcx), %rdx
cmpq %rax, %rcx
movq %rdx, %rcx
jb 0x60ca
movl 0x5e0c(%rbx), %r15d
leaq 0x70b8(%rbx), %rdi
movl $0xfa0, %edx            # imm = 0xFA0
movl $0xff, %esi
callq 0x3150
testl %r15d, %r15d
jle 0x6126
xorl %eax, %eax
movslq 0x5e14(%rbx,%rax,4), %rcx
movl %eax, 0x70b8(%rbx,%rcx,4)
incq %rax
movslq 0x5e0c(%rbx), %rcx
cmpq %rcx, %rax
jl 0x6108
movq %rbx, 0x88(%rsp)
movq %r14, 0x90(%rsp)
leaq 0x1029(%rip), %rax      # 0x7166
movq %rax, 0xa0(%rsp)
leaq 0x1020(%rip), %rax      # 0x716c
movq %rax, 0x98(%rsp)
movl 0x5e10(%rbx), %eax
leaq 0x68(%rsp), %r15
movl %eax, (%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x7194
movq %rbx, 0x68(%rsp)
movq %r15, 0x70(%rsp)
leaq 0x10ae(%rip), %rax      # 0x722c
movq %rax, 0x80(%rsp)
leaq 0x10a5(%rip), %rax      # 0x7232
movq %rax, 0x78(%rsp)
movl 0x5e10(%rbx), %esi
movq %r15, %rdi
xorl %edx, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x69c4
movq 0x78(%rsp), %rax
testq %rax, %rax
je 0x61c0
leaq 0x68(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x98(%rsp), %rax
testq %rax, %rax
je 0x61df
leaq 0x88(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x61f8
leaq 0x20(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x621d
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x6242
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x625e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3230
movl $0xfa0, %esi            # imm = 0xFA0
movq %r12, %rdi
callq 0x3230
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x6290
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x3230
leaq 0x118(%rsp), %rdi
callq 0x3090
leaq 0x320(%rsp), %rdi
callq 0x3090
addq $0x528, %rsp            # imm = 0x528
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5e40(%rip), %rdi      # 0xc103
leaq 0x5e02(%rip), %rsi      # 0xc0cc
leaq 0x5e38(%rip), %rcx      # 0xc109
movl $0x93, %edx
callq 0x3180
leaq 0x5e21(%rip), %rdi      # 0xc103
leaq 0x5de3(%rip), %rsi      # 0xc0cc
leaq 0x5e19(%rip), %rcx      # 0xc109
movl $0xa7, %edx
callq 0x3180
leaq 0x5e02(%rip), %rdi      # 0xc103
leaq 0x5dc4(%rip), %rsi      # 0xc0cc
leaq 0x5dfa(%rip), %rcx      # 0xc109
movl $0x7e, %edx
callq 0x3180
leaq 0x5de3(%rip), %rdi      # 0xc103
leaq 0x5da5(%rip), %rsi      # 0xc0cc
leaq 0x5ddb(%rip), %rcx      # 0xc109
movl $0x9d, %edx
callq 0x3180
leaq 0x5dc4(%rip), %rdi      # 0xc103
leaq 0x5d86(%rip), %rsi      # 0xc0cc
leaq 0x5dbc(%rip), %rcx      # 0xc109
movl $0xaf, %edx
callq 0x3180
leaq 0x5da5(%rip), %rdi      # 0xc103
leaq 0x5d67(%rip), %rsi      # 0xc0cc
leaq 0x5d9d(%rip), %rcx      # 0xc109
movl $0xc4, %edx
callq 0x3180
jmp 0x63e0
jmp 0x63e0
jmp 0x63e0
movq %rax, %r12
movq 0x78(%rsp), %rax
testq %rax, %rax
je 0x639f
leaq 0x68(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x639f
jmp 0x63e0
movq %rax, %r12
movq 0x98(%rsp), %rax
testq %rax, %rax
je 0x63c5
leaq 0x88(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x63c5
jmp 0x63e0
movq %rax, %r12
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x6425
leaq 0x20(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x6425
movq %rax, %rdi
callq 0x66f1
jmp 0x641d
jmp 0x641d
movq %rax, %r12
jmp 0x64cf
movq %rax, %r12
jmp 0x64dc
jmp 0x641d
movq %rax, %r12
movq 0x40(%rsp), %rdi
cmpq %rbp, %rdi
je 0x649d
movq 0x50(%rsp), %rsi
incq %rsi
jmp 0x6498
jmp 0x6422
jmp 0x6422
movq %rax, %r12
jmp 0x649d
movq %rax, %r12
movq 0x8(%rsp), %r14
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x644f
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x6474
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x6490
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3230
movl $0xfa0, %esi            # imm = 0xFA0
movq %r14, %rdi
callq 0x3230
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x64c2
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x3230
leaq 0x118(%rsp), %rdi
callq 0x3090
leaq 0x320(%rsp), %rdi
callq 0x3090
movl $0x5e00, %r14d          # imm = 0x5E00
movq -0x10(%rbx,%r14), %rdi
testq %rdi, %rdi
je 0x64f8
movq (%rbx,%r14), %rsi
subq %rdi, %rsi
callq 0x3230
addq $-0x18, %r14
cmpq $0x40, %r14
jne 0x64e2
movq 0x10(%rsp), %rdi
callq 0x69f8
movq %rbx, %rdi
callq 0x72ca
movq %r12, %rdi
callq 0x33e0