// File: rurban[P]dgnlib/cpl_path.cpp
// Function: CPLFormCIFilename
const char *CPLFormCIFilename( const char * pszPath,
                               const char * pszBasename,
                               const char * pszExtension )

{
#ifdef WIN32
    return CPLFormFilename( pszPath, pszBasename, pszExtension );
#else
    const char  *pszAddedExtSep = "";
    char        *pszFilename;
    const char  *pszFullPath;
    int         nLen = strlen(pszBasename)+2, i;
    FILE        *fp;

    if( pszExtension != NULL )
        nLen += strlen(pszExtension);

    pszFilename = (char *) CPLMalloc(nLen);

    if( pszExtension == NULL )
        pszExtension = "";
    else if( pszExtension[0] != '.' && strlen(pszExtension) > 0 )
        pszAddedExtSep = ".";

    sprintf( pszFilename, "%s%s%s", 
             pszBasename, pszAddedExtSep, pszExtension );

    pszFullPath = CPLFormFilename( pszPath, pszFilename, NULL );
    fp = VSIFOpen( pszFullPath, "r" );
    if( fp == NULL )
    {
        for( i = 0; pszFilename[i] != '\0'; i++ )
        {
            if( islower(pszFilename[i]) )
                pszFilename[i] = toupper(pszFilename[i]);
        }

        pszFullPath = CPLFormFilename( pszPath, pszFilename, NULL );
        fp = VSIFOpen( pszFullPath, "r" );
    }

    if( fp == NULL )
    {
        for( i = 0; pszFilename[i] != '\0'; i++ )
        {
            if( isupper(pszFilename[i]) )
                pszFilename[i] = tolower(pszFilename[i]);
        }

        pszFullPath = CPLFormFilename( pszPath, pszFilename, NULL );
        fp = VSIFOpen( pszFullPath, "r" );
    }

    if( fp != NULL )
        VSIFClose( fp );
    else
        pszFullPath = CPLFormFilename( pszPath, pszBasename, pszExtension );

    CPLFree( pszFilename );

    return pszFullPath;
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0x12e79(%rip), %rax     # 0x19c84
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2120
addq $0x2, %rax
movl %eax, -0x34(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x6e3c
movq -0x18(%rbp), %rdi
callq 0x2120
movq %rax, %rcx
movslq -0x34(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x34(%rbp)
movslq -0x34(%rbp), %rdi
callq 0x3040
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6e5d
leaq 0x12e2d(%rip), %rax     # 0x19c84
movq %rax, -0x18(%rbp)
jmp 0x6e85
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
je 0x6e83
movq -0x18(%rbp), %rdi
callq 0x2120
cmpq $0x0, %rax
jbe 0x6e83
leaq 0x13b71(%rip), %rax     # 0x1a9f0
movq %rax, -0x20(%rbp)
jmp 0x6e85
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %r8
leaq 0x127d1(%rip), %rsi     # 0x1966d
movb $0x0, %al
callq 0x20a0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x6c90
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x12148(%rip), %rsi     # 0x1900b
callq 0x9c80
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x6f59
movl $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x6f30
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x23d0
cmpl $0x0, %eax
je 0x6f23
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x2530
movb %al, %dl
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x6f25
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x6ede
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x6c90
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x120bb(%rip), %rsi     # 0x1900b
callq 0x9c80
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x6fe6
movl $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x6fbd
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x2200
cmpl $0x0, %eax
je 0x6fb0
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x2420
movb %al, %dl
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x6fb2
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x6f6b
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x6c90
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x1202e(%rip), %rsi     # 0x1900b
callq 0x9c80
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x6ff8
movq -0x40(%rbp), %rdi
callq 0x9cb0
jmp 0x700d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x6c90
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0xa000
movq -0x30(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq