// File: rurban[P]dgnlib/cpl_conv.cpp
// Function: CPLOpenShared
FILE *CPLOpenShared( const char *pszFilename, const char *pszAccess,
                     int bLarge )

{
    int i;
    int bReuse;
    CPLMutexHolderD( &hSharedFileMutex );

/* -------------------------------------------------------------------- */
/*      Is there an existing file we can use?                           */
/* -------------------------------------------------------------------- */
    bReuse = EQUAL(pszAccess,"rb") || EQUAL(pszAccess, "rb+");

    for( i = 0; bReuse && i < nSharedFileCount; i++ )
    {
        if( strcmp(pasSharedFileList[i].pszFilename,pszFilename) == 0 
            && !bLarge == !pasSharedFileList[i].bLarge
            && EQUAL(pasSharedFileList[i].pszAccess,pszAccess) )
        {
            pasSharedFileList[i].nRefCount++;
            return pasSharedFileList[i].fp;
        }
    }

/* -------------------------------------------------------------------- */
/*      Open the file.                                                  */
/* -------------------------------------------------------------------- */
    FILE *fp;

    if( bLarge )
        fp = VSIFOpenL( pszFilename, pszAccess );
    else
        fp = VSIFOpen( pszFilename, pszAccess );

    if( fp == NULL )
        return NULL;

/* -------------------------------------------------------------------- */
/*      Add an entry to the list.                                       */
/* -------------------------------------------------------------------- */
    nSharedFileCount++;

    pasSharedFileList = (CPLSharedFileInfo *)
        CPLRealloc( (void *) pasSharedFileList, 
                    sizeof(CPLSharedFileInfo) * nSharedFileCount );

    pasSharedFileList[nSharedFileCount-1].fp = fp;
    pasSharedFileList[nSharedFileCount-1].nRefCount = 1;
    pasSharedFileList[nSharedFileCount-1].bLarge = bLarge;
    pasSharedFileList[nSharedFileCount-1].pszFilename =CPLStrdup(pszFilename);
    pasSharedFileList[nSharedFileCount-1].pszAccess = CPLStrdup(pszAccess);

    return fp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq -0x40(%rbp), %rdi
leaq 0x1a9c7(%rip), %rsi     # 0x1f648
movsd 0x14597(%rip), %xmm0    # 0x19220
leaq 0x1476b(%rip), %rdx     # 0x193fb
movl $0x728, %ecx            # imm = 0x728
callq 0x6370
movq -0x18(%rbp), %rdi
leaq 0x1477c(%rip), %rsi     # 0x19421
callq 0x2300
movl %eax, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x5d(%rbp)
je 0x4ccf
movq -0x18(%rbp), %rdi
leaq 0x14763(%rip), %rsi     # 0x19424
callq 0x2300
cmpl $0x0, %eax
sete %al
movb %al, -0x5d(%rbp)
movb -0x5d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x24(%rbp)
movb %al, -0x5e(%rbp)
je 0x4cfd
movl -0x20(%rbp), %eax
movl 0x1a95b(%rip), %ecx     # 0x1f650
cmpl %ecx, %eax
setl %al
movb %al, -0x5e(%rbp)
movb -0x5e(%rbp), %al
testb $0x1, %al
jne 0x4d09
jmp 0x4ddb
movq 0x1a948(%rip), %rax     # 0x1f658
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x2400
cmpl $0x0, %eax
jne 0x4dcb
cmpl $0x0, -0x1c(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movq 0x1a912(%rip), %rcx     # 0x1f658
movslq -0x20(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
cmpl $0x0, %ecx
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x4dcb
movq 0x1a8ea(%rip), %rax     # 0x1f658
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x2300
cmpl $0x0, %eax
jne 0x4dcb
movq 0x1a8c6(%rip), %rax     # 0x1f658
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movq 0x1a8ab(%rip), %rax     # 0x1f658
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x44(%rbp)
jmp 0x4f51
jmp 0x4dcd
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4ce1
cmpl $0x0, -0x1c(%rbp)
je 0x4e18
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9af0
movq %rax, -0x68(%rbp)
jmp 0x4df4
movq -0x68(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x4e33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x6390
jmp 0x4f67
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9c80
movq %rax, -0x70(%rbp)
jmp 0x4e2b
movq -0x70(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x4e4e
movq $0x0, -0x8(%rbp)
movl $0x1, -0x44(%rbp)
jmp 0x4f51
movl 0x1a7fc(%rip), %eax     # 0x1f650
incl %eax
movl %eax, 0x1a7f4(%rip)     # 0x1f650
movq 0x1a7f5(%rip), %rdi     # 0x1f658
movslq 0x1a7e6(%rip), %rsi     # 0x1f650
shlq $0x5, %rsi
callq 0x3120
movq %rax, -0x78(%rbp)
jmp 0x4e79
movq -0x78(%rbp), %rax
movq %rax, 0x1a7d4(%rip)     # 0x1f658
movq -0x50(%rbp), %rdx
movq 0x1a7c9(%rip), %rax     # 0x1f658
movl 0x1a7bb(%rip), %ecx     # 0x1f650
decl %ecx
movslq %ecx, %rcx
shlq $0x5, %rcx
movq %rdx, (%rax,%rcx)
movq 0x1a7af(%rip), %rax     # 0x1f658
movl 0x1a7a1(%rip), %ecx     # 0x1f650
decl %ecx
movslq %ecx, %rcx
shlq $0x5, %rcx
movl $0x1, 0x8(%rax,%rcx)
movl -0x1c(%rbp), %edx
movq 0x1a78e(%rip), %rax     # 0x1f658
movl 0x1a780(%rip), %ecx     # 0x1f650
decl %ecx
movslq %ecx, %rcx
shlq $0x5, %rcx
movl %edx, 0xc(%rax,%rcx)
movq -0x10(%rbp), %rdi
callq 0x31e0
movq %rax, -0x80(%rbp)
jmp 0x4eec
movq -0x80(%rbp), %rdx
movq 0x1a761(%rip), %rax     # 0x1f658
movl 0x1a753(%rip), %ecx     # 0x1f650
decl %ecx
movslq %ecx, %rcx
shlq $0x5, %rcx
movq %rdx, 0x10(%rax,%rcx)
movq -0x18(%rbp), %rdi
callq 0x31e0
movq %rax, -0x88(%rbp)
jmp 0x4f1d
movq -0x88(%rbp), %rcx
movq 0x1a72d(%rip), %rax     # 0x1f658
movl 0x1a71f(%rip), %edx     # 0x1f650
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x44(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x6390
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x24f0