// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x168, %rsp            # imm = 0x168
movq %rdi, 0x50(%rsp)
movq %rdi, %rax
movq %rax, 0x58(%rsp)
movq %rdi, 0x160(%rsp)
movq %rsi, 0x158(%rsp)
leaq 0x137(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0xdc30
movq 0x60(%rsp), %rdx
leaq 0xaa939(%rip), %rsi     # 0xc5b4b
leaq 0x138(%rsp), %rdi
callq 0xdad0
jmp 0x1b221
leaq 0x137(%rsp), %rdi
callq 0xdf30
movl $0x1, 0x120(%rsp)
movq 0xd3d00(%rip), %rax     # 0xeef40
movq %rax, 0x118(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x23760
movq 0x158(%rsp), %rdi
leaq 0xacc48(%rip), %rsi     # 0xc7eac
callq 0x19c90
movb %al, 0x4f(%rsp)
jmp 0x1b26f
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x1b28c
jmp 0x1b279
movq 0x158(%rsp), %rdi
callq 0xd3f0
testb $0x1, %al
jne 0x1b28c
jmp 0x1b302
movq 0x50(%rsp), %rdi
movl $0x0, 0xe4(%rsp)
leaq 0xe4(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x23770
jmp 0x1b2b3
movl $0x1, 0xe0(%rsp)
jmp 0x1b6f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
leaq 0x137(%rsp), %rdi
callq 0xdf30
jmp 0x1b731
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
jmp 0x1b717
leaq 0xbf(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0xdc30
movq 0x40(%rsp), %rdx
leaq 0xaa82b(%rip), %rsi     # 0xc5b4b
leaq 0xc0(%rsp), %rdi
callq 0xdad0
jmp 0x1b32f
leaq 0xbf(%rsp), %rdi
callq 0xdf30
movl $0x1, 0xb8(%rsp)
movslq 0xb8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x158(%rsp), %rdi
callq 0xd410
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0x1b6b8
movq 0x158(%rsp), %rdi
movslq 0xb8(%rsp), %rsi
callq 0xddd0
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x1b560
movq 0x158(%rsp), %rsi
movslq 0x120(%rsp), %rdx
movl %edx, %ecx
movl 0xb8(%rsp), %eax
subl %ecx, %eax
movslq %eax, %rcx
leaq 0x98(%rsp), %rdi
callq 0xdca0
jmp 0x1b3c0
leaq 0x138(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xd6f0
leaq 0x98(%rsp), %rdi
callq 0xdf50
movl 0xb8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x120(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0xd3f0
testb $0x1, %al
jne 0x1b49f
leaq 0xe8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x237b0
movq %rax, 0x30(%rsp)
jmp 0x1b424
movq 0x30(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0xde60
jmp 0x1b438
leaq 0xaa70c(%rip), %rsi     # 0xc5b4b
leaq 0xc0(%rsp), %rdi
callq 0xd560
jmp 0x1b44e
jmp 0x1b6a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
leaq 0xbf(%rsp), %rdi
callq 0xdf30
jmp 0x1b717
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0xdf50
jmp 0x1b717
movq 0x118(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x23650
movq %rax, 0x28(%rsp)
jmp 0x1b4bb
movq 0x28(%rsp), %rax
cmpq $0x0, (%rax)
je 0x1b529
movq 0x118(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x23650
movq %rax, 0x20(%rsp)
jmp 0x1b4e2
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x118(%rsp)
movq 0x118(%rsp), %rdi
addq $0x30, %rdi
callq 0xd3f0
testb $0x1, %al
jne 0x1b524
movq 0x118(%rsp), %rsi
addq $0x30, %rsi
leaq 0xc0(%rsp), %rdi
callq 0xde60
jmp 0x1b522
jmp 0x1b524
jmp 0x1b6a2
movq 0x50(%rsp), %rdi
movl $0xffffffff, 0x94(%rsp) # imm = 0xFFFFFFFF
leaq 0x94(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x23770
jmp 0x1b550
movl $0x1, 0xe0(%rsp)
jmp 0x1b6e3
movslq 0xb8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x158(%rsp), %rdi
callq 0xd410
movq %rax, %rcx
movq 0x18(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x1b6a0
movq 0x158(%rsp), %rsi
movslq 0x120(%rsp), %rdx
movl %edx, %ecx
movl 0xb8(%rsp), %eax
subl %ecx, %eax
incl %eax
movslq %eax, %rcx
leaq 0x70(%rsp), %rdi
callq 0xdca0
jmp 0x1b5bb
leaq 0x138(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0xd6f0
leaq 0x70(%rsp), %rdi
callq 0xdf50
leaq 0xc0(%rsp), %rdi
callq 0xd3f0
testb $0x1, %al
jne 0x1b61d
leaq 0xe8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x237b0
movq %rax, 0x10(%rsp)
jmp 0x1b604
movq 0x10(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0xde60
jmp 0x1b618
jmp 0x1b6b8
movq 0x118(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x23650
movq %rax, 0x8(%rsp)
jmp 0x1b639
movq 0x8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x1b670
movq 0x118(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x23650
movq %rax, (%rsp)
jmp 0x1b65f
movq (%rsp), %rax
movq (%rax), %rax
movq %rax, 0x118(%rsp)
jmp 0x1b69e
movq 0x50(%rsp), %rdi
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
leaq 0x6c(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x23770
jmp 0x1b691
movl $0x1, 0xe0(%rsp)
jmp 0x1b6e3
jmp 0x1b6a0
jmp 0x1b6a2
movl 0xb8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb8(%rsp)
jmp 0x1b347
movq 0x50(%rsp), %rdi
movq 0x118(%rsp), %rsi
addq $0x50, %rsi
leaq 0xe8(%rsp), %rdx
callq 0x238a0
jmp 0x1b6d8
movl $0x1, 0xe0(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0xdf50
leaq 0xe8(%rsp), %rdi
callq 0x238e0
leaq 0x138(%rsp), %rdi
callq 0xdf50
movq 0x58(%rsp), %rax
addq $0x168, %rsp            # imm = 0x168
retq
leaq 0xe8(%rsp), %rdi
callq 0x238e0
leaq 0x138(%rsp), %rdi
callq 0xdf50
movq 0x128(%rsp), %rdi
callq 0xd8a0
nop