// File: /workspace/github_c_makefile_star2_O1/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, %r12d
testq %rdi, %rdi
je 0x85d9
movq %rsi, %r14
movq %rdi, %rbx
movq 0x20(%rdi), %r15
testq %r15, %r15
sete %al
testq %rsi, %rsi
sete %sil
orb %al, %sil
jne 0x85d9
movl $0x11, %r12d
cmpl $0xfaded00d, (%r15)     # imm = 0xFADED00D
jne 0x85d9
movl %r8d, 0x38(%rbx)
movq %rcx, 0x58(%rbx)
movl %edx, 0x60(%rbx)
movq %r14, 0x40(%rbx)
movl $0x3, %eax
movl $0x3c00, %ecx           # imm = 0x3C00
movl $0x130, %edx            # imm = 0x130
movslq %eax, %rsi
movl (%r15,%rsi,4), %edi
movl %edi, %r9d
andl $-0x2, %r9d
cmpl $0xc, %r9d
jne 0x8431
movl $0x0, 0x10(%r15,%rsi,4)
testl %edi, %edi
je 0x8471
movl (%r15,%rsi,4), %edi
cmpl $0xd, %edi
ja 0x8468
movl $0x5, %esi
btl %edi, %ecx
jb 0x846d
btl %edi, %edx
jae 0x8468
leal 0x2(%rax), %esi
movslq %esi, %rsi
leaq (%r15,%rsi,4), %rdi
xorl %esi, %esi
cmpl $0x0, (%rdi,%rsi,4)
leaq 0x1(%rsi), %rsi
jne 0x8459
addl $0x2, %esi
jmp 0x846d
movl $0x2, %esi
addl %esi, %eax
jne 0x8414
movl %r8d, -0x34(%rbp)
movslq 0x14(%rbx), %rax
testq %rax, %rax
je 0x84ec
movq %rax, -0x30(%rbp)
movl (%r15,%rax,4), %esi
movl 0x4(%rbx), %r12d
andl $0x2, %r12d
movq %r14, %rdi
movl %esi, -0x38(%rbp)
movl %r12d, %edx
callq 0x131e8
testq %rax, %rax
je 0x85ce
movq %rax, %r13
movq -0x30(%rbp), %rax
leaq (%r15,%rax,4), %rax
movq %rax, -0x30(%rbp)
movl 0x18(%rbx), %r15d
movq -0x30(%rbp), %rdi
movl %r15d, %esi
movq %r13, %rdx
movl %r12d, %ecx
callq 0x1323b
testl %eax, %eax
jns 0x84ec
incq %r13
movq %r13, %rdi
movl -0x38(%rbp), %esi
movl %r12d, %edx
callq 0x131e8
movq %rax, %r13
testq %rax, %rax
jne 0x84b8
jmp 0x85ce
movq %r14, 0x50(%rbx)
cmpl $0x0, 0x10(%rbx)
je 0x8505
testb $0x10, -0x34(%rbp)
je 0x858f
jmp 0x85a4
cmpl $0x0, 0xc(%rbx)
je 0x855f
movl 0x4(%rbx), %edx
movl 0xc(%rbx), %esi
andl $0x2, %edx
movq %r14, %rdi
callq 0x131e8
movl $0x1, %r12d
testq %rax, %rax
je 0x85d9
movq %rax, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1329c
testl %eax, %eax
jne 0x85d6
incq %r14
movl 0x4(%rbx), %edx
movl 0xc(%rbx), %esi
andl $0x2, %edx
movq %r14, %rdi
callq 0x131e8
movq %rax, %r14
testq %rax, %rax
jne 0x852e
jmp 0x85d9
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1329c
xorl %r12d, %r12d
testl %eax, %eax
jne 0x85d9
incq %r14
cmpb $0x0, -0x1(%r14)
je 0x85ce
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1329c
incq %r14
testl %eax, %eax
je 0x8574
jmp 0x85d9
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1329c
testl %eax, %eax
jne 0x85d6
cmpb $0x0, (%r14)
je 0x85ce
movl $0x1, %r12d
testb $0x1, 0x4(%rbx)
je 0x85d9
movq %r14, %rdi
movl $0xa, %esi
callq 0x61c0
testq %rax, %rax
je 0x85d9
movq %rax, %r14
incq %r14
movq %r14, 0x50(%rbx)
jmp 0x858f
movl $0x1, %r12d
jmp 0x85d9
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq