// File: davidgfnet[P]tadns/tadns.cc
// Function: tokenizedom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int)
std::pair<std::string, bool> tokenizedom (std::string dom, unsigned level) {
    std::vector<std::string> chunks;
    while (dom.size()) {
        auto p = dom.find(".");
        if (p != std::string::npos) {
            chunks.push_back(dom.substr(0, p));
            dom = dom.substr(p+1);
        }
        else {
            chunks.push_back(dom);
            break;
        }
    }

    bool lastquery = level > chunks.size();
    std::string ret;
    while (level-- && chunks.size()) {
        ret = chunks.back() + "." + ret;
        chunks.pop_back();
    }
    if (ret.size())
        ret.pop_back();

    return std::make_pair(ret, lastquery);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rsi, -0x108(%rbp)
movq %rdi, -0x100(%rbp)
movq %rdi, %rax
movq %rax, -0xf8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xa710
movq -0x108(%rbp), %rdi
callq 0x3240
cmpq $0x0, %rax
je 0x7e3d
movq -0x108(%rbp), %rdi
leaq 0x113cd(%rip), %rsi     # 0x19138
xorl %eax, %eax
movl %eax, %edx
callq 0x35e0
movq %rax, -0x38(%rbp)
cmpq $-0x1, -0x38(%rbp)
je 0x7e24
movq -0x108(%rbp), %rsi
movq -0x38(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x58(%rbp), %rdi
callq 0x3370
jmp 0x7d9d
leaq -0x30(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xa730
jmp 0x7dac
leaq -0x58(%rbp), %rdi
callq 0x3200
movq -0x108(%rbp), %rsi
movq -0x38(%rbp), %rdx
incq %rdx
leaq -0x88(%rbp), %rdi
movq $-0x1, %rcx
callq 0x3370
jmp 0x7dd8
movq -0x108(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3430
leaq -0x88(%rbp), %rdi
callq 0x3200
jmp 0x7e38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x7fba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3200
jmp 0x7fba
movq -0x108(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xa760
jmp 0x7e36
jmp 0x7e3d
jmp 0x7d47
movl -0x14(%rbp), %eax
movq %rax, -0x110(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xa7d0
movq %rax, %rcx
movq -0x110(%rbp), %rax
cmpq %rcx, %rax
seta %al
andb $0x1, %al
movb %al, -0x89(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x34a0
movl -0x14(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x111(%rbp)
je 0x7ea2
leaq -0x30(%rbp), %rdi
callq 0xa7d0
cmpq $0x0, %rax
setne %al
movb %al, -0x111(%rbp)
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x7eb1
jmp 0x7f4f
leaq -0x30(%rbp), %rdi
callq 0xa8c0
movq %rax, %rsi
leaq 0x11274(%rip), %rdx     # 0x19138
leaq -0xf0(%rbp), %rdi
callq 0xa840
jmp 0x7ed2
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0xa7f0
jmp 0x7eee
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3430
leaq -0xd0(%rbp), %rdi
callq 0x3200
leaq -0xf0(%rbp), %rdi
callq 0x3200
leaq -0x30(%rbp), %rdi
callq 0xa900
jmp 0x7e74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x7fae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x3200
jmp 0x7fae
leaq -0xb0(%rbp), %rdi
callq 0x3240
cmpq $0x0, %rax
je 0x7f6d
leaq -0xb0(%rbp), %rdi
callq 0x3420
movq -0x100(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
leaq -0x89(%rbp), %rdx
callq 0xa930
jmp 0x7f89
leaq -0xb0(%rbp), %rdi
callq 0x3200
leaq -0x30(%rbp), %rdi
callq 0xa970
movq -0xf8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0xb0(%rbp), %rdi
callq 0x3200
leaq -0x30(%rbp), %rdi
callq 0xa970
movq -0x60(%rbp), %rdi
callq 0x3530
nopl (%rax)