// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r13
movq (%rdi), %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
xorl %ebp, %ebp
testq %rsi, %rsi
je 0x2d2504
movslq (%r13), %rbx
movq %rbx, %rsi
shlq $0x5, %rsi
movq %r15, %rdi
callq 0x283569
movl $0x7fff, %ecx           # imm = 0x7FFF
cmpl %ecx, %ebx
cmovll %ebx, %ecx
jmp 0x2d2508
xorl %eax, %eax
xorl %ecx, %ecx
movw %cx, (%r12)
movq %rax, 0x10(%rsp)
movq %rax, (%r14)
testl %ecx, %ecx
jle 0x2d2752
movq %r14, 0x20(%rsp)
movq %r12, 0x28(%rsp)
addq $0x8, %r13
movl %ecx, 0x1c(%rsp)
movl %ecx, %eax
movq %rax, 0x30(%rsp)
leaq 0x40(%rsp), %rbx
leaq 0x10f062(%rip), %r14    # 0x3e15a4
xorl %ebp, %ebp
movq 0x10(%rsp), %r12
movq %r13, 0x38(%rsp)
cmpb $0x0, 0x61(%r15)
jne 0x2d2748
leaq (,%rbp,2), %rax
addq %rbp, %rax
leaq (,%rax,8), %rax
addq %r13, %rax
movq 0x8(%rax), %r13
testq %r13, %r13
je 0x2d257e
testb $0x3, 0x11(%rax)
je 0x2d25f3
movq (%rax), %rax
testq %rax, %rax
je 0x2d25ab
movl 0x4(%rax), %ecx
testl $0x41000, %ecx          # imm = 0x41000
je 0x2d25ab
btl $0x12, %ecx
jb 0x2d259d
addq $0x10, %rax
jmp 0x2d257e
movq 0x20(%rax), %rax
addq $0x8, %rax
jmp 0x2d257e
movq 0x18(%rax), %rax
movzbl (%rax), %ecx
cmpl $0x8b, %ecx
je 0x2d25a7
cmpl $0x3b, %ecx
je 0x2d25ec
cmpl $0xa4, %ecx
jne 0x2d25f3
movzwl 0x30(%rax), %edx
movq 0x40(%rax), %rcx
testw %dx, %dx
jns 0x2d25d4
movzwl 0x44(%rcx), %edx
leaq 0x10d6d8(%rip), %r13    # 0x3dfcb3
testw %dx, %dx
js 0x2d25f3
movzwl %dx, %eax
shll $0x5, %eax
addq 0x8(%rcx), %rax
jmp 0x2d25f0
addq $0x8, %rax
movq (%rax), %r13
testq %r13, %r13
je 0x2d2604
movq %r13, %rdi
callq 0x2d27c2
testl %eax, %eax
je 0x2d261a
leal 0x1(%rbp), %edx
movq %r15, %rdi
leaq 0x10ef8a(%rip), %rsi    # 0x3e159b
xorl %eax, %eax
callq 0x284f95
jmp 0x2d2625
movq %r15, %rdi
movq %r13, %rsi
callq 0x283365
movq %rax, %r13
movl $0x0, 0xc(%rsp)
testq %r13, %r13
je 0x2d26d3
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2aefdf
cmpq $0x0, 0x10(%rax)
je 0x2d26df
movq %r13, %rdi
callq 0x172f0
movl %eax, %edx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
je 0x2d2683
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
cmpq $0x2, %rax
jl 0x2d2687
movzbl -0x1(%r13,%rax), %ecx
decq %rax
addq $-0x3a, %rcx
cmpq $-0xb, %rcx
ja 0x2d2668
jmp 0x2d2689
xorl %edx, %edx
jmp 0x2d2694
xorl %eax, %eax
movl %eax, %ecx
cmpb $0x3a, (%r13,%rcx)
cmovel %eax, %edx
movl 0xc(%rsp), %r8d
incl %r8d
movl %r8d, 0xc(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rcx
xorl %eax, %eax
callq 0x284f95
movq %rax, %r13
cmpl $0x4, 0xc(%rsp)
jb 0x2d2630
movl $0x4, %edi
leaq 0xc(%rsp), %rsi
callq 0x27e7ad
jmp 0x2d2630
movq %r13, (%r12)
movb $0x0, 0x1b(%r12)
jmp 0x2d272b
movq %r13, (%r12)
movb (%r13), %dl
testb %dl, %dl
je 0x2d2709
leaq 0x1(%r13), %rcx
xorl %eax, %eax
leaq 0x108368(%rip), %rsi    # 0x3daa60
movzbl %dl, %edx
addb (%rdx,%rsi), %al
movb (%rcx), %dl
incq %rcx
testb %dl, %dl
jne 0x2d26f8
jmp 0x2d270b
xorl %eax, %eax
movb %al, 0x1b(%r12)
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2aed98
cmpq %r12, %rax
jne 0x2d272b
movq %r15, %rdi
callq 0x2824bb
incq %rbp
addq $0x20, %r12
cmpq 0x30(%rsp), %rbp
movq 0x38(%rsp), %r13
jne 0x2d254e
movl 0x1c(%rsp), %eax
movl %eax, %ebp
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %r14
leaq 0x40(%rsp), %rdi
callq 0x2aebab
cmpb $0x0, 0x61(%r15)
je 0x2d27b3
movq %r14, %r13
testl %ebp, %ebp
je 0x2d2792
movl %ebp, %ebx
shlq $0x5, %rbx
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
movq (%rax,%r14), %rsi
testq %rsi, %rsi
je 0x2d2789
movq %r15, %rdi
callq 0x28c3e7
addq $0x20, %r14
cmpq %r14, %rbx
jne 0x2d2773
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x2d27a4
movq %r15, %rdi
callq 0x28c3e7
movq $0x0, (%r13)
movw $0x0, (%r12)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq