// File: eniac[P]Mantis/src/compile/compile_p4.cpp
// Function: generateExportControl(std::vector<AstNode*, std::allocator<AstNode*>>*, std::vector<std::pair<std::vector<std::pair<ReactionArgNode*, int>, std::allocator<std::pair<ReactionArgNode*, int>>>, int>, std::allocator<std::pair<std::vector<std::pair<ReactionArgNode*, int>, std::allocator<std::pair<ReactionArgNode*, int>>>, int>>> const&, std::vector<std::pair<std::vector<std::pair<ReactionArgNode*, int>, std::allocator<std::pair<ReactionArgNode*, int>>>, int>, std::allocator<std::pair<std::vector<std::pair<ReactionArgNode*, int>, std::allocator<std::pair<ReactionArgNode*, int>>>, int>>> const&)
void generateExportControl(vector<AstNode*>* newNodes,
                           const vector<ReactionArgBin>& argBinsIng, const vector<ReactionArgBin>& argBinsEgr){
    ostringstream oss;
    oss << "control " << kSetargsIngControlName << " {\n";
    for (int i = 0; i < argBinsIng.size(); ++i) {
        oss << "  apply(__tiPack" << i << ");\n";
        oss << "  apply(__tiSetArgs" << i << ");\n";
    }
    oss << "}\n\n";

    newNodes->push_back(new UnanchoredNode(new string(oss.str()),
                                           new string("control"),
                                           new string(kSetargsIngControlName)));

    oss.str("");
    oss << "control " << kSetargsEgrControlName << " {\n";
    for (int i = 0; i < argBinsEgr.size(); ++i) {
        oss << "  apply(__tePack" << i << ");\n";
        oss << "  apply(__teSetArgs" << i << ");\n";
    }
    oss << "}\n\n";

    newNodes->push_back(new UnanchoredNode(new string(oss.str()),
                                           new string("control"),
                                           new string(kSetargsEgrControlName)));

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x190(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0xaa7b0
movq -0x1f8(%rbp), %rdi
leaq 0x24281(%rip), %rsi     # 0x13df29
callq 0xaa540
movq %rax, -0x1f0(%rbp)
jmp 0x119cb6
movq -0x1f0(%rbp), %rdi
leaq 0x240f1(%rip), %rsi     # 0x13ddb5
callq 0xaa540
movq %rax, -0x200(%rbp)
jmp 0x119cd2
movq -0x200(%rbp), %rdi
leaq 0x242b7(%rip), %rsi     # 0x13df97
callq 0xaa540
jmp 0x119ce7
movl $0x0, -0x1a0(%rbp)
movslq -0x1a0(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x10(%rbp), %rdi
callq 0xd1800
movq %rax, %rcx
movq -0x208(%rbp), %rax
cmpq %rcx, %rax
jae 0x119de0
leaq 0x24210(%rip), %rsi     # 0x13df32
leaq -0x190(%rbp), %rdi
callq 0xaa540
movq %rax, -0x210(%rbp)
jmp 0x119d37
movq -0x210(%rbp), %rdi
movl -0x1a0(%rbp), %esi
callq 0xaaa20
movq %rax, -0x218(%rbp)
jmp 0x119d52
movq -0x218(%rbp), %rdi
leaq 0x200d4(%rip), %rsi     # 0x139e34
callq 0xaa540
jmp 0x119d67
leaq 0x241d5(%rip), %rsi     # 0x13df43
leaq -0x190(%rbp), %rdi
callq 0xaa540
movq %rax, -0x220(%rbp)
jmp 0x119d83
movq -0x220(%rbp), %rdi
movl -0x1a0(%rbp), %esi
callq 0xaaa20
movq %rax, -0x228(%rbp)
jmp 0x119d9e
movq -0x228(%rbp), %rdi
leaq 0x20088(%rip), %rsi     # 0x139e34
callq 0xaa540
jmp 0x119db3
jmp 0x119db5
movl -0x1a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a0(%rbp)
jmp 0x119cf1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x11a414
leaq 0x2466e(%rip), %rsi     # 0x13e455
leaq -0x190(%rbp), %rdi
callq 0xaa540
jmp 0x119df5
movq -0x8(%rbp), %rax
movq %rax, -0x238(%rbp)
movl $0x58, %edi
callq 0xaa560
movq %rax, -0x230(%rbp)
jmp 0x119e13
movb $0x1, -0x1ad(%rbp)
movl $0x20, %edi
callq 0xaa560
movq %rax, -0x240(%rbp)
jmp 0x119e2d
movq -0x240(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0xaa580
jmp 0x119e42
movl $0x20, %edi
callq 0xaa560
movq %rax, -0x248(%rbp)
jmp 0x119e55
movb $0x1, -0x1aa(%rbp)
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0xaaa70
movq -0x248(%rbp), %rdi
movq -0x250(%rbp), %rdx
leaq 0x240d3(%rip), %rsi     # 0x13df57
callq 0xaa7d0
jmp 0x119e8b
movb $0x0, -0x1aa(%rbp)
movl $0x20, %edi
callq 0xaa560
movq %rax, -0x258(%rbp)
jmp 0x119ea5
movb $0x1, -0x1ac(%rbp)
leaq -0x1ab(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0xaaa70
movq -0x258(%rbp), %rdi
movq -0x260(%rbp), %rdx
leaq 0x23ee1(%rip), %rsi     # 0x13ddb5
callq 0xaa7d0
jmp 0x119edb
movq -0x258(%rbp), %rcx
movq -0x248(%rbp), %rdx
movq -0x240(%rbp), %rsi
movq -0x230(%rbp), %rdi
movb $0x0, -0x1ac(%rbp)
callq 0xcaee0
jmp 0x119f05
movq -0x238(%rbp), %rdi
movq -0x230(%rbp), %rax
movb $0x0, -0x1ad(%rbp)
movq %rax, -0x1a8(%rbp)
leaq -0x1a8(%rbp), %rsi
callq 0xb2540
jmp 0x119f2f
leaq -0x1ab(%rbp), %rdi
callq 0xaa5f0
leaq -0x1a9(%rbp), %rdi
callq 0xaa5f0
leaq -0x1d1(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0xaaa70
movq -0x268(%rbp), %rdx
leaq 0x21c3b(%rip), %rsi     # 0x13bba3
leaq -0x1d0(%rbp), %rdi
callq 0xaa7d0
jmp 0x119f76
leaq -0x190(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0xaa2c0
jmp 0x119f8b
leaq -0x1d0(%rbp), %rdi
callq 0xaabe8
leaq -0x1d1(%rbp), %rdi
callq 0xaa5f0
leaq 0x23f7f(%rip), %rsi     # 0x13df29
leaq -0x190(%rbp), %rdi
callq 0xaa540
movq %rax, -0x270(%rbp)
jmp 0x119fbf
movq -0x270(%rbp), %rdi
leaq 0x23ea5(%rip), %rsi     # 0x13de72
callq 0xaa540
movq %rax, -0x278(%rbp)
jmp 0x119fdb
movq -0x278(%rbp), %rdi
leaq 0x23fae(%rip), %rsi     # 0x13df97
callq 0xaa540
jmp 0x119ff0
movl $0x0, -0x1d8(%rbp)
movslq -0x1d8(%rbp), %rax
movq %rax, -0x280(%rbp)
movq -0x18(%rbp), %rdi
callq 0xd1800
movq %rax, %rcx
movq -0x280(%rbp), %rax
cmpq %rcx, %rax
jae 0x11a1d8
leaq 0x23f34(%rip), %rsi     # 0x13df5f
leaq -0x190(%rbp), %rdi
callq 0xaa540
movq %rax, -0x288(%rbp)
jmp 0x11a040
movq -0x288(%rbp), %rdi
movl -0x1d8(%rbp), %esi
callq 0xaaa20
movq %rax, -0x290(%rbp)
jmp 0x11a05b
movq -0x290(%rbp), %rdi
leaq 0x1fdcb(%rip), %rsi     # 0x139e34
callq 0xaa540
jmp 0x11a070
leaq 0x23ef9(%rip), %rsi     # 0x13df70
leaq -0x190(%rbp), %rdi
callq 0xaa540
movq %rax, -0x298(%rbp)
jmp 0x11a08c
movq -0x298(%rbp), %rdi
movl -0x1d8(%rbp), %esi
callq 0xaaa20
movq %rax, -0x2a0(%rbp)
jmp 0x11a0a7
movq -0x2a0(%rbp), %rdi
leaq 0x1fd7f(%rip), %rsi     # 0x139e34
callq 0xaa540
jmp 0x11a0bc
jmp 0x11a0be
movl -0x1d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d8(%rbp)
jmp 0x119ffa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x11a179
movq -0x240(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
callq 0xaa4e0
jmp 0x11a179
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x11a154
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x1ab(%rbp), %rdi
callq 0xaa5f0
testb $0x1, -0x1ac(%rbp)
jne 0x11a146
jmp 0x11a152
movq -0x258(%rbp), %rdi
callq 0xaa4e0
jmp 0x11a154
leaq -0x1a9(%rbp), %rdi
callq 0xaa5f0
testb $0x1, -0x1aa(%rbp)
jne 0x11a16b
jmp 0x11a177
movq -0x248(%rbp), %rdi
callq 0xaa4e0
jmp 0x11a179
testb $0x1, -0x1ad(%rbp)
jne 0x11a184
jmp 0x11a190
movq -0x230(%rbp), %rdi
callq 0xaa4e0
jmp 0x11a414
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x11a1c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0xaabe8
leaq -0x1d1(%rbp), %rdi
callq 0xaa5f0
jmp 0x11a414
leaq 0x24276(%rip), %rsi     # 0x13e455
leaq -0x190(%rbp), %rdi
callq 0xaa540
jmp 0x11a1ed
movq -0x8(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movl $0x58, %edi
callq 0xaa560
movq %rax, -0x2a8(%rbp)
jmp 0x11a20b
movb $0x1, -0x1e5(%rbp)
movl $0x20, %edi
callq 0xaa560
movq %rax, -0x2b8(%rbp)
jmp 0x11a225
movq -0x2b8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0xaa580
jmp 0x11a23a
movl $0x20, %edi
callq 0xaa560
movq %rax, -0x2c0(%rbp)
jmp 0x11a24d
movb $0x1, -0x1e2(%rbp)
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0xaaa70
movq -0x2c0(%rbp), %rdi
movq -0x2c8(%rbp), %rdx
leaq 0x23cdb(%rip), %rsi     # 0x13df57
callq 0xaa7d0
jmp 0x11a283
movb $0x0, -0x1e2(%rbp)
movl $0x20, %edi
callq 0xaa560
movq %rax, -0x2d0(%rbp)
jmp 0x11a29d
movb $0x1, -0x1e4(%rbp)
leaq -0x1e3(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0xaaa70
movq -0x2d0(%rbp), %rdi
movq -0x2d8(%rbp), %rdx
leaq 0x23ba6(%rip), %rsi     # 0x13de72
callq 0xaa7d0
jmp 0x11a2d3
movq -0x2d0(%rbp), %rcx
movq -0x2c0(%rbp), %rdx
movq -0x2b8(%rbp), %rsi
movq -0x2a8(%rbp), %rdi
movb $0x0, -0x1e4(%rbp)
callq 0xcaee0
jmp 0x11a2fd
movq -0x2b0(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movb $0x0, -0x1e5(%rbp)
movq %rax, -0x1e0(%rbp)
leaq -0x1e0(%rbp), %rsi
callq 0xb2540
jmp 0x11a327
leaq -0x1e3(%rbp), %rdi
callq 0xaa5f0
leaq -0x1e1(%rbp), %rdi
callq 0xaa5f0
leaq -0x190(%rbp), %rdi
callq 0xaa130
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x11a3fb
movq -0x2b8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
callq 0xaa4e0
jmp 0x11a3fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x11a3d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x1e3(%rbp), %rdi
callq 0xaa5f0
testb $0x1, -0x1e4(%rbp)
jne 0x11a3c8
jmp 0x11a3d4
movq -0x2d0(%rbp), %rdi
callq 0xaa4e0
jmp 0x11a3d6
leaq -0x1e1(%rbp), %rdi
callq 0xaa5f0
testb $0x1, -0x1e2(%rbp)
jne 0x11a3ed
jmp 0x11a3f9
movq -0x2c0(%rbp), %rdi
callq 0xaa4e0
jmp 0x11a3fb
testb $0x1, -0x1e5(%rbp)
jne 0x11a406
jmp 0x11a412
movq -0x2a8(%rbp), %rdi
callq 0xaa4e0
jmp 0x11a414
leaq -0x190(%rbp), %rdi
callq 0xaa130
movq -0x198(%rbp), %rdi
callq 0xaaa60
nopl (%rax)