// File: /workspace/github_c_makefile_star2_O0/jarun[P]nnn/src/nnn.c
// Function: batch_rename
static bool batch_rename(void)
{
	int fd1, fd2;
	uint_t count = 0, lines = 0;
	bool dir = FALSE, ret = FALSE;
	char foriginal[TMP_LEN_MAX] = {0};
	static const char batchrenamecmd[] = "paste -d'\n' %s %s | "SED" 'N; /^\\(.*\\)\\n\\1$/!p;d' | "
					     "tr '\n' '\\0' | xargs -0 -n2 sh -c 'mv -i -- \"$0\" \"$@\" <"
					     " /dev/tty'";
	char buf[sizeof(batchrenamecmd) + (PATH_MAX << 1)];
	int i = get_cur_or_sel();

	if (!i)
		return ret;

	if (i == 'c') { /* Rename entries in current dir */
		selbufpos = 0;
		dir = TRUE;
	}

	fd1 = create_tmp_file();
	if (fd1 == -1)
		return ret;

	xstrsncpy(foriginal, g_tmpfpath, xstrlen(g_tmpfpath) + 1);

	fd2 = create_tmp_file();
	if (fd2 == -1) {
		unlink(foriginal);
		close(fd1);
		return ret;
	}

	if (dir)
		for (i = 0; i < ndents; ++i)
			appendfpath(pdents[i].name, NAME_MAX);

	seltofile(fd1, &count, NEWLINE);
	seltofile(fd2, NULL, NEWLINE);
	close(fd2);

	if (dir) /* Don't retain dir entries in selection */
		selbufpos = 0;

	spawn((cfg.waitedit ? enveditor : editor), g_tmpfpath, NULL, NULL, F_CLI);

	/* Reopen file descriptor to get updated contents */
	fd2 = open(g_tmpfpath, O_RDONLY);
	if (fd2 == -1)
		goto finish;

	lines = entries_in_file(fd2, buf, sizeof(buf), NEWLINE_CHAR);
	DPRINTF_U(count);
	DPRINTF_U(lines);
	if (!lines || (count != lines)) {
		DPRINTF_S("cannot delete files");
		goto finish;
	}

	snprintf(buf, sizeof(buf), batchrenamecmd, foriginal, g_tmpfpath);
	spawn(utils[UTIL_SH_EXEC], buf, NULL, NULL, F_CLI);
	ret = TRUE;

finish:
	if (fd1 >= 0)
		close(fd1);
	unlink(foriginal);

	if (fd2 >= 0)
		close(fd2);
	unlink(g_tmpfpath);

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2100, %rsp           # imm = 0x2100
movl $0x0, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
movb $0x0, -0x16(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x4380
callq 0x13f70
movl %eax, -0x20e4(%rbp)
cmpl $0x0, -0x20e4(%rbp)
jne 0x12a32
movb -0x16(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x12c6a
cmpl $0x63, -0x20e4(%rbp)
jne 0x12a49
movl $0x0, 0xf32b(%rip)      # 0x21d70
movb $0x1, -0x15(%rbp)
callq 0xddd0
movl %eax, -0x8(%rbp)
cmpl $-0x1, -0x8(%rbp)
jne 0x12a64
movb -0x16(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x12c6a
leaq -0x60(%rbp), %rax
movq %rax, -0x20f0(%rbp)
leaq 0xdf8a(%rip), %rdi      # 0x20a00
callq 0x5cc0
movq -0x20f0(%rbp), %rdi
movq %rax, %rdx
addq $0x1, %rdx
leaq 0xdf70(%rip), %rsi      # 0x20a00
callq 0x6250
callq 0xddd0
movl %eax, -0xc(%rbp)
cmpl $-0x1, -0xc(%rbp)
jne 0x12ac1
leaq -0x60(%rbp), %rdi
callq 0x40d0
movl -0x8(%rbp), %edi
callq 0x43c0
movb -0x16(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x12c6a
testb $0x1, -0x15(%rbp)
je 0x12b14
movl $0x0, -0x20e4(%rbp)
movl -0x20e4(%rbp), %eax
cmpl 0xf3af(%rip), %eax      # 0x21e8c
jge 0x12b12
movq 0x1788a(%rip), %rax     # 0x2a370
movslq -0x20e4(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movl $0xff, %esi
callq 0x10af0
movl -0x20e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20e4(%rbp)
jmp 0x12ad1
jmp 0x12b14
movl -0x8(%rbp), %edi
leaq -0x10(%rbp), %rsi
leaq 0x9d4c(%rip), %rdx      # 0x1c86e
callq 0xc650
movl -0xc(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
leaq 0x9d39(%rip), %rdx      # 0x1c86e
callq 0xc650
movl -0xc(%rbp), %edi
callq 0x43c0
testb $0x1, -0x15(%rbp)
je 0x12b52
movl $0x0, 0xf21e(%rip)      # 0x21d70
movl 0xd978(%rip), %eax      # 0x204d0
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x12b73
movq 0xde36(%rip), %rax      # 0x209a0
movq %rax, -0x20f8(%rbp)
jmp 0x12b81
movq 0xde6e(%rip), %rax      # 0x209e8
movq %rax, -0x20f8(%rbp)
movq -0x20f8(%rbp), %rdi
leaq 0xde71(%rip), %rsi      # 0x20a00
xorl %eax, %eax
movl %eax, %ecx
movl $0x9, %r8d
movq %rcx, %rdx
callq 0xde30
leaq 0xde58(%rip), %rdi      # 0x20a00
xorl %esi, %esi
movb $0x0, %al
callq 0x46c0
movl %eax, -0xc(%rbp)
cmpl $-0x1, -0xc(%rbp)
jne 0x12bbc
jmp 0x12c31
movl -0xc(%rbp), %edi
leaq -0x20e0(%rbp), %rsi
movl $0x2073, %edx           # imm = 0x2073
movl $0xa, %ecx
callq 0x197d0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x12be6
movl -0x10(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x12be8
jmp 0x12c31
leaq -0x20e0(%rbp), %rdi
leaq -0x60(%rbp), %rcx
movl $0x2073, %esi           # imm = 0x2073
leaq 0x8991(%rip), %rdx      # 0x1b590
leaq 0xddfa(%rip), %r8       # 0x20a00
movb $0x0, %al
callq 0x4350
movq 0xcdd4(%rip), %rdi      # 0x1f9e8
leaq -0x20e0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movl $0x9, %r8d
movq %rcx, %rdx
callq 0xde30
movb $0x1, -0x16(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x12c3f
movl -0x8(%rbp), %edi
callq 0x43c0
leaq -0x60(%rbp), %rdi
callq 0x40d0
cmpl $0x0, -0xc(%rbp)
jl 0x12c56
movl -0xc(%rbp), %edi
callq 0x43c0
leaq 0xdda3(%rip), %rdi      # 0x20a00
callq 0x40d0
movb -0x16(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x2100, %rsp           # imm = 0x2100
popq %rbp
retq
nopl (%rax,%rax)