// File: /workspace/github_c_makefile_star2_O0/mmcco[P]sljit/regex_src/regexJIT.c
// Function: compile_end_check
static int compile_end_check(struct compiler_common *compiler_common, struct sljit_label *end_check_label)
{
	struct sljit_compiler *compiler = compiler_common->compiler;
	struct sljit_jump *jump;
	struct sljit_jump *clear_states_jump;
	struct sljit_label *label;
	struct sljit_label *leave_label;
	struct sljit_label *begin_loop_label;

	/* Priority order: best_begin > best_end > best_id.
	   In other words:
	       if (new best_begin > old test_begin) do nothing
	       otherwise we know that new_end > old_end, since R_CURR_INDEX ever increasing
	       therefore we must overwrite all best_* variables (new_id also contains the highest id for this turn). */

	/* Both R_CURR_CHAR and R_BEST_BEGIN used as temporary regs. */

	if (!(compiler_common->flags & REGEX_MATCH_BEGIN)) {
		EMIT_OP1(SLJIT_MOV, R_CURR_CHAR, 0, SLJIT_MEM1(R_CURR_STATE), TERM_REL_OFFSET_OF(0, 2));
		EMIT_CMP(jump, !(compiler_common->flags & REGEX_MATCH_NON_GREEDY) ? SLJIT_LESS : SLJIT_LESS_EQUAL, SLJIT_MEM1(R_REGEX_MATCH), SLJIT_OFFSETOF(struct regex_match, best_begin), R_CURR_CHAR, 0);
		sljit_set_label(jump, end_check_label);

		EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_REGEX_MATCH), SLJIT_OFFSETOF(struct regex_match, best_begin), R_CURR_CHAR, 0);
		if (!(compiler_common->flags & (REGEX_FAKE_MATCH_BEGIN | REGEX_FAKE_MATCH_END))) {
			EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_REGEX_MATCH), SLJIT_OFFSETOF(struct regex_match, best_end), R_CURR_INDEX, 0);
		}
		else {
			if ((compiler_common->flags & (REGEX_FAKE_MATCH_BEGIN | REGEX_FAKE_MATCH_END)) == (REGEX_FAKE_MATCH_BEGIN | REGEX_FAKE_MATCH_END)) {
				EMIT_OP2(SLJIT_SUB, SLJIT_MEM1(R_REGEX_MATCH), SLJIT_OFFSETOF(struct regex_match, best_end), R_CURR_INDEX, 0, SLJIT_IMM, 2);
			}
			else {
				EMIT_OP2(SLJIT_SUB, SLJIT_MEM1(R_REGEX_MATCH), SLJIT_OFFSETOF(struct regex_match, best_end), R_CURR_INDEX, 0, SLJIT_IMM, 1);
			}
		}
		if (compiler_common->flags & REGEX_ID_CHECK) {
			EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_REGEX_MATCH), SLJIT_OFFSETOF(struct regex_match, best_id), SLJIT_MEM1(R_CURR_STATE), TERM_REL_OFFSET_OF(0, 3));
		}

		EMIT_CMP(clear_states_jump, SLJIT_LESS, R_CURR_CHAR, 0, R_BEST_BEGIN, 0);

		EMIT_LABEL(leave_label);
		EMIT_OP1(SLJIT_MOV, R_BEST_BEGIN, 0, R_CURR_CHAR, 0);
		EMIT_JUMP(jump, SLJIT_JUMP);
		sljit_set_label(jump, end_check_label);

		/* A loop to clear all states, which are > (or >=) than R_CURR_CHAR. */
		EMIT_LABEL(label);
		sljit_set_label(clear_states_jump, label);

		EMIT_OP1(SLJIT_MOV, R_TEMP, 0, R_NEXT_HEAD, 0);
		EMIT_OP1(SLJIT_MOV, R_NEXT_HEAD, 0, SLJIT_IMM, 0);

		/* Begin of the loop. */
		EMIT_LABEL(begin_loop_label);
		EMIT_CMP(jump, SLJIT_EQUAL, R_TEMP, 0, SLJIT_IMM, 0);
		sljit_set_label(jump, leave_label);

		EMIT_OP2(SLJIT_ADD, R_TEMP, 0, R_TEMP, 0, R_CURR_STATE, 0);
		EMIT_OP1(SLJIT_MOV, R_BEST_BEGIN, 0, SLJIT_MEM1(R_TEMP), sizeof(long));
		EMIT_CMP(clear_states_jump, !(compiler_common->flags & REGEX_MATCH_NON_GREEDY) ? SLJIT_GREATER : SLJIT_GREATER_EQUAL, SLJIT_MEM1(R_TEMP), 2 * sizeof(long), R_CURR_CHAR, 0);

		/* Case 1: keep this case. */
		EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_TEMP), sizeof(long), R_NEXT_HEAD, 0);
		EMIT_OP2(SLJIT_SUB, R_NEXT_HEAD, 0, R_TEMP, 0, R_CURR_STATE, 0);

		EMIT_OP1(SLJIT_MOV, R_TEMP, 0, R_BEST_BEGIN, 0);
		EMIT_JUMP(jump, SLJIT_JUMP);
		sljit_set_label(jump, begin_loop_label);

		/* Case 2: remove this case. */
		EMIT_LABEL(label);
		sljit_set_label(clear_states_jump, label);

		EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_TEMP), sizeof(long), SLJIT_IMM, -1);

		EMIT_OP1(SLJIT_MOV, R_TEMP, 0, R_BEST_BEGIN, 0);
		EMIT_JUMP(jump, SLJIT_JUMP);
		sljit_set_label(jump, begin_loop_label);
	}
	else {
		EMIT_OP1(SLJIT_MOV, R_BEST_BEGIN, 0, SLJIT_IMM, 0);
		EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_REGEX_MATCH), SLJIT_OFFSETOF(struct regex_match, best_begin), SLJIT_IMM, 0);
		EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_REGEX_MATCH), SLJIT_OFFSETOF(struct regex_match, best_end), R_CURR_INDEX, 0);
		if (compiler_common->flags & REGEX_ID_CHECK) {
			EMIT_OP1(SLJIT_MOV, SLJIT_MEM1(R_REGEX_MATCH), SLJIT_OFFSETOF(struct regex_match, best_id), SLJIT_MEM1(R_CURR_STATE), TERM_REL_OFFSET_OF(0, 2));
		}
		EMIT_JUMP(jump, SLJIT_JUMP);
		sljit_set_label(jump, end_check_label);
	}
	return REGEX_NO_ERROR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x6a6d
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x2, %edx
xorl %eax, %eax
movl %eax, %ecx
movl $0x8c, %r8d
movl $0x10, %r9d
callq 0xeee0
cmpl $0x0, %eax
je 0x6453
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
setne %cl
xorb $-0x1, %cl
movl $0x5, %esi
movl $0x2, %eax
testb $0x1, %cl
cmovnel %eax, %esi
movl $0x81, %edx
movl $0x10, %ecx
addq $0x20, %rcx
subq $0x10, %rcx
movl $0x2, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x1c790
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x64b3
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa940
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x81, %edx
movl $0x10, %ecx
addq $0x20, %rcx
subq $0x10, %rcx
movl $0x2, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0xeee0
cmpl $0x0, %eax
je 0x64fc
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x600, %eax            # imm = 0x600
cmpl $0x0, %eax
jne 0x654e
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x81, %edx
movl $0x10, %ecx
addq $0x28, %rcx
subq $0x10, %rcx
movl $0x5, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0xeee0
cmpl $0x0, %eax
je 0x6549
movl $0x1, -0x4(%rbp)
jmp 0x6b98
jmp 0x65ff
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x600, %eax            # imm = 0x600
cmpl $0x600, %eax            # imm = 0x600
jne 0x65af
movq -0x20(%rbp), %rdi
movl $0x62, %esi
movl $0x81, %edx
movl $0x10, %ecx
addq $0x28, %rcx
subq $0x10, %rcx
movl $0x5, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x40, (%rsp)
movq $0x2, 0x8(%rsp)
callq 0x113e0
cmpl $0x0, %eax
je 0x65ad
movl $0x1, -0x4(%rbp)
jmp 0x6b98
jmp 0x65fd
movq -0x20(%rbp), %rdi
movl $0x62, %esi
movl $0x81, %edx
movl $0x10, %ecx
addq $0x28, %rcx
subq $0x10, %rcx
movl $0x5, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x40, (%rsp)
movq $0x1, 0x8(%rsp)
callq 0x113e0
cmpl $0x0, %eax
je 0x65fb
movl $0x1, -0x4(%rbp)
jmp 0x6b98
jmp 0x65fd
jmp 0x65ff
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x664f
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x81, %edx
movl $0x10, %ecx
addq $0x30, %rcx
subq $0x10, %rcx
movl $0x8c, %r8d
movl $0x18, %r9d
callq 0xeee0
cmpl $0x0, %eax
je 0x664d
movl $0x1, -0x4(%rbp)
jmp 0x6b98
jmp 0x664f
movq -0x20(%rbp), %rdi
movl $0x2, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0x4, %r8d
movl %edx, %esi
movq %r9, %rcx
callq 0x1c790
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x6684
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
callq 0x19d30
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x66a4
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x4, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0x2, %r8d
movq %r9, %rcx
callq 0xeee0
cmpl $0x0, %eax
je 0x66d6
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x16, %esi
callq 0x19ee0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x66fb
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa940
movq -0x20(%rbp), %rdi
callq 0x19d30
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x6728
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xa940
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x3, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0xa, %r8d
movq %r9, %rcx
callq 0xeee0
cmpl $0x0, %eax
je 0x6767
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0xa, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0x40, %r8d
movq %r9, %rcx
callq 0xeee0
cmpl $0x0, %eax
je 0x6799
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
callq 0x19d30
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x67b9
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0x40, %r8d
movq %r9, %rcx
callq 0x1c790
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x67ee
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xa940
movq -0x20(%rbp), %rdi
movl $0x60, %esi
movl $0x3, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq %r9, %rcx
movl $0xc, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x113e0
cmpl $0x0, %eax
je 0x683b
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x4, %edx
xorl %eax, %eax
movl %eax, %ecx
movl $0x83, %r8d
movl $0x8, %r9d
callq 0xeee0
cmpl $0x0, %eax
je 0x686f
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
setne %cl
xorb $-0x1, %cl
movl $0x3, %esi
movl $0x4, %eax
testb $0x1, %cl
cmovnel %eax, %esi
movl $0x83, %edx
movl $0x10, %ecx
movl $0x2, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0x1c790
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x68c7
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x83, %edx
movl $0x8, %ecx
movl $0xa, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0xeee0
cmpl $0x0, %eax
je 0x68fb
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x62, %esi
movl $0xa, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, %r8d
movq %r9, %rcx
movl $0xc, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x113e0
cmpl $0x0, %eax
je 0x693d
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x3, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0x4, %r8d
movq %r9, %rcx
callq 0xeee0
cmpl $0x0, %eax
je 0x696f
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x16, %esi
callq 0x19ee0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x6994
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xa940
movq -0x20(%rbp), %rdi
callq 0x19d30
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x69c1
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xa940
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x83, %edx
movl $0x8, %ecx
movl $0x40, %r8d
movq $-0x1, %r9
callq 0xeee0
cmpl $0x0, %eax
je 0x6a04
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x3, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0x4, %r8d
movq %r9, %rcx
callq 0xeee0
cmpl $0x0, %eax
je 0x6a36
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x16, %esi
callq 0x19ee0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x6a5b
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xa940
jmp 0x6b91
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x4, %edx
xorl %eax, %eax
movl %eax, %r9d
movl $0x40, %r8d
movq %r9, %rcx
callq 0xeee0
cmpl $0x0, %eax
je 0x6a9f
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x81, %edx
movl $0x10, %ecx
addq $0x20, %rcx
subq $0x10, %rcx
movl $0x40, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0xeee0
cmpl $0x0, %eax
je 0x6adb
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x81, %edx
movl $0x10, %ecx
addq $0x28, %rcx
subq $0x10, %rcx
movl $0x5, %r8d
xorl %eax, %eax
movl %eax, %r9d
callq 0xeee0
cmpl $0x0, %eax
je 0x6b17
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x6b62
movq -0x20(%rbp), %rdi
movl $0x20, %esi
movl $0x81, %edx
movl $0x10, %r9d
movq %r9, %rcx
addq $0x30, %rcx
subq $0x10, %rcx
movl $0x8c, %r8d
callq 0xeee0
cmpl $0x0, %eax
je 0x6b60
movl $0x1, -0x4(%rbp)
jmp 0x6b98
jmp 0x6b62
movq -0x20(%rbp), %rdi
movl $0x16, %esi
callq 0x19ee0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x6b84
movl $0x1, -0x4(%rbp)
jmp 0x6b98
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa940
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)