// File: /workspace/github_c_makefile_star2_O0/jarun[P]nnn/src/nnn.c
// Function: run_plugin
static bool run_plugin(char **path, const char *file, char *runfile, char **lastname, char **lastdir)
{
	pid_t p;
	char ctx = 0;
	uchar_t flags = 0;
	bool cmd_as_plugin = FALSE;
	char *nextpath;

	if (!g_state.pluginit) {
		plctrl_init();
		g_state.pluginit = 1;
	}

	setexports(*path);

	/* Check for run-cmd-as-plugin mode */
	if (*file == '!') {
		flags = F_MULTI | F_CONFIRM;
		++file;

		if (*file == '|') { /* Check if output should be paged */
			flags |= F_PAGE;
			++file;
		} else if (*file == '&') { /* Check if GUI flags are to be used */
			flags = F_MULTI | F_NOTRACE | F_NOWAIT;
			++file;
		}

		if (!*file)
			return FALSE;

		if ((flags & F_NOTRACE) || (flags & F_PAGE)) {
			run_cmd_as_plugin(file, flags);
			return TRUE;
		}

		cmd_as_plugin = TRUE;
	}

	if (mkfifo(g_pipepath, 0600) != 0)
		return FALSE;

	exitcurses();

	p = fork();

	if (!p) { // In child
		int wfd = open(g_pipepath, O_WRONLY | O_CLOEXEC);

		if (wfd == -1)
			_exit(EXIT_FAILURE);

		/* Restore sigpipe handler to default */
		sigaction(SIGPIPE, &(struct sigaction){.sa_handler = SIG_DFL}, NULL);

		if (!cmd_as_plugin) {
			char *sel = NULL;
			char std[2] = "-";

			/* Generate absolute path to plugin */
			mkpath(plgpath, file, g_buf);

			if (g_state.picker)
				sel = selpath ? selpath : std;

			if (runfile && runfile[0]) {
				xstrsncpy(*lastname, runfile, NAME_MAX);
				spawn(g_buf, *lastname, *path, sel, 0);
			} else
				spawn(g_buf, NULL, *path, sel, 0);
		} else
			run_cmd_as_plugin(file, flags);

		close(wfd);
		_exit(EXIT_SUCCESS);
	}

	int rfd;

	do
		rfd = open(g_pipepath, O_RDONLY);
	while (rfd == -1 && errno == EINTR);

	nextpath = readpipe(rfd, &ctx, path);
	if (nextpath)
		set_smart_ctx(ctx, nextpath, path, runfile, lastname, lastdir);

	close(rfd);

	/* wait for the child to finish. no zombies allowed */
	waitpid(p, NULL, 0);

	refresh();

	unlink(g_pipepath);

	return TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movb $0x0, -0x35(%rbp)
movb $0x0, -0x36(%rbp)
movb $0x0, -0x37(%rbp)
movl 0x10113(%rip), %eax     # 0x20824
shrl $0xd, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x10737
callq 0x18b40
movl 0x100fd(%rip), %eax     # 0x20824
andl $0xffffdfff, %eax       # imm = 0xFFFFDFFF
orl $0x2000, %eax           # imm = 0x2000
movl %eax, 0x100ed(%rip)     # 0x20824
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x18c10
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x21, %eax
jne 0x107ed
movb $0x11, -0x36(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7c, %eax
jne 0x10789
movzbl -0x36(%rbp), %eax
orl $0x80, %eax
movb %al, -0x36(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x107a7
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x26, %eax
jne 0x107a5
movb $0x7, -0x36(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x107a7
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x107b9
movb $0x0, -0x1(%rbp)
jmp 0x10a36
movzbl -0x36(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x107d3
movzbl -0x36(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x107e9
movq -0x18(%rbp), %rdi
movzbl -0x36(%rbp), %esi
callq 0x18e70
movb $0x1, -0x1(%rbp)
jmp 0x10a36
movb $0x1, -0x37(%rbp)
leaq 0x1164c(%rip), %rdi     # 0x21e40
movl $0x180, %esi            # imm = 0x180
callq 0x4520
cmpl $0x0, %eax
je 0x1080c
movb $0x0, -0x1(%rbp)
jmp 0x10a36
callq 0x4890
callq 0x48c0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x1097f
leaq 0x11616(%rip), %rdi     # 0x21e40
movl $0x80001, %esi          # imm = 0x80001
movb $0x0, %al
callq 0x46c0
movl %eax, -0x44(%rbp)
cmpl $-0x1, -0x44(%rbp)
jne 0x10849
movl $0x1, %edi
callq 0x4110
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x4380
movl $0xd, %edi
leaq -0xe0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x4170
testb $0x1, -0x37(%rbp)
jne 0x10963
movq $0x0, -0xe8(%rbp)
movw 0xb9b2(%rip), %ax       # 0x1c23f
movw %ax, -0xea(%rbp)
movq 0x11505(%rip), %rdi     # 0x21da0
movq -0x18(%rbp), %rsi
leaq 0x101aa(%rip), %rdx     # 0x20a50
callq 0x74c0
movl 0xff73(%rip), %eax      # 0x20824
shrl $0xc, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x108f2
cmpq $0x0, 0xff64(%rip)      # 0x20828
je 0x108d6
movq 0xff5b(%rip), %rax      # 0x20828
movq %rax, -0xf8(%rbp)
jmp 0x108e4
leaq -0xea(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x10940
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x10940
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
movl $0xff, %edx
callq 0x6250
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0xe8(%rbp), %rcx
leaq 0x1011a(%rip), %rdi     # 0x20a50
xorl %r8d, %r8d
callq 0xde30
jmp 0x10961
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0xe8(%rbp), %rcx
leaq 0x100fb(%rip), %rdi     # 0x20a50
xorl %eax, %eax
movl %eax, %esi
xorl %r8d, %r8d
callq 0xde30
jmp 0x10970
movq -0x18(%rbp), %rdi
movzbl -0x36(%rbp), %esi
callq 0x18e70
movl -0x44(%rbp), %edi
callq 0x43c0
xorl %edi, %edi
callq 0x4110
jmp 0x10981
leaq 0x114b8(%rip), %rdi     # 0x21e40
xorl %esi, %esi
movb $0x0, %al
callq 0x46c0
movl %eax, -0xf0(%rbp)
xorl %eax, %eax
cmpl $-0x1, -0xf0(%rbp)
movb %al, -0xf9(%rbp)
jne 0x109b9
callq 0x40c0
cmpl $0x4, (%rax)
sete %al
movb %al, -0xf9(%rbp)
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0x10981
movl -0xf0(%rbp), %edi
movq -0x10(%rbp), %rdx
leaq -0x35(%rbp), %rsi
callq 0x18f50
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x109fe
movsbl -0x35(%rbp), %edi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x112c0
movl -0xf0(%rbp), %edi
callq 0x43c0
movl -0x34(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x4710
movq 0xf572(%rip), %rax      # 0x1ff90
movq (%rax), %rdi
callq 0x4440
leaq 0x11413(%rip), %rdi     # 0x21e40
callq 0x40d0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)