// File: /workspace/github_cpp_makefile_star2_O3/davidgfnet[P]dns-db/dns_index.cc
// Function: DNS_DB::DnsIndex::addDomain(char const*)
DNS_DB::queryError DNS_DB::DnsIndex::addDomain(const char * domain) {
	char domint[MAX_DNS_SIZE];
	if (!domain2idom(domain, domint))
		return resDomainTooLong;

	int n = lookupNode(domint);
	DNS_DB::DnsBlockPtr blk = database->getBlock(nodes[n].dnsblock_id);

	queryError res = blk->addDomain(domint);

	if (res == resNoSpaceLeft) {
		// Ops, just split the Block in two, must be full
		unsigned int nwblk_id = this->current_id++;
		DnsBlockPtr newblk = database->getBlock(nwblk_id);
		blk->splitBlock(domint, newblk);

		char nodemax[MAX_DNS_SIZE];
		char dommax [MAX_DNS_SIZE];
		getBlkMax(n, nodemax);
		newblk->getMinDomain(dommax);

		// Set new block boundaries
		addBlock(nwblk_id, dommax, nodemax);

		// Just recalculate the max for the other block
		setBlkMinMax(n, 0, dommax);

		// Redo
		n = lookupNode(domint);
		blk = database->getBlock(nodes[n].dnsblock_id);

		res = blk->addDomain(domint);
		assert(res != resNoSpaceLeft);
	}

	// Make sure the blog minimum is consistent
	#ifdef EXTRA_CHECK
	char tmpd[MAX_DNS_SIZE];
	blk->getIterator(database, 0).getDomain(tmpd);
	assert(less_eq(nodes[n].min, tmpd));

	// Make sure it is allright
	char prev[MAX_DNS_SIZE] = {0};
	DnsBlock::Iterator it = blk->getIterator(database, 0);
	while (!it.end()) {
		char curr[MAX_DNS_SIZE];
		it.getDomain(curr);
		assert(less_eq(prev, curr));
		memcpy(prev,curr,MAX_DNS_SIZE);
		it.next();
	}
	#endif

	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xc0, %rsp
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x60(%rsp), %rsi
movq %rax, %rdi
callq 0x73ac
movl $0x3, %ebp
testb %al, %al
je 0x570d
leaq 0x60(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4928
movq (%rbx), %rcx
movq 0x18(%rbx), %rsi
cltq
imulq $0x4a, %rax, %r12
movl 0x46(%rcx,%r12), %edx
movq %rsp, %r15
movq %r15, %rdi
callq 0x7e88
movq (%r15), %rdi
movq %r14, %rsi
callq 0x6540
movl %eax, %ebp
cmpl $0x1, %eax
jne 0x56fe
movl 0x20(%rbx), %r14d
leal 0x1(%r14), %eax
movl %eax, 0x20(%rbx)
movq 0x18(%rbx), %rsi
leaq 0x10(%rsp), %rdi
movl %r14d, %edx
callq 0x7e88
movq (%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x6a76
movq (%rbx), %rax
movl 0x42(%rax,%r12), %ecx
movl %ecx, 0xaf(%rsp)
movups 0x23(%rax,%r12), %xmm0
movups 0x33(%rax,%r12), %xmm1
movaps %xmm1, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x6bcc
leaq 0x30(%rsp), %rdx
leaq 0x90(%rsp), %rcx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x50e4
movq (%rbx), %rax
movl 0x4f(%rsp), %ecx
movl %ecx, 0x42(%rax,%r12)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x33(%rax,%r12)
movups %xmm0, 0x23(%rax,%r12)
leaq 0x60(%rsp), %rsi
movq %rbx, %rdi
callq 0x4928
movq (%rbx), %rcx
movq 0x18(%rbx), %rsi
cltq
imulq $0x4a, %rax, %rax
movl 0x46(%rcx,%rax), %edx
leaq 0x20(%rsp), %rdi
callq 0x7e88
movaps 0x20(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x20(%rsp)
movq 0x8(%rsp), %rdi
movaps %xmm0, (%rsp)
testq %rdi, %rdi
je 0x56da
callq 0x4628
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x56da
callq 0x4628
movq (%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x6540
movl %eax, %ebp
cmpl $0x1, %eax
je 0x571f
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x56fe
callq 0x4628
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x570d
callq 0x4628
movl %ebp, %eax
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4af8(%rip), %rdi      # 0xa21e
leaq 0x4a1d(%rip), %rsi      # 0xa14a
leaq 0x4b00(%rip), %rcx      # 0xa234
movl $0xce, %edx
callq 0x3180
jmp 0x5749
jmp 0x5749
jmp 0x5744
movq %rax, %rbx
jmp 0x575b
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x575b
callq 0x4628
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x576a
callq 0x4628
movq %rbx, %rdi
callq 0x3400