// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3ComputeGeneratedColumns
SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns(
  Parse *pParse,    /* Parsing context */
  int iRegStore,    /* Register holding the first column */
  Table *pTab       /* The table */
){
  int i;
  Walker w;
  Column *pRedo;
  int eProgress;
  VdbeOp *pOp;

  assert( pTab->tabFlags & TF_HasGenerated );
  testcase( pTab->tabFlags & TF_HasVirtual );
  testcase( pTab->tabFlags & TF_HasStored );

  /* Before computing generated columns, first go through and make sure
  ** that appropriate affinity has been applied to the regular columns
  */
  sqlite3TableAffinity(pParse->pVdbe, pTab, iRegStore);
  if( (pTab->tabFlags & TF_HasStored)!=0
   && (pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1))->opcode==OP_Affinity
  ){
    /* Change the OP_Affinity argument to '@' (NONE) for all stored
    ** columns.  '@' is the no-op affinity and those columns have not
    ** yet been computed. */
    int ii, jj;
    char *zP4 = pOp->p4.z;
    assert( zP4!=0 );
    assert( pOp->p4type==P4_DYNAMIC );
    for(ii=jj=0; zP4[jj]; ii++){
      if( pTab->aCol[ii].colFlags & COLFLAG_VIRTUAL ){
        continue;
      }
      if( pTab->aCol[ii].colFlags & COLFLAG_STORED ){
        zP4[jj] = SQLITE_AFF_NONE;
      }
      jj++;
    }
  }

  /* Because there can be multiple generated columns that refer to one another,
  ** this is a two-pass algorithm.  On the first pass, mark all generated
  ** columns as "not available".
  */
  for(i=0; i<pTab->nCol; i++){
    if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){
      testcase( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL );
      testcase( pTab->aCol[i].colFlags & COLFLAG_STORED );
      pTab->aCol[i].colFlags |= COLFLAG_NOTAVAIL;
    }
  }

  w.u.pTab = pTab;
  w.xExprCallback = exprColumnFlagUnion;
  w.xSelectCallback = 0;
  w.xSelectCallback2 = 0;

  /* On the second pass, compute the value of each NOT-AVAILABLE column.
  ** Companion code in the TK_COLUMN case of sqlite3ExprCodeTarget() will
  ** compute dependencies and mark remove the COLSPAN_NOTAVAIL mark, as
  ** they are needed.
  */
  pParse->iSelfTab = -iRegStore;
  do{
    eProgress = 0;
    pRedo = 0;
    for(i=0; i<pTab->nCol; i++){
      Column *pCol = pTab->aCol + i;
      if( (pCol->colFlags & COLFLAG_NOTAVAIL)!=0 ){
        int x;
        pCol->colFlags |= COLFLAG_BUSY;
        w.eCode = 0;
        sqlite3WalkExpr(&w, pCol->pDflt);
        pCol->colFlags &= ~COLFLAG_BUSY;
        if( w.eCode & COLFLAG_NOTAVAIL ){
          pRedo = pCol;
          continue;
        }
        eProgress = 1;
        assert( pCol->colFlags & COLFLAG_GENERATED );
        x = sqlite3TableColumnToStorage(pTab, i) + iRegStore;
        sqlite3ExprCodeGeneratedColumn(pParse, pCol, x);
        pCol->colFlags &= ~COLFLAG_NOTAVAIL;
      }
    }
  }while( pRedo && eProgress );
  if( pRedo ){
    sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pRedo->zName);
  }
  pParse->iSelfTab = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
movl %esi, %edx
movq %rdi, 0x8(%rsp)
movq 0x10(%rdi), %rdi
movq %r14, %rsi
movl %edx, 0x14(%rsp)
callq 0x2c42fe
testb $0x40, 0x40(%r14)
je 0x2e44f7
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x2e449b
leaq 0x1da9ef(%rip), %rax    # 0x4bee88
jmp 0x2e44b5
movslq 0x90(%rax), %rcx
movq 0x88(%rax), %rax
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rax
addq $-0x18, %rax
cmpb $0x5a, (%rax)
jne 0x2e44f7
movq 0x10(%rax), %rax
cmpb $0x0, (%rax)
je 0x2e44f7
xorl %ecx, %ecx
movl $0x1c, %edx
movq %rax, %rsi
movq 0x8(%r14), %rdi
movzwl (%rdi,%rdx), %edi
testb $0x20, %dil
jne 0x2e44e6
testb $0x40, %dil
je 0x2e44e4
movb $0x40, (%rsi)
incl %ecx
movslq %ecx, %rdi
leaq (%rax,%rdi), %rsi
addq $0x20, %rdx
cmpb $0x0, (%rax,%rdi)
jne 0x2e44cd
movswq 0x46(%r14), %rax
testq %rax, %rax
jle 0x2e452d
movq 0x8(%r14), %rcx
movq %rax, %rdx
shlq $0x5, %rdx
xorl %esi, %esi
movzwl 0x1c(%rcx,%rsi), %edi
testb $0x60, %dil
je 0x2e4524
orl $0x80, %edi
movw %di, 0x1c(%rcx,%rsi)
addq $0x20, %rsi
cmpq %rsi, %rdx
jne 0x2e450e
leaq 0x18(%rsp), %rdx
movq %r14, 0x28(%rdx)
leaq 0x1a62(%rip), %rcx      # 0x2e5f9f
movq %rcx, 0x8(%rdx)
movl 0x14(%rsp), %ecx
negl %ecx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdx)
movq 0x8(%rsp), %rdx
movl %ecx, 0x40(%rdx)
testw %ax, %ax
jle 0x2e462c
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x8(%r14), %rcx
movzwl 0x1c(%rcx,%r15), %eax
testb %al, %al
jns 0x2e45ee
leaq (%rcx,%r15), %r12
movl %eax, %edx
orl $0x100, %edx            # imm = 0x100
movw %dx, 0x1c(%rcx,%r15)
movw $0x0, 0x3c(%rsp)
movq 0x8(%rcx,%r15), %rsi
testq %rsi, %rsi
je 0x2e45b9
leaq 0x18(%rsp), %rdi
callq 0x2c0a8c
movb 0x3c(%rsp), %al
andw $0xfeff, 0x1c(%r12)     # imm = 0xFEFF
testb %al, %al
jns 0x2e45c4
movq %r12, %r13
jmp 0x2e45ee
andl $0xfeff, %eax           # imm = 0xFEFF
movw %ax, 0x1c(%r12)
movswl %bx, %esi
movq %r14, %rdi
callq 0x2be097
movswl %ax, %edx
addl 0x14(%rsp), %edx
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x2be0f0
andb $0x7f, 0x1c(%r12)
movl $0x1, %ebp
incq %rbx
movswq 0x46(%r14), %rax
addq $0x20, %r15
cmpq %rax, %rbx
jl 0x2e4569
testq %r13, %r13
je 0x2e4610
testl %ebp, %ebp
jne 0x2e4556
testq %r13, %r13
je 0x2e462c
movq (%r13), %rdx
leaq 0xf2f3c(%rip), %rsi     # 0x3d755c
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x27b48d
movq 0x8(%rsp), %rax
movl $0x0, 0x40(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq