// File: /workspace/github_c_makefile_star2_O2/MikeGray-APH[P]LibLouisAPH/source/compile.c
// Function: table_compile_from_file
struct table* table_compile_from_file(const char *file_name)
{
	FILE *file;
	struct table table_auto;
	char attrs_chars_default[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
	int file_name_len, i;

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

	table = &table_auto;
	table_init(table);

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

	rule_attrs = 0;
	rule_filter_forward =
	rule_filter_backward = NULL;
	variables = NULL;
	macros = NULL;
	var_enum = 0;
	macro_depth = 0;
	include_depth = -1;

	/*   set defaults   */
	table->marker_user      = TABLE_MARKER_USER;
	table->marker_begin     = TABLE_MARKER_BEGIN;
	table->marker_end       = TABLE_MARKER_END;
	table->marker_modifier  = TABLE_MARKER_MODIFIER;
	table->marker_hard      = TABLE_MARKER_HARD;
	table->marker_soft      = TABLE_MARKER_SOFT;
	table->marker_internal  = TABLE_MARKER_INTERNAL;
	for(i = 0; i < 32; i++)
		table->attrs_chars[i] = attrs_chars_default[i];

	file_read(file, table->file_name);
	fclose(file);

	variable_free(variables);
	variables = NULL;
	macro_free(macros);
	macros = NULL;

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

	table = table_allocate();
	*table = table_auto;

#ifdef DEBUG

	if(!table->nocontract_set)
	{
		ASSERT(!table->nocontract.begin_len)
		ASSERT(!table->nocontract.end_len)
		ASSERT(!table->nocontract.word_len)
		ASSERT(!table->nocontract.term_len)
		ASSERT(!table->nocontract.symbol_len)
	}
	if(!table->capital_set)
	{
		ASSERT(!table->capital.begin_len)
		ASSERT(!table->capital.end_len)
		ASSERT(!table->capital.word_len)
		ASSERT(!table->capital.term_len)
		ASSERT(!table->capital.symbol_len)
	}
	if(!table->numeric_set)
	{
		ASSERT(!table->numeric.begin_len)
		ASSERT(!table->numeric.end_len)
		ASSERT(!table->numeric.word_len)
		ASSERT(!table->numeric.term_len)
		ASSERT(!table->numeric.symbol_len)
	}

#endif

	return table;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x320, %rsp            # imm = 0x320
movq %rdi, %r14
leaq 0xf164(%rip), %rsi      # 0x11d7e
callq 0x11d0
testq %rax, %rax
je 0x2e31
movq %rax, %rbx
movq %rsp, %rdi
movq %rdi, 0x1455b(%rip)     # 0x17190
callq 0x192c
movq %r14, %rdi
callq 0x10b0
incl %eax
movslq %eax, %rdi
callq 0x1190
movq 0x1453d(%rip), %r15     # 0x17190
movq %rax, 0x10(%r15)
testq %rax, %rax
je 0x2e00
movq %rax, %rdi
movq %r14, %rsi
callq 0x1080
andl $0x0, 0x14526(%rip)     # 0x17198
andq $0x0, 0x14526(%rip)     # 0x171a0
andq $0x0, 0x14526(%rip)     # 0x171a8
andq $0x0, 0x14526(%rip)     # 0x171b0
andq $0x0, 0x14526(%rip)     # 0x171b8
andl $0x0, 0x14527(%rip)     # 0x171c0
andl $0x0, 0x14524(%rip)     # 0x171c4
orl $-0x1, 0x14521(%rip)    # 0x171c8
movabsq $-0xffb0ffc0ffd0fff, %rax # imm = 0xF004F003F002F001
movq %rax, 0x1e8(%r15)
movl $0xf006f005, 0x1f0(%r15) # imm = 0xF006F005
movw $0xf007, 0x1f4(%r15)    # imm = 0xF007
xorl %eax, %eax
leaq 0xe5ea(%rip), %rcx      # 0x112c0
cmpq $0x20, %rax
je 0x2ce9
movb (%rax,%rcx), %dl
movb %dl, 0x30(%r15,%rax)
incq %rax
jmp 0x2cd6
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0x2e43
movq %rbx, %rdi
callq 0x10a0
movq 0x144ac(%rip), %rdi     # 0x171b0
callq 0x3240
andq $0x0, 0x1449f(%rip)     # 0x171b0
movq 0x144a0(%rip), %rdi     # 0x171b8
callq 0x326f
andq $0x0, 0x14493(%rip)     # 0x171b8
cmpl $0x0, 0x144a4(%rip)     # 0x171d0
je 0x2e21
callq 0x1db7
movq %rax, %rbx
movq %rax, 0x1444f(%rip)     # 0x17190
movq %rsp, %rsi
movl $0x320, %edx            # imm = 0x320
movq %rax, %rdi
callq 0x1180
cmpl $0x0, 0x1d8(%rbx)
jne 0x2d8f
cmpl $0x0, 0xa4(%rbx)
jne 0x2dfb
cmpl $0x0, 0xa8(%rbx)
jne 0x2dfb
cmpl $0x0, 0xac(%rbx)
jne 0x2dfb
cmpl $0x0, 0xb0(%rbx)
jne 0x2dfb
cmpl $0x0, 0xb4(%rbx)
jne 0x2dfb
cmpl $0x0, 0x1dc(%rbx)
jne 0x2dc5
cmpl $0x0, 0x124(%rbx)
jne 0x2dfb
cmpl $0x0, 0x128(%rbx)
jne 0x2dfb
cmpl $0x0, 0x12c(%rbx)
jne 0x2dfb
cmpl $0x0, 0x130(%rbx)
jne 0x2dfb
cmpl $0x0, 0x134(%rbx)
jne 0x2dfb
cmpl $0x0, 0x1e0(%rbx)
jne 0x2e33
cmpl $0x0, 0x1a4(%rbx)
jne 0x2dfb
cmpl $0x0, 0x1a8(%rbx)
jne 0x2dfb
cmpl $0x0, 0x1ac(%rbx)
jne 0x2dfb
cmpl $0x0, 0x1b0(%rbx)
jne 0x2dfb
cmpl $0x0, 0x1b4(%rbx)
je 0x2e33
callq 0x1060
leaq 0xe435(%rip), %rsi      # 0x1123c
leaq 0xe4d3(%rip), %rdx      # 0x112e1
xorl %ebx, %ebx
pushq $0x7
popq %rdi
movl $0x847, %ecx            # imm = 0x847
xorl %eax, %eax
callq 0x9174
jmp 0x2e33
movq 0x14368(%rip), %rax     # 0x17190
movq 0x10(%rax), %rdi
callq 0x1040
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x320, %rsp            # imm = 0x320
popq %rbx
popq %r14
popq %r15
retq