// File: /workspace/github_cpp_makefile_star2_O2/tbonelaforge[P]gradebook/Main.cpp
// Function: main
int main() {
    int state; // 0 = unitialized, 1 = initialized, 2 = done
    bool idMode = true; // Whether to print students by id or by name.
    Gradebook gradebook;
    char C = '?';
    bool done = false;
    ifstream inData;

    try {
        inData.open("Grades.dat");
        if (!inData) {
            state = 0;
        } else {
            gradebook.deserialize(inData);
            state = 1;
        }
        while (C != 'Q' && state != 2) {
            displayMenu(state, gradebook, idMode);
            cin >> C;
            C = toupper(C);
            if (state == 0) {
                switch (C) {
                case 'Q':
                    handleQuit(state, gradebook);
                    break;
                case 'S':
                    handleSetup(state, gradebook);
                    break;
                default :
                    cout << "Unrecognized command." << endl;
                    break;
                }
            } else if (state == 1) {
                switch (C) {
                case 'A':
                    handleAddStudent(gradebook);
                    break;
                case 'G':
                    handleCalculateGrades(gradebook, idMode);
                    break;
                case 'O':
                    handleOutputGrades(gradebook, idMode);
                    break;
                case 'S':
                    handleSetup(state, gradebook);
                    break;
                case 'Q':
                    handleQuit(state, gradebook);
                    break;
                case 'M':
                    handleModeToggle(idMode);
                    break;
                case 'P':
                    if (gradebook.getNumStudents() > 0) {
                        handleAddProgramGrade(gradebook, idMode);
                        break;
                    }
                case 'T':
                    if (gradebook.getNumStudents() > 0) {
                        handleAddTestGrade(gradebook, idMode);
                        break;
                    }
                case 'F':
                    if (gradebook.getNumStudents() > 0) {
                        handleAddFinalExamGrade(gradebook, idMode);
                        break;
                    }
                case 'C':
                    if (gradebook.getNumStudents() > 0) {
                        handleChangeGrade(gradebook);
                        break;
                    }
                default :
                    cout << "Unrecognized Command." << endl;
                }
            }
        }
    } catch (string& e) {
        cout << "Got exception:" << endl << e;
        exit(1);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movb $0x1, -0x2a(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4054
movb $0x3f, -0x29(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x21b0
leaq 0x326e(%rip), %rsi      # 0x7068
leaq -0x288(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x20f0
movq -0x288(%rbp), %rax
movq -0x18(%rax), %rax
xorl %ebx, %ebx
testb $0x5, -0x268(%rbp,%rax)
jne 0x3e33
leaq -0x80(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x4720
pushq $0x1
popq %rbx
leaq -0x30(%rbp), %rax
movl %ebx, (%rax)
leaq -0x80(%rbp), %r14
movq 0x719c(%rip), %r15      # 0xafe0
leaq -0x29(%rbp), %r12
cmpb $0x51, -0x29(%rbp)
je 0x3fa5
cmpl $0x2, %ebx
je 0x3fa5
movzbl -0x2a(%rbp), %r13d
movl %ebx, %edi
movq %r14, %rsi
movl %r13d, %edx
callq 0x3c07
movq %r15, %rdi
movq %r12, %rsi
callq 0x2230
movsbl -0x29(%rbp), %edi
callq 0x22f0
movb %al, -0x29(%rbp)
cmpl $0x1, %ebx
je 0x3eb6
testl %ebx, %ebx
jne 0x3f03
cmpb $0x53, %al
je 0x3ef7
movsbl %al, %eax
leaq 0x3b42(%rip), %rsi      # 0x79dd
cmpl $0x51, %eax
je 0x3ee9
movq 0x7121(%rip), %rdi      # 0xafc8
callq 0x2170
movq %rax, %rdi
callq 0x20b0
jmp 0x3f03
movsbl %al, %eax
addl $-0x41, %eax
leaq 0x3b30(%rip), %rsi      # 0x79f3
cmpl $0x13, %eax
ja 0x3ea0
leaq 0x3135(%rip), %rcx      # 0x7004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
leaq 0x3b16(%rip), %rsi      # 0x79f3
jmpq *%rax
movq %r14, %rdi
callq 0x378c
jmp 0x3f03
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x2924
jmp 0x3f03
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x25e7
movl -0x30(%rbp), %ebx
jmp 0x3e48
movq %r14, %rdi
movl %r13d, %esi
callq 0x29fe
jmp 0x3f03
movq %r14, %rdi
callq 0x459e
testl %eax, %eax
jle 0x3f31
movq %r14, %rdi
movl %r13d, %esi
callq 0x2ad0
jmp 0x3f03
movq %r14, %rdi
callq 0x459e
testl %eax, %eax
jle 0x3f4a
movq %r14, %rdi
movl %r13d, %esi
callq 0x2da5
jmp 0x3f03
movq %r14, %rdi
callq 0x459e
testl %eax, %eax
jle 0x3f63
movq %r14, %rdi
movl %r13d, %esi
callq 0x30ae
jmp 0x3f03
movq %r14, %rdi
callq 0x459e
leaq 0x3a81(%rip), %rsi      # 0x79f3
testl %eax, %eax
jle 0x3ea0
movq %r14, %rdi
callq 0x32e7
jmp 0x3f03
movq %r14, %rdi
movl %r13d, %esi
callq 0x36dd
jmp 0x3f03
leaq -0x2a(%rbp), %rdi
callq 0x297e
jmp 0x3f03
leaq -0x288(%rbp), %rdi
callq 0x2070
leaq -0x80(%rbp), %rdi
callq 0x4092
xorl %eax, %eax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x402a
jmp 0x3fd5
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x401e
movq %rbx, %rdi
callq 0x2090
movq %rax, %rbx
movq 0x6fd9(%rip), %rdi      # 0xafc8
leaq 0x3a13(%rip), %rsi      # 0x7a09
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2160
pushq $0x1
popq %rdi
callq 0x21e0
movq %rax, %rbx
callq 0x2280
leaq -0x288(%rbp), %rdi
callq 0x2070
leaq -0x80(%rbp), %rdi
callq 0x4092
movq %rbx, %rdi
callq 0x22d0
movq %rax, %rdi
callq 0x4043