// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r13
movq %rdx, %r12
movq (%rdi), %r15
andq $0x0, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x26eb77
movslq (%rsi), %r14
movq %rsi, %rbp
movq %r14, %rsi
shlq $0x5, %rsi
movq %r15, %rdi
callq 0x2258ed
movq %rbp, %rsi
movq %rax, %rbp
movl $0x7fff, %eax           # imm = 0x7FFF
cmpl %eax, %r14d
cmovll %r14d, %eax
jmp 0x26eb7b
xorl %ebp, %ebp
xorl %eax, %eax
movq %r12, 0x18(%rsp)
movw %ax, (%r12)
movq %r13, 0x10(%rsp)
movq %rbp, (%r13)
addq $0x8, %rsi
testl %eax, %eax
cmovlel %ebx, %eax
leaq 0x30(%rsp), %rbx
leaq 0x1096cc(%rip), %r14    # 0x37826f
xorl %r12d, %r12d
movq %rbp, %r13
movq %rax, 0x8(%rsp)
movq %rbp, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
cmpq %rax, %r12
je 0x26ed64
cmpb $0x0, 0x61(%r15)
jne 0x26ed5f
imulq $0x18, %r12, %rcx
leaq (%rsi,%rcx), %rax
movq 0x8(%rsi,%rcx), %rbp
testq %rbp, %rbp
je 0x26ebe4
testb $0x3, 0x11(%rax)
je 0x26ec3f
movq (%rax), %rdi
callq 0x267d34
movzbl (%rax), %ecx
cmpl $0x8b, %ecx
jne 0x26ebfd
movq 0x18(%rax), %rax
jmp 0x26ebec
cmpl $0x3b, %ecx
je 0x26ec33
cmpl $0xa4, %ecx
jne 0x26ec3a
movzwl 0x30(%rax), %edx
movq 0x40(%rax), %rcx
testw %dx, %dx
jns 0x26ec27
movzwl 0x44(%rcx), %edx
leaq 0x107d64(%rip), %rbp    # 0x376986
testw %dx, %dx
js 0x26ec3f
movzwl %dx, %eax
shll $0x5, %eax
addq 0x8(%rcx), %rax
jmp 0x26ec37
addq $0x8, %rax
movq (%rax), %rbp
testq %rbp, %rbp
je 0x26ec4b
movq %rbp, %rdi
callq 0x26edc7
testl %eax, %eax
je 0x26ec63
leal 0x1(%r12), %edx
movq %r15, %rdi
leaq 0x10960c(%rip), %rsi    # 0x378266
xorl %eax, %eax
callq 0x226ec3
jmp 0x26ec6e
movq %r15, %rdi
movq %rbp, %rsi
callq 0x22572a
movq %rax, %rbp
andl $0x0, 0x4(%rsp)
testq %rbp, %rbp
je 0x26ed07
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x24a8e6
testq %rax, %rax
je 0x26ed19
movq %rbp, %rdi
callq 0x2211ac
testl %eax, %eax
je 0x26ecbd
movl %eax, %ecx
cmpq $0x1, %rcx
jbe 0x26ecc1
decq %rcx
movl %ecx, %edx
movzbl (%rbp,%rdx), %edx
leaq -0x3a(%rdx), %rsi
cmpq $-0xb, %rsi
ja 0x26eca1
jmp 0x26ecc6
xorl %eax, %eax
jmp 0x26eccc
movb (%rbp), %dl
xorl %ecx, %ecx
cmpb $0x3a, %dl
cmovel %ecx, %eax
movl 0x4(%rsp), %r8d
incl %r8d
movl %r8d, 0x4(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movl %eax, %edx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x226ec3
movq %rax, %rbp
cmpl $0x4, 0x4(%rsp)
jb 0x26ec76
pushq $0x4
popq %rdi
leaq 0x4(%rsp), %rsi
callq 0x221618
jmp 0x26ec76
andq $0x0, (%r13)
xorl %edi, %edi
callq 0x26d05f
movb %al, 0x1b(%r13)
jmp 0x26ed44
movq %rbp, (%r13)
movq %rbp, %rdi
callq 0x26d05f
movb %al, 0x1b(%r13)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x24a8f4
cmpq %r13, %rax
jne 0x26ed44
movq %r15, %rdi
callq 0x224bb1
incq %r12
addq $0x20, %r13
movq 0x28(%rsp), %rbp
movq 0x20(%rsp), %rsi
movq 0x8(%rsp), %rax
jmp 0x26ebb8
movq %r12, 0x8(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x24a72c
cmpb $0x0, 0x61(%r15)
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %r13
je 0x26edb8
movl 0x8(%rsp), %ebx
shlq $0x5, %rbx
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x26eda2
movq (%rbp,%r14), %rsi
movq %r15, %rdi
callq 0x21f26b
addq $0x20, %r14
jmp 0x26ed8a
movq %r15, %rdi
movq %rbp, %rsi
callq 0x21f26b
andq $0x0, (%r13)
andw $0x0, (%r12)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq