// File: /workspace/github_cpp_makefile_star2_O3/solaldunckel[P]webserv/srcs/HTTP/Response.cpp
// Function: Response::localization(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>>>>&)
bool Response::localization(std::vector<std::string> &matches){
  std::string path = file_.getPath();
  std::string all = config_.getHeader("Accept-Language");
  int q = 10;
  int max = 0;
  std::vector<std::string> new_matches;
  std::vector<std::string> select_matches;

  headers_["Content-Language"] = "fr";
  while (1) {
    std::string str = all.substr(0, all.find_first_of(" ,;\0"));
    new_matches.clear();
    if (str.find("*") == std::string::npos){
      for (std::vector<std::string>::iterator it = matches.begin() ; it != matches.end() ; it++)
        if (it->find("." + str) != std::string::npos)
          new_matches.push_back(*it);
    }
    else
      new_matches = matches;
    if (!new_matches.empty() && (q > max)) {
      select_matches = new_matches;
      if (str[0] != '*')
        headers_["Content-Language"] = str;
      max = q;
    }
    if (all.find(".") != std::string::npos)
      q = ft::stoi(all.substr(all.find_first_of(".") + 1, 1));
    if (all.find(",") == std::string::npos){
      if (!select_matches.empty()) {
        matches = select_matches;
        return (1);
      }
      return (0);
    }
    all = all.substr(all.find_first_of(" ,;"));
    all = all.substr(all.find_first_of("abcdefghijklmnoprstuvwxyz*"));
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movq %rdi, %r14
addq $0x8, %rdi
callq 0x1f480
leaq 0x90(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x6c2a
movq %r14, %r12
movq (%r14), %r14
leaq 0xf8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xf4a1(%rip), %rsi      # 0x2588f
leaq 0xf4a9(%rip), %rdx      # 0x2589e
leaq 0xe8(%rsp), %rdi
callq 0x579e
leaq 0xe8(%rsp), %rsi
movq %r14, %rdi
callq 0x9f62
leaq 0xd0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0x6c2a
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x16452
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x4470
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %eax, %eax
movq %rax, 0x60(%rsp)
movq %rax, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xf4f5(%rip), %rsi      # 0x25976
leaq 0xf4fe(%rip), %rdx      # 0x25986
leaq 0x10(%rsp), %rdi
callq 0x579e
movq %r12, %rdi
addq $0x190, %rdi            # imm = 0x190
leaq 0x10(%rsp), %rsi
movq %rdi, 0xe0(%rsp)
callq 0x105ca
movq 0x8(%rax), %rdx
leaq 0xf4ba(%rip), %rcx      # 0x25973
movl $0x2, %r8d
movq %rax, %rdi
xorl %esi, %esi
callq 0x4690
movq %rbx, 0x78(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x164ea
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x40(%rsp), %r15
movq $0x0, 0x70(%rsp)
movl $0xa, 0x8(%rsp)
leaq 0xc0(%rsp), %r14
leaq 0x30(%rsp), %r12
movl %eax, 0xc(%rsp)
movq %r12, %rbx
movl $0x3, %ecx
movq %r14, %rdi
leaq 0xf4a6(%rip), %rsi      # 0x259c9
xorl %edx, %edx
callq 0x4660
leaq 0x10(%rsp), %rdi
movq %r14, %r13
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4490
movq 0x50(%rsp), %r12
movq 0x58(%rsp), %rbp
cmpq %r12, %rbp
je 0x16582
movq %r15, %r14
leaq 0x10(%r12), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x1656a
movq (%r15), %rsi
incq %rsi
callq 0x4470
leaq 0x20(%r15), %rax
addq $0x10, %r15
cmpq %rbp, %r15
movq %rax, %r15
jne 0x16556
movq %r12, 0x58(%rsp)
movq %r14, %r15
movl $0x1, %ecx
leaq 0x10(%rsp), %rdi
leaq 0xf413(%rip), %rsi      # 0x259a6
xorl %edx, %edx
callq 0x4780
cmpq $-0x1, %rax
movq %rbx, %r12
je 0x165bd
leaq 0x50(%rsp), %rdi
movq 0x78(%rsp), %rbx
movq %rbx, %rsi
callq 0xcc34
movq %r13, %r14
movq %rbx, %r13
jmp 0x16633
movq 0x78(%rsp), %rax
movq (%rax), %rbp
cmpq 0x8(%rax), %rbp
movq %r13, %r14
movq %rax, %r13
je 0x16633
movq %r12, %rdi
leaq 0xf3ec(%rip), %rsi      # 0x259c7
leaq 0x10(%rsp), %rdx
callq 0x568a
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rcx
movq %rbp, %rdi
xorl %edx, %edx
callq 0x4780
movq %rax, %r12
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x16613
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
cmpq $-0x1, %r12
je 0x16626
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x6b0a
addq $0x20, %rbp
cmpq 0x8(%r13), %rbp
movq %rbx, %r12
jne 0x165d1
movq 0x50(%rsp), %rax
cmpq 0x58(%rsp), %rax
je 0x166cb
movq 0x70(%rsp), %rax
cmpl %eax, 0x8(%rsp)
jle 0x166cb
leaq 0xa0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xcc34
movq 0x10(%rsp), %rax
cmpb $0x2a, (%rax)
movl 0x8(%rsp), %eax
movq %rax, 0x70(%rsp)
je 0x166cb
movq %r15, 0x30(%rsp)
movq %r12, %rdi
leaq 0xf2f4(%rip), %rsi      # 0x25976
leaq 0xf2fd(%rip), %rdx      # 0x25986
callq 0x579e
movq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x105ca
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4230
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x166c2
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movl 0x8(%rsp), %eax
movq %rax, 0x70(%rsp)
movl $0x1, %ecx
movq %r14, %rdi
leaq 0xf2ed(%rip), %rsi      # 0x259c7
xorl %edx, %edx
callq 0x4780
cmpq $-0x1, %rax
je 0x1673b
movl $0x1, %ecx
movq %r14, %rdi
leaq 0xf2d1(%rip), %rsi      # 0x259c7
xorl %edx, %edx
callq 0x4660
leaq 0x1(%rax), %rdx
movl $0x1, %ecx
movq %r12, %rdi
movq %r14, %rsi
callq 0x4490
movq %r12, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x24471
movl %eax, 0x8(%rsp)
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x1673b
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movl $0x1, %ecx
movq %r14, %rdi
leaq 0xf23d(%rip), %rsi      # 0x25987
xorl %edx, %edx
callq 0x4780
movq %rax, %rbp
cmpq $-0x1, %rax
je 0x167fa
movl $0x3, %ecx
movq %r14, %rdi
leaq 0xf21c(%rip), %rsi      # 0x25989
xorl %edx, %edx
callq 0x4660
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0x4490
movq %r14, %rdi
movq %r12, %rsi
callq 0x4570
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x167ab
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movl $0x1a, %ecx
movq %r14, %rdi
leaq 0xf1d3(%rip), %rsi      # 0x2598d
xorl %edx, %edx
callq 0x4660
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0x4490
movq %r14, %rdi
movq %r12, %rsi
callq 0x4570
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x1682c
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x1682c
movq 0xa0(%rsp), %rax
cmpq 0xa8(%rsp), %rax
je 0x16824
movb $0x1, %al
movl %eax, 0xc(%rsp)
movq %r13, %rdi
leaq 0xa0(%rsp), %rsi
callq 0xcc34
jmp 0x1682c
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x16848
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
cmpq $-0x1, %rbp
jne 0x16511
leaq 0xa0(%rsp), %rdi
callq 0x6a2c
leaq 0x50(%rsp), %rdi
callq 0x6a2c
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x1688e
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
movl 0xc(%rsp), %ebx
je 0x168b7
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4470
andb $0x1, %bl
movl %ebx, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16921
movq %rax, %rbx
jmp 0x16985
jmp 0x1692a
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x16985
movq 0xf8(%rsp), %rsi
jmp 0x1697d
jmp 0x1692a
jmp 0x16905
jmp 0x1692a
jmp 0x1692a
jmp 0x1692a
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x1692d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x1692d
movq %rax, %rbx
jmp 0x16949
jmp 0x1692a
jmp 0x1692a
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x16949
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0xa0(%rsp), %rdi
callq 0x6a2c
leaq 0x50(%rsp), %rdi
callq 0x6a2c
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x16985
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x90(%rsp), %rax
movq 0x80(%rsp), %rdi
cmpq %rax, %rdi
je 0x169aa
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4790