// File: /workspace/github_c_makefile_star2_O3/msteveb[P]autosetup/./jimsh0.c
// Function: jim_regexec
int jim_regexec(regex_t  *preg,  const  char *string, size_t nmatch, regmatch_t pmatch[], int eflags)
{
	const char *s;
	int scan;


	if (preg == NULL || preg->program == NULL || string == NULL) {
		return REG_ERR_NULL_ARGUMENT;
	}


	if (*preg->program != REG_MAGIC) {
		return REG_ERR_CORRUPTED;
	}

#ifdef DEBUG
	fprintf(stderr, "regexec: %s\n", string);
	regdump(preg);
#endif

	preg->eflags = eflags;
	preg->pmatch = pmatch;
	preg->nmatch = nmatch;
	preg->start = string;


	for (scan = OPERAND(1); scan != 0; scan += regopsize(preg, scan)) {
		int op = OP(preg, scan);
		if (op == END)
			break;
		if (op == REPX || op == REPXMIN)
			preg->program[scan + 4] = 0;
	}


	if (preg->regmust != 0) {
		s = string;
		while ((s = str_find(s, preg->program[preg->regmust], preg->cflags & REG_ICASE)) != NULL) {
			if (prefix_cmp(preg->program + preg->regmust, preg->regmlen, s, preg->cflags & REG_ICASE) >= 0) {
				break;
			}
			s++;
		}
		if (s == NULL)
			return REG_NOMATCH;
	}


	preg->regbol = string;


	if (preg->reganch) {
		if (eflags & REG_NOTBOL) {

			goto nextline;
		}
		while (1) {
			if (regtry(preg, string)) {
				return REG_NOERROR;
			}
			if (*string) {
nextline:
				if (preg->cflags & REG_NEWLINE) {

					string = strchr(string, '\n');
					if (string) {
						preg->regbol = ++string;
						continue;
					}
				}
			}
			return REG_NOMATCH;
		}
	}


	s = string;
	if (preg->regstart != '\0') {

		while ((s = str_find(s, preg->regstart, preg->cflags & REG_ICASE)) != NULL) {
			if (regtry(preg, s))
				return REG_NOERROR;
			s++;
		}
	}
	else

		while (1) {
			if (regtry(preg, s))
				return REG_NOERROR;
			if (*s == '\0') {
				break;
			}
			else {
				int c;
				s += utf8_tounicode(s, &c);
			}
		}


	return REG_NOMATCH;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0x3, %r15d
testq %rdi, %rdi
je 0x8621
movq %rdi, %r9
movq 0x20(%rdi), %r13
testq %r13, %r13
sete %al
testq %rsi, %rsi
sete %dil
orb %al, %dil
jne 0x8621
movl $0x11, %r15d
cmpl $0xfaded00d, (%r13)     # imm = 0xFADED00D
jne 0x8621
movl %r8d, -0x2c(%rbp)
movl %r8d, 0x38(%r9)
movq %rcx, 0x58(%r9)
movl %edx, 0x60(%r9)
movq %rsi, 0x40(%r9)
movl $0x3, %eax
movl $0x3c00, %ecx           # imm = 0x3C00
movl $0x130, %edx            # imm = 0x130
movslq %eax, %rdi
movl (%r13,%rdi,4), %r10d
testl %r10d, %r10d
je 0x849a
movl %r10d, %r8d
andl $-0x2, %r8d
cmpl $0xc, %r8d
jne 0x8457
movl $0x0, 0x10(%r13,%rdi,4)
cmpl $0xd, %r10d
ja 0x8491
movl $0x5, %edi
btl %r10d, %ecx
jb 0x8496
btl %r10d, %edx
jae 0x8491
leal 0x2(%rax), %edi
movslq %edi, %rdi
leaq (,%rdi,4), %r8
addq %r13, %r8
xorl %edi, %edi
cmpl $0x0, (%r8,%rdi,4)
leaq 0x1(%rdi), %rdi
jne 0x8481
addl $0x2, %edi
jmp 0x8496
movl $0x2, %edi
addl %edi, %eax
jne 0x8434
movq %rsi, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movslq 0x14(%r9), %rbx
testq %rbx, %rbx
je 0x8533
movl (%r13,%rbx,4), %esi
movq -0x40(%rbp), %r14
movl 0x4(%r14), %r12d
andl $0x2, %r12d
movq -0x38(%rbp), %rdi
movl %esi, -0x30(%rbp)
movl %r12d, %edx
callq 0x12e51
testq %rax, %rax
je 0x861b
movq %rax, %r15
leaq (%r13,%rbx,4), %r13
movl 0x18(%r14), %ebx
xorl %r14d, %r14d
cmpl %r14d, %ebx
je 0x8511
movzbl (%r15,%r14), %eax
testl %eax, %eax
je 0x8515
testl %r12d, %r12d
je 0x8501
movl %eax, %edi
callq 0x60e0
leaq 0x1(%r14), %rcx
cmpl (%r13,%r14,4), %eax
movq %rcx, %r14
je 0x84e7
jmp 0x8515
testl %ebx, %ebx
jns 0x8533
incq %r15
movq %r15, %rdi
movl -0x30(%rbp), %esi
movl %r12d, %edx
callq 0x12e51
movq %rax, %r15
testq %rax, %rax
jne 0x84e4
jmp 0x861b
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r14
movq %r14, 0x50(%rbx)
cmpl $0x0, 0x10(%rbx)
je 0x8554
testb $0x10, -0x2c(%rbp)
je 0x85dc
jmp 0x85f1
movl 0xc(%rbx), %esi
testl %esi, %esi
je 0x85ac
movl 0x4(%rbx), %edx
andl $0x2, %edx
movq %r14, %rdi
callq 0x12e51
movl $0x1, %r15d
testq %rax, %rax
je 0x8621
movq %rax, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12ea4
testl %eax, %eax
jne 0x8633
incq %r14
movl 0x4(%rbx), %edx
movl 0xc(%rbx), %esi
andl $0x2, %edx
movq %r14, %rdi
callq 0x12e51
movq %rax, %r14
testq %rax, %rax
jne 0x857b
jmp 0x8621
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12ea4
xorl %r15d, %r15d
testl %eax, %eax
jne 0x8621
incq %r14
cmpb $0x0, -0x1(%r14)
je 0x861b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12ea4
incq %r14
testl %eax, %eax
je 0x85c1
jmp 0x8621
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12ea4
testl %eax, %eax
jne 0x8633
cmpb $0x0, (%r14)
je 0x861b
movl $0x1, %r15d
testb $0x1, 0x4(%rbx)
je 0x8621
movq %r14, %rdi
movl $0xa, %esi
callq 0x61c0
testq %rax, %rax
je 0x8621
movq %rax, %r14
incq %r14
movq %r14, 0x50(%rbx)
jmp 0x85dc
movl $0x1, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x8621