// File: /workspace/github_cpp_makefile_star2_O1/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 0x11388(%rip), %rdi     # 0x224c8
movl %ebp, %esi
movq %rbx, %rdx
callq 0x5b86
leaq 0x11377(%rip), %rdi     # 0x224c8
callq 0x68b8
leaq 0x1146b(%rip), %rdi     # 0x225c8
movq %rax, %rsi
callq 0x1099e
leaq 0x1145c(%rip), %rdi     # 0x225c8
callq 0x10bca
leaq 0x11450(%rip), %rdi     # 0x225c8
callq 0x10d38
leaq 0x11344(%rip), %rdi     # 0x224c8
callq 0x68a4
leaq 0xa8(%rsp), %rdi
movq %rax, %rsi
callq 0x1165e
movl $0x10, %edi
callq 0x53e0
movq %rax, %rbx
leaq 0xa8(%rsp), %rsi
movq %rax, %rdi
callq 0x16c34
leaq 0x78(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq %rbx, %rsi
callq 0x11fae
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %r15
movaps %xmm0, (%r15)
movq $0x0, 0x10(%r15)
xorl %r13d, %r13d
leaq 0x112e0(%rip), %rbp     # 0x224c8
leaq 0x7687(%rip), %r14      # 0x18876
movq %rbp, %rdi
callq 0x68a4
movl %r13d, %r13d
cmpq %r13, %rax
jbe 0x1130d
movl $0x30, %edi
callq 0x53e0
movq %rax, %rbx
movq %rbp, %rdi
callq 0x689e
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 0x12052
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
callq 0x120f0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1126c
callq 0x11f3e
movq %rbp, %rdi
callq 0x689e
addq (%rax), %r12
leaq 0x1134a(%rip), %rdi     # 0x225c8
movl $0x4, %esi
leaq 0x75e7(%rip), %rdx      # 0x18871
movq %r12, %rcx
movq %r14, %r8
callq 0x116e4
incl %r13d
jmp 0x111ef
movq %rdx, %rbx
movq %rax, %r12
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x112d1
callq 0x11f3e
jmp 0x112d1
jmp 0x112b6
movq %rdx, %rbx
movq %rax, %r12
jmp 0x112d1
movq %rax, %r12
movl $0x30, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x53f0
cmpl $0x2, %ebx
jne 0x115f2
movq %r12, %rdi
callq 0x51e0
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x1185e
leaq 0x112cf(%rip), %rdi     # 0x225c8
movl $0x1, %esi
movq %rbx, %rdx
callq 0x118be
callq 0x56b0
jmp 0x11295
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rbx
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
xorl %ebp, %ebp
leaq 0x1119f(%rip), %r15     # 0x224c8
leaq 0xa8(%rsp), %r12
leaq 0x8(%rsp), %r13
movq %r15, %rdi
callq 0x68be
movl %ebp, %ecx
cmpq %rcx, %rax
jbe 0x1139a
movl $0x20, %edi
callq 0x53e0
movq %rax, %r14
movq %r15, %rdi
callq 0x68b2
movq (%rax), %rdx
movq %r14, %rdi
movl %ebp, %esi
movq %r12, %rcx
callq 0x170ac
movq %r14, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x122ba
movq %rbx, %rdi
movq %r13, %rsi
callq 0x120f0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x11396
callq 0x11f3e
incl %ebp
jmp 0x11336
leaq 0x5887(%rip), %rdx      # 0x16c28
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x119be
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x50(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x5851(%rip), %rcx      # 0x16c28
leaq 0x58(%rsp), %rdi
callq 0x11aa6
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
leaq 0x50(%rsp), %rsi
movq %rax, (%rsi)
leaq 0xa0(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x5823(%rip), %rcx      # 0x16c28
leaq 0x38(%rsp), %rdi
callq 0x11aa6
leaq 0x111b2(%rip), %rdi     # 0x225c8
leaq 0x7462(%rip), %rdx      # 0x1887f
movl $0x1, %esi
callq 0x11bb2
leaq 0x38(%rsp), %rdi
callq 0x16f4c
leaq 0x58(%rsp), %rdi
movl $0xa, %esi
callq 0x16fe2
leaq 0x8(%rsp), %rdi
movl $0xa, %esi
callq 0x16fe2
leaq 0x11172(%rip), %rdi     # 0x225c8
leaq 0x7431(%rip), %rdx      # 0x1888e
movl $0x1, %esi
callq 0x11cbe
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x1147e
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x11495
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x114ac
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
leaq 0x20(%rsp), %rdi
callq 0x11dca
leaq 0x80(%rsp), %rdi
callq 0x11dca
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x114d2
callq 0x11f3e
leaq 0x418(%rsp), %rdi
callq 0x17b86
leaq 0x3f8(%rsp), %rdi
callq 0x17b86
leaq 0x3d0(%rsp), %rdi
callq 0x17b5c
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 0x56b0
jmp 0x115f2
jmp 0x115c5
movq %rdx, %rbx
movq %rax, %r12
jmp 0x11579
movq %rdx, %rbx
movq %rax, %r12
jmp 0x11590
jmp 0x115e2
movq %rax, %r12
movl $0x10, %esi
movq %rbx, %rdi
movq %rdx, %rbx
callq 0x53f0
jmp 0x1160e
movq %rdx, %rbx
movq %rax, %r12
jmp 0x1160e
jmp 0x115a4
movq %rdx, %rbx
movq %rax, %r12
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x11579
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x11590
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x53f0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x115e8
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
jmp 0x115db
movq %rdx, %rbx
movq %rax, %r12
jmp 0x1161b
movq %rdx, %rbx
movq %rax, %r12
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x115e8
callq 0x11f3e
jmp 0x115e8
jmp 0x115e2
movq %rdx, %rbx
movq %rax, %r12
jmp 0x115f2
movq %rdx, %rbx
movq %rax, %r12
movl $0x20, %esi
movq %r14, %rdi
callq 0x53f0
jmp 0x115e8
movq %rdx, %rbx
movq %rax, %r12
leaq 0x20(%rsp), %rdi
callq 0x11dca
leaq 0x80(%rsp), %rdi
callq 0x11dca
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x1160e
callq 0x11f3e
leaq 0xa8(%rsp), %rdi
callq 0x11e12
cmpl $0x1, %ebx
jne 0x1164e
movq %r12, %rdi
callq 0x51e0
leaq 0x10f99(%rip), %rdi     # 0x225c8
movl $0x1, %esi
movq %rax, %rdx
callq 0x11e3e
callq 0x56b0
jmp 0x114f9
movq %rax, %r12
callq 0x56b0
movq %r12, %rdi
callq 0x5730
movq %rax, %rdi
callq 0x7db2