// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movl -0xc(%rbp), %edi
leaq 0x7adb(%rip), %rsi      # 0x20a50
movl $0x1, %edx
callq 0x191b0
cmpq $0x1, %rax
je 0x18f92
movq $0x0, -0x8(%rbp)
jmp 0x1919b
movsbl 0x7ab7(%rip), %eax      # 0x20a50
cmpl $0x2d, %eax
jne 0x18fcc
callq 0x12c80
movl -0xc(%rbp), %edi
leaq 0x7aa3(%rip), %rsi      # 0x20a50
movl $0x1, %edx
callq 0x191b0
cmpq $0x1, %rax
je 0x18fca
movq $0x0, -0x8(%rbp)
jmp 0x1919b
jmp 0x18fcc
movsbl 0x7a7d(%rip), %eax      # 0x20a50
cmpl $0x2b, %eax
jne 0x18fe8
callq 0x19210
movzbl %al, %eax
addl $0x1, %eax
movb %al, -0x21(%rbp)
jmp 0x19028
movsbl 0x7a61(%rip), %eax      # 0x20a50
cmpl $0x30, %eax
jge 0x19001
movq $0x0, -0x8(%rbp)
jmp 0x1919b
movsbl 0x7a48(%rip), %eax      # 0x20a50
subl $0x30, %eax
movb %al, -0x21(%rbp)
movsbl -0x21(%rbp), %eax
cmpl $0x4, %eax
jle 0x19024
movq $0x0, -0x8(%rbp)
jmp 0x1919b
jmp 0x19026
jmp 0x19028
movl -0xc(%rbp), %edi
leaq 0x7a1e(%rip), %rsi      # 0x20a50
movl $0x1, %edx
callq 0x191b0
cmpq $0x1, %rax
je 0x1904f
movq $0x0, -0x8(%rbp)
jmp 0x1919b
movb 0x79fb(%rip), %al       # 0x20a50
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
cmpl $0x63, %eax
jne 0x19114
movl -0xc(%rbp), %edi
leaq 0x79e1(%rip), %rsi      # 0x20a50
movl $0x1000, %edx           # imm = 0x1000
callq 0x191b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jg 0x19091
movq $0x0, -0x8(%rbp)
jmp 0x1919b
movq -0x40(%rbp), %rcx
leaq 0x79b4(%rip), %rax      # 0x20a50
movb $0x0, (%rax,%rcx)
movsbl 0x79a9(%rip), %eax      # 0x20a50
cmpl $0x2f, %eax
jne 0x19112
leaq 0x799d(%rip), %rax      # 0x20a50
movq %rax, -0x30(%rbp)
leaq 0x7992(%rip), %rdi      # 0x20a50
callq 0x5cc0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
addq $-0x1, %rcx
movq %rcx, -0x40(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x41(%rbp)
je 0x190f6
movq -0x40(%rbp), %rcx
leaq 0x7967(%rip), %rax      # 0x20a50
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
sete %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x190ff
jmp 0x19110
movq -0x40(%rbp), %rcx
leaq 0x7946(%rip), %rax      # 0x20a50
movb $0x0, (%rax,%rcx)
jmp 0x190c7
jmp 0x19112
jmp 0x1918a
movsbl -0x31(%rbp), %eax
cmpl $0x6c, %eax
jne 0x19137
callq 0xc830
movl -0xc(%rbp), %edi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
callq 0x64d0
movq %rax, -0x30(%rbp)
jmp 0x19188
movsbl -0x31(%rbp), %eax
cmpl $0x70, %eax
jne 0x19186
movq 0x76e1(%rip), %rdi      # 0x20828
callq 0x4090
movq $0x0, 0x76d1(%rip) # 0x20828
callq 0x12c80
movl 0x76c2(%rip), %eax      # 0x20824
andl $0xffffefff, %eax       # imm = 0xFFFFEFFF
orl $0x0, %eax
movl %eax, 0x76b4(%rip)      # 0x20824
movl 0x76ae(%rip), %eax      # 0x20824
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
orl $0x800, %eax            # imm = 0x800
movl %eax, 0x769e(%rip)      # 0x20824
jmp 0x19188
jmp 0x1918a
movb -0x21(%rbp), %cl
movq -0x18(%rbp), %rax
movb %cl, (%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)