// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3FindTable
SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
  Table *p = 0;
  int i;

  /* All mutexes are required for schema access.  Make sure we hold them. */
  assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) );
#if SQLITE_USER_AUTHENTICATION
  /* Only the admin user is allowed to know that the sqlite_user table
  ** exists */
  if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){
    return 0;
  }
#endif
  if( zDatabase ){
    for(i=0; i<db->nDb; i++){
      if( sqlite3StrICmp(zDatabase, db->aDb[i].zDbSName)==0 ) break;
    }
    if( i>=db->nDb ){
      /* No match against the official names.  But always match "main"
      ** to schema 0 as a legacy fallback. */
      if( sqlite3StrICmp(zDatabase,"main")==0 ){
        i = 0;
      }else{
        return 0;
      }
    }
    p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, zName);
    if( p==0 && sqlite3StrNICmp(zName, "sqlite_", 7)==0 ){
      if( i==1 ){
        if( sqlite3StrICmp(zName+7, &ALT_TEMP_SCHEMA_TABLE[7])==0
         || sqlite3StrICmp(zName+7, &ALT_SCHEMA_TABLE[7])==0
         || sqlite3StrICmp(zName+7, &DFLT_SCHEMA_TABLE[7])==0
        ){
          p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash,
                              DFLT_TEMP_SCHEMA_TABLE);
        }
      }else{
        if( sqlite3StrICmp(zName+7, &ALT_SCHEMA_TABLE[7])==0 ){
          p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash,
                              DFLT_SCHEMA_TABLE);
        }
      }
    }
  }else{
    /* Match against TEMP first */
    p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash, zName);
    if( p ) return p;
    /* The main database is second */
    p = sqlite3HashFind(&db->aDb[0].pSchema->tblHash, zName);
    if( p ) return p;
    /* Attached databases are in order of attachment */
    for(i=2; i<db->nDb; i++){
      assert( sqlite3SchemaMutexHeld(db, i, 0) );
      p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, zName);
      if( p ) break;
    }
    if( p==0 && sqlite3StrNICmp(zName, "sqlite_", 7)==0 ){
      if( sqlite3StrICmp(zName+7, &ALT_SCHEMA_TABLE[7])==0 ){
        p = sqlite3HashFind(&db->aDb[0].pSchema->tblHash, DFLT_SCHEMA_TABLE);
      }else if( sqlite3StrICmp(zName+7, &ALT_TEMP_SCHEMA_TABLE[7])==0 ){
        p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash,
                            DFLT_TEMP_SCHEMA_TABLE);
      }
    }
  }
  return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
testq %rdx, %rdx
je 0x22bf09
movq %rdx, %r12
movq %r14, (%rsp)
movl 0x28(%rbx), %r13d
xorl %ebp, %ebp
testl %r13d, %r13d
cmovlel %ebp, %r13d
xorl %r15d, %r15d
cmpq %r15, %r13
je 0x22bf79
movq 0x20(%rbx), %r14
movq (%r14,%rbp), %rsi
movq %r12, %rdi
callq 0x221779
testl %eax, %eax
je 0x22bf99
incq %r15
addq $0x20, %rbp
jmp 0x22bedf
movq 0x20(%rbx), %rax
movq 0x38(%rax), %rdi
addq $0x8, %rdi
movq %r14, %rsi
callq 0x24a8e6
testq %rax, %rax
jne 0x22bfbd
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdi
addq $0x8, %rdi
movq %r14, %rsi
callq 0x24a8e6
testq %rax, %rax
jne 0x22bfbd
pushq $0x58
popq %r12
pushq $0x1
popq %r13
movslq 0x28(%rbx), %rax
incq %r13
cmpq %rax, %r13
jge 0x22c04d
movq 0x20(%rbx), %rax
movq (%rax,%r12), %rdi
addq $0x20, %r12
addq $0x8, %rdi
movq %r14, %rsi
callq 0x24a8e6
movq %rax, %r15
testq %rax, %rax
je 0x22bf47
jmp 0x22bfc0
leaq 0xcef9f(%rip), %rsi     # 0x2faf1f
movq %r12, %rdi
callq 0x221779
xorl %r15d, %r15d
testl %eax, %eax
movq (%rsp), %rbp
jne 0x22bfc0
movq 0x20(%rbx), %r14
jmp 0x22bf9d
movq (%rsp), %rbp
movl %r15d, %r13d
movq %r13, %r12
shlq $0x5, %r12
movq 0x18(%r14,%r12), %rdi
addq $0x8, %rdi
movq %rbp, %rsi
callq 0x24a8e6
testq %rax, %rax
je 0x22bfd2
movq %rax, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14bc1a(%rip), %rsi    # 0x377bf3
pushq $0x7
popq %rdx
movq %rbp, %rdi
callq 0x2217ad
testl %eax, %eax
je 0x22bfed
xorl %r15d, %r15d
jmp 0x22bfc0
addq $0x7, %rbp
cmpl $0x1, %r13d
jne 0x22c02d
leaq 0x14ea16(%rip), %rsi    # 0x37aa14
movq %rbp, %rdi
callq 0x221779
testl %eax, %eax
je 0x22c091
leaq 0x14ea12(%rip), %rsi    # 0x37aa27
movq %rbp, %rdi
callq 0x221779
testl %eax, %eax
je 0x22c091
leaq 0x14a932(%rip), %rsi    # 0x37695a
movq %rbp, %rdi
jmp 0x22c084
leaq 0x14e9f3(%rip), %rsi    # 0x37aa27
movq %rbp, %rdi
callq 0x221779
testl %eax, %eax
jne 0x22bfe8
movq 0x20(%rbx), %rax
addq %r12, %rax
addq $0x18, %rax
jmp 0x22c0aa
leaq 0x14bb9f(%rip), %rsi    # 0x377bf3
pushq $0x7
popq %rdx
movq %r14, %rdi
callq 0x2217ad
testl %eax, %eax
jne 0x22bfe8
addq $0x7, %r14
leaq 0x14e9b9(%rip), %rsi    # 0x37aa27
movq %r14, %rdi
callq 0x221779
testl %eax, %eax
je 0x22c0a2
leaq 0x14e993(%rip), %rsi    # 0x37aa14
movq %r14, %rdi
callq 0x221779
testl %eax, %eax
jne 0x22bfe8
movq 0x20(%rbx), %rax
addq $0x38, %rax
leaq 0x14a994(%rip), %rsi    # 0x376a34
jmp 0x22c0b1
movq 0x20(%rbx), %rax
addq $0x18, %rax
leaq 0x14a8a2(%rip), %rsi    # 0x376953
movq (%rax), %rdi
addq $0x8, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x24a8e6