// File: /workspace/github_c_makefile_star2_O3/MikeGray-APH[P]LibLouisAPH/source/compile.c
// Function: compile_filter
static int compile_filter(void)
{
	struct filter *filter;
	unichar pattern[PATTERN_MAX], *name, *before, *after;
	int name_len, before_len, after_len;

	DB_MEMSET(pattern, 0, PATTERN_MAX)
	before =
	after = NULL;

	if(!token_parse())
		goto return_fail;

	token_convert_escapes();
	if(token_len <= 0)
	{
		log_message(LOG_ERROR, "%s:%d  invalid filter name", table_file_names[include_depth], table_file_lines[include_depth]);
		return 0;
	}
	name = token_crs;
	name_len = token_len;

	if(!token_parse())
		goto return_fail;

	if(token_crs[0] == u'-' && token_len == 1)
	{
		before = NULL;
		before_len = 0;
	}
	else
	{
		if(token_convert_escapes_with_dots() <= 0)
			goto return_fail;
		before_len = pattern_compile(pattern, PATTERN_MAX, token_crs, token_len, table->attrs_chars, table->subpatterns);
		if(!before_len)
			goto return_fail;
		pattern_reverse(pattern);
		before = MALLOC((before_len + 1) * sizeof(unichar));
		if(!before)
		{
			LOG_ALLOCATE_FAIL
			goto return_fail_free;
		}
		memcpy(before, pattern, (before_len + 1) * sizeof(unichar));
	}

	if(!token_parse())
		goto return_fail;

	if(token_crs[0] == u'-' && token_len == 1)
	{
		after = NULL;
		after_len = 0;
	}
	else
	{
		if(token_convert_escapes_with_dots() <= 0)
			goto return_fail;
		after_len = pattern_compile(pattern, PATTERN_MAX, token_crs, token_len, table->attrs_chars, table->subpatterns);
		if(!after_len)
			goto return_fail;
		after = MALLOC((after_len + 1) * sizeof(unichar));
		if(!after)
		{
			LOG_ALLOCATE_FAIL
			goto return_fail_free;
		}
		memcpy(after, pattern, (after_len + 1) * sizeof(unichar));
	}

	filter = filter_allocate();
	if(!filter)
	{
		LOG_ALLOCATE_FAIL
		goto return_fail_free;
	}
	filter->name = MALLOC((name_len + 1) * sizeof(unichar));
	if(!filter->name)
	{
		LOG_ALLOCATE_FAIL
		goto return_fail_free;
	}
	utf16_copy(filter->name, name, name_len + 1);
	filter->name_len = name_len;

	filter->nxt = NULL;
	filter->before = before;
	filter->before_len = before_len;
	filter->after = after;
	filter->after_len = after_len;

	filter->nxt = table->filters;
	table->filters = filter;

	return 1;

	return_fail:
	log_message(LOG_ERROR, "%s:%d  invalid filter", table_file_names[include_depth], table_file_lines[include_depth]);

	return_fail_free:
	if(before)
		FREE(before);
	if(after)
		FREE(after);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4a58, %rsp           # imm = 0x4A58
leaq 0x10(%rsp), %rdi
xorl %ebx, %ebx
movl $0x2520, %edx           # imm = 0x2520
xorl %esi, %esi
callq 0x1110
callq 0x53ae
testl %eax, %eax
je 0x598b
movq 0x129cb(%rip), %rdi     # 0x18180
movq 0x14a6c(%rip), %rsi     # 0x1a228
movl 0x14a5e(%rip), %edx     # 0x1a220
callq 0x2022
movl %eax, 0x14a53(%rip)     # 0x1a220
movq 0x14a54(%rip), %rdi     # 0x1a228
movl %eax, %esi
callq 0x134f
movl %eax, 0x14a3f(%rip)     # 0x1a220
testl %eax, %eax
jle 0x58da
movl %eax, %r14d
movq 0x14a35(%rip), %rbp     # 0x1a228
callq 0x53ae
xorl %r15d, %r15d
testl %eax, %eax
je 0x5989
movq 0x14a1e(%rip), %rax     # 0x1a228
cmpw $0x2d, (%rax)
jne 0x5910
cmpl $0x1, 0x14a05(%rip)     # 0x1a220
jne 0x5910
xorl %ebx, %ebx
callq 0x53ae
testl %eax, %eax
je 0x598b
movq 0x149f1(%rip), %rax     # 0x1a228
cmpw $0x2d, (%rax)
jne 0x59ed
cmpl $0x1, 0x149d8(%rip)     # 0x1a220
jne 0x59ed
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
callq 0x1faa
testq %rax, %rax
je 0x5a5c
movq %rax, %r13
leal 0x2(,%r14,2), %edi
callq 0x1190
movq %rax, 0x20(%r13)
testq %rax, %rax
je 0x5a98
movl %r14d, %ecx
incl %ecx
movl %ecx, %ecx
xorl %edx, %edx
movzwl (%rbp,%rdx,2), %esi
movw %si, (%rax,%rdx,2)
incq %rdx
cmpq %rdx, %rcx
jne 0x588d
movw $0x0, -0x2(%rax,%rcx,2)
movl %r14d, 0x28(%r13)
movq %rbx, 0x8(%r13)
movl %r15d, 0x18(%r13)
movq %r12, 0x10(%r13)
movl 0xc(%rsp), %eax
movl %eax, 0x1c(%r13)
movq 0x128bc(%rip), %rax     # 0x18180
movq 0x20(%rax), %rcx
movq %rcx, (%r13)
movq %r13, 0x20(%rax)
movl $0x1, %ebx
jmp 0x59d9
movslq 0x128d7(%rip), %rax     # 0x181b8
leaq 0x128f8(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x128cd(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xdf52(%rip), %rsi      # 0x1384f
xorl %ebx, %ebx
movl $0x6, %edi
xorl %eax, %eax
callq 0xa278
jmp 0x59d9
callq 0x6cea
testl %eax, %eax
jle 0x5989
movq 0x14908(%rip), %rdx     # 0x1a228
movl 0x148fa(%rip), %ecx     # 0x1a220
movq 0x12853(%rip), %r8      # 0x18180
movq 0x28(%r8), %r9
addq $0x30, %r8
leaq 0x10(%rsp), %rdi
movl $0x2520, %esi           # imm = 0x2520
callq 0x8061
testl %eax, %eax
je 0x5989
movl %eax, %r15d
leaq 0x10(%rsp), %rdi
callq 0x84e0
movslq %r15d, %rax
leaq 0x2(,%rax,2), %r12
movq %r12, %rdi
callq 0x1190
testq %rax, %rax
je 0x5a79
movq %rax, %rbx
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x1180
jmp 0x5823
xorl %ebx, %ebx
movslq 0x12826(%rip), %rax     # 0x181b8
leaq 0x12847(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x1281c(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xdebc(%rip), %rsi      # 0x1386a
xorl %r12d, %r12d
movl $0x6, %edi
xorl %eax, %eax
callq 0xa278
testq %rbx, %rbx
je 0x59ca
movq %rbx, %rdi
callq 0x1040
xorl %ebx, %ebx
testq %r12, %r12
je 0x59d9
movq %r12, %rdi
callq 0x1040
movl %ebx, %eax
addq $0x4a58, %rsp           # imm = 0x4A58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6cea
testl %eax, %eax
jle 0x598b
movq 0x1482b(%rip), %rdx     # 0x1a228
movl 0x1481d(%rip), %ecx     # 0x1a220
movq 0x12776(%rip), %r8      # 0x18180
movq 0x28(%r8), %r9
addq $0x30, %r8
leaq 0x10(%rsp), %rdi
movl $0x2520, %esi           # imm = 0x2520
callq 0x8061
testl %eax, %eax
je 0x598b
movl %eax, 0xc(%rsp)
cltq
leaq 0x2(,%rax,2), %r13
movq %r13, %rdi
callq 0x1190
testq %rax, %rax
je 0x5ab5
movq %rax, %r12
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x1180
jmp 0x5859
leaq 0xd7d9(%rip), %rsi      # 0x1323c
leaq 0xd8d7(%rip), %rdx      # 0x13341
movl $0x7, %edi
movl $0x3f2, %ecx            # imm = 0x3F2
jmp 0x59b6
leaq 0xd7bc(%rip), %rsi      # 0x1323c
leaq 0xd8ba(%rip), %rdx      # 0x13341
xorl %ebx, %ebx
movl $0x7, %edi
movl $0x3d1, %ecx            # imm = 0x3D1
jmp 0x5904
leaq 0xd79d(%rip), %rsi      # 0x1323c
leaq 0xd89b(%rip), %rdx      # 0x13341
movl $0x7, %edi
movl $0x3f8, %ecx            # imm = 0x3F8
jmp 0x59b6
leaq 0xd780(%rip), %rsi      # 0x1323c
leaq 0xd87e(%rip), %rdx      # 0x13341
xorl %r12d, %r12d
movl $0x7, %edi
movl $0x3e9, %ecx            # imm = 0x3E9
jmp 0x59b6