// File: hyp1231[P]FMSS/filesystem.cpp
// Function: FileSystem::MoveFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool FileSystem::MoveFile(string& S_filepath, string& D_filepath) {
    string filename;
    int dir_inodeNum = Analysis_path(S_filepath, filename);
    if(dir_inodeNum == -1) {
        return false;
    }
    int file_inodeNum = Get_file_inodeNum_from_dir(dir_inodeNum, filename);
    if(file_inodeNum == -1) {
        return false;
    }
    if(isDir(file_inodeNum)) {
        cout << "[Error] Source cannot be a directory" << endl;
        return false;
    }

	// convert inside file to string
	string file_data;
	if(!Inside_file2str(S_filepath, file_data)) {
		return false;
	}

	DeleteFile(S_filepath);
    str2Inside_file(file_data, D_filepath);

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x33e0
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rdx
movq -0x18(%rbp), %rsi
callq 0x65b0
movl %eax, -0xa8(%rbp)
jmp 0x8b81
movl -0xa8(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpl $-0x1, -0x44(%rbp)
jne 0x8bb1
movb $0x0, -0x1(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0x8d88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8d9f
movq -0xb8(%rbp), %rdi
movl -0x44(%rbp), %esi
leaq -0x40(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4d30
movl %eax, -0xbc(%rbp)
jmp 0x8bce
movl -0xbc(%rbp), %eax
movl %eax, -0x5c(%rbp)
cmpl $-0x1, -0x5c(%rbp)
jne 0x8bed
movb $0x0, -0x1(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0x8d88
movq -0xb8(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x6800
movb %al, -0xbd(%rbp)
jmp 0x8c04
movb -0xbd(%rbp), %al
testb $0x1, %al
jne 0x8c10
jmp 0x8c51
movq 0xc3b9(%rip), %rdi      # 0x14fd0
leaq 0x6ac5(%rip), %rsi      # 0xf6e3
callq 0x3250
movq %rax, -0xc8(%rbp)
jmp 0x8c2c
movq -0xc8(%rbp), %rdi
movq 0xc386(%rip), %rsi      # 0x14fc0
callq 0x32a0
jmp 0x8c41
movb $0x0, -0x1(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0x8d88
leaq -0x80(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x33e0
movq -0xb8(%rbp), %rdi
movq -0xd8(%rbp), %rdx
movq -0x18(%rbp), %rsi
callq 0x8880
movb %al, -0xc9(%rbp)
jmp 0x8c80
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x8cad
jmp 0x8c8c
movb $0x0, -0x1(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0x8d72
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8d7d
movq -0x18(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x34a0
movq -0xe0(%rbp), %rdx
leaq 0x6973(%rip), %rsi      # 0xf64c
leaq -0xa0(%rbp), %rdi
callq 0x3c50
jmp 0x8ce7
movq -0xe8(%rbp), %rsi
movq -0xb8(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x5f50
jmp 0x8d03
leaq -0xa0(%rbp), %rdi
callq 0x3160
leaq -0xa1(%rbp), %rdi
callq 0x32d0
movq -0xb8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq -0x80(%rbp), %rsi
callq 0x7c00
jmp 0x8d31
movb $0x1, -0x1(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0x8d72
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8d64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3160
leaq -0xa1(%rbp), %rdi
callq 0x32d0
jmp 0x8d7d
leaq -0x80(%rbp), %rdi
callq 0x3160
jmp 0x8d88
leaq -0x80(%rbp), %rdi
callq 0x3160
jmp 0x8d9f
leaq -0x40(%rbp), %rdi
callq 0x3160
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xf0, %rsp
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x3160
movq -0x50(%rbp), %rdi
callq 0x3490
nopw %cs:(%rax,%rax)