// File: tbonelaforge[P]gradebook/Main.cpp
// Function: handleAddFinalExamGrade(Gradebook&, bool)
void handleAddFinalExamGrade(Gradebook &gradebook, bool idMode) {
    int finalExamGrade;
    Student * student;
    if (gradebook.getFinalExamRecorded()) {
        cout << "Final Exam Already Recorded..." << endl;
        return;
    }
    if (!idMode) {
        Node * current = gradebook.getIndex();
        while (current != NULL) {
            student = current->student;
            cout << "Enter Final Exam Grade for "
                 << student->getLastName() << ", " << student->getFirstName() << endl;
            cin >> finalExamGrade;
            student->setFinalExamGrade(finalExamGrade);
            saveGrades(gradebook);
            current = current->next;
        }
    } else {
        student = gradebook.getHead();
        while (student != NULL) {
            cout << "Enter Final Exam Grade for "
                 << student->getLastName() << ", " << student->getFirstName() << endl;
            cin >> finalExamGrade;
            student->setFinalExamGrade(finalExamGrade);
            saveGrades(gradebook);
            student = student->next;
        }
    }
    gradebook.setFinalExamRecorded();
    saveGrades(gradebook);
    handleOutputGrades(gradebook, idMode);
    
    transLog << "Recorded grades for Final" << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6eb0
testb $0x1, %al
jne 0x4776
jmp 0x479d
movq 0x984b(%rip), %rdi      # 0xdfc8
leaq 0x5c18(%rip), %rsi      # 0xa39c
callq 0x3220
movq %rax, %rdi
movq 0x9815(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x4a77
testb $0x1, -0x9(%rbp)
jne 0x48eb
movq -0x8(%rbp), %rdi
callq 0x6780
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x48e6
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq 0x97f7(%rip), %rdi      # 0xdfc8
leaq 0x5be3(%rip), %rsi      # 0xa3bb
callq 0x3220
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x7590
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x3200
movq %rax, -0xb8(%rbp)
jmp 0x4814
movq -0xb8(%rbp), %rdi
leaq 0x5b04(%rip), %rsi      # 0xa326
callq 0x3220
movq %rax, -0xd0(%rbp)
jmp 0x4830
movq -0x18(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x7560
jmp 0x483f
movq -0xd0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3200
movq %rax, -0xd8(%rbp)
jmp 0x4858
movq -0xd8(%rbp), %rdi
movq 0x9742(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x486d
leaq -0x70(%rbp), %rdi
callq 0x3498
leaq -0x40(%rbp), %rdi
callq 0x3498
movq 0x975a(%rip), %rdi      # 0xdfe0
leaq -0x10(%rbp), %rsi
callq 0x3150
movq -0x18(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x76e0
movq -0x8(%rbp), %rdi
callq 0x36f0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x47b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x48d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3498
leaq -0x40(%rbp), %rdi
callq 0x3498
jmp 0x4a80
jmp 0x4a32
movq -0x8(%rbp), %rdi
callq 0x6760
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x4a30
movq 0x96be(%rip), %rdi      # 0xdfc8
leaq 0x5aaa(%rip), %rsi      # 0xa3bb
callq 0x3220
movq %rax, -0xf0(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x90(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x7590
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x3200
movq %rax, -0xe0(%rbp)
jmp 0x4950
movq -0xe0(%rbp), %rdi
leaq 0x59c8(%rip), %rsi      # 0xa326
callq 0x3220
movq %rax, -0xf8(%rbp)
jmp 0x496c
movq -0x18(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x7560
jmp 0x497e
movq -0xf8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3200
movq %rax, -0x100(%rbp)
jmp 0x499a
movq -0x100(%rbp), %rdi
movq 0x9600(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x49af
leaq -0xb0(%rbp), %rdi
callq 0x3498
leaq -0x90(%rbp), %rdi
callq 0x3498
movq 0x9612(%rip), %rdi      # 0xdfe0
leaq -0x10(%rbp), %rsi
callq 0x3150
movq -0x18(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x76e0
movq -0x8(%rbp), %rdi
callq 0x36f0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x48f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x4a22
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3498
leaq -0x90(%rbp), %rdi
callq 0x3498
jmp 0x4a80
jmp 0x4a32
movq -0x8(%rbp), %rdi
callq 0x6df0
movq -0x8(%rbp), %rdi
callq 0x36f0
movq -0x8(%rbp), %rdi
movb -0x9(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x3db0
leaq 0x981c(%rip), %rdi      # 0xe278
leaq 0x5974(%rip), %rsi      # 0xa3d7
callq 0x3220
movq %rax, %rdi
movq 0x9536(%rip), %rsi      # 0xdfa8
callq 0x3250
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x33f0
nopl (%rax)