// File: /workspace/github_cpp_makefile_star2_O1/alfanick[P]rest-cpp/src/rest/server.cpp
// Function: REST::Server::Server(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, REST::Dispatcher*)
Server::Server(std::string address, int port, Dispatcher* d) : dispatcher(d) {
  srand(time(0));
  signal(SIGPIPE, SIG_IGN);
  Router::instance();
  int status;

  memset(&host_info, 0, sizeof(host_info));

  host_info.ai_family = AF_UNSPEC;
  host_info.ai_socktype = SOCK_STREAM;

  status = getaddrinfo(address.c_str(), std::to_string(port).c_str(), &host_info, &host_info_list);
  if (status != 0)
    throw AddressResolvingError();

  handle = socket(host_info_list->ai_family, host_info_list->ai_socktype, host_info_list->ai_protocol);
  if (handle == -1)
    throw SocketCreationError();

  int yes = 1;
  status = setsockopt(handle, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
  status = bind(handle, host_info_list->ai_addr, host_info_list->ai_addrlen);
  if (status == -1)
    throw PortInUseError();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %r14d
movq %rsi, %r12
movq %rdi, %rbx
movq %rcx, (%rdi)
movb $0x1, 0x8(%rdi)
xorl %edi, %edi
callq 0x22090
movl %eax, %edi
callq 0x22170
movl $0x1, %esi
movl $0xd, %edi
callq 0x22570
movq 0x11a0a(%rip), %rax     # 0x4dfa0
movb (%rax), %al
testb %al, %al
je 0x3c6f6
leaq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
vxorps %xmm0, %xmm0, %xmm0
vmovups %ymm0, 0x10(%rbx)
vmovups %ymm0, 0x20(%rbx)
movl $0x1, 0x18(%rbx)
movq (%r12), %rax
movq %rax, 0x8(%rsp)
movl %r14d, %ebp
negl %ebp
cmovsl %r14d, %ebp
movl $0x1, %r13d
cmpl $0xa, %ebp
jb 0x3c624
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0x3c61b
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x3c621
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x3c624
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x3c5e8
addl $-0x3, %r13d
jmp 0x3c624
addl $-0x2, %r13d
jmp 0x3c624
decl %r13d
shrl $0x1f, %r14d
leal (%r13,%r14), %esi
leaq 0x28(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movl $0x2d, %edx
vzeroupper
callq 0x22520
addq (%r15), %r14
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x22a70
movq (%r15), %rsi
leaq 0x40(%rbx), %rcx
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0x226b0
movl %eax, %ebp
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x3c683
callq 0x22130
testl %ebp, %ebp
jne 0x3c741
movq 0x40(%rbx), %rax
movl 0x4(%rax), %edi
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
callq 0x21350
movl %eax, 0x48(%rbx)
cmpl $-0x1, %eax
je 0x3c762
leaq 0x18(%rsp), %rcx
movl $0x1, (%rcx)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x23180
movl 0x48(%rbx), %edi
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rsi
movl 0x10(%rax), %edx
callq 0x211b0
cmpl $-0x1, %eax
je 0x3c783
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x118a3(%rip), %rdi     # 0x4dfa0
callq 0x231e0
testl %eax, %eax
je 0x3c5a0
movq 0x118b7(%rip), %rdi     # 0x4dfc8
callq 0x231c0
movq 0x1153b(%rip), %rdi     # 0x4dc58
movq 0x118a4(%rip), %rsi     # 0x4dfc8
leaq 0x12b75(%rip), %rdx     # 0x4f2a0
callq 0x21fa0
movq 0x11869(%rip), %rdi     # 0x4dfa0
callq 0x21b30
jmp 0x3c5a0
movl $0x8, %edi
callq 0x217b0
movq 0x1161e(%rip), %rcx     # 0x4dd70
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x115a8(%rip), %rsi     # 0x4dd08
jmp 0x3c7a2
movl $0x8, %edi
callq 0x217b0
movq 0x1153d(%rip), %rcx     # 0x4dcb0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x117cf(%rip), %rsi     # 0x4df50
jmp 0x3c7a2
movl $0x8, %edi
callq 0x217b0
movq 0x1148c(%rip), %rcx     # 0x4dc20
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x1152e(%rip), %rsi     # 0x4dcd0
movq 0x1180f(%rip), %rdx     # 0x4dfb8
movq %rax, %rdi
callq 0x230a0
movq %rax, %rbx
movq 0x117e5(%rip), %rdi     # 0x4dfa0
callq 0x21ac0
jmp 0x3c7d4
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x3c7d4
callq 0x22130
movq %rbx, %rdi
callq 0x23170