// File: /workspace/github_cpp_makefile_star2_O1/alfanick[P]rest-cpp/src/rest/router.cpp
// Function: REST::Router::to_regex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
std::pair<std::regex, std::vector<std::string>> Router::to_regex(std::string path, bool exact) {
    std::vector<std::string> params;
    path = ((!path.empty()) && (path[0] != '/')) ? "/" + path : path;

    std::string regex = "^";
    regex.reserve(path.size());

    size_t start = 1;

    while (true) {
      regex += "/";
      size_t next = path.find("/", start);

      std::string section = path.substr(start, next - start);
      std::string format;

      if (next >= path.size()+1) {
        size_t dot = section.find(".");

        if (dot != std::string::npos) {
          format = section.substr(dot);
          section = section.substr(0, dot);
        }
      }

      if (section[0] == ':') {
        regex += "([^/]+)";
        params.emplace_back(section.substr(1));
      } else
      if (section[0] == '*') {
        regex += "(.+)";
        params.emplace_back(section.size() == 1 ? "*" : section.substr(1));
      } else {
        regex += section;
      }

      if (next >= path.size()) {
        if (!format.empty())
          regex += "\\" + format;
        break;
      }

      start = next + 1;
    }

    if (exact) {
      regex += "$";
    } else {
      regex += "/?(.*)$";
      params.emplace_back("*");
    }

    return std::make_pair(std::regex(regex), params);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rdi, %r15
vxorps %xmm0, %xmm0, %xmm0
vmovaps %xmm0, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
je 0x28309
movq (%r14), %rax
cmpb $0x2f, (%rax)
jne 0x28322
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x21600
jmp 0x28334
leaq 0x17f10(%rip), %rsi     # 0x40239
movq %rsp, %rdi
movq %r14, %rdx
callq 0x21fb0
movq %rsp, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x22620
movq (%rbx), %rdi
leaq 0x10(%rsp), %rbx
cmpq %rbx, %rdi
je 0x28354
callq 0x22130
movq %rsp, %rdi
movq %rbx, (%rdi)
leaq 0x16dc8(%rip), %rsi     # 0x3f129
leaq 0x16dc2(%rip), %rdx     # 0x3f12a
callq 0x215e0
movl %ebp, 0x44(%rsp)
movq %r15, 0x48(%rsp)
movq %r14, 0x58(%rsp)
movq 0x8(%r14), %rsi
movq %rsp, %rdi
callq 0x22d30
movl $0x1, %eax
movq %rax, 0x50(%rsp)
leaq 0x17ea1(%rip), %rbx     # 0x40239
leaq 0x60(%rsp), %rbp
leaq 0x20(%rsp), %r14
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x233d0
movl $0x1, %ecx
movq 0x58(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movq 0x50(%rsp), %rbx
movq %rbx, %rdx
callq 0x23120
movq %rax, %r12
movq %rax, %rcx
subq %rbx, %rcx
movq %rbp, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x22330
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq $0x0, 0x88(%rsp)
movb $0x0, 0x90(%rsp)
movq 0x8(%r13), %rax
incq %rax
cmpq %rax, %r12
jb 0x284ab
movl $0x1, %ecx
movq %rbp, %rdi
leaq 0x15da0(%rip), %rsi     # 0x3e1c4
xorl %edx, %edx
callq 0x23120
cmpq $-0x1, %rax
je 0x284ab
movq %rax, %r13
movq %rbp, %rsi
movq %r14, %rbp
movq %r14, %rdi
movq %rsi, %rbx
movq %rax, %rdx
movq $-0x1, %rcx
callq 0x22330
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
callq 0x22620
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x28473
callq 0x22130
movq %r14, %rbp
movq %r14, %rdi
movq %rbx, %r15
movq %rbx, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x22330
movq %r15, %rdi
movq %rbp, %rsi
callq 0x22620
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x284a8
callq 0x22130
movq %rbx, %rbp
movq 0x60(%rsp), %rsi
movzbl (%rsi), %eax
cmpl $0x2a, %eax
je 0x284f8
cmpl $0x3a, %eax
jne 0x28534
movq %r14, %r13
movq %rsp, %rdi
leaq 0x16c61(%rip), %rsi     # 0x3f12b
callq 0x233d0
movl $0x1, %edx
movq %r13, %rdi
movq %rbp, %rsi
movq $-0x1, %rcx
callq 0x22330
leaq 0xa0(%rsp), %rdi
movq %r13, %rsi
callq 0x23300
jmp 0x2856a
movq %rsp, %rdi
leaq 0x16c31(%rip), %rsi     # 0x3f133
callq 0x233d0
movq %r14, %r13
cmpq $0x1, 0x68(%rsp)
jne 0x28543
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r13, %rdi
leaq 0x16c12(%rip), %rsi     # 0x3f138
leaq 0x16c0c(%rip), %rdx     # 0x3f139
callq 0x215e0
jmp 0x2855a
movq 0x68(%rsp), %rdx
movq %rsp, %rdi
callq 0x21440
jmp 0x2857e
movl $0x1, %edx
movq %r13, %rdi
movq %rbp, %rsi
movq $-0x1, %rcx
callq 0x22330
leaq 0xa0(%rsp), %rdi
movq %r13, %rsi
callq 0x23300
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2857e
callq 0x22130
movq 0x58(%rsp), %rax
movq 0x8(%rax), %r13
cmpq %r13, %r12
jae 0x28598
leaq 0x1(%r12), %rax
movq %rax, 0x50(%rsp)
jmp 0x285e0
cmpq $0x0, 0x88(%rsp)
je 0x285e0
movq %r14, %rdi
leaq 0x160ae(%rip), %rsi     # 0x3e65b
leaq 0x80(%rsp), %rdx
callq 0x21fb0
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rsp, %rdi
callq 0x21440
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x285e0
callq 0x22130
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x285fa
callq 0x22130
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2860e
callq 0x22130
cmpq %r13, %r12
leaq 0x17c21(%rip), %rbx     # 0x40239
jb 0x283a2
cmpb $0x0, 0x44(%rsp)
je 0x28640
leaq 0x16b14(%rip), %rsi     # 0x3f140
movq %rsp, %rdi
leaq 0x10(%rsp), %r14
callq 0x233d0
movq 0x48(%rsp), %rbx
jmp 0x2866d
leaq 0x16af3(%rip), %rsi     # 0x3f13a
movq %rsp, %rdi
leaq 0x10(%rsp), %r14
callq 0x233d0
movq 0x48(%rsp), %rbx
leaq 0x16ad8(%rip), %rsi     # 0x3f138
leaq 0xa0(%rsp), %rdi
callq 0x225b0
leaq 0x60(%rsp), %rdi
movq %rsp, %rsi
movl $0x10, %edx
callq 0x214b0
leaq 0x60(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
movq %rbx, %rdi
callq 0x21bf0
leaq 0x60(%rsp), %rdi
callq 0x221f0
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x286ac
callq 0x22130
leaq 0xa0(%rsp), %rdi
callq 0x21c70
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x221f0
jmp 0x2874c
jmp 0x28716
jmp 0x28716
jmp 0x286e3
movq %rax, %rbx
jmp 0x2875f
movq %rax, %rbx
jmp 0x28751
jmp 0x2871b
jmp 0x286f7
jmp 0x2871b
jmp 0x2871b
jmp 0x286f7
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2871e
callq 0x22130
jmp 0x2871e
jmp 0x2871b
jmp 0x2871b
jmp 0x28716
movq %rax, %rbx
jmp 0x2874c
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x28738
callq 0x22130
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2874c
callq 0x22130
leaq 0x10(%rsp), %r14
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x2875f
callq 0x22130
leaq 0xa0(%rsp), %rdi
callq 0x21c70
movq %rbx, %rdi
callq 0x23170