// File: Kyle-Alvares[P]SQA1/main.cpp
// Function: main
int main(int argc, char* argv[]) {
    if(argc == 3) {
        string cmd = "./cmdline.sh ";
        string arg1 = argv[1]; // input file
        string arg2 = argv[2]; // expected file
        cmd += arg1;
        cmd += " "; 
        cmd += arg2;
        return system(cmd.c_str());
    } else if(argc > 1) {
        cerr << "Invalid Args!" << endl << "Expected: <input-file> <expected-file>" << endl;
    }
    while(true) {
        User user;
        bool isAdmin = false;
        int action;
        cout << endl << "=============HOME=============" << endl;
        cout << "[1] Login" << endl << "[2] Create Account" << endl;
        cout << "Action: ";
        cin >> action;
        if(action == 1) {
            int accountNumber;
            string password;
            bool validPassword = false;
            while(!validPassword) {
                validPassword = true;
                cout << "Enter Account Number: "; 
                accountNumber = req::askAccountNumber();
                user.getUserData(accountNumber);
                cout << "Enter Password: ";
                cin >> password;
                if(user.getPassword().compare(password) != 0) {
                    cout << "Error: Incorrect password!" << endl;
                    validPassword = false;
                }
            }
        } else if(action == 2) {
            user.createUser();
        } else if(action == -1) {
            break;
        } else {
            continue;
        }
        cout << endl << "===========LOGGED IN===========" << endl;
        Session session(user);
        session.save();
        cout << endl << "===========LOGGED OUT===========" << endl;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3c0, %rsp            # imm = 0x3C0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x3, -0x8(%rbp)
jne 0x3cd2
leaq -0x31(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x34d0
movq -0x330(%rbp), %rdx
leaq 0x94c3(%rip), %rsi      # 0xd004
leaq -0x30(%rbp), %rdi
callq 0x4160
jmp 0x3b4c
leaq -0x31(%rbp), %rdi
callq 0x3330
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x340(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x34d0
movq -0x340(%rbp), %rsi
movq -0x338(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x4160
jmp 0x3b8d
leaq -0x69(%rbp), %rdi
callq 0x3330
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x350(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0x348(%rbp)
callq 0x34d0
movq -0x350(%rbp), %rsi
movq -0x348(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x4160
jmp 0x3bd4
leaq -0x91(%rbp), %rdi
callq 0x3330
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x33c0
jmp 0x3bef
leaq 0x94bc(%rip), %rsi      # 0xd0b2
leaq -0x30(%rbp), %rdi
callq 0x32c0
jmp 0x3c01
leaq -0x30(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x33c0
jmp 0x3c13
leaq -0x30(%rbp), %rdi
callq 0x3150
movq %rax, %rdi
callq 0x3270
movl %eax, -0x354(%rbp)
jmp 0x3c2c
movl -0x354(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x31f0
leaq -0x68(%rbp), %rdi
callq 0x31f0
leaq -0x30(%rbp), %rdi
callq 0x31f0
jmp 0x4144
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x3330
jmp 0x4150
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x3330
jmp 0x3cc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x3330
jmp 0x3cbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x31f0
leaq -0x68(%rbp), %rdi
callq 0x31f0
leaq -0x30(%rbp), %rdi
callq 0x31f0
jmp 0x4150
cmpl $0x1, -0x8(%rbp)
jle 0x3d18
movq 0xf311(%rip), %rdi      # 0x12ff0
leaq 0x932c(%rip), %rsi      # 0xd012
callq 0x32d0
movq %rax, %rdi
movq 0xf2ab(%rip), %rsi      # 0x12fa0
callq 0x3310
movq %rax, %rdi
leaq 0x931c(%rip), %rsi      # 0xd020
callq 0x32d0
movq %rax, %rdi
movq 0xf28d(%rip), %rsi      # 0x12fa0
callq 0x3310
jmp 0x3d1a
jmp 0x3d1c
leaq -0x140(%rbp), %rdi
callq 0x5220
movb $0x0, -0x141(%rbp)
movq 0xf28a(%rip), %rdi      # 0x12fc0
movq 0xf263(%rip), %rsi      # 0x12fa0
callq 0x3310
movq %rax, -0x360(%rbp)
jmp 0x3d4b
movq -0x360(%rbp), %rdi
leaq 0x92ee(%rip), %rsi      # 0xd047
callq 0x32d0
movq %rax, -0x368(%rbp)
jmp 0x3d67
movq -0x368(%rbp), %rdi
movq 0xf22b(%rip), %rsi      # 0x12fa0
callq 0x3310
jmp 0x3d7c
movq 0xf23d(%rip), %rdi      # 0x12fc0
leaq 0x92dc(%rip), %rsi      # 0xd066
callq 0x32d0
movq %rax, -0x370(%rbp)
jmp 0x3d98
movq -0x370(%rbp), %rdi
movq 0xf1fa(%rip), %rsi      # 0x12fa0
callq 0x3310
movq %rax, -0x378(%rbp)
jmp 0x3db4
movq -0x378(%rbp), %rdi
leaq 0x92ae(%rip), %rsi      # 0xd070
callq 0x32d0
movq %rax, -0x380(%rbp)
jmp 0x3dd0
movq -0x380(%rbp), %rdi
movq 0xf1c2(%rip), %rsi      # 0x12fa0
callq 0x3310
jmp 0x3de5
movq 0xf1d4(%rip), %rdi      # 0x12fc0
leaq 0x9290(%rip), %rsi      # 0xd083
callq 0x32d0
jmp 0x3dfa
movq 0xf1d7(%rip), %rdi      # 0x12fd8
leaq -0x148(%rbp), %rsi
callq 0x31e0
jmp 0x3e0f
cmpl $0x1, -0x148(%rbp)
jne 0x3f91
leaq -0x170(%rbp), %rdi
callq 0x3400
movb $0x0, -0x171(%rbp)
movb -0x171(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x3e40
jmp 0x3f72
movb $0x1, -0x171(%rbp)
movq 0xf172(%rip), %rdi      # 0x12fc0
leaq 0x9237(%rip), %rsi      # 0xd08c
callq 0x32d0
jmp 0x3e5c
callq 0xc470
movl %eax, -0x384(%rbp)
jmp 0x3e69
movl -0x384(%rbp), %eax
movl %eax, -0x14c(%rbp)
movl -0x14c(%rbp), %esi
leaq -0x140(%rbp), %rdi
callq 0x5340
jmp 0x3e89
movq 0xf130(%rip), %rdi      # 0x12fc0
leaq 0x920c(%rip), %rsi      # 0xd0a3
callq 0x32d0
jmp 0x3e9e
movq 0xf133(%rip), %rdi      # 0x12fd8
leaq -0x170(%rbp), %rsi
callq 0x33b0
jmp 0x3eb3
leaq -0x198(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x5940
jmp 0x3ec8
leaq -0x198(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x3050
movl %eax, -0x388(%rbp)
jmp 0x3ee3
leaq -0x198(%rbp), %rdi
callq 0x31f0
movl -0x388(%rbp), %eax
cmpl $0x0, %eax
je 0x3f6d
movq 0xf0bf(%rip), %rdi      # 0x12fc0
leaq 0x91ac(%rip), %rsi      # 0xd0b4
callq 0x32d0
movq %rax, -0x390(%rbp)
jmp 0x3f16
movq -0x390(%rbp), %rdi
movq 0xf07c(%rip), %rsi      # 0x12fa0
callq 0x3310
jmp 0x3f2b
movb $0x0, -0x171(%rbp)
jmp 0x3f6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x412f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3f80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x31f0
jmp 0x3f80
jmp 0x3e2f
leaq -0x170(%rbp), %rdi
callq 0x31f0
jmp 0x3fd3
leaq -0x170(%rbp), %rdi
callq 0x31f0
jmp 0x412f
cmpl $0x2, -0x148(%rbp)
jne 0x3faa
leaq -0x140(%rbp), %rdi
callq 0x5a90
jmp 0x3fa8
jmp 0x3fd1
cmpl $-0x1, -0x148(%rbp)
jne 0x3fc2
movl $0x3, -0x19c(%rbp)
jmp 0x40c7
movl $0x2, -0x19c(%rbp)
jmp 0x40c7
jmp 0x3fd3
movq 0xefe6(%rip), %rdi      # 0x12fc0
movq 0xefbf(%rip), %rsi      # 0x12fa0
callq 0x3310
movq %rax, -0x398(%rbp)
jmp 0x3fef
movq -0x398(%rbp), %rdi
leaq 0x90d2(%rip), %rsi      # 0xd0cf
callq 0x32d0
movq %rax, -0x3a0(%rbp)
jmp 0x400b
movq -0x3a0(%rbp), %rdi
movq 0xef87(%rip), %rsi      # 0x12fa0
callq 0x3310
jmp 0x4020
leaq -0x328(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x4210
jmp 0x4035
leaq -0x280(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x7d70
jmp 0x404a
leaq -0x328(%rbp), %rdi
callq 0x4330
leaq -0x280(%rbp), %rdi
callq 0xa110
jmp 0x4064
movq 0xef55(%rip), %rdi      # 0x12fc0
movq 0xef2e(%rip), %rsi      # 0x12fa0
callq 0x3310
movq %rax, -0x3a8(%rbp)
jmp 0x4080
movq -0x3a8(%rbp), %rdi
leaq 0x9061(%rip), %rsi      # 0xd0ef
callq 0x32d0
movq %rax, -0x3b0(%rbp)
jmp 0x409c
movq -0x3b0(%rbp), %rdi
movq 0xeef6(%rip), %rsi      # 0x12fa0
callq 0x3310
jmp 0x40b1
leaq -0x280(%rbp), %rdi
callq 0x4390
movl $0x0, -0x19c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x4330
movl -0x19c(%rbp), %eax
movl %eax, -0x3b4(%rbp)
testl %eax, %eax
je 0x40f8
jmp 0x40e5
movl -0x3b4(%rbp), %eax
subl $0x2, %eax
je 0x3d1c
jmp 0x40f6
jmp 0x413d
jmp 0x3d1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x328(%rbp), %rdi
callq 0x4330
jmp 0x412f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x4390
leaq -0x140(%rbp), %rdi
callq 0x4330
jmp 0x4150
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x34c0
nopl (%rax)