// File: /workspace/github_cpp_makefile_star2_O2/eniac[P]Mantis/src/compile/find_nodes.cpp
// Function: findAndRemoveMalleables(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, P4RMalleableValueNode*, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<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, P4RMalleableValueNode*>>>*, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, P4RMalleableFieldNode*, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<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, P4RMalleableFieldNode*>>>*, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, P4RMalleableTableNode*, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<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, P4RMalleableTableNode*>>>*, std::vector<AstNode*, std::allocator<AstNode*>> const&)
void findAndRemoveMalleables(
            unordered_map<string, P4RMalleableValueNode*>* mblValues,
            unordered_map<string, P4RMalleableFieldNode*>* mblFields,
            unordered_map<string, P4RMalleableTableNode*>* mblTables,
            const vector<AstNode*>& astNodes) {
    // Find all the Malleables
    for (auto n : astNodes) {
        if (typeContains(n, "P4RMalleableValueNode")) {
            auto v = dynamic_cast<P4RMalleableValueNode*>(n);
            mblValues->emplace(*v->name_->word_, v);
            n->removed_ = true;
        } else if (typeContains(n, "P4RMalleableFieldNode")) {
            auto v = dynamic_cast<P4RMalleableFieldNode*>(n);
            mblFields->emplace(*v->name_->word_, v);
            n->removed_ = true;
        } else if (typeContains(n, "P4RMalleableTableNode")) {
            auto v = dynamic_cast<P4RMalleableTableNode*>(n);
            mblTables->emplace(*v->table_->name_->word_, v);
            // for a Malleable table, the parser will give both MalleableTableNode and TableNode, 
            // we need to tag the latter as Malleable
            v->table_->isMalleable_ = true;
            n->removed_ = true;
        } else if (typeContains(n, "P4RInitBlockNode")) {
            n->removed_ = true;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdi, %r15
movq (%rcx), %r13
movq 0x8(%rcx), %rbx
leaq 0x8cec(%rip), %r12      # 0x7ade9
cmpq %rbx, %r13
je 0x72207
movq (%r13), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x71cf8
movq %r14, %rdi
testb %al, %al
je 0x7214b
leaq 0x2256d(%rip), %rsi     # 0x94690
leaq 0x232be(%rip), %rdx     # 0x953e8
xorl %ecx, %ecx
callq 0x41480
movq %rax, -0x30(%rbp)
movq 0x40(%rax), %rax
movq 0x40(%rax), %rsi
movq %r15, %rdi
leaq -0x30(%rbp), %rdx
callq 0x7389a
jmp 0x7218c
leaq 0x8db6(%rip), %rsi      # 0x7af08
callq 0x71cf8
movq %r14, %rdi
testb %al, %al
je 0x7219a
leaq 0x2252b(%rip), %rsi     # 0x94690
leaq 0x232ac(%rip), %rdx     # 0x95418
xorl %ecx, %ecx
callq 0x41480
movq %rax, -0x30(%rbp)
movq 0x40(%rax), %rax
movq 0x40(%rax), %rsi
movq -0x40(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x73b90
movb $0x1, 0x38(%r14)
addq $0x8, %r13
jmp 0x720fd
leaq 0x8a24(%rip), %rsi      # 0x7abc5
callq 0x71cf8
movq %r14, %rdi
testb %al, %al
je 0x721f5
leaq 0x224dc(%rip), %rsi     # 0x94690
leaq 0x23275(%rip), %rdx     # 0x95430
xorl %ecx, %ecx
callq 0x41480
movq %rax, -0x30(%rbp)
movq 0x40(%rax), %rax
movq 0x40(%rax), %rax
movq 0x40(%rax), %rsi
movq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x73e86
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movb $0x1, %cl
movb %cl, 0x91(%rax)
movb %cl, 0x38(%r14)
jmp 0x72191
leaq 0xb147(%rip), %rsi      # 0x7d343
callq 0x71cf8
testb %al, %al
jne 0x7218c
jmp 0x72191
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq