// File: /workspace/github_cpp_makefile_star2_O3/metopa[P]HTTP_Server/src/main.cpp
// Function: main
int main( int argc, char * argv[] ) {
	try {
		signalNS::blockSignals();
		signalNS::setEmptyHandler( SIGUSR1 );

		config.load( argc, argv );
		Log.init( config.getLogFile() );
		Log.welcome();
		Log.options();

		CThreadSafeQueue<CRequest *, nullptr> queue( config.getPortCount() );

		CRunnable::ptr_t signalHandler( new CSignalThread( &queue ) );

		vector<CRunnable::ptr_t> ports;
		for ( unsigned int i = 0; i < config.getPortCount(); i++ ) {
			try {
				ports.push_back( CRunnable::ptr_t( new CPortThread( i, config.getPorts()[i].c_str(), 10, &queue ) ) );
				Log.ger<>( NETWORK, "Port", config.getPorts()[i], "obtained" );
			}
			catch ( PortInitializationException& e ) {
				queue.notifyProducerStopped();
				Log.ger<>( CRITICAL, e );
			}
		}

		vector<CRunnable::ptr_t> workers;
		for ( unsigned int i = 0; i < config.getWorkerCount(); i++ )
			workers.push_back( CRunnable::ptr_t( new CWorkerThread( i, config.getWorkDir().c_str(), &queue ) ) );

		CThreadPool sigThread( signalHandler );
		CThreadPool portThreads( ports.begin(), ports.end() );
		CThreadPool workerThreads( workers.begin(), workers.end() );

		Log.ger<>( CRITICAL, "Server started" );

		workerThreads.join();
		portThreads.stop();
		sigThread.stop();
		Log.ger<>( CRITICAL, "Server stoped" );
	}
	catch ( GeneralException& e ) {
		Log.ger<>( CRITICAL, e );
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
movq %rsi, %rbx
movl %edi, %ebp
callq 0x16412
movl $0xa, %edi
callq 0x16482
leaq 0x113f0(%rip), %rdi     # 0x224c0
movl %ebp, %esi
movq %rbx, %rdx
callq 0x5b76
leaq 0x113df(%rip), %rdi     # 0x224c0
callq 0x6824
leaq 0x114d3(%rip), %rdi     # 0x225c0
movq %rax, %rsi
callq 0x1091a
leaq 0x114c4(%rip), %rdi     # 0x225c0
callq 0x10b5a
leaq 0x114b8(%rip), %rdi     # 0x225c0
callq 0x10cc8
leaq 0x113ac(%rip), %rdi     # 0x224c0
callq 0x6810
leaq 0xa8(%rsp), %rdi
movq %rax, %rsi
callq 0x115ee
movl $0x10, %edi
callq 0x53e0
movq %rax, %rbx
leaq 0xa8(%rsp), %rsi
movq %rax, %rdi
callq 0x16c2c
leaq 0x78(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq %rbx, %rsi
callq 0x11f4e
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %r15
movaps %xmm0, (%r15)
movq $0x0, 0x10(%r15)
xorl %r13d, %r13d
leaq 0x11348(%rip), %rbp     # 0x224c0
leaq 0x76f7(%rip), %r14      # 0x18876
movq %rbp, %rdi
callq 0x6810
movl %r13d, %r13d
cmpq %r13, %rax
jbe 0x1129d
movl $0x30, %edi
callq 0x53e0
movq %rax, %rbx
movq %rbp, %rdi
callq 0x680a
movq (%rax), %rax
movq %r13, %r12
shlq $0x5, %r12
movq (%rax,%r12), %rdx
movq %rbx, %rdi
movl %r13d, %esi
movl $0xa, %ecx
leaq 0xa8(%rsp), %r8
callq 0x164c4
movq %rbx, 0x20(%rsp)
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x11fec
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1208a
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x111fc
callq 0x11ede
movq %rbp, %rdi
callq 0x680a
addq (%rax), %r12
leaq 0x113b2(%rip), %rdi     # 0x225c0
movl $0x4, %esi
leaq 0x7657(%rip), %rdx      # 0x18871
movq %r12, %rcx
movq %r14, %r8
callq 0x11674
incl %r13d
jmp 0x1117f
movq %rdx, %rbx
movq %rax, %r12
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x11261
callq 0x11ede
jmp 0x11261
jmp 0x11246
movq %rdx, %rbx
movq %rax, %r12
jmp 0x11261
movq %rax, %r12
movl $0x30, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x53f0
cmpl $0x2, %ebx
jne 0x11582
movq %r12, %rdi
callq 0x51e0
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x117ee
leaq 0x11337(%rip), %rdi     # 0x225c0
movl $0x1, %esi
movq %rbx, %rdx
callq 0x1184e
callq 0x56a0
jmp 0x11225
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rbx
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
xorl %ebp, %ebp
leaq 0x11207(%rip), %r15     # 0x224c0
leaq 0xa8(%rsp), %r12
leaq 0x8(%rsp), %r13
movq %r15, %rdi
callq 0x682a
movl %ebp, %ecx
cmpq %rcx, %rax
jbe 0x1132a
movl $0x20, %edi
callq 0x53e0
movq %rax, %r14
movq %r15, %rdi
callq 0x681e
movq (%rax), %rdx
movq %r14, %rdi
movl %ebp, %esi
movq %r12, %rcx
callq 0x170a4
movq %r14, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x12240
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1208a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x11326
callq 0x11ede
incl %ebp
jmp 0x112c6
leaq 0x58ef(%rip), %rdx      # 0x16c20
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x1194e
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x50(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x58b9(%rip), %rcx      # 0x16c20
leaq 0x58(%rsp), %rdi
callq 0x11a3c
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
leaq 0x50(%rsp), %rsi
movq %rax, (%rsi)
leaq 0xa0(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x588b(%rip), %rcx      # 0x16c20
leaq 0x38(%rsp), %rdi
callq 0x11a3c
leaq 0x1121a(%rip), %rdi     # 0x225c0
leaq 0x74d2(%rip), %rdx      # 0x1887f
movl $0x1, %esi
callq 0x11b4c
leaq 0x38(%rsp), %rdi
callq 0x16f44
leaq 0x58(%rsp), %rdi
movl $0xa, %esi
callq 0x16fda
leaq 0x8(%rsp), %rdi
movl $0xa, %esi
callq 0x16fda
leaq 0x111da(%rip), %rdi     # 0x225c0
leaq 0x74a1(%rip), %rdx      # 0x1888e
movl $0x1, %esi
callq 0x11c58
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x1140e
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x11425
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1143c
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
leaq 0x20(%rsp), %rdi
callq 0x11d64
leaq 0x80(%rsp), %rdi
callq 0x11d64
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x11462
callq 0x11ede
leaq 0x418(%rsp), %rdi
callq 0x17b72
leaq 0x3f8(%rsp), %rdi
callq 0x17b72
leaq 0x3d0(%rsp), %rdi
callq 0x17b48
xorl %eax, %eax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %rbx
movq %rax, %r12
callq 0x56a0
jmp 0x11582
jmp 0x11555
movq %rdx, %rbx
movq %rax, %r12
jmp 0x11509
movq %rdx, %rbx
movq %rax, %r12
jmp 0x11520
jmp 0x11572
movq %rax, %r12
movl $0x10, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x53f0
jmp 0x1159e
movq %rdx, %rbx
movq %rax, %r12
jmp 0x1159e
jmp 0x11534
movq %rdx, %rbx
movq %rax, %r12
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x11509
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x11520
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x11578
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
jmp 0x1156b
movq %rdx, %rbx
movq %rax, %r12
jmp 0x115ab
movq %rdx, %rbx
movq %rax, %r12
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x11578
callq 0x11ede
jmp 0x11578
jmp 0x11572
movq %rdx, %rbx
movq %rax, %r12
jmp 0x11582
movq %rdx, %rbx
movq %rax, %r12
movl $0x20, %esi
movq %r14, %rdi
callq 0x53f0
jmp 0x11578
movq %rdx, %rbx
movq %rax, %r12
leaq 0x20(%rsp), %rdi
callq 0x11d64
leaq 0x80(%rsp), %rdi
callq 0x11d64
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x1159e
callq 0x11ede
leaq 0xa8(%rsp), %rdi
callq 0x11db2
cmpl $0x1, %ebx
jne 0x115de
movq %r12, %rdi
callq 0x51e0
leaq 0x11001(%rip), %rdi     # 0x225c0
movl $0x1, %esi
movq %rax, %rdx
callq 0x11dde
callq 0x56a0
jmp 0x11489
movq %rax, %r12
callq 0x56a0
movq %r12, %rdi
callq 0x5720
movq %rax, %rdi
callq 0x7cac