// File: /workspace/github_cpp_makefile_star2_O1/kiven-li[P]xbytes/xbytes.cpp
// Function: xbytes::xbytes::emit_cxx_file()
void xbytes::emit_cxx_file()
{
	//open output file
	std::ofstream ofs;
	ofs.open("PARSER.cxx", std::ofstream::out);

	//open template file
	std::ifstream ifs;
	ifs.open("TEMPLATE.cxx", std::ifstream::in);

	//copy data
	string line;
	while(ifs.good())
	{
		line.clear();
		getline(ifs, line);

		if(line.size() == 0)
		{
			ofs << std::endl;
			continue;
		}
		
		if(line[0] == '%' && line[1] == '%')
		{
			string keyword;
			for(int i = 2; i < line.size(); ++i)
			{
				if(line[i] == '%') break;
				keyword.push_back(line[i]);
			}

			if(keyword == "DECLARE_SYMBOL_TABLE")
			{
				output_symbol_table(ofs);
			}
			else if(keyword == "DECLARE_RULE_TABLE")
			{
				output_rule_table(ofs);
			}
			else if(keyword == "DECLARE_ACTION_TABLE")
			{
				output_action_table(ofs);
			}
			else if(keyword == "DECLARE_REDUCE_CODE")
			{
				output_reduce_code(ofs);
			}
			else if(keyword == "DECLARE_SYNTAX_ERROR_CODE")
			{
				if(syntax_error_code.size() > 0)
					ofs << syntax_error_code << std::endl;
			}

			continue;
		}

		ofs << line << std::endl;	
	}

	ifs.close();
	ofs.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x458, %rsp            # imm = 0x458
movq %rdi, -0x30(%rbp)
leaq -0x478(%rbp), %rbx
movq %rbx, %rdi
callq 0x33a0
leaq 0x788b(%rip), %rsi      # 0xd921
movq %rbx, %rdi
movl $0x10, %edx
callq 0x3040
leaq -0x278(%rbp), %rdi
callq 0x32a0
leaq 0x7876(%rip), %rsi      # 0xd92c
leaq -0x278(%rbp), %r15
movq %r15, %rdi
movl $0x8, %edx
callq 0x3140
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq -0x278(%rbp), %rax
movq -0x18(%rax), %rcx
cmpl $0x0, -0x258(%rbp,%rcx)
je 0x617b
leaq -0x278(%rbp), %rdi
callq 0x3070
leaq -0x478(%rbp), %rdi
callq 0x32e0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x6127
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3260
leaq -0x278(%rbp), %rdi
callq 0x3080
movq 0xae96(%rip), %rax      # 0x10fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x470(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x478(%rbp,%rcx)
callq 0x31e0
leaq -0x380(%rbp), %rdi
callq 0x30c0
addq $0x458, %rsp            # imm = 0x458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $-0x18, %rax
leaq -0x50(%rbp), %r12
leaq -0x70(%rbp), %r13
movq $0x0, -0x48(%rbp)
movq -0x50(%rbp), %rcx
movb $0x0, (%rcx)
movq (%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x33f0
movq -0x48(%rbp), %rdx
testq %rdx, %rdx
je 0x6303
movq -0x50(%rbp), %rsi
cmpb $0x25, (%rsi)
jne 0x62e2
cmpb $0x25, 0x1(%rsi)
jne 0x62e2
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movb $0x0, -0x60(%rbp)
cmpq $0x3, -0x48(%rbp)
jb 0x6219
movl $0x2, %r14d
movq -0x50(%rbp), %rax
movb (%rax,%r14), %al
cmpb $0x25, %al
je 0x6219
movsbl %al, %esi
movq %r13, %rdi
callq 0x31f0
incq %r14
cmpq %r14, -0x48(%rbp)
ja 0x61f9
movq %r13, %rdi
leaq 0x7716(%rip), %rsi      # 0xd939
callq 0x30a0
testl %eax, %eax
je 0x6353
movq %r13, %rdi
leaq 0x7714(%rip), %rsi      # 0xd94e
callq 0x30a0
testl %eax, %eax
je 0x6361
movq %r13, %rdi
leaq 0x7710(%rip), %rsi      # 0xd961
callq 0x30a0
testl %eax, %eax
je 0x636f
movq %r13, %rdi
leaq 0x770e(%rip), %rsi      # 0xd976
callq 0x30a0
testl %eax, %eax
je 0x637d
movq %r13, %rdi
leaq 0x770b(%rip), %rsi      # 0xd98a
callq 0x30a0
testl %eax, %eax
jne 0x6389
movq -0x30(%rbp), %rax
movq 0x98(%rax), %rdx
testq %rdx, %rdx
je 0x6389
movq -0x30(%rbp), %rax
movq 0x90(%rax), %rsi
movq %rbx, %rdi
callq 0x32b0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
jmp 0x6389
movq %rbx, %rdi
callq 0x32b0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x631e
movq -0x478(%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movq %rbx, %r14
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq -0x278(%rbp), %rax
movq -0x18(%rax), %rcx
addq $-0x18, %rax
cmpl $0x0, -0x258(%rbp,%rcx)
je 0x6187
jmp 0x60f6
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x957a
jmp 0x6389
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x9678
jmp 0x6389
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x98ee
jmp 0x6389
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x9b76
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x6331
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3260
jmp 0x6331
movq %rax, %rbx
jmp 0x63ee
jmp 0x63ab
movq %rax, %rbx
jmp 0x63fa
jmp 0x63b4
jmp 0x63d2
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x63d5
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3260
jmp 0x63d5
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x63ee
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3260
leaq -0x278(%rbp), %rdi
callq 0x3080
leaq -0x478(%rbp), %rdi
callq 0x3300
movq %rbx, %rdi
callq 0x33d0