// File: /workspace/github_cpp_makefile_star2_O2/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 0x10a31(%rip), %al      # 0x15390
testb %al, %al
je 0x4b1a
cmpb $0x0, 0x10a12(%rip)     # 0x15380
je 0x497c
movq 0x10a11(%rip), %rdi     # 0x15388
jmp 0x4ab2
leaq 0x9bd5(%rip), %rdi      # 0xe558
leaq 0xa37e(%rip), %rsi      # 0xed08
callq 0x3708
movb $0x1, 0x109ea(%rip)     # 0x15380
leaq 0x9bcc(%rip), %rdi      # 0xe569
xorl %esi, %esi
callq 0x367f
movq %rax, %r15
movq 0x10632(%rip), %rax     # 0x14fe0
movq (%rax), %rdi
movq %rdi, 0x109d0(%rip)     # 0x15388
testq %r15, %r15
je 0x4ab2
leaq 0x9bca(%rip), %rsi      # 0xe592
movq %r15, %rdi
callq 0x22e0
testl %eax, %eax
je 0x4b10
movl %r14d, (%rsp)
movl %ebp, 0x4(%rsp)
movq %rbx, 0x8(%rsp)
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x22a0
leaq 0x96f9(%rip), %r13      # 0xe0f5
leaq 0x9b9b(%rip), %r14      # 0xe59e
xorl %ebp, %ebp
movq %r12, %rdi
movq %r13, %rsi
callq 0x2340
movq %rax, 0x10971(%rip)     # 0x15388
testq %rax, %rax
je 0x4a8a
movq %rax, %rdi
callq 0x22d0
movq %r15, %rdi
pushq $0x2e
popq %rsi
callq 0x22f0
testq %rax, %rax
je 0x4a6a
movq %r15, %rdi
callq 0x2530
movq %rax, %rbx
movq %rax, %rdi
leaq 0xb3f7(%rip), %rsi      # 0xfe40
callq 0x2070
testl %eax, %eax
jle 0x4a5b
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, (%rbx,%rax)
movq %r12, %rdi
leaq 0x9b31(%rip), %rsi      # 0xe596
movq %rbx, %rdx
jmp 0x4a77
movq %r12, %rdi
leaq 0x9b22(%rip), %rsi      # 0xe596
movq %r15, %rdx
movl %ebp, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x20a0
incl %ebp
jmp 0x4a05
leaq 0x9ae0(%rip), %rsi      # 0xe571
leaq 0x10(%rsp), %rdi
callq 0x2340
movq %rax, %rdi
movq %rax, 0x108e3(%rip)     # 0x15388
movq 0x8(%rsp), %rbx
movl 0x4(%rsp), %ebp
movl (%rsp), %r14d
testq %rdi, %rdi
je 0x4afe
cmpl $0x2, %r14d
je 0x4ad6
cmpl $0x1, %r14d
jne 0x4adf
leaq 0x9ac4(%rip), %rsi      # 0xe58e
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2410
jmp 0x4af2
leaq 0x9a97(%rip), %rsi      # 0xe574
jmp 0x4ae6
leaq 0x9a9e(%rip), %rsi      # 0xe584
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2410
movq 0x1088f(%rip), %rdi     # 0x15388
callq 0x2330
addq $0x1398, %rsp           # imm = 0x1398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
andq $0x0, 0x10870(%rip)     # 0x15388
jmp 0x4afe
leaq 0x1086f(%rip), %rdi     # 0x15390
callq 0x2520
testl %eax, %eax
je 0x4967
movq 0x104ab(%rip), %rax     # 0x14fe0
movq (%rax), %rax
movq %rax, 0x10849(%rip)     # 0x15388
leaq 0x1084a(%rip), %rdi     # 0x15390
callq 0x21a0
jmp 0x4967