// File: arnoldrobbins[P]mcilroy-regex/re1.cpp
// Function: Trie::insert(unsigned char*)
int Trie::insert(uchar *s)
{
	int len;
	Tnode *node = root[*s&MASK];
	if(node == 0)
		node = root[*s&MASK] = new Tnode(*s);
	for(len=1; ; ) {
		if(node == 0)
			return 1;
		if(node->c == *s) {
			if(s[1] == 0)
				break;
			if(node->son == 0)
				node->son = new Tnode(s[1]);
			node = node->son;
			len++;
			s++;
		} else {
			if(node->sib == 0)
				node->sib = new Tnode(*s);
			node = node->sib;
		}	
	}
	if(len < min)
		min = len;
	else if(len > max)
		max = len;
	node->end = 1;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rcx
movzbl (%rcx), %ecx
andl $0xff, %ecx
movslq %ecx, %rcx
movq 0x20(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xa33c
movl $0x18, %edi
callq 0x51a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movzbl (%rax), %esi
callq 0xbfa0
jmp 0xa2fa
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rdx
movzbl (%rdx), %edx
andl $0xff, %edx
movslq %edx, %rdx
movq %rax, 0x20(%rcx,%rdx,8)
movq %rax, -0x28(%rbp)
jmp 0xa33c
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x18, %esi
callq 0x51b0
jmp 0xa4ac
movl $0x1, -0x1c(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xa356
movl $0x1, -0x4(%rbp)
jmp 0xa4a3
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
movq -0x18(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0xa3fc
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0xa37e
jmp 0xa464
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xa3d9
movl $0x18, %edi
callq 0x51a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %esi
callq 0xbfa0
jmp 0xa3ac
movq -0x50(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xa3d9
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x18, %esi
callq 0x51b0
jmp 0xa4ac
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xa45f
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xa453
movl $0x18, %edi
callq 0x51a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movzbl (%rax), %esi
callq 0xbfa0
jmp 0xa429
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xa453
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x18, %esi
callq 0x51b0
jmp 0xa4ac
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xa343
movq -0x40(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x18(%rcx), %eax
jge 0xa47c
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, 0x18(%rax)
jmp 0xa494
movq -0x40(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x1c(%rcx), %eax
jle 0xa492
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, 0x1c(%rax)
jmp 0xa494
movq -0x28(%rbp), %rax
movb $0x1, 0x1(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x52d0
nopw %cs:(%rax,%rax)