// File: /workspace/github_cpp_makefile_star2_O1/eniac[P]Mantis/src/compile/compile_p4.cpp
// Function: generateIngDigestPacking(std::vector<AstNode*, std::allocator<AstNode*>>*, std::vector<ReactionArgNode*, std::allocator<ReactionArgNode*>> const&, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<FieldDecNode*, std::allocator<FieldDecNode*>>*, 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, std::vector<FieldDecNode*, std::allocator<FieldDecNode*>>*>>> const&, 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&, std::vector<AstNode*, std::allocator<AstNode*>> const&, int*)
vector<ReactionArgBin> generateIngDigestPacking(
            vector<AstNode*>* newNodes,
            const vector<ReactionArgNode*>& reaction_args,
            const HeaderDecsMap& headerDecsMap,
            const unordered_map<string, P4RMalleableValueNode*>& mblValues,
            const unordered_map<string, P4RMalleableFieldNode*>& mblFields,
            const vector<AstNode*>& astNodes, int* ing_iso_opt) {
    if (reaction_args.size() == 0) {
        return vector<ReactionArgBin>();
    }

    vector<pair<ReactionArgNode*, int> > argSizes =
            findAllReactionArgSizes(reaction_args, headerDecsMap, mblValues,
                                    mblFields);

    // Currently pack arguments into 32-bit bins
    // Note HW target could support 64-bit reg --- further reducing the number of packed regs by half (therefore latency)
    vector<ReactionArgBin> argBins = runBinPackForIng(&argSizes, astNodes, true);
    vector<MblRefNode*> mblRefs = generatePackingTablesForIng(newNodes, argBins, true);

    // Update meas isolation option
    if(argBins.size()<=1) {
        vector<ReactionArgNode*> reaction_args = findReactionArgs(astNodes);
        bool has_regarg = false;
        for (auto ra : reaction_args) {    
            if (ra->argType_==ReactionArgNode::REGISTER) {
                if(findRegargInIng(ra, astNodes)) {
                    has_regarg = true;
                }
            }    
        }
        if(!has_regarg) {
            if((*ing_iso_opt)==1) {
                *ing_iso_opt = 0;
            } else if ((*ing_iso_opt)==3) {
                *ing_iso_opt = 2;
            }
            PRINT_VERBOSE("Update ing isolation opt to %d\n", *ing_iso_opt);
        }
    }

    generateArgRegistersForIng(newNodes, argBins, *ing_iso_opt, true);

    // Redo the transformations to capture any malleable references in the generated code
    PRINT_VERBOSE("Found %d generated malleable refs for ing\n", mblRefs.size());
    transformMalleableRefs(&mblRefs, mblValues, mblFields, newNodes);

    return argBins;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movq 0x8(%rdx), %rax
cmpq (%rdx), %rax
je 0x69e8f
movq %r9, %r14
movq %r8, %r15
movq %rsi, %r12
movq 0x10(%rbp), %r13
leaq -0x90(%rbp), %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
movq %r9, %r8
callq 0x702c1
leaq -0xc0(%rbp), %rdi
movq %r13, %rsi
callq 0x32d96
leaq -0x90(%rbp), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x69f97
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x69dbe
callq 0x2e360
leaq -0x78(%rbp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
movl $0x1, %ecx
callq 0x6a1a3
movq 0x18(%rbp), %rcx
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cmpq $0x20, %rax
ja 0x69eb9
movq %r12, -0x48(%rbp)
leaq -0x60(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0x70010
movq -0x60(%rbp), %r12
movq -0x58(%rbp), %r13
cmpq %r13, %r12
je 0x69e78
movq %r15, -0x38(%rbp)
movq %r14, -0x40(%rbp)
movq %rbx, -0x30(%rbp)
xorl %ebx, %ebx
leaq -0xa8(%rbp), %r14
movq (%r12), %r15
cmpl $0x4, 0x3c(%r15)
jne 0x69e5e
movq %r14, %rdi
movq 0x10(%rbp), %rsi
callq 0x32d96
movq %r15, %rdi
movq %r14, %rsi
callq 0x708a0
movl %eax, %r15d
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x69e50
callq 0x2e360
movzbl %bl, %ebx
testb %r15b, %r15b
movl $0x1, %eax
cmovnel %eax, %ebx
addq $0x8, %r12
cmpq %r13, %r12
jne 0x69e1a
testb $0x1, %bl
movq -0x30(%rbp), %rbx
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %r15
jne 0x69ea3
movq 0x18(%rbp), %rcx
movl (%rcx), %eax
cmpl $0x1, %eax
je 0x69e9f
cmpl $0x3, %eax
jne 0x69ea3
movl $0x2, %eax
jmp 0x69ea1
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
jmp 0x69efc
xorl %eax, %eax
movl %eax, (%rcx)
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
movq -0x48(%rbp), %r12
je 0x69eb5
callq 0x2e360
movq 0x18(%rbp), %rcx
movl (%rcx), %edx
movq %r12, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq 0x6c0a0
leaq -0x78(%rbp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x648f1
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x69eeb
callq 0x2e360
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x69efc
callq 0x2e360
movq %rbx, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x69f37
movq %rbx, -0x30(%rbp)
movq %rax, %r14
jmp 0x69f75
movq %rax, %r14
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x69f7e
callq 0x2e360
jmp 0x69f7e
movq %rax, %r14
jmp 0x69f7e
movq %rbx, -0x30(%rbp)
movq %rax, %r14
jmp 0x69f67
movq %rax, %r14
jmp 0x69f59
movq %rax, %r14
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x69f59
callq 0x2e360
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x69f67
callq 0x2e360
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x69f75
callq 0x2e360
movq -0x30(%rbp), %rdi
callq 0x3f9d0
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x69f8f
callq 0x2e360
movq %r14, %rdi
callq 0x2e730