// File: /workspace/github_cpp_makefile_star2_O2/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 0x6a68
testb %al, %al
je 0x4c74
leaq 0x60(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4254
movq (%rbx), %rcx
movq 0x18(%rbx), %rsi
cltq
imulq $0x4a, %rax, %r12
movl 0x46(%rcx,%r12), %edx
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x7510
movq (%r15), %rdi
movq %r14, %rsi
callq 0x5c98
movl %eax, %ebp
cmpl $0x1, %eax
jne 0x4c68
movl 0x20(%rbx), %r14d
leal 0x1(%r14), %eax
movl %eax, 0x20(%rbx)
movq 0x18(%rbx), %rsi
movq %rsp, %rdi
movl %r14d, %edx
callq 0x7510
movq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movq %rsp, %rdx
callq 0x61e2
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 (%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x6342
leaq 0x30(%rsp), %rdx
leaq 0x90(%rsp), %rcx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x497e
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 0x4254
movq (%rbx), %rcx
movq 0x18(%rbx), %rsi
cltq
imulq $0x4a, %rax, %rax
movl 0x46(%rcx,%rax), %edx
leaq 0x20(%rsp), %rdi
callq 0x7510
leaq 0x10(%rsp), %rbx
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x507e
leaq 0x28(%rsp), %rdi
callq 0x3f74
movq (%rbx), %rdi
leaq 0x60(%rsp), %rsi
callq 0x5c98
movl %eax, %ebp
cmpl $0x1, %eax
je 0x4c89
leaq 0x8(%rsp), %rdi
callq 0x3f74
leaq 0x18(%rsp), %rdi
callq 0x3f74
jmp 0x4c77
pushq $0x3
popq %rbp
movl %ebp, %eax
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x455e(%rip), %rdi      # 0x91ee
leaq 0x4483(%rip), %rsi      # 0x911a
leaq 0x4566(%rip), %rcx      # 0x9204
movl $0xce, %edx
callq 0x31a0
jmp 0x4cb3
jmp 0x4cb3
jmp 0x4cae
movq %rax, %rbx
jmp 0x4cc0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3f74
leaq 0x18(%rsp), %rdi
callq 0x3f74
movq %rbx, %rdi
callq 0x3420