// File: /workspace/github_c_makefile_star2_O1/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 0x5525
testl %eax, %eax
je 0x5b2d
movq 0x12831(%rip), %rdi     # 0x18180
movq 0x148d2(%rip), %rsi     # 0x1a228
movl 0x148c4(%rip), %edx     # 0x1a220
callq 0x1fef
movl %eax, 0x148b9(%rip)     # 0x1a220
movq 0x148ba(%rip), %rdi     # 0x1a228
movl %eax, %esi
callq 0x133d
movl %eax, 0x148a5(%rip)     # 0x1a220
testl %eax, %eax
jle 0x5a7c
movl %eax, %r14d
movq 0x1489b(%rip), %rbp     # 0x1a228
callq 0x5525
xorl %r15d, %r15d
testl %eax, %eax
je 0x5b2b
movq 0x14884(%rip), %rax     # 0x1a228
cmpw $0x2d, (%rax)
jne 0x5ab2
cmpl $0x1, 0x1486b(%rip)     # 0x1a220
jne 0x5ab2
xorl %ebx, %ebx
callq 0x5525
testl %eax, %eax
je 0x5b2d
movq 0x14857(%rip), %rax     # 0x1a228
cmpw $0x2d, (%rax)
jne 0x5b8f
cmpl $0x1, 0x1483e(%rip)     # 0x1a220
jne 0x5b8f
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
callq 0x1f69
testq %rax, %rax
je 0x5bfe
movq %rax, %r13
leal 0x2(,%r14,2), %edi
callq 0x1180
movq %rax, 0x20(%r13)
testq %rax, %rax
je 0x5c44
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 0x5a27
movw $0x0, -0x2(%rax,%rcx,2)
movl %r14d, 0x28(%r13)
movq $0x0, (%r13)
movq %rbx, 0x8(%r13)
movl %r15d, 0x18(%r13)
movq %r12, 0x10(%r13)
movl 0xc(%rsp), %eax
movl %eax, 0x1c(%r13)
movq 0x1271a(%rip), %rax     # 0x18180
movq 0x20(%rax), %rcx
movq %rcx, (%r13)
movq %r13, 0x20(%rax)
movl $0x1, %ebx
jmp 0x5b7b
movslq 0x12735(%rip), %rax     # 0x181b8
leaq 0x12756(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x1272b(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xdd14(%rip), %rsi      # 0x137b3
xorl %ebx, %ebx
movl $0x6, %edi
xorl %eax, %eax
callq 0xa36c
jmp 0x5b7b
callq 0x6edd
testl %eax, %eax
jle 0x5b2b
movq 0x14766(%rip), %rdx     # 0x1a228
movl 0x14758(%rip), %ecx     # 0x1a220
movq 0x126b1(%rip), %r8      # 0x18180
movq 0x28(%r8), %r9
addq $0x30, %r8
leaq 0x10(%rsp), %rdi
movl $0x2520, %esi           # imm = 0x2520
callq 0x8144
testl %eax, %eax
je 0x5b2b
movl %eax, %r15d
leaq 0x10(%rsp), %rdi
callq 0x85c5
movslq %r15d, %rax
leaq 0x2(,%rax,2), %r12
movq %r12, %rdi
callq 0x1180
testq %rax, %rax
je 0x5c1b
movq %rax, %rbx
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x1170
jmp 0x59bd
xorl %ebx, %ebx
movslq 0x12684(%rip), %rax     # 0x181b8
leaq 0x126a5(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x1267a(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xdc7e(%rip), %rsi      # 0x137ce
xorl %r12d, %r12d
movl $0x6, %edi
xorl %eax, %eax
callq 0xa36c
testq %rbx, %rbx
je 0x5b6c
movq %rbx, %rdi
callq 0x1040
xorl %ebx, %ebx
testq %r12, %r12
je 0x5b7b
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 0x6edd
testl %eax, %eax
jle 0x5b2d
movq 0x14689(%rip), %rdx     # 0x1a228
movl 0x1467b(%rip), %ecx     # 0x1a220
movq 0x125d4(%rip), %r8      # 0x18180
movq 0x28(%r8), %r9
addq $0x30, %r8
leaq 0x10(%rsp), %rdi
movl $0x2520, %esi           # imm = 0x2520
callq 0x8144
testl %eax, %eax
je 0x5b2d
movl %eax, 0xc(%rsp)
cltq
leaq 0x2(,%rax,2), %r13
movq %r13, %rdi
callq 0x1180
testq %rax, %rax
je 0x5c61
movq %rax, %r12
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x1170
jmp 0x59f3
leaq 0xd5ef(%rip), %rsi      # 0x131f4
leaq 0xd695(%rip), %rdx      # 0x132a1
movl $0x7, %edi
movl $0x3f2, %ecx            # imm = 0x3F2
jmp 0x5b58
leaq 0xd5d2(%rip), %rsi      # 0x131f4
leaq 0xd678(%rip), %rdx      # 0x132a1
xorl %ebx, %ebx
movl $0x7, %edi
movl $0x3d1, %ecx            # imm = 0x3D1
xorl %eax, %eax
callq 0xa36c
xorl %r12d, %r12d
jmp 0x5b5f
leaq 0xd5a9(%rip), %rsi      # 0x131f4
leaq 0xd64f(%rip), %rdx      # 0x132a1
movl $0x7, %edi
movl $0x3f8, %ecx            # imm = 0x3F8
jmp 0x5b58
leaq 0xd58c(%rip), %rsi      # 0x131f4
leaq 0xd632(%rip), %rdx      # 0x132a1
xorl %r12d, %r12d
movl $0x7, %edi
movl $0x3e9, %ecx            # imm = 0x3E9
jmp 0x5b58