// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./src/router.h
// Function: route::route(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::pair<int, std::map<std::string, std::string>>
    route(const std::string& uri){
        std::string tmp = "";
        int last_pos = 1;
        struct Tree *top = root;
        std::map<std::string, std::string> ret;
        if(uri == "/" || uri.empty()) return make_pair(0, ret);

        std::string has_catcher = "";

        for(auto i = 1; i < uri.size(); ++i){
            if(uri[i] == '/'){
                tmp = uri.substr(last_pos, i - last_pos);
                last_pos = i + 1;

                if(!has_catcher.empty()){
                    ret[has_catcher] = tmp;
                    has_catcher = "";
                    continue;
                }

                if(top->to[tmp]){
                    top = top->to[tmp];

                    if(!top->catcher.empty()){
                        has_catcher = top->catcher;
                    }
                    continue;
                }
                else{
                    return make_pair(-1, ret);
                }
            }
            if(i == uri.size() - 1){
                tmp = uri.substr(last_pos, i - last_pos + 1);
                // std::cout << tmp << ",";
                if(!has_catcher.empty()){
                    ret[has_catcher] = tmp;
                    break;
                }

                if(top->to[tmp]) 
                    top = top->to[tmp];
                else
                    return make_pair(-1, ret);
            }
        }

        return make_pair(top->ending, ret);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
leaq 0x560a3(%rip), %rsi     # 0x67652
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0xcb10
movq 0x765a3(%rip), %r15     # 0x87b68
leaq 0x60(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x57fa6(%rip), %rsi     # 0x6958c
movq %rbx, %rdi
callq 0x10fbd
testb %al, %al
jne 0x1177b
cmpq $0x0, 0x8(%rbx)
je 0x1177b
movq %rbx, 0x10(%rsp)
leaq 0x56045(%rip), %rsi     # 0x67652
leaq 0x18(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0xcb10
pushq $0x1
popq %rbx
pushq $0x1
popq %rbp
pushq $0x2
popq %r13
movq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rax
cmpq %rbp, %rax
jbe 0x117af
movq (%rsi), %rcx
cmpb $0x2f, (%rcx,%rbp)
movslq %ebx, %rdx
jne 0x116ba
movl %edx, %eax
notl %eax
addl %r13d, %eax
movslq %eax, %rcx
leaq 0x88(%rsp), %r12
movq %r12, %rdi
callq 0xcb30
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xc5f0
movq %r12, %rdi
callq 0xcd88
cmpq $0x0, 0x20(%rsp)
je 0x1172e
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x14e40
movq %rax, %rdi
leaq 0x38(%rsp), %rsi
callq 0xcc70
leaq 0x18(%rsp), %rdi
leaq 0x55fa5(%rip), %rsi     # 0x67652
callq 0xcd10
movl %r13d, %ebx
jmp 0x11770
decq %rax
cmpq %rax, %rbp
jne 0x11770
movl %r13d, %eax
subl %edx, %eax
movslq %eax, %rcx
leaq 0x88(%rsp), %r14
movq %r14, %rdi
movq 0x10(%rsp), %rsi
callq 0xcb30
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0xc5f0
movq %r14, %rdi
callq 0xcd88
cmpq $0x0, 0x20(%rsp)
jne 0x11793
movq %r15, %rdi
movq %r12, %rsi
callq 0x14dda
cmpq $0x0, (%rax)
je 0x117fd
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x14dda
movq (%rax), %r15
jmp 0x11770
movq %r15, %rdi
movq %rbx, %rsi
callq 0x14dda
cmpq $0x0, (%rax)
je 0x11815
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x14dda
movq (%rax), %r15
cmpq $0x0, 0x38(%r15)
je 0x1176d
leaq 0x30(%r15), %rsi
leaq 0x18(%rsp), %rdi
callq 0xcc70
movl %r13d, %ebx
jmp 0x11770
movl %r13d, %ebx
incq %rbp
incl %r13d
jmp 0x11629
movq 0x8(%rsp), %rbx
andl $0x0, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x58(%rsp), %rsi
callq 0x15ec6
jmp 0x117d4
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x14e40
leaq 0x38(%rsp), %rsi
movq %rax, %rdi
callq 0xcc70
addq $0x50, %r15
leaq 0x58(%rsp), %rdx
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x1619a
leaq 0x18(%rsp), %rdi
callq 0xcd88
movq 0x8(%rsp), %rbx
leaq 0x58(%rsp), %rdi
callq 0x161aa
leaq 0x38(%rsp), %rdi
callq 0xcd88
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rax
orl $-0x1, (%rax)
leaq 0x8(%rax), %rdi
leaq 0x58(%rsp), %rsi
callq 0x15ec6
jmp 0x117c5
movq 0x8(%rsp), %rax
orl $-0x1, (%rax)
leaq 0x8(%rax), %rdi
leaq 0x58(%rsp), %rsi
callq 0x15ec6
jmp 0x117c5
jmp 0x11840
jmp 0x11840
jmp 0x11840
jmp 0x11840
jmp 0x11837
movq %rax, %rbx
jmp 0x1184d
jmp 0x11840
jmp 0x11840
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xcd88
leaq 0x58(%rsp), %rdi
callq 0x161aa
leaq 0x38(%rsp), %rdi
callq 0xcd88
movq %rbx, %rdi
callq 0xc790