// File: /workspace/github_cpp_makefile_star2_O1/lega911[P]ijson/src/server.cpp
// Function: Server::_accept()
void Server::_accept() {
    while (true) {
        struct sockaddr_in peer_addr;
        socklen_t peer_addr_len = sizeof(peer_addr);
        int fd = accept(_fd, (struct sockaddr *)&peer_addr, &peer_addr_len);
        if(fd < 0) {
            if(log & 1) std::cout << ltime() << "warning: accept error\n";
            continue;
        }
        if(fd >= MAX_CONNECTS) {
            std::cout << "socket fd (" << fd << ") >= " << MAX_CONNECTS << std::endl;
            THROW("socket fd error");
        }
        unblock_socket(fd);

        if(!_valid_ip(peer_addr.sin_addr.s_addr)) {
            close(fd);
            if(log & 8) std::cout << ltime() << "Client filtered\n";
            continue;
        };

        if(connections[fd]) THROW("Connection place is not empty");
        Connect* conn = new Connect(this, fd);
        connections[fd] = conn;
        conn->link();

        if(fd > max_fd) max_fd = fd;
        if(log & 16) std::cout << ltime() << "connect " << fd << " " << (void*)conn << std::endl;

        loops[active_loop]->accept(conn);
        stat_connect++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq -0x3c(%rbp), %r13
leaq -0x2c(%rbp), %r15
movq 0xeb91(%rip), %r12      # 0x1dfd0
movl $0x10, -0x2c(%rbp)
movl (%rbx), %edi
movq %r13, %rsi
movq %r15, %rdx
callq 0x80e0
testl %eax, %eax
js 0xf4b3
movl %eax, %r14d
cmpl $0x4000, %eax           # imm = 0x4000
jge 0xf663
movl %r14d, %edi
callq 0xefc4
movl -0x38(%rbp), %esi
movq %rbx, %rdi
callq 0xf39a
testb %al, %al
jne 0xf542
movl %r14d, %edi
callq 0x8500
testb $0x8, 0x20(%rbx)
je 0xf43f
callq 0x16531
testq %rax, %rax
je 0xf510
movq %rax, %r14
movq %rax, %rdi
callq 0x8130
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8350
jmp 0xf529
testb $0x1, 0x20(%rbx)
je 0xf43f
callq 0x16531
testq %rax, %rax
je 0xf4de
movq %rax, %r14
movq %rax, %rdi
callq 0x8130
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8350
jmp 0xf4f7
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x8470
movl $0x16, %edx
movq %r12, %rdi
leaq 0x8d9d(%rip), %rsi      # 0x182a3
callq 0x8350
jmp 0xf43f
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x8470
movl $0x10, %edx
movq %r12, %rdi
leaq 0x8dbb(%rip), %rsi      # 0x182f3
callq 0x8350
jmp 0xf43f
movl %r14d, %r15d
cmpq $0x0, 0x50(%rbx,%r15,8)
jne 0xf708
movl $0x1e8, %edi            # imm = 0x1E8
callq 0xee48
movq %rax, %r13
movq %rax, %rdi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x13032
movq %r13, 0x50(%rbx,%r15,8)
incl 0x8(%r13)
cmpl 0x8(%rbx), %r14d
jle 0xf57f
movl %r14d, 0x8(%rbx)
testb $0x10, 0x20(%rbx)
je 0xf640
callq 0x16531
testq %rax, %rax
je 0xf5b5
movq %rax, %r15
movq %rax, %rdi
callq 0x8130
movq 0xea2b(%rip), %r12      # 0x1dfd0
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x8350
jmp 0xf5d5
movq 0xea14(%rip), %r12      # 0x1dfd0
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x8470
movl $0x8, %edx
movq %r12, %rdi
leaq 0x7ac6(%rip), %rsi      # 0x170aa
callq 0x8350
movq %r12, %rdi
movl %r14d, %esi
callq 0x8490
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x80a3(%rip), %rsi      # 0x176a9
callq 0x8350
movq %r14, %rdi
movq %r13, %rsi
callq 0x8250
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x82f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x81f0
movq 0x20050(%rbx), %rax
movslq 0x4(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
movq %r13, %rsi
callq 0xf774
incq 0x20080(%rbx)
jmp 0xf430
movq 0xe966(%rip), %rbx      # 0x1dfd0
leaq 0x8c49(%rip), %rsi      # 0x182ba
movl $0xb, %edx
movq %rbx, %rdi
callq 0x8350
movq %rbx, %rdi
movl %r14d, %esi
callq 0x8490
movq %rax, %rbx
leaq 0x8c33(%rip), %rsi      # 0x182c6
movl $0x5, %edx
movq %rax, %rdi
callq 0x8350
movq %rbx, %rdi
movl $0x4000, %esi           # imm = 0x4000
callq 0x8490
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x82f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x81f0
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0x8be1(%rip), %rsi      # 0x182cc
leaq 0x8b00(%rip), %rdx      # 0x181f2
leaq 0x8be3(%rip), %r8       # 0x182dc
movq %rax, %rdi
movl $0x51, %ecx
callq 0xcd04
jmp 0xf737
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0x8be8(%rip), %rsi      # 0x18304
leaq 0x8acf(%rip), %rdx      # 0x181f2
leaq 0x8bb2(%rip), %r8       # 0x182dc
movq %rax, %rdi
movl $0x5b, %ecx
callq 0xcd04
leaq 0xe5da(%rip), %rsi      # 0x1dd18
leaq -0x2435(%rip), %rdx     # 0xd310
movq %r14, %rdi
callq 0x8480
jmp 0xf761
movq %rax, %rbx
movl $0x1e8, %esi            # imm = 0x1E8
movq %r13, %rdi
callq 0x8320
jmp 0xf76c
movq %rax, %rbx
movq %r14, %rdi
callq 0x8220
movq %rbx, %rdi
callq 0x84a0