// File: Kyle-Alvares[P]SQA1/session.cpp
// Function: Session::withdraw(double, bool)
double Session::withdraw(double max, bool displayHeader) {
    if(displayHeader)
        cout << endl << "============WITHDRAW===========" << endl;
    if(user.isAdmin())
        askNames(user);
    bool valid = false;
    string accountName;
    while(!valid) {
        accountName = askAccountName(user, -1);
        valid = user.isDisabled(accountName) ? false : true;
        if(!valid) cout << "Error: disabled account!" << endl;
    }
    int index = user.getAccountIndex(accountName);
    double balance = user.getAccounts()[index].balance;
    double amount;
    if(user.isAdmin()) amount = askAmount(balance);
    else amount = askAmount(min(balance, max));
    user.withdraw(accountName, amount);
    transactions.push_back("01" + username + to_string(amount));
    return amount;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movb %sil, %al
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2b0(%rbp)
testb $0x1, -0x11(%rbp)
je 0x82ae
movq 0xad3c(%rip), %rdi      # 0x12fc0
movq 0xad15(%rip), %rsi      # 0x12fa0
callq 0x3310
movq %rax, %rdi
leaq 0x50dd(%rip), %rsi      # 0xd377
callq 0x32d0
movq %rax, %rdi
movq 0xacf7(%rip), %rsi      # 0x12fa0
callq 0x3310
movq -0x2b0(%rbp), %rdi
callq 0x5980
testb $0x1, %al
jne 0x82c0
jmp 0x8319
movq -0x2b0(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x4210
movq -0x2b8(%rbp), %rdi
callq 0xc820
jmp 0x82e8
leaq -0xc0(%rbp), %rdi
callq 0x4330
jmp 0x8319
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x4330
jmp 0x87a1
movb $0x0, -0xcd(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x3400
movb -0xcd(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x833d
jmp 0x84a3
movq -0x2b0(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x4210
jmp 0x8352
leaq -0x110(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xc6e0
jmp 0x836c
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
leaq -0x110(%rbp), %rsi
movq %rsi, -0x2d0(%rbp)
callq 0x3380
movq -0x2d0(%rbp), %rdi
callq 0x31f0
leaq -0x1b8(%rbp), %rdi
callq 0x4330
movq -0x2b0(%rbp), %rax
movq -0x2c8(%rbp), %rsi
movq %rax, -0x2c0(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x3160
jmp 0x83c8
movq -0x2c0(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x6600
movb %al, -0x2d1(%rbp)
jmp 0x83e3
movb -0x2d1(%rbp), %al
andb $0x1, %al
decb %al
andb $0x1, %al
movb %al, -0xcd(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x31f0
testb $0x1, -0xcd(%rbp)
jne 0x849e
movq 0xabab(%rip), %rdi      # 0x12fc0
leaq 0x4f7b(%rip), %rsi      # 0xd397
callq 0x32d0
movq %rax, -0x2e0(%rbp)
jmp 0x842a
movq -0x2e0(%rbp), %rdi
movq 0xab68(%rip), %rsi      # 0x12fa0
callq 0x3310
jmp 0x843f
jmp 0x849e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x8795
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x4330
jmp 0x8795
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x31f0
jmp 0x8795
jmp 0x832c
movq -0x2b0(%rbp), %rax
movq %rax, -0x2e8(%rbp)
leaq -0x200(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x3160
jmp 0x84c6
movq -0x2e8(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x61b0
movl %eax, -0x2ec(%rbp)
jmp 0x84e1
leaq -0x200(%rbp), %rdi
callq 0x31f0
movl -0x2ec(%rbp), %eax
movq -0x2b0(%rbp), %rsi
movl %eax, -0x1dc(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x59a0
jmp 0x850e
movslq -0x1dc(%rbp), %rsi
leaq -0x220(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x6b20
movq -0x300(%rbp), %rdi
movsd 0x28(%rax), %xmm0
movsd %xmm0, -0x2f8(%rbp)
callq 0x44c0
movsd -0x2f8(%rbp), %xmm0
movq -0x2b0(%rbp), %rdi
movsd %xmm0, -0x208(%rbp)
callq 0x5980
movb %al, -0x2ed(%rbp)
jmp 0x8565
movb -0x2ed(%rbp), %al
testb $0x1, %al
jne 0x8571
jmp 0x85bd
movsd -0x208(%rbp), %xmm0
callq 0xc9c0
movsd %xmm0, -0x308(%rbp)
jmp 0x8588
movsd -0x308(%rbp), %xmm0
movsd %xmm0, -0x228(%rbp)
jmp 0x8600
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x31f0
jmp 0x8795
leaq -0x208(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0xa570
movq %rax, -0x310(%rbp)
jmp 0x85d6
movq -0x310(%rbp), %rax
movsd (%rax), %xmm0
callq 0xc9c0
movsd %xmm0, -0x318(%rbp)
jmp 0x85f0
movsd -0x318(%rbp), %xmm0
movsd %xmm0, -0x228(%rbp)
movq -0x2b0(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0x248(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x3160
jmp 0x8623
movq -0x320(%rbp), %rdi
movsd -0x228(%rbp), %xmm0
leaq -0x248(%rbp), %rsi
callq 0x6300
jmp 0x8640
leaq -0x248(%rbp), %rdi
callq 0x31f0
movq -0x2b0(%rbp), %rdx
movq %rdx, %rax
addq $0xc8, %rax
movq %rax, -0x328(%rbp)
addq $0xa8, %rdx
leaq 0x4d3f(%rip), %rsi      # 0xd3b0
leaq -0x288(%rbp), %rdi
callq 0xa5e0
jmp 0x867f
movsd -0x228(%rbp), %xmm0
leaq -0x2a8(%rbp), %rdi
callq 0xa6f0
jmp 0x8695
leaq -0x268(%rbp), %rdi
leaq -0x288(%rbp), %rsi
leaq -0x2a8(%rbp), %rdx
callq 0xa4a0
jmp 0x86b1
movq -0x328(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0xa5b0
jmp 0x86c6
leaq -0x268(%rbp), %rdi
callq 0x31f0
leaq -0x2a8(%rbp), %rdi
callq 0x31f0
leaq -0x288(%rbp), %rdi
callq 0x31f0
movsd -0x228(%rbp), %xmm0
movsd %xmm0, -0x330(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x31f0
movsd -0x330(%rbp), %xmm0
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x31f0
jmp 0x8795
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x8789
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x877d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x31f0
leaq -0x2a8(%rbp), %rdi
callq 0x31f0
leaq -0x288(%rbp), %rdi
callq 0x31f0
leaq -0xf0(%rbp), %rdi
callq 0x31f0
movq -0xc8(%rbp), %rdi
callq 0x34c0
nopl (%rax)