// File: /workspace/github_c_makefile_star2_O0/mmcco[P]sljit/regex_src/regexJIT.c
// Function: parse
static int parse(const regex_char_t *regex_string, int length, struct compiler_common *compiler_common)
{
	/* Depth of bracketed expressions. */
	int depth = 0;
	/* Have we already found a term? '1' if not yet. */
	int begin = 1;
	/* Cache stack pointer. */
	struct stack* stack = &compiler_common->stack;
	int tmp;

	/* Type_begin and type_end. */
	compiler_common->dfa_size = 2;
	stack_init(stack);
	if (stack_push(stack, type_begin, 0))
		return REGEX_MEMORY_ERROR;

	if (length > 0 && *regex_string == '^') {
		compiler_common->flags |= REGEX_MATCH_BEGIN;
		length--;
		regex_string++;
	}

	if ((compiler_common->flags & (REGEX_MATCH_BEGIN | REGEX_NEWLINE)) == (REGEX_MATCH_BEGIN | REGEX_NEWLINE)) {
		/* Replace REGEX_MATCH_BEGIN flag to REGEX_FAKE_MATCH_BEGIN */
		compiler_common->flags &= ~REGEX_MATCH_BEGIN;
		compiler_common->flags |= REGEX_FAKE_MATCH_BEGIN;
		/* and append a new-line search. */
		if (stack_push(stack, type_newline, 0))
			return REGEX_MEMORY_ERROR;
		compiler_common->dfa_size++;
		/* Begin intentionally kept as 1. */
	}

	while (length > 0) {
		switch (*regex_string) {
		case '\\' :
			length--;
			regex_string++;
			if (length == 0)
				return REGEX_INVALID_REGEX;
			if (stack_push(stack, type_char, *regex_string))
				return REGEX_MEMORY_ERROR;
			begin = 0;
			compiler_common->dfa_size++;
			break;

		case '.' :
			if (stack_push(stack, type_rng_start, 1))
				return REGEX_MEMORY_ERROR;
			if (compiler_common->flags & REGEX_NEWLINE) {
				if (stack_push(stack, type_rng_char, '\n'))
					return REGEX_MEMORY_ERROR;
				if (stack_push(stack, type_rng_char, '\r'))
					return REGEX_MEMORY_ERROR;
				compiler_common->dfa_size += 2;
			}
			if (stack_push(stack, type_rng_end, 1))
				return REGEX_MEMORY_ERROR;
			begin = 0;
			compiler_common->dfa_size += 2;
			break;

		case '(' :
			depth++;
			if (stack_push(stack, type_open_br, 0))
				return REGEX_MEMORY_ERROR;
			begin = 1;
			break;

		case ')' :
			if (depth == 0)
				return REGEX_INVALID_REGEX;
			depth--;
			if (stack_push(stack, type_close_br, 0))
				return REGEX_MEMORY_ERROR;
			begin = 0;
			break;

		case '|' :
			if (stack_push(stack, type_select, 0))
				return REGEX_MEMORY_ERROR;
			begin = 1;
			compiler_common->dfa_size += 2;
			break;

		case '*' :
			if (begin)
				return REGEX_INVALID_REGEX;
			if (stack_push(stack, type_asterisk, 0))
				return REGEX_MEMORY_ERROR;
			compiler_common->dfa_size += 2;
			break;

		case '?' :
		case '+' :
			if (begin)
				return REGEX_INVALID_REGEX;
			if (stack_push(stack, (*regex_string == '+') ? type_plus_sign : type_qestion_mark, 0))
				return REGEX_MEMORY_ERROR;
			compiler_common->dfa_size++;
			break;

		case '{' :
			tmp = parse_iterator(regex_string, length, stack, &compiler_common->dfa_size, begin);

			if (tmp >= 0) {
				length -= tmp;
				regex_string += tmp;
			}
			else if (tmp == -1)
				return REGEX_MEMORY_ERROR;
			else {
				/* Not a valid range expression. */
				SLJIT_ASSERT(tmp == -2);
				if (stack_push(stack, type_char, '{'))
					return REGEX_MEMORY_ERROR;
				compiler_common->dfa_size++;
			}
			break;

		case '[' :
			tmp = parse_char_range(regex_string, length, compiler_common);
			if (tmp >= 0) {
				length -= tmp;
				regex_string += tmp;
			}
			else if (tmp == -1)
				return REGEX_MEMORY_ERROR;
			else {
				SLJIT_ASSERT(tmp == -2);
				return REGEX_INVALID_REGEX;
			}
			begin = 0;
			break;

		default:
			if (length == 1 && *regex_string == '$') {
				compiler_common->flags |= REGEX_MATCH_END;
				break;
			}
			if (stack_push(stack, type_char, *regex_string))
				return REGEX_MEMORY_ERROR;
			begin = 0;
			compiler_common->dfa_size++;
			break;
		}
		length--;
		regex_string++;
	}

	if (depth != 0)
		return REGEX_INVALID_REGEX;

	if ((compiler_common->flags & (REGEX_MATCH_END | REGEX_NEWLINE)) == (REGEX_MATCH_END | REGEX_NEWLINE)) {
		/* Replace REGEX_MATCH_END flag to REGEX_FAKE_MATCH_END */
		compiler_common->flags &= ~REGEX_MATCH_END;
		compiler_common->flags |= REGEX_FAKE_MATCH_END;
		/* and append a new-line search. */
		if (stack_push(stack, type_newline, 1))
			return REGEX_MEMORY_ERROR;
		compiler_common->dfa_size++;
		/* Begin intentionally kept as 1. */
	}

	if (stack_push(stack, type_end, 0))
		return REGEX_MEMORY_ERROR;

	return REGEX_NO_ERROR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x1, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq $0x2, 0x38(%rax)
movq -0x30(%rbp), %rdi
callq 0x5930
movq -0x30(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x8980
cmpl $0x0, %eax
je 0x48fc
movl $0x1, -0x4(%rbp)
jmp 0x4e95
cmpl $0x0, -0x14(%rbp)
jle 0x4930
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x4930
movq -0x20(%rbp), %rax
movl 0x30(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x30(%rax)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x5, %eax
cmpl $0x5, %eax
jne 0x498d
movq -0x20(%rbp), %rax
movl 0x30(%rax), %ecx
andl $-0x2, %ecx
movl %ecx, 0x30(%rax)
movq -0x20(%rbp), %rax
movl 0x30(%rax), %ecx
orl $0x200, %ecx            # imm = 0x200
movl %ecx, 0x30(%rax)
movq -0x30(%rbp), %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x497d
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x38(%rax)
jmp 0x498f
cmpl $0x0, -0x14(%rbp)
jle 0x4e01
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
addl $-0x28, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x54, %eax
ja 0x4d89
movq -0x40(%rbp), %rax
leaq 0x1ac33(%rip), %rcx     # 0x1f5f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x49ed
movl $0x2, -0x4(%rbp)
jmp 0x4e95
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movsbl (%rax), %edx
movl $0x2, %esi
callq 0x8980
cmpl $0x0, %eax
je 0x4a13
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movl $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x38(%rax)
jmp 0x4de7
movq -0x30(%rbp), %rdi
movl $0x5, %esi
movl $0x1, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4a53
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x4aba
movq -0x30(%rbp), %rdi
movl $0x7, %esi
movl $0xa, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4a86
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movq -0x30(%rbp), %rdi
movl $0x7, %esi
movl $0xd, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4aaa
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x2, %rcx
movq %rcx, 0x38(%rax)
movq -0x30(%rbp), %rdi
movl $0x6, %esi
movl $0x1, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4ade
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movl $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x2, %rcx
movq %rcx, 0x38(%rax)
jmp 0x4de7
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4b24
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movl $0x1, -0x28(%rbp)
jmp 0x4de7
cmpl $0x0, -0x24(%rbp)
jne 0x4b42
movl $0x2, -0x4(%rbp)
jmp 0x4e95
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rdi
movl $0xd, %esi
xorl %edx, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4b6c
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movl $0x0, -0x28(%rbp)
jmp 0x4de7
movq -0x30(%rbp), %rdi
movl $0xe, %esi
xorl %edx, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4b99
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movl $0x1, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x2, %rcx
movq %rcx, 0x38(%rax)
jmp 0x4de7
cmpl $0x0, -0x28(%rbp)
je 0x4bc7
movl $0x2, -0x4(%rbp)
jmp 0x4e95
movq -0x30(%rbp), %rdi
movl $0xf, %esi
xorl %edx, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4be8
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x2, %rcx
movq %rcx, 0x38(%rax)
jmp 0x4de7
cmpl $0x0, -0x28(%rbp)
je 0x4c0f
movl $0x2, -0x4(%rbp)
jmp 0x4e95
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movl $0x11, %esi
movl $0x10, %eax
cmpl $0x2b, %ecx
cmovel %eax, %esi
xorl %edx, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4c42
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x38(%rax)
jmp 0x4de7
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
addq $0x38, %rcx
movl -0x28(%rbp), %r8d
callq 0x8b30
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x4c9a
movl -0x34(%rbp), %ecx
movl -0x14(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x4d04
cmpl $-0x1, -0x34(%rbp)
jne 0x4cac
movl $0x1, -0x4(%rbp)
jmp 0x4e95
jmp 0x4cae
cmpl $-0x2, -0x34(%rbp)
je 0x4ccc
leaq 0x1ab55(%rip), %rdi     # 0x1f810
movl $0x36e, %esi            # imm = 0x36E
movb $0x0, %al
callq 0x2060
callq 0x2040
jmp 0x4cce
movq -0x30(%rbp), %rdi
movl $0x2, %esi
movl $0x7b, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4cf2
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x38(%rax)
jmp 0x4d04
jmp 0x4de7
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x8f40
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x4d40
movl -0x34(%rbp), %ecx
movl -0x14(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x4d80
cmpl $-0x1, -0x34(%rbp)
jne 0x4d52
movl $0x1, -0x4(%rbp)
jmp 0x4e95
jmp 0x4d54
cmpl $-0x2, -0x34(%rbp)
je 0x4d72
leaq 0x1aaaf(%rip), %rdi     # 0x1f810
movl $0x37e, %esi            # imm = 0x37E
movb $0x0, %al
callq 0x2060
callq 0x2040
jmp 0x4d74
movl $0x2, -0x4(%rbp)
jmp 0x4e95
movl $0x0, -0x28(%rbp)
jmp 0x4de7
cmpl $0x1, -0x14(%rbp)
jne 0x4daa
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x4daa
movq -0x20(%rbp), %rax
movl 0x30(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x30(%rax)
jmp 0x4de7
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movsbl (%rax), %edx
movl $0x2, %esi
callq 0x8980
cmpl $0x0, %eax
je 0x4dd0
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movl $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x38(%rax)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x498f
cmpl $0x0, -0x24(%rbp)
je 0x4e13
movl $0x2, -0x4(%rbp)
jmp 0x4e95
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x6, %eax
cmpl $0x6, %eax
jne 0x4e70
movq -0x20(%rbp), %rax
movl 0x30(%rax), %ecx
andl $-0x3, %ecx
movl %ecx, 0x30(%rax)
movq -0x20(%rbp), %rax
movl 0x30(%rax), %ecx
orl $0x400, %ecx            # imm = 0x400
movl %ecx, 0x30(%rax)
movq -0x30(%rbp), %rdi
movl $0x3, %esi
movl $0x1, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4e60
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x38(%rax)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x8980
cmpl $0x0, %eax
je 0x4e8e
movl $0x1, -0x4(%rbp)
jmp 0x4e95
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop