// File: tbonelaforge[P]gradebook/Main.cpp
// Function: handleAddProgramGrade(Gradebook&, bool)
void handleAddProgramGrade(Gradebook &gradebook, bool idMode) {
    int programNumber, programGrade;
    cout << "Enter programming assignment number: (1 - " << gradebook.getNumPrograms() << ")" << endl;
    cin >> programNumber;
    if (programNumber < 1 || programNumber > gradebook.getNumPrograms()) {
        cout << "Invalid Program Number." << endl;
        return;
    }
    if (gradebook.getProgramRecorded(programNumber)) {
        cout << "Program " << programNumber << " already recorded..." << endl;
        return;
    }
    Student * student;
    if (!idMode) {
        Node * current = gradebook.getIndex();
        while (current != NULL) {
            student = current->student;
            cout << "Enter Program Grade for "
                 << student->getLastName() << ", " << student->getFirstName() << endl;
            cin >> programGrade;
            student->setProgramGrade(programNumber - 1, programGrade);
            saveGrades(gradebook);
            current = current->next;
        }
    } else {
        student = gradebook.getHead();
        while (student != NULL) {
            cout << "Enter Program Grade for "
                 << student->getLastName() << ", " << student->getFirstName() << endl;
            cin >> programGrade;
            student->setProgramGrade(programNumber - 1, programGrade);
            saveGrades(gradebook);
            student = student->next;
        }
    }
    gradebook.setProgramRecorded(programNumber);
    saveGrades(gradebook);
    handleOutputGrades(gradebook, idMode);
    
    transLog << "Recorded grades for Program: " << programNumber << 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 0xa0ca(%rip), %rdi      # 0xdfc8
leaq 0x63b0(%rip), %rsi      # 0xa2b5
callq 0x3220
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6100
movq -0xc0(%rbp), %rdi
movl %eax, %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x61e3(%rip), %rsi      # 0xa115
callq 0x3220
movq %rax, %rdi
movq 0xa067(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa093(%rip), %rdi      # 0xdfe0
leaq -0x10(%rbp), %rsi
callq 0x3150
cmpl $0x1, -0x10(%rbp)
jl 0x3f7a
movl -0x10(%rbp), %eax
movl %eax, -0xc4(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6100
movl %eax, %ecx
movl -0xc4(%rbp), %eax
cmpl %ecx, %eax
jle 0x3fa1
movq 0xa047(%rip), %rdi      # 0xdfc8
leaq 0x6358(%rip), %rsi      # 0xa2e0
callq 0x3220
movq %rax, %rdi
movq 0xa011(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x42e8
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x6e70
testb $0x1, %al
jne 0x3fb3
jmp 0x3ff4
movq 0xa00e(%rip), %rdi      # 0xdfc8
leaq 0x6bac(%rip), %rsi      # 0xab6d
callq 0x3220
movq %rax, %rdi
movl -0x10(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x631d(%rip), %rsi      # 0xa2f8
callq 0x3220
movq %rax, %rdi
movq 0x9fbe(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x42e8
testb $0x1, -0x9(%rbp)
jne 0x4148
movq -0x8(%rbp), %rdi
callq 0x6780
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x4143
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq 0x9fa0(%rip), %rdi      # 0xdfc8
leaq 0x62de(%rip), %rsi      # 0xa30d
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 0x406b
movq -0xd0(%rbp), %rdi
leaq 0x62ad(%rip), %rsi      # 0xa326
callq 0x3220
movq %rax, -0xe8(%rbp)
jmp 0x4087
movq -0x20(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x7560
jmp 0x4096
movq -0xe8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3200
movq %rax, -0xf0(%rbp)
jmp 0x40af
movq -0xf0(%rbp), %rdi
movq 0x9eeb(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x40c4
leaq -0x78(%rbp), %rdi
callq 0x3498
leaq -0x48(%rbp), %rdi
callq 0x3498
movq 0x9f03(%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 0x7640
movq -0x8(%rbp), %rdi
callq 0x36f0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x400b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4135
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 0x42f1
jmp 0x4295
movq -0x8(%rbp), %rdi
callq 0x6760
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x4293
movq 0x9e61(%rip), %rdi      # 0xdfc8
leaq 0x619f(%rip), %rsi      # 0xa30d
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 0x41ad
movq -0xf8(%rbp), %rdi
leaq 0x616b(%rip), %rsi      # 0xa326
callq 0x3220
movq %rax, -0x110(%rbp)
jmp 0x41c9
movq -0x20(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x7560
jmp 0x41db
movq -0x110(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x3200
movq %rax, -0x118(%rbp)
jmp 0x41f7
movq -0x118(%rbp), %rdi
movq 0x9da3(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x420c
leaq -0xb8(%rbp), %rdi
callq 0x3498
leaq -0x98(%rbp), %rdi
callq 0x3498
movq 0x9db5(%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 0x7640
movq -0x8(%rbp), %rdi
callq 0x36f0
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x4155
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4285
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 0x42f1
jmp 0x4295
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x6db0
movq -0x8(%rbp), %rdi
callq 0x36f0
movq -0x8(%rbp), %rdi
movb -0x9(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x3db0
leaq 0x9fb6(%rip), %rdi      # 0xe278
leaq 0x6060(%rip), %rsi      # 0xa329
callq 0x3220
movq %rax, %rdi
movl -0x10(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
movq 0x9cc5(%rip), %rsi      # 0xdfa8
callq 0x3250
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x33f0
nopw (%rax,%rax)