// File: /workspace/github_cpp_makefile_star2_O2/eniac[P]Mantis/src/compile/compile_c.cpp
// Function: extractReactionMacro(std::vector<AstNode*, std::allocator<AstNode*>>, std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void extractReactionMacro(std::vector<AstNode*> nodeArray, ostringstream& oss_preprocessor, string out_fn_base) {
    string cinclude_str = "";
    string cdefine_str = "";
	for (auto node : nodeArray) {
        if(typeContains(node, "IncludeNode")) {
            IncludeNode* includenode = dynamic_cast<IncludeNode*>(node);
            if(includenode->macrotype_==IncludeNode::C) {
                if(includenode->toString().find("include")!=string::npos) {
                    cinclude_str += includenode->toString();
                    cinclude_str += "\n";
                } else if (includenode->toString().find("define")!=string::npos) {
                    cdefine_str += includenode->toString();
                    cdefine_str += "\n";
                }
            }
        }
    }

    // Keep preprocessor other than include
    oss_preprocessor << cdefine_str;
    // Include preprocessor goes to seperate tmp file
    std::ofstream os;
    os.open(out_fn_base+"_mantis.include");
    os << cinclude_str << endl;
    os.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rdx, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdi, %rbx
leaq 0x2ac5d(%rip), %r14     # 0x7a8bb
leaq -0x78(%rbp), %rdi
leaq -0x298(%rbp), %rdx
movq %r14, %rsi
callq 0x411c0
leaq -0x58(%rbp), %rdi
leaq -0x298(%rbp), %rdx
movq %r14, %rsi
callq 0x411c0
movq (%rbx), %r14
movq 0x8(%rbx), %r13
leaq -0x298(%rbp), %r12
cmpq %r13, %r14
je 0x4fd8a
movq (%r14), %r15
movq %r15, %rdi
leaq 0x29960(%rip), %rsi     # 0x79608
callq 0x71cf8
testb %al, %al
je 0x4fd81
movq %r15, %rdi
leaq 0x449d1(%rip), %rsi     # 0x94690
leaq 0x44d4a(%rip), %rdx     # 0x94a10
xorl %ecx, %ecx
callq 0x41480
cmpl $0x1, 0x48(%rax)
jne 0x4fd81
movq %rax, %r15
movq (%rax), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *(%rax)
movq %r12, %rdi
leaq 0x29934(%rip), %rsi     # 0x79623
xorl %edx, %edx
callq 0x41880
movq %rax, %rbx
movq %r12, %rdi
callq 0x418c8
cmpq $-0x1, %rbx
je 0x4fd23
movq (%r15), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *(%rax)
leaq -0x78(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x41870
jmp 0x4fd6a
movq (%r15), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *(%rax)
movq %r12, %rdi
leaq 0x298dc(%rip), %rsi     # 0x79614
xorl %edx, %edx
callq 0x41880
movq %rax, %rbx
movq %r12, %rdi
callq 0x418c8
cmpq $-0x1, %rbx
leaq -0x58(%rbp), %rbx
je 0x4fd81
movq (%r15), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x41870
movq %r12, %rdi
callq 0x418c8
movq %rbx, %rdi
leaq 0x29028(%rip), %rsi     # 0x78da4
callq 0x41840
addq $0x8, %r14
jmp 0x4fc92
leaq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x41380
leaq -0x298(%rbp), %rdi
callq 0x41740
leaq 0x29871(%rip), %rdx     # 0x7961b
leaq -0x98(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4df81
leaq -0x298(%rbp), %rdi
leaq -0x98(%rbp), %rsi
pushq $0x10
popq %rdx
callq 0x41230
leaq -0x98(%rbp), %rdi
callq 0x418c8
leaq -0x298(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x41380
movq %rax, %rdi
callq 0x41240
leaq -0x298(%rbp), %rdi
callq 0x415f0
leaq -0x298(%rbp), %rdi
callq 0x41650
leaq -0x58(%rbp), %rdi
callq 0x418c8
leaq -0x78(%rbp), %rdi
callq 0x418c8
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x418c8
jmp 0x4fe55
jmp 0x4fe52
jmp 0x4fe7a
jmp 0x4fe7a
movq %rax, %rbx
jmp 0x4fe86
jmp 0x4fe63
jmp 0x4fe7a
jmp 0x4fe7a
movq %rax, %rbx
leaq -0x298(%rbp), %rdi
callq 0x41650
jmp 0x4fe7d
movq %rax, %rbx
leaq -0x298(%rbp), %rdi
callq 0x418c8
jmp 0x4fe7d
jmp 0x4fe7a
jmp 0x4fe7a
jmp 0x4fe7a
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x418c8
leaq -0x78(%rbp), %rdi
callq 0x418c8
movq %rbx, %rdi
callq 0x41790