// File: /workspace/github_cpp_makefile_star2_O1/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 0x175b27(%rip), %rdi    # 0x57a48a
callq 0x4d7910
leaq -0xf0(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x405f38
movq (%rbx), %rsi
leaq 0x17581f(%rip), %rdi    # 0x57a1a9
xorl %eax, %eax
callq 0x4d07c0
movq (%r12), %rsi
leaq 0x175828(%rip), %rdi    # 0x57a1c4
xorl %eax, %eax
callq 0x4d07c0
movq (%r15), %rsi
leaq 0x175832(%rip), %rdi    # 0x57a1df
xorl %eax, %eax
callq 0x4d07c0
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
callq 0x406144
leaq -0x80(%rbp), %r14
movq -0x10(%r14), %rsi
leaq 0x175828(%rip), %rdi    # 0x57a1fa
xorl %eax, %eax
callq 0x4d07c0
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x4049ee
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x40ad30
leaq -0x40(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
movl $0x258, %edx            # imm = 0x258
callq 0x4065f0
leaq 0x175abf(%rip), %rdi    # 0x57a4c9
callq 0x4d7910
movq -0x40(%rbp), %rsi
leaq 0x175808(%rip), %rdi    # 0x57a222
xorl %eax, %eax
callq 0x4d07c0
leaq 0x175b54(%rip), %rdi    # 0x57a57c
callq 0x4d7910
leaq 0x1e8d5c(%rip), %rdi    # 0x5ed790
movq %rbx, %rsi
callq 0x405302
movq %rax, %r14
cmpq $0x0, 0x30(%rax)
je 0x404b34
leaq -0x90(%rbp), %rdi
callq 0x406818
movq %r14, %rsi
addq $0x28, %rsi
leaq -0x90(%rbp), %rdi
callq 0x40686a
testl %eax, %eax
jne 0x404b1b
leaq -0x90(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x406c22
testb %al, %al
je 0x404b1b
movq (%r14), %rsi
cmpq %rsi, -0x68(%rbp)
jae 0x404aa0
leaq 0x1757ca(%rip), %rdi    # 0x57a263
xorl %eax, %eax
callq 0x4d07c0
movq (%rbx), %rsi
leaq 0x1756ff(%rip), %rdi    # 0x57a1a9
xorl %eax, %eax
callq 0x4d07c0
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x4068aa
leaq -0xa0(%rbp), %r14
movq -0x10(%r14), %rsi
leaq 0x175724(%rip), %rdi    # 0x57a1fa
xorl %eax, %eax
callq 0x4d07c0
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x404af5
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x40ad30
movq -0x60(%rbp), %rsi
leaq 0x175780(%rip), %rdi    # 0x57a280
callq 0x40447f
movq -0x68(%rbp), %r14
leaq 0x1e8c80(%rip), %rdi    # 0x5ed790
movq %rbx, %rsi
callq 0x405302
movq %r14, (%rax)
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
callq 0x404556
movq %rbx, %rdi
callq 0x40683c
jmp 0x404b45
movq (%rbx), %rsi
leaq 0x17570b(%rip), %rdi    # 0x57a249
xorl %eax, %eax
callq 0x4d07c0
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x404b5e
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x40ad30
leaq -0xf0(%rbp), %rdi
callq 0x405f3e
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x404b7e
jmp 0x404b8f
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x40683c
jmp 0x404b92
movq %rax, %rbx
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x404bb2
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x40ad30
jmp 0x404bb2
jmp 0x404baf
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x405f3e
movq %rbx, %rdi
callq 0x4a9c80