// File: /workspace/github_c_makefile_star2_O0/jarun[P]nnn/src/nnn.c
// Function: addtoselbuf
static void addtoselbuf(const int pathlen, int startid, int endid)
{
	int i;
	size_t len, alloclen = 0;
	struct entry *dentp;
	char *found;
	char * const pbuf = g_sel + pathlen;

	/* Remember current selection buffer position */
	for (i = startid; i <= endid; ++i) {
		dentp = &pdents[i];

		if (findselpos) {
			len = pathlen + xstrsncpy(pbuf, dentp->name, NAME_MAX);
			found = findinsel(findselpos, len);
			if (found) {
				dentp->flags |= (FILE_SCANNED | FILE_SELECTED);
				if (found == findselpos) {
					findselpos += len;
					if (findselpos == (pselbuf + selbufpos))
						findselpos = NULL;
				}
			} else
				alloclen += pathlen + dentp->nlen;
		} else
			alloclen += pathlen + dentp->nlen;
	}

	selbufrealloc(alloclen);

	for (i = startid; i <= endid; ++i) {
		if (!(pdents[i].flags & FILE_SELECTED)) {
			len = pathlen + xstrsncpy(pbuf, pdents[i].name, NAME_MAX);
			appendfpath(g_sel, len);
			++nselected;
			pdents[i].flags |= (FILE_SCANNED | FILE_SELECTED);
		}
	}

	writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movq $0x0, -0x20(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x16bfc(%rip), %rax     # 0x2a5c0
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0x13b1e
movq 0x1698c(%rip), %rax     # 0x2a370
movslq -0x10(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, 0x17bc5(%rip)     # 0x2b5c0
je 0x13aec
movslq -0x4(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movl $0xff, %edx
callq 0x6250
movq %rax, %rcx
movq -0x40(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq 0x17b8d(%rip), %rdi     # 0x2b5c0
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x17c90
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x13ac8
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rcx
shrq $0x38, %rcx
orl $0x30, %ecx
movslq %ecx, %rdx
movq 0x20(%rax), %rcx
andq $0xff, %rdx
shlq $0x38, %rdx
movabsq $0xffffffffffffff, %rsi # imm = 0xFFFFFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
cmpq 0x17b37(%rip), %rax     # 0x2b5c0
jne 0x13ac6
movq -0x18(%rbp), %rax
addq 0x17b2a(%rip), %rax     # 0x2b5c0
movq %rax, 0x17b23(%rip)     # 0x2b5c0
movq 0x17b1c(%rip), %rax     # 0x2b5c0
movq 0xe2cd(%rip), %rcx      # 0x21d78
movl 0xe2bf(%rip), %edx      # 0x21d70
addq %rdx, %rcx
cmpq %rcx, %rax
jne 0x13ac4
movq $0x0, 0x17afc(%rip) # 0x2b5c0
jmp 0x13ac6
jmp 0x13aea
movl -0x4(%rbp), %eax
movq -0x28(%rbp), %rcx
movq 0x20(%rcx), %rcx
shrq $0x28, %rcx
andq $0xffff, %rcx           # imm = 0xFFFF
addl %ecx, %eax
cltq
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x13b0e
movl -0x4(%rbp), %eax
movq -0x28(%rbp), %rcx
movq 0x20(%rcx), %rcx
shrq $0x28, %rcx
andq $0xffff, %rcx           # imm = 0xFFFF
addl %ecx, %eax
cltq
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x13b10
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x139d1
movq -0x20(%rbp), %rdi
callq 0x19970
movl -0x8(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0x13c0a
movq 0x16830(%rip), %rax     # 0x2a370
movslq -0x10(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
shrq $0x38, %rax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x13bfa
movslq -0x4(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq 0x167fe(%rip), %rax     # 0x2a370
movslq -0x10(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl $0xff, %edx
callq 0x6250
movq %rax, %rcx
movq -0x48(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rsi
leaq 0x16a1d(%rip), %rdi     # 0x2a5c0
callq 0x10af0
movl 0x169fe(%rip), %eax     # 0x2a5ac
addl $0x1, %eax
movl %eax, 0x169f5(%rip)     # 0x2a5ac
movq 0x167b2(%rip), %rax     # 0x2a370
movslq -0x10(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rcx
shrq $0x38, %rcx
orl $0x30, %ecx
movslq %ecx, %rdx
movq 0x20(%rax), %rcx
andq $0xff, %rdx
shlq $0x38, %rdx
movabsq $0xffffffffffffff, %rsi # imm = 0xFFFFFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x20(%rax)
jmp 0x13bfc
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x13b2d
movq 0xe167(%rip), %rdi      # 0x21d78
movl 0xe159(%rip), %eax      # 0x21d70
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0xe130
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)