// File: BleuLlama[P]msf-tools/DiskUtils.cpp
// Function: DiskUtils::LFNFrom83(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string DiskUtils::LFNFrom83( std::string _path, std::string eightthree )
{
	int foundcount = 0;
	std::string foundname( "" );


	// expand out the full path
	std::string e3_fullpath( _path );
	e3_fullpath.append( eightthree );

	// okay. let's now search the directory for the LFN with the same size.
	DIR * theDir = opendir( _path.c_str() );
	struct dirent * entry;
	if( theDir ) {

		// check each entry
		while(( entry = readdir( theDir )) != NULL ) {

			// build a full path to the file
			std::string lfn_fullpath( _path );
			lfn_fullpath.append( entry->d_name );

			// are they similar?
			bool isSimilar = DiskUtils::IsSimilarFile( e3_fullpath, lfn_fullpath );

			// WE GOT ONE!!!
			if( isSimilar ) {
				foundcount++;
				foundname.assign( entry->d_name );
			}
		}


		closedir( theDir );
	}

	// okay. there was a match. return it.
	if( foundcount >= 1 ) {
		return foundname;
	}

	return _path + eightthree;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdx, -0x120(%rbp)
movq %rsi, -0x118(%rbp)
movq %rdi, -0x110(%rbp)
movq %rdi, %rax
movq %rax, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x2330
movq -0x100(%rbp), %rdx
leaq 0x3851(%rip), %rsi      # 0x61ac
leaq -0x40(%rbp), %rdi
callq 0x2e40
jmp 0x2966
leaq -0x41(%rbp), %rdi
callq 0x21c0
movq -0x118(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x20a0
jmp 0x2981
movq -0x120(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x2390
jmp 0x2993
movq -0x118(%rbp), %rdi
callq 0x2090
movq %rax, %rdi
callq 0x2290
movq %rax, -0x128(%rbp)
jmp 0x29b0
movq -0x128(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x2b5f
jmp 0x29c8
movq -0x80(%rbp), %rdi
callq 0x22a0
movq %rax, -0x130(%rbp)
jmp 0x29da
movq -0x130(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x2b52
movq -0x118(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x20a0
jmp 0x2a07
movq -0x88(%rbp), %rsi
addq $0x13, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x2360
jmp 0x2a20
leaq -0xd0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x20a0
jmp 0x2a32
leaq -0xf0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x20a0
jmp 0x2a47
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x26f0
movb %al, -0x131(%rbp)
jmp 0x2a62
leaq -0xf0(%rbp), %rdi
callq 0x20e0
leaq -0xd0(%rbp), %rdi
callq 0x20e0
movb -0x131(%rbp), %al
andb $0x1, %al
movb %al, -0xa9(%rbp)
testb $0x1, -0xa9(%rbp)
je 0x2b33
movl -0x1c(%rbp), %eax
incl %eax
movl %eax, -0x1c(%rbp)
movq -0x88(%rbp), %rsi
addq $0x13, %rsi
leaq -0x40(%rbp), %rdi
callq 0x2370
jmp 0x2ab3
jmp 0x2b33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x21c0
jmp 0x2bdb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2bd2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2bc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2b44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2b25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x20e0
leaq -0xd0(%rbp), %rdi
callq 0x20e0
jmp 0x2b44
leaq -0xa8(%rbp), %rdi
callq 0x20e0
jmp 0x29c8
leaq -0xa8(%rbp), %rdi
callq 0x20e0
jmp 0x2bc9
movq -0x80(%rbp), %rdi
callq 0x22f0
jmp 0x2b5d
jmp 0x2b5f
cmpl $0x1, -0x1c(%rbp)
jl 0x2b81
movq -0x110(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x20d0
movl $0x1, -0xf4(%rbp)
jmp 0x2ba7
movq -0x120(%rbp), %rdx
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdi
callq 0x2ef0
jmp 0x2b9d
movl $0x1, -0xf4(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x20e0
leaq -0x40(%rbp), %rdi
callq 0x20e0
movq -0x108(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
leaq -0x78(%rbp), %rdi
callq 0x20e0
leaq -0x40(%rbp), %rdi
callq 0x20e0
movq -0x50(%rbp), %rdi
callq 0x2320
nopw %cs:(%rax,%rax)