// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x50(%rdi), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3330
movq (%rax), %r12
movq %r12, 0x10(%rsp)
movl 0x20(%r12), %eax
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x3de2
movq (%rax), %r14
cmpb $0x1, 0x25(%r14)
jne 0x2e15
movq %rbx, %rdi
movq %r12, %rsi
callq 0x40c0
leaq 0x10(%rsp), %r12
movq (%r12), %rax
movl (%rax), %eax
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x43fc
movq %r14, %rdi
movq %r12, %rsi
callq 0x41c2
movq (%r12), %r15
testq %r15, %r15
je 0x2df2
movq %r15, %rdi
callq 0x41ec
pushq $0x28
popq %rsi
movq %r15, %rdi
callq 0x21b0
andq $0x0, 0x10(%rsp)
movb $0x0, 0x25(%r14)
movl (%r14), %esi
movq %rbx, %rdi
callq 0x3e46
jmp 0x2e80
cmpl $0x1, (%r14)
jne 0x2e6f
movq %rbx, %rdi
movq %r12, %rsi
callq 0x40c0
leaq 0x10(%rsp), %r12
movq (%r12), %rax
movl (%rax), %eax
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x43fc
movq %r14, %rdi
movq %r12, %rsi
callq 0x41c2
movq (%r12), %r14
testq %r14, %r14
je 0x2e5c
movq %r14, %rdi
callq 0x41ec
pushq $0x28
popq %rsi
movq %r14, %rdi
callq 0x21b0
andq $0x0, 0x10(%rsp)
jmp 0x2e80
movb $0x1, 0x24(%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x40c0
movq %rbx, %rdi
callq 0x4256
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq