// File: /workspace/github_cpp_makefile_star2_O2/lega911[P]ijson/src/server.cpp
// Function: Server::_listen()
int Server::_listen() {
    _fd = socket(AF_INET, SOCK_STREAM, 0);
    if(_fd < 0) THROW("Error opening socket");

    int opt = 1;
    if(setsockopt(_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) THROW("setsockopt");

    struct sockaddr_in serv_addr;
    memset(&serv_addr, 0, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = inet_addr(host.as_string().c_str());
    serv_addr.sin_port = htons(port);
    int r = bind(_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
    if(r < 0) {
        if(this->log & 1) std::cout << "Port is busy\n";
        return -1;
    }

    if(listen(_fd, 64) < 0) THROW("ERROR on listen");
    if(this->log & 8) std::cout << ltime() << "Inverted Json " << ijson_version << " started on " << host.as_string() << ":" << port << std::endl;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0xa0a0
movl %eax, (%rbx)
testl %eax, %eax
js 0xfed0
leaq -0x2c(%rbp), %rcx
movl $0x1, (%rcx)
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %r8
movl %eax, %edi
callq 0xa480
testl %eax, %eax
js 0xfefd
leaq -0x60(%rbp), %r12
andq $0x0, 0x8(%r12)
movw $0x2, (%r12)
leaq 0x10(%rbx), %r15
leaq -0x50(%rbp), %r13
pushq $-0x1
popq %r14
movq %r13, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0xd636
movq (%r13), %rdi
callq 0xa2f0
movl %eax, 0x4(%r12)
movq %r13, %rdi
callq 0xa130
movzwl 0x24(%rbx), %eax
rolw $0x8, %ax
movw %ax, 0x2(%r12)
movl (%rbx), %edi
pushq $0x10
popq %rdx
movq %r12, %rsi
callq 0xa070
testl %eax, %eax
js 0xfea5
movl (%rbx), %edi
pushq $0x40
popq %rsi
callq 0xa320
testl %eax, %eax
js 0xff2a
xorl %r14d, %r14d
testb $0x8, 0x20(%rbx)
je 0xfebe
callq 0x16a89
movq 0x101a9(%rip), %rdi     # 0x1ffd0
movq %rax, %rsi
callq 0xa2e0
leaq 0x9455(%rip), %rsi      # 0x1928b
movq %rax, %rdi
callq 0xa2e0
leaq 0x8c17(%rip), %rsi      # 0x18a5c
movq %rax, %rdi
callq 0xa2e0
leaq 0x9446(%rip), %rsi      # 0x1929a
movq %rax, %rdi
callq 0xa2e0
movq %rax, %r12
pushq $-0x1
popq %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0xd636
movq %r12, %rdi
movq %r13, %rsi
callq 0xa280
leaq 0x8574(%rip), %rsi      # 0x183f3
movq %rax, %rdi
callq 0xa2e0
movl 0x24(%rbx), %esi
movq %rax, %rdi
callq 0xa460
movq %rax, %rdi
callq 0xa160
leaq -0x50(%rbp), %rdi
callq 0xa130
jmp 0xfebe
testb $0x1, 0x20(%rbx)
je 0xfebe
movq 0x1011e(%rip), %rdi     # 0x1ffd0
leaq 0x93b4(%rip), %rsi      # 0x1926d
callq 0xa2e0
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x30
popq %rdi
callq 0xa170
movq %rax, %r14
leaq 0x9355(%rip), %rsi      # 0x19237
leaq 0x930d(%rip), %rdx      # 0x191f6
leaq 0x935c(%rip), %r8       # 0x1924c
pushq $0x24
popq %rcx
movq %rax, %rdi
callq 0xe15c
jmp 0xff55
pushq $0x30
popq %rdi
callq 0xa170
movq %rax, %r14
leaq 0x9353(%rip), %rsi      # 0x19262
leaq 0x92e0(%rip), %rdx      # 0x191f6
leaq 0x932f(%rip), %r8       # 0x1924c
pushq $0x27
popq %rcx
movq %rax, %rdi
callq 0xe15c
jmp 0xff55
pushq $0x30
popq %rdi
callq 0xa170
movq %rax, %r14
leaq 0x933f(%rip), %rsi      # 0x1927b
leaq 0x92b3(%rip), %rdx      # 0x191f6
leaq 0x9302(%rip), %r8       # 0x1924c
pushq $0x34
popq %rcx
movq %rax, %rdi
callq 0xe15c
leaq 0xfdbc(%rip), %rsi      # 0x1fd18
leaq -0x1a4d(%rip), %rdx     # 0xe516
movq %r14, %rdi
callq 0xa450
jmp 0xff6f
jmp 0xff6f
movq %rax, %rbx
movq %r14, %rdi
callq 0xa200
jmp 0xff88
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0xa130
movq %rbx, %rdi
callq 0xa470