// File: /workspace/github_cpp_makefile_star2_O2/msotoodeh[P]asymmetric-passwords/demo/demo.cpp
// Function: demoUserLogin(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void demoUserLogin(
    const std::string& userid,
    const std::string& password,
    const std::string& domain)
{
    printf("\n-- CLIENT ---- LOGIN ----------------------------------------\n");
    APUser user(userid, password, domain);
    printf(" user id ........... : %s\n", userid.c_str());
    printf(" password .......... : %s\n", password.c_str());
    printf(" domain ............ : %s\n", domain.c_str());
    printf(" public key ........ : %s\n", user.getPublicKey().c_str());

    std::string login_token = user.login(600);
    printf(" token layout ...... : li.timestamp.duration.signature\n");
    printf(" token: %s\n", login_token.c_str());

    printf("\n~~ SERVER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
    // Locate user's public key
    user_info_record& ui = user_info_records[userid];
    if (ui.publicKey.empty())
    {
        printf(" USER ID '%s' NOT FOUND.\n", userid.c_str());
        return;
    }

    APVerifier verifier = APVerifier();
    if (verifier.setKey(ui.publicKey) == APVerifier::AP_SUCCESS &&
        verifier.parseUserLoginToken(login_token))
    {
        if (verifier.getTimestamp() < ui.last_access_time)
        {
            // Token re-use
            printf(" TOKEN-REUSE ....... : %llu\n", ui.last_access_time);
        }

        // SUCCESS
        printf(" user id ........... : %s\n", userid.c_str());
        printf(" public key ........ : %s\n", verifier.getPublicKey().c_str());
        print_time_value(" expiration time ... :", verifier.getExpirationTime());
        user_info_records[userid].last_access_time = verifier.getTimestamp();
    }
    print_verifier_state(verifier);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x174c2f(%rip), %rdi    # 0x57948a
callq 0x4d7170
leaq -0xf0(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x405ad8
movq (%rbx), %rsi
leaq 0x174927(%rip), %rdi    # 0x5791a9
xorl %eax, %eax
callq 0x4d0020
movq (%r12), %rsi
leaq 0x174930(%rip), %rdi    # 0x5791c4
xorl %eax, %eax
callq 0x4d0020
movq (%r15), %rsi
leaq 0x17493a(%rip), %rdi    # 0x5791df
xorl %eax, %eax
callq 0x4d0020
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
callq 0x405c0a
leaq -0x90(%rbp), %r14
movq (%r14), %rsi
leaq 0x17492e(%rip), %rdi    # 0x5791fa
xorl %eax, %eax
callq 0x4d0020
movq %r14, %rdi
callq 0x477260
leaq -0x40(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
movl $0x258, %edx            # imm = 0x258
callq 0x405f00
leaq 0x174bd2(%rip), %rdi    # 0x5794c9
callq 0x4d7170
movq -0x40(%rbp), %rsi
leaq 0x17491b(%rip), %rdi    # 0x579222
xorl %eax, %eax
callq 0x4d0020
leaq 0x174c67(%rip), %rdi    # 0x57957c
callq 0x4d7170
leaq 0x1e7e6f(%rip), %rdi    # 0x5ec790
movq %rbx, %rsi
callq 0x405084
movq %rax, %r14
cmpq $0x0, 0x30(%rax)
je 0x404a10
leaq -0x90(%rbp), %rdi
callq 0x4060dc
movq %r14, %rsi
addq $0x28, %rsi
leaq -0x90(%rbp), %rdi
callq 0x40612a
testl %eax, %eax
jne 0x4049f7
leaq -0x90(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x406478
testb %al, %al
je 0x4049f7
movq (%r14), %rsi
cmpq %rsi, -0x68(%rbp)
jae 0x40498d
leaq 0x1748dd(%rip), %rdi    # 0x579263
xorl %eax, %eax
callq 0x4d0020
movq (%rbx), %rsi
leaq 0x174812(%rip), %rdi    # 0x5791a9
xorl %eax, %eax
callq 0x4d0020
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x406164
leaq -0xb0(%rbp), %r14
movq (%r14), %rsi
leaq 0x174838(%rip), %rdi    # 0x5791fa
xorl %eax, %eax
callq 0x4d0020
movq %r14, %rdi
callq 0x477260
movq -0x60(%rbp), %rsi
leaq 0x1748a4(%rip), %rdi    # 0x579280
callq 0x40446f
movq -0x68(%rbp), %r14
leaq 0x1e7da4(%rip), %rdi    # 0x5ec790
movq %rbx, %rsi
callq 0x405084
movq %r14, (%rax)
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
callq 0x40453c
movq %rbx, %rdi
callq 0x406100
jmp 0x404a21
movq (%rbx), %rsi
leaq 0x17482f(%rip), %rdi    # 0x579249
xorl %eax, %eax
callq 0x4d0020
leaq -0x40(%rbp), %rdi
callq 0x477260
leaq -0xf0(%rbp), %rdi
callq 0x405ade
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x404a4a
jmp 0x404a5b
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x406100
jmp 0x404a5e
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x477260
jmp 0x404a6e
jmp 0x404a6b
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x405ade
movq %rbx, %rdi
callq 0x4a94e0