// File: hyp1231[P]FMSS/filesystem.cpp
// Function: FileSystem::Analysis_path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
int FileSystem::Analysis_path(const string& filepath, string& filename) {
	vector<string> path;
    int dir_inodeNum;
    if(!Decomposition_path(filepath, path)) {
        cout << "[Error] Illegal path!" << endl;
        return -1;
    }

    if(path.empty()) {
        cout << "[Error] Empty path!" << endl;
        return -1;
    }

    if((int)path.size() >= 2) {
        filename = path[path.size() - 1];
    } else {
        filename = path[0]; // omit path
    }
    path.pop_back();
    
    if((int)filename.size() > 8) {
    	cout << "[Error] filename is too long" << endl;
    	return -1;
    }

    if((int)path.size() >= 1) {
        dir_inodeNum = Get_dir_inodeNum_from_path(path);
    } else {
        dir_inodeNum = cur_dir_inodeNum;    // omit path -> cur dir
    }

    return dir_inodeNum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9260
movq -0x18(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x30f0
jmp 0x65e7
leaq -0x60(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4280
movb %al, -0x79(%rbp)
jmp 0x65f9
movb -0x79(%rbp), %al
xorb $-0x1, %al
movb %al, -0x7a(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3160
movb -0x7a(%rbp), %al
testb $0x1, %al
jne 0x6613
jmp 0x6682
movq 0xe9b6(%rip), %rdi      # 0x14fd0
leaq 0x8ec6(%rip), %rsi      # 0xf4e7
callq 0x3250
movq %rax, -0x88(%rbp)
jmp 0x662f
movq -0x88(%rbp), %rdi
movq 0xe983(%rip), %rsi      # 0x14fc0
callq 0x32a0
jmp 0x6644
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x70(%rbp)
jmp 0x67cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x67e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3160
jmp 0x67e4
leaq -0x38(%rbp), %rdi
callq 0x92e0
testb $0x1, %al
jne 0x6691
jmp 0x66d5
movq 0xe938(%rip), %rdi      # 0x14fd0
leaq 0x8e5e(%rip), %rsi      # 0xf4fd
callq 0x3250
movq %rax, -0x90(%rbp)
jmp 0x66ad
movq -0x90(%rbp), %rdi
movq 0xe905(%rip), %rsi      # 0x14fc0
callq 0x32a0
jmp 0x66c2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x70(%rbp)
jmp 0x67cf
leaq -0x38(%rbp), %rdi
callq 0x9370
cmpl $0x2, %eax
jl 0x6715
leaq -0x38(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x9370
movq -0x98(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x9350
movq %rax, %rsi
movq -0x20(%rbp), %rdi
callq 0x3040
jmp 0x6713
jmp 0x6732
xorl %eax, %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
callq 0x9350
movq %rax, %rsi
movq -0x20(%rbp), %rdi
callq 0x3040
jmp 0x6730
jmp 0x6732
leaq -0x38(%rbp), %rdi
callq 0x9610
movq -0x20(%rbp), %rdi
callq 0x31a0
cmpl $0x8, %eax
jle 0x678a
movq 0xe880(%rip), %rdi      # 0x14fd0
leaq 0x8d25(%rip), %rsi      # 0xf47c
callq 0x3250
movq %rax, -0xa0(%rbp)
jmp 0x6765
movq -0xa0(%rbp), %rdi
movq 0xe84d(%rip), %rsi      # 0x14fc0
callq 0x32a0
jmp 0x677a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x70(%rbp)
jmp 0x67cf
leaq -0x38(%rbp), %rdi
callq 0x9370
cmpl $0x1, %eax
jl 0x67b8
movq -0x78(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4be0
movl %eax, -0xa4(%rbp)
jmp 0x67ad
movl -0xa4(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x67c2
movq -0x78(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9280
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x9280
movq -0x68(%rbp), %rdi
callq 0x3490
nopw %cs:(%rax,%rax)