// File: /workspace/github_cpp_makefile_star2_O3/msotoodeh[P]asymmetric-passwords/server/APVerifier.cpp
// Function: APVerifier::SplitToken(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int APVerifier::SplitToken(const std::string& token)
{
    std::istringstream t(token);
    std::string s;
    m_items.clear();
    while (std::getline(t, s, AP_SEP)) m_items.push_back(s);

    if (m_items.size() < 3 || m_items[0].length() != 2)
        return AP_E_FORMAT;

    const char* p = m_items[0].c_str();
    m_tag = ((unsigned char)p[0] << 8) | (unsigned char)p[1];

    // Next item is timestamp (in hex format)
    p = hex_string_to_u64(m_items[1].c_str(), m_token_timestamp);
    if (*p != '\0') return AP_E_TIMESTAMP;

    // Validate timestamp against verifier time
    // Allow maximum of 30 mins difference
    uint64_t time_now = (uint64_t)time(NULL);

    if (m_token_timestamp > time_now)
    {
        // Token time is in future!!
        // We assume client time is not set accurately
        if (m_token_timestamp > (time_now + APV_MAX_TOKEN_TIME_DIFF))
            return AP_E_TIME;
    }
    else
    {
        if (time_now > (m_token_timestamp + APV_MAX_TOKEN_TIME_DIFF))
            return AP_E_TIME;
    }

    return AP_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %rbx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x46f4a0
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
leaq 0x38(%rbx), %r15
movq 0x38(%rbx), %rsi
movq %r15, %rdi
callq 0x406d24
leaq 0x8(%rsp), %r12
movq %r14, %rdi
movq %r12, %rsi
movl $0x2e, %edx
callq 0x40c030
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4068f6
movq %r15, %rdi
movq %r12, %rsi
callq 0x406ce6
jmp 0x4068cb
movq 0x38(%rbx), %rax
movq 0x40(%rbx), %rcx
subq %rax, %rcx
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
cmpq $0x41, %rcx
jb 0x406971
cmpq $0x2, 0x8(%rax)
jne 0x406971
movq (%rax), %rcx
movzwl (%rcx), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, 0x24(%rbx)
movq 0x20(%rax), %rdi
addq $0x28, %rbx
movq %rbx, %rsi
callq 0x406833
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
cmpb $0x0, (%rax)
jne 0x406971
xorl %edi, %edi
callq 0x52da20
movq (%rbx), %rcx
cmpq %rax, %rcx
jbe 0x40695e
addq $0x708, %rax            # imm = 0x708
movl $0xfffffff5, %ebp       # imm = 0xFFFFFFF5
cmpq %rax, %rcx
jbe 0x40696f
jmp 0x406971
addq $0x708, %rcx            # imm = 0x708
movl $0xfffffff5, %ebp       # imm = 0xFFFFFFF5
cmpq %rcx, %rax
ja 0x406971
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x406988
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x40ac80
movq $0x5e7af8, %rsi         # imm = 0x5E7AF8
leaq 0x28(%rsp), %rdi
callq 0x46f750
leaq 0xa0(%rsp), %rdi
callq 0x44ae50
movl %ebp, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x4069d4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x40ac80
movq $0x5e7af8, %rsi         # imm = 0x5E7AF8
leaq 0x28(%rsp), %rdi
callq 0x46f750
leaq 0xa0(%rsp), %rdi
callq 0x44ae50
movq %rbx, %rdi
callq 0x4a9bd0