// File: /workspace/github_cpp_makefile_star2_O3/talyerushalmy[P]SimpleFileSystem/src/Commands.cpp
// Function: RenameCommand::execute(FileSystem&)
void RenameCommand::execute(FileSystem& fs)
{
	std::vector<std::string> arguments = StringTools::split(this->getArgs(), " ");

	if (arguments.size() != 2)
	{
		std::cout << "Usage: rename <path/old-name> <new-name>" << std::endl;
		return;
	}

	std::string src_name = StringTools::split(StringTools::trim(arguments[0]), "/").back();
	std::string src_dir = StringTools::trim(arguments[0]).substr(0, arguments[0].length() - src_name.length());

	Directory* src = fs.getDirectoryFromPath(src_dir);
	if (!src || !src->childExists(src_name))
	{
		std::cout << "No such file or directory" << std::endl;
		return;
	}

	src->getChildByName(src_name)->setName(StringTools::trim(arguments[1]));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x180, %rsp            # imm = 0x180
movq %rsi, %rbx
leaq -0x128(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rdi), %rsi
movq 0x30(%rdi), %rdx
addq %rsi, %rdx
leaq -0x138(%rbp), %rdi
callq 0x392c
leaq -0x108(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x552e(%rip), %rsi      # 0xe173
leaq 0x5528(%rip), %rdx      # 0xe174
leaq -0x118(%rbp), %rdi
callq 0xab8a
leaq -0x38(%rbp), %rdi
leaq -0x138(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x34ec
movq -0x118(%rbp), %rdi
cmpq %r15, %rdi
je 0x8c80
callq 0x31a0
movq -0x138(%rbp), %rdi
cmpq %r14, %rdi
je 0x8c91
callq 0x31a0
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rax
subq %rsi, %rax
cmpq $0x40, %rax
jne 0x8ea3
leaq -0x198(%rbp), %rdi
callq 0x35f2
leaq -0xe8(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x553f(%rip), %rsi      # 0xe203
leaq 0x5539(%rip), %rdx      # 0xe204
leaq -0xf8(%rbp), %rdi
callq 0xab8a
leaq -0x58(%rbp), %rdi
leaq -0x198(%rbp), %rsi
leaq -0xf8(%rbp), %rdx
callq 0x34ec
movq -0x50(%rbp), %rax
leaq -0x68(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %rdi
callq 0x392c
leaq -0x58(%rbp), %rdi
callq 0x36b8
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0x8d28
callq 0x31a0
leaq -0x188(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8d3d
callq 0x31a0
movq -0x38(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x35f2
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
subq -0x70(%rbp), %rcx
leaq -0x58(%rbp), %rdi
leaq -0x178(%rbp), %rsi
xorl %edx, %edx
callq 0x31d0
leaq -0x168(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8d80
callq 0x31a0
leaq -0xc8(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0xd8(%rbp), %rdi
callq 0x392c
leaq -0xd8(%rbp), %rsi
movq %rbx, %rdi
callq 0xacd6
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
je 0x8dc5
callq 0x31a0
testq %rbx, %rbx
je 0x8eeb
leaq -0xa8(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0xb8(%rbp), %rdi
callq 0x392c
leaq -0xb8(%rbp), %rsi
movq %rbx, %rdi
callq 0xbcda
movl %eax, %r14d
movq -0xb8(%rbp), %rdi
cmpq %r12, %rdi
je 0x8e14
callq 0x31a0
testb %r14b, %r14b
je 0x8eeb
leaq -0x88(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %rdi
callq 0x392c
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0xc41c
movq %rax, %rbx
movq -0x38(%rbp), %rsi
addq $0x20, %rsi
leaq -0x158(%rbp), %rdi
callq 0x35f2
leaq -0x158(%rbp), %rsi
movq %rbx, %rdi
callq 0xb338
leaq -0x148(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8e89
callq 0x31a0
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0x8f31
callq 0x31a0
jmp 0x8f31
movq 0xa126(%rip), %rbx      # 0x12fd0
leaq 0x5444(%rip), %rsi      # 0xe2f5
movl $0x28, %edx
movq %rbx, %rdi
callq 0x3200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq 0xa0f4(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
jmp 0x8f51
movq 0xa0de(%rip), %rbx      # 0x12fd0
leaq 0x5398(%rip), %rsi      # 0xe291
movl $0x19, %edx
movq %rbx, %rdi
callq 0x3200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq 0xa0ac(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8f43
callq 0x31a0
movq -0x78(%rbp), %rdi
cmpq %r15, %rdi
je 0x8f51
callq 0x31a0
leaq -0x38(%rbp), %rdi
callq 0x36b8
addq $0x180, %rsp            # imm = 0x180
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x148(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8f87
callq 0x31a0
jmp 0x8f87
movq %rax, %rbx
movq -0x98(%rbp), %rdi
jmp 0x8fae
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
cmpq %r12, %rdi
jne 0x8fb7
jmp 0x9044
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
je 0x9044
callq 0x31a0
jmp 0x9044
movq %rax, %rbx
leaq -0x168(%rbp), %rax
jmp 0x9048
movq %rax, %rbx
jmp 0x9056
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x36b8
jmp 0x8fe6
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0x8ffc
callq 0x31a0
jmp 0x8ffc
movq %rax, %rbx
leaq -0x188(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x905f
jmp 0x9064
jmp 0x903c
movq %rax, %rbx
movq -0x118(%rbp), %rdi
cmpq %r15, %rdi
je 0x9029
callq 0x31a0
jmp 0x9029
movq %rax, %rbx
movq -0x138(%rbp), %rdi
cmpq %r14, %rdi
je 0x906d
callq 0x31a0
jmp 0x906d
movq %rax, %rbx
jmp 0x9064
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9056
callq 0x31a0
movq -0x78(%rbp), %rdi
cmpq %r15, %rdi
je 0x9064
callq 0x31a0
leaq -0x38(%rbp), %rdi
callq 0x36b8
movq %rbx, %rdi
callq 0x32b0
nop