// File: /workspace/github_cpp_makefile_star2_O2/davidgfnet[P]dns-db/dns_db.cc
// Function: DNS_DB::getNewBlock(int)
DNS_DB::DnsBlock * DNS_DB::getNewBlock(int blockid) {
	// Generate path in a hierachical way, to prevent many files in a directory
	// This should be beneficial on most file systems
	std::string filename = to_string(blockid,16);
	std::string dir1 = filename.substr(filename.size()-1,1) + "/";
	std::string dir2 = filename.substr(filename.size()-2,1) + "/";
	std::string blockfile = db_path + "/" + dir1 + dir2 + filename + ".blk";

	if (!FileMapper::getInstance().fileExists(blockfile)) {
		mkdir((db_path).c_str(),                           S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
		mkdir((db_path + "/" + dir1).c_str(),              S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
		mkdir((db_path + "/" + dir1 + "/" + dir2).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
	}

	return new DNS_DB::DnsBlock(blockfile, blockid);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movl %esi, %ebx
movq %rdi, %r14
leaq 0xe0(%rsp), %r15
pushq $0x10
popq %rdx
movq %r15, %rdi
callq 0x37fb
movq 0x8(%r15), %rdx
decq %rdx
leaq 0x40(%rsp), %rdi
pushq $0x1
popq %rcx
movq %r15, %rsi
callq 0x3280
leaq 0x5707(%rip), %rdx      # 0x900b
leaq 0xc0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x3e4b
leaq 0x40(%rsp), %rdi
callq 0x3100
leaq 0xe0(%rsp), %rsi
movq 0x8(%rsi), %rdx
addq $-0x2, %rdx
leaq 0x20(%rsp), %rdi
pushq $0x1
popq %rcx
callq 0x3280
leaq 0x56c7(%rip), %rdx      # 0x900b
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x3e4b
leaq 0x20(%rsp), %rdi
callq 0x3100
addq $0x68, %r14
leaq 0x56a3(%rip), %rdx      # 0x900b
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
callq 0x3daa
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x3ded
movq %rsp, %rdi
leaq 0x80(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x3ded
leaq 0xa0(%rsp), %rdi
movq %rsp, %rsi
leaq 0xe0(%rsp), %rdx
callq 0x3ded
leaq 0x564a(%rip), %rdx      # 0x900d
leaq 0x20(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x3e4b
leaq 0xa0(%rsp), %rdi
callq 0x3100
movq %rsp, %rdi
callq 0x3100
leaq 0x80(%rsp), %rdi
callq 0x3100
leaq 0x60(%rsp), %rdi
callq 0x3100
callq 0x3e6a
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x6eba
testb %al, %al
jne 0x3b0d
movq (%r14), %rdi
movl $0x1fd, %esi            # imm = 0x1FD
callq 0x3110
leaq 0x55dc(%rip), %rdx      # 0x900b
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3daa
leaq 0xa0(%rsp), %rdi
movq %rsp, %rsi
leaq 0xc0(%rsp), %rdx
callq 0x3ded
leaq 0xa0(%rsp), %r15
movq (%r15), %rdi
movl $0x1fd, %esi            # imm = 0x1FD
callq 0x3110
movq %r15, %rdi
callq 0x3100
movq %rsp, %rdi
callq 0x3100
leaq 0x558d(%rip), %rdx      # 0x900b
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
callq 0x3daa
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x3ded
leaq 0x555f(%rip), %rdx      # 0x900b
movq %rsp, %rdi
leaq 0x80(%rsp), %rsi
callq 0x3e4b
leaq 0xa0(%rsp), %rdi
movq %rsp, %rsi
leaq 0x40(%rsp), %rdx
callq 0x3ded
leaq 0xa0(%rsp), %r14
movq (%r14), %rdi
movl $0x1fd, %esi            # imm = 0x1FD
callq 0x3110
movq %r14, %rdi
callq 0x3100
movq %rsp, %rdi
callq 0x3100
leaq 0x80(%rsp), %rdi
callq 0x3100
leaq 0x60(%rsp), %rdi
callq 0x3100
pushq $0x28
popq %rdi
callq 0x3260
movq %rax, %r14
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
movl %ebx, %edx
callq 0x5800
leaq 0x20(%rsp), %rdi
callq 0x3100
leaq 0x40(%rsp), %rdi
callq 0x3100
leaq 0xc0(%rsp), %rdi
callq 0x3100
leaq 0xe0(%rsp), %rdi
callq 0x3100
movq %r14, %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3100
jmp 0x3b75
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x3100
jmp 0x3b87
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x3b96
jmp 0x3c0a
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3100
jmp 0x3c0d
jmp 0x3c0a
movq %rax, %rbx
movq %r14, %rdi
callq 0x3230
jmp 0x3c0d
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x3100
jmp 0x3bc1
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3100
jmp 0x3bce
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x3100
jmp 0x3be0
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x3c12
movq %rax, %rbx
jmp 0x3c17
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x3c1c
movq %rax, %rbx
jmp 0x3c21
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x3c29
movq %rax, %rbx
jmp 0x3c2e
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3100
leaq 0x40(%rsp), %rdi
callq 0x3100
leaq 0xc0(%rsp), %rdi
callq 0x3100
leaq 0xe0(%rsp), %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x3420
nop