// File: /workspace/github_c_makefile_star2_O0/MikeGray-APH[P]LibLouisAPH/source/pattern.c
// Function: pattern_compile_3
static int pattern_compile_3(unichar *expr_data, int expr_at, const int expr_len, unichar *expr_crs)
{
	int expr_mrk, expr_start, expr_end, expr_sub_start, expr_sub_end;

	while(EXPR_TYPE(expr_at) != PTN_END)
	{
		if(   EXPR_TYPE(expr_at) == PTN_GROUP
		   || EXPR_TYPE(expr_at) == PTN_NOT
		   || EXPR_TYPE(expr_at) == PTN_OPTIONAL
		   || EXPR_TYPE(expr_at) == PTN_ZERO_MORE
		   || EXPR_TYPE(expr_at) == PTN_ONE_MORE)
		{
			if(!pattern_compile_3(expr_data, EXPR_DATA_0(expr_at), expr_len, expr_crs))
				return 0;
		}

		if(EXPR_TYPE(expr_at) == PTN_ALTERNATE)
		{
			if(*expr_crs + 12 >= expr_len)
				return 0;

			/*   get previous start expression,
			     can include alternate expressions   */
			expr_mrk = EXPR_PRV(expr_at);
			if(EXPR_TYPE(expr_mrk) == PTN_START)
				return 0;
			expr_sub_end = expr_mrk;
			while(EXPR_TYPE(expr_mrk) != PTN_START)
				expr_mrk = EXPR_PRV(expr_mrk);
			expr_sub_start = EXPR_NXT(expr_mrk);

			/*   create first start expression   */
			expr_start = *expr_crs;
			EXPR_TYPE(expr_start) = PTN_START;
			EXPR_PRV(expr_start) = PTN_END;
			EXPR_NXT(expr_start) = expr_sub_start;
			*expr_crs += 3;

			/*   create first end expression   */
			expr_end = *expr_crs;
			EXPR_TYPE(expr_end) = PTN_END;
			EXPR_PRV(expr_end) = expr_sub_end;
			EXPR_NXT(expr_end) = expr_at;
			*expr_crs += 3;

			/*   relink previous expression before sub expression   */
			EXPR_DATA_0(expr_at) = expr_start;
			EXPR_NXT(expr_mrk) = expr_at;
			EXPR_PRV(expr_at) = expr_mrk;

			/*   relink sub expression to start and end   */
			EXPR_PRV(expr_sub_start) = expr_start;
			EXPR_NXT(expr_sub_end) = expr_end;

			/*   get following PTN_END or PTN_ALTERNATE expression   */
			expr_mrk = EXPR_NXT(expr_at);
			if(EXPR_TYPE(expr_mrk) == PTN_END || EXPR_TYPE(expr_mrk) == PTN_ALTERNATE)
				return 0;
			expr_sub_start = expr_mrk;
			while(EXPR_TYPE(expr_mrk) != PTN_END && EXPR_TYPE(expr_mrk) != PTN_ALTERNATE)
				expr_mrk = EXPR_NXT(expr_mrk);
			expr_sub_end = EXPR_PRV(expr_mrk);

			/*   create first start expression   */
			expr_start = *expr_crs;
			EXPR_TYPE(expr_start) = PTN_START;
			EXPR_PRV(expr_start) = PTN_END;
			EXPR_NXT(expr_start) = expr_sub_start;
			*expr_crs += 3;

			/*   create first end expression   */
			expr_end = *expr_crs;
			EXPR_TYPE(expr_end) = PTN_END;
			EXPR_PRV(expr_end) = expr_sub_end;
			EXPR_NXT(expr_end) = expr_at;
			*expr_crs += 3;

			/*   relink following expression before sub expression   */
			EXPR_DATA_1(expr_at) = expr_start;
			EXPR_PRV(expr_mrk) = expr_at;
			EXPR_NXT(expr_at) = expr_mrk;

			/*   relink sub expression to start and end   */
			EXPR_PRV(expr_sub_start) = expr_start;
			EXPR_NXT(expr_sub_end) = expr_end;

			/*   check expressions were after alternate and got moved into
			     a sub expression, previous expressions already checked   */
			if(!pattern_compile_3(expr_data, EXPR_DATA_1(expr_at), expr_len, expr_crs))
				return 0;
		}

		expr_at = EXPR_NXT(expr_at);
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0xca1c
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x2, %eax
je 0xc5f0
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x3, %eax
je 0xc5f0
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x6, %eax
je 0xc5f0
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x5, %eax
je 0xc5f0
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x4, %eax
jne 0xc624
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %esi
movl -0x18(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0xc550
cmpl $0x0, %eax
jne 0xc622
movl $0x0, -0x4(%rbp)
jmp 0xca23
jmp 0xc624
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x7, %eax
jne 0xca03
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
addl $0xc, %eax
cmpl -0x18(%rbp), %eax
jl 0xc659
movl $0x0, -0x4(%rbp)
jmp 0xca23
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x1, %eax
jne 0xc68f
movl $0x0, -0x4(%rbp)
jmp 0xca23
movl -0x24(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x1, %eax
je 0xc6c1
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x24(%rbp)
jmp 0xc695
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movw $0x1, (%rax,%rcx,2)
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw $0xffff, (%rax,%rcx,2)  # imm = 0xFFFF
movl -0x30(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movq -0x20(%rbp), %rax
movzwl (%rax), %ecx
addl $0x3, %ecx
movw %cx, (%rax)
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movw $0xffff, (%rax,%rcx,2)  # imm = 0xFFFF
movl -0x34(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movq -0x20(%rbp), %rax
movzwl (%rax), %ecx
addl $0x3, %ecx
movw %cx, (%rax)
movl -0x28(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x24(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x28(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x2c(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0xc836
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x7, %eax
jne 0xc842
movl $0x0, -0x4(%rbp)
jmp 0xca23
movl -0x24(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
xorl %eax, %eax
cmpl $0xffff, %ecx           # imm = 0xFFFF
movb %al, -0x35(%rbp)
je 0xc880
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x7, %eax
setne %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0xc889
jmp 0xc89f
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x24(%rbp)
jmp 0xc848
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movw $0x1, (%rax,%rcx,2)
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw $0xffff, (%rax,%rcx,2)  # imm = 0xFFFF
movl -0x30(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movq -0x20(%rbp), %rax
movzwl (%rax), %ecx
addl $0x3, %ecx
movw %cx, (%rax)
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movw $0xffff, (%rax,%rcx,2)  # imm = 0xFFFF
movl -0x34(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movq -0x20(%rbp), %rax
movzwl (%rax), %ecx
addl $0x3, %ecx
movw %cx, (%rax)
movl -0x28(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x24(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x28(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x2c(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %esi
movl -0x18(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0xc550
cmpl $0x0, %eax
jne 0xca01
movl $0x0, -0x4(%rbp)
jmp 0xca23
jmp 0xca03
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x14(%rbp)
jmp 0xc566
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)