// File: sisong[P]ApkDiffPatch/HDiffPatch/file_for_patch.c
// Function: hpatch_getPathStat_noEndDirSeparator
hpatch_BOOL _hpatch_getPathStat_noEndDirSeparator(const char* path_utf8,hpatch_TPathType* out_type,
                                                  hpatch_StreamPos_t* out_fileSize,size_t* out_st_mode){
#if (_IS_USED_WIN32_UTF8_WAPI)
    int            wsize;
    wchar_t        path_w[hpatch_kPathMaxSize];
    struct _stat64 s;
#else
#   ifdef _MSC_VER
    struct _stat64 s;
#   else
    struct stat  s;
#   endif
#endif
    
    int          rt;
    assert(out_type!=0);
    memset(&s,0,sizeof(s));
#if (_IS_USED_WIN32_UTF8_WAPI)
    wsize=_utf8FileName_to_w(path_utf8,path_w,hpatch_kPathMaxSize);
    if (wsize<=0) return hpatch_FALSE;
    #if (_IS_FOR_WINXP)
        _getStatByAttributes(path_w,s,rt,GetFileAttributesExW);
    #else
        rt = _wstat64(path_w,&s);
    #endif
#else
#   ifdef _MSC_VER
    #if (_IS_FOR_WINXP)
        _getStatByAttributes(path_utf8,s,rt,GetFileAttributesExA);
    #else
        rt = _stat64(path_utf8,&s);
    #endif
#   else
    rt = stat(path_utf8,&s);
#   endif
#endif
    if (out_st_mode) *out_st_mode=s.st_mode;
    
    if(rt!=0){
        if (errno==ENOENT){
            *out_type=kPathType_notExist;
            return hpatch_TRUE;
        }
        return hpatch_FALSE; //error
    }else if ((s.st_mode&S_IFMT)==S_IFREG){
        *out_type=kPathType_file;
        if (out_fileSize) *out_fileSize=s.st_size;
        return hpatch_TRUE;
    }else if ((s.st_mode&S_IFMT)==S_IFDIR){
        *out_type=kPathType_dir;
        if (out_fileSize) *out_fileSize=0;
        return hpatch_TRUE;
#if (_IS_NEED_BLOCK_DEV)
    }else if ((s.st_mode&S_IFMT)==S_IFBLK){
        hpatch_uint64_t bsize=0;
        if (!_get_block_dev_size(path_utf8, &bsize))
            return hpatch_FALSE;
        *out_type=kPathType_file;
        if (out_fileSize) *out_fileSize=bsize;
        return hpatch_TRUE;
#endif
    }else{
        return hpatch_FALSE; //as error; unknow how to dispose
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x8cfa4
jmp 0x8cfc3
leaq 0x28965(%rip), %rdi     # 0xb5910
leaq 0x2896a(%rip), %rsi     # 0xb591c
movl $0xab, %edx
leaq 0x2897a(%rip), %rcx     # 0xb5938
callq 0x4270
leaq -0xb8(%rbp), %rdi
xorl %esi, %esi
movl $0x90, %edx
callq 0x4210
movq -0x10(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4640
movl %eax, -0xbc(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x8d002
movl -0xa0(%rbp), %eax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x0, -0xbc(%rbp)
je 0x8d037
callq 0x4050
cmpl $0x2, (%rax)
jne 0x8d02b
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x8d115
movl $0x0, -0x4(%rbp)
jmp 0x8d115
movl -0xa0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x8d074
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x8d068
movq -0x88(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x8d115
movl -0xa0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x8d0ab
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x8d0a2
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x8d115
movl -0xa0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x6000, %eax           # imm = 0x6000
jne 0x8d10e
movq $0x0, -0xc8(%rbp)
movq -0x10(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x8d130
cmpl $0x0, %eax
jne 0x8d0e6
movl $0x0, -0x4(%rbp)
jmp 0x8d115
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x8d105
movq -0xc8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x8d115
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)