// File: /workspace/github_cpp_makefile_star2_O3/msotoodeh[P]asymmetric-passwords/demo/demo.cpp
// Function: demoChangeUserPassword(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&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void demoChangeUserPassword(
    const std::string& userid,
    const std::string& old_password,
    const std::string& new_password,
    const std::string& domain)
{
    printf("\n-- CLIENT ---- CHANGE PASSWORD ------------------------------\n");
    APUser new_user(userid, new_password, domain);
    APUser old_user(userid, old_password, domain);
    printf(" user id ........... : %s\n", userid.c_str());
    printf(" old password ...... : %s\n", old_password.c_str());
    printf(" new password ...... : %s\n", new_password.c_str());
    printf(" domain ............ : %s\n", domain.c_str());
    printf(" new public key .... : %s\n", new_user.getPublicKey().c_str());
    std::string new_key_token = old_user.changePassword(new_user);
    printf(" token layout ...... : cp.timestamp.new_public_key.signature\n");
    printf(" token: %s\n", new_key_token.c_str());

    printf("\n~~ SERVER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");

    // Locate user's public key
    user_info_record& ui = user_info_records[userid];
    APVerifier verifier = APVerifier();
    if (verifier.setKey(ui.publicKey) == APVerifier::AP_SUCCESS &&
        verifier.parseChangePasswordToken(new_key_token))
    {
        // SUCCESS: Update user record
        user_info_records[userid].publicKey = verifier.getPublicKey();
        user_info_records[userid].last_access_time = verifier.getTimestamp();
    }
    else
    {
        // ERROR
    }

    print_verifier_state(verifier);
    printf(" new public key .... : %s\n", verifier.getPublicKey().c_str());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x175915(%rip), %rdi    # 0x57a500
callq 0x4d7860
leaq -0xf0(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x405ea0
leaq -0x130(%rbp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x405ea0
movq (%rbx), %rsi
leaq 0x175585(%rip), %rdi    # 0x57a1a9
xorl %eax, %eax
callq 0x4d0710
movq (%r12), %rsi
leaq 0x175661(%rip), %rdi    # 0x57a297
xorl %eax, %eax
callq 0x4d0710
movq (%r15), %rsi
leaq 0x17566b(%rip), %rdi    # 0x57a2b2
xorl %eax, %eax
callq 0x4d0710
movq (%r14), %rsi
leaq 0x175587(%rip), %rdi    # 0x57a1df
xorl %eax, %eax
callq 0x4d0710
leaq -0xb0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x4060ac
leaq -0xa0(%rbp), %r14
movq -0x10(%r14), %rsi
leaq 0x175649(%rip), %rdi    # 0x57a2cd
xorl %eax, %eax
callq 0x4d0710
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x404ca3
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x40ac80
leaq -0x60(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0x40645e
leaq 0x17587e(%rip), %rdi    # 0x57a53f
callq 0x4d7860
movq -0x60(%rbp), %rsi
leaq 0x175551(%rip), %rdi    # 0x57a222
xorl %eax, %eax
callq 0x4d0710
leaq 0x17589d(%rip), %rdi    # 0x57a57c
callq 0x4d7860
leaq 0x1e8aa5(%rip), %rdi    # 0x5ed790
movq %rbx, %rsi
callq 0x405302
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x406780
addq $0x28, %r14
leaq -0xb0(%rbp), %rdi
movq %r14, %rsi
callq 0x4067d2
testl %eax, %eax
jne 0x404d8e
leaq -0xb0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x406c38
testb %al, %al
je 0x404d8e
leaq -0x40(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x406812
leaq 0x1e8a4c(%rip), %rdi    # 0x5ed790
movq %rbx, %rsi
callq 0x405302
addq $0x28, %rax
leaq -0x40(%rbp), %rsi
movq %rax, %rdi
callq 0x4776e0
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x404d75
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x40ac80
movq -0x88(%rbp), %r14
leaq 0x1e8a0d(%rip), %rdi    # 0x5ed790
movq %rbx, %rsi
callq 0x405302
movq %r14, (%rax)
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
callq 0x404556
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x406812
leaq -0x30(%rbp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x175515(%rip), %rdi    # 0x57a2cd
xorl %eax, %eax
callq 0x4d0710
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0x404dd4
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x40ac80
leaq -0xb0(%rbp), %rdi
callq 0x4067a4
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x404df9
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x40ac80
leaq -0x130(%rbp), %rdi
callq 0x405ea6
leaq -0xf0(%rbp), %rdi
callq 0x405ea6
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x404e56
movq %rax, %rbx
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x404e59
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x40ac80
jmp 0x404e59
jmp 0x404e56
jmp 0x404e45
movq %rax, %rbx
jmp 0x404e65
jmp 0x404e4c
movq %rax, %rbx
jmp 0x404e7e
movq %rax, %rbx
jmp 0x404e8a
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x4067a4
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x404e7e
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x40ac80
leaq -0x130(%rbp), %rdi
callq 0x405ea6
leaq -0xf0(%rbp), %rdi
callq 0x405ea6
movq %rbx, %rdi
callq 0x4a9bd0