// File: /workspace/github_cpp_makefile_star2_O2/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 0x174a59(%rip), %rdi    # 0x579500
callq 0x4d7170
leaq -0xf0(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x405ad8
leaq -0x130(%rbp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x405ad8
movq (%rbx), %rsi
leaq 0x1746c9(%rip), %rdi    # 0x5791a9
xorl %eax, %eax
callq 0x4d0020
movq (%r12), %rsi
leaq 0x1747a5(%rip), %rdi    # 0x579297
xorl %eax, %eax
callq 0x4d0020
movq (%r15), %rsi
leaq 0x1747af(%rip), %rdi    # 0x5792b2
xorl %eax, %eax
callq 0x4d0020
movq (%r14), %rsi
leaq 0x1746cb(%rip), %rdi    # 0x5791df
xorl %eax, %eax
callq 0x4d0020
leaq -0xb0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x405c0a
leaq -0xb0(%rbp), %r14
movq (%r14), %rsi
leaq 0x17478e(%rip), %rdi    # 0x5792cd
xorl %eax, %eax
callq 0x4d0020
movq %r14, %rdi
callq 0x477260
leaq -0x60(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0x405e5e
leaq 0x1749d3(%rip), %rdi    # 0x57953f
callq 0x4d7170
movq -0x60(%rbp), %rsi
leaq 0x1746a6(%rip), %rdi    # 0x579222
xorl %eax, %eax
callq 0x4d0020
leaq 0x1749f2(%rip), %rdi    # 0x57957c
callq 0x4d7170
leaq 0x1e7bfa(%rip), %rdi    # 0x5ec790
movq %rbx, %rsi
callq 0x405084
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x4060dc
addq $0x28, %r14
leaq -0xb0(%rbp), %rdi
movq %r14, %rsi
callq 0x40612a
testl %eax, %eax
jne 0x404c29
leaq -0xb0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4064f4
testb %al, %al
je 0x404c29
leaq -0x40(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x406164
leaq 0x1e7ba1(%rip), %rdi    # 0x5ec790
movq %rbx, %rsi
callq 0x405084
addq $0x28, %rax
leaq -0x40(%rbp), %rsi
movq %rax, %rdi
callq 0x476e90
leaq -0x40(%rbp), %rdi
callq 0x477260
movq -0x88(%rbp), %r14
leaq 0x1e7b72(%rip), %rdi    # 0x5ec790
movq %rbx, %rsi
callq 0x405084
movq %r14, (%rax)
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
callq 0x40453c
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x406164
leaq -0x40(%rbp), %rbx
movq (%rbx), %rsi
leaq 0x17467b(%rip), %rdi    # 0x5792cd
xorl %eax, %eax
callq 0x4d0020
movq %rbx, %rdi
callq 0x477260
leaq -0xb0(%rbp), %rdi
callq 0x406100
leaq -0x60(%rbp), %rdi
callq 0x477260
leaq -0x130(%rbp), %rdi
callq 0x405ade
leaq -0xf0(%rbp), %rdi
callq 0x405ade
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x404cc3
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x477260
jmp 0x404cc6
jmp 0x404cc3
jmp 0x404cb2
movq %rax, %rbx
jmp 0x404cd2
jmp 0x404cb9
movq %rax, %rbx
jmp 0x404cdb
movq %rax, %rbx
jmp 0x404ce7
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x406100
leaq -0x60(%rbp), %rdi
callq 0x477260
leaq -0x130(%rbp), %rdi
callq 0x405ade
leaq -0xf0(%rbp), %rdi
callq 0x405ade
movq %rbx, %rdi
callq 0x4a94e0