// File: /workspace/github_cpp_makefile_star2_O3/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
vxorps %xmm0, %xmm0, %xmm0
movq $0x0, 0xb0(%rsp)
movq %rdx, %r14
movl %ecx, %ebp
movq %rdi, %r15
vmovaps %xmm0, 0xa0(%rsp)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
je 0x28269
cmpb $0x2f, (%rsi)
jne 0x2827f
leaq 0x10(%rsp), %rax
addq %rsi, %rdx
movq %rax, -0x10(%rax)
movq %rsp, %rdi
callq 0x21600
jmp 0x28291
leaq 0x16fb3(%rip), %rsi     # 0x3f239
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 0x282b1
callq 0x22130
movq %rsp, %rdi
movq %rbx, (%rdi)
leaq 0x15e6b(%rip), %rsi     # 0x3e129
leaq 0x15e65(%rip), %rdx     # 0x3e12a
callq 0x215e0
movq 0x8(%r14), %rsi
movl %ebp, 0x44(%rsp)
movq %r15, 0x48(%rsp)
movq %r14, 0x58(%rsp)
movq %rsp, %rdi
callq 0x22d30
movl $0x1, %eax
leaq 0x16f49(%rip), %rbx     # 0x3f239
leaq 0x60(%rsp), %rbp
leaq 0x20(%rsp), %r14
movq %rax, 0x50(%rsp)
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x233c0
movq 0x58(%rsp), %r13
movq %rbx, %rsi
movq 0x50(%rsp), %rbx
movl $0x1, %ecx
movq %r13, %rdi
movq %rbx, %rdx
callq 0x23110
movq %rax, %rcx
movq %rax, %r12
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 0x28408
movl $0x1, %ecx
leaq 0x14e46(%rip), %rsi     # 0x3d1c4
movq %rbp, %rdi
xorl %edx, %edx
callq 0x23110
cmpq $-0x1, %rax
je 0x28408
movq $-0x1, %rcx
movq %rbp, %rsi
movq %rax, %r13
movq %r14, %rbp
movq %r14, %rdi
movq %rax, %rdx
movq %rsi, %rbx
callq 0x22330
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
callq 0x22620
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x283d0
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 0x28405
callq 0x22130
movq %rbx, %rbp
movq 0x60(%rsp), %rsi
movzbl (%rsi), %eax
cmpl $0x2a, %eax
je 0x28455
cmpl $0x3a, %eax
jne 0x28491
leaq 0x15d0a(%rip), %rsi     # 0x3e12b
movq %rsp, %rdi
movq %r14, %r13
callq 0x233c0
movl $0x1, %edx
movq $-0x1, %rcx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x22330
leaq 0xa0(%rsp), %rdi
movq %r13, %rsi
callq 0x232f0
jmp 0x284c7
leaq 0x15cd7(%rip), %rsi     # 0x3e133
movq %rsp, %rdi
callq 0x233c0
cmpq $0x1, 0x68(%rsp)
movq %r14, %r13
jne 0x284a0
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x15cb8(%rip), %rsi     # 0x3e138
leaq 0x15cb2(%rip), %rdx     # 0x3e139
movq %r13, %rdi
callq 0x215e0
jmp 0x284b7
movq 0x68(%rsp), %rdx
movq %rsp, %rdi
callq 0x21440
jmp 0x284db
movl $0x1, %edx
movq $-0x1, %rcx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x22330
leaq 0xa0(%rsp), %rdi
movq %r13, %rsi
callq 0x232f0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x284db
callq 0x22130
movq 0x58(%rsp), %rax
movq 0x8(%rax), %r13
cmpq %r13, %r12
jae 0x284f5
leaq 0x1(%r12), %rax
movq %rax, 0x50(%rsp)
jmp 0x2853d
cmpq $0x0, 0x88(%rsp)
je 0x2853d
leaq 0x15154(%rip), %rsi     # 0x3d65b
leaq 0x80(%rsp), %rdx
movq %r14, %rdi
callq 0x21fb0
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rsi
movq %rsp, %rdi
callq 0x21440
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2853d
callq 0x22130
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x28557
callq 0x22130
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2856b
callq 0x22130
leaq 0x16cc7(%rip), %rbx     # 0x3f239
cmpq %r13, %r12
jb 0x282ff
cmpb $0x0, 0x44(%rsp)
je 0x2859d
leaq 0x15bb7(%rip), %rsi     # 0x3e140
movq %rsp, %rdi
leaq 0x10(%rsp), %r14
callq 0x233c0
movq 0x48(%rsp), %rbx
jmp 0x285ca
leaq 0x15b96(%rip), %rsi     # 0x3e13a
movq %rsp, %rdi
leaq 0x10(%rsp), %r14
callq 0x233c0
movq 0x48(%rsp), %rbx
leaq 0x15b7b(%rip), %rsi     # 0x3e138
leaq 0xa0(%rsp), %rdi
callq 0x225b0
leaq 0x60(%rsp), %rdi
movl $0x10, %edx
movq %rsp, %rsi
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 0x28609
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
leaq 0x60(%rsp), %rdi
movq %rax, %rbx
callq 0x221f0
jmp 0x286a9
jmp 0x28673
jmp 0x28673
jmp 0x28640
movq %rax, %rbx
jmp 0x286bc
movq %rax, %rbx
jmp 0x286ae
jmp 0x28678
jmp 0x28654
jmp 0x28678
jmp 0x28678
jmp 0x28654
movq 0x20(%rsp), %rdi
movq %rax, %rbx
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2867b
callq 0x22130
jmp 0x2867b
jmp 0x28678
jmp 0x28678
jmp 0x28673
movq %rax, %rbx
jmp 0x286a9
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x28695
callq 0x22130
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x286a9
callq 0x22130
leaq 0x10(%rsp), %r14
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x286bc
callq 0x22130
leaq 0xa0(%rsp), %rdi
callq 0x21c70
movq %rbx, %rdi
callq 0x23160
nop