// File: /workspace/github_c_makefile_star2_O0/dlbeer[P]ufat/main.c
// Function: cmd_move
static int cmd_move(struct ufat *uf, const struct options *opt)
{
	struct ufat_directory dir;
	struct ufat_dirent src_ent;
	struct ufat_dirent dst_ent;
	int err;
	const char *src_path;
	const char *dst_path;
	const char *new_name;
	char old_name[UFAT_LFN_MAX_UTF8];

	if (opt->argc < 2) {
		fprintf(stderr, "You must specified a source path and "
			"a destination path.\n");
		return -1;
	}

	src_path = opt->argv[0];
	dst_path = opt->argv[1];

	err = find_path(uf, &dir, src_path, &src_ent, NULL);
	if (err < 0)
		return -1;

	if (err) {
		fprintf(stderr, "No such file or directory: %s\n",
			opt->argv[0]);
		return -1;
	}

	ufat_open_root(uf, &dir);
	err = ufat_dir_find_path(&dir, dst_path, &dst_ent, &new_name);

	if (err < 0) {
		fprintf(stderr, "ufat_dir_find_path: %s\n",
			ufat_strerror(err));
		return -1;
	}

	if (!err) {
		/* Is the destination a directory or an existing file? */
		if (!(dst_ent.attributes & UFAT_ATTR_DIRECTORY)) {
			fprintf(stderr, "File already exists: %s\n",
				dst_path);
			return -1;
		}

		/* It's a directory name. Use the old canonical filename. */
		err = ufat_open_subdir(uf, &dir, &dst_ent);
		if (err < 0) {
			fprintf(stderr, "ufat_open_subdir: %s\n",
				ufat_strerror(err));
			return -1;
		}

		err = ufat_get_filename(uf, &src_ent,
					old_name, sizeof(old_name));
		if (err < 0) {
			fprintf(stderr, "ufat_get_filename: %s\n",
				ufat_strerror(err));
			return -1;
		}

		new_name = old_name;
	}

	err = ufat_move(&src_ent, &dir, new_name);
	if (err < 0) {
		fprintf(stderr, "ufat_move: %s\n", ufat_strerror(err));
		return -1;
	}

	return 0;
}

// Assembly:
subq $0x408, %rsp            # imm = 0x408
movq %rdi, 0x3f8(%rsp)
movq %rsi, 0x3f0(%rsp)
movq 0x3f0(%rsp), %rax
cmpl $0x2, 0x40(%rax)
jge 0xa87d
movq 0x579c(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x2675(%rip), %rsi      # 0xcedb
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x404(%rsp) # imm = 0xFFFFFFFF
jmp 0xab73
movq 0x3f0(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movq %rax, 0x330(%rsp)
movq 0x3f0(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x328(%rsp)
movq 0x3f8(%rsp), %rdi
movq 0x330(%rsp), %rdx
leaq 0x3d0(%rsp), %rsi
leaq 0x388(%rsp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0xaf10
movl %eax, 0x33c(%rsp)
cmpl $0x0, 0x33c(%rsp)
jge 0xa8f7
movl $0xffffffff, 0x404(%rsp) # imm = 0xFFFFFFFF
jmp 0xab73
cmpl $0x0, 0x33c(%rsp)
je 0xa938
movq 0x56f0(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq 0x3f0(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rdx
leaq 0x21ee(%rip), %rsi      # 0xcb0f
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x404(%rsp) # imm = 0xFFFFFFFF
jmp 0xab73
movq 0x3f8(%rsp), %rdi
leaq 0x3d0(%rsp), %rsi
callq 0x3c30
movq 0x328(%rsp), %rsi
leaq 0x3d0(%rsp), %rdi
leaq 0x340(%rsp), %rdx
leaq 0x320(%rsp), %rcx
callq 0x49d0
movl %eax, 0x33c(%rsp)
cmpl $0x0, 0x33c(%rsp)
jge 0xa9c4
movq 0x566e(%rip), %rax      # 0xfff8
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movl 0x33c(%rsp), %edi
callq 0x2c40
movq 0x18(%rsp), %rdi
movq %rax, %rdx
leaq 0x2181(%rip), %rsi      # 0xcb2e
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x404(%rsp) # imm = 0xFFFFFFFF
jmp 0xab73
cmpl $0x0, 0x33c(%rsp)
jne 0xaafe
movl 0x36c(%rsp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0xaa11
movq 0x5610(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq 0x328(%rsp), %rdx
leaq 0x251b(%rip), %rsi      # 0xcf15
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x404(%rsp) # imm = 0xFFFFFFFF
jmp 0xab73
movq 0x3f8(%rsp), %rdi
leaq 0x3d0(%rsp), %rsi
leaq 0x340(%rsp), %rdx
callq 0x3ce0
movl %eax, 0x33c(%rsp)
cmpl $0x0, 0x33c(%rsp)
jge 0xaa80
movq 0x55b2(%rip), %rax      # 0xfff8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movl 0x33c(%rsp), %edi
callq 0x2c40
movq 0x10(%rsp), %rdi
movq %rax, %rdx
leaq 0x2090(%rip), %rsi      # 0xcaf9
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x404(%rsp) # imm = 0xFFFFFFFF
jmp 0xab73
movq 0x3f8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
leaq 0x388(%rsp), %rsi
movl $0x300, %ecx            # imm = 0x300
callq 0x4c00
movl %eax, 0x33c(%rsp)
cmpl $0x0, 0x33c(%rsp)
jge 0xaaf1
movq 0x5541(%rip), %rax      # 0xfff8
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl 0x33c(%rsp), %edi
callq 0x2c40
movq 0x8(%rsp), %rdi
movq %rax, %rdx
leaq 0x20df(%rip), %rsi      # 0xcbb9
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x404(%rsp) # imm = 0xFFFFFFFF
jmp 0xab73
leaq 0x20(%rsp), %rax
movq %rax, 0x320(%rsp)
movq 0x320(%rsp), %rdx
leaq 0x388(%rsp), %rdi
leaq 0x3d0(%rsp), %rsi
callq 0x4d60
movl %eax, 0x33c(%rsp)
cmpl $0x0, 0x33c(%rsp)
jge 0xab68
movq 0x54c5(%rip), %rax      # 0xfff8
movq (%rax), %rax
movq %rax, (%rsp)
movl 0x33c(%rsp), %edi
callq 0x2c40
movq (%rsp), %rdi
movq %rax, %rdx
leaq 0x23da(%rip), %rsi      # 0xcf2e
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x404(%rsp) # imm = 0xFFFFFFFF
jmp 0xab73
movl $0x0, 0x404(%rsp)
movl 0x404(%rsp), %eax
addq $0x408, %rsp            # imm = 0x408
retq
nopw %cs:(%rax,%rax)