// File: /workspace/github_cpp_makefile_star2_O2/solaldunckel[P]webserv/srcs/Config/Config.cpp
// Function: Config::parse()
void Config::parse() {
  tokenize();
  int i = 1;
  std::vector<std::string>::iterator it;

  for (it = tokens_.begin(); it != tokens_.end(); ++it) {
    if (*it == "server") {
      ServerConfig serv;

      serv.id_ = i++;
      serv.server(++it);
      servers_.push_back(serv);
    }
    else if (*it == "workers") {
      workers_ = ft::stoi(*(++it));
      if (workers_ > 16 || workers_ < 0)
        throw std::runtime_error("workers must be between [0-16]range");
      if (*++it != ";")
        throw std::runtime_error("missing ';' in 'workers'");
    }
    else
      throw webserv_exception("invalid directive % in main block", 0, *it);
  }
  if (servers_.empty())
    throw webserv_exception("missing server block");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rdi, %rbx
callq 0x57ee
movq 0x48(%rbx), %rdi
leaq 0x60(%rbx), %r14
pushq $0x1
popq %r13
leaq 0x164b3(%rip), %r15     # 0x1c0c9
leaq 0x90(%rsp), %r12
leaq 0x16d05(%rip), %rbp     # 0x1c92a
movq %rdi, (%rsp)
cmpq 0x50(%rbx), %rdi
je 0x5cd6
movq %r15, %rsi
callq 0x610b
testb %al, %al
je 0x5c77
movq %r12, %rdi
callq 0x9bd4
movl %r13d, 0x90(%rsp)
addq $0x20, (%rsp)
movq %r12, %rdi
movq %rsp, %rsi
callq 0xac3c
movq %r14, %rdi
movq %r12, %rsi
callq 0x619c
incl %r13d
movq %r12, %rdi
callq 0xa160
jmp 0x5cc9
movq (%rsp), %rdi
leaq 0x1644e(%rip), %rsi     # 0x1c0d0
callq 0x610b
testb %al, %al
je 0x5d15
movq (%rsp), %rdi
addq $0x20, %rdi
movq %rdi, (%rsp)
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x1b536
movl %eax, 0x24(%rbx)
cmpl $0x11, %eax
jae 0x5cf6
movq (%rsp), %rdi
addq $0x20, %rdi
movq %rdi, (%rsp)
movq %rbp, %rsi
callq 0x61cb
testb %al, %al
jne 0x5d7b
movq (%rsp), %rdi
addq $0x20, %rdi
jmp 0x5c25
movq 0x60(%rbx), %rax
cmpq 0x68(%rbx), %rax
je 0x5dab
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x41e0
movq %rax, %r14
leaq 0x163d0(%rip), %rsi     # 0x1c0d8
movq %rax, %rdi
callq 0x4170
jmp 0x5d95
pushq $0x30
popq %rdi
callq 0x41e0
movq %rax, %r14
leaq 0x163ee(%rip), %rsi     # 0x1c115
leaq 0x70(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x5328
movq (%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x45e0
movb $0x1, %bpl
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x5e96
xorl %ebp, %ebp
leaq 0x24fa9(%rip), %rsi     # 0x2ad10
leaq 0x2e4(%rip), %rdx       # 0x6052
movq %r14, %rdi
callq 0x4730
jmp 0x5e14
pushq $0x10
popq %rdi
callq 0x41e0
movq %rax, %r14
leaq 0x1636f(%rip), %rsi     # 0x1c0fc
movq %rax, %rdi
callq 0x4170
movq 0x25254(%rip), %rsi     # 0x2aff0
movq 0x2520d(%rip), %rdx     # 0x2afb0
movq %r14, %rdi
callq 0x4730
pushq $0x30
popq %rdi
callq 0x41e0
movq %rax, %r14
leaq 0x1637a(%rip), %rsi     # 0x1c137
leaq 0x30(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x5328
leaq 0x16c54(%rip), %rsi     # 0x1ca2a
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x5328
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x5e96
xorl %ebp, %ebp
leaq 0x24f0b(%rip), %rsi     # 0x2ad10
leaq 0x246(%rip), %rdx       # 0x6052
movq %r14, %rdi
callq 0x4730
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4898
jmp 0x5e29
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
jmp 0x5e4c
jmp 0x5e5c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4898
jmp 0x5e47
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x70(%rsp), %rdi
callq 0x4898
testb %bpl, %bpl
jne 0x5e5f
jmp 0x5e79
jmp 0x5e5c
jmp 0x5e5c
movq %rax, %rbx
movq %r14, %rdi
callq 0x4310
jmp 0x5e79
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0xa160
movq %rbx, %rdi
callq 0x4750
nop