// File: /workspace/github_c_makefile_star2_O2/MikeGray-APH[P]LibLouisAPH/source/outputs/table-output.c
// Function: rules_output
static void rules_output(FILE *output, const struct rule *const*rule_hash, const int rules_max, const enum rule_direction direction, const int use_dots)
{
	const struct rule *rule;
	int i, cnt, most;

#ifdef TABLE_ALLOCATE_HASHES
	if(!rule_hash)
		return;
#endif

	most = 0;
	for(i = 0; i < rules_max; i++)
	{
		rule = rule_hash[i];
		cnt = 0;
		while(rule)
		{
			cnt++;
			if(direction == FORWARD)
				rule = rule->chars_nxt;
			else
				rule = rule->dots_nxt;
		}
		if(cnt > most)
			most = cnt;
		if(!cnt)
			continue;

		fprintf(output, "[%5d] %5d", i, cnt);
		rule = rule_hash[i];
		while(rule)
		{
			fputs("\n   ", output);

			if(direction == FORWARD)
			{
				if(rule->chars_len == 1)
					utf16_output_char_escape(output, rule->chars[0]);
				else
					utf16_output(output, rule->chars, rule->chars_len);
				fputs(" ", output);
				if(use_dots)
					output_dots_string(output, rule->dots, rule->dots_len);
				else
				if(rule->dots_len == 1)
					utf16_output_char_escape(output, rule->dots[0]);
				else
					utf16_output(output, rule->dots, rule->dots_len);
			}
			else
			{
				if(use_dots)
					output_dots_string(output, rule->dots, rule->dots_len);
				else
				if(rule->dots_len == 1)
					utf16_output_char_escape(output, rule->dots[0]);
				else
					utf16_output(output, rule->dots, rule->dots_len);
				fputs(" ", output);
				if(rule->chars_len == 1)
					utf16_output_char_escape(output, rule->chars[0]);
				else
					utf16_output(output, rule->chars, rule->chars_len);
			}
			if(rule->attrs)
				fprintf(output, " <0x%08x>", rule->attrs);

			if(rule->filter_forward)
			{
				fputs("   ", output);
				if(!rule->filter_forward->name)
				{
					if(rule->filter_forward->before)
						pattern_print_reverse(output, rule->filter_forward->before, rule->filter_forward->before_len);
					else
						fputs("-", output);
					fputs("   ", output);
					if(rule->filter_forward->after)
						pattern_print(output, rule->filter_forward->after, attrs_chars);
					else
						fputs("-", output);
				}
				else
					utf16_output(output, rule->filter_forward->name, rule->filter_forward->name_len);
			}

			if(rule->filter_backward)
			{
				fputs("   ", output);
				if(!rule->filter_forward)
					fputs("--   ", output);
				if(!rule->filter_backward->name)
				{
					if(rule->filter_backward->before)
						pattern_print_reverse(output, rule->filter_backward->before, rule->filter_backward->before_len);
					else
						fputs("-", output);
					fputs("   ", output);
					if(rule->filter_backward->after)
						pattern_print(output, rule->filter_backward->after, attrs_chars);
					else
						fputs("-", output);
				}
				else
					utf16_output(output, rule->filter_backward->name, rule->filter_backward->name_len);
			}

			if(direction == FORWARD)
				rule = rule->chars_nxt;
			else
				rule = rule->dots_nxt;
		}
		fputs("\n", output);
	}
	fprintf(output, "most = %d\n", most);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x8(%rsp)
testq %rsi, %rsi
je 0x103dd
movl %edx, %ebp
movq %rdi, %rbx
xorl %eax, %eax
cmpl $0x1, %edx
setne %al
leaq 0x8(,%rax,8), %r12
leaq 0x2066(%rip), %r15      # 0x12197
leaq 0x205d(%rip), %r14      # 0x12195
xorl %r8d, %r8d
xorl %edx, %edx
cmpq $0x100, %r8             # imm = 0x100
je 0x103be
movq 0x8(%rsp), %rax
leaq (%rax,%r8,8), %r13
xorl %ecx, %ecx
movq %r13, %rax
movq (%rax), %rax
testq %rax, %rax
je 0x10167
incl %ecx
addq %r12, %rax
jmp 0x10158
cmpl %edx, %ecx
cmovgl %ecx, %edx
testl %ecx, %ecx
je 0x103b6
movl %edx, 0x4(%rsp)
movq %rbx, %rdi
leaq 0x2008(%rip), %rsi      # 0x1218a
movq %r8, 0x10(%rsp)
movl %r8d, %edx
xorl %eax, %eax
callq 0x1160
movq (%r13), %r13
testq %r13, %r13
je 0x1039e
leaq 0x1fef(%rip), %rdi      # 0x12194
movq %rbx, %rsi
callq 0x1100
cmpl $0x1, %ebp
jne 0x101cc
movl 0x74(%r13), %edx
leaq 0x18(%r13), %rsi
cmpl $0x1, %edx
jne 0x101e6
movzwl (%rsi), %esi
movq %rbx, %rdi
callq 0xed51
jmp 0x101ee
movl 0x78(%r13), %edx
leaq 0x46(%r13), %rsi
cmpl $0x1, %edx
jne 0x10203
movzwl (%rsi), %esi
movq %rbx, %rdi
callq 0xed51
jmp 0x1020b
movq %rbx, %rdi
callq 0xec74
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1100
movl 0x78(%r13), %edx
leaq 0x46(%r13), %rsi
jmp 0x1021e
movq %rbx, %rdi
callq 0xec74
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1100
movl 0x74(%r13), %edx
leaq 0x18(%r13), %rsi
cmpl $0x1, %edx
jne 0x10230
movzwl (%rsi), %esi
movq %rbx, %rdi
callq 0xed51
jmp 0x10238
movq %rbx, %rdi
callq 0xec74
movl (%r13), %edx
testl %edx, %edx
je 0x10251
movq %rbx, %rdi
leaq 0x1f4f(%rip), %rsi      # 0x12199
xorl %eax, %eax
callq 0x1160
cmpq $0x0, 0x80(%r13)
je 0x102e7
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1100
movq 0x80(%r13), %rax
movq 0x20(%rax), %rsi
testq %rsi, %rsi
je 0x10287
movl 0x28(%rax), %edx
movq %rbx, %rdi
callq 0xec74
jmp 0x102e7
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x1029d
movl 0x18(%rax), %edx
movq %rbx, %rdi
callq 0x103ec
jmp 0x102ac
leaq 0x1ee4(%rip), %rdi      # 0x12188
movq %rbx, %rsi
callq 0x1100
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1100
movq 0x80(%r13), %rax
movq 0x10(%rax), %rsi
testq %rsi, %rsi
je 0x102d8
movq %rbx, %rdi
leaq 0x8fdf(%rip), %rdx      # 0x192b0
callq 0xf5a4
jmp 0x102e7
leaq 0x1ea9(%rip), %rdi      # 0x12188
movq %rbx, %rsi
callq 0x1100
cmpq $0x0, 0x88(%r13)
je 0x10396
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1100
cmpq $0x0, 0x80(%r13)
jne 0x10319
leaq 0x1e92(%rip), %rdi      # 0x121a3
movq %rbx, %rsi
callq 0x1100
movq 0x88(%r13), %rax
movq 0x20(%rax), %rsi
testq %rsi, %rsi
je 0x10336
movl 0x28(%rax), %edx
movq %rbx, %rdi
callq 0xec74
jmp 0x10396
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x1034c
movl 0x18(%rax), %edx
movq %rbx, %rdi
callq 0x103ec
jmp 0x1035b
leaq 0x1e35(%rip), %rdi      # 0x12188
movq %rbx, %rsi
callq 0x1100
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1100
movq 0x88(%r13), %rax
movq 0x10(%rax), %rsi
testq %rsi, %rsi
je 0x10387
movq %rbx, %rdi
leaq 0x8f30(%rip), %rdx      # 0x192b0
callq 0xf5a4
jmp 0x10396
leaq 0x1dfa(%rip), %rdi      # 0x12188
movq %rbx, %rsi
callq 0x1100
addq %r12, %r13
jmp 0x10191
leaq 0x1bdb(%rip), %rdi      # 0x11f80
movq %rbx, %rsi
callq 0x1100
movl 0x4(%rsp), %edx
movq 0x10(%rsp), %r8
incq %r8
jmp 0x1013d
leaq 0x1da7(%rip), %rsi      # 0x1216c
movq %rbx, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1160
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq