// File: /workspace/github_c_makefile_star2_O1/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:
testq %rsi, %rsi
je 0x121f2
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
xorl %eax, %eax
cmpl $0x1, %edx
setne %al
leaq 0x8(,%rax,8), %r13
leaq 0x2209(%rip), %r14      # 0x14155
xorl %r12d, %r12d
xorl %edx, %edx
movq %rsi, 0x10(%rsp)
movq (%r15,%r12,8), %rax
movl $0x0, %ecx
testq %rax, %rax
je 0x11f71
xorl %ecx, %ecx
incl %ecx
movq (%rax,%r13), %rax
testq %rax, %rax
jne 0x11f66
cmpl %edx, %ecx
cmovgl %ecx, %edx
testl %ecx, %ecx
je 0x121c3
movl %edx, 0xc(%rsp)
movq %rbx, %rdi
leaq 0x21be(%rip), %rsi      # 0x1414a
movl %r12d, %edx
xorl %eax, %eax
callq 0x1150
movq (%r15,%r12,8), %r15
testq %r15, %r15
je 0x121ab
leaq 0x21aa(%rip), %rdi      # 0x14154
movq %rbx, %rsi
callq 0x1100
cmpl $0x1, %ebp
jne 0x11fd1
movl 0x74(%r15), %edx
leaq 0x18(%r15), %rsi
cmpl $0x1, %edx
jne 0x11feb
movzwl (%rsi), %esi
movq %rbx, %rdi
callq 0x10b1e
jmp 0x11ff3
movl 0x78(%r15), %edx
leaq 0x46(%r15), %rsi
cmpl $0x1, %edx
jne 0x1200c
movzwl (%rsi), %esi
movq %rbx, %rdi
callq 0x10b1e
jmp 0x12014
movq %rbx, %rdi
callq 0x10a3c
leaq 0x215d(%rip), %rdi      # 0x14157
movq %rbx, %rsi
callq 0x1100
movl 0x78(%r15), %edx
leaq 0x46(%r15), %rsi
jmp 0x1202b
movq %rbx, %rdi
callq 0x10a3c
leaq 0x213c(%rip), %rdi      # 0x14157
movq %rbx, %rsi
callq 0x1100
movl 0x74(%r15), %edx
leaq 0x18(%r15), %rsi
cmpl $0x1, %edx
jne 0x1203d
movzwl (%rsi), %esi
movq %rbx, %rdi
callq 0x10b1e
jmp 0x12045
movq %rbx, %rdi
callq 0x10a3c
movl (%r15), %edx
testl %edx, %edx
je 0x1205d
movq %rbx, %rdi
leaq 0x2103(%rip), %rsi      # 0x14159
xorl %eax, %eax
callq 0x1150
cmpq $0x0, 0x80(%r15)
je 0x120f3
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1100
movq 0x80(%r15), %rax
movq 0x20(%rax), %rsi
testq %rsi, %rsi
je 0x12093
movl 0x28(%rax), %edx
movq %rbx, %rdi
callq 0x10a3c
jmp 0x120f3
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x120a9
movl 0x18(%rax), %edx
movq %rbx, %rdi
callq 0x121f3
jmp 0x120b8
leaq 0x2098(%rip), %rdi      # 0x14148
movq %rbx, %rsi
callq 0x1100
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1100
movq 0x80(%r15), %rax
movq 0x10(%rax), %rsi
testq %rsi, %rsi
je 0x120e4
movq %rbx, %rdi
leaq 0x81c3(%rip), %rdx      # 0x1a2a0
callq 0x113b4
jmp 0x120f3
leaq 0x205d(%rip), %rdi      # 0x14148
movq %rbx, %rsi
callq 0x1100
cmpq $0x0, 0x88(%r15)
je 0x121a2
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1100
cmpq $0x0, 0x80(%r15)
jne 0x12125
leaq 0x2046(%rip), %rdi      # 0x14163
movq %rbx, %rsi
callq 0x1100
movq 0x88(%r15), %rax
movq 0x20(%rax), %rsi
testq %rsi, %rsi
je 0x12142
movl 0x28(%rax), %edx
movq %rbx, %rdi
callq 0x10a3c
jmp 0x121a2
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x12158
movl 0x18(%rax), %edx
movq %rbx, %rdi
callq 0x121f3
jmp 0x12167
leaq 0x1fe9(%rip), %rdi      # 0x14148
movq %rbx, %rsi
callq 0x1100
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1100
movq 0x88(%r15), %rax
movq 0x10(%rax), %rsi
testq %rsi, %rsi
je 0x12193
movq %rbx, %rdi
leaq 0x8114(%rip), %rdx      # 0x1a2a0
callq 0x113b4
jmp 0x121a2
leaq 0x1fae(%rip), %rdi      # 0x14148
movq %rbx, %rsi
callq 0x1100
movq (%r15,%r13), %r15
jmp 0x11f9a
leaq 0x1d8e(%rip), %rdi      # 0x13f40
movq %rbx, %rsi
callq 0x1100
movq 0x10(%rsp), %r15
movl 0xc(%rsp), %edx
incq %r12
cmpq $0x100, %r12            # imm = 0x100
jne 0x11f56
leaq 0x1f52(%rip), %rsi      # 0x1412c
movq %rbx, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1150
retq