// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/reactor.cpp
// Function: reactor::open(options const&)
int reactor::open(const options &opt) {
    if (opt.poller_num < 1) {
        fprintf(stderr, "reactor: poller_num=%d < 1\n", opt.poller_num);
        return -1;
    }
    this->poller_num = opt.poller_num;
    this->pollers = new poller[this->poller_num]();

    int cpu_num = std::thread::hardware_concurrency();
    for (int i = 0; i < this->poller_num; ++i) {
        if (opt.set_cpu_affinity) {
            int cpu_id = i % cpu_num;
            this->pollers[i].set_cpu_id(cpu_id);
        }
        if (this->pollers[i].open(opt) != 0) {
            return -1; // destroy ?
        }
    }
    if (opt.with_timer_shared == true) {
        this->timer = new timer_shared(opt.timer_init_size);
        if (this->timer->open() != 0)
            return -1; // destroy ?
        if (this->add_ev_handler(this->timer, this->timer->get_fd(), ev_handler::ev_read) != 0)
            return -1; // destroy ?
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movslq 0x8(%rsi), %r12
testq %r12, %r12
jle 0xa2ad
movq %rsi, %r14
movq %rdi, %rbx
movl %r12d, (%rdi)
movq %r12, %rax
shlq $0x7, %rax
leaq (%rax,%r12,8), %r13
leaq (%rax,%r12,8), %rdi
addq $0x8, %rdi
callq 0x6030
movq %rax, %r15
movq %r12, (%rax)
addq %rax, %r13
addq $0x8, %r13
addq $0x8, %r15
xorl %ebp, %ebp
movq %r15, %r12
movl $0x88, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x62c0
movq $-0x1, (%r12)
movq %rbp, 0x48(%r12)
leaq 0x80(%r12), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r12)
movups %xmm0, 0x18(%r12)
movups %xmm0, 0x28(%r12)
movq %rbp, 0x38(%r12)
movq %rax, 0x50(%r12)
movq $0x1, 0x58(%r12)
movups %xmm0, 0x60(%r12)
movl $0x3f800000, 0x70(%r12) # imm = 0x3F800000
movups %xmm0, 0x78(%r12)
addq $0x88, %r12
cmpq %r13, %r12
jne 0xa16f
movq %r15, 0x8(%rbx)
callq 0x65c0
cmpl $0x0, (%rbx)
jle 0xa22f
movl %eax, %ebp
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpb $0x1, (%r14)
jne 0xa206
movl %r15d, %eax
cltd
idivl %ebp
movq 0x8(%rbx), %rax
movl %edx, (%rax,%r12)
movq 0x8(%rbx), %rdi
addq %r12, %rdi
movq %r14, %rsi
callq 0x63a0
testl %eax, %eax
jne 0xa2c8
incq %r15
movslq (%rbx), %rax
addq $0x88, %r12
cmpq %rax, %r15
jl 0xa1f2
cmpb $0x1, 0x1(%r14)
jne 0xa2f7
movl $0x80, %edi
callq 0x64a0
movq %rax, %r15
movl 0x14(%r14), %esi
movq %rax, %rdi
callq 0x6060
movq 0x4d4e(%rip), %rax      # 0xefa8
addq $0x10, %rax
movq %rax, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x58(%r15)
movups %xmm0, 0x68(%r15)
movq $0x0, 0x78(%r15)
movq %r15, 0x10(%rbx)
movq %r15, %rdi
callq 0x60e0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0xa2f9
movq 0x10(%rbx), %r14
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
testl %eax, %eax
js 0xa2f9
movl %eax, %ecx
movl (%rbx), %esi
cmpl $0x2, %esi
jl 0xa2cf
movl %ecx, %eax
xorl %edx, %edx
divl %esi
jmp 0xa2d1
movq 0x4d24(%rip), %rax      # 0xefd8
movq (%rax), %rdi
leaq 0x10ca(%rip), %rsi      # 0xb388
movl %r12d, %edx
xorl %eax, %eax
callq 0x6630
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xa2f9
xorl %edx, %edx
movq %rbx, 0x20(%r14)
movq %rdx, %rax
shlq $0x7, %rax
leaq (%rax,%rdx,8), %rdi
addq 0x8(%rbx), %rdi
movq %r14, %rsi
movl %ecx, %edx
movl $0x2001, %ecx           # imm = 0x2001
callq 0x67f0
testl %eax, %eax
jne 0xa2f9
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r15, %rdi
callq 0x6480
movq %rbx, %rdi
callq 0x6750
nop