// File: /workspace/github_c_makefile_star2_O1/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 0x11381
cmpl $0x1, %edx
jle 0x113af
movq %rsi, %r14
movzwl (%rsi), %eax
cmpl %edx, %eax
jle 0x113af
movq %rdi, %r12
leaq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0x2cc5(%rip), %rbp      # 0x13d74
movq %rdi, 0x10(%rsp)
movl %edx, %r13d
movzwl (%r14,%r13,2), %edx
leal -0x1(%rdx), %eax
cmpl $0xb, %eax
ja 0x11379
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
leaq 0x2ce8(%rip), %rdi      # 0x13dc1
movq %r12, %rsi
callq 0x1100
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x1106b
leaq 0x2cca(%rip), %rdi      # 0x13dc3
jmp 0x11366
leaq 0x2cd3(%rip), %rdi      # 0x13dd8
jmp 0x11366
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x1106b
leaq 0x2ca7(%rip), %rdi      # 0x13dc9
jmp 0x11366
cmpw $0x1, 0x6(%r14,%r13,2)
jne 0x11320
movq 0x6e9d(%rip), %rax      # 0x17fd8
movq (%rax), %rdi
movzwl 0x8(%r14,%r13,2), %esi
callq 0x10b1e
jmp 0x1136e
leaq 0x2c70(%rip), %rdi      # 0x13dc5
movq %r12, %rsi
callq 0x1100
movzwl 0x6(%r14,%r13,2), %edx
jmp 0x111d1
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x1106b
leaq 0x2c4a(%rip), %rdi      # 0x13dc7
jmp 0x11366
leaq 0x2c44(%rip), %rdi      # 0x13dcd
jmp 0x11366
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x1106b
leaq 0x2c38(%rip), %rdi      # 0x13dde
jmp 0x11366
movzwl 0x6(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x1106b
leaq 0x2c08(%rip), %rdi      # 0x13dcb
movq %r12, %rsi
callq 0x1100
movzwl 0x8(%r14,%r13,2), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x1106b
jmp 0x1136e
leaq 0x2beb(%rip), %rdi      # 0x13dd3
movq %r12, %rsi
callq 0x1100
cmpw $0x0, 0x6(%r14,%r13,2)
je 0x11220
movq 0x8(%rsp), %rax
leaq (%rax,%r13,2), %rbx
xorl %r15d, %r15d
movzwl (%rbx,%r15,2), %edi
incq %r15
movq %r12, %rsi
callq 0x1130
movzwl 0x6(%r14,%r13,2), %eax
cmpq %rax, %r15
jb 0x11205
leaq 0x2baf(%rip), %rdi      # 0x13dd6
jmp 0x11366
leaq 0x2b9c(%rip), %rdi      # 0x13dcf
movq %r12, %rsi
callq 0x1100
movzwl 0x6(%r14,%r13,2), %ebx
movzwl 0x8(%r14,%r13,2), %r12d
xorl %ecx, %ecx
xorl %ebp, %ebp
movl $0x1, %eax
shlq %cl, %rax
andl %ebx, %eax
cmpl $0x1, %eax
sbbl $-0x1, %ebp
incq %rcx
cmpq $0x10, %rcx
jne 0x1124b
xorl %ecx, %ecx
movl $0x1, %eax
shlq %cl, %rax
andl %r12d, %eax
cmpl $0x1, %eax
sbbl $-0x1, %ebp
incq %rcx
cmpq $0x10, %rcx
jne 0x11266
cmpl $0x2, %ebp
jb 0x1128f
movl $0x5b, %edi
callq 0x1050
xorl %r15d, %r15d
movl $0x1, %eax
movl %r15d, %ecx
shlq %cl, %rax
testl %ebx, %eax
je 0x112bf
movq 0x6d30(%rip), %rax      # 0x17fd8
movq (%rax), %rdi
leaq 0x6e9e(%rip), %rax      # 0x18150
movsbl (%r15,%rax), %eax
movzwl %ax, %esi
callq 0x10b1e
incq %r15
cmpq $0x10, %r15
jne 0x11292
xorl %r15d, %r15d
movl $0x1, %eax
movl %r15d, %ecx
shlq %cl, %rax
testl %r12d, %eax
je 0x112fa
movq 0x6cf6(%rip), %rax      # 0x17fd8
movq (%rax), %rdi
leaq 0x6e64(%rip), %rax      # 0x18150
movsbl 0x10(%r15,%rax), %eax
movzwl %ax, %esi
callq 0x10b1e
incq %r15
cmpq $0x10, %r15
jne 0x112cb
cmpl $0x2, %ebp
movq 0x10(%rsp), %r12
leaq 0x2a62(%rip), %rbp      # 0x13d74
jb 0x1136e
movl $0x5d, %edi
callq 0x1050
jmp 0x1136e
leaq 0x2aaa(%rip), %rdi      # 0x13dd1
movq %r12, %rsi
callq 0x1100
cmpw $0x0, 0x6(%r14,%r13,2)
je 0x1135f
movq 0x8(%rsp), %rax
leaq (%rax,%r13,2), %rbx
xorl %r15d, %r15d
movzwl (%rbx,%r15,2), %esi
incq %r15
movq %r12, %rdi
callq 0x10b1e
movzwl 0x6(%r14,%r13,2), %eax
cmpq %rax, %r15
jb 0x11344
leaq 0x2dc4(%rip), %rdi      # 0x1412a
movq %r12, %rsi
callq 0x1100
movzwl 0x4(%r14,%r13,2), %edx
jmp 0x110b4
cmpl $0xffff, %edx           # imm = 0xFFFF
jne 0x11390
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2a43(%rip), %rsi      # 0x13dda
movq %r12, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1150
callq 0x1060