// File: /workspace/github_cpp_makefile_star2_O1/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 0x7bc5(%rip), %rsi      # 0xd883
movq %r14, %rdi
movl $0x10, %edx
callq 0x3040
leaq -0x278(%rbp), %rdi
callq 0x32a0
leaq 0x7bb0(%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 0x5da3
leaq -0x278(%rbp), %rdi
callq 0x3070
leaq -0x478(%rbp), %rdi
callq 0x32e0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x5d4f
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3260
leaq -0x278(%rbp), %rdi
callq 0x3080
movq 0xb26e(%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 0x5f20
movq -0x50(%rbp), %rsi
cmpb $0x25, (%rsi)
jne 0x5eff
cmpb $0x25, 0x1(%rsi)
jne 0x5eff
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movb $0x0, -0x60(%rbp)
cmpq $0x3, -0x48(%rbp)
jb 0x5e3f
movl $0x2, %ebx
movq -0x50(%rbp), %rax
movb (%rax,%rbx), %al
cmpb $0x25, %al
je 0x5e3f
movsbl %al, %esi
movq %r13, %rdi
callq 0x31f0
incq %rbx
cmpq %rbx, -0x48(%rbp)
ja 0x5e20
movq %r13, %rdi
leaq 0x7a52(%rip), %rsi      # 0xd89b
callq 0x30a0
testl %eax, %eax
je 0x5f70
movq %r13, %rdi
leaq 0x7a4a(%rip), %rsi      # 0xd8aa
callq 0x30a0
testl %eax, %eax
je 0x5f7e
movq %r13, %rdi
leaq 0x7a64(%rip), %rsi      # 0xd8db
callq 0x30a0
testl %eax, %eax
jne 0x5fdb
movq -0x30(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x5fdb
movl $0x1d, %edx
movq %r14, %rdi
leaq 0x7a4c(%rip), %rsi      # 0xd8ee
callq 0x32b0
movl $0x8, %edx
movq %r14, %rdi
leaq 0x7a56(%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 0x7a34(%rip), %rsi      # 0xd915
callq 0x32b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x5fc8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x5f3b
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 0x5daf
jmp 0x5d1e
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x936a
jmp 0x5fdb
movq -0x30(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x5fdb
movl $0x1b, %edx
movq %r14, %rdi
leaq 0x7927(%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 0x5f4e
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3260
jmp 0x5f4e
movq %rax, %rbx
jmp 0x6047
jmp 0x6004
movq %rax, %rbx
jmp 0x6053
jmp 0x602b
jmp 0x600d
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x602e
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3260
jmp 0x602e
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x6047
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
nop