// File: 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
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x7ef0
movl $0x1, -0xc(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x91f0
movq -0x278(%rbp), %rdi
addq $0x48, %rdi
callq 0x9210
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x278(%rbp), %rdi
addq $0x48, %rdi
callq 0x9280
movq %rax, -0x28(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x9240
testb $0x1, %al
jne 0x8635
jmp 0x8962
leaq -0x18(%rbp), %rdi
callq 0x92b0
movq %rax, %rdi
leaq 0x3aa81(%rip), %rsi     # 0x430c9
callq 0x8ff0
testb $0x1, %al
jne 0x8656
jmp 0x86e0
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x16300
movl -0xc(%rbp), %eax
movl %eax, %ecx
incl %ecx
movl %ecx, -0xc(%rbp)
movl %eax, -0x1c0(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x92d0
movq -0x280(%rbp), %rdi
movq %rax, %rsi
callq 0x18070
jmp 0x8693
movq -0x278(%rbp), %rdi
addq $0x60, %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x92f0
jmp 0x86ac
leaq -0x1c0(%rbp), %rdi
callq 0x16e30
jmp 0x8952
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x16e30
jmp 0x8ac1
leaq -0x18(%rbp), %rdi
callq 0x92b0
movq %rax, %rdi
leaq 0x3a9dd(%rip), %rsi     # 0x430d0
callq 0x8ff0
testb $0x1, %al
jne 0x8701
jmp 0x8831
leaq -0x18(%rbp), %rdi
callq 0x92d0
movq %rax, %rdi
callq 0x92b0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x41890
movl %eax, %ecx
movq -0x278(%rbp), %rax
movl %ecx, 0x24(%rax)
cmpl $0x10, 0x24(%rax)
jg 0x8742
movq -0x278(%rbp), %rax
cmpl $0x0, 0x24(%rax)
jge 0x87a4
movl $0x10, %edi
callq 0x5250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x288(%rbp)
leaq 0x3a978(%rip), %rsi     # 0x430d8
callq 0x51d0
jmp 0x8767
movq -0x288(%rbp), %rdi
movq 0x5387b(%rip), %rsi     # 0x5bff0
movq 0x5381c(%rip), %rdx     # 0x5bf98
callq 0x5920
movq -0x288(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
callq 0x53b0
jmp 0x8ac1
leaq -0x18(%rbp), %rdi
callq 0x92d0
movq %rax, %rdi
callq 0x92b0
movq %rax, %rdi
leaq 0x3b1a8(%rip), %rsi     # 0x43967
callq 0x9360
testb $0x1, %al
jne 0x87ca
jmp 0x882c
movl $0x10, %edi
callq 0x5250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x290(%rbp)
leaq 0x3a914(%rip), %rsi     # 0x430fc
callq 0x51d0
jmp 0x87ef
movq -0x290(%rbp), %rdi
movq 0x537f3(%rip), %rsi     # 0x5bff0
movq 0x53794(%rip), %rdx     # 0x5bf98
callq 0x5920
movq -0x290(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
callq 0x53b0
jmp 0x8ac1
jmp 0x8950
movb $0x1, -0x219(%rbp)
movl $0x30, %edi
callq 0x5250
movq %rax, -0x2a0(%rbp)
leaq -0x1f1(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x5960
movq -0x298(%rbp), %rdx
leaq 0x3a8ab(%rip), %rsi     # 0x43115
leaq -0x1f0(%rbp), %rdi
callq 0x6be0
jmp 0x8878
leaq -0x18(%rbp), %rdi
callq 0x92b0
movq %rax, %rsi
leaq -0x218(%rbp), %rdi
callq 0x5200
jmp 0x8892
movq -0x2a0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
xorl %edx, %edx
leaq -0x218(%rbp), %rcx
callq 0x8b80
jmp 0x88b0
movq -0x2a0(%rbp), %rdi
movb $0x0, -0x219(%rbp)
leaq 0x5342b(%rip), %rsi     # 0x5bcf0
leaq 0x564(%rip), %rdx       # 0x8e30
callq 0x5920
jmp 0x8acd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x8928
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x891c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x5aa8
leaq -0x1f0(%rbp), %rdi
callq 0x5aa8
leaq -0x1f1(%rbp), %rdi
callq 0x55e0
testb $0x1, -0x219(%rbp)
jne 0x893f
jmp 0x894b
movq -0x2a0(%rbp), %rdi
callq 0x53b0
jmp 0x8ac1
jmp 0x8952
jmp 0x8954
leaq -0x18(%rbp), %rdi
callq 0x92d0
jmp 0x860b
movq -0x278(%rbp), %rdi
addq $0x60, %rdi
callq 0x9390
testb $0x1, %al
jne 0x897b
jmp 0x8ab8
movb $0x1, -0x26a(%rbp)
movl $0x30, %edi
callq 0x5250
movq %rax, -0x2b0(%rbp)
leaq -0x241(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x5960
movq -0x2a8(%rbp), %rdx
leaq 0x3a783(%rip), %rsi     # 0x43137
leaq -0x240(%rbp), %rdi
callq 0x6be0
jmp 0x89c2
leaq -0x269(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x5960
movq -0x2b8(%rbp), %rdx
leaq 0x3b071(%rip), %rsi     # 0x43a54
leaq -0x268(%rbp), %rdi
callq 0x6be0
jmp 0x89f1
movq -0x2b0(%rbp), %rdi
leaq -0x240(%rbp), %rsi
xorl %edx, %edx
leaq -0x268(%rbp), %rcx
callq 0x8b80
jmp 0x8a0f
movq -0x2b0(%rbp), %rdi
movb $0x0, -0x26a(%rbp)
leaq 0x532cc(%rip), %rsi     # 0x5bcf0
leaq 0x405(%rip), %rdx       # 0x8e30
callq 0x5920
jmp 0x8acd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x8a93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x8a7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x5aa8
leaq -0x269(%rbp), %rdi
callq 0x55e0
leaq -0x240(%rbp), %rdi
callq 0x5aa8
leaq -0x241(%rbp), %rdi
callq 0x55e0
testb $0x1, -0x26a(%rbp)
jne 0x8aaa
jmp 0x8ab6
movq -0x2b0(%rbp), %rdi
callq 0x53b0
jmp 0x8ac1
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq -0x1c8(%rbp), %rdi
callq 0x5950
nopl (%rax)