// File: /workspace/github_cpp_makefile_star2_O2/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 0x11dba
pushq $0xa
popq %rdi
callq 0x11e25
leaq 0x1349e(%rip), %rdi     # 0x214f0
movl %ebp, %esi
movq %rbx, %rdx
callq 0x5a80
leaq 0x1348d(%rip), %rdi     # 0x214f0
callq 0x64a4
leaq 0x13581(%rip), %rdi     # 0x215f0
movq %rax, %rsi
callq 0xdb34
leaq 0x13572(%rip), %rdi     # 0x215f0
callq 0xdce6
leaq 0x13566(%rip), %rdi     # 0x215f0
callq 0xdda0
leaq 0x1345a(%rip), %rdi     # 0x214f0
callq 0x6490
leaq 0xa8(%rsp), %rdi
movq %rax, %rsi
callq 0xe4b2
pushq $0x10
popq %rdi
callq 0x5410
movq %rax, %rbx
leaq 0xa8(%rsp), %rsi
movq %rax, %rdi
callq 0x12574
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0xeb04
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %r15
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
xorl %r14d, %r14d
leaq 0x13402(%rip), %rbp     # 0x214f0
movq %rsp, %rbx
movq %rbp, %rdi
callq 0x6490
movl %r14d, %r14d
cmpq %r14, %rax
jbe 0xe1f7
pushq $0x30
popq %rdi
callq 0x5410
movq %rax, %r13
movq %rbp, %rdi
callq 0x648a
movq (%rax), %rax
movq %r14, %r12
shlq $0x5, %r12
movq (%rax,%r12), %rdx
movq %r13, %rdi
movl %r14d, %esi
pushq $0xa
popq %rcx
leaq 0xa8(%rsp), %r8
callq 0x11e68
movq %rbx, %rdi
movq %r13, %rsi
callq 0xebfe
movq %r15, %rdi
movq %rbx, %rsi
callq 0xec9e
leaq 0x8(%rsp), %rdi
callq 0xea54
movq %rbp, %rdi
callq 0x648a
addq (%rax), %r12
leaq 0x13482(%rip), %rdi     # 0x215f0
pushq $0x4
popq %rsi
leaq 0x6709(%rip), %rdx      # 0x14881
movq %r12, %rcx
leaq 0x6704(%rip), %r8       # 0x14886
callq 0xe532
incl %r14d
jmp 0xe0f1
movq %rdx, %r13
movq %rax, %r12
leaq 0x8(%rsp), %rdi
callq 0xea54
jmp 0xe1bc
jmp 0xe1a3
movq %rdx, %r13
movq %rax, %r12
jmp 0xe1bc
movq %rax, %r12
movq %r13, %rdi
movq %rdx, %r13
pushq $0x30
popq %rsi
callq 0x5420
cmpl $0x2, %r13d
jne 0xe44f
movq %r12, %rdi
callq 0x51f0
movq %rax, %r12
leaq 0xa8(%rsp), %rdi
callq 0xe5e6
leaq 0x1340b(%rip), %rdi     # 0x215f0
pushq $0x1
popq %rsi
movq %r12, %rdx
callq 0xe62c
callq 0x5700
jmp 0xe187
movq %rsp, %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
xorl %ebp, %ebp
leaq 0x132e2(%rip), %r15     # 0x214f0
pushq $0x20
popq %r12
leaq 0xa8(%rsp), %r13
leaq 0x20(%rsp), %rbx
movq %r15, %rdi
callq 0x64aa
movl %ebp, %ecx
cmpq %rcx, %rax
jbe 0xe275
movq %r12, %rdi
callq 0x5410
movq %rax, %r14
movq %r15, %rdi
callq 0x649e
movq (%rax), %rdx
movq %r14, %rdi
movl %ebp, %esi
movq %r13, %rcx
callq 0x12910
movq %rbx, %rdi
movq %r14, %rsi
callq 0xef56
movq %rsp, %rdi
movq %rbx, %rsi
callq 0xec9e
leaq 0x28(%rsp), %rdi
callq 0xea54
incl %ebp
jmp 0xe21f
leaq 0x42ec(%rip), %rdx      # 0x12568
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xe6c0
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq 0x70(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x38(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x42bc(%rip), %rcx      # 0x12568
leaq 0x88(%rsp), %rdi
callq 0xe778
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
leaq 0xa0(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x428c(%rip), %rcx      # 0x12568
leaq 0x70(%rsp), %rdi
callq 0xe778
leaq 0x13303(%rip), %rdi     # 0x215f0
leaq 0x659b(%rip), %rdx      # 0x1488f
pushq $0x1
popq %rsi
callq 0xe84a
leaq 0x70(%rsp), %rdi
callq 0x127d8
leaq 0x88(%rsp), %rdi
pushq $0xa
popq %rsi
callq 0x1286c
leaq 0x20(%rsp), %rdi
pushq $0xa
popq %rsi
callq 0x1286c
leaq 0x132c6(%rip), %rdi     # 0x215f0
leaq 0x656d(%rip), %rdx      # 0x1489e
pushq $0x1
popq %rsi
callq 0xe8de
leaq 0x70(%rsp), %rdi
callq 0xead0
leaq 0x88(%rsp), %rdi
callq 0xead0
leaq 0x20(%rsp), %rdi
callq 0xead0
movq %rsp, %rdi
callq 0xe972
leaq 0x50(%rsp), %rdi
callq 0xe972
leaq 0x48(%rsp), %rdi
callq 0xea54
leaq 0xa8(%rsp), %rdi
callq 0xe994
xorl %eax, %eax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r13
movq %rax, %r12
callq 0x5700
jmp 0xe44f
jmp 0xe426
movq %rdx, %r13
movq %rax, %r12
jmp 0xe3f1
movq %rdx, %r13
movq %rax, %r12
jmp 0xe3fe
jmp 0xe441
movq %rdx, %r13
movq %rax, %r12
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x5420
jmp 0xe463
movq %rdx, %r13
movq %rax, %r12
jmp 0xe463
jmp 0xe40a
movq %rdx, %r13
movq %rax, %r12
leaq 0x70(%rsp), %rdi
callq 0xead0
leaq 0x88(%rsp), %rdi
callq 0xead0
leaq 0x20(%rsp), %rdi
callq 0xead0
jmp 0xe447
movq %rdx, %r13
movq %rax, %r12
jmp 0xe470
movq %rdx, %r13
movq %rax, %r12
leaq 0x28(%rsp), %rdi
callq 0xea54
jmp 0xe447
jmp 0xe441
movq %rdx, %r13
movq %rax, %r12
jmp 0xe44f
movq %rdx, %r13
movq %rax, %r12
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x5420
jmp 0xe447
movq %rdx, %r13
movq %rax, %r12
movq %rsp, %rdi
callq 0xe972
leaq 0x50(%rsp), %rdi
callq 0xe972
leaq 0x48(%rsp), %rdi
callq 0xea54
leaq 0xa8(%rsp), %rdi
callq 0xe994
cmpl $0x1, %r13d
jne 0xe4a2
movq %r12, %rdi
callq 0x51f0
leaq 0x1316b(%rip), %rdi     # 0x215f0
pushq $0x1
popq %rsi
movq %rax, %rdx
callq 0xe9c0
callq 0x5700
jmp 0xe383
movq %rax, %r12
callq 0x5700
movq %r12, %rdi
callq 0x5770
movq %rax, %rdi
callq 0x7285