// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x1148, %rsp           # imm = 0x1148
cmpl $0x1, %edi
jg 0x3729
movq (%rsi), %r14
movq 0xc937(%rip), %rdi      # 0xffd0
leaq 0x69cd(%rip), %rsi      # 0xa06d
callq 0x3290
pushq $0xa
popq %rbx
movq %rax, %rdi
movl %ebx, %esi
callq 0x3300
leaq 0x69bb(%rip), %rsi      # 0xa074
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
movq %r14, %rsi
callq 0x3290
leaq 0x69a3(%rip), %rsi      # 0xa076
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
movl %ebx, %esi
callq 0x3300
leaq 0x69a5(%rip), %rsi      # 0xa091
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
movl %ebx, %esi
callq 0x3300
leaq 0x69bb(%rip), %rsi      # 0xa0c0
movq %rax, %rdi
callq 0x3290
movq %rax, %rdi
movl %ebx, %esi
callq 0x3300
movq %rax, %rdi
movl %ebx, %esi
callq 0x3300
pushq $0x1
popq %rax
jmp 0x382d
movq 0x8(%rsi), %rsi
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0x387e
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x38ae
leaq 0x80(%rsp), %rax
leaq 0x58(%rsp), %rcx
movq %rax, (%rcx)
movq %rcx, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq $0x32, 0x30(%rsp)
leaq 0x68b5(%rip), %rdi      # 0xa02c
pushq $0x7
popq %rcx
movl $0x7d0, %esi            # imm = 0x7D0
xorl %edx, %edx
callq 0x916a
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x8974
leaq 0x38(%rsp), %rdi
callq 0x3d1e
leaq 0x6c24(%rip), %rax      # 0xa3cc
movl (%rax), %r9d
addl %r9d, %r9d
leaq 0x20(%rsp), %rax
leaq 0x38(%rsp), %rdx
movq %rax, 0x18(%rdx)
leaq 0x4(%rsp), %rax
movl %ebx, (%rax)
leaq 0x98(%rsp), %rcx
movq %rax, (%rcx)
movq $0x1, 0x8(%rcx)
leaq 0xa8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x1e
popq %r8
callq 0x38f4
leaq 0x38(%rsp), %rdi
callq 0x3cea
leaq 0x8(%rsp), %rdi
callq 0x89d4
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3a0c
testb %al, %al
jne 0x3808
leaq 0xa8(%rsp), %rdi
callq 0x3ada
leaq 0x60(%rsp), %rdi
callq 0x3b3c
xorl %eax, %eax
addq $0x1148, %rsp           # imm = 0x1148
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3cea
jmp 0x384a
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x89d4
jmp 0x386b
movq %rax, %rbx
jmp 0x386b
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x3ada
leaq 0x60(%rsp), %rdi
callq 0x3b3c
movq %rbx, %rdi
callq 0x3460
nop