// File: /workspace/github_cpp_makefile_star2_O1/rurban[P]dgnlib/cpl_conv.cpp
// Function: CPLUnlinkTree
int CPLUnlinkTree( const char *pszPath )

{
/* -------------------------------------------------------------------- */
/*      First, ensure there isn't any such file yet.                    */
/* -------------------------------------------------------------------- */
    VSIStatBuf sStatBuf;

    if( VSIStat( pszPath, &sStatBuf ) != 0 )
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "It seems no file system object called '%s' exists.",
                  pszPath );

        return errno;
    }

/* -------------------------------------------------------------------- */
/*      If it's a simple file, just delete it.                          */
/* -------------------------------------------------------------------- */
    if( VSI_ISREG( sStatBuf.st_mode ) )
    {
        if( VSIUnlink( pszPath ) != 0 )
        {
            CPLError( CE_Failure, CPLE_AppDefined, 
                      "Failed to unlink %s.\n%s", 
                      pszPath, VSIStrerror( errno ) );
            return errno;
        }
        else
            return 0;
    }

/* -------------------------------------------------------------------- */
/*      If it is a directory recurse then unlink the directory.         */
/* -------------------------------------------------------------------- */
    else if( VSI_ISDIR( sStatBuf.st_mode ) )
    {
        char **papszItems = CPLReadDir( pszPath );
        int  i;

        for( i = 0; papszItems != NULL && papszItems[i] != NULL; i++ )
        {
            char *pszSubPath;
            int nErr;

            if( EQUAL(papszItems[i],".") || EQUAL(papszItems[i],"..") )
                continue;

            pszSubPath = CPLStrdup(
                CPLFormFilename( pszPath, papszItems[i], NULL ) );

            nErr = CPLUnlinkTree( pszSubPath );
            CPLFree( pszSubPath );

            if( nErr != 0 )
            {
                CSLDestroy( papszItems );
                return nErr;
            }
        }
        
        CSLDestroy( papszItems );

        if( VSIRmdir( pszPath ) != 0 )
        {
            CPLError( CE_Failure, CPLE_AppDefined, 
                      "Failed to unlink %s.\n%s", 
                      pszPath, VSIStrerror( errno ) );
            return errno;
        }
        else
            return 0;
    }

/* -------------------------------------------------------------------- */
/*      otherwise report an error.                                      */
/* -------------------------------------------------------------------- */
    else
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "Failed to unlink %s.\nUnrecognised filesystem object.",
                  pszPath );
        return 1000;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
leaq 0x18(%rsp), %rsi
callq 0x702c
testl %eax, %eax
je 0x44a2
leaq 0xbfe9(%rip), %rdx      # 0x1045e
movl $0x3, %edi
movl $0x1, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x46dc
callq 0x2040
movl (%rax), %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xf000, %eax           # imm = 0xF000
andl 0x30(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x44ca
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x45d4
movq %rbx, %rdi
callq 0x6ef5
jmp 0x459b
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0x4678
movq %rax, %r12
testq %rax, %rax
je 0x4586
leaq 0xd886(%rip), %rbp      # 0x11d70
movq %r12, %r14
movq (%r14), %r13
testq %r13, %r13
je 0x4586
movq %r13, %rdi
movq %rbp, %rsi
callq 0x22f0
movl $0x4, %r15d
testl %eax, %eax
je 0x456f
movq %r13, %rdi
leaq 0xbf91(%rip), %rsi      # 0x104a9
callq 0x22f0
testl %eax, %eax
je 0x456f
xorl %r15d, %r15d
movq 0x10(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x54b6
movq %rax, %rdi
callq 0x2e6c
movq %r12, %rbx
movq %rax, %r12
movq %rax, %rdi
callq 0x444c
movl %eax, %r13d
movq %r12, %rdi
movq %rbx, %r12
callq 0x701d
testl %r13d, %r13d
je 0x456f
movq %r12, %rdi
callq 0x596e
movl $0x1, %r15d
movl %r13d, 0xc(%rsp)
testb $0x3, %r15b
jne 0x4600
addq $0x8, %r14
testq %r12, %r12
jne 0x44ed
movq %r12, %rdi
callq 0x596e
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x6eff
testl %eax, %eax
je 0x45f9
callq 0x2040
movq %rax, %r14
movl (%rax), %edi
callq 0x70af
leaq 0xbedc(%rip), %rdx      # 0x10491
movl $0x3, %edi
movl $0x1, %esi
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x46dc
movl (%r14), %eax
jmp 0x4490
leaq 0xbed1(%rip), %rdx      # 0x104ac
movl $0x3, %edi
movl $0x1, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x46dc
movl $0x3e8, %eax            # imm = 0x3E8
jmp 0x4490
xorl %eax, %eax
jmp 0x4490
movl 0xc(%rsp), %eax
jmp 0x4490
nop