// File: /workspace/github_cpp_makefile_star2_O3/arnoldrobbins[P]mcilroy-regex/re2.cpp
// Function: regRep(Rex*, int, int, Cenv*)
static Rex*
regRep(Rex *e, int n1, int n2, Cenv *env)
{
	if(cdebug)
		printf("regRep %lx.%d\n",
			(unsigned long)env->cursor.p,env->cursor.n);
	int c;
	unsigned long m = 0;
	unsigned long n = RE_DUP_INF;
	char *sp, *ep;
	if(e == ERROR)
		return e;
	c = token(env);
	switch(c) {
	default:
		return e;
	case T_BANG:
		eat(env);
		return NEW(Neg(e));
	case T_QUES:
		n = 1;
		eat(env);
		break;
	case T_STAR:
		eat(env);
		break;
	case T_PLUS:
		m = 1;
		eat(env);
		break;
	case T_LEFT:
		eat(env);
		errno = 0;
		sp = (char*)env->cursor.p;
		n = m = strtoul(sp, &ep, 10);
		if(ep == sp || ep-sp >= env->cursor.n)
			goto error;
		if(*ep == ',') {
			sp = ep + 1;
			if(*sp == '\\' || *sp == '}') {
				n = RE_DUP_INF;
				ep = sp;
			} else {
				n = strtoul(sp, &ep, 10);
				if(ep == sp || n > RE_DUP_MAX)
					goto error;
				if(ep- (char*)env->cursor.p >= env->cursor.n)
					goto error;
			}
		}
		env->cursor.next(ep - (char*)env->cursor.p);
		if(errno || m > n || m > RE_DUP_MAX)
			goto error;
		else if(env->flags&REG_EXTENDED) {
			if(token(env) != '}')
				goto error;
		} else if(token(env) != T_RIGHT)
				goto error;
		eat(env);
		break;
	}
	switch(e->type) {
	case DOT:
	case CLASS:
	case ONECHAR:
		((Dup*)e)->lo = (int)m;
		((Dup*)e)->hi = (int)n;
		return e;
	}
	return NEW(Rep((int)m, (int)n, n1, n2, e));
error:
	delete e;
	return ERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0xba3b
movq %rcx, %r14
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
movq %rcx, %rdi
callq 0xb15e
addl $0xfffffefa, %eax       # imm = 0xFFFFFEFA
cmpl $0xa, %eax
ja 0xba3d
leaq 0x1cd4(%rip), %rcx      # 0xd514
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%r14), %rax
xorl %ecx, %ecx
cmpb $0x5c, (%rax)
sete %cl
addq %rcx, %rax
incq %rax
movq %rax, 0x8(%r14)
notl %ecx
addl %ecx, 0x10(%r14)
movl $0x40000000, %r13d      # imm = 0x40000000
jmp 0xb88f
movq 0x8(%r14), %rax
xorl %ecx, %ecx
cmpb $0x5c, (%rax)
sete %cl
addq %rcx, %rax
incq %rax
movq %rax, 0x8(%r14)
notl %ecx
addl %ecx, 0x10(%r14)
movl $0x1, %r13d
xorl %r12d, %r12d
jmp 0xb8bc
movq 0x8(%r14), %rax
xorl %ecx, %ecx
cmpb $0x5c, (%rax)
sete %cl
addq %rcx, %rax
incq %rax
movq %rax, 0x8(%r14)
notl %ecx
addl %ecx, 0x10(%r14)
movl $0x40000000, %r13d      # imm = 0x40000000
movl $0x1, %r12d
movzbl 0x8(%rbx), %eax
cmpl $0x7, %eax
ja 0xb9c5
movl $0x98, %ecx
btl %eax, %ecx
jae 0xb9c5
movl %r12d, 0x18(%rbx)
movl %r13d, 0x1c(%rbx)
jmp 0xba3d
movl %ebp, 0x4(%rsp)
movq 0x8(%r14), %rax
xorl %ecx, %ecx
cmpb $0x5c, (%rax)
sete %cl
leaq (%rcx,%rax), %r13
incq %r13
movq %r13, 0x8(%r14)
notl %ecx
addl %ecx, 0x10(%r14)
callq 0x5040
movq %rax, 0x10(%rsp)
movl $0x0, (%rax)
leaq 0x8(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0x50b0
movq (%rbp), %rbp
movq %rbp, %rcx
subq %r13, %rcx
je 0xba32
movq %rax, %r12
movslq 0x10(%r14), %rax
cmpq %rax, %rcx
jge 0xba32
cmpb $0x2c, (%rbp)
jne 0xba0e
movzbl 0x1(%rbp), %ecx
incq %rbp
cmpl $0x7d, %ecx
je 0xb969
cmpl $0x5c, %ecx
jne 0xba77
movl $0x40000000, %r13d      # imm = 0x40000000
jmp 0xba11
movq 0x8(%r14), %rax
xorl %ecx, %ecx
cmpb $0x5c, (%rax)
sete %cl
addq %rcx, %rax
incq %rax
movq %rax, 0x8(%r14)
notl %ecx
addl %ecx, 0x10(%r14)
movl $0x20, %edi
callq 0x5170
movb $0xd, 0x8(%rax)
movq $0x0, 0x10(%rax)
leaq 0x72f3(%rip), %rcx      # 0x12ca0
movq %rcx, (%rax)
movq %rbx, 0x18(%rax)
testb $0x4, 0x1(%r14)
je 0xb9ff
movq %rax, %rdi
callq 0xc33a
jmp 0xba3b
movl $0x30, %edi
callq 0x5170
movb $0xc, 0x8(%rax)
movq $0x0, 0x10(%rax)
movl %r12d, 0x18(%rax)
movl %r13d, 0x1c(%rax)
leaq 0x7266(%rip), %rcx      # 0x12c50
movq %rcx, (%rax)
movl %r15d, 0x20(%rax)
movl %ebp, 0x24(%rax)
movq %rbx, 0x28(%rax)
testb $0x4, 0x1(%r14)
jne 0xba04
movq %rax, %rbx
jmp 0xba3d
movq %rax, %rdi
callq 0xc2e0
jmp 0xba3b
movq %r12, %r13
movq 0x8(%r14), %rcx
subq %rcx, %rbp
movslq %ebp, %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%r14)
subl %edx, %eax
movl %eax, 0x10(%r14)
movq 0x10(%rsp), %rax
cmpl $0x0, (%rax)
je 0xba4f
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x3fffffff, %r12       # imm = 0x3FFFFFFF
ja 0xba32
cmpq %r13, %r12
ja 0xba32
movb (%r14), %bpl
movq %r14, %rdi
callq 0xb15e
testb $0x1, %bpl
jne 0xbac4
cmpl $0x10c, %eax            # imm = 0x10C
jne 0xba32
jmp 0xbacd
leaq 0x8(%rsp), %rsi
movq %rbp, %rdi
movl $0xa, %edx
callq 0x50b0
movq %rax, %r13
leaq 0x8(%rsp), %rax
movq (%rax), %rcx
cmpq %rbp, %rcx
sete %al
cmpq $0x40000000, %r13       # imm = 0x40000000
setae %dl
orb %al, %dl
jne 0xba32
movq %rcx, %rdx
subq 0x8(%r14), %rdx
movslq 0x10(%r14), %rax
cmpq %rax, %rdx
jge 0xba32
movq %rcx, %rbp
jmp 0xba11
cmpl $0x7d, %eax
jne 0xba32
movq 0x8(%r14), %rax
xorl %ecx, %ecx
cmpb $0x5c, (%rax)
sete %cl
addq %rcx, %rax
incq %rax
movq %rax, 0x8(%r14)
notl %ecx
addl %ecx, 0x10(%r14)
movl 0x4(%rsp), %ebp
jmp 0xb8bc