// File: /workspace/github_cpp_makefile_star2_O1/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 0x1f45c
leaq 0x90(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x6bac
movq %r14, %r12
movq (%r14), %r14
leaq 0xf8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xf537(%rip), %rsi      # 0x2588f
leaq 0xf53f(%rip), %rdx      # 0x2589e
leaq 0xe8(%rsp), %rdi
callq 0x578e
leaq 0xe8(%rsp), %rsi
movq %r14, %rdi
callq 0x9f0c
leaq 0xd0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0x6bac
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x163bc
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x4460
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 0xf58b(%rip), %rsi      # 0x25976
leaq 0xf594(%rip), %rdx      # 0x25986
leaq 0x10(%rsp), %rdi
callq 0x578e
movq %r12, %rdi
addq $0x190, %rdi            # imm = 0x190
leaq 0x10(%rsp), %rsi
movq %rdi, 0xe0(%rsp)
callq 0x104da
movq 0x8(%rax), %rdx
leaq 0xf550(%rip), %rcx      # 0x25973
movl $0x2, %r8d
movq %rax, %rdi
xorl %esi, %esi
callq 0x4680
movq %rbx, 0x78(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x16454
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4460
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 0xf53c(%rip), %rsi      # 0x259c9
xorl %edx, %edx
callq 0x4650
leaq 0x10(%rsp), %rdi
movq %r14, %r13
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4480
movq 0x50(%rsp), %r12
movq 0x58(%rsp), %rbp
cmpq %r12, %rbp
je 0x164ec
movq %r15, %r14
leaq 0x10(%r12), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x164d4
movq (%r15), %rsi
incq %rsi
callq 0x4460
leaq 0x20(%r15), %rax
addq $0x10, %r15
cmpq %rbp, %r15
movq %rax, %r15
jne 0x164c0
movq %r12, 0x58(%rsp)
movq %r14, %r15
movl $0x1, %ecx
leaq 0x10(%rsp), %rdi
leaq 0xf4a9(%rip), %rsi      # 0x259a6
xorl %edx, %edx
callq 0x4770
cmpq $-0x1, %rax
movq %rbx, %r12
je 0x16527
leaq 0x50(%rsp), %rdi
movq 0x78(%rsp), %rbx
movq %rbx, %rsi
callq 0xcbac
movq %r13, %r14
movq %rbx, %r13
jmp 0x1659d
movq 0x78(%rsp), %rax
movq (%rax), %rbp
cmpq 0x8(%rax), %rbp
movq %r13, %r14
movq %rax, %r13
je 0x1659d
movq %r12, %rdi
leaq 0xf482(%rip), %rsi      # 0x259c7
leaq 0x10(%rsp), %rdx
callq 0x567a
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rcx
movq %rbp, %rdi
xorl %edx, %edx
callq 0x4770
movq %rax, %r12
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x1657d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4460
cmpq $-0x1, %r12
je 0x16590
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x6a94
addq $0x20, %rbp
cmpq 0x8(%r13), %rbp
movq %rbx, %r12
jne 0x1653b
movq 0x50(%rsp), %rax
cmpq 0x58(%rsp), %rax
je 0x16635
movq 0x70(%rsp), %rax
cmpl %eax, 0x8(%rsp)
jle 0x16635
leaq 0xa0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xcbac
movq 0x10(%rsp), %rax
cmpb $0x2a, (%rax)
movl 0x8(%rsp), %eax
movq %rax, 0x70(%rsp)
je 0x16635
movq %r15, 0x30(%rsp)
movq %r12, %rdi
leaq 0xf38a(%rip), %rsi      # 0x25976
leaq 0xf393(%rip), %rdx      # 0x25986
callq 0x578e
movq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x104da
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4230
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x1662c
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4460
movl 0x8(%rsp), %eax
movq %rax, 0x70(%rsp)
movl $0x1, %ecx
movq %r14, %rdi
leaq 0xf383(%rip), %rsi      # 0x259c7
xorl %edx, %edx
callq 0x4770
cmpq $-0x1, %rax
je 0x166a5
movl $0x1, %ecx
movq %r14, %rdi
leaq 0xf367(%rip), %rsi      # 0x259c7
xorl %edx, %edx
callq 0x4650
leaq 0x1(%rax), %rdx
movl $0x1, %ecx
movq %r12, %rdi
movq %r14, %rsi
callq 0x4480
movq %r12, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x244f4
movl %eax, 0x8(%rsp)
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x166a5
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4460
movl $0x1, %ecx
movq %r14, %rdi
leaq 0xf2d3(%rip), %rsi      # 0x25987
xorl %edx, %edx
callq 0x4770
movq %rax, %rbp
cmpq $-0x1, %rax
je 0x16764
movl $0x3, %ecx
movq %r14, %rdi
leaq 0xf2b2(%rip), %rsi      # 0x25989
xorl %edx, %edx
callq 0x4650
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0x4480
movq %r14, %rdi
movq %r12, %rsi
callq 0x4560
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x16715
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4460
movl $0x1a, %ecx
movq %r14, %rdi
leaq 0xf269(%rip), %rsi      # 0x2598d
xorl %edx, %edx
callq 0x4650
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0x4480
movq %r14, %rdi
movq %r12, %rsi
callq 0x4560
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x16796
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4460
jmp 0x16796
movq 0xa0(%rsp), %rax
cmpq 0xa8(%rsp), %rax
je 0x1678e
movb $0x1, %al
movl %eax, 0xc(%rsp)
movq %r13, %rdi
leaq 0xa0(%rsp), %rsi
callq 0xcbac
jmp 0x16796
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x167b2
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4460
cmpq $-0x1, %rbp
jne 0x1647b
leaq 0xa0(%rsp), %rdi
callq 0x69ba
leaq 0x50(%rsp), %rdi
callq 0x69ba
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x167f8
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4460
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
movl 0xc(%rsp), %ebx
je 0x16821
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4460
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 0x1688b
movq %rax, %rbx
jmp 0x168ef
jmp 0x16894
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x168ef
movq 0xf8(%rsp), %rsi
jmp 0x168e7
jmp 0x16894
jmp 0x1686f
jmp 0x16894
jmp 0x16894
jmp 0x16894
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x16897
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4460
jmp 0x16897
movq %rax, %rbx
jmp 0x168b3
jmp 0x16894
jmp 0x16894
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x168b3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4460
leaq 0xa0(%rsp), %rdi
callq 0x69ba
leaq 0x50(%rsp), %rdi
callq 0x69ba
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x168ef
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4460
leaq 0x90(%rsp), %rax
movq 0x80(%rsp), %rdi
cmpq %rax, %rdi
je 0x16914
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4460
movq %rbx, %rdi
callq 0x4780