// File: /workspace/github_c_makefile_star2_O2/MikeGray-APH[P]LibLouisAPH/source/outputs/pattern-output.c
// Function: pattern_print_expression
void pattern_print_expression(FILE *output, const unichar *expr_data, int expr_crs)
{
	int i;

	if(expr_crs == PTN_END)
		return;

	ASSERT(expr_crs > 1)
	ASSERT(expr_crs < expr_data[0])

	while(EXPR_TYPE(expr_crs) != PTN_END)
	{
		switch(EXPR_TYPE(expr_crs))
		{
		case PTN_START:  break;

		case PTN_GROUP:

			fputs("(", output);
			pattern_print_expression(output, expr_data, EXPR_DATA_0(expr_crs));
			fputs(")", output);
			break;

		case PTN_NOT:

			fputs("!", output);
			pattern_print_expression(output, expr_data, EXPR_DATA_0(expr_crs));
			break;

		case PTN_ONE_MORE:

			pattern_print_expression(output, expr_data, EXPR_DATA_0(expr_crs));
			fputs("+", output);
			break;

		case PTN_ZERO_MORE:

			pattern_print_expression(output, expr_data, EXPR_DATA_0(expr_crs));
			fputs("*", output);
			break;

		case PTN_OPTIONAL:

			pattern_print_expression(output, expr_data, EXPR_DATA_0(expr_crs));
			fputs("?", output);
			break;

		case PTN_ALTERNATE:

			pattern_print_expression(output, expr_data, EXPR_DATA_0(expr_crs));
			fputs("|", output);
			pattern_print_expression(output, expr_data, EXPR_DATA_1(expr_crs));
			break;

		case PTN_ANY:

			fputs(".", output);
			break;

		case PTN_ATTRIBUTES:

			fputs("%", output);
			attrs_output_brackets(EXPR_DATA_0(expr_crs), EXPR_DATA_1(expr_crs));
			break;

		case PTN_CHARS:

			if(EXPR_DATA_0(expr_crs) == 1)
				utf16_output_char_escape(stdout, EXPR_DATA_1(expr_crs));
			else
			{
				fputs("[", output);
				for(i = 0; i < EXPR_DATA_0(expr_crs); i++)
					utf16_output_char_escape(output, EXPR_CONST_DATA(expr_crs)[i + 1]);
				fputs("]", output);
			}
			break;

		case PTN_SUBPATTERN:

			fputs("@{", output);
			for(i = 0; i < EXPR_DATA_0(expr_crs); i++)
				fprintf(output, "%c", EXPR_CONST_DATA(expr_crs)[i + 1]);
			fputs("}", output);
			break;

		case PTN_END_OF_INPUT:

			fputs("^", output);
			break;

		default:  fprintf(output, "0x%x?", EXPR_TYPE(expr_crs));  return;
		}

		expr_crs = EXPR_NXT(expr_crs);
	}

	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0xf571
cmpl $0x1, %edx
jle 0xf59f
movq %rsi, %r14
movzwl (%rsi), %eax
cmpl %edx, %eax
jbe 0xf59f
movq %rdi, %r12
leaq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0x2b13(%rip), %rbp      # 0x11db4
movq %rdi, 0x10(%rsp)
movl %edx, %r13d
movzwl (%r14,%r13,2), %edx
leal -0x1(%rdx), %eax
cmpl $0xb, %eax
ja 0xf569
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
leaq 0x2b36(%rip), %rdi      # 0x11e01
movq %r12, %rsi
callq 0x1100
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0xf25d
leaq 0x2b18(%rip), %rdi      # 0x11e03
jmp 0xf556
leaq 0x2b21(%rip), %rdi      # 0x11e18
jmp 0xf556
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0xf25d
leaq 0x2af5(%rip), %rdi      # 0x11e09
jmp 0xf556
cmpw $0x1, 0x6(%r14,%r13,2)
jne 0xf517
movq 0x7cab(%rip), %rax      # 0x16fd8
movq (%rax), %rdi
movzwl 0x8(%r14,%r13,2), %esi
callq 0xed51
jmp 0xf55e
leaq 0x2abe(%rip), %rdi      # 0x11e05
movq %r12, %rsi
callq 0x1100
movzwl 0x6(%r14,%r13,2), %edx
jmp 0xf3c3
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0xf25d
leaq 0x2a98(%rip), %rdi      # 0x11e07
jmp 0xf556
leaq 0x2a92(%rip), %rdi      # 0x11e0d
jmp 0xf556
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0xf25d
leaq 0x2a86(%rip), %rdi      # 0x11e1e
jmp 0xf556
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0xf25d
leaq 0x2a56(%rip), %rdi      # 0x11e0b
movq %r12, %rsi
callq 0x1100
movzwl 0x8(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0xf25d
jmp 0xf55e
leaq 0x2a39(%rip), %rdi      # 0x11e13
movq %r12, %rsi
callq 0x1100
movq 0x8(%rsp), %rax
leaq (%rax,%r13,2), %rbx
xorl %r15d, %r15d
movzwl 0x6(%r14,%r13,2), %eax
cmpq %rax, %r15
jae 0xf40b
movzwl (%rbx,%r15,2), %edi
incq %r15
movq %r12, %rsi
callq 0x1130
jmp 0xf3ee
leaq 0x2a04(%rip), %rdi      # 0x11e16
jmp 0xf556
leaq 0x29f1(%rip), %rdi      # 0x11e0f
movq %r12, %rsi
callq 0x1100
pushq $0x1
popq %rsi
movzwl 0x6(%r14,%r13,2), %ebp
movzwl 0x8(%r14,%r13,2), %r12d
xorl %ecx, %ecx
xorl %ebx, %ebx
cmpq $0x10, %rcx
je 0xf454
movq %rsi, %rax
shlq %cl, %rax
movl %ebp, %edx
andl %eax, %edx
cmpl $0x1, %edx
sbbl $-0x1, %ebx
incq %rcx
jmp 0xf439
xorl %ecx, %ecx
cmpq $0x10, %rcx
je 0xf472
movq %rsi, %rax
shlq %cl, %rax
movl %r12d, %edx
andl %eax, %edx
cmpl $0x1, %edx
sbbl $-0x1, %ebx
incq %rcx
jmp 0xf456
cmpl $0x2, %ebx
jb 0xf482
pushq $0x5b
popq %rdi
callq 0x1050
pushq $0x1
popq %rsi
xorl %r15d, %r15d
cmpq $0x10, %r15
je 0xf4be
movq %rsi, %rax
movl %r15d, %ecx
shlq %cl, %rax
testl %ebp, %eax
je 0xf4b9
movq 0x7b39(%rip), %rax      # 0x16fd8
movq (%rax), %rdi
leaq 0x7cb7(%rip), %rax      # 0x17160
movsbl (%r15,%rax), %eax
movzwl %ax, %esi
callq 0xed51
pushq $0x1
popq %rsi
incq %r15
jmp 0xf485
xorl %r15d, %r15d
leaq 0x28ec(%rip), %rbp      # 0x11db4
cmpq $0x10, %r15
je 0xf503
movq %rsi, %rax
movl %r15d, %ecx
shlq %cl, %rax
testl %r12d, %eax
je 0xf4fe
movq 0x7af5(%rip), %rax      # 0x16fd8
movq (%rax), %rdi
leaq 0x7c73(%rip), %rax      # 0x17160
movsbl 0x10(%r15,%rax), %eax
movzwl %ax, %esi
callq 0xed51
pushq $0x1
popq %rsi
incq %r15
jmp 0xf4c8
cmpl $0x2, %ebx
movq 0x10(%rsp), %r12
jb 0xf55e
pushq $0x5d
popq %rdi
callq 0x1050
jmp 0xf55e
leaq 0x28f3(%rip), %rdi      # 0x11e11
movq %r12, %rsi
callq 0x1100
movq 0x8(%rsp), %rax
leaq (%rax,%r13,2), %rbx
xorl %r15d, %r15d
movzwl 0x6(%r14,%r13,2), %eax
cmpq %rax, %r15
jae 0xf54f
movzwl (%rbx,%r15,2), %esi
incq %r15
movq %r12, %rdi
callq 0xed51
jmp 0xf532
leaq 0x2c14(%rip), %rdi      # 0x1216a
movq %r12, %rsi
callq 0x1100
movzwl 0x4(%r14,%r13,2), %edx
jmp 0xf2a6
cmpl $0xffff, %edx           # imm = 0xFFFF
jne 0xf580
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2893(%rip), %rsi      # 0x11e1a
movq %r12, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1160
callq 0x1060