// File: /workspace/github_cpp_makefile_star2_O2/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 $0x98, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %rsi
callq 0x6a53
testl %eax, %eax
je 0x41ad
leaq 0xa2fc(%rip), %rdx      # 0xe47e
pushq $0x3
popq %rdi
pushq $0x1
popq %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x439c
callq 0x2040
movl (%rax), %ebp
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpw $0x4000, %ax            # imm = 0x4000
je 0x41d4
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x4255
movq %rbx, %rdi
callq 0x6921
jmp 0x4287
movq %rbx, %rdi
callq 0x4340
movq %rax, (%rsp)
testq %rax, %rax
je 0x4276
leaq 0xbc50(%rip), %r15      # 0xfe40
leaq 0xa2d2(%rip), %r12      # 0xe4c9
movq (%rsp), %r14
movq (%r14), %r13
testq %r13, %r13
je 0x4276
movq %r13, %rdi
movq %r15, %rsi
callq 0x22e0
testl %eax, %eax
je 0x424f
movq %r13, %rdi
movq %r12, %rsi
callq 0x22e0
testl %eax, %eax
je 0x424f
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x5112
movq %rax, %rdi
callq 0x2d77
movq %rax, %r13
movq %rax, %rdi
callq 0x4159
movl %eax, %ebp
movq %r13, %rdi
callq 0x6a49
testl %ebp, %ebp
jne 0x42c3
addq $0x8, %r14
jmp 0x41fb
leaq 0xa270(%rip), %rdx      # 0xe4cc
pushq $0x3
popq %rdi
pushq $0x1
popq %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x439c
movl $0x3e8, %ebp            # imm = 0x3E8
jmp 0x4199
movq (%rsp), %rdi
callq 0x5585
movq %rbx, %rdi
callq 0x692b
testl %eax, %eax
je 0x42bc
callq 0x2040
movq %rax, %r14
movl (%rax), %edi
callq 0x6ad6
leaq 0xa210(%rip), %rdx      # 0xe4b1
pushq $0x3
popq %rdi
pushq $0x1
popq %rsi
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x439c
movl (%r14), %ebp
jmp 0x4199
xorl %ebp, %ebp
jmp 0x4199
movq (%rsp), %rdi
callq 0x5585
jmp 0x4199
nop