// File: /workspace/github_cpp_makefile_star2_O3/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, %r15
movq %rdx, 0x50(%rsp)
movq %rcx, 0x58(%rsp)
movq %r8, 0x60(%rsp)
movq %r9, 0x68(%rsp)
testb %al, %al
je 0x48af
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 0x47fa
movq %rax, %r14
leaq 0xac90(%rip), %rdi      # 0xf54e
xorl %esi, %esi
callq 0x3872
testq %rax, %rax
je 0x4a71
movq %rax, %r12
leaq 0xb430(%rip), %rsi      # 0xfd08
movq %rax, %rdi
callq 0x22e0
testl %eax, %eax
je 0x4931
leaq 0xb701(%rip), %rsi      # 0xffec
movq %r12, %rdi
callq 0x22e0
testl %eax, %eax
je 0x4931
cmpb $0x0, (%r12)
je 0x4a71
movq %r15, %rdi
callq 0x2120
movslq %eax, %r13
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x23b0
testl %eax, %eax
je 0x4931
cmpb $0x0, 0x1(%r12)
leaq 0x1(%r12), %r12
jne 0x490d
jmp 0x4a71
movl $0x61a8, %edi           # imm = 0x61A8
callq 0x6ed3
testq %rax, %rax
je 0x4a71
movq %rax, %r12
movb $0x0, (%rax)
leaq 0xac07(%rip), %rdi      # 0xf558
xorl %esi, %esi
callq 0x3872
testq %rax, %rax
je 0x49a2
xorl %edi, %edi
callq 0x6ef1
movq %rax, %rdi
callq 0x6f06
movq %r12, %rdi
movq %rax, %rsi
callq 0x22a0
movq %r12, %rdi
callq 0x2120
cmpb $0xa, -0x1(%r12,%rax)
jne 0x498d
movb $0x0, -0x1(%r12,%rax)
movq %r12, %rdi
callq 0x2120
movw $0x203a, (%r12,%rax)    # imm = 0x203A
movb $0x0, 0x2(%r12,%rax)
movq %r12, %rdi
movq %r15, %rsi
callq 0x2510
movq %r12, %rdi
callq 0x2120
movw $0x203a, (%r12,%rax)    # imm = 0x203A
movb $0x0, 0x2(%r12,%rax)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
leaq 0x20(%rsp), %r15
movq %rax, (%r15)
leaq 0x120(%rsp), %rax
movq %rax, 0x8(%r15)
leaq 0x40(%rsp), %rax
movq %rax, 0x10(%r15)
movq %r12, %rdi
callq 0x2120
movq %r12, %rdi
addq %rax, %rdi
movl $0x61a8, %esi           # imm = 0x61A8
subq %rax, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2190
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x4a22
movl $0x1, %edi
xorl %esi, %esi
movq %r12, %rdx
callq *0x8(%rax)
jmp 0x4a69
leaq 0x10937(%rip), %rsi     # 0x15360
leaq 0xab10(%rip), %rdx      # 0xf540
leaq 0x8(%rsp), %rdi
movsd 0xa7d3(%rip), %xmm0     # 0xf210
movl $0x15e, %ecx            # imm = 0x15E
callq 0x4ecc
movq 0x10882(%rip), %rax     # 0x152d0
testq %rax, %rax
je 0x4a5f
movl $0x1, %edi
xorl %esi, %esi
movq %r12, %rdx
callq *%rax
leaq 0x8(%rsp), %rdi
callq 0x4ece
movq %r12, %rdi
callq 0x6edd
addq $0xf0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4ece
movq %rbx, %rdi
callq 0x2500