// File: /workspace/github_c_makefile_star2_O1/MikeGray-APH[P]LibLouisAPH/source/compile.c
// Function: compile_rule
static int compile_rule(void)
{
	struct rule *rule;
	enum table_hash_type hash_type;
	enum rule_direction direction;
	unichar *chars, *dots;
	int chars_len, dots_len;
	int chars_weight, dots_weight;

	if(!token_parse())
		goto return_fail;

	chars_weight =
	dots_weight = 0;
	direction = BOTH;
	while(*token_crs == u'-')
	{
		if(token_is_equal("-forward", 8))
			direction = FORWARD;
		else if(token_is_equal("-backward", 9))
			direction = BACKWARD;
		else if(token_is_equal("-after", 6))
			chars_weight =
			dots_weight = 1;
		else
		{
			log_message(LOG_ERROR, "%s:%d  invalid rule option %#S", table_file_names[include_depth], table_file_lines[include_depth], token_crs, token_len);
			return 0;
		}

		if(!token_parse())
			goto return_fail;
	}

	if(token_is_equal("init", 4))
		hash_type = TABLE_HASH_INIT;
	else if(token_is_equal("premode", 7))
		hash_type = TABLE_HASH_PREMODE;
	else if(token_is_equal("postmode", 8))
		hash_type = TABLE_HASH_POSTMODE;
	else if(token_is_equal("pretrans", 8))
		hash_type = TABLE_HASH_PRETRANS;
	else if(token_is_equal("trans", 5))
		hash_type = TABLE_HASH_TRANS;
	else if(token_is_equal("posttrans", 9))
		hash_type = TABLE_HASH_POSTTRANS;
	else if(token_is_equal("fini", 4))
		hash_type = TABLE_HASH_FINI;
	else
	{
		log_message(LOG_ERROR, "%s:%d  invalid rule type %#S", table_file_names[include_depth], table_file_lines[include_depth], token_crs, token_len);
		return 0;
	}

	if(!token_parse())
		goto return_fail;

	chars_len = token_convert_escapes_with_dots();
	if(chars_len <= 0)
		goto return_fail;
	chars = token_crs;

	if(!token_parse())
		goto return_fail;

	if(token_is_equal("-", 1))
	{
		//NOTE:  FORWARD direction may noy be necessary
		direction = FORWARD;
		dots_len = 0;
		dots = NULL;
	}
	else
	{
		if(hash_type == TABLE_HASH_TRANS)
			dots_len = token_convert_to_dots();
		else
			dots_len = token_convert_escapes_with_dots();
		if(dots_len <= 0)
			goto return_fail;
		dots = token_crs;
	}

	rule = table_add_rule(table, hash_type, direction, rule_filter_forward, rule_filter_backward, chars, chars_len, dots, dots_len, chars_weight, dots_weight);
	if(!rule)
	{
		log_message(LOG_ERROR, "%s:%d  unable to add rule", table_file_names[include_depth], table_file_lines[include_depth]);
		return 0;
	}
	rule->attrs = rule_attrs;
	rule->direction = direction;

	return 1;

	return_fail:
	log_message(LOG_ERROR, "%s:%d  invalid rule", table_file_names[include_depth], table_file_lines[include_depth]);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x5525
testl %eax, %eax
je 0x6171
xorl %ebx, %ebx
leaq 0xd9da(%rip), %r14      # 0x13827
leaq 0xd9c9(%rip), %r15      # 0x1381d
leaq 0xd9b9(%rip), %rbp      # 0x13814
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x143c0(%rip), %r8      # 0x1a228
cmpw $0x2d, (%r8)
movl 0x143ac(%rip), %r9d     # 0x1a220
jne 0x5f48
cmpl $0x6, %r9d
je 0x5edd
cmpl $0x9, %r9d
je 0x5eb9
cmpl $0x8, %r9d
jne 0x5f12
xorl %eax, %eax
movsbl (%rax,%rbp), %ecx
cmpw %cx, (%r8,%rax,2)
jne 0x5ead
incq %rax
cmpq $0x8, %rax
jne 0x5e92
movl $0x1, %ebx
jmp 0x5f00
cmpl $0x6, %r9d
je 0x5edd
cmpl $0x9, %r9d
jne 0x5f12
xorl %eax, %eax
movsbl (%rax,%r15), %ecx
cmpw %cx, (%r8,%rax,2)
jne 0x5ed7
incq %rax
cmpq $0x9, %rax
jne 0x5ebb
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x5f00
cmpl $0x6, %r9d
jne 0x5f12
xorl %eax, %eax
movsbl (%rax,%r14), %ecx
cmpw %cx, (%r8,%rax,2)
jne 0x5f12
incq %rax
cmpq $0x6, %rax
jne 0x5edf
movl $0x1, %r12d
movl $0x1, %r13d
callq 0x5525
testl %eax, %eax
jne 0x5e61
jmp 0x6171
movslq 0x1229f(%rip), %rax     # 0x181b8
leaq 0x122c0(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x12295(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xd8f9(%rip), %rsi      # 0x1382e
xorl %ebx, %ebx
movl $0x6, %edi
xorl %eax, %eax
callq 0xa36c
jmp 0x61a2
cmpl $0x4, %r9d
jne 0x5f75
xorl %eax, %eax
leaq 0xd8f6(%rip), %rcx      # 0x1384d
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5f75
incq %rax
cmpq $0x4, %rax
jne 0x5f57
movl $0x1, %ebp
jmp 0x6081
cmpl $0x7, %r9d
jne 0x5fa2
xorl %eax, %eax
leaq 0xd8ce(%rip), %rcx      # 0x13852
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5fa2
incq %rax
cmpq $0x7, %rax
jne 0x5f84
movl $0x2, %ebp
jmp 0x6081
cmpl $0x8, %r9d
jne 0x5ffc
xorl %eax, %eax
leaq 0xd8a9(%rip), %rcx      # 0x1385a
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5fcf
incq %rax
cmpq $0x8, %rax
jne 0x5fb1
movl $0x3, %ebp
jmp 0x6081
cmpl $0x8, %r9d
jne 0x5ffc
xorl %eax, %eax
leaq 0xd885(%rip), %rcx      # 0x13863
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5ffc
incq %rax
cmpq $0x8, %rax
jne 0x5fde
movl $0x4, %ebp
jmp 0x6081
cmpl $0x9, %r9d
je 0x6035
cmpl $0x5, %r9d
jne 0x6059
xorl %eax, %eax
leaq 0xd855(%rip), %rcx      # 0x13866
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x602f
incq %rax
cmpq $0x5, %rax
jne 0x6011
movl $0x5, %ebp
movb $0x1, %r15b
jmp 0x6084
cmpl $0x9, %r9d
jne 0x6059
xorl %eax, %eax
leaq 0xd82e(%rip), %rcx      # 0x1386c
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x6059
incq %rax
cmpq $0x9, %rax
jne 0x603e
movl $0x6, %ebp
jmp 0x6081
cmpl $0x4, %r9d
jne 0x60dd
xorl %eax, %eax
leaq 0xd80e(%rip), %rcx      # 0x13876
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x60dd
incq %rax
cmpq $0x4, %rax
jne 0x6068
movl $0x7, %ebp
xorl %r15d, %r15d
callq 0x5525
testl %eax, %eax
je 0x6171
callq 0x6edd
testl %eax, %eax
jle 0x6171
movl %eax, %r14d
movq 0x14180(%rip), %rax     # 0x1a228
movq %rax, (%rsp)
callq 0x5525
testl %eax, %eax
je 0x6171
movq 0x14168(%rip), %rdi     # 0x1a228
movl 0x1415a(%rip), %esi     # 0x1a220
cmpl $0x1, %esi
jne 0x6105
cmpw $0x2d, (%rdi)
jne 0x6105
xorl %r10d, %r10d
movl $0x1, %ebx
xorl %eax, %eax
jmp 0x6127
movslq 0x120d4(%rip), %rax     # 0x181b8
leaq 0x120f5(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x120ca(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xd77b(%rip), %rsi      # 0x1387b
jmp 0x5f35
testb %r15b, %r15b
je 0x6117
callq 0x6e16
movl %eax, 0x1410b(%rip)     # 0x1a220
jmp 0x611c
callq 0x6edd
testl %eax, %eax
jle 0x6171
movq 0x14101(%rip), %r10     # 0x1a228
movq (%rsp), %r9
movq 0x1204e(%rip), %rdi     # 0x18180
movq 0x1205f(%rip), %rcx     # 0x18198
movq 0x12050(%rip), %r8      # 0x18190
subq $0x8, %rsp
movl %ebp, %esi
movl %ebx, %edx
pushq %r13
pushq %r12
pushq %rax
pushq %r10
pushq %r14
callq 0x20f5
addq $0x30, %rsp
testq %rax, %rax
je 0x61b3
movl 0x12023(%rip), %ecx     # 0x18188
movl %ecx, (%rax)
movl %ebx, 0x4(%rax)
movl $0x1, %ebx
jmp 0x61a2
movslq 0x12040(%rip), %rax     # 0x181b8
leaq 0x12061(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x12036(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xd71e(%rip), %rsi      # 0x138b2
xorl %ebx, %ebx
movl $0x6, %edi
xorl %eax, %eax
callq 0xa36c
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x11ffe(%rip), %rax     # 0x181b8
leaq 0x1201f(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x11ff4(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xd6c2(%rip), %rsi      # 0x13898
jmp 0x6194