// File: /workspace/github_cpp_makefile_star2_O1/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 $0xb0, %rsp
movq %rcx, %r15
movq %rdx, %r14
movq %rdi, %rbx
movq %rdx, %rsi
callq 0x10194
movq %rbx, %rdi
movq %r14, %rdx
callq 0x10284
movq (%rbx), %rdi
leaq 0x20(%rsp), %rsi
callq 0x5380
testl %eax, %eax
jne 0x1061e
movq (%rbx), %rdi
movl $0x4, %esi
callq 0x56d0
testl %eax, %eax
jne 0x10671
movl $0xf000, %eax           # imm = 0xF000
andl 0x38(%rsp), %eax
movl %eax, %ecx
negw %cx
jo 0x105b5
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x106a1
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x105ac
movq %r14, %rdi
movl $0x2f, %esi
callq 0x5340
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x5340
movl $0x1, (%r15)
jmp 0x1060b
movq %rsp, %rdi
movq %rbx, %rdx
callq 0x104a2
leaq 0x11f01(%rip), %rdi     # 0x224c8
movq %rsp, %rsi
callq 0x685e
movl $0x2, %ecx
testb %al, %al
jne 0x105ed
leaq 0x11ee9(%rip), %rdi     # 0x224c8
movq %rsp, %rsi
callq 0x687e
movzbl %al, %eax
leal (%rax,%rax,2), %ecx
movl %ecx, (%r15)
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1060b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53f0
movq %rbx, %rax
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x5060
movl (%rax), %eax
cmpq $0x24, %rax
ja 0x1072b
movabsq $0x1000104004, %rcx     # imm = 0x1000104004
btq %rax, %rcx
jae 0x10701
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xbf86
leaq 0x10d3e(%rip), %rsi     # 0x213a0
leaq -0x8a41(%rip), %rdx     # 0x7c28
movq %r15, %rdi
callq 0x5700
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xbf3a
leaq 0x10f10(%rip), %rsi     # 0x215a0
leaq -0x8a6f(%rip), %rdx     # 0x7c28
movq %r15, %rdi
callq 0x5700
jmp 0x10701
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x7f83(%rip), %rsi      # 0x18642
leaq 0x7fb2(%rip), %rdx      # 0x18678
movq %rsp, %rdi
callq 0x8f0e
movb $0x1, %bpl
movq %rsp, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x857a
leaq 0x10d2a(%rip), %rax     # 0x21410
movq %rax, (%r15)
xorl %ebp, %ebp
leaq 0x10cae(%rip), %rsi     # 0x213a0
leaq -0x8ad1(%rip), %rdx     # 0x7c28
movq %r15, %rdi
callq 0x5700
cmpq $0xd, %rax
jne 0x1072b
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xbf3a
leaq 0x10e7a(%rip), %rsi     # 0x215a0
jmp 0x10662
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xc01a
leaq 0x10e6e(%rip), %rsi     # 0x215b8
jmp 0x10662
jmp 0x1077f
jmp 0x1077f
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x10774
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53f0
jmp 0x10774
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
jne 0x10782
jmp 0x107b1
jmp 0x1077f
jmp 0x107ae
movq %rax, %r14
movq %r15, %rdi
callq 0x52e0
jmp 0x107b1
jmp 0x107ae
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x107b1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53f0
jmp 0x107b1
movq %rax, %r14
movq (%rbx), %rdi
addq $0x10, %rbx
cmpq %rbx, %rdi
je 0x107c8
movq (%rbx), %rsi
incq %rsi
callq 0x53f0
movq %r14, %rdi
callq 0x5730