// File: /workspace/github_cpp_makefile_star2_O2/eniac[P]Mantis/src/compile/compile_p4.cpp
// Function: generateArgRegistersForIng(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&, int, bool)
static void generateArgRegistersForIng(vector<AstNode*>* newNodes,
                          const vector<ReactionArgBin>& bins, int ing_iso_opt, bool forIng) {
    string p4rArgHdrName;
    string p4rMetaName;
    string p4rSetArgsTableNameBase;
    string p4rSetArgsActionNameBase;
    string p4rSetArgsBlackboxNameBase;
    string p4rSetArgsRegNameBase;
    if(forIng) {
        p4rArgHdrName = std::string(kP4rIngArghdrName);
        p4rMetaName = std::string(kP4rIngMetadataName);
        p4rSetArgsTableNameBase = "__tiSetArgs";
        p4rSetArgsActionNameBase = "__aiSetArgs";
        p4rSetArgsBlackboxNameBase = "__biSetArgs";
        p4rSetArgsRegNameBase = "__riSetArgs";
    } else {
        p4rArgHdrName = std::string(kP4rEgrArghdrName);
        p4rMetaName = std::string(kP4rEgrMetadataName);
        p4rSetArgsTableNameBase = "__teSetArgs";
        p4rSetArgsActionNameBase = "__aeSetArgs";
        p4rSetArgsBlackboxNameBase = "__beSetArgs";
        p4rSetArgsRegNameBase = "__reSetArgs";
    }

    for (int i = 0; i < bins.size(); ++i) {
        ostringstream oss;
        oss << "table " << p4rSetArgsTableNameBase << i << " {\n"
            << "  actions { " << p4rSetArgsActionNameBase << i << "; }\n"
            << "  default_action : " << p4rSetArgsActionNameBase << i << "();\n"
            << "}\n\n"
            << "action " << p4rSetArgsActionNameBase << i << "() {\n";
        if (((unsigned int)ing_iso_opt) & 0b1) {
            oss << "  " << p4rSetArgsBlackboxNameBase << i << ".execute_stateful_alu("<< p4rMetaName << ".__mv);\n";
        } else {
            oss << "  " << p4rSetArgsBlackboxNameBase << i << ".execute_stateful_alu(0);\n";
        }
        oss << "}\n\n"
            << "blackbox stateful_alu " << p4rSetArgsBlackboxNameBase << i << " {\n"
            << "  reg : " << p4rSetArgsRegNameBase << i << ";\n"
            << "  update_lo_1_value : " << p4rArgHdrName
                                       << ".reg" << i << ";\n"
            << "}\n\n"
            << "register " << p4rSetArgsRegNameBase << i << " {\n"
            << "  width : " << bins[i].second << ";\n"
            << "  instance_count : 2;\n"
            << "}\n\n";

        auto newSetArgsNode = new UnanchoredNode(new string(oss.str()),
                                                 new string("table"),
                                                 new string("__tiSetArgs"));
        newNodes->push_back(newSetArgsNode);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movl %edx, -0x3c(%rbp)
movq %rsi, -0x50(%rbp)
movq %rdi, -0x58(%rbp)
leaq -0x108(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0xe8(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
xorl %esi, %esi
movb %sil, (%rax)
leaq -0xc8(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0x88(%rbp), %rdi
movq %rdi, -0x10(%rdi)
andq $0x0, -0x8(%rdi)
movb %sil, (%rdx)
movb %sil, (%rax)
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0xa8(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %sil, (%rdi)
movb %sil, (%rax)
movb %sil, (%rdx)
testl %ecx, %ecx
je 0x6f510
leaq 0xdb72(%rip), %rsi      # 0x7cfe4
leaq -0x290(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x411c0
leaq -0x118(%rbp), %rdi
leaq -0x290(%rbp), %rbx
movq %rbx, %rsi
callq 0x41500
movq %rbx, %rdi
callq 0x418c8
leaq 0xb734(%rip), %rsi      # 0x7abdb
leaq -0x290(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x411c0
leaq -0xf8(%rbp), %rdi
movq %rbx, %rsi
callq 0x41500
movq %rbx, %rdi
callq 0x418c8
leaq 0xd73e(%rip), %rsi      # 0x7cc13
leaq -0xd8(%rbp), %rdi
callq 0x41850
leaq 0xdcc6(%rip), %rsi      # 0x7d1ae
leaq -0x98(%rbp), %rdi
callq 0x41850
leaq 0xdcbf(%rip), %rsi      # 0x7d1ba
leaq -0x78(%rbp), %rdi
callq 0x41850
leaq 0xdcbb(%rip), %rsi      # 0x7d1c6
jmp 0x6f5b0
leaq 0xdb23(%rip), %rsi      # 0x7d03a
leaq -0x290(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x411c0
leaq -0x118(%rbp), %rdi
leaq -0x290(%rbp), %rbx
movq %rbx, %rsi
callq 0x41500
movq %rbx, %rdi
callq 0x418c8
leaq 0xb6ad(%rip), %rsi      # 0x7abf9
leaq -0x290(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x411c0
leaq -0xf8(%rbp), %rdi
movq %rbx, %rsi
callq 0x41500
movq %rbx, %rdi
callq 0x418c8
leaq 0xd6c6(%rip), %rsi      # 0x7cc40
leaq -0xd8(%rbp), %rdi
callq 0x41850
leaq 0xdc45(%rip), %rsi      # 0x7d1d2
leaq -0x98(%rbp), %rdi
callq 0x41850
leaq 0xdc3e(%rip), %rsi      # 0x7d1de
leaq -0x78(%rbp), %rdi
callq 0x41850
leaq 0xdc3a(%rip), %rsi      # 0x7d1ea
leaq -0xb8(%rbp), %rdi
callq 0x41850
pushq $0x18
popq %rax
movq %rax, -0x48(%rbp)
xorl %r13d, %r13d
movq -0x50(%rbp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x5, %rax
cmpq %r13, %rax
jbe 0x6f968
leaq -0x290(%rbp), %rbx
movq %rbx, %rdi
callq 0x415a0
movq %rbx, %rdi
leaq 0x97af(%rip), %rsi      # 0x78da6
callq 0x413d0
movq %rax, %rdi
leaq -0xd8(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
movq %rax, %rdi
leaq 0xd63f(%rip), %rsi      # 0x7cc5f
callq 0x413d0
movq %rax, %rdi
leaq 0xdbc7(%rip), %rsi      # 0x7d1f6
callq 0x413d0
movq %rax, %rdi
leaq -0x98(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
movq %rax, %rdi
leaq 0xdbab(%rip), %rsi      # 0x7d203
callq 0x413d0
movq %rax, %rdi
leaq 0xda1d(%rip), %rsi      # 0x7d084
callq 0x413d0
movq %rax, %rdi
leaq -0x98(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
movq %rax, %rdi
leaq 0xd3e8(%rip), %rsi      # 0x7ca78
callq 0x413d0
movq %rax, %rdi
leaq 0xda7e(%rip), %rsi      # 0x7d11d
callq 0x413d0
movq %rax, %rdi
leaq 0x9be5(%rip), %rsi      # 0x79293
callq 0x413d0
movq %rax, %rdi
leaq -0x98(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
movq %rax, %rdi
leaq 0xdb31(%rip), %rsi      # 0x7d208
callq 0x413d0
testb $0x1, -0x3c(%rbp)
jne 0x6f715
leaq -0x290(%rbp), %rdi
leaq 0xb960(%rip), %rsi      # 0x7b050
callq 0x413d0
movq %rax, %rdi
leaq -0x78(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
leaq 0xdb04(%rip), %rsi      # 0x7d217
jmp 0x6f764
leaq -0x290(%rbp), %rdi
leaq 0xb92d(%rip), %rsi      # 0x7b050
callq 0x413d0
movq %rax, %rdi
leaq -0x78(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
movq %rax, %rdi
leaq 0xd616(%rip), %rsi      # 0x7cd5f
callq 0x413d0
movq %rax, %rdi
leaq -0xf8(%rbp), %rsi
callq 0x41380
leaq 0xdaaa(%rip), %rsi      # 0x7d20e
movq %rax, %rdi
callq 0x413d0
leaq -0x290(%rbp), %rdi
leaq 0xd9a3(%rip), %rsi      # 0x7d11d
callq 0x413d0
movq %rax, %rdi
leaq 0xd542(%rip), %rsi      # 0x7cccb
callq 0x413d0
movq %rax, %rdi
leaq -0x78(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
movq %rax, %rdi
leaq 0xd4b0(%rip), %rsi      # 0x7cc5f
callq 0x413d0
movq %rax, %rdi
leaq 0xd52b(%rip), %rsi      # 0x7cce9
callq 0x413d0
movq %rax, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
movq %rax, %rdi
leaq 0x961e(%rip), %rsi      # 0x78e05
callq 0x413d0
movq %rax, %rdi
leaq 0xd524(%rip), %rsi      # 0x7cd1a
callq 0x413d0
movq %rax, %rdi
leaq -0x118(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
leaq 0xda1e(%rip), %rsi      # 0x7d232
callq 0x413d0
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
movq %rax, %rdi
leaq 0x95d7(%rip), %rsi      # 0x78e05
callq 0x413d0
movq %rax, %rdi
leaq 0xd8e0(%rip), %rsi      # 0x7d11d
callq 0x413d0
movq %rax, %rdi
leaq 0x9524(%rip), %rsi      # 0x78d70
callq 0x413d0
movq %rax, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
movl %r13d, %esi
callq 0x41760
movq %rax, %rdi
leaq 0xd3ea(%rip), %rsi      # 0x7cc5f
callq 0x413d0
movq %rax, %rdi
leaq 0xd9b3(%rip), %rsi      # 0x7d237
callq 0x413d0
movq -0x50(%rbp), %rcx
movq (%rcx), %rcx
movq -0x48(%rbp), %rdx
movl (%rcx,%rdx), %esi
movq %rax, %rdi
callq 0x41760
movq %rax, %rdi
leaq 0x955c(%rip), %rsi      # 0x78e05
callq 0x413d0
movq %rax, %rdi
leaq 0xd98a(%rip), %rsi      # 0x7d242
callq 0x413d0
movq %rax, %rdi
leaq 0xd856(%rip), %rsi      # 0x7d11d
callq 0x413d0
pushq $0x58
popq %rdi
callq 0x413f0
movq %rax, %r15
pushq $0x20
popq %rdi
callq 0x413f0
movq %rax, %rbx
movq %rax, %rdi
leaq -0x288(%rbp), %rsi
callq 0x416b0
pushq $0x20
popq %rdi
callq 0x413f0
movq %rax, %r14
movq %rax, %rdi
leaq 0xd48b(%rip), %rsi      # 0x7cd91
leaq -0x38(%rbp), %rdx
callq 0x411c0
pushq $0x20
popq %rdi
callq 0x413f0
movq %rax, %r12
movq %rax, %rdi
leaq 0xd2ef(%rip), %rsi      # 0x7cc13
leaq -0x29(%rbp), %rdx
callq 0x411c0
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x4dd8e
movq %r15, -0x38(%rbp)
movq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x44d46
leaq -0x290(%rbp), %rdi
callq 0x410e0
incq %r13
addq $0x20, -0x48(%rbp)
jmp 0x6f5c6
leaq -0xb8(%rbp), %rdi
callq 0x418c8
leaq -0x78(%rbp), %rdi
callq 0x418c8
leaq -0x98(%rbp), %rdi
callq 0x418c8
leaq -0xd8(%rbp), %rdi
callq 0x418c8
leaq -0xf8(%rbp), %rdi
callq 0x418c8
leaq -0x118(%rbp), %rdi
callq 0x418c8
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6f9ee
jmp 0x6f9ee
jmp 0x6f9ee
jmp 0x6f9ee
jmp 0x6f9ee
jmp 0x6fa00
jmp 0x6f9f3
jmp 0x6f9f3
movq %rax, %r13
movq %r12, %rdi
jmp 0x6f9e5
movq %rax, %r13
movq %r14, %rdi
jmp 0x6f9e5
movq %rax, %r13
movq %rbx, %rdi
callq 0x413a0
jmp 0x6f9f6
jmp 0x6fa00
movq %rax, %r13
jmp 0x6fa0f
movq %rax, %r13
movq %r15, %rdi
callq 0x413a0
jmp 0x6fa03
movq %rax, %r13
leaq -0x290(%rbp), %rdi
callq 0x410e0
leaq -0xb8(%rbp), %rdi
callq 0x418c8
leaq -0x78(%rbp), %rdi
callq 0x418c8
leaq -0x98(%rbp), %rdi
callq 0x418c8
leaq -0xd8(%rbp), %rdi
callq 0x418c8
leaq -0xf8(%rbp), %rdi
callq 0x418c8
leaq -0x118(%rbp), %rdi
callq 0x418c8
movq %r13, %rdi
callq 0x41790