// File: /workspace/github_cpp_makefile_star2_O2/eniac[P]Mantis/src/compile/compile.cpp
// Function: compileP4Code(std::vector<AstNode*, std::allocator<AstNode*>>*)
vector<AstNode*> compileP4Code(vector<AstNode*>* nodeArray) {

    ing_iso_opt = inferIsoOptForIng(nodeArray, true);
    egr_iso_opt = inferIsoOptForIng(nodeArray, false);

    transformPragma(nodeArray);

    findAndRemoveMalleables(&mblValues, &mblFields, &mblTables, *nodeArray);

    vector<MblRefNode*> mblRefs;
    findMalleableRefs(&mblRefs, *nodeArray);

    // Visitor pass to find the corresponding usage
    findMalleableUsage(mblRefs, mblValues, mblFields, nodeArray, &mblUsages);

    // Transform all references to mbls into references to the appropriate metadata
    transformMalleableRefs(&mblRefs, mblValues, mblFields, nodeArray);

    transformMalleableTables(&mblTables, *nodeArray, ing_iso_opt, egr_iso_opt);

    auto newNodes = vector<AstNode*>();

    generateMetadata(&newNodes, mblValues, mblFields, ing_iso_opt, egr_iso_opt);
    num_init_mbls_ing = generateInitTableForIng(&mblUsages, &newNodes, mblValues, mblFields, ing_iso_opt, true);
    num_init_mbls_egr = generateInitTableForIng(&mblUsages, &newNodes, mblValues, mblFields, egr_iso_opt, false);

    generateSetvarControl(&newNodes);

    // Measurement code
    HeaderDecsMap headerDecsMap = findHeaderDecs(*nodeArray);
    vector<ReactionArgNode*> reaction_args = findReactionArgs(*nodeArray);

    global_ing_bins = generateIngDigestPacking(&newNodes, reaction_args, headerDecsMap,
                    mblValues, mblFields, *nodeArray, &ing_iso_opt);
    global_egr_bins = generateEgrDigestPacking(&newNodes, reaction_args, headerDecsMap,
                    mblValues, mblFields, *nodeArray, &egr_iso_opt);    

    // After packing, iso_opt is firm
    augmentRegisterArgProgForIng(&newNodes, nodeArray, reaction_args, ing_iso_opt, true);   
    augmentRegisterArgProgForIng(&newNodes, nodeArray, reaction_args, egr_iso_opt, false);  

    generateDupRegArgProg(&newNodes, nodeArray, reaction_args, ing_iso_opt, egr_iso_opt);

    generateRegArgGateControl(&newNodes, nodeArray, reaction_args, ing_iso_opt, egr_iso_opt);

    generateExportControl(&newNodes, global_ing_bins, global_egr_bins);

    // Finally, assemble ingress/egress
    augmentIngress(nodeArray);
    augmentEgress(nodeArray); 

    return newNodes;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %r14
movq %rdi, %rbx
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x6945f
movl %eax, 0x484a1(%rip)     # 0x96484
movq %r14, %rdi
xorl %esi, %esi
callq 0x6945f
movl %eax, 0x48495(%rip)     # 0x96488
movq %r14, %rdi
callq 0x693c8
leaq 0x48a26(%rip), %rdi     # 0x96a28
leaq 0x48a57(%rip), %rsi     # 0x96a60
leaq 0x48a88(%rip), %rdx     # 0x96a98
movq %r14, %rcx
callq 0x720d3
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq %r14, %rsi
callq 0x72216
leaq -0x98(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4ecda
leaq 0x489e2(%rip), %rsi     # 0x96a28
leaq -0x140(%rbp), %rdi
callq 0x4f1d0
leaq 0x48a07(%rip), %rsi     # 0x96a60
leaq -0x108(%rbp), %rdi
callq 0x4f476
leaq 0x48984(%rip), %r8      # 0x969f0
leaq -0x98(%rbp), %rdi
leaq -0x140(%rbp), %rsi
leaq -0x108(%rbp), %rdx
movq %r14, %rcx
callq 0x69d63
leaq -0x108(%rbp), %rdi
callq 0x4ef64
leaq -0x140(%rbp), %rdi
callq 0x4eea0
leaq -0x98(%rbp), %rdi
callq 0x4f7f8
leaq 0x48974(%rip), %rsi     # 0x96a28
leaq 0x489a5(%rip), %rdx     # 0x96a60
leaq -0x50(%rbp), %rdi
movq %r14, %rcx
callq 0x6a14f
leaq -0x80(%rbp), %rdi
movq %r14, %rsi
callq 0x4486c
movl 0x483ab(%rip), %edx     # 0x96484
movl 0x483a9(%rip), %ecx     # 0x96488
leaq 0x489b2(%rip), %rdi     # 0x96a98
leaq -0x80(%rbp), %rsi
callq 0x6ab80
leaq -0x80(%rbp), %rdi
callq 0x44be0
andq $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movl 0x4837b(%rip), %ecx     # 0x96484
movl 0x48378(%rip), %r8d     # 0x96488
leaq 0x48911(%rip), %rsi     # 0x96a28
leaq 0x48942(%rip), %rdx     # 0x96a60
movq %rbx, %rdi
callq 0x6fc62
movl 0x48357(%rip), %r8d     # 0x96484
leaq 0x488bc(%rip), %rdi     # 0x969f0
leaq 0x488ed(%rip), %rdx     # 0x96a28
leaq 0x4891e(%rip), %rcx     # 0x96a60
pushq $0x1
popq %r9
movq %rbx, %rsi
callq 0x701c9
movl %eax, 0x48338(%rip)     # 0x9648c
movl 0x4832d(%rip), %r8d     # 0x96488
leaq 0x4888e(%rip), %rdi     # 0x969f0
leaq 0x488bf(%rip), %rdx     # 0x96a28
leaq 0x488f0(%rip), %rcx     # 0x96a60
movq %rbx, %rsi
xorl %r9d, %r9d
callq 0x701c9
movl %eax, 0x4830f(%rip)     # 0x96490
movq %rbx, %rdi
callq 0x7095f
leaq -0xd0(%rbp), %rdi
movq %r14, %rsi
callq 0x727ca
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x7272a
leaq 0x482d9(%rip), %rax     # 0x96484
leaq 0x48876(%rip), %r8      # 0x96a28
leaq 0x488a7(%rip), %r9      # 0x96a60
leaq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
movq %rbx, %rsi
pushq %rax
pushq %r14
callq 0x6dd84
popq %rax
popq %rcx
leaq 0x487e4(%rip), %rdi     # 0x969c0
leaq -0x68(%rbp), %r15
movq %r15, %rsi
callq 0x4f890
movq %r15, %rdi
callq 0x4ec7c
leaq 0x48291(%rip), %rax     # 0x96488
leaq 0x4882a(%rip), %r8      # 0x96a28
leaq 0x4885b(%rip), %r9      # 0x96a60
leaq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
movq %rbx, %rsi
pushq %rax
pushq %r14
callq 0x6fa5c
popq %rax
popq %rcx
leaq 0x487b0(%rip), %rdi     # 0x969d8
movq %r15, %rsi
callq 0x4f890
movq %r15, %rdi
callq 0x4ec7c
movl 0x48246(%rip), %ecx     # 0x96484
leaq -0x30(%rbp), %rdx
pushq $0x1
popq %r8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6ce73
movl 0x48231(%rip), %ecx     # 0x96488
leaq -0x30(%rbp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r8d, %r8d
callq 0x6ce73
movl 0x48215(%rip), %ecx     # 0x96484
movl 0x48212(%rip), %r8d     # 0x96488
leaq -0x30(%rbp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6b7b6
movl 0x481f9(%rip), %ecx     # 0x96484
movl 0x481f6(%rip), %r8d     # 0x96488
leaq -0x30(%rbp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6b199
leaq 0x48718(%rip), %rsi     # 0x969c0
leaq 0x48729(%rip), %rdx     # 0x969d8
movq %rbx, %rdi
callq 0x6ae2b
movq %r14, %rdi
callq 0x698af
movq %r14, %rdi
callq 0x69b09
leaq -0x30(%rbp), %rdi
callq 0x4f87c
leaq -0xd0(%rbp), %rdi
callq 0x4f6e6
leaq -0x50(%rbp), %rdi
callq 0x4f7f8
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4e347
jmp 0x4e347
movq %rax, %r14
jmp 0x4e353
jmp 0x4e33d
movq %rax, %r14
leaq -0x80(%rbp), %rdi
jmp 0x4e362
movq %rax, %r14
leaq -0x108(%rbp), %rdi
callq 0x4ef64
jmp 0x4e31e
movq %rax, %r14
leaq -0x140(%rbp), %rdi
callq 0x4eea0
jmp 0x4e32f
movq %rax, %r14
leaq -0x98(%rbp), %rdi
callq 0x4f7f8
jmp 0x4e367
movq %rax, %r14
jmp 0x4e35f
movq %rax, %r14
jmp 0x4e367
movq %rax, %r14
leaq -0x30(%rbp), %rdi
callq 0x4f87c
leaq -0xd0(%rbp), %rdi
callq 0x4f6e6
movq %rbx, %rdi
callq 0x44be0
leaq -0x50(%rbp), %rdi
callq 0x4f7f8
movq %r14, %rdi
callq 0x41790