// File: /workspace/github_cpp_makefile_star2_O1/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 0x5128
movb $0x3f, -0x29(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x2200
leaq 0x4285(%rip), %rsi      # 0x9068
leaq -0x288(%rbp), %rdi
movl $0x8, %edx
callq 0x2120
movq -0x288(%rbp), %rax
movq -0x18(%rax), %rax
xorl %r13d, %r13d
testb $0x5, -0x268(%rbp,%rax)
jne 0x4e22
movl $0x1, %r13d
leaq -0x80(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x5ae6
movl %r13d, -0x30(%rbp)
cmpb $0x51, -0x29(%rbp)
jne 0x4e55
leaq -0x288(%rbp), %rdi
callq 0x2060
leaq -0x80(%rbp), %rdi
callq 0x5190
xorl %eax, %eax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x80(%rbp), %rbx
movq 0x8180(%rip), %r14      # 0xcfe0
leaq -0x29(%rbp), %r15
movzbl -0x2a(%rbp), %r12d
movl %r13d, %edi
movq %rbx, %rsi
movl %r12d, %edx
callq 0x4a07
movq %r14, %rdi
movq %r15, %rsi
callq 0x2270
movsbl -0x29(%rbp), %edi
callq 0x2330
movb %al, -0x29(%rbp)
cmpl $0x1, %r13d
je 0x4ef9
testl %r13d, %r13d
jne 0x4f46
cmpb $0x53, %al
je 0x4f3a
movsbl %al, %eax
leaq 0x4b2e(%rip), %rsi      # 0x99dd
cmpl $0x51, %eax
je 0x4f2c
movl $0x15, %edx
movq 0x8108(%rip), %rdi      # 0xcfc8
callq 0x2210
movq 0x80fc(%rip), %rcx      # 0xcfc8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x80de(%rip), %rdi      # 0xcfc8
callq 0x2040
movq %rax, %rdi
callq 0x2130
jmp 0x4f46
movsbl %al, %eax
addl $-0x41, %eax
leaq 0x4aed(%rip), %rsi      # 0x99f3
cmpl $0x13, %eax
ja 0x4eb4
leaq 0x40f2(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
leaq 0x4ad3(%rip), %rsi      # 0x99f3
jmpq *%rax
movq %rbx, %rdi
callq 0x429d
jmp 0x4f46
leaq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x2d30
jmp 0x4f46
leaq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x2652
cmpb $0x51, -0x29(%rbp)
je 0x4e2c
movl -0x30(%rbp), %r13d
cmpl $0x2, %r13d
jne 0x4e64
jmp 0x4e2c
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2edb
jmp 0x4f46
movq %rbx, %rdi
callq 0x5858
testl %eax, %eax
jle 0x4f89
movq %rbx, %rdi
movl %r12d, %esi
callq 0x3055
jmp 0x4f46
movq %rbx, %rdi
callq 0x5858
testl %eax, %eax
jle 0x4fa2
movq %rbx, %rdi
movl %r12d, %esi
callq 0x345e
jmp 0x4f46
movq %rbx, %rdi
callq 0x5858
testl %eax, %eax
jle 0x4fbb
movq %rbx, %rdi
movl %r12d, %esi
callq 0x38ab
jmp 0x4f46
movq %rbx, %rdi
callq 0x5858
leaq 0x4a29(%rip), %rsi      # 0x99f3
testl %eax, %eax
jle 0x4eb4
movq %rbx, %rdi
callq 0x3bc2
jmp 0x4f46
movq %rbx, %rdi
movl %r12d, %esi
callq 0x4199
jmp 0x4f46
leaq -0x2a(%rbp), %rdi
callq 0x2de5
jmp 0x4f46
movq %rax, %rbx
jmp 0x5064
jmp 0x5004
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x5058
movq %rbx, %rdi
callq 0x20a0
movq %rax, %rbx
movq 0x7faa(%rip), %rdi      # 0xcfc8
leaq 0x49e4(%rip), %rsi      # 0x9a09
movl $0xe, %edx
callq 0x2210
movq 0x7f92(%rip), %rdi      # 0xcfc8
callq 0x20d0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21a0
movl $0x1, %edi
callq 0x2230
movq %rax, %rbx
callq 0x22c0
leaq -0x288(%rbp), %rdi
callq 0x2060
leaq -0x80(%rbp), %rdi
callq 0x5190
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
callq 0x507d