// File: msotoodeh[P]asymmetric-passwords/demo/demo.cpp
// Function: demoRegisterNewUser(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 demoRegisterNewUser(
    const std::string& userid,
    const std::string& password,
    const std::string& domain)
{
    printf("\n-- CLIENT ---- REGISTER NEW USER ----------------------------\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 reg_token = user.registerNewUser("888-555-1234");
    printf(" token layout ...... : nu.timestamp.algo.public_key.pw_reset_info.signature\n");
    printf(" token: %s\n", reg_token.c_str());

    printf("\n~~ SERVER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
    APVerifier verifier = APVerifier();
    if (verifier.parseUserRegistrationToken(reg_token))
    {
        printf(" new user id ....... : %s\n", userid.c_str());
        printf(" public key ........ : %s\n", verifier.getPublicKey().c_str());

        // save new user record (if not exists already)
        //if (user_info_records.find((userid) == user_info_records.end())
        {
            user_info_record ui;
            ui.algo = verifier.getItem(2);
            ui.publicKey = verifier.getPublicKey();
            ui.last_access_time = verifier.getTimestamp();
            user_info_records[userid] = ui;
        }
    }
    print_verifier_state(verifier);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0x17cbd7(%rip), %rdi    # 0x5812f5
xorl %eax, %eax
movb %al, -0x1a9(%rbp)
callq 0x4d79b0
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq -0x58(%rbp), %rdi
callq 0x407bc0
movq -0x8(%rbp), %rdi
callq 0x480630
movq %rax, %rsi
movb -0x1a9(%rbp), %al
leaq 0x17cbdc(%rip), %rdi    # 0x581335
callq 0x4d79b0
jmp 0x404760
movq -0x10(%rbp), %rdi
callq 0x480630
movq %rax, %rsi
leaq 0x17cbdd(%rip), %rdi    # 0x581350
xorl %eax, %eax
callq 0x4d79b0
jmp 0x40477c
movq -0x18(%rbp), %rdi
callq 0x480630
movq %rax, %rsi
leaq 0x17cbdc(%rip), %rdi    # 0x58136b
xorl %eax, %eax
callq 0x4d79b0
jmp 0x404798
leaq -0x88(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x407df0
jmp 0x4047aa
leaq -0x88(%rbp), %rdi
callq 0x480630
movq %rax, %rsi
leaq 0x17cbc6(%rip), %rdi    # 0x581386
xorl %eax, %eax
callq 0x4d79b0
jmp 0x4047c9
leaq -0x88(%rbp), %rdi
callq 0x47ebf0
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x412d90
movq -0x1b8(%rbp), %rdx
leaq 0x17cbab(%rip), %rsi    # 0x5813a1
leaq -0xc8(%rbp), %rdi
callq 0x405970
jmp 0x404804
leaq -0xa8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
callq 0x407e20
jmp 0x40481d
leaq -0xc8(%rbp), %rdi
callq 0x47ebf0
leaq -0xc9(%rbp), %rdi
callq 0x412db0
leaq 0x17cb72(%rip), %rdi    # 0x5813ae
xorl %eax, %eax
callq 0x4d79b0
jmp 0x404845
leaq -0xa8(%rbp), %rdi
callq 0x480630
movq %rax, %rsi
leaq 0x17cba0(%rip), %rdi    # 0x5813fb
xorl %eax, %eax
callq 0x4d79b0
jmp 0x404864
leaq 0x17cb9c(%rip), %rdi    # 0x581407
xorl %eax, %eax
callq 0x4d79b0
jmp 0x404874
leaq -0x120(%rbp), %rdi
callq 0x4088d0
jmp 0x404882
leaq -0x120(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x408ff0
movb %al, -0x1b9(%rbp)
jmp 0x40489d
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0x4048ac
jmp 0x404ab0
movq -0x8(%rbp), %rdi
callq 0x480630
movq %rax, %rsi
leaq 0x17cb88(%rip), %rdi    # 0x581447
xorl %eax, %eax
callq 0x4d79b0
jmp 0x4048c8
leaq -0x140(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x4089f0
jmp 0x4048dd
leaq -0x140(%rbp), %rdi
callq 0x480630
movq %rax, %rsi
leaq 0x17ca93(%rip), %rdi    # 0x581386
xorl %eax, %eax
callq 0x4d79b0
jmp 0x4048fc
leaq -0x140(%rbp), %rdi
callq 0x47ebf0
leaq -0x188(%rbp), %rdi
callq 0x405a20
leaq -0x120(%rbp), %rdi
movl $0x2, %esi
callq 0x408f20
movq %rax, -0x1c8(%rbp)
jmp 0x40492e
movq -0x1c8(%rbp), %rsi
leaq -0x180(%rbp), %rdi
callq 0x47ec20
jmp 0x404943
leaq -0x1a8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x4089f0
jmp 0x404958
leaq -0x160(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x47ec20
jmp 0x40496d
leaq -0x1a8(%rbp), %rdi
callq 0x47ebf0
leaq -0x120(%rbp), %rdi
callq 0x405950
movq %rax, -0x1d0(%rbp)
jmp 0x40498e
movq -0x1d0(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x1f0dc9(%rip), %rdi    # 0x5f5770
callq 0x405a50
movq %rax, -0x1d8(%rbp)
jmp 0x4049b5
movq -0x1d8(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x405b30
jmp 0x4049ca
leaq -0x188(%rbp), %rdi
callq 0x405b90
jmp 0x404ab0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x404b00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x47ebf0
jmp 0x404b00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x404a2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x47ebf0
leaq -0xc9(%rbp), %rdi
callq 0x412db0
jmp 0x404b00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x404af4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x404ae8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x47ebf0
jmp 0x404ae8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x404aa2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x47ebf0
leaq -0x188(%rbp), %rdi
callq 0x405b90
jmp 0x404ae8
leaq -0x120(%rbp), %rdi
callq 0x404680
jmp 0x404abe
leaq -0x120(%rbp), %rdi
callq 0x408940
leaq -0xa8(%rbp), %rdi
callq 0x47ebf0
leaq -0x58(%rbp), %rdi
callq 0x407c00
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
leaq -0x120(%rbp), %rdi
callq 0x408940
leaq -0xa8(%rbp), %rdi
callq 0x47ebf0
leaq -0x58(%rbp), %rdi
callq 0x407c00
movq -0x60(%rbp), %rdi
callq 0x4b0e70
nopw %cs:(%rax,%rax)