// File: /workspace/github_cpp_makefile_star2_O3/solaldunckel[P]webserv/srcs/HTTP/Server.cpp
// Function: Server::setup()
void Server::setup() {
  int yes = 1;
  int server_fd = 0;

  std::vector<Listen> is_bind;

  for (std::vector<ServerConfig>::iterator it = servers_.begin(); it != servers_.end(); it++) {
    if (it->getListens().empty())
      it->getListens().push_back(Listen("0.0.0.0", 80));
    for (std::vector<Listen>::iterator list = it->getListens().begin(); list != it->getListens().end(); list++) {
      if (std::find(is_bind.begin(), is_bind.end(), *list) == is_bind.end()) {
        if ((server_fd = socket(PF_INET, SOCK_STREAM, 0)) < 0)
          throw webserv_exception("socket() failed", errno);

        fcntl(server_fd, F_SETFL, O_NONBLOCK);

        struct sockaddr_in address;
        memset(&address, 0, sizeof(address));
        address.sin_family = AF_INET;
        address.sin_addr.s_addr = inet_addr(list->ip_.c_str());
        address.sin_port = htons(list->port_);

        setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));

        if (bind(server_fd, (struct sockaddr *)&address, sizeof(address)) < 0)
          throw webserv_exception("bind() to % failed", errno, list->ip_ + ":" + ft::to_string(list->port_));

        if (listen(server_fd, MAX_CONNECTION) < 0)
          throw webserv_exception("listen() failed", errno);

        running_server_[server_fd] = Listen(list->ip_, list->port_);

        Log.print(INFO, "listening on " + ft::to_string(list->ip_) + ":" + ft::to_string(list->port_), GREEN);

        add_to_fd_set(server_fd);
        is_bind.push_back(*list);
      }
    }
  }

  if (is_bind.empty())
    throw webserv_exception("listen() failed", errno);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movl $0x1, 0x7c(%rsp)
movl $0x0, 0xc(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
movq 0x8(%rdi), %rax
movq (%rax), %rbx
cmpq 0x8(%rax), %rbx
je 0x18e40
movq %rdi, %rbp
leaq 0x18(%rdi), %rax
movq %rax, 0x158(%rsp)
leaq 0x10(%rsp), %r14
leaq 0x130(%rsp), %r15
leaq 0x188(%rsp), %r12
movq %rdi, 0x150(%rsp)
movq %rbx, %rdi
callq 0xcc22
movq (%rax), %rcx
cmpq 0x8(%rax), %rcx
jne 0x18739
movq %rbx, %rdi
callq 0xcc22
movq %rax, %r13
leaq 0xf0(%rsp), %rax
movq %rax, 0xe0(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xcc8c(%rip), %rsi      # 0x25340
leaq 0xcc8c(%rip), %rdx      # 0x25347
callq 0x579e
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x6c2a
movl $0x50, 0x30(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xdc52
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x18714
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x18739
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0xcc22
movq (%rax), %r13
movq %rbx, 0x160(%rsp)
movq %rbx, %rdi
callq 0xcc22
cmpq 0x8(%rax), %r13
je 0x18c17
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq %r13, %rdx
callq 0xdaed
cmpq 0x88(%rsp), %rax
jne 0x18c0e
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x40c0
movl %eax, 0xc(%rsp)
testl %eax, %eax
js 0x18c61
movl %eax, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x4260
xorps %xmm0, %xmm0
movaps %xmm0, 0x100(%rsp)
movw $0x2, 0x100(%rsp)
movq (%r13), %rdi
callq 0x4460
movl %eax, 0x104(%rsp)
movzwl 0x20(%r13), %eax
rolw $0x8, %ax
movw %ax, 0x102(%rsp)
movl 0xc(%rsp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq 0x7c(%rsp), %rcx
movl $0x4, %r8d
callq 0x47b0
movl 0xc(%rsp), %edi
leaq 0x100(%rsp), %rsi
movl $0x10, %edx
callq 0x4080
testl %eax, %eax
js 0x18d91
movl 0xc(%rsp), %edi
movl $0x80, %esi
callq 0x44c0
testl %eax, %eax
js 0x18cf9
leaq 0xd0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0x6c2a
movq %r14, %rdi
movl 0x20(%r13), %ebp
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
addq %rsi, %rdx
callq 0x6c2a
movl %ebp, 0x30(%rsp)
movq 0x158(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x1abc6
movq %rax, %rbp
movq %rax, %rdi
movq %r14, %rsi
callq 0x4570
movl 0x30(%rsp), %eax
movl %eax, 0x20(%rbp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x188d4
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
movq %r12, %rbp
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x188fc
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x140(%rsp), %rax
movq %rax, 0x130(%rsp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
movq %r15, %r12
movq %r15, %rdi
callq 0x6c2a
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1ac2b
movl $0xd, %r8d
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0xd0c0(%rip), %rcx      # 0x25a01
callq 0x44d0
movq %rbp, %r12
leaq 0x68(%rsp), %rsi
movq %rsi, 0x58(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x18971
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x18977
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x60(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x58(%rsp), %rdi
leaq 0xca87(%rip), %rsi      # 0x25422
callq 0x4840
leaq 0x20(%rsp), %rsi
movq %rsi, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x189c8
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x189ce
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl 0x20(%r13), %esi
leaq 0xa0(%rsp), %rdi
callq 0x106c9
movq 0x10(%rsp), %rcx
movl $0xf, %edi
leaq 0x20(%rsp), %rax
cmpq %rax, %rcx
je 0x18a10
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x18a4d
movl $0xf, %edi
leaq 0xb0(%rsp), %r9
cmpq %r9, %rsi
je 0x18a48
movq 0xb0(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x18a57
movq %r14, %rdi
callq 0x4100
jmp 0x18a68
leaq 0xa0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x44d0
leaq 0x48(%rsp), %rsi
movq %rsi, 0x38(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x18a8d
movq %rdx, 0x38(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x48(%rsp)
jmp 0x18a93
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x40(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x120(%rsp), %rax
movq %rax, 0x110(%rsp)
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
leaq 0xcf3d(%rip), %rsi      # 0x25a0f
leaq 0xcf3b(%rip), %rdx      # 0x25a14
callq 0x579e
leaq 0x19a03(%rip), %rdi     # 0x324e8
movl $0x1, %esi
leaq 0x38(%rsp), %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x20f32
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x18b1f
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x18b3b
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x18b60
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x18b7c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x18b98
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x188(%rsp), %rdi
leaq 0x198(%rsp), %rax
cmpq %rax, %rdi
movq 0x150(%rsp), %rbp
je 0x18bc5
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
movq 0x160(%rsp), %rbx
je 0x18bf2
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x4470
movl 0xc(%rsp), %esi
movq %rbp, %rdi
callq 0x19296
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x1acb2
addq $0x28, %r13
jmp 0x1874c
addq $0x198, %rbx            # imm = 0x198
movq 0x8(%rbp), %rax
cmpq 0x8(%rax), %rbx
jne 0x18675
movq 0x80(%rsp), %rax
cmpq 0x88(%rsp), %rax
je 0x18e40
leaq 0x80(%rsp), %rdi
callq 0x7b26
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x30, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x1f8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xcd4d(%rip), %rsi      # 0x259ce
leaq 0xcd55(%rip), %rdx      # 0x259dd
leaq 0x1e8(%rsp), %rdi
callq 0x579e
callq 0x4050
movl (%rax), %ebx
leaq 0x258(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xcdc9(%rip), %rdx      # 0x25a78
leaq 0x248(%rsp), %rdi
movq %rdx, %rsi
callq 0x579e
movb $0x1, %bpl
leaq 0x1e8(%rsp), %rsi
leaq 0x248(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %edx
callq 0x65b0
xorl %ebp, %ebp
leaq 0x1901b(%rip), %rsi     # 0x31d00
leaq -0x12324(%rip), %rdx    # 0x69c8
movq %r14, %rdi
callq 0x4760
jmp 0x18ed3
movl $0x30, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x1b8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xccd8(%rip), %rsi      # 0x259f1
leaq 0xcce0(%rip), %rdx      # 0x25a00
leaq 0x1a8(%rsp), %rdi
callq 0x579e
callq 0x4050
movl (%rax), %ebx
leaq 0x238(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xcd31(%rip), %rdx      # 0x25a78
leaq 0x228(%rsp), %rdi
movq %rdx, %rsi
callq 0x579e
movb $0x1, %bpl
leaq 0x1a8(%rsp), %rsi
leaq 0x228(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %edx
callq 0x65b0
xorl %ebp, %ebp
leaq 0x18f83(%rip), %rsi     # 0x31d00
leaq -0x123bc(%rip), %rdx    # 0x69c8
movq %r14, %rdi
callq 0x4760
jmp 0x18ed3
movl $0x30, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x1d8(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0xcc2d(%rip), %rsi      # 0x259de
leaq 0xcc38(%rip), %rdx      # 0x259f0
leaq 0x1c8(%rsp), %rdi
callq 0x579e
callq 0x4050
movl (%rax), %ebx
leaq 0xc64f(%rip), %rdx      # 0x25422
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x9276
movl 0x20(%r13), %esi
leaq 0x58(%rsp), %rdi
callq 0x106c9
leaq 0x268(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x1ab1e
movb $0x1, %r13b
leaq 0x1c8(%rsp), %rsi
leaq 0x268(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %edx
callq 0x65b0
xorl %r13d, %r13d
leaq 0x18ed4(%rip), %rsi     # 0x31d00
leaq -0x1246b(%rip), %rdx    # 0x69c8
movq %r14, %rdi
callq 0x4760
jmp 0x18ed3
movl $0x30, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x178(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xcb91(%rip), %rsi      # 0x259f1
leaq 0xcb99(%rip), %rdx      # 0x25a00
leaq 0x168(%rsp), %rdi
callq 0x579e
callq 0x4050
movl (%rax), %ebx
leaq 0x218(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xcbea(%rip), %rdx      # 0x25a78
leaq 0x208(%rsp), %rdi
movq %rdx, %rsi
callq 0x579e
movb $0x1, %bpl
leaq 0x168(%rsp), %rsi
leaq 0x208(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %edx
callq 0x65b0
xorl %ebp, %ebp
leaq 0x18e3c(%rip), %rsi     # 0x31d00
leaq -0x12503(%rip), %rdx    # 0x69c8
movq %r14, %rdi
callq 0x4760
movq %rax, %r12
movq 0x208(%rsp), %rdi
cmpq %r13, %rdi
je 0x18ef3
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x168(%rsp), %rdi
cmpq %r15, %rdi
je 0x190d6
movq 0x178(%rsp), %rsi
jmp 0x190ce
movq %rax, %r12
movq 0x168(%rsp), %rdi
cmpq %r15, %rdi
je 0x19109
movq 0x178(%rsp), %rsi
jmp 0x190f8
jmp 0x19106
movq %rax, %r12
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x18f5b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x18f5b
movq %rax, %r12
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x19281
movq 0xf0(%rsp), %rsi
jmp 0x1926c
jmp 0x1927e
movq %rax, %r12
leaq 0x278(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18fb2
movq 0x278(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x18fb2
movq %rax, %r12
movb $0x1, %r13b
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x18fe0
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x18fe0
jmp 0x1927e
jmp 0x1927e
movq %rax, %r12
movb $0x1, %r13b
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x18ffc
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x1c8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x19019
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x4470
testb %r13b, %r13b
jne 0x19109
jmp 0x19281
movq %rax, %r12
movq 0x1c8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x19109
movq 0x1d8(%rsp), %rsi
jmp 0x190f8
movq %rax, %r12
movq 0x228(%rsp), %rdi
cmpq %r13, %rdi
je 0x19068
movq 0x238(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x190d6
movq 0x1b8(%rsp), %rsi
jmp 0x190ce
movq %rax, %r12
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x19109
movq 0x1b8(%rsp), %rsi
jmp 0x190f8
movq %rax, %r12
movq 0x248(%rsp), %rdi
cmpq %r13, %rdi
je 0x190b9
movq 0x258(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x1e8(%rsp), %rdi
cmpq %r15, %rdi
je 0x190d6
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x4470
testb %bpl, %bpl
jne 0x19109
jmp 0x19281
movq %rax, %r12
movq 0x1e8(%rsp), %rdi
cmpq %r15, %rdi
je 0x19109
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x19109
jmp 0x19106
jmp 0x19106
movq %rax, %r12
movq %r14, %rdi
callq 0x4310
jmp 0x19281
movq %rax, %r12
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x1916c
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x1916c
movq %rax, %r12
jmp 0x1920e
movq %rax, %r12
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x19195
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x19195
movq %rax, %r12
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x191be
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x191be
movq %rax, %r12
jmp 0x1922a
movq %rax, %r12
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x19281
movq 0xd0(%rsp), %rsi
jmp 0x1926c
movq %rax, %r12
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x191f2
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x191f2
movq %rax, %r12
jmp 0x1924f
jmp 0x1927e
movq %rax, %r12
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1920e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1922a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x188(%rsp), %rdi
leaq 0x198(%rsp), %rax
cmpq %rax, %rdi
je 0x1924f
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0x19281
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x19281
jmp 0x1927e
jmp 0x1927e
jmp 0x1927e
jmp 0x1927e
movq %rax, %r12
leaq 0x80(%rsp), %rdi
callq 0x7b26
movq %r12, %rdi
callq 0x4790