// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
movslq 0x8(%rsi), %r15
testq %r15, %r15
jle 0xa137
movq %rsi, %r14
movq %rdi, %rbx
movl %r15d, (%rdi)
movq %r15, %rax
shlq $0x7, %rax
leaq (%rax,%r15,8), %r12
leaq (%rax,%r15,8), %rdi
addq $0x8, %rdi
callq 0x6030
movq %r15, (%rax)
leaq 0x8(%rax), %rcx
addq $0x88, %rax
xorps %xmm0, %xmm0
xorl %edx, %edx
movups %xmm0, -0x30(%rax)
movq %rdx, -0x10(%rax)
movups %xmm0, -0x40(%rax)
movq $-0x1, -0x80(%rax)
movups %xmm0, -0x78(%rax)
movups %xmm0, -0x68(%rax)
movups %xmm0, -0x58(%rax)
movq %rdx, -0x48(%rax)
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
addq $0x88, %rax
addq $-0x88, %r12
jne 0xa01c
movq %rcx, 0x8(%rbx)
callq 0x65b0
cmpl $0x0, (%rbx)
jle 0xa0b9
movl %eax, %ebp
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x8(%rbx), %rdi
cmpb $0x1, (%r14)
jne 0xa094
movl %r15d, %eax
cltd
idivl %ebp
movl %edx, (%rdi,%r12)
addq %r12, %rdi
movq %r14, %rsi
callq 0x6390
testl %eax, %eax
jne 0xa152
incq %r15
movslq (%rbx), %rax
addq $0x88, %r12
cmpq %rax, %r15
jl 0xa080
cmpb $0x1, 0x1(%r14)
jne 0xa181
movl $0x80, %edi
callq 0x6490
movq %rax, %r15
movl 0x14(%r14), %esi
movq %rax, %rdi
callq 0x6050
movq 0x4ec4(%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 0x60d0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0xa183
movq 0x10(%rbx), %r14
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
testl %eax, %eax
js 0xa183
movl %eax, %ecx
movl (%rbx), %esi
cmpl $0x2, %esi
jl 0xa159
movl %ecx, %eax
xorl %edx, %edx
divl %esi
jmp 0xa15b
movq 0x4e9a(%rip), %rax      # 0xefd8
movq (%rax), %rdi
leaq 0x1240(%rip), %rsi      # 0xb388
movl %r15d, %edx
xorl %eax, %eax
callq 0x6620
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xa183
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 0x67e0
testl %eax, %eax
jne 0xa183
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r15, %rdi
callq 0x6470
movq %rbx, %rdi
callq 0x6740
nop