// File: /workspace/github_c_makefile_star2_O2/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 0xea77(%rip), %rsi      # 0x11d7e
callq 0x11d0
testq %rax, %rax
je 0x35fb
movq %rax, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x2aa0
movq %r14, %rdi
callq 0x10b0
incl %eax
movslq %eax, %rdi
callq 0x1190
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x35ca
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
movq %rax, %rdi
movq %r14, %rsi
callq 0x1080
andl $0x0, 0x13e70(%rip)     # 0x171d0
leaq 0x220(%rsp), %r14
leaq 0x13ec1(%rip), %r15     # 0x17230
pushq $0x7
popq %r13
pushq $0x6
popq %r12
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
je 0x359d
incl 0x13e3a(%rip)           # 0x171d0
movq %r14, %rdi
callq 0x10b0
shlq $0x20, %rax
addq %rbp, %rax
sarq $0x20, %rax
movzbl 0x220(%rsp,%rax), %eax
cmpl $0xa, %eax
je 0x3451
cmpl $0xd, %eax
je 0x3451
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
je 0x3451
movslq 0x13de9(%rip), %rax     # 0x171c8
leaq 0x13e0a(%rip), %rcx     # 0x171f0
movq (%rcx,%rax,8), %rdx
leaq 0x13ddf(%rip), %rcx     # 0x171d0
movl (%rcx,%rax,4), %ecx
movl %r12d, %edi
leaq 0xdef4(%rip), %rsi      # 0x112f2
xorl %eax, %eax
callq 0x9174
callq 0x3612
movq %r14, %rdi
callq 0x10b0
shlq $0x20, %rax
addq %rbp, %rax
sarq $0x20, %rax
movzbl 0x220(%rsp,%rax), %eax
cmpl $0xa, %eax
je 0x3377
cmpl $0xd, %eax
je 0x3377
movq %r14, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x1140
testq %rax, %rax
jne 0x340a
jmp 0x3377
cmpb $0x23, 0x220(%rsp)
je 0x3377
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 0x146a
movq %r15, %rdi
callq 0x3664
testl %eax, %eax
je 0x3377
leaq 0xde6a(%rip), %rdi      # 0x11307
pushq $0x4
popq %rsi
callq 0x36a1
testl %eax, %eax
jne 0x359d
leaq 0xe4e7(%rip), %rdi      # 0x1199b
movl %r13d, %esi
callq 0x36a1
testl %eax, %eax
je 0x3544
callq 0x51da
testl %eax, %eax
je 0x3523
callq 0x63c5
testl %eax, %eax
js 0x3523
cmpl $0x1, 0x15d53(%rip)     # 0x19230
jne 0x3523
movq 0x15d52(%rip), %rax     # 0x19238
movzwl (%rax), %eax
movw %ax, 0x6(%rsp)
callq 0x51da
testl %eax, %eax
je 0x3523
callq 0x6220
cmpl $0x1, 0x15d2d(%rip)     # 0x19230
jne 0x3523
movq 0x15d2c(%rip), %rax     # 0x19238
movzwl (%rax), %edx
movzwl 0x6(%rsp), %esi
leaq 0x8(%rsp), %rdi
callq 0x2b48
jmp 0x3377
movq 0x10(%rsp), %rdx
movl 0x13ca2(%rip), %ecx     # 0x171d0
movl %r12d, %edi
leaq 0xe454(%rip), %rsi      # 0x1198c
xorl %eax, %eax
callq 0x9174
jmp 0x3377
leaq 0xe467(%rip), %rdi      # 0x119b2
movl %r13d, %esi
callq 0x36a1
testl %eax, %eax
je 0x3377
callq 0x51da
testl %eax, %eax
je 0x3586
cmpl $0x1, 0x15cc5(%rip)     # 0x19230
jne 0x3586
movq 0x15cc4(%rip), %rax     # 0x19238
movzwl (%rax), %esi
leaq 0x8(%rsp), %rdi
callq 0x2b66
jmp 0x3377
movq 0x10(%rsp), %rdx
movl 0x13c3f(%rip), %ecx     # 0x171d0
movl %r12d, %edi
leaq 0xe408(%rip), %rsi      # 0x119a3
jmp 0x3538
movq %rbx, %rdi
callq 0x10a0
cmpl $0x0, 0x13c24(%rip)     # 0x171d0
je 0x35eb
callq 0x2ae8
movq %rax, %rbx
leaq 0x8(%rsp), %rsi
movl $0x218, %edx            # imm = 0x218
movq %rax, %rdi
callq 0x1180
jmp 0x35fd
leaq 0xdc6b(%rip), %rsi      # 0x1123c
leaq 0xdd09(%rip), %rdx      # 0x112e1
xorl %ebx, %ebx
pushq $0x7
popq %rdi
movl $0x8ce, %ecx            # imm = 0x8CE
xorl %eax, %eax
callq 0x9174
jmp 0x35fd
movq 0x13b9e(%rip), %rax     # 0x17190
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