// File: /workspace/github_c_makefile_star2_O0/jarun[P]nnn/src/nnn.c
// Function: cpmv_rename
static bool cpmv_rename(int choice, const char *path)
{
	int fd;
	uint_t count = 0, lines = 0;
	bool ret = FALSE;
	char *cmd = (choice == 'c' ? cp : mv);
	char buf[sizeof(patterns[P_CPMVRNM]) + (MAX(sizeof(cp), sizeof(mv))) + (PATH_MAX << 1)];

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

	/* selsafe() returned TRUE for this to be called */
	if (!selbufpos) {
		snprintf(buf, sizeof(buf), "tr '\\0' '\\n' < %s > %s", selpath, g_tmpfpath);
		spawn(utils[UTIL_SH_EXEC], buf, NULL, NULL, F_CLI);

		count = entries_in_file(fd, buf, sizeof(buf), NEWLINE_CHAR);
		if (!count)
			goto finish;
	} else
		seltofile(fd, &count, NEWLINE);

	close(fd);

	snprintf(buf, sizeof(buf), patterns[P_CPMVFMT], g_tmpfpath);
	spawn(utils[UTIL_SH_EXEC], buf, NULL, NULL, F_CLI);

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

	fd = open(g_tmpfpath, O_RDONLY);
	if (fd == -1)
		goto finish;

	lines = entries_in_file(fd, buf, sizeof(buf), NEWLINE_CHAR);
	DPRINTF_U(count);
	DPRINTF_U(lines);
	if (!lines || (2 * count != lines)) {
		DPRINTF_S("num mismatch");
		goto finish;
	}

	snprintf(buf, sizeof(buf), patterns[P_CPMVRNM], path, g_tmpfpath, cmd);
	if (!spawn(utils[UTIL_SH_EXEC], buf, NULL, NULL, F_CLI | F_CHKRTN))
		ret = TRUE;
finish:
	if (fd >= 0)
		close(fd);

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2050, %rsp           # imm = 0x2050
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movb $0x0, -0x1d(%rbp)
movl -0x8(%rbp), %edx
leaq 0x682b(%rip), %rax      # 0x204b9
leaq 0x6817(%rip), %rcx      # 0x204ac
cmpl $0x63, %edx
cmoveq %rcx, %rax
movq %rax, -0x28(%rbp)
callq 0xddd0
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x19cbb
movb -0x1d(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x19e96
cmpl $0x0, 0x80ae(%rip)      # 0x21d70
jne 0x19d35
leaq -0x2040(%rbp), %rdi
movq 0x6b56(%rip), %rcx      # 0x20828
movl $0x2015, %esi           # imm = 0x2015
leaq 0x2c3a(%rip), %rdx      # 0x1c918
leaq 0x6d1b(%rip), %r8       # 0x20a00
movb $0x0, %al
callq 0x4350
movq 0x5cf5(%rip), %rdi      # 0x1f9e8
leaq -0x2040(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movl $0x9, %r8d
movq %rcx, %rdx
callq 0xde30
movl -0x14(%rbp), %edi
leaq -0x2040(%rbp), %rsi
movl $0x2015, %edx           # imm = 0x2015
movl $0xa, %ecx
callq 0x197d0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x19d33
jmp 0x19e80
jmp 0x19d48
movl -0x14(%rbp), %edi
leaq -0x18(%rbp), %rsi
leaq 0x2b2b(%rip), %rdx      # 0x1c86e
callq 0xc650
movl -0x14(%rbp), %edi
callq 0x43c0
leaq -0x2040(%rbp), %rdi
movq 0x5e62(%rip), %rdx      # 0x1fbc0
movl $0x2015, %esi           # imm = 0x2015
leaq 0x6c96(%rip), %rcx      # 0x20a00
movb $0x0, %al
callq 0x4350
movq 0x5c70(%rip), %rdi      # 0x1f9e8
leaq -0x2040(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movl $0x9, %r8d
movq %rcx, %rdx
callq 0xde30
movl 0x6739(%rip), %eax      # 0x204d0
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x19db2
movq 0x6bf7(%rip), %rax      # 0x209a0
movq %rax, -0x2048(%rbp)
jmp 0x19dc0
movq 0x6c2f(%rip), %rax      # 0x209e8
movq %rax, -0x2048(%rbp)
movq -0x2048(%rbp), %rdi
leaq 0x6c32(%rip), %rsi      # 0x20a00
xorl %eax, %eax
movl %eax, %ecx
movl $0x9, %r8d
movq %rcx, %rdx
callq 0xde30
leaq 0x6c19(%rip), %rdi      # 0x20a00
xorl %esi, %esi
movb $0x0, %al
callq 0x46c0
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x19dfe
jmp 0x19e80
movl -0x14(%rbp), %edi
leaq -0x2040(%rbp), %rsi
movl $0x2015, %edx           # imm = 0x2015
movl $0xa, %ecx
callq 0x197d0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x19e2a
movl -0x18(%rbp), %eax
shll %eax
cmpl -0x1c(%rbp), %eax
je 0x19e2c
jmp 0x19e80
leaq -0x2040(%rbp), %rdi
movq 0x5d8e(%rip), %rdx      # 0x1fbc8
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %r9
movl $0x2015, %esi           # imm = 0x2015
leaq 0x6bb2(%rip), %r8       # 0x20a00
movb $0x0, %al
callq 0x4350
movq 0x5b8c(%rip), %rdi      # 0x1f9e8
leaq -0x2040(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movl $0x29, %r8d
movq %rcx, %rdx
callq 0xde30
cmpl $0x0, %eax
jne 0x19e7e
movb $0x1, -0x1d(%rbp)
jmp 0x19e80
cmpl $0x0, -0x14(%rbp)
jl 0x19e8e
movl -0x14(%rbp), %edi
callq 0x43c0
movb -0x1d(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x2050, %rsp           # imm = 0x2050
popq %rbp
retq
nopw %cs:(%rax,%rax)