// File: /workspace/github_cpp_makefile_star2_O3/rurban[P]dgnlib/cpl_error.cpp
// Function: CPLLoggingErrorHandler
void CPL_STDCALL CPLLoggingErrorHandler( CPLErr eErrClass, int nError, 
                             const char * pszErrorMsg )

{
    static int       bLogInit = FALSE;
    static FILE *    fpLog = stderr;

    if( !bLogInit )
    {
        const char *cpl_log = NULL;

        CPLSetConfigOption( "CPL_TIMESTAMP", "ON" );

        bLogInit = TRUE;

        cpl_log = CPLGetConfigOption("CPL_LOG", NULL );

        fpLog = stderr;
        if( cpl_log != NULL && EQUAL(cpl_log,"OFF") )
        {
            fpLog = NULL;
        }
        else if( cpl_log != NULL )
        {
            char      path[5000];
            int       i = 0;

            strcpy( path, cpl_log );

            while( (fpLog = fopen( path, "rt" )) != NULL ) 
            {
                fclose( fpLog );

                /* generate sequenced log file names, inserting # before ext.*/
                if (strrchr(cpl_log, '.') == NULL)
                {
                    sprintf( path, "%s_%d%s", cpl_log, i++,
                             ".log" );
                }
                else
                {
                    int pos = 0;
                    char *cpl_log_base = strdup(cpl_log);
                    pos = strcspn(cpl_log_base, ".");
                    if (pos > 0)
                    {
                        cpl_log_base[pos] = '\0';
                    }
                    sprintf( path, "%s_%d%s", cpl_log_base,
                             i++, ".log" );
                }
            }

            fpLog = fopen( path, "wt" );
        }
    }

    if( fpLog == NULL )
        return;

    if( eErrClass == CE_Debug )
        fprintf( fpLog, "%s\n", pszErrorMsg );
    else if( eErrClass == CE_Warning )
        fprintf( fpLog, "Warning %d: %s\n", nError, pszErrorMsg );
    else
        fprintf( fpLog, "ERROR %d: %s\n", nError, pszErrorMsg );

    fflush( fpLog );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1398, %rsp           # imm = 0x1398
movq %rdx, %rbx
movl %esi, %ebp
movl %edi, %r14d
movb 0x107ab(%rip), %al      # 0x15390
testb %al, %al
je 0x4dcc
cmpb $0x0, 0x1078c(%rip)     # 0x15380
je 0x4c02
movq 0x1078b(%rip), %rdi     # 0x15388
jmp 0x4d61
leaq 0xa94f(%rip), %rdi      # 0xf558
leaq 0xb0f8(%rip), %rsi      # 0xfd08
callq 0x38fb
movb $0x1, 0x10764(%rip)     # 0x15380
leaq 0xa946(%rip), %rdi      # 0xf569
xorl %esi, %esi
callq 0x3872
movq %rax, %r15
movq 0x103ac(%rip), %rax     # 0x14fe0
movq (%rax), %rdi
movq %rdi, 0x1074a(%rip)     # 0x15388
testq %r15, %r15
je 0x4d61
leaq 0xa944(%rip), %rsi      # 0xf592
movq %r15, %rdi
callq 0x22e0
testl %eax, %eax
je 0x4dbf
movl %r14d, (%rsp)
movl %ebp, 0x4(%rsp)
movq %rbx, 0x8(%rsp)
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x22a0
leaq 0xa473(%rip), %rsi      # 0xf0f5
movq %rbx, %rdi
callq 0x2340
movq %rax, 0x106f7(%rip)     # 0x15388
testq %rax, %rax
je 0x4d39
leaq 0xa8fd(%rip), %r13      # 0xf59e
leaq 0x10(%rsp), %rbp
leaq 0xa448(%rip), %rbx      # 0xf0f5
xorl %r14d, %r14d
movq %rax, %rdi
callq 0x22d0
movq %r15, %rdi
movl $0x2e, %esi
callq 0x22f0
testq %rax, %rax
je 0x4d01
movq %r15, %rdi
callq 0x2530
movq %rax, %r12
movq %rax, %rdi
leaq 0xc151(%rip), %rsi      # 0x10e30
callq 0x2070
testl %eax, %eax
jle 0x4cf2
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, (%r12,%rax)
movq %rbp, %rdi
leaq 0xa89a(%rip), %rsi      # 0xf596
movq %r12, %rdx
jmp 0x4d0e
movq %rbp, %rdi
leaq 0xa88b(%rip), %rsi      # 0xf596
movq %r15, %rdx
movl %r14d, %ecx
movq %r13, %r8
xorl %eax, %eax
callq 0x20a0
incl %r14d
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2340
movq %rax, 0x10658(%rip)     # 0x15388
testq %rax, %rax
jne 0x4cb0
leaq 0xa831(%rip), %rsi      # 0xf571
leaq 0x10(%rsp), %rdi
callq 0x2340
movq %rax, %rdi
movq %rax, 0x10634(%rip)     # 0x15388
movq 0x8(%rsp), %rbx
movl 0x4(%rsp), %ebp
movl (%rsp), %r14d
testq %rdi, %rdi
je 0x4dad
cmpl $0x2, %r14d
je 0x4d85
cmpl $0x1, %r14d
jne 0x4d8e
leaq 0xa815(%rip), %rsi      # 0xf58e
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2410
jmp 0x4da1
leaq 0xa7e8(%rip), %rsi      # 0xf574
jmp 0x4d95
leaq 0xa7ef(%rip), %rsi      # 0xf584
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2410
movq 0x105e0(%rip), %rdi     # 0x15388
callq 0x2330
addq $0x1398, %rsp           # imm = 0x1398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x0, 0x105be(%rip) # 0x15388
jmp 0x4dad
callq 0x25b1
jmp 0x4bed