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

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

		if(   EXPR_TYPE(expr_at) == PTN_ZERO_MORE
		   || EXPR_TYPE(expr_at) == PTN_ONE_MORE
		   || EXPR_TYPE(expr_at) == PTN_OPTIONAL)
		{
			if(*expr_crs + 6 >= expr_len)
				return 0;

			/*   get previous expressions, there must
			     be at least something and a PTN_START   */
			expr_sub = EXPR_PRV(expr_at);
			if(EXPR_TYPE(expr_sub) == PTN_START)
				return 0;
			expr_prv = EXPR_PRV(expr_sub);

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

			/*   create end expression   */
			expr_end = *expr_crs;
			EXPR_TYPE(expr_end) = PTN_END;
			EXPR_PRV(expr_end) = expr_sub;
			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_prv) = expr_at;
			EXPR_PRV(expr_at) = expr_prv;

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

		expr_at = EXPR_NXT(expr_at);
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %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 0xc535
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x2, %eax
je 0xc31e
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x3, %eax
jne 0xc352
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 0xc2c0
cmpl $0x0, %eax
jne 0xc350
movl $0x0, -0x4(%rbp)
jmp 0xc53c
jmp 0xc352
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x5, %eax
je 0xc398
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x4, %eax
je 0xc398
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x6, %eax
jne 0xc51c
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
addl $0x6, %eax
cmpl -0x18(%rbp), %eax
jl 0xc3b3
movl $0x0, -0x4(%rbp)
jmp 0xc53c
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x1, %eax
jne 0xc3e9
movl $0x0, -0x4(%rbp)
jmp 0xc53c
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movw $0x1, (%rax,%rcx,2)
movq -0x10(%rbp), %rax
movl -0x24(%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 -0x24(%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, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x0, %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 $0x1, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x14(%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)
movl -0x24(%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 -0x2c(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x2c(%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 -0x24(%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 -0x28(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x30(%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, -0x14(%rbp)
jmp 0xc2d6
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)