// File: /workspace/github_c_makefile_star2_O0/jarun[P]nnn/src/nnn.c
// Function: xlink
static int xlink(char *prefix, char *path, char *curfname, char *buf, int type)
{
	int count = 0, choice;
	char *psel = pselbuf, *fname;
	size_t pos = 0, len, r;
	int (*link_fn)(const char *, const char *) = NULL;
	char lnpath[PATH_MAX];

	choice = get_cur_or_sel();
	if (!choice)
		return -1;

	if (type == 's') /* symbolic link */
		link_fn = &symlink;
	else /* hard link */
		link_fn = &link;

	if (choice == 'c' || (nselected == 1)) {
		prefix = abspath(prefix, path, lnpath); /* Generate link path */
		if (!prefix)
			return -1;

		if (choice == 'c')
			mkpath(path, curfname, buf); /* Generate target file path */

		if (!link_fn((choice == 'c') ? buf : pselbuf, lnpath)) {
			if (choice == 's')
				clearselection();
			return 1; /* One link created */
		}
		return 0;
	}

	r = xstrsncpy(buf, prefix, NAME_MAX + 1); /* Copy prefix */

	while (pos < selbufpos) {
		len = xstrlen(psel);
		fname = xbasename(psel);

		xstrsncpy(buf + r - 1, fname, NAME_MAX - r); /* Suffix target file name */
		mkpath(path, buf, lnpath); /* Generate link path */

		if (!link_fn(psel, lnpath))
			++count;

		pos += len + 1;
		psel += len + 1;
	}

	if (count == nselected) /* Clear selection if all links are generated */
		clearselection();
	return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1080, %rsp           # imm = 0x1080
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq 0xc67b(%rip), %rax      # 0x21d78
movq %rax, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x68(%rbp)
callq 0x13f70
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x1572b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x158d8
cmpl $0x73, -0x2c(%rbp)
jne 0x1573e
movq 0xa850(%rip), %rax      # 0x1ff88
movq %rax, -0x68(%rbp)
jmp 0x15749
movq 0xa893(%rip), %rax      # 0x1ffd8
movq %rax, -0x68(%rbp)
cmpl $0x63, -0x34(%rbp)
je 0x1575c
cmpl $0x1, 0x14e56(%rip)     # 0x2a5ac
jne 0x15809
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x1070(%rbp), %rdx
callq 0x5f00
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x15787
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x158d8
cmpl $0x63, -0x34(%rbp)
jne 0x1579e
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x74c0
movq -0x68(%rbp), %rax
movq %rax, -0x1078(%rbp)
cmpl $0x63, -0x34(%rbp)
jne 0x157bc
movq -0x28(%rbp), %rax
movq %rax, -0x1080(%rbp)
jmp 0x157ca
movq 0xc5b5(%rip), %rax      # 0x21d78
movq %rax, -0x1080(%rbp)
movq -0x1078(%rbp), %rax
movq -0x1080(%rbp), %rdi
leaq -0x1070(%rbp), %rsi
callq *%rax
cmpl $0x0, %eax
jne 0x157fd
cmpl $0x73, -0x34(%rbp)
jne 0x157f1
callq 0x12c80
movl $0x1, -0x4(%rbp)
jmp 0x158d8
movl $0x0, -0x4(%rbp)
jmp 0x158d8
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x6250
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movl 0xc547(%rip), %ecx      # 0x21d70
cmpq %rcx, %rax
jae 0x158c2
movq -0x40(%rbp), %rdi
callq 0x5cc0
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rdi
callq 0x7240
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rdi
addq -0x60(%rbp), %rdi
addq $-0x1, %rdi
movq -0x48(%rbp), %rsi
movl $0xff, %edx
subq -0x60(%rbp), %rdx
callq 0x6250
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x1070(%rbp), %rdx
callq 0x74c0
movq -0x68(%rbp), %rax
movq -0x40(%rbp), %rdi
leaq -0x1070(%rbp), %rsi
callq *%rax
cmpl $0x0, %eax
jne 0x1589d
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1581f
movl -0x30(%rbp), %eax
cmpl 0x14ce1(%rip), %eax     # 0x2a5ac
jne 0x158d2
callq 0x12c80
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1080, %rsp           # imm = 0x1080
popq %rbp
retq
nopw %cs:(%rax,%rax)