// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %rdx, 0x30(%rsp)
movl %esi, %ebp
movq 0x10(%rdi), %rax
leaq 0x10(%rsp), %r15
movq %rax, 0x10(%r15)
movq %rdi, 0x8(%rsp)
movups (%rdi), %xmm0
movaps %xmm0, (%r15)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %r14d, %r14d
leaq 0xc8a0(%rip), %rbx      # 0x136b0
xorl %r13d, %r13d
movq %r15, %rdi
callq 0x4ee0
movl (%rax), %eax
cmpq $0x11, %rax
ja 0x6e36
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
incl %r13d
testl %r12d, %r12d
js 0x6e13
jmp 0x6e6b
testl %r14d, %r14d
jne 0x6e2c
movl 0x24(%rsp), %r12d
jmp 0x6e2c
testl %r14d, %r14d
jle 0x702f
decl %r14d
jne 0x6e2f
movl 0x24(%rsp), %r12d
jmp 0x6e2f
testl %r14d, %r14d
jle 0x7021
addl $0x2, %r13d
jmp 0x6e2f
incl %r14d
jmp 0x6e2f
movq 0x30(%rsp), %rbx
movl %ebx, %eax
orl %ebp, %eax
je 0x6ef5
movq 0x8(%rsp), %r14
movl 0x14(%r14), %r15d
subl %r12d, %r15d
movq %r14, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x7071
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x7001
leaq 0x10(%rsp), %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x6bbe
testl %eax, %eax
jne 0x7047
testl %ebx, %ebx
jle 0x6f30
leal -0x1(%rbx), %eax
imull %eax, %r13d
subl %ebp, %ebx
addl %ebx, %r13d
testl %ebp, %ebp
jle 0x6f84
incl %ebp
decl %ebp
cmpl $0x2, %ebp
jl 0x6fc8
movq %r14, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x7071
testl %eax, %eax
je 0x6ed3
jmp 0x7001
movq 0x20(%rsp), %rax
movq 0x8(%rsp), %rbx
movq %rax, 0x10(%rbx)
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rbx)
movq %rbx, %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x6bbe
movl $0x1, %r12d
testl %eax, %eax
jne 0x7001
movq %rbx, %rdi
jmp 0x6fe9
testl %ebp, %ebp
jle 0x7055
cmpl $0x1, %ebp
je 0x6f5c
movl %ebp, %ebx
movq %r14, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x7071
testl %eax, %eax
jne 0x6fde
decl %ebx
cmpl $0x2, %ebx
jge 0x6f3f
movq %r14, %rdi
movl $0x10, %esi
xorl %edx, %edx
callq 0x6bbe
movl $0x1, %r12d
testl %eax, %eax
jne 0x7001
decl %ebp
imull %ebp, %r13d
incl %r13d
jmp 0x6fe6
testl %ebx, %ebx
jle 0x7063
movq %r14, %rdi
movl $0x11, %esi
xorl %edx, %edx
callq 0x6bbe
movl $0x1, %r12d
testl %eax, %eax
jne 0x7001
cmpl $0x1, %ebx
je 0x6fe6
incl %r15d
movq %r14, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x7071
testl %eax, %eax
jne 0x6fde
decl %ebx
cmpl $0x2, %ebx
jge 0x6fad
jmp 0x6fe6
testl %ebx, %ebx
jle 0x6fe6
movq %r14, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x7071
testl %eax, %eax
je 0x6f8c
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x7001
movq %r14, %rdi
movl $0xd, %esi
xorl %edx, %edx
callq 0x6bbe
testl %eax, %eax
movl $0x1, %r12d
cmovel %r13d, %r12d
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc6de(%rip), %rdi      # 0x136f8
movl $0x1d6, %esi            # imm = 0x1D6
jmp 0x703b
leaq 0xc6d0(%rip), %rdi      # 0x136f8
movl $0x1d1, %esi            # imm = 0x1D1
jmp 0x703b
leaq 0xc6c2(%rip), %rdi      # 0x136f8
movl $0x1ca, %esi            # imm = 0x1CA
xorl %eax, %eax
callq 0x2080
callq 0x2050
leaq 0xc6aa(%rip), %rdi      # 0x136f8
movl $0x1f0, %esi            # imm = 0x1F0
jmp 0x703b
leaq 0xc69c(%rip), %rdi      # 0x136f8
movl $0x21b, %esi            # imm = 0x21B
jmp 0x703b
leaq 0xc68e(%rip), %rdi      # 0x136f8
movl $0x20d, %esi            # imm = 0x20D
jmp 0x703b