// File: /workspace/github_cpp_makefile_star2_O3/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 0x10148
movq %rbx, %rdi
movq %r14, %rdx
callq 0x10238
movq (%rbx), %rdi
leaq 0x20(%rsp), %rsi
callq 0x5380
testl %eax, %eax
jne 0x1059e
movq (%rbx), %rdi
movl $0x4, %esi
callq 0x56c0
testl %eax, %eax
jne 0x105f1
movl $0xf000, %eax           # imm = 0xF000
andl 0x38(%rsp), %eax
movl %eax, %ecx
negw %cx
jo 0x10535
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x10621
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x1052c
movq %r14, %rdi
movl $0x2f, %esi
callq 0x5340
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x5340
movl $0x1, (%r15)
jmp 0x1058b
movq %rsp, %rdi
movq %rbx, %rdx
callq 0x10422
leaq 0x11f79(%rip), %rdi     # 0x224c0
movq %rsp, %rsi
callq 0x67ca
movl $0x2, %ecx
testb %al, %al
jne 0x1056d
leaq 0x11f61(%rip), %rdi     # 0x224c0
movq %rsp, %rsi
callq 0x67ea
movzbl %al, %eax
leal (%rax,%rax,2), %ecx
movl %ecx, (%r15)
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1058b
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 0x106ab
movabsq $0x1000104004, %rcx     # imm = 0x1000104004
btq %rax, %rcx
jae 0x10681
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xbea0
leaq 0x10df6(%rip), %rsi     # 0x213d8
leaq -0x8ac7(%rip), %rdx     # 0x7b22
movq %r15, %rdi
callq 0x56f0
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xbe54
leaq 0x10fc8(%rip), %rsi     # 0x215d8
leaq -0x8af5(%rip), %rdx     # 0x7b22
movq %r15, %rdi
callq 0x56f0
jmp 0x10681
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x8003(%rip), %rsi      # 0x18642
leaq 0x8032(%rip), %rdx      # 0x18678
movq %rsp, %rdi
callq 0x8e2c
movb $0x1, %bpl
movq %rsp, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x8492
leaq 0x10de2(%rip), %rax     # 0x21448
movq %rax, (%r15)
xorl %ebp, %ebp
leaq 0x10d66(%rip), %rsi     # 0x213d8
leaq -0x8b57(%rip), %rdx     # 0x7b22
movq %r15, %rdi
callq 0x56f0
cmpq $0xd, %rax
jne 0x106ab
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xbe54
leaq 0x10f32(%rip), %rsi     # 0x215d8
jmp 0x105e2
movl $0x48, %edi
callq 0x5200
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xbf34
leaq 0x10f26(%rip), %rsi     # 0x215f0
jmp 0x105e2
jmp 0x106f9
jmp 0x106f9
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x106ec
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53f0
testb %bpl, %bpl
jne 0x106fc
jmp 0x1072b
jmp 0x106f9
jmp 0x106f9
jmp 0x10728
movq %rax, %r14
movq %r15, %rdi
callq 0x52e0
jmp 0x1072b
jmp 0x10728
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1072b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x53f0
jmp 0x1072b
movq %rax, %r14
movq (%rbx), %rdi
addq $0x10, %rbx
cmpq %rbx, %rdi
je 0x10742
movq (%rbx), %rsi
incq %rsi
callq 0x53f0
movq %r14, %rdi
callq 0x5720
nop