// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
pushq $0x3
popq %rax
testq %rdi, %rdi
je 0x81bf
movl %r8d, %r15d
movq %rsi, %r14
movq %rdi, %rbx
movq 0x20(%rdi), %rsi
testq %rsi, %rsi
sete %dil
testq %r14, %r14
sete %r8b
orb %dil, %r8b
jne 0x81bf
cmpl $0xfaded00d, (%rsi)     # imm = 0xFADED00D
jne 0x80c3
movl %r15d, 0x38(%rbx)
movq %rcx, 0x58(%rbx)
movl %edx, 0x60(%rbx)
movq %r14, 0x40(%rbx)
pushq $0x3
popq %rax
pushq $0x5
popq %rcx
pushq $0x2
popq %rdx
movl $0x3c00, %edi           # imm = 0x3C00
movl $0x130, %r8d            # imm = 0x130
testl %eax, %eax
je 0x80cb
movslq %eax, %r10
movl (%rsi,%r10,4), %r9d
testl %r9d, %r9d
je 0x80cb
movl %r9d, %r11d
andl $-0x2, %r11d
cmpl $0xc, %r11d
jne 0x8087
andl $0x0, 0x10(%rsi,%r10,4)
cmpl $0xd, %r9d
ja 0x80bb
btl %r9d, %edi
movl %ecx, %r10d
jb 0x80be
btl %r9d, %r8d
jae 0x80bb
leal 0x2(%rax), %r9d
movslq %r9d, %r9
leaq (%rsi,%r9,4), %r9
xorl %r10d, %r10d
cmpl $0x0, (%r9,%r10,4)
leaq 0x1(%r10), %r10
jne 0x80aa
addl $0x2, %r10d
jmp 0x80be
movl %edx, %r10d
addl %r10d, %eax
jmp 0x8064
pushq $0x11
popq %rax
jmp 0x81bf
cmpl $0x0, 0x14(%rbx)
pushq $0x1
popq %r13
je 0x8121
movq %r14, %r12
movq 0x20(%rbx), %rax
movslq 0x14(%rbx), %rcx
movl (%rax,%rcx,4), %esi
movl 0x4(%rbx), %edx
andl $0x2, %edx
movq %r12, %rdi
callq 0x117fc
testq %rax, %rax
je 0x81bc
movq %rax, %r12
movslq 0x14(%rbx), %rdi
shlq $0x2, %rdi
addq 0x20(%rbx), %rdi
movl 0x4(%rbx), %ecx
movl 0x18(%rbx), %esi
andl $0x2, %ecx
movq %rax, %rdx
callq 0x1185d
incq %r12
testl %eax, %eax
js 0x80d8
movq %r14, 0x50(%rbx)
cmpl $0x0, 0x10(%rbx)
je 0x8133
testb $0x10, %r15b
je 0x8185
jmp 0x819a
cmpl $0x0, 0xc(%rbx)
je 0x8174
movl 0x4(%rbx), %edx
movl 0xc(%rbx), %esi
andl $0x2, %edx
movq %r14, %rdi
callq 0x117fc
testq %rax, %rax
je 0x81bc
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x118b9
movl %eax, %ecx
incq %r14
xorl %eax, %eax
testl %ecx, %ecx
je 0x8139
jmp 0x81bf
cmpb $0x0, (%r14)
leaq 0x1(%r14), %r14
je 0x81bc
movq %rbx, %rdi
movq %r14, %rsi
callq 0x118b9
testl %eax, %eax
je 0x816a
jmp 0x81ce
movq %rbx, %rdi
movq %r14, %rsi
callq 0x118b9
testl %eax, %eax
jne 0x81ce
cmpb $0x0, (%r14)
je 0x81bc
testb $0x1, 0x4(%rbx)
je 0x81bc
pushq $0xa
popq %rsi
movq %r14, %rdi
callq 0x61c0
testq %rax, %rax
je 0x81bc
movq %rax, %r14
incq %r14
movq %r14, 0x50(%rbx)
jmp 0x8185
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x81bf