// File: /workspace/github_c_makefile_star2_O1/MikeGray-APH[P]LibLouisAPH/source/compile.c
// Function: conversion_compile_from_file
struct conversion* conversion_compile_from_file(const char *file_name)
{
	FILE *file;
	char cchars[INPUT_LINE_MAX];
	struct conversion conversion_auto, *conversion;
	int file_name_len, cchars_len;

	file = fopen(file_name, "r");
	if(!file)
		return NULL;

	conversion = &conversion_auto;
	conversion_init(conversion);

	file_name_len = strlen(file_name);
	conversion->file_name = MALLOC(file_name_len + 1);
	LOG_ALLOCATE_FAIL_RETURN_NULL(conversion->file_name)
	strcpy(conversion->file_name, file_name);

	table_file_lines[0] = 0;

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

		cchars_len = strlen(cchars);
		if(cchars[cchars_len - 1] != '\n' && cchars[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();

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

		if(cchars[0] == '#')
			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;

		     if(token_is_equal("convert", 7))
			compile_convert(conversion);
		else if(token_is_equal("unknown", 7))
			compile_unknown(conversion);
	}

	fclose(file);

	/*   this could happen if file_name was a directory   */
	if(!table_file_lines[0])
	{
		FREE(table->file_name);
		return NULL;
	}

	conversion = conversion_allocate();
	*conversion = conversion_auto;

	return conversion;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1228, %rsp           # imm = 0x1228
movq %rdi, %r14
leaq 0x107b1(%rip), %rsi     # 0x13d3e
callq 0x11b0
testq %rax, %rax
je 0x3919
movq %rax, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x2c44
movq %r14, %rdi
callq 0x10b0
incl %eax
movslq %eax, %rdi
callq 0x1180
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x38e6
movq %rax, %rdi
movq %r14, %rsi
callq 0x1080
movl $0x0, 0x14be1(%rip)     # 0x181c0
leaq 0x220(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
je 0x38b9
movabsq $-0x100000000, %r12     # imm = 0xFFFFFFFF00000000
leaq 0x220(%rsp), %r14
leaq 0x14c0a(%rip), %r13     # 0x18220
leaq 0xfcaa(%rip), %rbp      # 0x132c7
leaq 0x10339(%rip), %r15     # 0x1395d
incl 0x14b96(%rip)           # 0x181c0
movq %r14, %rdi
callq 0x10b0
shlq $0x20, %rax
addq %r12, %rax
sarq $0x20, %rax
movzbl 0x220(%rsp,%rax), %eax
cmpl $0xa, %eax
je 0x36e7
cmpl $0xd, %eax
je 0x36e7
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
je 0x36e7
movslq 0x14b45(%rip), %rax     # 0x181b8
leaq 0x14b66(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x14b3b(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
movl $0x6, %edi
leaq 0xfc1e(%rip), %rsi      # 0x132b2
xorl %eax, %eax
callq 0xa36c
callq 0x3930
movq %r14, %rdi
callq 0x10b0
shlq $0x20, %rax
addq %r12, %rax
sarq $0x20, %rax
movzbl 0x220(%rsp,%rax), %eax
cmpl $0xa, %eax
je 0x387e
cmpl $0xd, %eax
je 0x387e
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
jne 0x36a0
jmp 0x387e
cmpb $0x23, 0x220(%rsp)
je 0x387e
movl $0x2000, %edx           # imm = 0x2000
movq %r13, %rdi
xorl %esi, %esi
callq 0x1110
movq %r13, %rdi
movl $0xfff, %esi            # imm = 0xFFF
movq %r14, %rdx
movl $0x1000, %ecx           # imm = 0x1000
xorl %r8d, %r8d
callq 0x147f
movq %r13, %rdi
callq 0x398a
testl %eax, %eax
je 0x387e
movq 0x16af5(%rip), %rax     # 0x1a228
movl 0x16ae7(%rip), %ecx     # 0x1a220
cmpl $0x4, %ecx
jne 0x3758
xorl %edx, %edx
movsbl (%rdx,%rbp), %esi
cmpw %si, (%rax,%rdx,2)
jne 0x3758
incq %rdx
cmpq $0x4, %rdx
jne 0x3740
jmp 0x38b9
cmpl $0x7, %ecx
jne 0x387e
xorl %edx, %edx
movsbl (%rdx,%r15), %esi
cmpw %si, (%rax,%rdx,2)
jne 0x3810
incq %rdx
cmpq $0x7, %rdx
jne 0x3763
callq 0x5525
testl %eax, %eax
je 0x3859
movq 0x16a99(%rip), %r13     # 0x1a228
movl 0x16a8b(%rip), %esi     # 0x1a220
movq %r13, %rdi
callq 0x6e16
movl %eax, 0x16a7d(%rip)     # 0x1a220
cmpl $0x1, %eax
jne 0x3859
movzwl (%r13), %r13d
callq 0x5525
testl %eax, %eax
je 0x3859
movq 0x149bb(%rip), %rdi     # 0x18180
movq 0x16a5c(%rip), %rsi     # 0x1a228
movl 0x16a4e(%rip), %edx     # 0x1a220
callq 0x1fef
movl %eax, 0x16a43(%rip)     # 0x1a220
movq 0x16a44(%rip), %rdi     # 0x1a228
movl %eax, %esi
callq 0x133d
movl %eax, 0x16a2f(%rip)     # 0x1a220
cmpl $0x1, %eax
jne 0x3859
movq 0x16a2b(%rip), %rax     # 0x1a228
movzwl (%rax), %edx
movzwl %r13w, %esi
leaq 0x8(%rsp), %rdi
callq 0x2d1b
jmp 0x3877
cmpl $0x7, %ecx
jne 0x387e
xorl %ecx, %ecx
leaq 0x10156(%rip), %rdx     # 0x13974
movsbl (%rcx,%rdx), %edx
cmpw %dx, (%rax,%rcx,2)
jne 0x387e
incq %rcx
cmpq $0x7, %rcx
jne 0x3817
callq 0x5525
testl %eax, %eax
je 0x3899
cmpl $0x1, 0x169df(%rip)     # 0x1a220
jne 0x3899
movq 0x169de(%rip), %rax     # 0x1a228
movzwl (%rax), %esi
leaq 0x8(%rsp), %rdi
callq 0x2d3c
jmp 0x387e
movq 0x10(%rsp), %rdx
movl 0x1495c(%rip), %ecx     # 0x181c0
movl $0x6, %edi
leaq 0x100de(%rip), %rsi     # 0x1394e
xorl %eax, %eax
callq 0xa36c
leaq 0x149a2(%rip), %r13     # 0x18220
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
jne 0x3624
jmp 0x38b9
movq 0x10(%rsp), %rdx
movl 0x1491c(%rip), %ecx     # 0x181c0
movl $0x6, %edi
leaq 0x100b5(%rip), %rsi     # 0x13965
xorl %eax, %eax
callq 0xa36c
jmp 0x387e
movq %rbx, %rdi
callq 0x10a0
cmpl $0x0, 0x148f8(%rip)     # 0x181c0
je 0x3909
callq 0x2c8e
movq %rax, %rbx
leaq 0x8(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movq %rax, %rdi
callq 0x1170
jmp 0x391b
leaq 0xf907(%rip), %rsi      # 0x131f4
leaq 0xf9ad(%rip), %rdx      # 0x132a1
xorl %ebx, %ebx
movl $0x7, %edi
movl $0x8ce, %ecx            # imm = 0x8CE
xorl %eax, %eax
callq 0xa36c
jmp 0x391b
movq 0x14870(%rip), %rax     # 0x18180
movq 0x10(%rax), %rdi
callq 0x1040
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x1228, %rsp           # imm = 0x1228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq