// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r8, (%rsp)
movq %rcx, %r12
movq %rdx, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, %rbx
testb $0x20, 0x93ee(%rip)     # 0x1a525
jne 0x11232
movq %rbx, 0x18(%rsp)
movq %r12, %rbx
movzbl 0x95f4(%rip), %eax      # 0x1a740
leaq 0x95ad(%rip), %rsi      # 0x1a700
movb $0x0, -0x1(%rax,%rsi)
leaq 0xa9e1(%rip), %r14      # 0x1bb40
movl $0x40, %ebp
movl $0x40, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x4860
movq %rax, %r15
testq %rax, %rax
jne 0x11189
movb $0x0, 0xa9fd(%rip)      # 0x1bb7f
leaq 0xa9f7(%rip), %r15      # 0x1bb80
movq %r15, %r12
subq %r14, %r12
movb $0x2f, -0x1(%r15)
subq %r12, %rbp
leaq 0x5226(%rip), %rsi      # 0x163c4
movq %r15, %rdi
xorl %edx, %edx
movq %rbp, %rcx
callq 0x4860
movq %rax, %rbp
testq %rax, %rax
jne 0x111c7
leaq 0xa9c6(%rip), %rbp      # 0x1bb80
cmpq $0x40, %r12
je 0x111c7
movb $0x0, 0xa9b8(%rip)      # 0x1bb7f
subq %r15, %rbp
addq %r12, %rbp
addq %rbp, %r14
decq %r14
callq 0x4220
movl %eax, %edi
callq 0x5fa8
subq $0x40, %rbp
sete %r15b
negq %rbp
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
movq %rbp, %rcx
callq 0x4860
testq %rax, %rax
setne %al
orb %r15b, %al
jne 0x1120b
movb $0x0, -0x1(%r14,%rbp)
leaq 0x462a(%rip), %rdi      # 0x1583c
leaq 0xa927(%rip), %rsi      # 0x1bb40
movl $0x1, %edx
callq 0x4200
orb $0x20, 0x92fb(%rip)     # 0x1a525
movq %rbx, %r12
movq 0x18(%rsp), %rbx
movq (%rbx), %rdi
callq 0x139b5
movb (%r13), %r15b
cmpb $0x21, %r15b
jne 0x112a7
leaq 0x1(%r13), %rdi
movb 0x1(%r13), %al
leaq 0x2(%r13), %rcx
cmpb $0x26, %al
sete %dl
movl $0x7, %esi
movl $0x11, %r8d
cmovel %esi, %r8d
cmpb $0x7c, %al
movl $0x91, %r14d
cmovnel %r8d, %r14d
sete %sil
orb %dl, %sil
movzbl %sil, %edx
testb %dl, %dl
cmovneq %rcx, %rdi
cmpb $0x0, 0x1(%rdx,%r13)
je 0x112c4
cmpb $0x7c, %al
setne %al
testb $0x4, %r14b
sete %cl
testb %cl, %al
jne 0x112ac
movzbl %r14b, %esi
callq 0x13b8f
jmp 0x114a2
xorl %r14d, %r14d
jmp 0x112af
movq %rdi, %r13
leaq 0xa88a(%rip), %rdi      # 0x1bb40
movl $0x180, %esi            # imm = 0x180
callq 0x4510
testl %eax, %eax
je 0x112cb
xorl %eax, %eax
jmp 0x114a4
callq 0x4890
callq 0x48c0
testl %eax, %eax
je 0x1151b
movl %eax, %ebp
leaq 0xa85a(%rip), %r14      # 0x1bb40
movq %r14, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x46b0
movl %eax, %r13d
cmpl $-0x1, %eax
jne 0x11304
callq 0x40c0
cmpl $0x4, (%rax)
je 0x112e6
movl $0x1, %esi
movl %r13d, %edi
callq 0x13c2b
cmpq $0x1, %rax
jne 0x1144e
cmpb $0x2d, 0x942e(%rip)     # 0x1a750
jne 0x11362
xorl %r15d, %r15d
movl %r15d, 0x12f7e(%rip)    # 0x242ac
movl %r15d, 0xa73b(%rip)     # 0x1ba70
andb $-0x21, 0x91ea(%rip)    # 0x1a526
xorl %edi, %edi
xorl %esi, %esi
callq 0xfa35
movl $0x1, %esi
movl %r13d, %edi
callq 0x13c2b
movl $0x0, %r14d
cmpq $0x1, %rax
jne 0x11454
movb 0x93e7(%rip), %r15b     # 0x1a750
cmpb $0x2b, %r15b
jne 0x113b4
movl 0x9153(%rip), %eax      # 0x1a4c8
shrl $0xd, %eax
andl $0x7, %eax
leaq 0xa80e(%rip), %rcx      # 0x1bb90
movl %eax, %r15d
movl %r15d, %edx
incl %edx
movl %edx, %r15d
andl $0x1fb, %r15d           # imm = 0x1FB
andl $0xfb, %edx
imulq $0x2138, %rdx, %rsi     # imm = 0x2138
testb $0x2, 0x2131(%rsi,%rcx)
je 0x113af
cmpl %eax, %edx
jne 0x11385
incb %r15b
jmp 0x113c4
leal -0x35(%r15), %eax
cmpb $-0x5, %al
jb 0x1144e
addb $-0x30, %r15b
movl $0x1, %esi
movl %r13d, %edi
callq 0x13c2b
cmpq $0x1, %rax
jne 0x1144e
movzbl 0x9372(%rip), %eax      # 0x1a750
xorl %r14d, %r14d
cmpl $0x70, %eax
je 0x114cb
cmpl $0x6c, %eax
je 0x114b6
cmpl $0x63, %eax
jne 0x11454
movl $0x1000, %esi           # imm = 0x1000
movl %r13d, %edi
callq 0x13c2b
testq %rax, %rax
jle 0x1144e
leaq 0x933f(%rip), %r14      # 0x1a750
movb $0x0, (%rax,%r14)
cmpb $0x2f, 0x9333(%rip)     # 0x1a750
jne 0x11451
movq %r14, %rdi
xorl %esi, %esi
callq 0x4490
movq %r14, %rcx
notq %rcx
addq %rax, %rcx
je 0x11454
leaq 0x9315(%rip), %r14      # 0x1a750
cmpb $0x2f, (%rcx,%r14)
jne 0x11454
movb $0x0, (%rcx,%r14)
decq %rcx
jne 0x1143b
jmp 0x11454
xorl %r15d, %r15d
xorl %r14d, %r14d
testq %r14, %r14
je 0x11474
movsbl %r15b, %edi
movq %r14, %rsi
movq %rbx, %rdx
movq 0x8(%rsp), %rcx
movq %r12, %r8
movq (%rsp), %r9
callq 0x11a14
movl %r13d, %edi
callq 0x43c0
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4700
movq 0x8b02(%rip), %rax      # 0x19f90
movq (%rax), %rdi
callq 0x4440
leaq 0xa6a3(%rip), %rdi      # 0x1bb40
callq 0x40d0
movb $0x1, %al
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xecea
movq (%rbx), %rsi
movl %r13d, %edi
callq 0x6390
movq %rax, %r14
jmp 0x11454
movq 0x9056(%rip), %rdi      # 0x1a528
callq 0x4090
movq $0x0, 0x9046(%rip) # 0x1a528
movl %r14d, 0x12dc3(%rip)    # 0x242ac
movl %r14d, 0xa580(%rip)     # 0x1ba70
andb $-0x21, 0x902f(%rip)    # 0x1a526
xorl %edi, %edi
xorl %esi, %esi
callq 0xfa35
movl $0xffffe7ff, %eax       # imm = 0xFFFFE7FF
andl 0x9019(%rip), %eax      # 0x1a524
orl $0x800, %eax            # imm = 0x800
movl %eax, 0x900e(%rip)      # 0x1a524
jmp 0x11454
movq %r12, (%rsp)
leaq 0xa61a(%rip), %rdi      # 0x1bb40
movl $0x80001, %esi          # imm = 0x80001
xorl %eax, %eax
callq 0x46b0
cmpl $-0x1, %eax
jne 0x11541
movl $0x1, %edi
callq 0x4110
movl %eax, %ebp
leaq 0x20(%rsp), %r12
movl $0x98, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x4380
movl $0xd, %edi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4170
cmpb $0x21, %r15b
jne 0x1157d
movzbl %r14b, %esi
movq %r13, %rdi
callq 0x13b8f
jmp 0x11613
leaq 0x16(%rsp), %r15
movw $0x2d, (%r15)
movq 0xa511(%rip), %rdi      # 0x1baa0
leaq 0x91ba(%rip), %rdx      # 0x1a750
movq %r13, %rsi
callq 0x6dd5
movq 0x8f83(%rip), %r14      # 0x1a528
testq %r14, %r14
cmoveq %r15, %r14
xorl %esi, %esi
testb $0x10, 0x8f70(%rip)     # 0x1a525
cmoveq %rsi, %r14
cmpq $0x0, 0x8(%rsp)
je 0x115fe
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x115cf
xorl %esi, %esi
jmp 0x115fe
movq (%rsp), %rax
movq (%rax), %r15
movl $0xff, %ecx
movq %r15, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x4860
testq %rax, %rax
jne 0x115f7
movb $0x0, 0xfe(%r15)
movq (%rsp), %rax
movq (%rax), %rsi
movq (%rbx), %rdx
leaq 0x9148(%rip), %rdi      # 0x1a750
movq %r14, %rcx
xorl %r8d, %r8d
callq 0xf5fc
movl %ebp, %edi
callq 0x43c0
xorl %edi, %edi
callq 0x4110