// File: isabellab3[P]OS-Simulation/./OS.h
// Function: OperatingSystem::Exit()
void Exit() {
            PCB* exiting_process = all_processes[CPU];
            PCB* parent = all_processes[exiting_process->GetParent()];

            //If parent is waiting, the process (and all of its children) terminate immediately, and the parent goes to the end of the ready queue.
            if (parent->IsWaiting()) {
                // Terminate all children and the process
                DeleteChildren(exiting_process);
                all_processes.erase(exiting_process->GetPid());
                parent->RemoveChild(exiting_process);
                delete exiting_process;
                exiting_process = nullptr;

                // Parent goes to the end of the ready queue and is no longer waiting, and the process exits the CPU
                parent->SetWaitingState(0);
                AddToReadyQueue(parent->GetPid());
                GetNextFromReadyQueue();
            }
            //If parent is process 1, terminate the process and all children immediately.
            else if (parent->GetPid() == 1) {
                //Terminate children
                DeleteChildren(exiting_process);

                //Terminate process
                all_processes.erase(exiting_process->GetPid());
                parent->RemoveChild(exiting_process);
                delete exiting_process;
                exiting_process = nullptr;

                // Replace the process in the CPU
                GetNextFromReadyQueue();

            }
            // Parent is not waiting, so process becomes a zombie.
            else {
                // Mark process as a zombie
                exiting_process->SetZombie(1);

                // Terminate all children
                DeleteChildren(exiting_process);
                GetNextFromReadyQueue();
            }
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x38(%rbp)
movq %rsi, %rdi
addq $0x50, %rdi
callq 0x4050
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x10(%rbp)
addq $0x50, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x93a0
movq -0x30(%rbp), %rdi
movl %eax, -0x1c(%rbp)
leaq -0x1c(%rbp), %rsi
callq 0x8510
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x93c0
testb $0x1, %al
jne 0x34c8
jmp 0x3561
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x93e0
movq -0x38(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x95d0
movq -0x48(%rbp), %rdi
movl %eax, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0x95a0
movq -0x18(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x95e0
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x352c
movq -0x40(%rbp), %rdi
callq 0x9690
movq -0x40(%rbp), %rdi
movl $0x28, %esi
callq 0x21f0
movq $0x0, -0x10(%rbp)
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x9740
movq -0x18(%rbp), %rdi
callq 0x95d0
movq -0x38(%rbp), %rdi
movl %eax, %esi
callq 0x8620
movq -0x38(%rbp), %rdi
callq 0x9760
jmp 0x360c
movq -0x18(%rbp), %rdi
callq 0x95d0
cmpl $0x1, %eax
jne 0x35e6
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x93e0
movq -0x38(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x95d0
movq -0x58(%rbp), %rdi
movl %eax, -0x24(%rbp)
leaq -0x24(%rbp), %rsi
callq 0x95a0
movq -0x18(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x95e0
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x35d3
movq -0x50(%rbp), %rdi
callq 0x9690
movq -0x50(%rbp), %rdi
movl $0x28, %esi
callq 0x21f0
movq -0x38(%rbp), %rdi
movq $0x0, -0x10(%rbp)
callq 0x9760
jmp 0x360a
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x97c0
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x93e0
movq -0x38(%rbp), %rdi
callq 0x9760
jmp 0x360c
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)