// File: /workspace/github_c_makefile_star2_O3/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 %r14
pushq %rbx
subq $0x10, %rsp
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)
movq $0x0, 0x60(%rdi)
testq %rsi, %rsi
je 0x12a70
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 0x12a81
movq %rbx, %rdi
movl $0x1, %esi
callq 0x25d00
movq 0x20(%rbx), %rax
movslq 0x30(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x30(%rbx)
movl $0xfaded00d, (%rax,%rcx,4) # imm = 0xFADED00D
leaq -0x14(%rbp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x12b71
testl %eax, %eax
je 0x12a92
cmpl $0x64, (%rbx)
jl 0x12a9a
movl $0x5, 0x8(%rbx)
movl $0x5, %eax
jmp 0x12b68
movl $0x3, 0x8(%rbx)
movl $0x3, %eax
jmp 0x12b68
movl $0x6, 0x8(%rbx)
movl $0x6, %eax
jmp 0x12b68
movl 0x8(%rbx), %eax
jmp 0x12b68
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rbx)
movq 0x20(%rbx), %rcx
movl 0x8(%rcx), %edx
xorl %eax, %eax
movl $0x0, %esi
testl %edx, %edx
je 0x12ac6
cmpl $0x7, 0x4(%rcx)
jne 0x12ac2
movl $0x1, %esi
subl %edx, %esi
jmp 0x12ac6
incl %edx
movl %edx, %esi
movslq %esi, %rdx
cmpl $0x0, (%rcx,%rdx,4)
jne 0x12b68
movl 0xc(%rcx), %edx
cmpl $0x1, %edx
je 0x12aeb
cmpl $0x8, %edx
jne 0x12af2
leaq 0xc(%rbx), %rdx
movl 0x14(%rcx), %esi
movl %esi, (%rdx)
jmp 0x12af2
movl $0x1, 0x10(%rbx)
testb $0x4, -0x14(%rbp)
je 0x12b68
leaq 0x4(%rcx), %rdx
movl $0x3, %esi
xorl %eax, %eax
xorl %edi, %edi
movslq %esi, %r9
movl (%rcx,%r9,4), %r8d
cmpl $0x8, %r8d
jne 0x12b43
leaq 0x2(%r9), %r10
cmpl $0x0, 0x8(%rcx,%r9,4)
je 0x12b32
leaq (%rdx,%r10,4), %r14
xorl %r11d, %r11d
cmpl $0x0, (%r14,%r11,4)
leaq 0x1(%r11), %r11
jne 0x12b25
jmp 0x12b35
xorl %r11d, %r11d
cmpl %eax, %r11d
cmovbl %edi, %r10d
cmoval %r11d, %eax
movl %r10d, %edi
movl 0x4(%rcx,%r9,4), %r9d
testl %r9d, %r9d
je 0x12b60
movl %r9d, %r10d
negl %r10d
cmpl $0x7, %r8d
cmovnel %r9d, %r10d
addl %r10d, %esi
jne 0x12b05
movl %edi, 0x14(%rbx)
movl %eax, 0x18(%rbx)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq