// File: /workspace/github_cpp_makefile_star2_O3/eniac[P]Mantis/src/compile/compile_p4.cpp
// Function: generateMetadata(std::vector<AstNode*, std::allocator<AstNode*>>*, 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*>>> const&, 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*>>> const&, int, int)
void generateMetadata(vector<AstNode*>* newNodes,
                      const unordered_map<string,
                                          P4RMalleableValueNode*>& mblValues,
                      const unordered_map<string,
                                          P4RMalleableFieldNode*>& mblFields,
                      int ing_iso_opt, int egr_iso_opt) {
    ostringstream oss;
    // Ing
    oss << "header_type "<< kP4rIngMetadataType << " {\n"
        << "  fields {\n";
    if (((unsigned int)ing_iso_opt) & 0b1) {
        oss << "  __mv : 1;\n";
    } 
    if (((unsigned int)ing_iso_opt) & 0b10) {
        oss << "  __vv : 1;\n";        
    }

    // Presume malleables at ing
    for (auto kv : mblValues){
        // Values need to be as wide as specified
        VarWidthNode* widthNode =
                dynamic_cast<VarWidthNode*>(kv.second->varWidth_);
        string varWidth = widthNode->val_->toString();
        oss << "  " << kv.first << " : " << varWidth << ";" << endl;
    }
    for (auto kv : mblFields){
        // Ref-vars only need to be wide enough to store an index
        auto alts = findAllAlts(*kv.second);
        int indexWidth = 1;
        if(alts.size()!=1) {
            indexWidth = int(ceil(log2(alts.size())));
        }
        oss << "  " << kv.first << kP4rIndexSuffix << " : "
            << indexWidth << ";" << endl;
    }

    oss << " }" << endl;
    oss << "}" << endl;
    oss << "metadata " << kP4rIngMetadataType << " "
                       << kP4rIngMetadataName << ";\n\n";

    newNodes->push_back(new UnanchoredNode(new string(oss.str()),
                                           new string("metadata"),
                                           new string(kP4rIngMetadataName)));
    // Egr
    oss.str("");
    oss << "header_type "<< kP4rEgrMetadataType << " {\n"
        << "  fields {\n";
    if (((unsigned int)egr_iso_opt) & 0b1) {
        oss << "  __mv : 1;\n";
    }

    oss << "  }" << endl;
    oss << "}" << endl;
    oss << "metadata " << kP4rEgrMetadataType << " "
                       << kP4rEgrMetadataName << ";\n\n";

    newNodes->push_back(new UnanchoredNode(new string(oss.str()),
                                           new string("metadata"),
                                           new string(kP4rEgrMetadataName)));    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movl %r8d, -0x54(%rbp)
movl %ecx, %r14d
movq %rdx, -0x88(%rbp)
movq %rsi, %rbx
movq %rdi, -0x60(%rbp)
leaq -0x200(%rbp), %r15
movq %r15, %rdi
callq 0x2e550
leaq 0x9ab7(%rip), %rsi      # 0x75de5
movl $0xc, %edx
movq %r15, %rdi
callq 0x2e440
leaq 0xda4f(%rip), %rsi      # 0x79d91
leaq -0x200(%rbp), %rdi
movl $0xe, %edx
callq 0x2e440
leaq 0xd875(%rip), %rsi      # 0x79bcf
leaq -0x200(%rbp), %rdi
movl $0x3, %edx
callq 0x2e440
leaq 0x9a80(%rip), %rsi      # 0x75df2
leaq -0x200(%rbp), %rdi
movl $0xb, %edx
callq 0x2e440
testb $0x1, %r14b
je 0x6c3a1
leaq 0xda10(%rip), %rsi      # 0x79da0
leaq -0x200(%rbp), %rdi
movl $0xc, %edx
callq 0x2e440
testb $0x2, %r14b
je 0x6c3bf
leaq 0xd9ff(%rip), %rsi      # 0x79dad
leaq -0x200(%rbp), %rdi
movl $0xc, %edx
callq 0x2e440
movq 0x10(%rbx), %r15
testq %r15, %r15
je 0x6c4c0
leaq -0x40(%rbp), %r12
leaq -0x200(%rbp), %r13
leaq 0xa34f(%rip), %rbx      # 0x7672d
movq %r12, -0x50(%rbp)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
addq %rsi, %rdx
leaq -0x50(%rbp), %rdi
callq 0x32cbc
movq 0x28(%r15), %rax
movq %rax, -0x30(%rbp)
movq 0x48(%rax), %rax
movq 0x40(%rax), %rsi
movq (%rsi), %rax
leaq -0x80(%rbp), %rdi
callq *(%rax)
movl $0x2, %edx
movq %r13, %rdi
leaq 0xbc52(%rip), %rsi      # 0x78070
callq 0x2e440
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r13, %rdi
callq 0x2e440
movq %rax, %r14
movl $0x3, %edx
movq %rax, %rdi
leaq 0xd8f7(%rip), %rsi      # 0x79d3c
callq 0x2e440
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq %r14, %rdi
callq 0x2e440
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2e440
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2e370
movsbl %al, %esi
movq %r14, %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x2e2b0
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x6c4a6
callq 0x2e360
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x6c4b4
callq 0x2e360
movq (%r15), %r15
testq %r15, %r15
jne 0x6c3de
movq -0x88(%rbp), %rax
movq 0x10(%rax), %r12
testq %r12, %r12
je 0x6c615
leaq -0x40(%rbp), %r15
leaq -0x200(%rbp), %r14
movq %r15, -0x50(%rbp)
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
addq %rsi, %rdx
leaq -0x50(%rbp), %rdi
callq 0x32cbc
movq 0x28(%r12), %rsi
movq %rsi, -0x30(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x6f34a
movq -0x78(%rbp), %rax
subq -0x80(%rbp), %rax
movl $0x1, %r13d
cmpq $0x8, %rax
je 0x6c553
sarq $0x3, %rax
movq %rax, %xmm1
punpckldq 0xd3c0(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xd3c8(%rip), %xmm1     # 0x79900
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
callq 0x2e740
callq 0x2e0a0
cvttsd2si %xmm0, %r13d
movl $0x2, %edx
movq %r14, %rdi
leaq 0xbb0e(%rip), %rsi      # 0x78070
callq 0x2e440
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r14, %rdi
callq 0x2e440
movq %rax, %rbx
movl $0x5, %edx
movq %rax, %rdi
leaq 0xb9b5(%rip), %rsi      # 0x77f3e
callq 0x2e440
movl $0x3, %edx
movq %rbx, %rdi
leaq 0xd79f(%rip), %rsi      # 0x79d3c
callq 0x2e440
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2e700
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0xa16e(%rip), %rsi      # 0x7672d
callq 0x2e440
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2e370
movsbl %al, %esi
movq %r13, %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x2e2b0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x6c5fa
callq 0x2e360
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x6c608
callq 0x2e360
movq (%r12), %r12
testq %r12, %r12
jne 0x6c4df
leaq 0xd7ae(%rip), %rsi      # 0x79dca
leaq -0x200(%rbp), %rbx
movl $0x2, %edx
movq %rbx, %rdi
callq 0x2e440
movq -0x200(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2e370
movsbl %al, %esi
leaq -0x200(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x2e2b0
leaq 0xb66a(%rip), %rsi      # 0x77cd0
leaq -0x200(%rbp), %rbx
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2e440
movq -0x200(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2e370
movsbl %al, %esi
leaq -0x200(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x2e2b0
leaq 0x9756(%rip), %rsi      # 0x75e06
leaq -0x200(%rbp), %rdi
movl $0x9, %edx
callq 0x2e440
leaq 0xd6c9(%rip), %rsi      # 0x79d91
leaq -0x200(%rbp), %rdi
movl $0xe, %edx
callq 0x2e440
leaq 0xb991(%rip), %rsi      # 0x78071
leaq -0x200(%rbp), %rdi
movl $0x1, %edx
callq 0x2e440
leaq 0xb503(%rip), %rsi      # 0x77bfb
leaq -0x200(%rbp), %rdi
movl $0xc, %edx
callq 0x2e440
leaq 0xaac4(%rip), %rsi      # 0x771d4
leaq -0x200(%rbp), %rdi
movl $0x3, %edx
callq 0x2e440
movl $0x58, %edi
callq 0x2e3a0
movq %rax, %r14
movl $0x20, %edi
callq 0x2e3a0
movq %rax, %r12
leaq -0x1f8(%rbp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x2e660
movl $0x20, %edi
callq 0x2e3a0
movq %rax, %r13
addq $0x10, %rax
movq %rax, (%r13)
leaq 0xd5d7(%rip), %rsi      # 0x79d40
leaq 0xd5d8(%rip), %rdx      # 0x79d48
movq %r13, %rdi
callq 0x32e40
movl $0x20, %edi
callq 0x2e3a0
movq %rax, %rbx
addq $0x10, %rax
movq %rax, (%rbx)
leaq 0xb468(%rip), %rsi      # 0x77bfb
leaq 0xb46d(%rip), %rdx      # 0x77c07
movq %rbx, %rdi
callq 0x32e40
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x3e120
movq %r14, -0x50(%rbp)
movq -0x60(%rbp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x6c7cf
movq %r14, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x6c7d8
leaq -0x50(%rbp), %rdx
callq 0x3311a
leaq -0x40(%rbp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0xb0f4(%rip), %rdx      # 0x778db
leaq -0x50(%rbp), %rdi
movq %rdx, %rsi
callq 0x32e40
leaq -0x50(%rbp), %rsi
movq %r15, %rdi
callq 0x2e610
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6c80d
callq 0x2e360
leaq 0x95d1(%rip), %rsi      # 0x75de5
leaq -0x200(%rbp), %rdi
movl $0xc, %edx
callq 0x2e440
leaq 0xd58e(%rip), %rsi      # 0x79dba
leaq -0x200(%rbp), %rdi
movl $0xe, %edx
callq 0x2e440
leaq 0xd38b(%rip), %rsi      # 0x79bcf
leaq -0x200(%rbp), %rdi
movl $0x3, %edx
callq 0x2e440
leaq 0x9596(%rip), %rsi      # 0x75df2
leaq -0x200(%rbp), %rdi
movl $0xb, %edx
callq 0x2e440
testb $0x1, -0x54(%rbp)
je 0x6c88b
leaq 0xd526(%rip), %rsi      # 0x79da0
leaq -0x200(%rbp), %rdi
movl $0xc, %edx
callq 0x2e440
leaq 0xd537(%rip), %rsi      # 0x79dc9
leaq -0x200(%rbp), %rbx
movl $0x3, %edx
movq %rbx, %rdi
callq 0x2e440
movq -0x200(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2e370
movsbl %al, %esi
leaq -0x200(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x2e2b0
leaq 0xb3f4(%rip), %rsi      # 0x77cd0
leaq -0x200(%rbp), %rbx
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2e440
movq -0x200(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2e370
movsbl %al, %esi
leaq -0x200(%rbp), %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x2e2b0
leaq 0x94e0(%rip), %rsi      # 0x75e06
leaq -0x200(%rbp), %rdi
movl $0x9, %edx
callq 0x2e440
leaq 0xd47c(%rip), %rsi      # 0x79dba
leaq -0x200(%rbp), %rdi
movl $0xe, %edx
callq 0x2e440
leaq 0xb71b(%rip), %rsi      # 0x78071
leaq -0x200(%rbp), %rdi
movl $0x1, %edx
callq 0x2e440
leaq 0xb2ab(%rip), %rsi      # 0x77c19
leaq -0x200(%rbp), %rdi
movl $0xc, %edx
callq 0x2e440
leaq 0xa84e(%rip), %rsi      # 0x771d4
leaq -0x200(%rbp), %rdi
movl $0x3, %edx
callq 0x2e440
movl $0x58, %edi
callq 0x2e3a0
movq %rax, %r14
movl $0x20, %edi
callq 0x2e3a0
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x2e660
movl $0x20, %edi
callq 0x2e3a0
movq %rax, %r15
addq $0x10, %rax
movq %rax, (%r15)
leaq 0xd369(%rip), %rsi      # 0x79d40
leaq 0xd36a(%rip), %rdx      # 0x79d48
movq %r15, %rdi
callq 0x32e40
movl $0x20, %edi
callq 0x2e3a0
movq %rax, %rbx
addq $0x10, %rax
movq %rax, (%rbx)
leaq 0xb218(%rip), %rsi      # 0x77c19
leaq 0xb21d(%rip), %rdx      # 0x77c25
movq %rbx, %rdi
callq 0x32e40
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x3e120
movq %r14, -0x50(%rbp)
movq -0x60(%rbp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x6ca3d
movq %r14, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x6ca46
leaq -0x50(%rbp), %rdx
callq 0x3311a
movq 0x2155b(%rip), %rsi     # 0x8dfa8
leaq -0x200(%rbp), %rdi
callq 0x2e230
leaq -0x190(%rbp), %rdi
callq 0x2e150
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6cb04
jmp 0x6cb04
jmp 0x6cade
movq %rax, %r13
movq %rbx, %rdi
jmp 0x6ca9b
jmp 0x6cade
movq %rax, %r13
movq %r15, %rdi
jmp 0x6ca9b
movq %rax, %r13
movq %r12, %rdi
callq 0x2e360
jmp 0x6cae1
jmp 0x6cb04
movq %rax, %r13
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
jne 0x6cb43
jmp 0x6cb48
jmp 0x6cb04
jmp 0x6cae6
movq %rax, %r15
movq %rbx, %rdi
jmp 0x6cad5
jmp 0x6cae6
movq %rax, %r15
movq %r13, %rdi
jmp 0x6cad5
movq %rax, %r15
movq %r12, %rdi
callq 0x2e360
jmp 0x6cae9
jmp 0x6cb04
movq %rax, %r13
movq %r14, %rdi
jmp 0x6cb43
movq %rax, %r15
movq %r14, %rdi
callq 0x2e360
movq %r15, %r13
jmp 0x6cb48
jmp 0x6cb04
movq %rax, %r13
jmp 0x6cb3a
jmp 0x6cb04
movq %rax, %r13
jmp 0x6cb1e
movq %rax, %r13
jmp 0x6cb48
movq %rax, %r13
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x6cb1e
callq 0x2e360
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
jne 0x6cb43
jmp 0x6cb48
movq %rax, %r13
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x6cb3a
callq 0x2e360
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x6cb48
callq 0x2e360
movq 0x21459(%rip), %rsi     # 0x8dfa8
leaq -0x200(%rbp), %rdi
callq 0x2e230
leaq -0x190(%rbp), %rdi
callq 0x2e150
movq %r13, %rdi
callq 0x2e730