// File: /workspace/github_cpp_makefile_star2_O2/metopa[P]HTTP_Server/src/content/CPathResolver.cpp
// Function: CPathResolver::resolve(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, EFileType&)
string CPathResolver::resolve( string& path, EFileType& ft ) {
	unwindPath( path );
	string realPath = substitutePath( path );
	struct stat info;

	if ( stat( realPath.c_str(), &info ) != 0 ) {
		int errNo = errno;
		switch ( errNo ) {
			case EFAULT:
			case ENAMETOOLONG:
			case ENOENT:
			case ENOTDIR:
				throw FileNotFoundException( path );
			case EACCES:
				throw PermissionDeniedException( path );
			default:
				throw FileErrorException( path );
		}
	}

	if ( access( realPath.c_str(), R_OK ) )
		throw PermissionDeniedException( path );

	if ( S_ISDIR( info.st_mode ) ) {
		if ( path.back() != '/' ) {
			path += '/';
			realPath += '/';
		}
		ft = FT_DIRECTORY;
		return realPath;
	}

	if ( S_ISREG( info.st_mode ) ) {
		string ext = getExt( realPath );
		if ( config.checkRegExt( ext ) )
			ft = FT_EXECUTABLE;
		else if ( config.checkScriptExt( ext ) )
			ft = FT_SCRIPT;
		else
			ft = FT_REGULAR;
		return realPath;
	}

	throw FileNotFoundException( path, "Is not file or directory. Error code 401 will be send." );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xc0, %rsp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movq %rdx, %rsi
callq 0xd4e4
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xd5be
movq (%rbx), %rdi
leaq 0x30(%rsp), %rsi
callq 0x53b0
testl %eax, %eax
jne 0xd85f
movq (%rbx), %rdi
pushq $0x4
popq %rsi
callq 0x5720
testl %eax, %eax
jne 0xd8b0
movl $0xf000, %eax           # imm = 0xF000
andl 0x48(%rsp), %eax
movl %eax, %ecx
negw %cx
jo 0xd801
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xd8de
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0xd7f8
pushq $0x2f
popq %rsi
movq %r14, %rdi
callq 0x5360
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x5360
movl $0x1, (%r15)
jmp 0xd84c
leaq 0x10(%rsp), %rdi
movq %rbx, %rdx
callq 0xd6f4
leaq 0x13cdb(%rip), %rdi     # 0x214f0
leaq 0x10(%rsp), %rsi
callq 0x644a
testb %al, %al
je 0xd828
pushq $0x2
popq %rax
jmp 0xd83f
leaq 0x13cc1(%rip), %rdi     # 0x214f0
leaq 0x10(%rsp), %rsi
callq 0x646a
movzbl %al, %eax
leal (%rax,%rax,2), %eax
movl %eax, (%r15)
leaq 0x10(%rsp), %rdi
callq 0x5210
movq %rbx, %rax
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x5060
movl (%rax), %eax
cmpq $0x24, %rax
ja 0xd952
movabsq $0x1000104004, %rcx     # imm = 0x1000104004
btq %rax, %rcx
jae 0xd92a
pushq $0x48
popq %rdi
callq 0x5230
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xa8de
leaq 0x12bbf(%rip), %rsi     # 0x20460
leaq -0x672c(%rip), %rdx     # 0x717c
movq %r15, %rdi
callq 0x5740
pushq $0x48
popq %rdi
callq 0x5230
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xa8c8
leaq 0x12d93(%rip), %rsi     # 0x20660
leaq -0x6758(%rip), %rdx     # 0x717c
movq %r15, %rdi
callq 0x5740
jmp 0xd92a
pushq $0x48
popq %rdi
callq 0x5230
movq %rax, %r15
leaq 0x6d36(%rip), %rsi      # 0x14626
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x712a
movb $0x1, %bpl
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x7166
xorl %ebp, %ebp
leaq 0x12b45(%rip), %rsi     # 0x20460
leaq -0x67a6(%rip), %rdx     # 0x717c
movq %r15, %rdi
callq 0x5740
cmpq $0xd, %rax
jne 0xd952
pushq $0x48
popq %rdi
callq 0x5230
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xa8c8
leaq 0x12d13(%rip), %rsi     # 0x20660
jmp 0xd8a1
pushq $0x48
popq %rdi
callq 0x5230
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xa948
leaq 0x12d09(%rip), %rsi     # 0x20678
jmp 0xd8a1
jmp 0xd992
jmp 0xd992
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x5210
testb %bpl, %bpl
jne 0xd995
jmp 0xd9b3
jmp 0xd992
jmp 0xd992
jmp 0xd9b0
movq %rax, %r14
movq %r15, %rdi
callq 0x5300
jmp 0xd9b3
jmp 0xd9b0
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x5210
jmp 0xd9b3
movq %rax, %r14
movq %rbx, %rdi
callq 0x5210
movq %r14, %rdi
callq 0x5770