// File: /workspace/github_c_makefile_star2_O3/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 0x108ee(%rip), %rsi     # 0x13e0e
callq 0x11c0
testq %rax, %rax
je 0x38a9
movq %rax, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x2b74
movq %r14, %rdi
callq 0x10b0
incl %eax
movslq %eax, %rdi
callq 0x1190
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x3876
movq %rax, %rdi
movq %r14, %rsi
callq 0x1080
movl $0x0, 0x14c4e(%rip)     # 0x181c0
leaq 0x220(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
je 0x3849
movabsq $-0x100000000, %r12     # imm = 0xFFFFFFFF00000000
leaq 0x220(%rsp), %r14
leaq 0x14c77(%rip), %r15     # 0x18220
leaq 0xfdb7(%rip), %rbp      # 0x13367
leaq 0x10442(%rip), %r13     # 0x139f9
incl 0x14c03(%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 0x367a
cmpl $0xd, %eax
je 0x367a
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
je 0x367a
movslq 0x14bb2(%rip), %rax     # 0x181b8
leaq 0x14bd3(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x14ba8(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
movl $0x6, %edi
leaq 0xfd2b(%rip), %rsi      # 0x13352
xorl %eax, %eax
callq 0xa278
callq 0x38c0
movq %r14, %rdi
callq 0x10b0
shlq $0x20, %rax
addq %r12, %rax
sarq $0x20, %rax
movzbl 0x220(%rsp,%rax), %eax
cmpl $0xa, %eax
je 0x3830
cmpl $0xd, %eax
je 0x3830
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
jne 0x3633
jmp 0x3830
cmpb $0x23, 0x220(%rsp)
je 0x3830
movl $0x2000, %edx           # imm = 0x2000
movq %r15, %rdi
xorl %esi, %esi
callq 0x1110
movq %r15, %rdi
movl $0xfff, %esi            # imm = 0xFFF
movq %r14, %rdx
movl $0x1000, %ecx           # imm = 0x1000
xorl %r8d, %r8d
callq 0x1491
movq %r15, %rdi
callq 0x391a
testl %eax, %eax
je 0x3830
movq 0x16b62(%rip), %rax     # 0x1a228
movl 0x16b54(%rip), %ecx     # 0x1a220
cmpl $0x4, %ecx
je 0x3797
cmpl $0x7, %ecx
jne 0x3830
xorl %ecx, %ecx
movsbl (%rcx,%r13), %edx
cmpw %dx, (%rax,%rcx,2)
jne 0x37b5
incq %rcx
cmpq $0x7, %rcx
jne 0x36e0
callq 0x53ae
testl %eax, %eax
je 0x37f9
movq 0x16b1c(%rip), %rdi     # 0x1a228
movl 0x16b0e(%rip), %esi     # 0x1a220
movq %rdi, (%rsp)
callq 0x6c24
movl %eax, 0x16aff(%rip)     # 0x1a220
cmpl $0x1, %eax
jne 0x37f9
movq (%rsp), %rax
movzwl (%rax), %eax
movw %ax, (%rsp)
callq 0x53ae
testl %eax, %eax
je 0x37f9
movq 0x14a37(%rip), %rdi     # 0x18180
movq 0x16ad8(%rip), %rsi     # 0x1a228
movl 0x16aca(%rip), %edx     # 0x1a220
callq 0x2022
movl %eax, 0x16abf(%rip)     # 0x1a220
movq 0x16ac0(%rip), %rdi     # 0x1a228
movl %eax, %esi
callq 0x134f
movl %eax, 0x16aab(%rip)     # 0x1a220
cmpl $0x1, %eax
jne 0x37f9
movq 0x16aa7(%rip), %rax     # 0x1a228
movzwl (%rax), %edx
movzwl (%rsp), %esi
leaq 0x8(%rsp), %rdi
callq 0x2c7c
jmp 0x3830
xorl %ecx, %ecx
movsbl (%rcx,%rbp), %edx
cmpw %dx, (%rax,%rcx,2)
jne 0x3830
incq %rcx
cmpq $0x4, %rcx
jne 0x3799
jmp 0x3849
xorl %ecx, %ecx
leaq 0x10252(%rip), %rdx     # 0x13a10
movsbl (%rcx,%rdx), %edx
cmpw %dx, (%rax,%rcx,2)
jne 0x3830
incq %rcx
cmpq $0x7, %rcx
jne 0x37b7
callq 0x53ae
testl %eax, %eax
je 0x3812
cmpl $0x1, 0x16a3f(%rip)     # 0x1a220
jne 0x3812
movq 0x16a3e(%rip), %rax     # 0x1a228
movzwl (%rax), %esi
leaq 0x8(%rsp), %rdi
callq 0x2c9d
jmp 0x3830
movq 0x10(%rsp), %rdx
movl 0x149bc(%rip), %ecx     # 0x181c0
movl $0x6, %edi
leaq 0x101da(%rip), %rsi     # 0x139ea
jmp 0x3829
movq 0x10(%rsp), %rdx
movl 0x149a3(%rip), %ecx     # 0x181c0
movl $0x6, %edi
leaq 0x101d8(%rip), %rsi     # 0x13a01
xorl %eax, %eax
callq 0xa278
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
jne 0x35b7
movq %rbx, %rdi
callq 0x10a0
cmpl $0x0, 0x14968(%rip)     # 0x181c0
je 0x3899
callq 0x2bdd
movq %rax, %rbx
leaq 0x8(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movq %rax, %rdi
callq 0x1180
jmp 0x38ab
leaq 0xf9bf(%rip), %rsi      # 0x1323c
leaq 0xfabd(%rip), %rdx      # 0x13341
xorl %ebx, %ebx
movl $0x7, %edi
movl $0x8ce, %ecx            # imm = 0x8CE
xorl %eax, %eax
callq 0xa278
jmp 0x38ab
movq 0x148e0(%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