// File: /workspace/github_cpp_makefile_star2_O3/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 0x37e0
movq (%rax), %r14
movl 0x20(%r14), %eax
leaq 0x14(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x3cda
movq (%rax), %r12
cmpb $0x1, 0x25(%r12)
jne 0x3160
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f68
movl (%r14), %eax
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x42ce
movq %r15, %rdi
movq %rax, %rsi
callq 0x434c
movq 0x8(%r12), %rdi
movq 0x10(%r12), %rax
cmpq %rax, %rdi
je 0x31ee
movq %rax, %rdx
subq %rdi, %rdx
addq $-0x8, %rdx
cmpq %r14, (%rdi)
je 0x31d2
addq $0x8, %rdi
addq $-0x8, %rdx
cmpq %rax, %rdi
jne 0x3145
jmp 0x31ee
cmpl $0x1, (%r12)
jne 0x31c0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f68
movl (%r14), %eax
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movq %r15, %rdi
callq 0x42ce
movq %r15, %rdi
movq %rax, %rsi
callq 0x434c
movq 0x8(%r12), %rdi
movq 0x10(%r12), %rax
cmpq %rax, %rdi
je 0x3233
movq %rax, %rdx
subq %rdi, %rdx
addq $-0x8, %rdx
cmpq %r14, (%rdi)
je 0x3217
addq $0x8, %rdi
addq $-0x8, %rdx
cmpq %rax, %rdi
jne 0x31ac
jmp 0x3233
movb $0x1, 0x24(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f68
jmp 0x3248
leaq 0x8(%rdi), %rsi
cmpq %rax, %rsi
je 0x31e5
callq 0x2230
movq 0x10(%r12), %rax
addq $-0x8, %rax
movq %rax, 0x10(%r12)
movq %r14, %rdi
callq 0x4104
movl $0x28, %esi
movq %r14, %rdi
callq 0x21a0
movb $0x0, 0x25(%r12)
movl (%r12), %esi
movq %rbx, %rdi
callq 0x3d6a
jmp 0x3248
leaq 0x8(%rdi), %rsi
cmpq %rax, %rsi
je 0x322a
callq 0x2230
movq 0x10(%r12), %rax
addq $-0x8, %rax
movq %rax, 0x10(%r12)
movq %r14, %rdi
callq 0x4104
movl $0x28, %esi
movq %r14, %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x417c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq