// File: /workspace/github_cpp_makefile_star2_O1/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 0x116f2(%rip), %al      # 0x16390
testb %al, %al
je 0x4e81
cmpb $0x0, 0x116d3(%rip)     # 0x16380
jne 0x4e1c
leaq 0xb87e(%rip), %rdi      # 0x10538
leaq 0xc00f(%rip), %rsi      # 0x10cd0
callq 0x3970
movb $0x1, 0x116b3(%rip)     # 0x16380
leaq 0xb875(%rip), %rdi      # 0x10549
xorl %esi, %esi
callq 0x38e7
movq %rax, %r15
movq 0x112fb(%rip), %rax     # 0x15fe0
movq (%rax), %rax
movq %rax, 0x11699(%rip)     # 0x16388
testq %r15, %r15
je 0x4e1c
leaq 0xb873(%rip), %rsi      # 0x10572
movq %r15, %rdi
callq 0x22f0
testl %eax, %eax
je 0x4e11
movl %r14d, (%rsp)
movl %ebp, 0x4(%rsp)
movq %rbx, 0x8(%rsp)
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x22b0
leaq 0xb3cb(%rip), %rsi      # 0x100fe
movq %rbx, %rdi
callq 0x2350
movq %rax, 0x11646(%rip)     # 0x16388
testq %rax, %rax
je 0x4dea
leaq 0xb82c(%rip), %r13      # 0x1057e
leaq 0x10(%rsp), %rbp
leaq 0xb3a0(%rip), %rbx      # 0x100fe
xorl %r14d, %r14d
movq %rax, %rdi
callq 0x22e0
movq %r15, %rdi
movl $0x2e, %esi
callq 0x2300
testq %rax, %rax
je 0x4db2
movq %r15, %rdi
callq 0x2540
movq %rax, %r12
movq %rax, %rdi
leaq 0xcfe0(%rip), %rsi      # 0x11d70
callq 0x2070
testl %eax, %eax
jle 0x4da3
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, (%r12,%rax)
movq %rbp, %rdi
leaq 0xb7c9(%rip), %rsi      # 0x10576
movq %r12, %rdx
jmp 0x4dbf
movq %rbp, %rdi
leaq 0xb7ba(%rip), %rsi      # 0x10576
movq %r15, %rdx
movl %r14d, %ecx
movq %r13, %r8
xorl %eax, %eax
callq 0x20a0
incl %r14d
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2350
movq %rax, 0x115a7(%rip)     # 0x16388
testq %rax, %rax
jne 0x4d61
leaq 0xb760(%rip), %rsi      # 0x10551
leaq 0x10(%rsp), %rdi
callq 0x2350
movq %rax, 0x11586(%rip)     # 0x16388
movq 0x8(%rsp), %rbx
movl 0x4(%rsp), %ebp
movl (%rsp), %r14d
jmp 0x4e1c
movq $0x0, 0x1156c(%rip) # 0x16388
movq 0x11565(%rip), %rdi     # 0x16388
testq %rdi, %rdi
je 0x4e6f
cmpl $0x2, %r14d
je 0x4e47
cmpl $0x1, %r14d
jne 0x4e50
leaq 0xb733(%rip), %rsi      # 0x1056e
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2420
jmp 0x4e63
leaq 0xb706(%rip), %rsi      # 0x10554
jmp 0x4e57
leaq 0xb70d(%rip), %rsi      # 0x10564
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2420
movq 0x1151e(%rip), %rdi     # 0x16388
callq 0x2340
addq $0x1398, %rsp           # imm = 0x1398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x25c1
jmp 0x4ca6