// File: /workspace/github_cpp_makefile_star2_O3/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 $0x458, %rsp            # imm = 0x458
movq %rdi, -0x30(%rbp)
leaq -0x478(%rbp), %r14
movq %r14, %rdi
callq 0x33a0
leaq 0x7ba7(%rip), %rsi      # 0xd883
movq %r14, %rdi
movl $0x10, %edx
callq 0x3040
leaq -0x278(%rbp), %rdi
callq 0x32a0
leaq 0x7b92(%rip), %rsi      # 0xd88e
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 0x5dc1
leaq -0x278(%rbp), %rdi
callq 0x3070
leaq -0x478(%rbp), %rdi
callq 0x32e0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x5d6d
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3260
leaq -0x278(%rbp), %rdi
callq 0x3080
movq 0xb250(%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 0x5f3d
movq -0x50(%rbp), %rsi
cmpb $0x25, (%rsi)
jne 0x5f1c
cmpb $0x25, 0x1(%rsi)
jne 0x5f1c
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movb $0x0, -0x60(%rbp)
cmpq $0x3, %rdx
jb 0x5e5c
movl $0x2, %ebx
movq -0x50(%rbp), %rax
movb (%rax,%rbx), %al
cmpb $0x25, %al
je 0x5e5c
movsbl %al, %esi
movq %r13, %rdi
callq 0x31f0
incq %rbx
cmpq %rbx, -0x48(%rbp)
ja 0x5e3d
movq %r13, %rdi
leaq 0x7a35(%rip), %rsi      # 0xd89b
callq 0x30a0
testl %eax, %eax
je 0x5f8d
movq %r13, %rdi
leaq 0x7a2d(%rip), %rsi      # 0xd8aa
callq 0x30a0
testl %eax, %eax
je 0x5f9b
movq %r13, %rdi
leaq 0x7a47(%rip), %rsi      # 0xd8db
callq 0x30a0
testl %eax, %eax
jne 0x5ff8
movq -0x30(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x5ff8
movl $0x1d, %edx
movq %r14, %rdi
leaq 0x7a2f(%rip), %rsi      # 0xd8ee
callq 0x32b0
movl $0x8, %edx
movq %r14, %rdi
leaq 0x7a39(%rip), %rsi      # 0xd90c
callq 0x32b0
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rsi
movq 0x78(%rax), %rdx
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
movl $0xb, %edx
movq %rax, %rdi
leaq 0x7a17(%rip), %rsi      # 0xd915
callq 0x32b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x5fe5
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x5f58
movq -0x478(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movq %r14, %rbx
movsbl %al, %esi
movq %rbx, %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 0x5dcd
jmp 0x5d3c
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x9324
jmp 0x5ff8
movq -0x30(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x5ff8
movl $0x1b, %edx
movq %r14, %rdi
leaq 0x790a(%rip), %rsi      # 0xd8bf
callq 0x32b0
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rsi
movq 0x58(%rax), %rdx
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x5f6b
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3260
jmp 0x5f6b
movq %rax, %rbx
jmp 0x6064
jmp 0x6021
movq %rax, %rbx
jmp 0x6070
jmp 0x6048
jmp 0x602a
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x604b
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3260
jmp 0x604b
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x6064
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