// File: /workspace/github_cpp_makefile_star2_O3/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 0x6ef5e
movq %rdi, %r15
leaq 0x8fb2(%rip), %r12      # 0x77e09
movq (%r13), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x6e968
movq %r14, %rdi
testb %al, %al
je 0x6ee9c
leaq 0x1d83c(%rip), %rsi     # 0x8c6b0
leaq 0x1e58d(%rip), %rdx     # 0x8d408
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 0x70aea
jmp 0x6eedd
leaq 0x9085(%rip), %rsi      # 0x77f28
callq 0x6e968
movq %r14, %rdi
testb %al, %al
je 0x6eef1
leaq 0x1d7fa(%rip), %rsi     # 0x8c6b0
leaq 0x1e57b(%rip), %rdx     # 0x8d438
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 0x70e40
movb $0x1, 0x38(%r14)
addq $0x8, %r13
cmpq %rbx, %r13
jne 0x6ee57
jmp 0x6ef5e
leaq 0x8ced(%rip), %rsi      # 0x77be5
callq 0x6e968
movq %r14, %rdi
testb %al, %al
je 0x6ef4c
leaq 0x1d7a5(%rip), %rsi     # 0x8c6b0
leaq 0x1e53e(%rip), %rdx     # 0x8d450
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 0x71196
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movb $0x1, %cl
movb %cl, 0x91(%rax)
movb %cl, 0x38(%r14)
jmp 0x6eee2
leaq 0xb360(%rip), %rsi      # 0x7a2b3
callq 0x6e968
testb %al, %al
jne 0x6eedd
jmp 0x6eee2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq