// File: /workspace/github_cpp_makefile_star2_O2/rurban[P]dgnlib/cpl_error.cpp
// Function: CPLDebug
void CPLDebug( const char * pszCategory, const char * pszFormat, ... )

{
    CPLErrorContext *psCtx = CPLGetErrorContext();
    char        *pszMessage;
    va_list     args;
    const char  *pszDebug = CPLGetConfigOption("CPL_DEBUG",NULL);

#define ERROR_MAX 25000

/* -------------------------------------------------------------------- */
/*      Does this message pass our current criteria?                    */
/* -------------------------------------------------------------------- */
    if( pszDebug == NULL )
        return;

    if( !EQUAL(pszDebug,"ON") && !EQUAL(pszDebug,"") )
    {
        int            i, nLen = strlen(pszCategory);

        for( i = 0; pszDebug[i] != '\0'; i++ )
        {
            if( EQUALN(pszCategory,pszDebug+i,nLen) )
                break;
        }

        if( pszDebug[i] == '\0' )
            return;
    }

/* -------------------------------------------------------------------- */
/*    Allocate a block for the error.                                   */
/* -------------------------------------------------------------------- */
    pszMessage = (char *) VSIMalloc( ERROR_MAX );
    if( pszMessage == NULL )
        return;
        
/* -------------------------------------------------------------------- */
/*      Dal -- always log a timestamp as the first part of the line     */
/*      to ensure one is looking at what one should be looking at!      */
/* -------------------------------------------------------------------- */

    pszMessage[0] = '\0';
#ifdef TIMESTAMP_DEBUG
    if( CPLGetConfigOption( "CPL_TIMESTAMP", NULL ) != NULL )
    {
        strcpy( pszMessage, VSICTime( VSITime(NULL) ) );
        
        // On windows anyway, ctime puts a \n at the end, but I'm not 
        // convinced this is standard behaviour, so we'll get rid of it
        // carefully

        if (pszMessage[strlen(pszMessage) -1 ] == '\n')
        {
            pszMessage[strlen(pszMessage) - 1] = 0; // blow it out
        }
        strcat( pszMessage, ": " );
    }
#endif

/* -------------------------------------------------------------------- */
/*      Add the category.                                               */
/* -------------------------------------------------------------------- */
    strcat( pszMessage, pszCategory );
    strcat( pszMessage, ": " );
    
/* -------------------------------------------------------------------- */
/*      Format the application provided portion of the debug message.   */
/* -------------------------------------------------------------------- */
    va_start(args, pszFormat);
#if defined(HAVE_VSNPRINTF)
    vsnprintf(pszMessage+strlen(pszMessage), ERROR_MAX - strlen(pszMessage), 
              pszFormat, args);
#else
    vsprintf(pszMessage+strlen(pszMessage), pszFormat, args);
#endif
    va_end(args);

/* -------------------------------------------------------------------- */
/*      Invoke the current error handler.                               */
/* -------------------------------------------------------------------- */
    if( psCtx->psHandlerStack != NULL )
    {
        psCtx->psHandlerStack->pfnHandler( CE_Debug, CPLE_None, pszMessage );
    }
    else
    {
        CPLMutexHolderD( &hErrorMutex );
        if( pfnErrorHandler != NULL )
            pfnErrorHandler( CE_Debug, CPLE_None, pszMessage );
    }

    VSIFree( pszMessage );
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf0, %rsp
movq %rsi, %rbx
movq %rdi, %r12
movq %rdx, 0x50(%rsp)
movq %rcx, 0x58(%rsp)
movq %r8, 0x60(%rsp)
movq %r9, 0x68(%rsp)
testb %al, %al
je 0x4613
movaps %xmm0, 0x70(%rsp)
movaps %xmm1, 0x80(%rsp)
movaps %xmm2, 0x90(%rsp)
movaps %xmm3, 0xa0(%rsp)
movaps %xmm4, 0xb0(%rsp)
movaps %xmm5, 0xc0(%rsp)
movaps %xmm6, 0xd0(%rsp)
movaps %xmm7, 0xe0(%rsp)
callq 0x4569
movq %rax, %r14
leaq 0x9f2c(%rip), %rdi      # 0xe54e
xorl %esi, %esi
callq 0x367f
testq %rax, %rax
je 0x47c4
movq %rax, %r15
leaq 0xa6cc(%rip), %rsi      # 0xed08
movq %rax, %rdi
callq 0x22e0
testl %eax, %eax
je 0x4685
leaq 0xa99d(%rip), %rsi      # 0xefec
movq %r15, %rdi
callq 0x22e0
testl %eax, %eax
je 0x4685
movq %r12, %rdi
callq 0x2120
movslq %eax, %r13
cmpb $0x0, (%r15)
je 0x47c4
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x23b0
incq %r15
testl %eax, %eax
jne 0x4666
movl $0x61a8, %edi           # imm = 0x61A8
callq 0x6a3f
testq %rax, %rax
je 0x47c4
movq %rax, %r15
movb $0x0, (%rax)
leaq 0x9eb3(%rip), %rdi      # 0xe558
xorl %esi, %esi
callq 0x367f
testq %rax, %rax
je 0x46f6
xorl %edi, %edi
callq 0x6a58
movq %rax, %rdi
callq 0x6a6d
movq %r15, %rdi
movq %rax, %rsi
callq 0x22a0
movq %r15, %rdi
callq 0x2120
cmpb $0xa, -0x1(%r15,%rax)
jne 0x46e1
movb $0x0, -0x1(%r15,%rax)
movq %r15, %rdi
callq 0x2120
movw $0x203a, (%r15,%rax)    # imm = 0x203A
movb $0x0, 0x2(%r15,%rax)
movq %r15, %rdi
movq %r12, %rsi
callq 0x2510
movq %r15, %rdi
callq 0x2120
movw $0x203a, (%r15,%rax)    # imm = 0x203A
movb $0x0, 0x2(%r15,%rax)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
leaq 0x20(%rsp), %r12
movq %rax, (%r12)
leaq 0x120(%rsp), %rax
movq %rax, 0x8(%r12)
leaq 0x40(%rsp), %rax
movq %rax, 0x10(%r12)
movq %r15, %rdi
callq 0x2120
movq %r15, %rdi
addq %rax, %rdi
movl $0x61a8, %esi           # imm = 0x61A8
subq %rax, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2190
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x4777
pushq $0x1
popq %rdi
xorl %esi, %esi
movq %r15, %rdx
callq *0x8(%rax)
jmp 0x47bc
leaq 0x10be2(%rip), %rsi     # 0x15360
leaq 0x9dbb(%rip), %rdx      # 0xe540
leaq 0x8(%rsp), %rdi
movsd 0x9a7e(%rip), %xmm0     # 0xe210
movl $0x15e, %ecx            # imm = 0x15E
callq 0x4c40
movq 0x10b2d(%rip), %rax     # 0x152d0
testq %rax, %rax
je 0x47b2
pushq $0x1
popq %rdi
xorl %esi, %esi
movq %r15, %rdx
callq *%rax
leaq 0x8(%rsp), %rdi
callq 0x4c42
movq %r15, %rdi
callq 0x6a49
addq $0xf0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4c42
movq %rbx, %rdi
callq 0x2500