// File: /workspace/github_cpp_makefile_star2_O1/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 0xb8df
movq %rcx, %r14
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
movq %rcx, %rdi
callq 0xafe8
addl $0xfffffefa, %eax       # imm = 0xFFFFFEFA
cmpl $0xa, %eax
ja 0xb8e1
leaq 0x1e19(%rip), %rcx      # 0xd504
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 0xb73a
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 0xb767
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 0xb898
movl $0x98, %ecx
btl %eax, %ecx
jae 0xb898
movl %r12d, 0x18(%rbx)
movl %r13d, 0x1c(%rbx)
jmp 0xb8e1
movl %ebp, 0xc(%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)
movq %rsp, %rbp
movq %r13, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0x50b0
movq %rax, %r12
movq (%rbp), %rbp
movq %rbp, %rax
subq %r13, %rax
je 0xb839
movslq 0x10(%r14), %rcx
cmpq %rcx, %rax
jge 0xb839
cmpb $0x2c, (%rbp)
movq %r12, %r13
jne 0xb813
movzbl 0x1(%rbp), %eax
incq %rbp
cmpl $0x7d, %eax
je 0xb809
cmpl $0x5c, %eax
jne 0xb927
movq %rbp, (%rsp)
movl $0x40000000, %r13d      # imm = 0x40000000
movq (%rsp), %rax
movq 0x8(%r14), %rcx
subq %rcx, %rax
cltq
addq %rax, %rcx
movq %rcx, 0x8(%r14)
subl %eax, 0x10(%r14)
movq 0x10(%rsp), %rax
cmpl $0x0, (%rax)
je 0xb8f3
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
jmp 0xb8df
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 0x7420(%rip), %rcx      # 0x12ca0
movq %rcx, (%rax)
movq %rbx, 0x18(%rax)
testb $0x4, 0x1(%r14)
je 0xb8d2
movq %rax, %rdi
callq 0xc1d6
jmp 0xb8df
movl $0x30, %edi
callq 0x5170
movb $0xc, 0x8(%rax)
movq $0x0, 0x10(%rax)
movl %r12d, 0x18(%rax)
movl %r13d, 0x1c(%rax)
leaq 0x7393(%rip), %rcx      # 0x12c50
movq %rcx, (%rax)
movl %r15d, 0x20(%rax)
movl %ebp, 0x24(%rax)
movq %rbx, 0x28(%rax)
testb $0x4, 0x1(%r14)
jne 0xb8d7
movq %rax, %rbx
jmp 0xb8e1
movq %rax, %rdi
callq 0xc17c
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 0xb839
cmpq %r13, %r12
ja 0xb839
movb (%r14), %bpl
movq %r14, %rdi
callq 0xafe8
testb $0x1, %bpl
jne 0xb96e
cmpl $0x10c, %eax            # imm = 0x10C
jne 0xb839
jmp 0xb977
movq %rsp, %rsi
movq %rbp, %rdi
movl $0xa, %edx
callq 0x50b0
movq %rax, %r13
movq %rsp, %rax
movq (%rax), %rax
cmpq %rbp, %rax
sete %cl
cmpq $0x40000000, %r13       # imm = 0x40000000
setae %dl
orb %cl, %dl
jne 0xb839
subq 0x8(%r14), %rax
movslq 0x10(%r14), %rcx
cmpq %rcx, %rax
jl 0xb813
jmp 0xb839
cmpl $0x7d, %eax
jne 0xb839
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 0xc(%rsp), %ebp
jmp 0xb767