// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdi, %r15
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x108(%rsp), %rdi
callq 0x60b8
leaq 0x28(%r15), %rax
movq %rax, 0x20(%rsp)
leaq 0x48(%r15), %r12
pushq $0x1
popq %rbx
leaq 0x28(%rsp), %rbp
leaq 0x48(%rsp), %r13
leaq 0x68(%rsp), %r14
movq %r15, 0x18(%rsp)
movl 0x20(%r15), %edi
leaq 0x10(%rsp), %rsi
callq 0x18c97
movq 0x10(%rsp), %rsi
testl %eax, %eax
je 0x5a2c
movq %rbp, %rdi
callq 0x4830
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x16972(%rip), %rdx     # 0x1c1f7
callq 0x60d3
movl %ebx, 0x8(%rsp)
movq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x4840
movq %r13, %rdi
callq 0x4898
xorl %ebx, %ebx
movq %rbp, %rdi
leaq 0x167e1(%rip), %rsi     # 0x1c090
movq %rbx, %rdx
callq 0x4270
cmpq $-0x1, %rax
je 0x5a12
movq %rax, %r15
movq 0x28(%rsp), %rax
cmpb $0x23, (%rax,%r15)
je 0x5a12
movq %rbp, %rdi
leaq 0x167b2(%rip), %rsi     # 0x1c090
movq %r15, %rdx
callq 0x4200
movq %rax, %rbx
movq %rax, %rcx
subq %r15, %rcx
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x44a0
movq %r14, %rdi
movq %r13, %rsi
callq 0x4560
movq %r13, %rdi
callq 0x4898
movq %r14, %rdi
leaq 0x16779(%rip), %rsi     # 0x1c093
callq 0x610b
testb %al, %al
je 0x593a
movb $0x1, 0x48(%rsp)
leaq 0x108(%rsp), %rdi
movq %r13, %rsi
callq 0x658c
jmp 0x5970
movq %r14, %rdi
leaq 0x16751(%rip), %rsi     # 0x1c095
callq 0x610b
testb %al, %al
je 0x5970
movq 0x138(%rsp), %rax
cmpq 0x118(%rsp), %rax
je 0x5ad3
leaq 0x108(%rsp), %rdi
callq 0x67d8
movq %r14, %rdi
callq 0x1b771
testb %al, %al
je 0x599f
movq 0x30(%rsp), %rdx
movq %rbp, %rdi
leaq 0x16705(%rip), %rsi     # 0x1c090
callq 0x47b0
movq 0x28(%rsp), %rcx
cmpb $0x3b, (%rcx,%rax)
jne 0x5a67
movq 0x70(%rsp), %rdx
decq %rdx
movq %r14, %rdi
pushq $0x3b
popq %rsi
callq 0x45a0
cmpq $-0x1, %rax
je 0x5a02
movq 0x70(%rsp), %rsi
decq %rsi
movq %r14, %rdi
pushq $0x1
popq %rdx
callq 0x40a0
movq %r12, %rdi
movq %r14, %rsi
callq 0x6170
movq %r13, %rdi
leaq 0x16f4a(%rip), %rsi     # 0x1c92a
leaq 0xf(%rsp), %rdx
callq 0x5328
movq %r12, %rdi
movq %r13, %rsi
callq 0x6a06
movq %r13, %rdi
callq 0x4898
jmp 0x58a5
movq %r12, %rdi
movq %r14, %rsi
callq 0x6170
jmp 0x58a5
movl 0x8(%rsp), %ebx
incl %ebx
movq 0x10(%rsp), %rdi
callq 0x4540
movq 0x18(%rsp), %r15
jmp 0x5855
movq %rsi, %rdi
callq 0x4540
leaq 0x108(%rsp), %rdi
callq 0x6274
leaq 0x68(%rsp), %rdi
callq 0x4898
leaq 0x28(%rsp), %rdi
callq 0x4898
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x30
popq %rdi
callq 0x41e0
movq %rax, %r14
leaq 0x1663a(%rip), %rsi     # 0x1c0b3
leaq 0xa8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x5328
leaq 0x88(%rsp), %rdi
movl 0x8(%rsp), %esi
callq 0x6118
movb $0x1, %bpl
leaq 0xa8(%rsp), %rsi
leaq 0x88(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x5e96
xorl %ebp, %ebp
leaq 0x2524e(%rip), %rsi     # 0x2ad10
leaq 0x589(%rip), %rdx       # 0x6052
movq %r14, %rdi
callq 0x4730
jmp 0x5b3d
pushq $0x30
popq %rdi
callq 0x41e0
movq %rax, %r14
leaq 0x165b2(%rip), %rsi     # 0x1c097
leaq 0xe8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x5328
leaq 0xc8(%rsp), %rdi
movl 0x8(%rsp), %esi
callq 0x6118
movb $0x1, %bpl
leaq 0xe8(%rsp), %rsi
leaq 0xc8(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x5e96
xorl %ebp, %ebp
leaq 0x251e2(%rip), %rsi     # 0x2ad10
leaq 0x51d(%rip), %rdx       # 0x6052
movq %r14, %rdi
callq 0x4730
movq %rax, %rbx
jmp 0x5bcd
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x4898
jmp 0x5b5d
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xe8(%rsp), %rdi
jmp 0x5b8d
jmp 0x5bbd
jmp 0x5baa
jmp 0x5b9b
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x4898
jmp 0x5b85
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xa8(%rsp), %rdi
callq 0x4898
testb %bpl, %bpl
jne 0x5b9e
jmp 0x5bc0
jmp 0x5bbd
movq %rax, %rbx
movq %r14, %rdi
callq 0x4310
jmp 0x5bc0
jmp 0x5bbd
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x4898
jmp 0x5bc0
jmp 0x5bbd
jmp 0x5bbd
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x6274
leaq 0x68(%rsp), %rdi
callq 0x4898
leaq 0x28(%rsp), %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4750
nop