// File: arnoldrobbins[P]mcilroy-regex/re2.cpp
// Function: regcomp
int
regcomp(regex_t *preg, const char *pattern, int cflags)
{
	preg->rex = 0;
	if(Done::done==0 && (Done::done=new Done)==0)
		return REG_ESPACE;
	if(cflags & REG_AUGMENTED)
		cflags |= REG_EXTENDED;
	cflags &= CFLAGS|GFLAGS;
	Cenv env(pattern, cflags);
	if(env.flags&SPACE)
		return REG_ESPACE;

	preg->rex = regAlt(1, &env);
	cflags |= special(preg, &env);
	if(preg->rex == ERROR)
		return env.flags&SPACE? REG_ESPACE: REG_BADPAT;

	preg->rex->serialize(1);
	Stat st = preg->rex->stat(&env);
	if(st.o) {
		regfree(preg);
		return REG_ESPACE;
	}
	cflags |= hard(&st);
	if(cflags & REG_ANCH)
		cflags |= ONCE;
	preg->flags = cflags;
	preg->re_nsub = st.p;
	preg->map = env.map;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
movq 0xa677(%rip), %rax      # 0x18300
movb $0x0, -0x29(%rbp)
cmpq $0x0, %rax
jne 0xdd00
movl $0x18, %edi
callq 0x51a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movq %rdi, -0x28(%rbp)
movb $0x1, -0x29(%rbp)
callq 0x10170
jmp 0xdcb9
movq -0xb8(%rbp), %rax
movq %rax, 0xa639(%rip)      # 0x18300
cmpq $0x0, %rax
jne 0xdd00
movl $0xc, -0x4(%rbp)
jmp 0xde8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
testb $0x1, -0x29(%rbp)
jne 0xdced
jmp 0xdcfb
movq -0x28(%rbp), %rdi
movl $0x18, %esi
callq 0x51b0
jmp 0xde99
movl -0x1c(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0xdd16
movl -0x1c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl $0x3cf, %eax            # imm = 0x3CF
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
leaq -0x90(%rbp), %rdi
callq 0xce60
movl -0x90(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0xdd50
movl $0xc, -0x4(%rbp)
jmp 0xde8d
movl $0x1, %edi
leaq -0x90(%rbp), %rsi
callq 0xdeb0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xe060
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpq 0xa77f(%rip), %rax      # 0x18510
jne 0xddb7
movl -0x90(%rbp), %edx
andl $0x400, %edx            # imm = 0x400
movl $0x2, %eax
movl $0xc, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xde8d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
movl $0x1, %esi
callq *%rax
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
leaq -0x90(%rbp), %rsi
callq *%rax
movq %rdx, -0xa8(%rbp)
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0x98(%rbp)
movw -0xa4(%rbp), %ax
movw %ax, -0x94(%rbp)
cmpb $0x0, -0x93(%rbp)
je 0xde36
movq -0x10(%rbp), %rdi
callq 0xe2c0
movl $0xc, -0x4(%rbp)
jmp 0xde8d
leaq -0xa0(%rbp), %rdi
callq 0xd900
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xde60
movl -0x1c(%rbp), %eax
orl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movzbl -0x94(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x52d0
nopw %cs:(%rax,%rax)