// File: /workspace/github_cpp_makefile_star2_O2/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: startListeningOnPort(_listenPortInfo*)
static void startListeningOnPort(listenPortInfo * pInfo)
{
    int yes = 1;
    struct sockaddr_in name;
    
    pInfo->socket = socket(PF_INET, SOCK_STREAM, 0);

    if (pInfo->socket < 0)
        fatal("startListeningOnPort(): socket() failed, errno=%d (%s)\n", errno, strerror(errno));
    else
        debug(LEVEL_3, "startListeningOnPort(): socket() initialized\n");

    if (setsockopt(pInfo->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
        fatal("startListeningOnPort(): setsockopt() failed, errno=%d (%s)\n", errno, strerror(errno));
    else
        debug(LEVEL_3, "startListeningOnPort(): setsockopt() success\n");

    name.sin_family = AF_INET;

    name.sin_port = htons(pInfo->port);

    name.sin_addr.s_addr = inet_addr(ownIpAddress);

    if (bind(pInfo->socket, (struct sockaddr *) &name, sizeof(name)) < 0)
        fatal("startListeningOnPort(): bind() to (ip: %s, port: %d) failed, errno=%d (%s)\n", 
            ownIpAddress, pInfo -> port, errno, strerror(errno));
    else
        debug(LEVEL_3, "startListeningOnPort(): bind() to (ip: %s, port: %d) succeeded\n", ownIpAddress, pInfo->port);

    if (listen(pInfo->socket, LISTEN_BACKLOG) < 0)
        fatal("startListeningOnPort(): listen() failed, errno=%d (%s)\n", errno, strerror(errno));
    else
        debug(LEVEL_3, "startListeningOnPort(): listen() succeeded\n");

}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movl $0x1, 0xc(%rsp)
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x2060
movl %eax, (%rbx)
testl %eax, %eax
js 0x3c68
leaq 0x3f3f(%rip), %rsi      # 0x7b9b
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x247c
jmp 0x3c89
callq 0x2030
movl (%rax), %ebp
movl %ebp, %edi
callq 0x20a0
leaq 0x3ee6(%rip), %rdi      # 0x7b63
movl %ebp, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x25b4
movl (%rbx), %edi
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
leaq 0xc(%rsp), %rcx
pushq $0x4
popq %r8
callq 0x2340
cmpl $-0x1, %eax
je 0x3cb7
leaq 0x3f5a(%rip), %rsi      # 0x7c05
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x247c
jmp 0x3cd8
callq 0x2030
movl (%rax), %ebp
movl %ebp, %edi
callq 0x20a0
leaq 0x3efd(%rip), %rdi      # 0x7bc9
movl %ebp, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x25b4
leaq 0x10(%rsp), %r14
movw $0x2, (%r14)
movzwl 0x4(%rbx), %eax
rolw $0x8, %ax
movw %ax, 0x2(%r14)
leaq 0x8609(%rip), %rdi      # 0xc300
callq 0x2200
movl %eax, 0x4(%r14)
movl (%rbx), %edi
pushq $0x10
popq %rdx
movq %r14, %rsi
callq 0x2050
movl 0x4(%rbx), %ebp
testl %eax, %eax
js 0x3d30
leaq 0x3f64(%rip), %rsi      # 0x7c7f
leaq 0x85de(%rip), %rdx      # 0xc300
pushq $0x3
popq %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x247c
jmp 0x3d5d
callq 0x2030
movl (%rax), %r14d
movl %r14d, %edi
callq 0x20a0
leaq 0x3eec(%rip), %rdi      # 0x7c33
leaq 0x85b2(%rip), %rsi      # 0xc300
movl %ebp, %edx
movl %r14d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x25b4
movl (%rbx), %edi
pushq $0x5
popq %rsi
callq 0x2220
testl %eax, %eax
js 0x3d7e
leaq 0x3f85(%rip), %rsi      # 0x7cf7
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x247c
jmp 0x3d9f
callq 0x2030
movl (%rax), %ebx
movl %ebx, %edi
callq 0x20a0
leaq 0x3f2c(%rip), %rdi      # 0x7cbf
movl %ebx, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x25b4
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq