// File: solaldunckel[P]webserv/srcs/Config/Config.cpp
// Function: Config::tokenize()
void Config::tokenize() {
  std::string line, tmp;
  std::string::size_type first, last;
  std::stack<bool> brackets;

  int line_idx = 1;
  char *line_c;

  while (get_next_line(fd_, &line_c)) {
    line = line_c;
    file_content_ += line + "\n";
    last = 0;
    while ((first = line.find_first_not_of(" \t", last)) != std::string::npos) {
      if (line[first] == '#')
        break;
      last = line.find_first_of(" \t", first);
      tmp = line.substr(first, last - first);
      if (tmp == "{")
        brackets.push(true);
      else if (tmp == "}") {
        if (brackets.empty())
          throw webserv_exception("extra closing '}' on line %", 0, ft::to_string(line_idx));
        brackets.pop();
      }
      if (isValidDirective(tmp) && line[line.find_last_not_of(" \t", line.length())] != ';')
        throw webserv_exception("missing ';' on line %", 0, ft::to_string(line_idx));
      if (tmp.find(';', tmp.length() - 1) != std::string::npos) {
        tmp.erase(tmp.length() - 1, 1);
        tokens_.push_back(tmp);
        tokens_.push_back(";");
      }
      else
        tokens_.push_back(tmp);
    }
    line_idx++;
    free(line_c);
  }
  free(line_c);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x57b0
leaq -0x48(%rbp), %rdi
callq 0x57b0
leaq -0xa8(%rbp), %rdi
callq 0x8f40
jmp 0x7f2a
movl $0x1, -0xb8(%rbp)
movq -0x1d8(%rbp), %rax
movl 0x20(%rax), %edi
leaq -0xc0(%rbp), %rsi
callq 0x3af00
movl %eax, -0x1dc(%rbp)
jmp 0x7f52
movl -0x1dc(%rbp), %eax
cmpl $0x0, %eax
je 0x855a
movq -0xc0(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x5780
jmp 0x7f73
leaq 0x3b27d(%rip), %rdx     # 0x431f7
leaq -0xe0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x8f70
jmp 0x7f8c
movq -0x1d8(%rbp), %rdi
addq $0x28, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x5710
jmp 0x7fa5
leaq -0xe0(%rbp), %rdi
callq 0x5aa8
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rdx
leaq -0x28(%rbp), %rdi
leaq 0x3b0c8(%rip), %rsi     # 0x43090
callq 0x52f0
movq %rax, -0x50(%rbp)
cmpq $-0x1, %rax
je 0x853a
movq -0x50(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x5a80
movq %rax, -0x1e8(%rbp)
jmp 0x7ff1
movq -0x1e8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x8056
jmp 0x853a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x8599
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x858d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x5aa8
jmp 0x858d
movq -0x50(%rbp), %rdx
leaq 0x3b02f(%rip), %rsi     # 0x43090
leaq -0x28(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x5270
movq -0x1f0(%rbp), %rsi
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
subq %rdx, %rcx
leaq -0x100(%rbp), %rdi
callq 0x55a0
jmp 0x8095
leaq -0x48(%rbp), %rdi
movq %rdi, -0x200(%rbp)
leaq -0x100(%rbp), %rsi
movq %rsi, -0x208(%rbp)
callq 0x56d0
movq -0x208(%rbp), %rdi
callq 0x5aa8
movq -0x200(%rbp), %rdi
leaq 0x3afc6(%rip), %rsi     # 0x43093
callq 0x8ff0
movb %al, -0x1f1(%rbp)
jmp 0x80da
movb -0x1f1(%rbp), %al
testb $0x1, %al
jne 0x80e6
jmp 0x8107
movb $0x1, -0x101(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0x101(%rbp), %rsi
callq 0x9020
jmp 0x8102
jmp 0x827c
leaq 0x3af87(%rip), %rsi     # 0x43095
leaq -0x48(%rbp), %rdi
callq 0x8ff0
movb %al, -0x209(%rbp)
jmp 0x811f
movb -0x209(%rbp), %al
testb $0x1, %al
jne 0x812e
jmp 0x827a
leaq -0xa8(%rbp), %rdi
callq 0x9050
movb %al, -0x20a(%rbp)
jmp 0x8142
movb -0x20a(%rbp), %al
testb $0x1, %al
jne 0x8151
jmp 0x826a
movb $0x1, -0x151(%rbp)
movl $0x30, %edi
callq 0x5250
movq %rax, -0x220(%rbp)
leaq -0x129(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x5960
movq -0x218(%rbp), %rdx
leaq 0x3af0d(%rip), %rsi     # 0x43097
leaq -0x128(%rbp), %rdi
callq 0x6be0
jmp 0x8198
movl -0xb8(%rbp), %esi
leaq -0x150(%rbp), %rdi
callq 0x9070
jmp 0x81ac
movq -0x220(%rbp), %rdi
leaq -0x128(%rbp), %rsi
xorl %edx, %edx
leaq -0x150(%rbp), %rcx
callq 0x8b80
jmp 0x81ca
movq -0x220(%rbp), %rdi
movb $0x0, -0x151(%rbp)
leaq 0x53b11(%rip), %rsi     # 0x5bcf0
leaq 0xc4a(%rip), %rdx       # 0x8e30
callq 0x5920
jmp 0x85b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x8242
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x8236
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x5aa8
leaq -0x128(%rbp), %rdi
callq 0x5aa8
leaq -0x129(%rbp), %rdi
callq 0x55e0
testb $0x1, -0x151(%rbp)
jne 0x8259
jmp 0x8265
movq -0x220(%rbp), %rdi
callq 0x53b0
jmp 0x858d
leaq -0xa8(%rbp), %rdi
callq 0x9110
jmp 0x8278
jmp 0x827a
jmp 0x827c
leaq -0x48(%rbp), %rdi
callq 0x41ef0
movb %al, -0x221(%rbp)
jmp 0x828d
movb -0x221(%rbp), %al
testb $0x1, %al
jne 0x829c
jmp 0x8406
leaq -0x28(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x5830
movq -0x238(%rbp), %rdi
movq %rax, %rdx
leaq 0x3add3(%rip), %rsi     # 0x43090
callq 0x59c0
movq -0x238(%rbp), %rdi
movq %rax, %rsi
callq 0x5a80
movq %rax, -0x230(%rbp)
jmp 0x82da
movq -0x230(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3b, %eax
je 0x8406
movb $0x1, -0x1a1(%rbp)
movl $0x30, %edi
callq 0x5250
movq %rax, -0x248(%rbp)
leaq -0x179(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x5960
movq -0x240(%rbp), %rdx
leaq 0x3ad8d(%rip), %rsi     # 0x430b3
leaq -0x178(%rbp), %rdi
callq 0x6be0
jmp 0x8334
movl -0xb8(%rbp), %esi
leaq -0x1a0(%rbp), %rdi
callq 0x9070
jmp 0x8348
movq -0x248(%rbp), %rdi
leaq -0x178(%rbp), %rsi
xorl %edx, %edx
leaq -0x1a0(%rbp), %rcx
callq 0x8b80
jmp 0x8366
movq -0x248(%rbp), %rdi
movb $0x0, -0x1a1(%rbp)
leaq 0x53975(%rip), %rsi     # 0x5bcf0
leaq 0xaae(%rip), %rdx       # 0x8e30
callq 0x5920
jmp 0x85b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x83de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x83d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x5aa8
leaq -0x178(%rbp), %rdi
callq 0x5aa8
leaq -0x179(%rbp), %rdi
callq 0x55e0
testb $0x1, -0x1a1(%rbp)
jne 0x83f5
jmp 0x8401
movq -0x248(%rbp), %rdi
callq 0x53b0
jmp 0x858d
leaq -0x48(%rbp), %rdi
callq 0x5830
movq %rax, %rdx
subq $0x1, %rdx
leaq -0x48(%rbp), %rdi
movl $0x3b, %esi
callq 0x5730
cmpq $-0x1, %rax
je 0x851d
leaq -0x48(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x5830
movq -0x250(%rbp), %rdi
movq %rax, %rsi
decq %rsi
movl $0x1, %edx
callq 0x50d0
jmp 0x8457
movq -0x1d8(%rbp), %rdi
addq $0x48, %rdi
leaq -0x48(%rbp), %rsi
callq 0x9130
jmp 0x846d
movq -0x1d8(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x260(%rbp)
leaq -0x1c9(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x5960
movq -0x258(%rbp), %rdx
leaq 0x3b4c7(%rip), %rsi     # 0x43967
leaq -0x1c8(%rbp), %rdi
callq 0x6be0
jmp 0x84ae
movq -0x260(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x91a0
jmp 0x84c3
leaq -0x1c8(%rbp), %rdi
callq 0x5aa8
leaq -0x1c9(%rbp), %rdi
callq 0x55e0
jmp 0x8535
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x850f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x5aa8
leaq -0x1c9(%rbp), %rdi
callq 0x55e0
jmp 0x858d
movq -0x1d8(%rbp), %rdi
addq $0x48, %rdi
leaq -0x48(%rbp), %rsi
callq 0x9130
jmp 0x8533
jmp 0x8535
jmp 0x7fb9
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x56b0
jmp 0x7f34
movq -0xc0(%rbp), %rdi
callq 0x56b0
leaq -0xa8(%rbp), %rdi
callq 0x91d0
leaq -0x48(%rbp), %rdi
callq 0x5aa8
leaq -0x28(%rbp), %rdi
callq 0x5aa8
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
leaq -0xa8(%rbp), %rdi
callq 0x91d0
leaq -0x48(%rbp), %rdi
callq 0x5aa8
leaq -0x28(%rbp), %rdi
callq 0x5aa8
movq -0xb0(%rbp), %rdi
callq 0x5950
nopw (%rax,%rax)