// File: /workspace/github_cpp_makefile_star2_O2/tylerkaraszewski[P]Argyle/Server.cpp
// Function: Server::bindPort()
bool Server::bindPort()
{
  m_mainSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (m_mainSocket == -1)
  {
    m_logger.logError("Socket error(" + Utils::llToString(errno) + "): " + strerror(errno));
    return false;
  }

  int reuseAddr = 1;
  if (setsockopt(m_mainSocket, SOL_SOCKET, SO_REUSEADDR, (char*)&reuseAddr, sizeof(reuseAddr)))
  {
    m_logger.logError("Setsockopt error(" + Utils::llToString(errno) + "): " + strerror(errno));
    close(m_mainSocket);
    return false;
  }
  
  if (bind(m_mainSocket, (struct sockaddr*)&m_address, sizeof(m_address)))
  {
    m_logger.logError("Bind error(" + Utils::llToString(errno) + "): " + strerror(errno));
    close(m_mainSocket);
    return false;
  }
  return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
pushq $0x6
popq %rdx
callq 0x30b0
movl %eax, (%rbx)
cmpl $-0x1, %eax
je 0x3a05
leaq 0x84(%rsp), %rcx
movl $0x1, (%rcx)
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %r8
movl %eax, %edi
callq 0x3520
testl %eax, %eax
je 0x3a99
movq 0x58(%rbx), %r14
callq 0x3040
movq %rax, %r15
movslq (%rax), %rsi
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0x8104
leaq 0x5678(%rip), %rsi      # 0x9032
movq %rsp, %rdi
movq %r12, %rdx
callq 0x42fb
leaq 0x5662(%rip), %rdx      # 0x902e
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x42dc
movl (%r15), %edi
callq 0x3110
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rax, %rdx
callq 0x42dc
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x80f6
jmp 0x3b18
movq 0x58(%rbx), %rbx
callq 0x3040
movq %rax, %r14
movslq (%rax), %rsi
leaq 0x60(%rsp), %r15
movq %r15, %rdi
callq 0x8104
leaq 0x55f8(%rip), %rsi      # 0x9020
movq %rsp, %rdi
movq %r15, %rdx
callq 0x42fb
leaq 0x55f4(%rip), %rdx      # 0x902e
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x42dc
movl (%r14), %edi
callq 0x3110
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rax, %rdx
callq 0x42dc
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x80f6
leaq 0x40(%rsp), %rdi
callq 0x35d8
leaq 0x20(%rsp), %rdi
callq 0x35d8
movq %rsp, %rdi
callq 0x35d8
leaq 0x60(%rsp), %rdi
callq 0x35d8
jmp 0x3b45
movl (%rbx), %edi
leaq 0x48(%rbx), %rsi
pushq $0x10
popq %rdx
callq 0x3090
testl %eax, %eax
je 0x3b56
movq 0x58(%rbx), %r14
callq 0x3040
movq %rax, %r15
movslq (%rax), %rsi
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0x8104
leaq 0x5572(%rip), %rsi      # 0x9044
movq %rsp, %rdi
movq %r12, %rdx
callq 0x42fb
leaq 0x554a(%rip), %rdx      # 0x902e
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x42dc
movl (%r15), %edi
callq 0x3110
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rax, %rdx
callq 0x42dc
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x80f6
leaq 0x40(%rsp), %rdi
callq 0x35d8
leaq 0x20(%rsp), %rdi
callq 0x35d8
movq %rsp, %rdi
callq 0x35d8
leaq 0x60(%rsp), %rdi
callq 0x35d8
movl (%rbx), %edi
callq 0x35a0
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movb $0x1, %al
jmp 0x3b47
jmp 0x3b6a
jmp 0x3b79
jmp 0x3b88
jmp 0x3b95
jmp 0x3b6a
jmp 0x3b79
jmp 0x3b88
jmp 0x3b95
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x35d8
jmp 0x3b7c
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x35d8
jmp 0x3b8b
movq %rax, %rbx
movq %rsp, %rdi
callq 0x35d8
jmp 0x3b98
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x35d8
movq %rbx, %rdi
callq 0x3510