// File: tbonelaforge[P]gradebook/Main.cpp
// Function: handleAddTestGrade(Gradebook&, bool)
void handleAddTestGrade(Gradebook &gradebook, bool idMode) {
    int testNumber, testGrade;
    cout << "Enter test number: (1 - " << gradebook.getNumTests() << ")" << endl;
    cin >> testNumber;
    if (testNumber < 1 || testNumber > gradebook.getNumTests()) {
        cout << "Invalid Test Number." << endl;
        return;
    }
    if (gradebook.getTestRecorded(testNumber)) {
        cout << "Test " << testNumber << " already recorded..." << endl;
        return;
    }
    Student * student;
    if (!idMode) {
        Node * current = gradebook.getIndex();
        while (current != NULL) {
            student = current->student;
            cout << "Enter Test " << testNumber << " Grade for "
                 << student->getLastName() << ", " << student->getFirstName() << endl;
            cin >> testGrade;
            student->setTestGrade(testNumber - 1, testGrade);
            saveGrades(gradebook);
            current = current->next;
        }
    } else {
        student = gradebook.getHead();
        while (student != NULL) {
            cout << "Enter Test " << testNumber << " Grade for "
                 << student->getLastName() << ", " << student->getFirstName() << endl;
            cin >> testGrade;
            student->setTestGrade(testNumber - 1, testGrade);
            saveGrades(gradebook);
            student = student->next;
        }
    }
    gradebook.setTestRecorded(testNumber);
    saveGrades(gradebook);
    handleOutputGrades(gradebook, idMode);
    
    transLog << "Recorded grades for Test: " << testNumber << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq 0x9caa(%rip), %rdi      # 0xdfc8
leaq 0x6022(%rip), %rsi      # 0xa347
callq 0x3220
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6110
movq -0xc0(%rbp), %rdi
movl %eax, %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x5dc3(%rip), %rsi      # 0xa115
callq 0x3220
movq %rax, %rdi
movq 0x9c47(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0x9c73(%rip), %rdi      # 0xdfe0
leaq -0x10(%rbp), %rsi
callq 0x3150
cmpl $0x1, -0x10(%rbp)
jl 0x439a
movl -0x10(%rbp), %eax
movl %eax, -0xc4(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6110
movl %eax, %ecx
movl -0xc4(%rbp), %eax
cmpl %ecx, %eax
jle 0x43c1
movq 0x9c27(%rip), %rdi      # 0xdfc8
leaq 0x5fb8(%rip), %rsi      # 0xa360
callq 0x3220
movq %rax, %rdi
movq 0x9bf1(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x473c
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x6e90
testb $0x1, %al
jne 0x43d3
jmp 0x4414
movq 0x9bee(%rip), %rdi      # 0xdfc8
leaq 0x5f9a(%rip), %rsi      # 0xa37b
callq 0x3220
movq %rax, %rdi
movl -0x10(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x5efd(%rip), %rsi      # 0xa2f8
callq 0x3220
movq %rax, %rdi
movq 0x9b9e(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x473c
testb $0x1, -0x9(%rbp)
jne 0x4582
movq -0x8(%rbp), %rdi
callq 0x6780
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x457d
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq 0x9b80(%rip), %rdi      # 0xdfc8
leaq 0x5f26(%rip), %rsi      # 0xa375
callq 0x3220
movq %rax, %rdi
movl -0x10(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x5eb1(%rip), %rsi      # 0xa31a
callq 0x3220
movq %rax, -0xe0(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x7590
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x3200
movq %rax, -0xd0(%rbp)
jmp 0x44a5
movq -0xd0(%rbp), %rdi
leaq 0x5e73(%rip), %rsi      # 0xa326
callq 0x3220
movq %rax, -0xe8(%rbp)
jmp 0x44c1
movq -0x20(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x7560
jmp 0x44d0
movq -0xe8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3200
movq %rax, -0xf0(%rbp)
jmp 0x44e9
movq -0xf0(%rbp), %rdi
movq 0x9ab1(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x44fe
leaq -0x78(%rbp), %rdi
callq 0x3498
leaq -0x48(%rbp), %rdi
callq 0x3498
movq 0x9ac9(%rip), %rdi      # 0xdfe0
leaq -0x14(%rbp), %rsi
callq 0x3150
movq -0x20(%rbp), %rdi
movl -0x10(%rbp), %esi
subl $0x1, %esi
movl -0x14(%rbp), %edx
callq 0x7690
movq -0x8(%rbp), %rdi
callq 0x36f0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x442b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x456f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3498
leaq -0x48(%rbp), %rdi
callq 0x3498
jmp 0x4745
jmp 0x46e9
movq -0x8(%rbp), %rdi
callq 0x6760
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x46e7
movq 0x9a27(%rip), %rdi      # 0xdfc8
leaq 0x5dcd(%rip), %rsi      # 0xa375
callq 0x3220
movq %rax, %rdi
movl -0x10(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x5d58(%rip), %rsi      # 0xa31a
callq 0x3220
movq %rax, -0x108(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x7590
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
callq 0x3200
movq %rax, -0xf8(%rbp)
jmp 0x4601
movq -0xf8(%rbp), %rdi
leaq 0x5d17(%rip), %rsi      # 0xa326
callq 0x3220
movq %rax, -0x110(%rbp)
jmp 0x461d
movq -0x20(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x7560
jmp 0x462f
movq -0x110(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x3200
movq %rax, -0x118(%rbp)
jmp 0x464b
movq -0x118(%rbp), %rdi
movq 0x994f(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x4660
leaq -0xb8(%rbp), %rdi
callq 0x3498
leaq -0x98(%rbp), %rdi
callq 0x3498
movq 0x9961(%rip), %rdi      # 0xdfe0
leaq -0x14(%rbp), %rsi
callq 0x3150
movq -0x20(%rbp), %rdi
movl -0x10(%rbp), %esi
subl $0x1, %esi
movl -0x14(%rbp), %edx
callq 0x7690
movq -0x8(%rbp), %rdi
callq 0x36f0
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x458f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x46d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x3498
leaq -0x98(%rbp), %rdi
callq 0x3498
jmp 0x4745
jmp 0x46e9
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x6dd0
movq -0x8(%rbp), %rdi
callq 0x36f0
movq -0x8(%rbp), %rdi
movb -0x9(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x3db0
leaq 0x9b62(%rip), %rdi      # 0xe278
leaq 0x5c64(%rip), %rsi      # 0xa381
callq 0x3220
movq %rax, %rdi
movl -0x10(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
movq 0x9871(%rip), %rsi      # 0xdfa8
callq 0x3250
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x33f0
nop