// File: /workspace/github_c_makefile_star2_O3/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 0x53ae
testl %eax, %eax
je 0x5fa8
xorl %ebx, %ebx
leaq 0xdc36(%rip), %r14      # 0x138b9
leaq 0xdc26(%rip), %r15      # 0x138b0
leaq 0xdc32(%rip), %rbp      # 0x138c3
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x1458a(%rip), %r8      # 0x1a228
cmpw $0x2d, (%r8)
movl 0x14576(%rip), %r9d     # 0x1a220
jne 0x5d6e
cmpl $0x9, %r9d
je 0x5d04
cmpl $0x8, %r9d
je 0x5ce6
cmpl $0x6, %r9d
jne 0x5d38
xorl %eax, %eax
movsbl (%rax,%rbp), %ecx
cmpw %cx, (%r8,%rax,2)
jne 0x5d38
incq %rax
cmpq $0x6, %rax
jne 0x5cc4
movl $0x1, %r12d
movl $0x1, %r13d
jmp 0x5d20
xorl %eax, %eax
movsbl (%rax,%r15), %ecx
cmpw %cx, (%r8,%rax,2)
jne 0x5d32
incq %rax
cmpq $0x8, %rax
jne 0x5ce8
movl $0x1, %ebx
jmp 0x5d20
xorl %eax, %eax
movsbl (%rax,%r14), %ecx
cmpw %cx, (%r8,%rax,2)
jne 0x5d38
incq %rax
cmpq $0x9, %rax
jne 0x5d06
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
callq 0x53ae
testl %eax, %eax
jne 0x5c97
jmp 0x5fa8
movl $0x8, %r9d
movslq 0x12479(%rip), %rax     # 0x181b8
leaq 0x1249a(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x1246f(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xdb6f(%rip), %rsi      # 0x138ca
xorl %ebx, %ebx
movl $0x6, %edi
xorl %eax, %eax
callq 0xa278
jmp 0x5fd9
cmpl $0x4, %r9d
jne 0x5d9b
xorl %eax, %eax
leaq 0xdb6c(%rip), %rcx      # 0x138e9
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5d9b
incq %rax
cmpq $0x4, %rax
jne 0x5d7d
movl $0x1, %ebp
jmp 0x5eb8
leal -0x5(%r9), %eax
cmpl $0x4, %eax
ja 0x5e90
leaq 0xd545(%rip), %rcx      # 0x132f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
leaq 0xdb41(%rip), %rcx      # 0x13902
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5e90
incq %rax
cmpq $0x5, %rax
jne 0x5dc1
movl $0x5, %ebp
movb $0x1, %r15b
jmp 0x5ebb
xorl %eax, %eax
leaq 0xdaff(%rip), %rcx      # 0x138ee
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5e90
incq %rax
cmpq $0x7, %rax
jne 0x5def
movl $0x2, %ebp
jmp 0x5eb8
xorl %eax, %eax
leaq 0xdadc(%rip), %rcx      # 0x138f6
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5e38
incq %rax
cmpq $0x8, %rax
jne 0x5e1a
movl $0x3, %ebp
jmp 0x5eb8
xorl %eax, %eax
leaq 0xdabe(%rip), %rcx      # 0x138ff
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5e5c
incq %rax
cmpq $0x8, %rax
jne 0x5e41
movl $0x4, %ebp
jmp 0x5eb8
cmpl $0x5, %r9d
je 0x5db8
cmpl $0x9, %r9d
jne 0x5e90
xorl %eax, %eax
leaq 0xda93(%rip), %rcx      # 0x13908
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5e90
incq %rax
cmpq $0x9, %rax
jne 0x5e75
movl $0x6, %ebp
jmp 0x5eb8
cmpl $0x4, %r9d
jne 0x5f14
xorl %eax, %eax
leaq 0xda73(%rip), %rcx      # 0x13912
movsbl (%rax,%rcx), %edx
cmpw %dx, (%r8,%rax,2)
jne 0x5f14
incq %rax
cmpq $0x4, %rax
jne 0x5e9f
movl $0x7, %ebp
xorl %r15d, %r15d
callq 0x53ae
testl %eax, %eax
je 0x5fa8
callq 0x6cea
testl %eax, %eax
jle 0x5fa8
movl %eax, %r14d
movq 0x14349(%rip), %rax     # 0x1a228
movq %rax, (%rsp)
callq 0x53ae
testl %eax, %eax
je 0x5fa8
movq 0x14331(%rip), %rdi     # 0x1a228
movl 0x14323(%rip), %esi     # 0x1a220
cmpl $0x1, %esi
jne 0x5f3c
cmpw $0x2d, (%rdi)
jne 0x5f3c
xorl %r10d, %r10d
movl $0x1, %ebx
xorl %eax, %eax
jmp 0x5f5e
movslq 0x1229d(%rip), %rax     # 0x181b8
leaq 0x122be(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x12293(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xd9e0(%rip), %rsi      # 0x13917
jmp 0x5d5b
testb %r15b, %r15b
je 0x5f4e
callq 0x6c24
movl %eax, 0x142d4(%rip)     # 0x1a220
jmp 0x5f53
callq 0x6cea
testl %eax, %eax
jle 0x5fa8
movq 0x142ca(%rip), %r10     # 0x1a228
movq (%rsp), %r9
movq 0x12217(%rip), %rdi     # 0x18180
movq 0x12228(%rip), %rcx     # 0x18198
movq 0x12219(%rip), %r8      # 0x18190
subq $0x8, %rsp
movl %ebp, %esi
movl %ebx, %edx
pushq %r13
pushq %r12
pushq %rax
pushq %r10
pushq %r14
callq 0x2151
addq $0x30, %rsp
testq %rax, %rax
je 0x5fea
movl 0x121ec(%rip), %ecx     # 0x18188
movl %ecx, (%rax)
movl %ebx, 0x4(%rax)
movl $0x1, %ebx
jmp 0x5fd9
movslq 0x12209(%rip), %rax     # 0x181b8
leaq 0x1222a(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x121ff(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xd983(%rip), %rsi      # 0x1394e
xorl %ebx, %ebx
movl $0x6, %edi
xorl %eax, %eax
callq 0xa278
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x121c7(%rip), %rax     # 0x181b8
leaq 0x121e8(%rip), %rcx     # 0x181e0
movq (%rcx,%rax,8), %rdx
leaq 0x121bd(%rip), %rcx     # 0x181c0
movl (%rcx,%rax,4), %ecx
leaq 0xd927(%rip), %rsi      # 0x13934
jmp 0x5fcb