// File: /workspace/github_c_makefile_star2_O1/containers[P]conmon/src/ctr_exit.c
// Function: do_exit_command
void do_exit_command()
{
	if (signal(SIGCHLD, SIG_DFL) == SIG_ERR) {
		_pexit("Failed to reset signal for SIGCHLD");
	}

	/*
	 * Close everything except stdin, stdout and stderr.
	 */
	close_all_fds_ge_than(3);

	/*
	 * We don't want the exit command to be reaped by the parent conmon
	 * as that would prevent double-fork from doing its job.
	 * Unfortunately, that also means that any new subchildren from
	 * still running processes could also get lost
	 */
	if (set_subreaper(false) != 0) {
		nwarn("Failed to disable self subreaper attribute - might wait for indirect children a long time");
	}

	pid_t exit_pid = fork();
	if (exit_pid < 0) {
		_pexit("Failed to fork");
	}

	if (exit_pid) {
		int ret, exit_status = 0;

		/*
		 * Make sure to cleanup any zombie process that the container runtime
		 * could have left around.
		 */
		do {
			int tmp;

			exit_status = 0;
			ret = waitpid(-1, &tmp, 0);
			if (ret == exit_pid)
				exit_status = get_exit_status(tmp);
		} while ((ret < 0 && errno == EINTR) || ret > 0);

		if (exit_status)
			_exit(exit_status);

		return;
	}

	/* Count the additional args, if any.  */
	size_t n_args = 0;
	if (opt_exit_args)
		for (; opt_exit_args[n_args]; n_args++)
			;

	gchar **args = malloc(sizeof(gchar *) * (n_args + 2));
	if (args == NULL)
		_exit(EXIT_FAILURE);

	args[0] = opt_exit_command;
	if (opt_exit_args)
		for (n_args = 0; opt_exit_args[n_args]; n_args++)
			args[n_args + 1] = opt_exit_args[n_args];
	args[n_args + 1] = NULL;

	if (opt_exit_delay) {
		ndebugf("Sleeping for %d seconds before executing exit command", opt_exit_delay);
		sleep(opt_exit_delay);
	}

	reset_oom_adjust();

	execv(opt_exit_command, args);

	/* Should not happen, but better be safe. */
	_exit(EXIT_FAILURE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x11, %edi
xorl %esi, %esi
callq 0x4540
cmpq $-0x1, %rax
je 0xc747
movl $0x3, %edi
callq 0xcdc3
xorl %edi, %edi
callq 0x9e2e
leaq 0x8dea(%rip), %r14      # 0x15494
testl %eax, %eax
je 0xc6b8
cmpl $0x0, (%r14)
jne 0xc73d
callq 0x4760
testl %eax, %eax
js 0xc74c
je 0xc751
movl %eax, %ebx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq 0x4(%rsp), %r14
xorl %ebp, %ebp
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %r14, %rsi
xorl %edx, %edx
callq 0x4560
cmpl %ebx, %eax
jne 0xc718
movl 0x4(%rsp), %ecx
movl %ecx, %ebp
andl $0x7f, %ebp
je 0xc715
movl %ebp, %ecx
shll $0x18, %ecx
addl $0x1000000, %ecx        # imm = 0x1000000
orl $0x80, %ebp
cmpl $0x2000000, %ecx        # imm = 0x2000000
cmovll %r15d, %ebp
jmp 0xc718
movzbl %ch, %ebp
testl %eax, %eax
js 0xc720
jne 0xc6d8
jmp 0xc72a
callq 0x45b0
cmpl $0x4, (%rax)
je 0xc6d8
testl %ebp, %ebp
jne 0xc765
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7d46
jmp 0xc6b8
callq 0x7e3d
callq 0x7de7
leaq 0x1d830(%rip), %rax     # 0x29f88
movq (%rax), %r12
testq %r12, %r12
jne 0xc76c
xorl %r13d, %r13d
jmp 0xc782
movl %ebp, %edi
callq 0x42a0
movq $-0x1, %rax
leaq 0x1(%rax), %r13
cmpq $0x0, 0x8(%r12,%rax,8)
movq %r13, %rax
jne 0xc773
leaq 0x10(,%r13,8), %rdi
callq 0x4250
testq %rax, %rax
je 0xc80d
movq %rax, %rbx
leaq 0x1d7e2(%rip), %r15     # 0x29f80
movq (%r15), %rax
movq %rax, (%rbx)
testq %r12, %r12
je 0xc7cf
movq (%r12), %rax
testq %rax, %rax
jne 0xc7b7
xorl %r13d, %r13d
jmp 0xc7cf
xorl %ecx, %ecx
leaq 0x1(%rcx), %r13
movq %rax, 0x8(%rbx,%rcx,8)
movq 0x8(%r12,%rcx,8), %rax
movq %r13, %rcx
testq %rax, %rax
jne 0xc7b9
movq $0x0, 0x8(%rbx,%r13,8)
leaq 0x1d7b1(%rip), %r12     # 0x29f90
movl (%r12), %edi
testl %edi, %edi
je 0xc7fb
cmpl $0x3, (%r14)
jb 0xc7f2
callq 0x7d98
movl (%r12), %edi
callq 0x4450
xorl %eax, %eax
callq 0xb7bd
movq (%r15), %rdi
movq %rbx, %rsi
callq 0x40a0
movl $0x1, %edi
callq 0x42a0