// File: /workspace/github_c_makefile_star2_O2/msteveb[P]autosetup/./jimsh0.c
// Function: jim_regcomp
int jim_regcomp(regex_t *preg, const char *exp, int cflags)
{
	int scan;
	int longest;
	unsigned len;
	int flags;

#ifdef DEBUG
	fprintf(stderr, "Compiling: '%s'\n", exp);
#endif
	memset(preg, 0, sizeof(*preg));

	if (exp == NULL)
		FAIL(preg, REG_ERR_NULL_ARGUMENT);


	preg->cflags = cflags;
	preg->regparse = exp;


	preg->proglen = (strlen(exp) + 1) * 5;
	preg->program = malloc(preg->proglen * sizeof(int));
	if (preg->program == NULL)
		FAIL(preg, REG_ERR_NOMEM);

	regc(preg, REG_MAGIC);
	if (reg(preg, 0, &flags) == 0) {
		return preg->err;
	}


	if (preg->re_nsub >= REG_MAX_PAREN)
		FAIL(preg,REG_ERR_TOO_BIG);


	preg->regstart = 0;
	preg->reganch = 0;
	preg->regmust = 0;
	preg->regmlen = 0;
	scan = 1;
	if (OP(preg, regnext(preg, scan)) == END) {
		scan = OPERAND(scan);


		if (OP(preg, scan) == EXACTLY) {
			preg->regstart = preg->program[OPERAND(scan)];
		}
		else if (OP(preg, scan) == BOL)
			preg->reganch++;

		if (flags&SPSTART) {
			longest = 0;
			len = 0;
			for (; scan != 0; scan = regnext(preg, scan)) {
				if (OP(preg, scan) == EXACTLY) {
					int plen = str_int_len(preg->program + OPERAND(scan));
					if (plen >= len) {
						longest = OPERAND(scan);
						len = plen;
					}
				}
			}
			preg->regmust = longest;
			preg->regmlen = len;
		}
	}

#ifdef DEBUG
	regdump(preg);
#endif

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
andq $0x0, 0x60(%rdi)
testq %rsi, %rsi
je 0x11531
movl %edx, 0x4(%rbx)
movq %rsi, 0x28(%rbx)
movq %rsi, %rdi
callq 0x6180
leal (%rax,%rax,4), %eax
addl $0x5, %eax
movl %eax, 0x34(%rbx)
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x6360
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x1153c
movq %rbx, %rdi
movl $0xfaded00d, %esi       # imm = 0xFADED00D
callq 0x11601
leaq -0x30(%rbp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1162c
testl %eax, %eax
je 0x11555
cmpl $0x64, (%rbx)
jl 0x1155a
movl $0x5, 0x8(%rbx)
pushq $0x5
jmp 0x11545
movl $0x3, 0x8(%rbx)
pushq $0x3
jmp 0x11545
movl $0x6, 0x8(%rbx)
pushq $0x6
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%rbx), %eax
jmp 0x11546
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rbx)
movq 0x20(%rbx), %r15
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x117c2
movslq %eax, %rcx
xorl %eax, %eax
cmpl $0x0, (%r15,%rcx,4)
jne 0x11546
movl 0xc(%r15), %ecx
cmpl $0x1, %ecx
je 0x11596
cmpl $0x8, %ecx
jne 0x1159d
leaq 0xc(%rbx), %rcx
movl 0x14(%r15), %edx
movl %edx, (%rcx)
jmp 0x1159d
movl $0x1, 0x10(%rbx)
testb $0x4, -0x30(%rbp)
je 0x11546
xorl %r12d, %r12d
pushq $0x3
popq %r14
movl $0x0, -0x2c(%rbp)
testl %r14d, %r14d
je 0x115f0
movslq %r14d, %rax
cmpl $0x8, (%r15,%rax,4)
jne 0x115e0
leal 0x2(%r14), %r13d
leaq (%r15,%rax,4), %rdi
addq $0x8, %rdi
callq 0x117e9
movl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
cmovael %r13d, %r12d
cmoval %eax, %ecx
movl %ecx, -0x2c(%rbp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x117c2
movl %eax, %r14d
jmp 0x115b1
movl %r12d, 0x14(%rbx)
movl -0x2c(%rbp), %eax
movl %eax, 0x18(%rbx)
xorl %eax, %eax
jmp 0x11546