// File: /workspace/github_cpp_makefile_star2_O1/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 (%rcx), %r13
movq 0x8(%rcx), %rbx
cmpq %rbx, %r13
je 0x6f9ae
movq %rdi, %r15
leaq 0x8562(%rip), %r12      # 0x77e09
movq (%r13), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x6f390
movq %r14, %rdi
testb %al, %al
je 0x6f8ec
leaq 0x1cd6c(%rip), %rsi     # 0x8c630
leaq 0x1dabd(%rip), %rdx     # 0x8d388
xorl %ecx, %ecx
callq 0x2e430
movq %rax, -0x30(%rbp)
movq 0x40(%rax), %rax
movq 0x40(%rax), %rsi
movq %r15, %rdi
leaq -0x30(%rbp), %rdx
callq 0x71622
jmp 0x6f92d
leaq 0x8635(%rip), %rsi      # 0x77f28
callq 0x6f390
movq %r14, %rdi
testb %al, %al
je 0x6f941
leaq 0x1cd2a(%rip), %rsi     # 0x8c630
leaq 0x1daab(%rip), %rdx     # 0x8d3b8
xorl %ecx, %ecx
callq 0x2e430
movq %rax, -0x30(%rbp)
movq 0x40(%rax), %rax
movq 0x40(%rax), %rsi
movq -0x40(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x71978
movb $0x1, 0x38(%r14)
addq $0x8, %r13
cmpq %rbx, %r13
jne 0x6f8a7
jmp 0x6f9ae
leaq 0x829d(%rip), %rsi      # 0x77be5
callq 0x6f390
movq %r14, %rdi
testb %al, %al
je 0x6f99c
leaq 0x1ccd5(%rip), %rsi     # 0x8c630
leaq 0x1da6e(%rip), %rdx     # 0x8d3d0
xorl %ecx, %ecx
callq 0x2e430
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 0x71cce
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movb $0x1, %cl
movb %cl, 0x91(%rax)
movb %cl, 0x38(%r14)
jmp 0x6f932
leaq 0xa910(%rip), %rsi      # 0x7a2b3
callq 0x6f390
testb %al, %al
jne 0x6f92d
jmp 0x6f932
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq