// File: /workspace/github_cpp_makefile_star2_O3/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
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x80b0
movl %eax, (%rbx)
testl %eax, %eax
js 0xf1da
leaq -0x5c(%rbp), %rcx
movl $0x1, (%rcx)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x84b0
testl %eax, %eax
js 0xf20b
movq $0x0, -0x50(%rbp)
movw $0x2, -0x58(%rbp)
leaq 0x10(%rbx), %r15
leaq -0x48(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xc49c
movq (%r14), %rdi
callq 0x8310
movl %eax, -0x54(%rbp)
movq (%r14), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xf047
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x8320
movzwl 0x24(%rbx), %eax
rolw $0x8, %ax
leaq -0x58(%rbp), %rsi
movw %ax, 0x2(%rsi)
movl (%rbx), %edi
movl $0x10, %edx
callq 0x8080
testl %eax, %eax
js 0xf0b1
movl (%rbx), %edi
movl $0x40, %esi
callq 0x8340
testl %eax, %eax
js 0xf23c
xorl %r14d, %r14d
testb $0x8, 0x20(%rbx)
je 0xf1c8
callq 0x163f5
testq %rax, %rax
je 0xf0de
movq %rax, %r12
movq %rax, %rdi
callq 0x8130
movq 0xef2c(%rip), %rdi      # 0x1dfd0
movq %r12, %rsi
movq %rax, %rdx
callq 0x8350
jmp 0xf0fc
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testb $0x1, 0x20(%rbx)
je 0xf1c8
movq 0xef08(%rip), %rdi      # 0x1dfd0
leaq 0x919a(%rip), %rsi      # 0x18269
movl $0xd, %edx
callq 0x8350
jmp 0xf1c8
movq 0xeeeb(%rip), %rax      # 0x1dfd0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %rdi
movl 0x20(%rax,%rcx), %esi
orl $0x1, %esi
callq 0x8470
movq 0xeecd(%rip), %r12      # 0x1dfd0
leaq 0x917d(%rip), %rsi      # 0x18287
movl $0xe, %edx
movq %r12, %rdi
callq 0x8350
leaq 0x893b(%rip), %rsi      # 0x17a59
movl $0x6, %edx
movq %r12, %rdi
callq 0x8350
leaq 0x9164(%rip), %rsi      # 0x18296
movl $0xc, %edx
movq %r12, %rdi
callq 0x8350
leaq -0x48(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xc49c
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r12, %rdi
callq 0x8350
movq %rax, %r15
leaq 0x8286(%rip), %rsi      # 0x173f3
movl $0x1, %edx
movq %rax, %rdi
callq 0x8350
movl 0x24(%rbx), %esi
movq %r15, %rdi
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
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xf1c8
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x8320
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0x9045(%rip), %rsi      # 0x18233
leaq 0x8ffd(%rip), %rdx      # 0x181f2
leaq 0x904c(%rip), %r8       # 0x18248
movq %rax, %rdi
movl $0x24, %ecx
callq 0xcd04
jmp 0xf26b
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0x903f(%rip), %rsi      # 0x1825e
leaq 0x8fcc(%rip), %rdx      # 0x181f2
leaq 0x901b(%rip), %r8       # 0x18248
movq %rax, %rdi
movl $0x27, %ecx
callq 0xcd04
jmp 0xf26b
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0x9027(%rip), %rsi      # 0x18277
leaq 0x8f9b(%rip), %rdx      # 0x181f2
leaq 0x8fea(%rip), %r8       # 0x18248
movq %rax, %rdi
movl $0x34, %ecx
callq 0xcd04
leaq 0xeaa6(%rip), %rsi      # 0x1dd18
leaq -0x1f69(%rip), %rdx     # 0xd310
movq %r14, %rdi
callq 0x8480
jmp 0xf285
jmp 0xf285
movq %rax, %rbx
movq %r14, %rdi
callq 0x8220
jmp 0xf2ae
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xf2ae
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x8320
movq %rbx, %rdi
callq 0x84a0