// File: arnoldrobbins[P]mcilroy-regex/re2.cpp
// Function: regbra(Cenv*)
static Rex*			// bracket expression
regbra(Cenv *env)
{
	Class *r = (Class*)NEW(Class);
	Set set;
	int c, i, neg, last, inrange, init;
	neg = 0;
	if(env->cursor.n>0 && *env->cursor.p=='^') {
		env->cursor.next();
		neg = 1;
	}
	if(env->cursor.n < 2)
		goto error;
	inrange = 0;	// 0=no, 1=possibly, 2=definitely
	for(init=1; ; init=0) {
		if(env->cursor.n <= 0)
			goto error;
		c = *env->cursor.p;
		env->cursor.next();
		if(c == ']') {
			if(init) {
				last = c;
				inrange = 1;
				continue;
			}
			if(inrange != 0)
				set.insert(last);
			if(inrange == 2)
				set.insert('-');
			break;
		} else if(c == '-') {
			if(inrange == 0 && !init)
				goto error;
			if(inrange == 1) {
				inrange = 2;
				continue;
			}
		} else if(c == '[') {
			if(env->cursor.n < 2)
				goto error;
			c = *env->cursor.p;
			switch(c) {
			case ':':
				env->cursor.next();
				if(inrange == 1)
					set.insert(last);
				if(!getcharcl(c, &set, env))
					goto error;
				inrange = 0;
				continue;
			case '=':
				env->cursor.next();
				if(inrange == 2)
					goto error;
				if(inrange == 1)
					set.insert(last);
				i = findcollelem(c, env);
				if(i == -1)
					goto error;
				set.insert(i);
				inrange = 0;
				continue;
			case '.':
				env->cursor.next();
				c = findcollelem(c, env);
				if(c == -1)
					goto error;
				break;
			default:
				c = '[';
			}
		}
		if(inrange == 2) {
			if(last > c)
				goto error;
			for(i=last; i<=c; i++)
				set.insert(i);
			inrange = 0;
		} else if(inrange == 1)
			set.insert(last);
		else
			inrange = 1;
		last = c;
	}
	r->orset(&set);
	r->icase(env->map);
	if(neg)
		r->neg(env->flags);
	return r;
error:
	delete r;
	return ERROR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl $0x40, %edi
callq 0x51a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x68(%rbp)
callq 0x10a30
jmp 0xf84a
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xd030
movq %rax, -0x18(%rbp)
leaq -0x44(%rbp), %rdi
callq 0x10aa0
movl $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0xf8bf
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
cmpl $0x5e, %eax
jne 0xf8bf
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0x10990
movl $0x1, -0x50(%rbp)
jmp 0xf8bf
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x40, %esi
callq 0x51b0
jmp 0xfba6
movq -0x10(%rbp), %rax
cmpl $0x2, 0x10(%rax)
jge 0xf8ce
jmp 0xfb76
movl $0x0, -0x58(%rbp)
movl $0x1, -0x5c(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jg 0xf8eb
jmp 0xfb76
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0x10990
cmpl $0x5d, -0x48(%rbp)
jne 0xf957
cmpl $0x0, -0x5c(%rbp)
je 0xf929
movl -0x48(%rbp), %eax
movl %eax, -0x54(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0xfb2d
cmpl $0x0, -0x58(%rbp)
je 0xf93e
movl -0x54(%rbp), %eax
leaq -0x44(%rbp), %rdi
movzbl %al, %esi
callq 0x93a0
cmpl $0x2, -0x58(%rbp)
jne 0xf952
leaq -0x44(%rbp), %rdi
movl $0x2d, %esi
callq 0x93a0
jmp 0xfb39
cmpl $0x2d, -0x48(%rbp)
jne 0xf985
cmpl $0x0, -0x58(%rbp)
jne 0xf96e
cmpl $0x0, -0x5c(%rbp)
jne 0xf96e
jmp 0xfb76
cmpl $0x1, -0x58(%rbp)
jne 0xf980
movl $0x2, -0x58(%rbp)
jmp 0xfb2d
jmp 0xfac1
cmpl $0x5b, -0x48(%rbp)
jne 0xfabf
movq -0x10(%rbp), %rax
cmpl $0x2, 0x10(%rax)
jge 0xf99e
jmp 0xfb76
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x6c(%rbp)
subl $0x2e, %eax
je 0xfa88
jmp 0xf9bd
movl -0x6c(%rbp), %eax
subl $0x3a, %eax
je 0xf9d4
jmp 0xf9c7
movl -0x6c(%rbp), %eax
subl $0x3d, %eax
je 0xfa21
jmp 0xfab6
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0x10990
cmpl $0x1, -0x58(%rbp)
jne 0xf9fb
movl -0x54(%rbp), %eax
leaq -0x44(%rbp), %rdi
movzbl %al, %esi
callq 0x93a0
movl -0x48(%rbp), %edi
movq -0x10(%rbp), %rdx
leaq -0x44(%rbp), %rsi
callq 0xfbb0
cmpl $0x0, %eax
jne 0xfa15
jmp 0xfb76
movl $0x0, -0x58(%rbp)
jmp 0xfb2d
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0x10990
cmpl $0x2, -0x58(%rbp)
jne 0xfa3e
jmp 0xfb76
cmpl $0x1, -0x58(%rbp)
jne 0xfa53
movl -0x54(%rbp), %eax
leaq -0x44(%rbp), %rdi
movzbl %al, %esi
callq 0x93a0
movl -0x48(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xfd00
movl %eax, -0x4c(%rbp)
cmpl $-0x1, -0x4c(%rbp)
jne 0xfa6d
jmp 0xfb76
movl -0x4c(%rbp), %eax
leaq -0x44(%rbp), %rdi
movzbl %al, %esi
callq 0x93a0
movl $0x0, -0x58(%rbp)
jmp 0xfb2d
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0x10990
movl -0x48(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xfd00
movl %eax, -0x48(%rbp)
cmpl $-0x1, -0x48(%rbp)
jne 0xfab4
jmp 0xfb76
jmp 0xfabd
movl $0x5b, -0x48(%rbp)
jmp 0xfabf
jmp 0xfac1
jmp 0xfac3
cmpl $0x2, -0x58(%rbp)
jne 0xfb07
movl -0x54(%rbp), %eax
cmpl -0x48(%rbp), %eax
jle 0xfad6
jmp 0xfb76
movl -0x54(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x48(%rbp), %eax
jg 0xfafe
movl -0x4c(%rbp), %eax
leaq -0x44(%rbp), %rdi
movzbl %al, %esi
callq 0x93a0
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xfadc
movl $0x0, -0x58(%rbp)
jmp 0xfb27
cmpl $0x1, -0x58(%rbp)
jne 0xfb1e
movl -0x54(%rbp), %eax
leaq -0x44(%rbp), %rdi
movzbl %al, %esi
callq 0x93a0
jmp 0xfb25
movl $0x1, -0x58(%rbp)
jmp 0xfb27
movl -0x48(%rbp), %eax
movl %eax, -0x54(%rbp)
movl $0x0, -0x5c(%rbp)
jmp 0xf8dc
movq -0x18(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x9a90
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x9b00
cmpl $0x0, -0x50(%rbp)
je 0xfb6c
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %esi
callq 0x9ac0
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xfb99
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
je 0xfb8e
movq -0x78(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x897b(%rip), %rax      # 0x18510
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x52d0
nop