// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
movl -0xc(%rbp), %edx
callq 0x434970
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x45ec09
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x429e10
movq %rax, -0x68(%rbp)
movzbl (%rax), %eax
cmpl $0x5a, %eax
jne 0x45ec09
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x70(%rbp)
movl $0x0, -0x6c(%rbp)
movq -0x78(%rbp), %rax
movslq -0x70(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x45ec07
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x6c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x1c(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x45ebc8
jmp 0x45ebfc
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x6c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x1c(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x45ebf3
movq -0x78(%rbp), %rax
movslq -0x70(%rbp), %rcx
movb $0x40, (%rax,%rcx)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x45eb99
jmp 0x45ec09
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jge 0x45ec6c
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x1c(%rax), %eax
andl $0x60, %eax
cmpl $0x0, %eax
je 0x45ec5f
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x1c(%rax), %ecx
orl $0x80, %ecx
movw %cx, 0x1c(%rax)
jmp 0x45ec61
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x45ec10
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x1995(%rip), %rax      # 0x460610
movq %rax, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
xorl %ecx, %ecx
subl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x40(%rax)
movl $0x0, -0x5c(%rbp)
movq $0x0, -0x58(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jge 0x45ed99
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movzwl 0x1c(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x45ed89
movq -0x80(%rbp), %rax
movzwl 0x1c(%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
movw %cx, 0x1c(%rax)
movw $0x0, -0x2c(%rbp)
movq -0x80(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x50(%rbp), %rdi
callq 0x42f650
movq -0x80(%rbp), %rax
movzwl 0x1c(%rax), %ecx
andl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
movw %cx, 0x1c(%rax)
movzwl -0x2c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x45ed44
movq -0x80(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x45ed8b
movl $0x1, -0x5c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
movswl %ax, %esi
callq 0x42bae0
cwtl
addl -0xc(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rsi
movl -0x84(%rbp), %edx
callq 0x42bbb0
movq -0x80(%rbp), %rax
movzwl 0x1c(%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
movw %cx, 0x1c(%rax)
jmp 0x45ed8b
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x45ecb1
jmp 0x45ed9b
xorl %eax, %eax
cmpq $0x0, -0x58(%rbp)
movb %al, -0x85(%rbp)
je 0x45edb7
cmpl $0x0, -0x5c(%rbp)
setne %al
movb %al, -0x85(%rbp)
movb -0x85(%rbp), %al
testb $0x1, %al
jne 0x45ec9b
cmpq $0x0, -0x58(%rbp)
je 0x45ede5
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rdx
leaq 0x14dc18(%rip), %rsi    # 0x5ac9f6
movb $0x0, %al
callq 0x3cb660
movq -0x8(%rbp), %rax
movl $0x0, 0x40(%rax)
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)