// File: /workspace/github_c_makefile_star2_O2/mmcco[P]sljit/regex_src/regexJIT.c
// Function: iterate
static int iterate(struct stack *stack, int min, int max)
{
	struct stack it;
	struct stack_item *item;
	int count = -1;
	int len = 0;
	int depth = 0;

	stack_clone(stack, &it);

	/* Calculate size. */
	while (count < 0) {
		item = stack_pop(&it);
		switch (item->type) {
		case type_id:
		case type_rng_end:
		case type_rng_char:
		case type_rng_left:
		case type_rng_right:
		case type_plus_sign:
		case type_qestion_mark:
			len++;
			break;

		case type_asterisk:
			len += 2;
			break;

		case type_close_br:
			depth++;
			break;

		case type_open_br:
			SLJIT_ASSERT(depth > 0);
			depth--;
			if (depth == 0)
				count = it.count;
			break;

		case type_select:
			SLJIT_ASSERT(depth > 0);
			len += 2;
			break;

		default:
			SLJIT_ASSERT(item->type != type_begin && item->type != type_end);
			if (depth == 0)
				count = it.count;
			len++;
			break;
		}
	}

	if (min == 0 && max == 0) {
		/* {0,0} case, not {0,} case: delete subtree. */
		stack_clone(&it, stack);
		/* and put an empty bracket expression instead of it. */
		if (stack_push(stack, type_open_br, 0))
			return REGEX_MEMORY_ERROR;
		if (stack_push(stack, type_close_br, 0))
			return REGEX_MEMORY_ERROR;
		return len;
	}

	count = stack->count - count;

	/* Put an open bracket before the sequence. */
	if (stack_push_copy(stack, 1, count))
		return -1;

#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
	SLJIT_ASSERT(stack_push(&it, type_open_br, 0) == 0);
#else
	stack_push(&it, type_open_br, 0);
#endif

	/* Copy the data. */
	if (max > 0) {
		len = len * (max - 1);
		max -= min;
		/* Insert ? operators. */
		len += max;

		if (min > 0) {
			min--;
			while (min > 0) {
				if (stack_push_copy(stack, count, count))
					return -1;
				min--;
			}
			if (max > 0) {
				if (stack_push_copy(stack, count, count))
					return -1;
				if (stack_push(stack, type_qestion_mark, 0))
					return REGEX_MEMORY_ERROR;
				count++;
				max--;
			}
		}
		else {
			SLJIT_ASSERT(max > 0);
			max--;
			count++;
			if (stack_push(stack, type_qestion_mark, 0))
				return REGEX_MEMORY_ERROR;
		}

		while (max > 0) {
			if (stack_push_copy(stack, count, count))
				return -1;
			max--;
		}
	}
	else {
		SLJIT_ASSERT(min > 0);
		min--;
		/* Insert + operator. */
		len = len * min + 1;
		while (min > 0) {
			if (stack_push_copy(stack, count, count))
				return -1;
			min--;
		}

		if (stack_push(stack, type_plus_sign, 0))
			return REGEX_MEMORY_ERROR;
	}

	/* Close the opened bracket. */
	if (stack_push(stack, type_close_br, 0))
		return REGEX_MEMORY_ERROR;

	return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, 0x4(%rsp)
movl %esi, %r14d
movq 0x10(%rdi), %rax
leaq 0x10(%rsp), %r15
movq %rax, 0x10(%r15)
movq %rdi, 0x8(%rsp)
movups (%rdi), %xmm0
movaps %xmm0, (%r15)
xorl %r13d, %r13d
pushq $-0x1
popq %r12
leaq 0xbcc5(%rip), %rbp      # 0x126b0
xorl %ebx, %ebx
negl %ebx
testl %r12d, %r12d
jns 0x6a4e
movq %r15, %rdi
callq 0x5f64
movl (%rax), %eax
cmpq $0x11, %rax
ja 0x6a12
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
decl %ebx
jmp 0x69ef
testl %ebx, %ebx
jne 0x6a1b
movl 0x24(%rsp), %r12d
incl %r13d
negl %ebx
jmp 0x69ed
movl %ebx, %eax
negl %eax
testl %eax, %eax
jle 0x6c13
addl $0x2, %r13d
jmp 0x6a1e
movl %ebx, %eax
negl %eax
testl %eax, %eax
jle 0x6c21
cmpl $-0x1, %ebx
jne 0x6a4a
movl 0x24(%rsp), %r12d
notl %ebx
jmp 0x69ed
movl 0x4(%rsp), %ebx
movl %ebx, %eax
orl %r14d, %eax
je 0x6a86
movq 0x8(%rsp), %rbp
movl 0x14(%rbp), %r15d
subl %r12d, %r15d
pushq $0x1
popq %r12
movq %rbp, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x6c59
pushq $-0x1
popq %rcx
testl %eax, %eax
je 0x6ab4
movl %ecx, %r12d
jmp 0x6bd0
movq 0x20(%rsp), %rax
movq 0x8(%rsp), %rbx
movq %rax, 0x10(%rbx)
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rbx)
pushq $0xc
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x67a8
testl %eax, %eax
je 0x6af7
pushq $0x1
jmp 0x6b6c
leaq 0x10(%rsp), %rdi
pushq $0xc
popq %rsi
xorl %edx, %edx
callq 0x67a8
testl %eax, %eax
jne 0x6c2f
testl %ebx, %ebx
jle 0x6b02
subl %r14d, %ebx
testl %r14d, %r14d
jle 0x6b2f
incl %r14d
decl %r14d
cmpl $0x2, %r14d
jl 0x6b54
movq %rbp, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x6c59
testl %eax, %eax
je 0x6ada
jmp 0x6b6a
pushq $0xd
popq %rsi
movq %rbx, %rdi
jmp 0x6bbf
testl %r14d, %r14d
jle 0x6c3d
leal -0x1(%r14), %eax
imull %eax, %r13d
incl %r13d
decl %r14d
jle 0x6b70
movq %rbp, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x6c59
testl %eax, %eax
je 0x6b16
jmp 0x6b6a
testl %ebx, %ebx
jle 0x6c4b
pushq $0x11
popq %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x67a8
testl %eax, %eax
jne 0x6bd0
leal -0x1(%rbx), %ebp
incl %r15d
jmp 0x6b85
testl %ebx, %ebx
jle 0x6b83
movq %rbp, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x6c59
testl %eax, %eax
je 0x6be2
pushq $-0x1
popq %r12
jmp 0x6bd0
pushq $0x10
popq %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x67a8
testl %eax, %eax
jne 0x6bd0
jmp 0x6bb9
movl %ebx, %ebp
movl 0x4(%rsp), %eax
decl %eax
imull %eax, %r13d
addl %ebx, %r13d
incl %ebp
pushq $-0x1
popq %r12
decl %ebp
testl %ebp, %ebp
jle 0x6bb4
movq 0x8(%rsp), %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x6c59
testl %eax, %eax
je 0x6b98
jmp 0x6bd0
movq 0x8(%rsp), %rbp
pushq $0xd
popq %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x67a8
testl %eax, %eax
pushq $0x1
popq %r12
cmovel %r13d, %r12d
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x11
popq %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x67a8
testl %eax, %eax
jne 0x6bd0
incl %r15d
leal -0x1(%rbx), %ebp
jmp 0x6b85
leaq 0xbaf6(%rip), %rdi      # 0x126f8
movl $0x1d6, %esi            # imm = 0x1D6
xorl %eax, %eax
callq 0x2080
callq 0x2050
leaq 0xbade(%rip), %rdi      # 0x126f8
movl $0x1d1, %esi            # imm = 0x1D1
jmp 0x6c07
leaq 0xbad0(%rip), %rdi      # 0x126f8
movl $0x1ca, %esi            # imm = 0x1CA
jmp 0x6c07
leaq 0xbac2(%rip), %rdi      # 0x126f8
movl $0x1f0, %esi            # imm = 0x1F0
jmp 0x6c07
leaq 0xbab4(%rip), %rdi      # 0x126f8
movl $0x21b, %esi            # imm = 0x21B
jmp 0x6c07
leaq 0xbaa6(%rip), %rdi      # 0x126f8
movl $0x20d, %esi            # imm = 0x20D
jmp 0x6c07