// File: /workspace/github_cpp_makefile_star2_O3/tbonelaforge[P]gradebook/Gradebook.cpp
// Function: Gradebook::addStudent(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Student * Gradebook::addStudent(int newId, string firstName, string lastName) {
    Student * current = head;
    Student * previous = NULL;
    while (current != NULL) {
        if (current->getId() == newId) {
            throw "Student Id " + to_string(newId) + " already exists.";
        }
        if (current->getId() > newId) {
            break;
        }
        previous = current;
        current = current->next;
    }
    Student * newStudent = new Student(numPrograms, numTests, numFinals);
    newStudent->setId(newId);
    newStudent->setFirstName(firstName);
    newStudent->setLastName(lastName);
    if (previous != NULL) {
        previous->next = newStudent;
    } else {
        head = newStudent;
    }
    newStudent->next = current;
    addToIndex(newStudent);
    numStudents += 1;
    return newStudent;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %r15
movl %esi, %r13d
movq %rdi, -0x30(%rbp)
movq 0x38(%rdi), %rax
testq %rax, %rax
movq %rcx, -0x38(%rbp)
je 0x538e
xorl %ebx, %ebx
movq %rax, %r14
movq %rax, %rdi
callq 0x62b6
cmpl %r13d, %eax
je 0x547c
movq %r14, %rdi
callq 0x62b6
cmpl %r13d, %eax
jg 0x5393
movq (%r14), %rax
movq %r14, %rbx
testq %rax, %rax
jne 0x535d
movq %r14, %rbx
jmp 0x5390
xorl %ebx, %ebx
xorl %r14d, %r14d
movl $0x78, %edi
callq 0x21c0
movq %rax, %r12
movq -0x30(%rbp), %rax
movl (%rax), %esi
movl 0x10(%rax), %edx
movl 0x20(%rax), %ecx
movq %r12, %rdi
callq 0x6164
movq %r12, %rdi
movl %r13d, %esi
callq 0x6290
leaq -0x68(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %r15
movq %r15, %rdi
callq 0x50a6
movq %r12, %rdi
movq %r15, %rsi
callq 0x629a
movq -0x78(%rbp), %rdi
cmpq %r13, %rdi
je 0x53fd
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x48(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x58(%rbp), %r15
movq %r15, %rdi
callq 0x50a6
movq %r12, %rdi
movq %r15, %rsi
callq 0x62a8
movq -0x30(%rbp), %rax
leaq 0x38(%rax), %r15
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x5447
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21d0
testq %rbx, %rbx
cmovneq %rbx, %r15
movq %r12, (%r15)
movq %r14, (%r12)
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x55a4
incl 0x48(%rbx)
movq %r12, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x20e0
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
movl %r13d, %esi
callq 0x6048
leaq 0x45d8(%rip), %rsi      # 0x9a77
leaq -0xb8(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0x5fce
movb $0x1, %r15b
leaq 0x45c7(%rip), %rdx      # 0x9a83
leaq -0xb8(%rbp), %rsi
movq %rbx, %rdi
callq 0x5f71
xorl %r15d, %r15d
leaq 0x78ab(%rip), %rsi      # 0xcd80
movq 0x7acc(%rip), %rdx      # 0xcfa8
movq %rbx, %rdi
callq 0x22f0
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x559c
movq -0x48(%rbp), %rsi
jmp 0x550e
movq %rax, %r14
movq -0x78(%rbp), %rdi
cmpq %r13, %rdi
je 0x559c
movq -0x68(%rbp), %rsi
incq %rsi
jmp 0x551e
movq %rax, %r14
movl $0x78, %esi
movq %r12, %rdi
callq 0x21d0
jmp 0x559c
movq %rax, %r14
leaq -0xa8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5547
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5566
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21d0
testb %r15b, %r15b
jne 0x5594
jmp 0x559c
movq %rax, %r14
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5594
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21d0
jmp 0x5594
movq %rax, %r14
movq %rbx, %rdi
callq 0x2150
movq %r14, %rdi
callq 0x2310