// File: /workspace/github_cpp_makefile_star2_O2/kiven-li[P]xbytes/xbytes.cpp
// Function: xbytes::xbytes::emit_hxx_file()
void xbytes::emit_hxx_file()
{
	//open output file
	std::ofstream ofs;
	ofs.open("PARSER.hxx", std::ofstream::out);

	//open template file
	std::ifstream ifs;
	ifs.open("TEMPLATE.hxx", 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")
			{
				output_declare_symbol(ofs);
			}
			else if(keyword == "DECLARE_INCLUDE_CODE")
			{
				if(include_code.size() > 0)
				{
					ofs << "//include file from .x file";
					ofs << include_code << std::endl;
				}					
			}
			else if(keyword == "DECLARE_TOKEN_CODE")
			{
				if(token_code.size() > 0)
				{
					ofs << "//declare token from .x file\n";
					ofs << "typedef " << token_code  << "TOKEN_TYPE;" << std::endl;					
				}
			}
		}
		else
		{
			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 $0x468, %rsp            # imm = 0x468
movq %rdi, -0x30(%rbp)
leaq -0x488(%rbp), %r14
movq %r14, %rdi
callq 0x2360
leaq 0x6733(%rip), %rsi      # 0xa883
pushq $0x10
popq %rdx
movq %r14, %rdi
callq 0x2030
leaq -0x288(%rbp), %rdi
callq 0x2260
leaq 0x6720(%rip), %rsi      # 0xa88e
leaq -0x288(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2150
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq -0x30(%rbp), %rax
leaq 0x70(%rax), %rcx
movq %rcx, -0x58(%rbp)
addq $0x50, %rax
movq %rax, -0x60(%rbp)
leaq -0x288(%rbp), %r13
leaq -0x50(%rbp), %r15
leaq -0x80(%rbp), %r12
movq -0x288(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x268(%rbp,%rax)
jne 0x4316
andq $0x0, -0x48(%rbp)
movq -0x50(%rbp), %rax
movb $0x0, (%rax)
movq %r13, %rdi
movq %r15, %rsi
callq 0x2060
movq -0x48(%rbp), %rcx
movq %r14, %rax
testq %rcx, %rcx
je 0x423e
movq -0x50(%rbp), %rax
cmpb $0x25, (%rax)
jne 0x4233
cmpb $0x25, 0x1(%rax)
jne 0x4233
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
andq $0x0, -0x78(%rbp)
movb $0x0, -0x70(%rbp)
pushq $0x2
popq %rbx
cmpq %rbx, %rcx
jbe 0x424b
movq -0x50(%rbp), %rax
movb (%rax,%rbx), %al
cmpb $0x25, %al
je 0x424b
movsbl %al, %esi
movq %r12, %rdi
callq 0x21e0
incq %rbx
movq -0x48(%rbp), %rcx
jmp 0x420f
movq %r14, %rdi
movq %r15, %rsi
callq 0x2200
movq %rax, %rdi
callq 0x2110
jmp 0x41b0
movq %r12, %rdi
leaq 0x6646(%rip), %rsi      # 0xa89b
callq 0x7074
testb %al, %al
je 0x426f
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x65d0
jmp 0x4309
movq %r12, %rdi
leaq 0x6631(%rip), %rsi      # 0xa8aa
callq 0x7074
testb %al, %al
je 0x42aa
movq -0x30(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x4309
movq %r14, %rdi
leaq 0x6628(%rip), %rsi      # 0xa8bf
callq 0x2220
movq %r14, %rdi
movq -0x60(%rbp), %rsi
callq 0x2200
jmp 0x4301
movq %r12, %rdi
leaq 0x6627(%rip), %rsi      # 0xa8db
callq 0x7074
testb %al, %al
je 0x4309
movq -0x30(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x4309
movq %r14, %rdi
leaq 0x661c(%rip), %rsi      # 0xa8ee
callq 0x2220
movq %r14, %rdi
leaq 0x662b(%rip), %rsi      # 0xa90c
callq 0x2220
movq %rax, %rdi
movq -0x58(%rbp), %rsi
callq 0x2200
movq %rax, %rdi
leaq 0x6619(%rip), %rsi      # 0xa915
callq 0x2220
movq %rax, %rdi
callq 0x2110
movq %r12, %rdi
callq 0x2100
jmp 0x41b0
leaq -0x288(%rbp), %rdi
callq 0x2070
leaq -0x488(%rbp), %rdi
callq 0x22c0
leaq -0x50(%rbp), %rdi
callq 0x2100
leaq -0x288(%rbp), %rdi
callq 0x2080
leaq -0x488(%rbp), %rdi
callq 0x22e0
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x438b
jmp 0x4368
movq %rax, %rbx
jmp 0x4397
jmp 0x4371
jmp 0x4376
movq %rax, %rbx
jmp 0x4382
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x2100
leaq -0x50(%rbp), %rdi
callq 0x2100
leaq -0x288(%rbp), %rdi
callq 0x2080
leaq -0x488(%rbp), %rdi
callq 0x22e0
movq %rbx, %rdi
callq 0x2380
nop