// File: SeTriones[P]Anubis/acceptor.cpp
// Function: acceptor::acceptor(int, int)
acceptor::acceptor(int _epoll_cnt, int _max_conn) {
	epoll_cnt = _epoll_cnt;
	max_conn = _max_conn;
	_INFO("epoll_cnt=%d,max_conn=%d", epoll_cnt, max_conn);
	listen_port = -1;
	stop_task = 0;
	conn_num = 0;
	wid = 0;
	epoll_fds = new int[epoll_cnt];
	epoll_ready_event_num = new int[epoll_cnt];
	pipe_read_fds = new int[epoll_cnt];
	pipe_write_fds = new int[epoll_cnt];
	add_sum = 2;
	for (int i = 0; i < epoll_cnt; i++) {
		epoll_ready_event_num[i] = 0;
	}
	epoll_mutexes = new pthread_mutex_t[epoll_cnt];
	for (int i = 0; i < epoll_cnt; i++) {
		pthread_mutex_init(&epoll_mutexes[i], NULL);
	}
	epoll_ready_events = new epoll_event*[epoll_cnt];
	for (int i = 0; i < epoll_cnt; i++) {
		epoll_ready_events[i] = new epoll_event[max_conn];
	}
	pthread_mutex_init(&epoll_idx_mutex, NULL);
	incoming_fd_cnt = 0;
	epoll_thread_cnt = 0;
	pthread_mutex_init(&conn_mutex, NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0xc(%rbp), %ecx
movl %ecx, 0x4(%rax)
movl -0x10(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x18(%rbp), %rdi
callq 0x21e0
leaq -0x18(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2120
leaq -0x70(%rbp), %rdi
movl $0x12, %esi
leaq 0x65c3(%rip), %rdx      # 0x9004
leaq -0x50(%rbp), %rcx
callq 0x2190
movq 0xa587(%rip), %rax      # 0xcfd8
movq (%rax), %rax
movq %rax, -0x98(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x90(%rbp)
callq 0x21c0
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rdx
movq %rax, %rcx
movq -0x88(%rbp), %rax
movl 0x4(%rax), %r9d
movl (%rax), %eax
leaq 0x6584(%rip), %rsi      # 0x9014
leaq 0x66e4(%rip), %r8       # 0x917b
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2310
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, -0x74(%rbp)
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movl $0x0, 0x18(%rax)
movl $0x0, 0x1c(%rax)
movl $0x0, 0x20(%rax)
movslq 0x4(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x10(%rax)
movslq 0x4(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x88(%rax)
movslq 0x4(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x90(%rax)
movslq 0x4(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x98(%rax)
movl $0x2, 0xa8(%rax)
movl $0x0, -0x78(%rbp)
movq -0x88(%rbp), %rcx
movl -0x78(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x2be2
movq -0x88(%rbp), %rax
movq 0x88(%rax), %rax
movslq -0x78(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x2baf
movq -0x88(%rbp), %rax
movslq 0x4(%rax), %rax
movl $0x28, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x0, -0x7c(%rbp)
movq -0x88(%rbp), %rcx
movl -0x7c(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x2c5c
movq -0x88(%rbp), %rax
movq 0x28(%rax), %rdi
movslq -0x7c(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2350
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x2c23
movq -0x88(%rbp), %rax
movslq 0x4(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x80(%rax)
movl $0x0, -0x80(%rbp)
movq -0x88(%rbp), %rcx
movl -0x80(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x2cfe
movq -0x88(%rbp), %rax
movslq (%rax), %rax
movl $0xc, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rdx
movq -0x88(%rbp), %rax
movq 0x80(%rax), %rax
movslq -0x80(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x2ca0
movq -0x88(%rbp), %rdi
addq $0x58, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2350
movq -0x88(%rbp), %rdi
movl $0x0, 0xa4(%rdi)
movl $0x0, 0xa0(%rdi)
addq $0x30, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2350
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)