// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3OpenTableAndIndices
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(
  Parse *pParse,   /* Parsing context */
  Table *pTab,     /* Table to be opened */
  int op,          /* OP_OpenRead or OP_OpenWrite */
  u8 p5,           /* P5 value for OP_Open* opcodes (except on WITHOUT ROWID) */
  int iBase,       /* Use this for the table cursor, if there is one */
  u8 *aToOpen,     /* If not NULL: boolean for each table and index */
  int *piDataCur,  /* Write the database source cursor number here */
  int *piIdxCur    /* Write the first index cursor number here */
){
  int i;
  int iDb;
  int iDataCur;
  Index *pIdx;
  Vdbe *v;

  assert( op==OP_OpenRead || op==OP_OpenWrite );
  assert( op==OP_OpenWrite || p5==0 );
  if( IsVirtual(pTab) ){
    /* This routine is a no-op for virtual tables. Leave the output
    ** variables *piDataCur and *piIdxCur uninitialized so that valgrind
    ** can detect if they are used by mistake in the caller. */
    return 0;
  }
  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
  v = sqlite3GetVdbe(pParse);
  assert( v!=0 );
  if( iBase<0 ) iBase = pParse->nTab;
  iDataCur = iBase++;
  if( piDataCur ) *piDataCur = iDataCur;
  if( HasRowid(pTab) && (aToOpen==0 || aToOpen[0]) ){
    sqlite3OpenTable(pParse, iDataCur, iDb, pTab, op);
  }else{
    sqlite3TableLock(pParse, iDb, pTab->tnum, op==OP_OpenWrite, pTab->zName);
  }
  if( piIdxCur ) *piIdxCur = iBase;
  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
    int iIdxCur = iBase++;
    assert( pIdx->pSchema==pTab->pSchema );
    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
      if( piDataCur ) *piDataCur = iIdxCur;
      p5 = 0;
    }
    if( aToOpen==0 || aToOpen[i+1] ){
      sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);
      sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
      sqlite3VdbeChangeP5(v, p5);
      VdbeComment((v, "%s", pIdx->zName));
    }
  }
  if( iBase>pParse->nTab ) pParse->nTab = iBase;
  return i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %r12d, %r12d
cmpl $0x0, 0x54(%rsi)
jne 0x2e0dce
movl %r8d, %r15d
movl %ecx, %r13d
movq %rdi, %r14
movl %edx, 0x4(%rsp)
movq 0x70(%rsi), %rax
testq %rax, %rax
movq %r9, 0x10(%rsp)
movq %rsi, %r12
je 0x2e0c63
movq (%r14), %rcx
movq 0x20(%rcx), %rcx
addq $0x18, %rcx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
incl %ebx
leaq 0x20(%rcx), %rdx
cmpq %rax, (%rcx)
movq %rdx, %rcx
jne 0x2e0c53
jmp 0x2e0c68
movl $0xffff8000, %ebx       # imm = 0xFFFF8000
movq %r14, %rdi
callq 0x2bc630
movq %rax, %rbp
testl %r15d, %r15d
jns 0x2e0c7c
movl 0x34(%r14), %r15d
movq %r14, 0x8(%rsp)
movq 0x60(%rsp), %rcx
testq %rcx, %rcx
movq 0x10(%rsp), %rax
je 0x2e0c93
movl %r15d, (%rcx)
movq 0x68(%rsp), %r14
testb $-0x80, 0x40(%r12)
jne 0x2e0cc3
testq %rax, %rax
je 0x2e0caa
cmpb $0x0, (%rax)
je 0x2e0cc3
movq 0x8(%rsp), %rdi
movl %r15d, %esi
movl %ebx, %edx
movq %r12, %rcx
movl 0x4(%rsp), %r8d
callq 0x2bc82f
jmp 0x2e0ce2
movl 0x38(%r12), %edx
xorl %ecx, %ecx
cmpl $0x61, 0x4(%rsp)
sete %cl
movq (%r12), %r8
movq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x2bc937
incl %r15d
testq %r14, %r14
je 0x2e0ced
movl %r15d, (%r14)
movq 0x10(%r12), %r14
testq %r14, %r14
movq 0x10(%rsp), %rsi
je 0x2e0dbc
movq %r12, 0x20(%rsp)
movl %r15d, 0x1c(%rsp)
movl %r15d, %r15d
xorl %r12d, %r12d
leaq (%r15,%r12), %rdx
movzwl 0x63(%r14), %eax
andl $0x3, %eax
cmpw $0x2, %ax
jne 0x2e0d50
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
sete %al
movq 0x20(%rsp), %rcx
testb $-0x80, 0x40(%rcx)
sete %cl
movzbl %r13b, %r13d
movl $0x0, %r8d
cmovnel %r8d, %r13d
orb %al, %cl
jne 0x2e0d50
movl %edx, (%rdi)
xorl %r13d, %r13d
testq %rsi, %rsi
je 0x2e0d5d
cmpb $0x0, 0x1(%rsi,%r12)
je 0x2e0da2
movl 0x58(%r14), %ecx
movq %rbp, %rdi
movl 0x4(%rsp), %esi
movl %ebx, %r8d
callq 0x2a83e1
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x2bca31
movq 0x10(%rsp), %rsi
movslq 0x90(%rbp), %rax
testq %rax, %rax
jle 0x2e0da2
movzbl %r13b, %ecx
movq 0x88(%rbp), %rdx
leaq (%rax,%rax,2), %rax
movw %cx, -0x16(%rdx,%rax,8)
incq %r12
movq 0x28(%r14), %r14
testq %r14, %r14
jne 0x2e0d10
movl 0x1c(%rsp), %r15d
addl %r12d, %r15d
jmp 0x2e0dbf
xorl %r12d, %r12d
movq 0x8(%rsp), %rax
cmpl 0x34(%rax), %r15d
jle 0x2e0dce
movl %r15d, 0x34(%rax)
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq