// File: /workspace/github_cpp_makefile_star2_O3/nmmmnu[P]HM3/main/db_net.cc
// Function: main
int main(int argc, char **argv){
	constexpr const char	*HOSTNAME		= "localhost.not.used.yet";
	constexpr int		PORT			= 2000;

	constexpr size_t	MAX_CLIENTS		= 1024;
	constexpr uint32_t	CONNECTION_TIMEOUT	= 30;
	const     size_t	MAX_PACKET_SIZE		= hm3::Pair::MAX_SIZE * 2;

	// ----------------------------------

	if (argc <= 1){
		printUsage(argv[0]);
		return 1;
	}

	const auto path = argv[1];

	// ----------------------------------

	using MyTableLoader	= hm3::tableloader::DirectoryTableLoader;
	using MyLSMTable	= hm3::LSMTable<MyTableLoader::container_type>;

	MyTableLoader loader{ path };
	MyLSMTable list(*loader);

	// ----------------------------------

	using MyAdapter = DBAdapter<MyLSMTable, MyTableLoader>;
	MyAdapter adapter(list, loader);

	// ----------------------------------

	using MySelector	= net::selector::PollSelector;
	using MyProtocol	= net::protocol::RedisProtocol;
	using MyWorker		= net::worker::KeyValueWorker<MyProtocol, MyAdapter>;

	using MyLoop		= net::AsyncLoop<MySelector, MyWorker>;

	int const fd1 = net::socket_create(net::SOCKET_TCP{}, HOSTNAME, PORT);

	MyLoop loop( MySelector{ MAX_CLIENTS }, MyWorker{ adapter }, { fd1 },
							CONNECTION_TIMEOUT, MAX_PACKET_SIZE);

	while(loop.process());
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x1150, %rsp           # imm = 0x1150
cmpl $0x1, %edi
jg 0x3766
movq (%rsi), %r14
movq 0xb8ca(%rip), %rbx      # 0xefd0
leaq 0x6960(%rip), %rsi      # 0xa06d
movl $0x6, %edx
movq %rbx, %rdi
callq 0x32d0
leaq 0xb0(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rbx, %rdi
callq 0x32d0
movq %rax, %rbx
leaq 0x6938(%rip), %rsi      # 0xa074
movl $0x1, %edx
movq %rax, %rdi
callq 0x32d0
testq %r14, %r14
je 0x3780
movq %r14, %rdi
callq 0x3110
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x32d0
jmp 0x3799
movq 0x8(%rsi), %rbx
testq %rbx, %rbx
je 0x3851
movq %rbx, %rdi
callq 0x3110
jmp 0x385a
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %rbx, %rdi
addq %rax, %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x3400
leaq 0x68d6(%rip), %rsi      # 0xa076
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x32d0
movb $0xa, %bpl
leaq 0xb0(%rsp), %r14
movb %bpl, (%r14)
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32d0
movq %rax, %rbx
leaq 0x68bc(%rip), %rsi      # 0xa091
movl $0x2e, %edx
movq %rax, %rdi
callq 0x32d0
movb %bpl, (%r14)
leaq 0xb0(%rsp), %r14
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32d0
movq %rax, %rbx
leaq 0x68b9(%rip), %rsi      # 0xa0c0
movl $0x1c, %edx
movq %rax, %rdi
callq 0x32d0
movb %bpl, (%r14)
leaq 0xb0(%rsp), %r14
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32d0
movb %bpl, (%r14)
leaq 0xb0(%rsp), %rsi
movl $0x1, %edx
movq %rax, %rdi
callq 0x32d0
movl $0x1, %eax
jmp 0x3980
leaq 0x681d(%rip), %rbx      # 0xa075
xorl %eax, %eax
leaq 0xb0(%rsp), %rsi
movq %rax, (%rsi)
movq %rbx, 0x8(%rsi)
leaq 0x68(%rsp), %r14
movq %r14, %rdi
callq 0x39de
leaq 0x88(%rsp), %rbx
leaq 0x60(%rsp), %rax
movq %rbx, (%rax)
movq %rax, 0x48(%rsp)
movq %r14, 0x50(%rsp)
movq $0x32, 0x58(%rsp)
leaq 0x678c(%rip), %rdi      # 0xa02c
movl $0x7d0, %esi            # imm = 0x7D0
xorl %edx, %edx
movl $0x7, %ecx
callq 0x9d71
movl %eax, %ebp
leaq 0x30(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x9244
leaq 0x10(%rsp), %rdi
callq 0x3e38
leaq 0x6af9(%rip), %rax      # 0xa3cc
movl (%rax), %r9d
addl %r9d, %r9d
leaq 0x48(%rsp), %rax
leaq 0x10(%rsp), %rdx
movq %rax, 0x18(%rdx)
leaq 0xc(%rsp), %rax
movl %ebp, (%rax)
leaq 0xa0(%rsp), %rcx
movq %rax, (%rcx)
movq $0x1, 0x8(%rcx)
leaq 0xb0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl $0x1e, %r8d
callq 0x3a50
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3930
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3290
leaq 0x30(%rsp), %rdi
callq 0x94b0
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
callq 0x3b96
testb %al, %al
jne 0x3942
leaq 0xb0(%rsp), %rdi
callq 0x3c7a
movq %rbx, %rdi
callq 0x3d10
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x397e
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3290
xorl %eax, %eax
addq $0x1150, %rsp           # imm = 0x1150
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x39ab
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3290
jmp 0x39ab
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x94b0
jmp 0x39cc
movq %rax, %rbx
jmp 0x39cc
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x3c7a
leaq 0x68(%rsp), %rdi
callq 0x3ce8
movq %rbx, %rdi
callq 0x3420