// File: loadzero[P]geoloc/geoloc/query.hpp
// Function: query(GeoData&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
inline void query(GeoData &data, const std::string &source)
{
    LOG_CONTEXT("query data with source %s", source.c_str());
    
    const char* iter = &source[0];
    const char* end = &source[0] + source.size();
    const char* res = strchr(iter, ':');

    if (!res)
    {
        FATAL_ERROR("could not parse source %s", source.c_str());
    }

    std::string protocol(iter, res);
    std::string path(res+1, end);

    if (protocol == "file")
    {
        FileReader reader(path);
        query(reader, data);
    }
    else if (protocol == "query")
    {
        std::vector<char*> toks;
        std::string scratch;
        csv_split(&path[0], path.size(), scratch, toks);

        std::vector<std::string> ip_list;
        ip_list.assign(toks.begin(), toks.end());

        StringInjector reader(ip_list);
        query(reader, data);
    }
    else
    {
        FATAL_ERROR("unknown source protocol %s", protocol.c_str());
    }
}

// Assembly:
subq $0x198, %rsp            # imm = 0x198
movq %rdi, 0x190(%rsp)
movq %rsi, 0x188(%rsp)
movq 0x188(%rsp), %rdi
callq 0x4100
movq %rax, %rcx
leaq 0x62ca(%rip), %rdi      # 0x1c5a8
movl $0x18a, %esi            # imm = 0x18A
leaq 0x655a(%rip), %rdx      # 0x1c844
movb $0x0, %al
callq 0x1b650
movq 0x188(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x42f0
movq %rax, 0x180(%rsp)
movq 0x188(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x42f0
movq %rax, 0x60(%rsp)
movq 0x188(%rsp), %rdi
callq 0x41e0
movq %rax, %rcx
movq 0x60(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x178(%rsp)
movq 0x180(%rsp), %rdi
movl $0x3a, %esi
callq 0x40d0
movq %rax, 0x170(%rsp)
cmpq $0x0, 0x170(%rsp)
jne 0x1638f
movq 0x188(%rsp), %rdi
callq 0x4100
movq %rax, %rcx
leaq 0x622c(%rip), %rdi      # 0x1c5a8
movl $0x192, %esi            # imm = 0x192
leaq 0x64d6(%rip), %rdx      # 0x1c85e
movb $0x0, %al
callq 0x1b800
movq 0x180(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x14f(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x44e0
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
leaq 0x150(%rsp), %rdi
callq 0x17170
jmp 0x163d9
leaq 0x14f(%rsp), %rdi
callq 0x42d0
movq 0x170(%rsp), %rax
incq %rax
movq %rax, 0x30(%rsp)
movq 0x178(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x117(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x44e0
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
leaq 0x118(%rsp), %rdi
callq 0x17170
jmp 0x16433
leaq 0x117(%rsp), %rdi
callq 0x42d0
leaq 0x6431(%rip), %rsi      # 0x1c878
leaq 0x150(%rsp), %rdi
callq 0x73f0
movb %al, 0x2f(%rsp)
jmp 0x1645a
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0x16467
jmp 0x16536
leaq 0xe8(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x6c10
jmp 0x1647e
movq 0x190(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x17bc0
jmp 0x16495
leaq 0xe8(%rsp), %rdi
callq 0x7350
jmp 0x164a4
jmp 0x1673c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0x14f(%rsp), %rdi
callq 0x42d0
jmp 0x16798
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0x117(%rsp), %rdi
callq 0x42d0
jmp 0x16787
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0x16776
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x7350
jmp 0x16531
jmp 0x16776
leaq 0x6340(%rip), %rsi      # 0x1c87d
leaq 0x150(%rsp), %rdi
callq 0x73f0
movb %al, 0x2e(%rsp)
jmp 0x16550
movb 0x2e(%rsp), %al
testb $0x1, %al
jne 0x1655d
jmp 0x16705
leaq 0xd0(%rsp), %rdi
callq 0x7510
jmp 0x1656c
leaq 0xb0(%rsp), %rdi
callq 0x4410
jmp 0x1657b
xorl %eax, %eax
movl %eax, %esi
leaq 0x118(%rsp), %rdi
callq 0x4580
movq %rax, 0x20(%rsp)
jmp 0x16593
leaq 0x118(%rsp), %rdi
callq 0x41e0
movq %rax, 0x18(%rsp)
jmp 0x165a7
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
leaq 0xd0(%rsp), %rcx
callq 0x7740
jmp 0x165c8
leaq 0x98(%rsp), %rdi
callq 0x5b50
jmp 0x165d7
leaq 0xd0(%rsp), %rdi
callq 0x8030
movq %rax, 0x10(%rsp)
jmp 0x165eb
movq 0x10(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x7eb0
movq %rax, 0x8(%rsp)
jmp 0x1660c
movq 0x8(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
leaq 0x98(%rsp), %rdi
callq 0x17ce0
jmp 0x16638
leaq 0x68(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x17d20
jmp 0x1664c
movq 0x190(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x17d70
jmp 0x16660
leaq 0x98(%rsp), %rdi
callq 0x61c0
jmp 0x1666f
leaq 0xb0(%rsp), %rdi
callq 0x41a0
jmp 0x1667e
leaq 0xd0(%rsp), %rdi
callq 0xad50
jmp 0x1668d
jmp 0x1673a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0x166f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0x166e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x61c0
jmp 0x166e1
jmp 0x166e3
leaq 0xb0(%rsp), %rdi
callq 0x41a0
jmp 0x166f2
jmp 0x166f4
leaq 0xd0(%rsp), %rdi
callq 0xad50
jmp 0x16703
jmp 0x16776
leaq 0x150(%rsp), %rdi
callq 0x4100
movq %rax, (%rsp)
jmp 0x16718
movq (%rsp), %rcx
leaq 0x5e85(%rip), %rdi      # 0x1c5a8
leaq 0x6159(%rip), %rdx      # 0x1c883
xorl %eax, %eax
movl $0x1ab, %esi            # imm = 0x1AB
callq 0x1b800
jmp 0x16738
jmp 0x1673a
jmp 0x1673c
leaq 0x118(%rsp), %rdi
callq 0x41a0
jmp 0x1674b
leaq 0x150(%rsp), %rdi
callq 0x41a0
addq $0x198, %rsp            # imm = 0x198
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0x16787
leaq 0x118(%rsp), %rdi
callq 0x41a0
jmp 0x16785
jmp 0x16787
leaq 0x150(%rsp), %rdi
callq 0x41a0
jmp 0x16796
jmp 0x16798
movq 0x140(%rsp), %rdi
callq 0x44d0
movq %rax, %rdi
callq 0x5b40
nopl (%rax)