// File: /workspace/github_c_makefile_star2_O2/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 0x51da
testl %eax, %eax
je 0x5712
callq 0x6220
movl 0x13caf(%rip), %ebp     # 0x19230
testl %ebp, %ebp
jle 0x5663
movq 0x13ca8(%rip), %r14     # 0x19238
callq 0x51da
xorl %r15d, %r15d
testl %eax, %eax
je 0x5710
movq 0x13c91(%rip), %rax     # 0x19238
cmpw $0x2d, (%rax)
jne 0x5697
cmpl $0x1, 0x13c78(%rip)     # 0x19230
jne 0x5697
xorl %ebx, %ebx
callq 0x51da
testl %eax, %eax
je 0x5712
movq 0x13c64(%rip), %rax     # 0x19238
cmpw $0x2d, (%rax)
jne 0x5768
cmpl $0x1, 0x13c4b(%rip)     # 0x19230
jne 0x5768
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
callq 0x1ef9
testq %rax, %rax
je 0x57d7
movq %rax, %r13
leaq 0x2(,%rbp,2), %rdi
callq 0x1190
movq %rax, 0x20(%r13)
testq %rax, %rax
je 0x5819
leaq 0x1(%rbp), %rdx
movq %rax, %rdi
movq %r14, %rsi
callq 0x5277
movl %ebp, 0x28(%r13)
movq %rbx, 0x8(%r13)
movl %r15d, 0x18(%r13)
movq %r12, 0x10(%r13)
movl 0xc(%rsp), %eax
movl %eax, 0x1c(%r13)
movq 0x11b41(%rip), %rax     # 0x17190
movq 0x20(%rax), %rcx
movq %rcx, (%r13)
movq %r13, 0x20(%rax)
pushq $0x1
popq %rbx
jmp 0x5754
movslq 0x11b5e(%rip), %rax     # 0x171c8
leaq 0x11b7f(%rip), %rcx     # 0x171f0
movq (%rcx,%rax,8), %rdx
leaq 0x11b54(%rip), %rcx     # 0x171d0
movl (%rcx,%rax,4), %ecx
leaq 0xc169(%rip), %rsi      # 0x117ef
xorl %ebx, %ebx
pushq $0x6
popq %rdi
xorl %eax, %eax
callq 0x9174
jmp 0x5754
callq 0x64b0
testl %eax, %eax
jle 0x5710
movq 0x13b91(%rip), %rdx     # 0x19238
movl 0x13b83(%rip), %ecx     # 0x19230
movq 0x11adc(%rip), %r8      # 0x17190
movq 0x28(%r8), %r9
addq $0x30, %r8
leaq 0x10(%rsp), %rdi
movl $0x2520, %esi           # imm = 0x2520
callq 0x7490
testl %eax, %eax
je 0x5710
movl %eax, %r15d
leaq 0x10(%rsp), %rdi
callq 0x7904
movslq %r15d, %rax
leaq 0x2(,%rax,2), %r12
movq %r12, %rdi
callq 0x1190
testq %rax, %rax
je 0x57f2
movq %rax, %rbx
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x1180
jmp 0x55c0
xorl %ebx, %ebx
movslq 0x11aaf(%rip), %rax     # 0x171c8
leaq 0x11ad0(%rip), %rcx     # 0x171f0
movq (%rcx,%rax,8), %rdx
leaq 0x11aa5(%rip), %rcx     # 0x171d0
movl (%rcx,%rax,4), %ecx
leaq 0xc0d5(%rip), %rsi      # 0x1180a
xorl %r12d, %r12d
pushq $0x6
popq %rdi
xorl %eax, %eax
callq 0x9174
movq %rbx, %rdi
callq 0x1040
movq %r12, %rdi
callq 0x1040
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x4a58, %rsp           # imm = 0x4A58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x64b0
testl %eax, %eax
jle 0x5712
movq 0x13ac0(%rip), %rdx     # 0x19238
movl 0x13ab2(%rip), %ecx     # 0x19230
movq 0x11a0b(%rip), %r8      # 0x17190
movq 0x28(%r8), %r9
addq $0x30, %r8
leaq 0x10(%rsp), %rdi
movl $0x2520, %esi           # imm = 0x2520
callq 0x7490
testl %eax, %eax
je 0x5712
movl %eax, 0xc(%rsp)
cltq
leaq 0x2(,%rax,2), %r13
movq %r13, %rdi
callq 0x1190
testq %rax, %rax
je 0x5834
movq %rax, %r12
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x1180
jmp 0x55f6
leaq 0xba5e(%rip), %rsi      # 0x1123c
leaq 0xbafc(%rip), %rdx      # 0x112e1
pushq $0x7
popq %rdi
movl $0x3f2, %ecx            # imm = 0x3F2
jmp 0x573b
leaq 0xba43(%rip), %rsi      # 0x1123c
leaq 0xbae1(%rip), %rdx      # 0x112e1
xorl %ebx, %ebx
pushq $0x7
popq %rdi
movl $0x3d1, %ecx            # imm = 0x3D1
xorl %eax, %eax
callq 0x9174
xorl %r12d, %r12d
jmp 0x5742
leaq 0xba1c(%rip), %rsi      # 0x1123c
leaq 0xbaba(%rip), %rdx      # 0x112e1
pushq $0x7
popq %rdi
movl $0x3f8, %ecx            # imm = 0x3F8
jmp 0x573b
leaq 0xba01(%rip), %rsi      # 0x1123c
leaq 0xba9f(%rip), %rdx      # 0x112e1
xorl %r12d, %r12d
pushq $0x7
popq %rdi
movl $0x3e9, %ecx            # imm = 0x3E9
jmp 0x573b