// File: /workspace/github_c_makefile_star2_O3/jarun[P]nnn/src/nnn.c
// Function: readpipe
static char *readpipe(int fd, char *ctxnum, char **path)
{
	char ctx, *nextpath = NULL;

	if (read_nointr(fd, g_buf, 1) != 1)
		return NULL;

	if (g_buf[0] == '-') { /* Clear selection on '-' */
		clearselection();
		if (read_nointr(fd, g_buf, 1) != 1)
			return NULL;
	}

	if (g_buf[0] == '+')
		ctx = (char)(get_free_ctx() + 1);
	else if (g_buf[0] < '0')
		return NULL;
	else {
		ctx = g_buf[0] - '0';
		if (ctx > CTX_MAX)
			return NULL;
	}

	if (read_nointr(fd, g_buf, 1) != 1)
		return NULL;

	char op = g_buf[0];

	if (op == 'c') {
		ssize_t len = read_nointr(fd, g_buf, PATH_MAX);

		if (len <= 0)
			return NULL;

		g_buf[len] = '\0'; /* Terminate the path read */
		if (g_buf[0] == '/') {
			nextpath = g_buf;
			len = xstrlen(g_buf);
			while (--len && (g_buf[len] == '/')) /* Trim all trailing '/' */
				g_buf[len] = '\0';
		}
	} else if (op == 'l') {
		rmlistpath(); /* Remove last list mode path, if any */
		nextpath = load_input(fd, *path);
	} else if (op == 'p') {
		free(selpath);
		selpath = NULL;
		clearselection();
		g_state.picker = 0;
		g_state.picked = 1;
	}

	*ctxnum = ctx;

	return nextpath;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r15
movq %rsi, %rbx
movl %edi, %ebp
movl $0x1, %esi
callq 0x13a9b
cmpq $0x1, %rax
jne 0x13a23
movb 0x6e5d(%rip), %r12b     # 0x1a750
cmpb $0x2d, %r12b
jne 0x13937
xorl %r14d, %r14d
movl %r14d, 0x109a9(%rip)    # 0x242ac
movl %r14d, 0x8166(%rip)     # 0x1ba70
andb $-0x21, 0x6c15(%rip)    # 0x1a526
xorl %edi, %edi
xorl %esi, %esi
callq 0xf7fd
movl $0x1, %esi
movl %ebp, %edi
callq 0x13a9b
cmpq $0x1, %rax
jne 0x13a26
movb 0x6e19(%rip), %r12b     # 0x1a750
cmpb $0x2b, %r12b
jne 0x13982
movl 0x6b85(%rip), %eax      # 0x1a4c8
shrl $0xd, %eax
andl $0x7, %eax
leaq 0x8240(%rip), %rcx      # 0x1bb90
movl %eax, %r12d
movl %r12d, %edx
incl %edx
movl %edx, %r12d
andl $0x1fb, %r12d           # imm = 0x1FB
andl $0xfb, %edx
imulq $0x2138, %rdx, %rsi     # imm = 0x2138
testb $0x2, 0x2131(%rsi,%rcx)
je 0x1397d
cmpl %eax, %edx
jne 0x13953
incb %r12b
jmp 0x13993
leal -0x35(%r12), %eax
cmpb $-0x5, %al
jb 0x13a23
addb $-0x30, %r12b
movl $0x1, %esi
movl %ebp, %edi
callq 0x13a9b
cmpq $0x1, %rax
jne 0x13a23
movzbl 0x6da4(%rip), %eax      # 0x1a750
xorl %r14d, %r14d
cmpl $0x70, %eax
je 0x13a46
cmpl $0x6c, %eax
je 0x13a32
cmpl $0x63, %eax
jne 0x13a96
movl $0x1000, %esi           # imm = 0x1000
movl %ebp, %edi
callq 0x13a9b
testq %rax, %rax
jle 0x13a23
leaq 0x6d72(%rip), %r14      # 0x1a750
movb $0x0, (%rax,%r14)
cmpb $0x2f, 0x6d66(%rip)     # 0x1a750
jne 0x13a93
movq %r14, %rdi
xorl %esi, %esi
callq 0x4490
movq %r14, %rcx
notq %rcx
addq %rax, %rcx
je 0x13a96
leaq 0x6d40(%rip), %r14      # 0x1a750
cmpb $0x2f, (%rcx,%r14)
jne 0x13a96
movb $0x0, (%rcx,%r14)
decq %rcx
jne 0x13a10
jmp 0x13a96
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0xeadb
movq (%r15), %rsi
movl %ebp, %edi
callq 0x639a
movq %rax, %r14
jmp 0x13a96
movq 0x6adb(%rip), %rdi      # 0x1a528
callq 0x4090
movq $0x0, 0x6acb(%rip) # 0x1a528
movl %r14d, 0x10848(%rip)    # 0x242ac
movl %r14d, 0x8005(%rip)     # 0x1ba70
andb $-0x21, 0x6ab4(%rip)    # 0x1a526
xorl %edi, %edi
xorl %esi, %esi
callq 0xf7fd
movl $0xffffe7ff, %eax       # imm = 0xFFFFE7FF
andl 0x6a9e(%rip), %eax      # 0x1a524
orl $0x800, %eax            # imm = 0x800
movl %eax, 0x6a93(%rip)      # 0x1a524
jmp 0x13a96
xorl %r14d, %r14d
movb %r12b, (%rbx)
jmp 0x13a26