// File: /workspace/github_c_makefile_star2_O3/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, %r12
movq %rdx, %r13
movq %rdi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
testq %rsi, %rsi
je 0x2c8ec8
movslq (%rsi), %rbx
movq %rsi, 0x10(%rsp)
movq %rbx, %rsi
shlq $0x5, %rsi
movq %r15, %rdi
callq 0x279b27
movq %rax, %rbp
movl $0x7fff, %eax           # imm = 0x7FFF
cmpl %eax, %ebx
cmovll %ebx, %eax
leaq 0x61(%r15), %r14
movw %ax, (%r13)
movq %rbp, (%r12)
testq %rbx, %rbx
jle 0x2c8edd
movq %r14, 0x8(%rsp)
movq %r12, 0x28(%rsp)
movq %r13, 0x30(%rsp)
movq 0x10(%rsp), %r13
addq $0x8, %r13
movl %eax, 0x1c(%rsp)
movl %eax, %eax
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rbx
leaq 0x10f1ab(%rip), %r14    # 0x3d7e4f
movq %rbp, %r12
xorl %ebp, %ebp
movq %r12, 0x20(%rsp)
movq %r13, 0x10(%rsp)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x2c8ee1
leaq (,%rbp,2), %rax
addq %rbp, %rax
leaq (,%rax,8), %rax
addq %r13, %rax
movq 0x8(%rax), %r13
testq %r13, %r13
je 0x2c8ce6
testb $0x3, 0x11(%rax)
je 0x2c8d64
movq (%rax), %rax
testq %rax, %rax
je 0x2c8d0f
movl 0x4(%rax), %ecx
testl $0x41000, %ecx          # imm = 0x41000
je 0x2c8d17
btl $0x12, %ecx
jb 0x2c8d05
addq $0x10, %rax
jmp 0x2c8ce6
movq 0x20(%rax), %rax
addq $0x8, %rax
jmp 0x2c8ce6
xorl %eax, %eax
jmp 0x2c8d17
movq 0x18(%rax), %rax
movzbl (%rax), %ecx
cmpl $0x8b, %ecx
je 0x2c8d13
cmpl $0x3b, %ecx
je 0x2c8d58
cmpl $0xa4, %ecx
jne 0x2c8d5f
movzwl 0x30(%rax), %edx
movq 0x40(%rax), %rcx
testw %dx, %dx
jns 0x2c8d4c
movzwl 0x44(%rcx), %edx
leaq 0x10d81f(%rip), %r13    # 0x3d6566
testw %dx, %dx
js 0x2c8d64
movzwl %dx, %eax
shll $0x5, %eax
addq 0x8(%rcx), %rax
jmp 0x2c8d5c
addq $0x8, %rax
movq (%rax), %r13
testq %r13, %r13
je 0x2c8d70
movq %r13, %rdi
callq 0x2c8f5f
testl %eax, %eax
je 0x2c8d86
leal 0x1(%rbp), %edx
movq %r15, %rdi
leaq 0x10f0c9(%rip), %rsi    # 0x3d7e46
xorl %eax, %eax
callq 0x27b56a
jmp 0x2c8d91
movq %r15, %rdi
movq %r13, %rsi
callq 0x279928
movq %rax, %r13
movl $0x0, 0x4(%rsp)
testq %r13, %r13
je 0x2c8e40
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2a547e
cmpq $0x0, 0x10(%rax)
je 0x2c8e50
movq %r13, %rdi
callq 0x172f0
movl %eax, %edx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
je 0x2c8df1
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
cmpq $0x1, %rax
jbe 0x2c8df5
decq %rax
movl %eax, %ecx
movzbl (%r13,%rcx), %ecx
leaq -0x3a(%rcx), %rsi
cmpq $-0xb, %rsi
ja 0x2c8dd4
jmp 0x2c8dfb
xorl %edx, %edx
jmp 0x2c8e01
movb (%r13), %cl
xorl %eax, %eax
cmpb $0x3a, %cl
cmovel %eax, %edx
movl 0x4(%rsp), %r8d
incl %r8d
movl %r8d, 0x4(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rcx
xorl %eax, %eax
callq 0x27b56a
movq %rax, %r13
cmpl $0x4, 0x4(%rsp)
jb 0x2c8d9c
movl $0x4, %edi
leaq 0x4(%rsp), %rsi
callq 0x274e7e
jmp 0x2c8d9c
movq $0x0, (%r12)
movb $0x0, 0x1b(%r12)
jmp 0x2c8e9c
movq %r13, (%r12)
movb (%r13), %dl
testb %dl, %dl
je 0x2c8e7a
leaq 0x1(%r13), %rcx
xorl %eax, %eax
leaq 0x108477(%rip), %rsi    # 0x3d12e0
movzbl %dl, %edx
addb (%rdx,%rsi), %al
movb (%rcx), %dl
incq %rcx
testb %dl, %dl
jne 0x2c8e69
jmp 0x2c8e7c
xorl %eax, %eax
movb %al, 0x1b(%r12)
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2a5210
cmpq %r12, %rax
jne 0x2c8e9c
movq %r15, %rdi
callq 0x278b1c
incq %rbp
addq $0x20, %r12
cmpq 0x38(%rsp), %rbp
movq 0x10(%rsp), %r13
jne 0x2c8cb3
movq 0x30(%rsp), %r13
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %rbp
movl 0x1c(%rsp), %ebx
jmp 0x2c8ef2
movw $0x0, (%r13)
movq $0x0, (%r12)
leaq 0x61(%r15), %r14
xorl %ebp, %ebp
xorl %ebx, %ebx
jmp 0x2c8ef7
movl %ebp, %ebx
movq 0x30(%rsp), %r13
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %rbp
movq 0x8(%rsp), %r14
leaq 0x40(%rsp), %rdi
callq 0x2a5003
cmpb $0x0, (%r14)
je 0x2c8f50
testl %ebx, %ebx
je 0x2c8f31
movl %ebx, %ebx
shlq $0x5, %rbx
xorl %r14d, %r14d
movq (%rbp,%r14), %rsi
testq %rsi, %rsi
je 0x2c8f26
movq %r15, %rdi
callq 0x282904
addq $0x20, %r14
cmpq %r14, %rbx
jne 0x2c8f14
jmp 0x2c8f36
testq %rbp, %rbp
je 0x2c8f41
movq %r15, %rdi
movq %rbp, %rsi
callq 0x282904
movq $0x0, (%r12)
movw $0x0, (%r13)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq