// File: /workspace/github_cpp_makefile_star2_O1/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, -0x78(%rbp)
movq %rsi, -0x80(%rbp)
movq %rdi, %rbx
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x37359(%rip), %r14     # 0x778db
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x33112
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x33112
movq (%rbx), %r12
movq 0x8(%rbx), %rbx
cmpq %rbx, %r12
je 0x40750
leaq 0x36069(%rip), %r13     # 0x76628
leaq 0x4c06a(%rip), %r14     # 0x8c630
movq %rbx, -0x30(%rbp)
movq (%r12), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x6f390
testb %al, %al
je 0x40743
movq %r15, %rdi
movq %r14, %rsi
leaq 0x4c3c2(%rip), %rdx     # 0x8c9b0
xorl %ecx, %ecx
callq 0x2e430
cmpl $0x1, 0x48(%rax)
jne 0x40743
movq %rax, %r15
movq %r13, %rbx
movq %r14, %r13
movq (%rax), %rax
leaq -0x2a0(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq *(%rax)
movl $0x7, %ecx
movq %r14, %rdi
leaq 0x3601a(%rip), %rsi     # 0x76643
xorl %edx, %edx
callq 0x2e710
movq %rax, %r14
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
je 0x4064b
callq 0x2e360
cmpq $-0x1, %r14
je 0x406a2
movq (%r15), %rax
leaq -0x2a0(%rbp), %rdi
movq %r15, %rsi
callq *(%rax)
movq %r13, %r14
movq -0x2a0(%rbp), %rsi
movq -0x298(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x2e130
movq %rbx, %r13
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
movq -0x30(%rbp), %rbx
je 0x40699
callq 0x2e360
leaq -0x70(%rbp), %rdi
jmp 0x40737
movq (%r15), %rax
leaq -0x2a0(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq *(%rax)
movl $0x6, %ecx
movq %r14, %rdi
leaq 0x35f71(%rip), %rsi     # 0x76634
xorl %edx, %edx
callq 0x2e710
movq %rax, %r14
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
je 0x406e5
callq 0x2e360
cmpq $-0x1, %r14
movq %r13, %r14
movq %rbx, %r13
movq -0x30(%rbp), %rbx
je 0x40743
movq (%r15), %rax
leaq -0x2a0(%rbp), %rdi
movq %r15, %rsi
callq *(%rax)
movq -0x2a0(%rbp), %rsi
movq -0x298(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0x2e130
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
je 0x40733
callq 0x2e360
leaq -0x50(%rbp), %rdi
leaq 0x35686(%rip), %rsi     # 0x75dc4
callq 0x2e7e0
addq $0x8, %r12
cmpq %rbx, %r12
jne 0x405ca
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x80(%rbp), %rdi
callq 0x2e440
leaq -0x2a0(%rbp), %rdi
callq 0x2e6e0
leaq -0x90(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x78(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
callq 0x32f92
leaq 0x35ea2(%rip), %rsi     # 0x7663b
leaq -0xa0(%rbp), %rdi
callq 0x2e7e0
leaq -0x2a0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movl $0x10, %edx
callq 0x2e1e0
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x407ce
callq 0x2e360
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
leaq -0x2a0(%rbp), %rdi
callq 0x2e440
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2e370
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2e040
movq %rax, %rdi
callq 0x2e2b0
leaq -0x2a0(%rbp), %rdi
callq 0x2e590
movq 0x4d769(%rip), %rax     # 0x8df88
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x298(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x2a0(%rbp,%rcx)
callq 0x2e320
leaq -0x1a8(%rbp), %rdi
callq 0x2e150
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x40860
callq 0x2e360
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x40872
callq 0x2e360
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x40886
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x408d1
callq 0x2e360
jmp 0x408d1
jmp 0x408ce
jmp 0x408e1
jmp 0x408e1
movq %rax, %rbx
jmp 0x408f6
jmp 0x408ad
jmp 0x408e1
jmp 0x408e1
movq %rax, %rbx
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
je 0x408e4
callq 0x2e360
jmp 0x408e4
jmp 0x408e1
jmp 0x408e1
movq %rax, %rbx
leaq -0x2a0(%rbp), %rdi
callq 0x2e5f0
jmp 0x408e4
jmp 0x408e1
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x408f6
callq 0x2e360
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x40908
callq 0x2e360
movq %rbx, %rdi
callq 0x2e730