// File: /workspace/github_cpp_makefile_star2_O1/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 0x37d6
movq (%rax), %r14
movl 0x20(%r14), %eax
leaq 0x14(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x3cca
movq (%rax), %r12
cmpb $0x1, 0x25(%r12)
jne 0x3172
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f56
movl (%r14), %eax
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x42b8
movq %r15, %rdi
movq %rax, %rsi
callq 0x4330
movq 0x8(%r12), %rdi
movq 0x10(%r12), %rax
cmpq %rax, %rdi
je 0x31f8
movq %rax, %rdx
subq %rdi, %rdx
addq $-0x8, %rdx
cmpq %r14, (%rdi)
je 0x31e4
addq $0x8, %rdi
addq $-0x8, %rdx
cmpq %rax, %rdi
jne 0x3157
jmp 0x31f8
cmpl $0x1, (%r12)
jne 0x31d2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f56
movl (%r14), %eax
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x42b8
movq %r15, %rdi
movq %rax, %rsi
callq 0x4330
movq 0x8(%r12), %rdi
movq 0x10(%r12), %rax
cmpq %rax, %rdi
je 0x3235
movq %rax, %rdx
subq %rdi, %rdx
addq $-0x8, %rdx
cmpq %r14, (%rdi)
je 0x3221
addq $0x8, %rdi
addq $-0x8, %rdx
cmpq %rax, %rdi
jne 0x31be
jmp 0x3235
movb $0x1, 0x24(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f56
jmp 0x324a
leaq 0x8(%rdi), %rsi
cmpq %rax, %rsi
je 0x31f2
callq 0x2230
addq $-0x8, 0x10(%r12)
movq %r14, %rdi
callq 0x40f4
movl $0x28, %esi
movq %r14, %rdi
callq 0x21a0
movb $0x0, 0x25(%r12)
movl (%r12), %esi
movq %rbx, %rdi
callq 0x3d58
jmp 0x324a
leaq 0x8(%rdi), %rsi
cmpq %rax, %rsi
je 0x322f
callq 0x2230
addq $-0x8, 0x10(%r12)
movq %r14, %rdi
callq 0x40f4
movl $0x28, %esi
movq %r14, %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x4166
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq