// File: /workspace/github_c_makefile_star2_O1/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, 0xc(%rsp)
movl %esi, %r14d
movq 0x10(%rdi), %rax
leaq 0x10(%rsp), %r15
movq %rax, 0x10(%r15)
movq %rdi, (%rsp)
movups (%rdi), %xmm0
movaps %xmm0, (%r15)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
leaq 0xc7e2(%rip), %rbx      # 0x13694
xorl %r13d, %r13d
movq %r15, %rdi
callq 0x4fb0
movl (%rax), %eax
cmpq $0x11, %rax
ja 0x6ed8
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
incl %r13d
testl %r12d, %r12d
js 0x6eb5
jmp 0x6f08
testl %ebp, %ebp
jne 0x6ece
movl 0x24(%rsp), %r12d
jmp 0x6ece
testl %ebp, %ebp
jle 0x7103
decl %ebp
jne 0x6ed1
movl 0x24(%rsp), %r12d
jmp 0x6ed1
testl %ebp, %ebp
jle 0x70f5
addl $0x2, %r13d
jmp 0x6ed1
incl %ebp
jmp 0x6ed1
movl 0xc(%rsp), %ebp
movl %ebp, %eax
orl %r14d, %eax
je 0x6f90
movq (%rsp), %rbx
movl 0x14(%rbx), %r15d
subl %r12d, %r15d
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x7145
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x707c
leaq 0x10(%rsp), %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x6c63
testl %eax, %eax
jne 0x711b
testl %ebp, %ebp
jle 0x6fe2
subl %r14d, %ebp
testl %r14d, %r14d
jle 0x7037
incl %r14d
decl %r14d
cmpl $0x2, %r14d
jl 0x7060
movq %rbx, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x7145
testl %eax, %eax
je 0x6f6c
jmp 0x707c
movq 0x20(%rsp), %rax
movq (%rsp), %rbx
movq %rax, 0x10(%rbx)
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rbx)
movq %rbx, %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x6c63
movl $0x1, %r12d
testl %eax, %eax
jne 0x707c
movq %rbx, %rdi
movl $0xd, %esi
xorl %edx, %edx
callq 0x6c63
testl %eax, %eax
movl $0x1, %r12d
cmovel %r13d, %r12d
jmp 0x707c
testl %r14d, %r14d
jle 0x7129
cmpl $0x1, %r14d
je 0x700e
movl %r14d, %ebx
movq (%rsp), %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x7145
testl %eax, %eax
jne 0x7076
decl %ebx
cmpl $0x2, %ebx
jge 0x6ff4
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0x10, %esi
xorl %edx, %edx
callq 0x6c63
movl $0x1, %r12d
testl %eax, %eax
jne 0x707c
decl %r14d
imull %r14d, %r13d
incl %r13d
jmp 0x6fc2
testl %ebp, %ebp
jle 0x7137
movq %rbx, %rdi
movl $0x11, %esi
xorl %edx, %edx
callq 0x6c63
movl $0x1, %r12d
testl %eax, %eax
jne 0x707c
leal -0x1(%rbp), %ebx
incl %r15d
jmp 0x7090
testl %ebp, %ebp
jle 0x708e
movq %rbx, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x7145
testl %eax, %eax
je 0x70c6
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %ebx
movl 0xc(%rsp), %eax
decl %eax
imull %eax, %r13d
addl %ebp, %r13d
testl %ebx, %ebx
jle 0x70bd
incl %ebx
movq (%rsp), %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x7145
testl %eax, %eax
jne 0x7076
decl %ebx
cmpl $0x2, %ebx
jge 0x70a3
movq (%rsp), %rbx
jmp 0x6fc2
movq %rbx, %rdi
movl $0x11, %esi
xorl %edx, %edx
callq 0x6c63
movl $0x1, %r12d
testl %eax, %eax
jne 0x707c
incl %r15d
leal -0x1(%rbp), %ebx
jmp 0x7090
leaq 0xc5ee(%rip), %rdi      # 0x136dc
movl $0x1d6, %esi            # imm = 0x1D6
jmp 0x710f
leaq 0xc5e0(%rip), %rdi      # 0x136dc
movl $0x1d1, %esi            # imm = 0x1D1
jmp 0x710f
leaq 0xc5d2(%rip), %rdi      # 0x136dc
movl $0x1ca, %esi            # imm = 0x1CA
xorl %eax, %eax
callq 0x2080
callq 0x2050
leaq 0xc5ba(%rip), %rdi      # 0x136dc
movl $0x1f0, %esi            # imm = 0x1F0
jmp 0x710f
leaq 0xc5ac(%rip), %rdi      # 0x136dc
movl $0x21b, %esi            # imm = 0x21B
jmp 0x710f
leaq 0xc59e(%rip), %rdi      # 0x136dc
movl $0x20d, %esi            # imm = 0x20D
jmp 0x710f