// File: /workspace/github_cpp_makefile_star2_O3/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 0x377a5(%rip), %r14     # 0x778db
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x32e40
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x32e40
movq (%rbx), %r12
movq 0x8(%rbx), %rbx
cmpq %rbx, %r12
je 0x40304
leaq 0x364b5(%rip), %r13     # 0x76628
leaq 0x4c536(%rip), %r14     # 0x8c6b0
movq %rbx, -0x30(%rbp)
movq (%r12), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x6e968
testb %al, %al
je 0x402f7
movq %r15, %rdi
movq %r14, %rsi
leaq 0x4c88e(%rip), %rdx     # 0x8ca30
xorl %ecx, %ecx
callq 0x2e430
cmpl $0x1, 0x48(%rax)
jne 0x402f7
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 0x36466(%rip), %rsi     # 0x76643
xorl %edx, %edx
callq 0x2e710
movq %rax, %r14
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
je 0x401ff
callq 0x2e360
cmpq $-0x1, %r14
je 0x40256
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 0x4024d
callq 0x2e360
leaq -0x70(%rbp), %rdi
jmp 0x402eb
movq (%r15), %rax
leaq -0x2a0(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq *(%rax)
movl $0x6, %ecx
movq %r14, %rdi
leaq 0x363bd(%rip), %rsi     # 0x76634
xorl %edx, %edx
callq 0x2e710
movq %rax, %r14
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
je 0x40299
callq 0x2e360
cmpq $-0x1, %r14
movq %r13, %r14
movq %rbx, %r13
movq -0x30(%rbp), %rbx
je 0x402f7
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 0x402e7
callq 0x2e360
leaq -0x50(%rbp), %rdi
leaq 0x35ad2(%rip), %rsi     # 0x75dc4
callq 0x2e7e0
addq $0x8, %r12
cmpq %rbx, %r12
jne 0x4017e
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 0x32cbc
leaq 0x362ee(%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 0x40382
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 0x4dbb5(%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 0x40414
callq 0x2e360
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x40426
callq 0x2e360
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4043a
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x40485
callq 0x2e360
jmp 0x40485
jmp 0x40482
jmp 0x40495
jmp 0x40495
movq %rax, %rbx
jmp 0x404aa
jmp 0x40461
jmp 0x40495
jmp 0x40495
movq %rax, %rbx
movq -0x2a0(%rbp), %rdi
leaq -0x290(%rbp), %rax
cmpq %rax, %rdi
je 0x40498
callq 0x2e360
jmp 0x40498
jmp 0x40495
jmp 0x40495
movq %rax, %rbx
leaq -0x2a0(%rbp), %rdi
callq 0x2e5f0
jmp 0x40498
jmp 0x40495
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x404aa
callq 0x2e360
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x404bc
callq 0x2e360
movq %rbx, %rdi
callq 0x2e730