// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, %rbx
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x80b0
movl %eax, (%rbx)
testl %eax, %eax
js 0xf2bd
leaq -0x64(%rbp), %rcx
movl $0x1, (%rcx)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x84b0
testl %eax, %eax
js 0xf2ee
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movw $0x2, -0x60(%rbp)
leaq 0x10(%rbx), %r15
leaq -0x48(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xc468
movq (%r14), %rdi
callq 0x8310
movl %eax, -0x5c(%rbp)
movq (%r14), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xf12a
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x8320
movzwl 0x24(%rbx), %eax
rolw $0x8, %ax
leaq -0x60(%rbp), %rsi
movw %ax, 0x2(%rsi)
movl (%rbx), %edi
movl $0x10, %edx
callq 0x8080
testl %eax, %eax
js 0xf194
movl (%rbx), %edi
movl $0x40, %esi
callq 0x8340
testl %eax, %eax
js 0xf31f
xorl %r14d, %r14d
testb $0x8, 0x20(%rbx)
je 0xf2ab
callq 0x16531
testq %rax, %rax
je 0xf1c1
movq %rax, %r12
movq %rax, %rdi
callq 0x8130
movq 0xee49(%rip), %rdi      # 0x1dfd0
movq %r12, %rsi
movq %rax, %rdx
callq 0x8350
jmp 0xf1df
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testb $0x1, 0x20(%rbx)
je 0xf2ab
movq 0xee25(%rip), %rdi      # 0x1dfd0
leaq 0x90b7(%rip), %rsi      # 0x18269
movl $0xd, %edx
callq 0x8350
jmp 0xf2ab
movq 0xee08(%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 0xedea(%rip), %r12      # 0x1dfd0
leaq 0x909a(%rip), %rsi      # 0x18287
movl $0xe, %edx
movq %r12, %rdi
callq 0x8350
leaq 0x8858(%rip), %rsi      # 0x17a59
movl $0x6, %edx
movq %r12, %rdi
callq 0x8350
leaq 0x9081(%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 0xc468
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r12, %rdi
callq 0x8350
movq %rax, %r15
leaq 0x81a3(%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 0xf2ab
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x8320
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0x8f62(%rip), %rsi      # 0x18233
leaq 0x8f1a(%rip), %rdx      # 0x181f2
leaq 0x8f69(%rip), %r8       # 0x18248
movq %rax, %rdi
movl $0x24, %ecx
callq 0xcd04
jmp 0xf34e
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0x8f5c(%rip), %rsi      # 0x1825e
leaq 0x8ee9(%rip), %rdx      # 0x181f2
leaq 0x8f38(%rip), %r8       # 0x18248
movq %rax, %rdi
movl $0x27, %ecx
callq 0xcd04
jmp 0xf34e
movl $0x30, %edi
callq 0x8170
movq %rax, %r14
leaq 0x8f44(%rip), %rsi      # 0x18277
leaq 0x8eb8(%rip), %rdx      # 0x181f2
leaq 0x8f07(%rip), %r8       # 0x18248
movq %rax, %rdi
movl $0x34, %ecx
callq 0xcd04
leaq 0xe9c3(%rip), %rsi      # 0x1dd18
leaq -0x204c(%rip), %rdx     # 0xd310
movq %r14, %rdi
callq 0x8480
jmp 0xf368
jmp 0xf368
movq %rax, %rbx
movq %r14, %rdi
callq 0x8220
jmp 0xf391
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xf391
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x8320
movq %rbx, %rdi
callq 0x84a0
nop