// File: /workspace/github_cpp_makefile_star2_O2/Kyle-Alvares[P]SQA1/session.cpp
// Function: Session::payBill()
void Session::payBill() {
    cout << endl << "============PAYBILL===========" << endl;
    // cin.ignore(); // clears buffer from cin for getline
    int numCompanies = sizeof(companyAcc) / sizeof(int);
    string company;
    int accountNumber;
    bool validCompany = false;
    while(!validCompany) {
        cout << "Companies: " << endl;
        for(int i = 0; i < numCompanies; i++)
            cout << companies[i] + " (" + companyAbbrv[i] << ")" << endl;
        cout << "Enter company name: ";
        cin >> company;
        for(int i = 0; i < numCompanies; i++) {
            if(company.compare(companyAbbrv[i]) == 0) {
                accountNumber = companyAcc[i];
                validCompany = true;
            }
        }
        if (!validCompany)
            cerr << "Error: Invalid company name!" << endl;
    }
    cout << "Choose account to use to pay bill." << endl;
    double amount = withdraw(2000, false);
    User other(accountNumber);
    other.deposit("chequings", amount);
    other.saveUserData();
    transactions.push_back("03" + username + to_string(amount));
    cout << endl <<  "Bill paid successfully!" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdi, 0x10(%rsp)
movq 0x65e3(%rip), %rdi      # 0xafc0
callq 0x2120
leaq 0x2a60(%rip), %rsi      # 0x7449
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq $0x0, 0x8(%rsp)
leaq 0x6866(%rip), %r15      # 0xb280
leaq 0x20(%rsp), %r12
leaq 0xc0(%rsp), %r13
leaq 0x2a49(%rip), %rbp      # 0x7477
testb $0x1, 0x8(%rsp)
jne 0x4b48
movq 0x6580(%rip), %rdi      # 0xafc0
leaq 0x2a21(%rip), %rsi      # 0x7468
callq 0x21f0
movq %rax, %rdi
callq 0x2120
xorl %r14d, %r14d
cmpq $0x60, %r14
je 0x4abe
leaq 0x67bc(%rip), %rax      # 0xb220
leaq (%rax,%r14), %rsi
movq %r12, %rdi
leaq 0x2a02(%rip), %rdx      # 0x7474
callq 0x59df
leaq (%r15,%r14), %rdx
movq %r13, %rdi
movq %r12, %rsi
callq 0x59c0
movq 0x6533(%rip), %rdi      # 0xafc0
movq %r13, %rsi
callq 0x21d0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
movq %r13, %rdi
callq 0x2110
movq %r12, %rdi
callq 0x2110
addq $0x20, %r14
jmp 0x4a57
movq 0x64fb(%rip), %rdi      # 0xafc0
leaq 0x29ad(%rip), %rsi      # 0x7479
callq 0x21f0
movq 0x6500(%rip), %rdi      # 0xafd8
leaq 0x40(%rsp), %rsi
callq 0x2260
movq %r15, %r14
xorl %ebx, %ebx
cmpq $0xc, %rbx
je 0x4b1d
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x2030
testl %eax, %eax
jne 0x4b13
leaq 0x282f(%rip), %rax      # 0x7334
movl (%rbx,%rax), %eax
movl %eax, 0x1c(%rsp)
movb $0x1, %al
movq %rax, 0x8(%rsp)
addq $0x4, %rbx
addq $0x20, %r14
jmp 0x4ae7
testb $0x1, 0x8(%rsp)
jne 0x4a2e
movq 0x64c1(%rip), %rdi      # 0xaff0
leaq 0x2958(%rip), %rsi      # 0x748e
callq 0x21f0
movq %rax, %rdi
callq 0x2120
jmp 0x4a2e
movq 0x6471(%rip), %rdi      # 0xafc0
leaq 0x2955(%rip), %rsi      # 0x74ab
callq 0x21f0
movq %rax, %rdi
callq 0x2120
movsd 0x2795(%rip), %xmm0     # 0x7300
movq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x444a
movsd %xmm0, 0x8(%rsp)
leaq 0xc0(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x2ef6
leaq 0x25fd(%rip), %rsi      # 0x7192
leaq 0xa0(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x2a46
leaq 0xc0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movsd 0x8(%rsp), %xmm0
callq 0x3820
leaq 0xa0(%rsp), %rdi
callq 0x2110
leaq 0xc0(%rsp), %rdi
callq 0x35a2
movq 0x10(%rsp), %rax
leaq 0xa8(%rax), %rdx
leaq 0x28df(%rip), %rsi      # 0x74ce
leaq 0x80(%rsp), %rdi
callq 0x5927
leaq 0x60(%rsp), %rdi
movsd 0x8(%rsp), %xmm0
callq 0x599d
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x58c0
movq 0x10(%rsp), %rdi
addq $0xc8, %rdi
leaq 0x20(%rsp), %rsi
callq 0x5e0e
leaq 0x20(%rsp), %rdi
callq 0x2110
leaq 0x60(%rsp), %rdi
callq 0x2110
leaq 0x80(%rsp), %rdi
callq 0x2110
movq 0x635f(%rip), %rdi      # 0xafc0
callq 0x2120
leaq 0x2864(%rip), %rsi      # 0x74d1
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0xc0(%rsp), %rdi
callq 0x2b38
leaq 0x40(%rsp), %rdi
callq 0x2110
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2110
jmp 0x4cb8
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x2110
jmp 0x4cc7
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x4cde
jmp 0x4ced
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x2110
jmp 0x4cf0
jmp 0x4ced
jmp 0x4d08
jmp 0x4d08
jmp 0x4d08
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x2b38
jmp 0x4d27
jmp 0x4d08
jmp 0x4d08
movq %rax, %rbx
jmp 0x4d1d
movq %rax, %rbx
jmp 0x4d27
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x2110
leaq 0x20(%rsp), %rdi
callq 0x2110
leaq 0x40(%rsp), %rdi
callq 0x2110
movq %rbx, %rdi
callq 0x2350
nop