// File: alfanick[P]rest-cpp/src/rest/router.cpp
// Function: REST::Router::find(REST::Request&, int)
Service* Router::find(Request &request, int worker_id) {
    const std::string &path = request.path;

    for (const auto &route : instance()->routes) {
      std::smatch matches;
      std::regex_match(path, matches, std::get<0>(route).first);

      if (!matches.empty()) {
        const auto &params = std::get<0>(route).second;

        for (size_t i = 1; i < matches.size(); i++) {
          request.parameters[params[i-1]] = matches[i];
          request.parameters[std::to_string(i)] = matches[i];
        }

        return std::get<2>(route)[worker_id];
      }
    }

    return nullptr;
  }

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x128(%rsp)
movl %esi, 0x124(%rsp)
movq 0x128(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x118(%rsp)
callq 0x8ee40
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rdi
callq 0x94260
movq %rax, 0x108(%rsp)
movq 0x110(%rsp), %rdi
callq 0x8dd60
movq %rax, 0x100(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x98060
testb $0x1, %al
jne 0xa794f
jmp 0xa7c30
leaq 0x108(%rsp), %rdi
callq 0x8ecd0
movq %rax, 0xf8(%rsp)
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x8eb20
movq 0x118(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x976c0
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x96aa0
jmp 0xa79a6
leaq 0xd8(%rsp), %rdi
callq 0x914a0
testb $0x1, %al
jne 0xa7bec
movq 0xf8(%rsp), %rdi
callq 0x976c0
addq $0x20, %rax
movq %rax, 0xc0(%rsp)
movq $0x1, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x97530
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0xa7bba
movq 0xb8(%rsp), %rsi
leaq 0xd8(%rsp), %rdi
callq 0x98820
movq %rax, 0x30(%rsp)
jmp 0xa7a27
movq 0x30(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0x90e50
jmp 0xa7a3b
movq 0x128(%rsp), %rax
addq $0x58, %rax
movq %rax, 0x20(%rsp)
movq 0xc0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
decq %rsi
callq 0x944d0
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x8d350
movq %rax, 0x28(%rsp)
jmp 0xa7a78
movq 0x28(%rsp), %rdi
leaq 0x98(%rsp), %rsi
movq %rsi, 0x10(%rsp)
callq 0x94870
movq 0x10(%rsp), %rdi
callq 0x99830
movq 0xb8(%rsp), %rsi
leaq 0xd8(%rsp), %rdi
callq 0x98820
movq %rax, 0x18(%rsp)
jmp 0xa7ab5
movq 0x18(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x90e50
jmp 0xa7ac6
movq 0x128(%rsp), %rax
addq $0x58, %rax
movq %rax, 0x8(%rsp)
movq 0xb8(%rsp), %rsi
leaq 0x58(%rsp), %rdi
callq 0x8ed70
jmp 0xa7aeb
movq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x98d00
movq %rax, (%rsp)
jmp 0xa7b00
movq (%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x94870
leaq 0x58(%rsp), %rdi
callq 0x99830
leaq 0x78(%rsp), %rdi
callq 0x99830
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
jmp 0xa79e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0xa7c21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x99830
jmp 0xa7c21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0xa7bae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x99830
leaq 0x78(%rsp), %rdi
callq 0x99830
jmp 0xa7c21
movq 0xf8(%rsp), %rdi
callq 0x93600
movq %rax, %rdi
movslq 0x124(%rsp), %rsi
callq 0x96820
movq (%rax), %rax
movq %rax, 0x130(%rsp)
movl $0x1, 0x54(%rsp)
jmp 0xa7bf4
movl $0x0, 0x54(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x98b50
movl 0x54(%rsp), %eax
testl %eax, %eax
je 0xa7c0d
jmp 0xa7c0b
jmp 0xa7c3c
jmp 0xa7c0f
leaq 0x108(%rsp), %rdi
callq 0x94080
jmp 0xa7931
leaq 0xd8(%rsp), %rdi
callq 0x98b50
jmp 0xa7c4c
movq $0x0, 0x130(%rsp)
movq 0x130(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
retq
movq 0xd0(%rsp), %rdi
callq 0x981c0
nopl (%rax)