// File: eniac[P]Mantis/src/compile/compile_c.cpp
// Function: mirrorFieldArg(std::vector<AstNode*, std::allocator<AstNode*>>, std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char>>&, 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>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
void mirrorFieldArg(std::vector<AstNode*> nodeArray, ostringstream& oss_reaction_mirror, 
                    ostringstream& oss_preprocessor, vector<ReactionArgBin> bins,
                    string prefix_str, bool forIng) {
    for (int i = 0; i < bins.size(); ++i) {
        // Applies to both cases with/without isolation by indexing __mv
        if(forIng) {
            oss_reaction_mirror << str(boost::format(kIngFieldArgPollT) % std::to_string(bins[i].second) % std::to_string(i) % prefix_str);
        } else {
            oss_reaction_mirror << str(boost::format(kEgrFieldArgPollT) % std::to_string(bins[i].second) % std::to_string(i) % prefix_str);
        }

        // Reverse order
        for (int j = bins[i].first.size()-1; j >= 0; --j) {      
            AstNode* arg_node = bins[i].first[j].first->arg_;
            int width = bins[i].first[j].second;
            std::regex e_dot2underscore ("\\.");
            string field_arg_c = std::regex_replace(arg_node->toString(), e_dot2underscore, "_");

            ostringstream oss_mask_tmp;
            oss_mask_tmp << "0b";
            for (int k = 0; k < width; ++k) {
                oss_mask_tmp << "1";
            }
            if(forIng) {
                oss_reaction_mirror << "\n  uint"
                                    << width
                                    << "_t "
                                    << field_arg_c
                                    << "="
                                    << "__mantis__values_riSetArgs_"
                                    << i
                                    << "[1]&"
                                    << oss_mask_tmp.str()
                                    << ";";    
                oss_reaction_mirror << "\n  __mantis__values_riSetArgs_"
                                    << i
                                    << "[1]>>"
                                    << width
                                    << ";";                   
            } else {
                oss_reaction_mirror << "\n  uint"
                                    << width
                                    << "_t "
                                    << field_arg_c
                                    << "="
                                    << "__mantis__values_reSetArgs_"
                                    << i
                                    << "[1]&"
                                    << oss_mask_tmp.str()
                                    << ";";    
                oss_reaction_mirror << "\n  __mantis__values_reSetArgs_"
                                    << i
                                    << "[1]>>"
                                    << width
                                    << ";";   
            }                                       
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x620, %rsp            # imm = 0x620
movq %r8, -0x508(%rbp)
movq %rcx, -0x500(%rbp)
movb %r9b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x500(%rbp), %rdi
movslq -0x30(%rbp), %rax
movq %rax, -0x510(%rbp)
callq 0xd1800
movq %rax, %rcx
movq -0x510(%rbp), %rax
cmpq %rcx, %rax
jae 0xd4945
testb $0x1, -0x29(%rbp)
je 0xd41fa
movq -0x10(%rbp), %rax
movq %rax, -0x518(%rbp)
leaq 0x66a7b(%rip), %rsi     # 0x13ab0d
leaq -0x130(%rbp), %rdi
callq 0xe2f10
movq -0x500(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xe34c0
movl 0x18(%rax), %esi
leaq -0x150(%rbp), %rdi
callq 0xc0780
jmp 0xd40bf
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xe3090
movq %rax, -0x520(%rbp)
jmp 0xd40db
movl -0x30(%rbp), %esi
leaq -0x180(%rbp), %rdi
callq 0xc0780
jmp 0xd40ec
movq -0x520(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0xe3090
movq %rax, -0x528(%rbp)
jmp 0xd4108
movq -0x508(%rbp), %rsi
movq -0x528(%rbp), %rdi
callq 0xe3490
movq %rax, -0x530(%rbp)
jmp 0xd4124
movq -0x530(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xe2ee0
jmp 0xd4136
movq -0x518(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xaa4c0
jmp 0xd4148
leaq -0x50(%rbp), %rdi
callq 0xaabe8
leaq -0x180(%rbp), %rdi
callq 0xaabe8
leaq -0x150(%rbp), %rdi
callq 0xaabe8
leaq -0x130(%rbp), %rdi
callq 0xe30c0
jmp 0xd4380
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xd41e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xd41dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xd41d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xaabe8
leaq -0x180(%rbp), %rdi
callq 0xaabe8
leaq -0x150(%rbp), %rdi
callq 0xaabe8
leaq -0x130(%rbp), %rdi
callq 0xe30c0
jmp 0xd494e
movq -0x10(%rbp), %rax
movq %rax, -0x538(%rbp)
leaq 0x66a1d(%rip), %rsi     # 0x13ac29
leaq -0x280(%rbp), %rdi
callq 0xe2f10
movq -0x500(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xe34c0
movl 0x18(%rax), %esi
leaq -0x2a0(%rbp), %rdi
callq 0xc0780
jmp 0xd4239
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0xe3090
movq %rax, -0x540(%rbp)
jmp 0xd4255
movl -0x30(%rbp), %esi
leaq -0x2c0(%rbp), %rdi
callq 0xc0780
jmp 0xd4266
movq -0x540(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0xe3090
movq %rax, -0x548(%rbp)
jmp 0xd4282
movq -0x508(%rbp), %rsi
movq -0x548(%rbp), %rdi
callq 0xe3490
movq %rax, -0x550(%rbp)
jmp 0xd429e
movq -0x550(%rbp), %rsi
leaq -0x1a0(%rbp), %rdi
callq 0xe2ee0
jmp 0xd42b3
movq -0x538(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0xaa4c0
jmp 0xd42c8
leaq -0x1a0(%rbp), %rdi
callq 0xaabe8
leaq -0x2c0(%rbp), %rdi
callq 0xaabe8
leaq -0x2a0(%rbp), %rdi
callq 0xaabe8
leaq -0x280(%rbp), %rdi
callq 0xe30c0
jmp 0xd4380
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xd436f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xd4363
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xd4357
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0xaabe8
leaq -0x2c0(%rbp), %rdi
callq 0xaabe8
leaq -0x2a0(%rbp), %rdi
callq 0xaabe8
leaq -0x280(%rbp), %rdi
callq 0xe30c0
jmp 0xd494e
movq -0x500(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xe34c0
movq %rax, %rdi
callq 0xd1dd0
subq $0x1, %rax
movl %eax, -0x2c4(%rbp)
cmpl $0x0, -0x2c4(%rbp)
jl 0xd4935
movq -0x500(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0xe34c0
movq %rax, %rdi
movslq -0x2c4(%rbp), %rsi
callq 0xe34e0
movq -0x500(%rbp), %rdi
movq (%rax), %rax
movq 0x40(%rax), %rax
movq %rax, -0x2d0(%rbp)
movslq -0x30(%rbp), %rsi
callq 0xe34c0
movq %rax, %rdi
movslq -0x2c4(%rbp), %rsi
callq 0xe34e0
movl 0x8(%rax), %eax
movl %eax, -0x2d4(%rbp)
leaq 0x6693a(%rip), %rsi     # 0x13ad45
leaq -0x2f8(%rbp), %rdi
movl $0x10, %edx
callq 0xe3150
movq -0x2d0(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x338(%rbp), %rdi
callq *%rax
jmp 0xd4434
leaq 0x67797(%rip), %rcx     # 0x13bbd2
leaq -0x318(%rbp), %rdi
leaq -0x338(%rbp), %rsi
leaq -0x2f8(%rbp), %rdx
xorl %r8d, %r8d
callq 0xe31f0
jmp 0xd445a
leaq -0x338(%rbp), %rdi
callq 0xaabe8
leaq -0x4b0(%rbp), %rdi
callq 0xaa7b0
jmp 0xd4474
leaq 0x668cd(%rip), %rsi     # 0x13ad48
leaq -0x4b0(%rbp), %rdi
callq 0xaa540
jmp 0xd4489
movl $0x0, -0x4b4(%rbp)
movl -0x4b4(%rbp), %eax
cmpl -0x2d4(%rbp), %eax
jge 0xd4535
leaq 0x68ccb(%rip), %rsi     # 0x13d177
leaq -0x4b0(%rbp), %rdi
callq 0xaa540
jmp 0xd44ba
jmp 0xd44bc
movl -0x4b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4b4(%rbp)
jmp 0xd4493
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xd4927
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x338(%rbp), %rdi
callq 0xaabe8
jmp 0xd4927
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xd491b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xd490f
testb $0x1, -0x29(%rbp)
je 0xd470e
movq -0x10(%rbp), %rdi
leaq 0x66801(%rip), %rsi     # 0x13ad4b
callq 0xaa540
movq %rax, -0x558(%rbp)
jmp 0xd4558
movq -0x558(%rbp), %rdi
movl -0x2d4(%rbp), %esi
callq 0xaaa20
movq %rax, -0x560(%rbp)
jmp 0xd4573
movq -0x560(%rbp), %rdi
leaq 0x6762e(%rip), %rsi     # 0x13bbaf
callq 0xaa540
movq %rax, -0x568(%rbp)
jmp 0xd458f
movq -0x568(%rbp), %rdi
leaq -0x318(%rbp), %rsi
callq 0xaa4c0
movq %rax, -0x570(%rbp)
jmp 0xd45ab
movq -0x570(%rbp), %rdi
leaq 0x64234(%rip), %rsi     # 0x1387ed
callq 0xaa540
movq %rax, -0x578(%rbp)
jmp 0xd45c7
movq -0x578(%rbp), %rdi
leaq 0x66786(%rip), %rsi     # 0x13ad5b
callq 0xaa540
movq %rax, -0x580(%rbp)
jmp 0xd45e3
movq -0x580(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0xaaa20
movq %rax, -0x588(%rbp)
jmp 0xd45fb
movq -0x588(%rbp), %rdi
leaq 0x6674a(%rip), %rsi     # 0x13ad53
callq 0xaa540
movq %rax, -0x590(%rbp)
jmp 0xd4617
leaq -0x4d8(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0xaa580
jmp 0xd462c
movq -0x590(%rbp), %rdi
leaq -0x4d8(%rbp), %rsi
callq 0xaa4c0
movq %rax, -0x598(%rbp)
jmp 0xd4648
movq -0x598(%rbp), %rdi
leaq 0x6639f(%rip), %rsi     # 0x13a9f5
callq 0xaa540
jmp 0xd465d
leaq -0x4d8(%rbp), %rdi
callq 0xaabe8
movq -0x10(%rbp), %rdi
leaq 0x666e4(%rip), %rsi     # 0x13ad58
callq 0xaa540
movq %rax, -0x5a0(%rbp)
jmp 0xd4682
movq -0x5a0(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0xaaa20
movq %rax, -0x5a8(%rbp)
jmp 0xd469a
movq -0x5a8(%rbp), %rdi
leaq 0x666cf(%rip), %rsi     # 0x13ad77
callq 0xaa540
movq %rax, -0x5b0(%rbp)
jmp 0xd46b6
movq -0x5b0(%rbp), %rdi
movl -0x2d4(%rbp), %esi
callq 0xaaa20
movq %rax, -0x5b8(%rbp)
jmp 0xd46d1
movq -0x5b8(%rbp), %rdi
leaq 0x66316(%rip), %rsi     # 0x13a9f5
callq 0xaa540
jmp 0xd46e6
jmp 0xd48d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x4d8(%rbp), %rdi
callq 0xaabe8
jmp 0xd490f
movq -0x10(%rbp), %rdi
leaq 0x66632(%rip), %rsi     # 0x13ad4b
callq 0xaa540
movq %rax, -0x5c0(%rbp)
jmp 0xd4727
movq -0x5c0(%rbp), %rdi
movl -0x2d4(%rbp), %esi
callq 0xaaa20
movq %rax, -0x5c8(%rbp)
jmp 0xd4742
movq -0x5c8(%rbp), %rdi
leaq 0x6745f(%rip), %rsi     # 0x13bbaf
callq 0xaa540
movq %rax, -0x5d0(%rbp)
jmp 0xd475e
movq -0x5d0(%rbp), %rdi
leaq -0x318(%rbp), %rsi
callq 0xaa4c0
movq %rax, -0x5d8(%rbp)
jmp 0xd477a
movq -0x5d8(%rbp), %rdi
leaq 0x64065(%rip), %rsi     # 0x1387ed
callq 0xaa540
movq %rax, -0x5e0(%rbp)
jmp 0xd4796
movq -0x5e0(%rbp), %rdi
leaq 0x665dc(%rip), %rsi     # 0x13ad80
callq 0xaa540
movq %rax, -0x5e8(%rbp)
jmp 0xd47b2
movq -0x5e8(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0xaaa20
movq %rax, -0x5f0(%rbp)
jmp 0xd47ca
movq -0x5f0(%rbp), %rdi
leaq 0x6657b(%rip), %rsi     # 0x13ad53
callq 0xaa540
movq %rax, -0x5f8(%rbp)
jmp 0xd47e6
leaq -0x4f8(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0xaa580
jmp 0xd47fb
movq -0x5f8(%rbp), %rdi
leaq -0x4f8(%rbp), %rsi
callq 0xaa4c0
movq %rax, -0x600(%rbp)
jmp 0xd4817
movq -0x600(%rbp), %rdi
leaq 0x661d0(%rip), %rsi     # 0x13a9f5
callq 0xaa540
jmp 0xd482c
leaq -0x4f8(%rbp), %rdi
callq 0xaabe8
movq -0x10(%rbp), %rdi
leaq 0x6653a(%rip), %rsi     # 0x13ad7d
callq 0xaa540
movq %rax, -0x608(%rbp)
jmp 0xd4851
movq -0x608(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0xaaa20
movq %rax, -0x610(%rbp)
jmp 0xd4869
movq -0x610(%rbp), %rdi
leaq 0x66500(%rip), %rsi     # 0x13ad77
callq 0xaa540
movq %rax, -0x618(%rbp)
jmp 0xd4885
movq -0x618(%rbp), %rdi
movl -0x2d4(%rbp), %esi
callq 0xaaa20
movq %rax, -0x620(%rbp)
jmp 0xd48a0
movq -0x620(%rbp), %rdi
leaq 0x66147(%rip), %rsi     # 0x13a9f5
callq 0xaa540
jmp 0xd48b5
jmp 0xd48d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x4f8(%rbp), %rdi
callq 0xaabe8
jmp 0xd490f
leaq -0x4b0(%rbp), %rdi
callq 0xaa130
leaq -0x318(%rbp), %rdi
callq 0xaabe8
leaq -0x2f8(%rbp), %rdi
callq 0xe3460
movl -0x2c4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0xd43a2
leaq -0x4b0(%rbp), %rdi
callq 0xaa130
leaq -0x318(%rbp), %rdi
callq 0xaabe8
leaq -0x2f8(%rbp), %rdi
callq 0xe3460
jmp 0xd494e
jmp 0xd4937
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xd404c
addq $0x620, %rsp            # imm = 0x620
popq %rbp
retq
movq -0x158(%rbp), %rdi
callq 0xaaa60
nopw (%rax,%rax)