// File: /workspace/github_c_makefile_star2_O0/MikeGray-APH[P]LibLouisAPH/source/compile.c
// Function: file_read
static void file_read(FILE *file, const char *file_name)
{
	FILE *include_file;
	char cchars[INPUT_LINE_MAX], path_name[INPUT_LINE_MAX];
	int pause, len, crs, i;

	if(include_depth >= INCLUDE_DEPTH_MAX - 1)
	{
		log_message(LOG_ERROR, "%s:%d  too many levels of include files", table_file_names[include_depth], table_file_lines[include_depth]);
		log_included_file_errors();
		return;
	}

	include_depth++;
	table_file_names[include_depth] = file_name;
	table_file_lines[include_depth] = 0;

	pause = 0;
	while(fgets(cchars, INPUT_LINE_MAX, file))
	{
		table_file_lines[include_depth]++;

		len = strlen(cchars);
		if(cchars[len - 1] != '\n' && cchars[len - 1] != '\r')
		{
			/*   last line not empty   */
			if(fgets(cchars, INPUT_LINE_MAX, file))
			{
				/*   input too long   */
				log_message(LOG_ERROR, "%s:%d  line too long", table_file_names[include_depth], table_file_lines[include_depth]);
				log_included_file_errors();

				len = strlen(cchars);
				while(cchars[len - 1] != '\n' && cchars[len - 1] != '\r')
				if(fgets(cchars, INPUT_LINE_MAX, file))
					len = strlen(cchars);
				else
					break;
				continue;
			}
		}

		if(pause)
		{
			if(!strncmp(cchars, ".cont", 5))
				pause = 0;
			continue;
		}
		else if(!strncmp(cchars, ".stop", 5))
		{
			pause = 1;
			continue;
		}

		if(cchars[0] == '#')
			continue;

		/*   include file   */
		else if(!strncmp(cchars, "include", 7))
		{
			/*   parse file name   */
			if(cchars[7] != ' ' && cchars[7] != '\t')
			{
				log_message(LOG_ERROR, "%s:%d  include missing file name", table_file_names[include_depth], table_file_lines[include_depth]);
				log_included_file_errors();
				continue;
			}
			for(crs = 8; cchars[crs] && crs < INPUT_LINE_MAX; crs++)
			if(!is_space(cchars[crs]))
				break;
			if(crs >= INPUT_LINE_MAX)
			{
				log_message(LOG_ERROR, "%s:%d  include missing file name", table_file_names[include_depth], table_file_lines[include_depth]);
				log_included_file_errors();
				continue;
			}

			/*   trim whitespace at end   */
			for(i = strlen(cchars) - 1; i > 8; i--)
			if(is_space(cchars[i]))
				cchars[i] = 0;
			else
				break;
			if(i <= 8)
			{
				log_message(LOG_ERROR, "%s:%d  invalid include", table_file_names[include_depth], table_file_lines[include_depth]);
				log_included_file_errors();
				continue;
			}

			/*   compile include file   */
			include_file = lookup_open_file(path_name, INPUT_LINE_MAX, &cchars[crs], table->file_name);
			if(!include_file)
			{
				log_message(LOG_ERROR, "%s:%d  unable to open include file %s", table_file_names[include_depth], table_file_lines[include_depth], &cchars[crs]);
				log_included_file_errors();
				continue;
			}
			file_read(include_file, path_name);
			fclose(include_file);
			continue;
		}

		memset(token_line, 0, INPUT_LINE_MAX * sizeof(unichar));
		utf8_convert_to_utf16(token_line, INPUT_LINE_MAX - 1, cchars, INPUT_LINE_MAX, NULL);

		if(!token_init(token_line))
			continue;

		if(token_is_equal(".end", 4))
			break;

		/*  do this here so macros can't define other macros   */
		if(token_is_equal("macro", 5))
		{
			if(!compile_macro(file, cchars, file_name))
				log_included_file_errors();
			continue;
		}

		token_compile();
	}

	include_depth--;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2040, %rsp           # imm = 0x2040
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x7, 0x1f44e(%rip)     # 0x24198
jl 0x4d8c
movslq 0x1f445(%rip), %rcx     # 0x24198
leaq 0x1f466(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1f433(%rip), %rcx     # 0x24198
leaq 0x1f434(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movl $0x6, %edi
leaq 0x195d1(%rip), %rsi     # 0x1e34c
movb $0x0, %al
callq 0xf610
callq 0x5710
jmp 0x52ff
movl 0x1f406(%rip), %eax     # 0x24198
addl $0x1, %eax
movl %eax, 0x1f3fd(%rip)     # 0x24198
movq -0x10(%rbp), %rdx
movslq 0x1f3f2(%rip), %rcx     # 0x24198
leaq 0x1f413(%rip), %rax     # 0x241c0
movq %rdx, (%rax,%rcx,8)
movslq 0x1f3e0(%rip), %rcx     # 0x24198
leaq 0x1f3e1(%rip), %rax     # 0x241a0
movl $0x0, (%rax,%rcx,4)
movl $0x0, -0x2024(%rbp)
leaq -0x1020(%rbp), %rdi
movq -0x8(%rbp), %rdx
movl $0x1000, %esi           # imm = 0x1000
callq 0x1120
cmpq $0x0, %rax
je 0x52f0
movslq 0x1f3a2(%rip), %rcx     # 0x24198
leaq 0x1f3a3(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x1f396(%rip), %rax     # 0x241a0
movl %edx, (%rax,%rcx,4)
leaq -0x1020(%rbp), %rdi
callq 0x10a0
movl %eax, -0x2028(%rbp)
movl -0x2028(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x1020(%rbp,%rax), %eax
cmpl $0xa, %eax
je 0x4f48
movl -0x2028(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x1020(%rbp,%rax), %eax
cmpl $0xd, %eax
je 0x4f48
leaq -0x1020(%rbp), %rdi
movq -0x8(%rbp), %rdx
movl $0x1000, %esi           # imm = 0x1000
callq 0x1120
cmpq $0x0, %rax
je 0x4f46
movslq 0x1f31b(%rip), %rcx     # 0x24198
leaq 0x1f33c(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1f309(%rip), %rcx     # 0x24198
leaq 0x1f30a(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movl $0x6, %edi
leaq 0x1948d(%rip), %rsi     # 0x1e332
movb $0x0, %al
callq 0xf610
callq 0x5710
leaq -0x1020(%rbp), %rdi
callq 0x10a0
movl %eax, -0x2028(%rbp)
movl -0x2028(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x1020(%rbp,%rax), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x2031(%rbp)
je 0x4f02
movl -0x2028(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x1020(%rbp,%rax), %eax
cmpl $0xd, %eax
setne %al
movb %al, -0x2031(%rbp)
movb -0x2031(%rbp), %al
testb $0x1, %al
jne 0x4f0e
jmp 0x4f41
leaq -0x1020(%rbp), %rdi
movq -0x8(%rbp), %rdx
movl $0x1000, %esi           # imm = 0x1000
callq 0x1120
cmpq $0x0, %rax
je 0x4f3d
leaq -0x1020(%rbp), %rdi
callq 0x10a0
movl %eax, -0x2028(%rbp)
jmp 0x4f3f
jmp 0x4f41
jmp 0x4ec3
jmp 0x4dd0
jmp 0x4f48
cmpl $0x0, -0x2024(%rbp)
je 0x4f7d
leaq -0x1020(%rbp), %rdi
leaq 0x19415(%rip), %rsi     # 0x1e374
movl $0x5, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x4f78
movl $0x0, -0x2024(%rbp)
jmp 0x4dd0
leaq -0x1020(%rbp), %rdi
leaq 0x193ef(%rip), %rsi     # 0x1e37a
movl $0x5, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x4fa9
movl $0x1, -0x2024(%rbp)
jmp 0x4dd0
jmp 0x4fab
movsbl -0x1020(%rbp), %eax
cmpl $0x23, %eax
jne 0x4fbc
jmp 0x4dd0
leaq -0x1020(%rbp), %rdi
leaq 0x193e6(%rip), %rsi     # 0x1e3b0
movl $0x7, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x5248
movsbl -0x1019(%rbp), %eax
cmpl $0x20, %eax
je 0x5035
movsbl -0x1019(%rbp), %eax
cmpl $0x9, %eax
je 0x5035
movslq 0x1f19c(%rip), %rcx     # 0x24198
leaq 0x1f1bd(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1f18a(%rip), %rcx     # 0x24198
leaq 0x1f18b(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movl $0x6, %edi
leaq 0x1935c(%rip), %rsi     # 0x1e380
movb $0x0, %al
callq 0xf610
callq 0x5710
jmp 0x4dd0
movl $0x8, -0x202c(%rbp)
movslq -0x202c(%rbp), %rax
movsbl -0x1020(%rbp,%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2032(%rbp)
je 0x506e
cmpl $0x1000, -0x202c(%rbp)  # imm = 0x1000
setl %al
movb %al, -0x2032(%rbp)
movb -0x2032(%rbp), %al
testb $0x1, %al
jne 0x507a
jmp 0x50ab
movslq -0x202c(%rbp), %rax
movsbl -0x1020(%rbp,%rax), %eax
movzwl %ax, %edi
callq 0x5950
cmpl $0x0, %eax
jne 0x5098
jmp 0x50ab
jmp 0x509a
movl -0x202c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x202c(%rbp)
jmp 0x503f
cmpl $0x1000, -0x202c(%rbp)  # imm = 0x1000
jl 0x50f7
movslq 0x1f0da(%rip), %rcx     # 0x24198
leaq 0x1f0fb(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1f0c8(%rip), %rcx     # 0x24198
leaq 0x1f0c9(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movl $0x6, %edi
leaq 0x1929a(%rip), %rsi     # 0x1e380
movb $0x0, %al
callq 0xf610
callq 0x5710
jmp 0x4dd0
leaq -0x1020(%rbp), %rdi
callq 0x10a0
subq $0x1, %rax
movl %eax, -0x2030(%rbp)
cmpl $0x8, -0x2030(%rbp)
jle 0x5158
movslq -0x2030(%rbp), %rax
movsbl -0x1020(%rbp,%rax), %eax
movzwl %ax, %edi
callq 0x5950
cmpl $0x0, %eax
je 0x5143
movslq -0x2030(%rbp), %rax
movb $0x0, -0x1020(%rbp,%rax)
jmp 0x5145
jmp 0x5158
jmp 0x5147
movl -0x2030(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2030(%rbp)
jmp 0x510d
cmpl $0x8, -0x2030(%rbp)
jg 0x51a1
movslq 0x1f030(%rip), %rcx     # 0x24198
leaq 0x1f051(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1f01e(%rip), %rcx     # 0x24198
leaq 0x1f01f(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movl $0x6, %edi
leaq 0x19211(%rip), %rsi     # 0x1e3a1
movb $0x0, %al
callq 0xf610
callq 0x5710
jmp 0x4dd0
leaq -0x2020(%rbp), %rdi
movslq -0x202c(%rbp), %rax
leaq -0x1020(%rbp), %rdx
addq %rax, %rdx
movq 0x1efa0(%rip), %rax     # 0x24160
movq 0x10(%rax), %rcx
movl $0x1000, %esi           # imm = 0x1000
callq 0xf2e0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x522a
movslq 0x1efb8(%rip), %rcx     # 0x24198
leaq 0x1efd9(%rip), %rax     # 0x241c0
movq (%rax,%rcx,8), %rdx
movslq 0x1efa6(%rip), %rcx     # 0x24198
leaq 0x1efa7(%rip), %rax     # 0x241a0
movl (%rax,%rcx,4), %ecx
movslq -0x202c(%rbp), %rax
leaq -0x1020(%rbp), %r8
addq %rax, %r8
movl $0x6, %edi
leaq 0x1919f(%rip), %rsi     # 0x1e3b8
movb $0x0, %al
callq 0xf610
callq 0x5710
jmp 0x4dd0
movq -0x18(%rbp), %rdi
leaq -0x2020(%rbp), %rsi
callq 0x4d30
movq -0x18(%rbp), %rdi
callq 0x1090
jmp 0x4dd0
jmp 0x524a
leaq 0x1efaf(%rip), %rdi     # 0x24200
xorl %esi, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x1100
leaq -0x1020(%rbp), %rdx
leaq 0x1ef95(%rip), %rdi     # 0x24200
movl $0xfff, %esi            # imm = 0xFFF
movl $0x1000, %ecx           # imm = 0x1000
xorl %eax, %eax
movl %eax, %r8d
callq 0x16c0
leaq 0x1ef7a(%rip), %rdi     # 0x24200
callq 0x5770
cmpl $0x0, %eax
jne 0x5295
jmp 0x4dd0
leaq 0x190ab(%rip), %rdi     # 0x1e347
movl $0x4, %esi
callq 0x57f0
cmpl $0x0, %eax
je 0x52ad
jmp 0x52f0
leaq 0x1912a(%rip), %rdi     # 0x1e3de
movl $0x5, %esi
callq 0x57f0
cmpl $0x0, %eax
je 0x52e6
movq -0x8(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x59b0
cmpl $0x0, %eax
jne 0x52e1
callq 0x5710
jmp 0x4dd0
callq 0x5f40
jmp 0x4dd0
movl 0x1eea2(%rip), %eax     # 0x24198
addl $-0x1, %eax
movl %eax, 0x1ee99(%rip)     # 0x24198
addq $0x2040, %rsp           # imm = 0x2040
popq %rbp
retq
nopl (%rax,%rax)