// File: /workspace/github_cpp_makefile_star2_O1/davidgfnet[P]dns-db/dns_index.cc
// Function: DNS_DB::DnsIndex::addIp4Record(char const*, IPv4_Record const&)
void DNS_DB::DnsIndex::addIp4Record(const char * domain, const IPv4_Record & record) {
	char domint[MAX_DNS_SIZE];
	if (!domain2idom(domain, domint)) {
		fprintf(stderr, "Domain too long!\n");
		return;
	}

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

	if (!blk->addDomainIpv4(domint, record)) {
		// 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);

		bool r = blk->addDomainIpv4(domint, record);
		assert(r);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc0, %rsp
movq %rdx, %rbx
movq %rsi, %rax
movq %rdi, %r14
leaq 0x60(%rsp), %rsi
movq %rax, %rdi
callq 0x74c8
testb %al, %al
je 0x50e9
leaq 0x60(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x49d4
movq (%r14), %rcx
movq 0x18(%r14), %rsi
cltq
imulq $0x4a, %rax, %r13
movl 0x46(%rcx,%r13), %edx
movq %rsp, %r12
movq %r12, %rdi
callq 0x8060
movq (%r12), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x6a36
testb %al, %al
jne 0x50c9
movl 0x20(%r14), %r15d
leal 0x1(%r15), %eax
movl %eax, 0x20(%r14)
movq 0x18(%r14), %rsi
leaq 0x10(%rsp), %rdi
movl %r15d, %edx
callq 0x8060
movq (%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x6b34
movq (%r14), %rax
movl 0x42(%rax,%r13), %ecx
movl %ecx, 0xaf(%rsp)
movups 0x23(%rax,%r13), %xmm0
movups 0x33(%rax,%r13), %xmm1
movaps %xmm1, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x6cf4
leaq 0x30(%rsp), %rdx
leaq 0x90(%rsp), %rcx
movq %r14, %rdi
movl %r15d, %esi
callq 0x516a
movq (%r14), %rax
movl 0x4f(%rsp), %ecx
movl %ecx, 0x42(%rax,%r13)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x33(%rax,%r13)
movups %xmm0, 0x23(%rax,%r13)
leaq 0x60(%rsp), %rsi
movq %r14, %rdi
callq 0x49d4
movq (%r14), %rcx
movq 0x18(%r14), %rsi
cltq
imulq $0x4a, %rax, %rax
movl 0x46(%rcx,%rax), %edx
leaq 0x20(%rsp), %rdi
callq 0x8060
movaps 0x20(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x20(%rsp)
movq 0x8(%rsp), %rdi
movups %xmm0, (%rsp)
testq %rdi, %rdi
je 0x5096
callq 0x46de
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x50a5
callq 0x46de
movq (%rsp), %rdi
leaq 0x60(%rsp), %rsi
movq %rbx, %rdx
callq 0x6a36
testb %al, %al
je 0x50f0
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x50c9
callq 0x46de
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x50d8
callq 0x46de
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x35ef
jmp 0x50d8
leaq 0x5829(%rip), %rdi      # 0xa920
leaq 0x504c(%rip), %rsi      # 0xa14a
leaq 0x50d2(%rip), %rcx      # 0xa1d7
movl $0x9f, %edx
callq 0x3180
jmp 0x5117
jmp 0x5117
jmp 0x5117
jmp 0x512b
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x512e
callq 0x46de
jmp 0x512e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x513d
callq 0x46de
movq %rbx, %rdi
callq 0x3400
nop