// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3ColumnsFromExprList
SQLITE_PRIVATE int sqlite3ColumnsFromExprList(
  Parse *pParse,          /* Parsing context */
  ExprList *pEList,       /* Expr list from which to derive column names */
  i16 *pnCol,             /* Write the number of columns here */
  Column **paCol          /* Write the new column list here */
){
  sqlite3 *db = pParse->db;   /* Database connection */
  int i, j;                   /* Loop counters */
  u32 cnt;                    /* Index added to make the name unique */
  Column *aCol, *pCol;        /* For looping over result columns */
  int nCol;                   /* Number of columns in the result set */
  char *zName;                /* Column name */
  int nName;                  /* Size of name in zName[] */
  Hash ht;                    /* Hash table of column names */

  sqlite3HashInit(&ht);
  if( pEList ){
    nCol = pEList->nExpr;
    aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
    testcase( aCol==0 );
    if( nCol>32767 ) nCol = 32767;
  }else{
    nCol = 0;
    aCol = 0;
  }
  assert( nCol==(i16)nCol );
  *pnCol = nCol;
  *paCol = aCol;

  for(i=0, pCol=aCol; i<nCol && !db->mallocFailed; i++, pCol++){
    /* Get an appropriate name for the column
    */
    if( (zName = pEList->a[i].zEName)!=0 && pEList->a[i].eEName==ENAME_NAME ){
      /* If the column contains an "AS <name>" phrase, use <name> as the name */
    }else{
      Expr *pColExpr = sqlite3ExprSkipCollateAndLikely(pEList->a[i].pExpr);
      while( pColExpr->op==TK_DOT ){
        pColExpr = pColExpr->pRight;
        assert( pColExpr!=0 );
      }
      if( pColExpr->op==TK_COLUMN ){
        /* For columns use the column name name */
        int iCol = pColExpr->iColumn;
        Table *pTab = pColExpr->y.pTab;
        assert( pTab!=0 );
        if( iCol<0 ) iCol = pTab->iPKey;
        zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid";
      }else if( pColExpr->op==TK_ID ){
        assert( !ExprHasProperty(pColExpr, EP_IntValue) );
        zName = pColExpr->u.zToken;
      }else{
        /* Use the original text of the column expression as its name */
        zName = pEList->a[i].zEName;
      }
    }
    if( zName && !sqlite3IsTrueOrFalse(zName) ){
      zName = sqlite3DbStrDup(db, zName);
    }else{
      zName = sqlite3MPrintf(db,"column%d",i+1);
    }

    /* Make sure the column name is unique.  If the name is not unique,
    ** append an integer to the name so that it becomes unique.
    */
    cnt = 0;
    while( zName && sqlite3HashFind(&ht, zName)!=0 ){
      nName = sqlite3Strlen30(zName);
      if( nName>0 ){
        for(j=nName-1; j>0 && sqlite3Isdigit(zName[j]); j--){}
        if( zName[j]==':' ) nName = j;
      }
      zName = sqlite3MPrintf(db, "%.*z:%u", nName, zName, ++cnt);
      if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);
    }
    pCol->zName = zName;
    pCol->hName = sqlite3StrIHash(zName);
    sqlite3ColumnPropertiesFromName(0, pCol);
    if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){
      sqlite3OomFault(db);
    }
  }
  sqlite3HashClear(&ht);
  if( db->mallocFailed ){
    for(j=0; j<i; j++){
      sqlite3DbFree(db, aCol[j].zName);
    }
    sqlite3DbFree(db, aCol);
    *paCol = 0;
    *pnCol = 0;
    return SQLITE_NOMEM_BKPT;
  }
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x40a9e0
cmpq $0x0, -0x18(%rbp)
je 0x43aff6
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x54(%rbp), %rsi
shlq $0x5, %rsi
callq 0x3c9520
movq %rax, -0x48(%rbp)
cmpl $0x7fff, -0x54(%rbp)    # imm = 0x7FFF
jle 0x43aff4
movl $0x7fff, -0x54(%rbp)    # imm = 0x7FFF
jmp 0x43b005
movl $0x0, -0x54(%rbp)
movq $0x0, -0x48(%rbp)
movl -0x54(%rbp), %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x34(%rbp), %ecx
xorl %eax, %eax
cmpl -0x54(%rbp), %ecx
movb %al, -0x99(%rbp)
jge 0x43b04f
movq -0x30(%rbp), %rax
cmpb $0x0, 0x61(%rax)
setne %al
xorb $-0x1, %al
movb %al, -0x99(%rbp)
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0x43b05e
jmp 0x43b36f
movq -0x18(%rbp), %rax
addq $0x8, %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x43b0a4
movq -0x18(%rbp), %rax
addq $0x8, %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movb 0x11(%rax), %al
andb $0x3, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x43b0a4
jmp 0x43b1c7
movq -0x18(%rbp), %rax
addq $0x8, %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x42f120
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x8b, %eax
jne 0x43b0eb
movq -0x88(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x43b0c6
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xa4, %eax
jne 0x43b188
movq -0x88(%rbp), %rax
movswl 0x30(%rax), %eax
movl %eax, -0x8c(%rbp)
movq -0x88(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x98(%rbp)
cmpl $0x0, -0x8c(%rbp)
jge 0x43b13d
movq -0x98(%rbp), %rax
movswl 0x44(%rax), %eax
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
jl 0x43b16b
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x8c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
jmp 0x43b17b
leaq 0x170881(%rip), %rax    # 0x5ab9f3
movq %rax, -0xa8(%rbp)
jmp 0x43b17b
movq -0xa8(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x43b1c5
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x3b, %eax
jne 0x43b1a8
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x43b1c3
movq -0x18(%rbp), %rax
addq $0x8, %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x43b1c5
jmp 0x43b1c7
cmpq $0x0, -0x60(%rbp)
je 0x43b1ef
movq -0x60(%rbp), %rdi
callq 0x43b400
cmpl $0x0, %eax
jne 0x43b1ef
movq -0x30(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x3c91a0
movq %rax, -0x60(%rbp)
jmp 0x43b20b
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %edx
addl $0x1, %edx
leaq 0x1720e0(%rip), %rsi    # 0x5ad2e0
movb $0x0, %al
callq 0x3cb7d0
movq %rax, -0x60(%rbp)
movl $0x0, -0x3c(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x60(%rbp)
movb %al, -0xa9(%rbp)
je 0x43b23b
movq -0x60(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x40ad70
cmpq $0x0, %rax
setne %al
movb %al, -0xa9(%rbp)
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x43b24a
jmp 0x43b30f
movq -0x60(%rbp), %rdi
callq 0x3c3400
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jle 0x43b2cd
movl -0x64(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x38(%rbp)
movb %al, -0xaa(%rbp)
jle 0x43b29b
movq -0x60(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x16b948(%rip), %rax    # 0x5a6bd0
movzbl (%rax,%rcx), %eax
andl $0x4, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0xaa(%rbp)
movb -0xaa(%rbp), %al
testb $0x1, %al
jne 0x43b2a7
jmp 0x43b2b4
jmp 0x43b2a9
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x43b265
movq -0x60(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0x43b2cb
movl -0x38(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0x43b2cd
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movq -0x60(%rbp), %rcx
movl -0x3c(%rbp), %r8d
addl $0x1, %r8d
movl %r8d, -0x3c(%rbp)
leaq 0x171ffe(%rip), %rsi    # 0x5ad2e9
movb $0x0, %al
callq 0x3cb7d0
movq %rax, -0x60(%rbp)
cmpl $0x3, -0x3c(%rbp)
jbe 0x43b30a
movl $0x4, %edi
leaq -0x3c(%rbp), %rsi
callq 0x3c3b60
jmp 0x43b212
movq -0x60(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x60(%rbp), %rdi
callq 0x437e20
movb %al, %cl
movq -0x50(%rbp), %rax
movb %cl, 0x1b(%rax)
cmpq $0x0, -0x60(%rbp)
je 0x43b353
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0x40ada0
cmpq -0x50(%rbp), %rax
jne 0x43b353
movq -0x30(%rbp), %rdi
callq 0x3c8ba0
jmp 0x43b355
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x50(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x50(%rbp)
jmp 0x43b02c
leaq -0x80(%rbp), %rdi
callq 0x40aa20
movq -0x30(%rbp), %rax
cmpb $0x0, 0x61(%rax)
je 0x43b3e1
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x43b3b7
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3c00a0
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x43b389
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3c00a0
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x20(%rbp), %rax
movw $0x0, (%rax)
movl $0x7, -0x4(%rbp)
jmp 0x43b3e8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)