// File: /workspace/github_c_makefile_star2_O0/jarun[P]nnn/src/nnn.c
// Function: prompt_run
static bool prompt_run(void)
{
	bool ret = FALSE;
	char *cmdline, *next;
	int cnt_j, cnt_J, cmd_ret;
	size_t len;

	const char *xargs_j = "xargs -0 -I{} %s < %s";
	const char *xargs_J = "xargs -0 %s < %s";
	char cmd[CMD_LEN_MAX + 32]; // 32 for xargs format strings


	while (1) {
		selcmdpos = INVALID_POS;
#ifndef NORL
		if (g_state.picker || g_state.xprompt) {
#endif
			cmdline = xreadline(NULL, PROMPT);
#ifndef NORL
		} else
			cmdline = getreadline("\n"PROMPT);
#endif
		// Check for an empty command
		if (!cmdline || !cmdline[0])
			break;

		addcmdtohist(cmdline);
		ret = TRUE;

		len = xstrlen(cmdline);

		cnt_j = 0;
		next = cmdline;
		while ((next = strstr(next, "%j"))) {
			++cnt_j;

			// replace %j with {} for xargs later
			next[0] = '{';
			next[1] = '}';

			++next;
		}

		cnt_J = 0;
		next = cmdline;
		while ((next = strstr(next, "%J"))) {
			++cnt_J;

			// %J should be the last thing in the command
			if (next == cmdline + len - 2) {
				cmdline[len - 2] = '\0';
			}

			++next;
		}

		// We can't handle both %j and %J in a single command
		if (cnt_j && cnt_J)
			break;

		if (cnt_j)
			snprintf(cmd, CMD_LEN_MAX + 32, xargs_j, cmdline, selpath);
		else if (cnt_J)
			snprintf(cmd, CMD_LEN_MAX + 32, xargs_J, cmdline, selpath);

		cmd_ret = spawn(shell, "-c", (cnt_j || cnt_J) ? cmd : cmdline, NULL, F_CLI | F_CONFIRM);
		if ((cnt_j || cnt_J) && cmd_ret == 0)
			clearselection();
	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1270, %rsp           # imm = 0x1270
movb $0x0, -0x1(%rbp)
leaq 0x288e(%rip), %rax      # 0x1c994
movq %rax, -0x38(%rbp)
leaq 0x2855(%rip), %rax      # 0x1c966
movq %rax, -0x40(%rbp)
movb $-0x1, 0x66dc(%rip)     # 0x207f8
movl 0x6702(%rip), %eax      # 0x20824
shrl $0xc, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x1a13e
movl 0x66f1(%rip), %eax      # 0x20824
shrl $0x19, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1a154
xorl %eax, %eax
movl %eax, %edi
leaq 0x2862(%rip), %rsi      # 0x1c9ab
callq 0x144a0
movq %rax, -0x10(%rbp)
jmp 0x1a164
leaq 0x284f(%rip), %rdi      # 0x1c9aa
callq 0x152f0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1a174
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x1a179
jmp 0x1a324
movq -0x10(%rbp), %rdi
callq 0x1a340
movb $0x1, -0x1(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5cc0
movq %rax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x2803(%rip), %rsi      # 0x1c9b0
callq 0x4920
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x1a1e2
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movb $0x7b, (%rax)
movq -0x18(%rbp), %rax
movb $0x7d, 0x1(%rax)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x1a1a2
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x27b7(%rip), %rsi      # 0x1c9b3
callq 0x4920
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x1a247
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
addq -0x30(%rbp), %rcx
addq $-0x2, %rcx
cmpq %rcx, %rax
jne 0x1a239
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x2, %rcx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x1a1f1
cmpl $0x0, -0x1c(%rbp)
je 0x1a258
cmpl $0x0, -0x20(%rbp)
je 0x1a258
jmp 0x1a324
cmpl $0x0, -0x1c(%rbp)
je 0x1a282
leaq -0x1260(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq 0x65b4(%rip), %r8       # 0x20828
movl $0x1220, %esi           # imm = 0x1220
movb $0x0, %al
callq 0x4350
jmp 0x1a2ac
cmpl $0x0, -0x20(%rbp)
je 0x1a2aa
leaq -0x1260(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq 0x658a(%rip), %r8       # 0x20828
movl $0x1220, %esi           # imm = 0x1220
movb $0x0, %al
callq 0x4350
jmp 0x1a2ac
movq 0x6745(%rip), %rax      # 0x209f8
movq %rax, -0x1268(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1a2c6
cmpl $0x0, -0x20(%rbp)
je 0x1a2d6
leaq -0x1260(%rbp), %rax
movq %rax, -0x1270(%rbp)
jmp 0x1a2e1
movq -0x10(%rbp), %rax
movq %rax, -0x1270(%rbp)
movq -0x1268(%rbp), %rdi
movq -0x1270(%rbp), %rdx
leaq 0x1f02(%rip), %rsi      # 0x1c1f8
xorl %eax, %eax
movl %eax, %ecx
movl $0x19, %r8d
callq 0xde30
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1a314
cmpl $0x0, -0x20(%rbp)
je 0x1a31f
cmpl $0x0, -0x24(%rbp)
jne 0x1a31f
callq 0x12c80
jmp 0x1a115
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1270, %rsp           # imm = 0x1270
popq %rbp
retq
nopw %cs:(%rax,%rax)