// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movq %rdx, %rsi
movl %ebp, %edx
callq 0x26ab99
testb $0x40, 0x40(%r14)
je 0x28178c
movq 0x10(%rbx), %rdi
pushq $-0x1
popq %rsi
callq 0x26468f
cmpb $0x5a, (%rax)
jne 0x28178c
movq 0x10(%rax), %rax
xorl %ecx, %ecx
pushq $0x1c
popq %rdx
movslq %ecx, %rsi
cmpb $0x0, (%rax,%rsi)
je 0x28178c
movq 0x8(%r14), %rdi
movzwl (%rdi,%rdx), %edi
testb $0x20, %dil
jne 0x281786
testb $0x40, %dil
je 0x281784
movb $0x40, (%rax,%rsi)
incl %ecx
addq $0x20, %rdx
jmp 0x281763
movzwl 0x46(%r14), %eax
xorl %ecx, %ecx
testw %ax, %ax
movl %eax, %edx
cmovlel %ecx, %edx
movzwl %dx, %edx
shll $0x5, %edx
cmpq %rcx, %rdx
je 0x2817c6
movq 0x8(%r14), %rsi
movzwl 0x1c(%rsi,%rcx), %edi
testb $0x60, %dil
je 0x2817c0
orl $0x80, %edi
movw %di, 0x1c(%rsi,%rcx)
addq $0x20, %rcx
jmp 0x2817a1
leaq 0x8(%rsp), %rdi
movq %r14, 0x28(%rdi)
leaq 0x1649(%rip), %rcx      # 0x282e1f
movq %rcx, 0x8(%rdi)
movl %ebp, 0x4(%rsp)
negl %ebp
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movl %ebp, 0x40(%rbx)
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %r12d, %r12d
movswq %ax, %rax
movq %r12, %rcx
movq %rcx, %r12
cmpq %rax, %r13
jl 0x281820
testq %r12, %r12
je 0x281897
xorl %r13d, %r13d
movl $0x0, %ecx
testl %r15d, %r15d
movl $0x0, %r15d
jne 0x2817fa
jmp 0x281897
movq 0x8(%r14), %rbp
movq %r13, %rcx
shlq $0x5, %rcx
movzwl 0x1c(%rbp,%rcx), %eax
testb %al, %al
jns 0x28188a
addq %rcx, %rbp
orl $0x100, %eax            # imm = 0x100
movw %ax, 0x1c(%rbp)
andw $0x0, 0x2c(%rsp)
movq 0x8(%rbp), %rsi
callq 0x267f87
andb $-0x2, 0x1d(%rbp)
testb $-0x80, 0x2c(%rsp)
jne 0x281882
movswl %r13w, %esi
movq %r14, %rdi
callq 0x265d66
movswl %ax, %edx
addl 0x4(%rsp), %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x265db8
andb $0x7f, 0x1c(%rbp)
pushq $0x1
popq %r15
jmp 0x281885
movq %rbp, %r12
leaq 0x8(%rsp), %rdi
incq %r13
movzwl 0x46(%r14), %eax
jmp 0x2817f3
testq %r12, %r12
je 0x2818b1
movq (%r12), %rdx
leaq 0xf60d5(%rip), %rsi     # 0x37797c
movq %rbx, %rdi
xorl %eax, %eax
callq 0x226dce
andl $0x0, 0x40(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq