// File: /workspace/github_cpp_makefile_star2_O3/solaldunckel[P]webserv/srcs/Config/ServerConfig.cpp
// Function: ServerConfig::listen(__gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&)
void ServerConfig::listen(std::vector<std::string>::iterator &it) {
  std::string str = *it;
  std::string ip = "0.0.0.0";
  uint32_t port = 8000;

  if (str.find(':') != std::string::npos) {
    ip = str.substr(0, str.find(':'));

    std::string port_str = str.substr(str.find(':') + 1);

    if (port_str.find_first_not_of("0123456789") != std::string::npos) {
      throw std::runtime_error("invalid port :" + port_str);
    }

    port = ft::stoi(port_str);
    if (port > 65535)
      throw std::runtime_error("duplicate value in 'listen'");
  }
  else if (str.find_first_not_of("0123456789") != std::string::npos) {
    ip = str;
  }
  else
    port = ft::stoi(str);

  Listen list(ip, port);

  if (std::find(listens_.begin(), listens_.end(), list) != listens_.end())
    throw std::runtime_error("duplicate value in 'listen'");
    // throw webserv_exception("duplicate listen " + ip + ":" + port);

  listens_.push_back(Listen(ip, port));

  if (*++it != ";")
    throw std::runtime_error("double value in 'listen'");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rax
leaq 0x60(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0x6c2a
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x19801(%rip), %rsi     # 0x25340
leaq 0x19801(%rip), %rdx     # 0x25347
leaq 0x30(%rsp), %rdi
callq 0x579e
leaq 0x50(%rsp), %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x4590
cmpq $-0x1, %rax
je 0xbc42
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x4590
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4490
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x4570
movq (%r15), %rdi
leaq 0x18(%rsp), %r12
cmpq %r12, %rdi
je 0xbbbd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x4590
leaq 0x1(%rax), %rdx
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
movq $-0x1, %rcx
callq 0x4490
leaq 0x19601(%rip), %rsi     # 0x251f1
leaq 0x8(%rsp), %rdi
movl $0xa, %ecx
xorl %edx, %edx
callq 0x4730
cmpq $-0x1, %rax
jne 0xbe79
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x24471
movl %eax, %ebp
cmpl $0x10000, %eax          # imm = 0x10000
jae 0xbec6
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xbc89
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0xbc89
leaq 0x195a8(%rip), %rsi     # 0x251f1
leaq 0x50(%rsp), %rdi
movl $0xa, %ecx
xorl %edx, %edx
callq 0x4730
cmpq $-0x1, %rax
je 0xbc76
movl $0x1f40, %ebp           # imm = 0x1F40
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x4230
jmp 0xbc89
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x24471
movl %eax, %ebp
leaq 0xc8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x6c2a
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x6c2a
movl %ebp, 0x28(%rsp)
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0xbcf7
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x8(%r14), %rdi
movq 0x10(%r14), %rsi
leaq 0x8(%rsp), %rdx
callq 0xdaed
cmpq 0x10(%r14), %rax
jne 0xbe29
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x6c2a
leaq 0x80(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x6c2a
addq $0x8, %r14
leaq 0x70(%rsp), %rsi
movl %ebp, 0x20(%rsi)
movq %r14, %rdi
callq 0xdc52
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0xbd91
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0xbdae
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x4470
movq (%rbx), %rdi
addq $0x20, %rdi
movq %rdi, (%rbx)
leaq 0x19bcc(%rip), %rsi     # 0x2598b
callq 0x40f0
testl %eax, %eax
jne 0xbe47
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0xbddf
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xbdfb
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xbe17
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x195e7(%rip), %rsi     # 0x25424
movq %rax, %rdi
callq 0x4170
jmp 0xbe63
movl $0x10, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x195e5(%rip), %rsi     # 0x25440
movq %rax, %rdi
callq 0x4170
movq 0x26186(%rip), %rsi     # 0x31ff0
movq 0x26137(%rip), %rdx     # 0x31fa8
movq %r14, %rdi
callq 0x4760
movl $0x10, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x19588(%rip), %rsi     # 0x25415
leaq 0x70(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x568a
movb $0x1, %bpl
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x46e0
xorl %ebp, %ebp
movq 0x2613b(%rip), %rsi     # 0x31ff0
movq 0x260ec(%rip), %rdx     # 0x31fa8
movq %r14, %rdi
callq 0x4760
jmp 0xbef8
movl $0x10, %edi
callq 0x41d0
movq %rax, %r14
leaq 0x1954a(%rip), %rsi     # 0x25424
movq %rax, %rdi
callq 0x4170
movq 0x26107(%rip), %rsi     # 0x31ff0
movq 0x260b8(%rip), %rdx     # 0x31fa8
movq %r14, %rdi
callq 0x4760
jmp 0xbf25
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbf1e
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
testb %bpl, %bpl
jne 0xbf28
jmp 0xbf53
movq %rax, %rbx
movq %r14, %rdi
callq 0x4310
jmp 0xbf53
jmp 0xbfda
jmp 0xbf39
movq %rax, %rbx
movq %r14, %rdi
callq 0x4310
jmp 0xbfa7
jmp 0xbfda
jmp 0xbfda
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
jne 0xbfb1
jmp 0xbfdd
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0xbf83
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0xbf83
jmp 0xbfa4
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0xbfa7
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0xbfa7
jmp 0xbfa4
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0xbfdd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0xbfdd
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0xbfdd
movq 0xc8(%rsp), %rsi
jmp 0xbfb6
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xbff9
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xc015
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4790
movq %rax, %rbx
jmp 0xbff9