// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: createTableStmt
static char *createTableStmt(sqlite3 *db, Table *p){
  int i, k, n;
  char *zStmt;
  char *zSep, *zSep2, *zEnd;
  Column *pCol;
  n = 0;
  for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){
    n += identLength(pCol->zName) + 5;
  }
  n += identLength(p->zName);
  if( n<50 ){ 
    zSep = "";
    zSep2 = ",";
    zEnd = ")";
  }else{
    zSep = "\n  ";
    zSep2 = ",\n  ";
    zEnd = "\n)";
  }
  n += 35 + 6*p->nCol;
  zStmt = sqlite3DbMallocRaw(0, n);
  if( zStmt==0 ){
    db->mallocFailed = 1;
    return 0;
  }
  sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
  k = sqlite3Strlen30(zStmt);
  identPut(zStmt, &k, p->zName);
  zStmt[k++] = '(';
  for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
    static const char * const azType[] = {
        /* SQLITE_AFF_TEXT    */ " TEXT",
        /* SQLITE_AFF_NONE    */ "",
        /* SQLITE_AFF_NUMERIC */ " NUM",
        /* SQLITE_AFF_INTEGER */ " INT",
        /* SQLITE_AFF_REAL    */ " REAL"
    };
    int len;
    const char *zType;

    sqlite3_snprintf(n-k, &zStmt[k], zSep);
    k += sqlite3Strlen30(&zStmt[k]);
    zSep = zSep2;
    identPut(zStmt, &k, pCol->zName);
    assert( pCol->affinity-SQLITE_AFF_TEXT >= 0 );
    assert( pCol->affinity-SQLITE_AFF_TEXT < ArraySize(azType) );
    testcase( pCol->affinity==SQLITE_AFF_TEXT );
    testcase( pCol->affinity==SQLITE_AFF_NONE );
    testcase( pCol->affinity==SQLITE_AFF_NUMERIC );
    testcase( pCol->affinity==SQLITE_AFF_INTEGER );
    testcase( pCol->affinity==SQLITE_AFF_REAL );
    
    zType = azType[pCol->affinity - SQLITE_AFF_TEXT];
    len = sqlite3Strlen30(zType);
    assert( pCol->affinity==SQLITE_AFF_NONE 
            || pCol->affinity==sqlite3AffinityType(zType) );
    memcpy(&zStmt[k], zType, len);
    k += len;
    assert( k<=n );
  }
  sqlite3_snprintf(n-k, &zStmt[k], "%s", zEnd);
  return zStmt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r12
movq %rdi, %r13
movswl 0x42(%rsi), %eax
testl %eax, %eax
jle 0x46704
movq 0x8(%r12), %rdx
xorl %esi, %esi
xorl %ecx, %ecx
movq (%rdx), %r8
xorl %edi, %edi
movzbl (%r8), %r9d
cmpl $0x22, %r9d
je 0x466e7
testl %r9d, %r9d
jne 0x466e9
jmp 0x466f0
incl %edi
incl %edi
incq %r8
jmp 0x466d6
addl %edi, %ecx
addl $0x7, %ecx
incl %esi
addq $0x30, %rdx
cmpl %eax, %esi
jne 0x466d1
addl $0x2, %ecx
jmp 0x46709
movl $0x2, %ecx
movq (%r12), %rsi
xorl %edx, %edx
movzbl (%rsi), %edi
cmpl $0x22, %edi
je 0x4671d
testl %edi, %edi
jne 0x4671f
jmp 0x46726
incl %edx
incl %edx
incq %rsi
jmp 0x4670f
addl %edx, %ecx
cmpl $0x32, %ecx
leaq 0x37c7e(%rip), %rdx     # 0x7e3b0
leaq 0x34c17(%rip), %r14     # 0x7b350
cmovlq %rdx, %r14
leaq 0x34c09(%rip), %rdx     # 0x7b34d
leaq 0x34c04(%rip), %rsi     # 0x7b34f
cmovlq %rdx, %rsi
movq %rsi, -0x58(%rbp)
leaq 0x34bfb(%rip), %rdx     # 0x7b355
leaq 0x34bf3(%rip), %rbx     # 0x7b354
cmovlq %rdx, %rbx
leal (%rax,%rax,2), %eax
leal (%rcx,%rax,2), %r15d
addl $0x23, %r15d
movl %r15d, %edi
callq 0xa38c
testq %rax, %rax
je 0x468d0
movq %rbx, -0x48(%rbp)
leaq 0x34bcb(%rip), %rdx     # 0x7b357
movl %r15d, %edi
xorl %r15d, %r15d
movl %edi, -0x3c(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rsi
xorl %eax, %eax
callq 0xb954
movq -0x38(%rbp), %rdi
cmpb $0x0, (%rdi,%r15)
leaq 0x1(%r15), %r15
jne 0x467a8
decl %r15d
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
leaq -0x2c(%rbp), %rbx
movl %r15d, (%rbx)
movq (%r12), %rdx
movq %rbx, %rsi
callq 0x4bac8
movq -0x38(%rbp), %rcx
movslq (%rbx), %rax
leal 0x1(%rax), %r13d
movb $0x28, (%rcx,%rax)
cmpw $0x0, 0x42(%r12)
jle 0x468a8
movq %r12, -0x50(%rbp)
movq 0x8(%r12), %r12
xorl %r15d, %r15d
movl -0x3c(%rbp), %edi
subl %r13d, %edi
movslq %r13d, %rbx
addq %rcx, %rbx
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xb954
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incl %eax
cmpb $0x0, (%rbx)
leaq 0x1(%rbx), %rbx
jne 0x46816
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
addl %r13d, %eax
movl %eax, -0x2c(%rbp)
movq (%r12), %rdx
movq -0x38(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x4bac8
movsbq 0x29(%r12), %rax
leaq 0x4cbf6(%rip), %rcx     # 0x93440
movq -0x308(%rcx,%rax,8), %rsi
movq $-0x1, %r13
cmpb $0x0, 0x1(%rsi,%r13)
leaq 0x1(%r13), %r13
jne 0x46859
andl $0x3fffffff, %r13d      # imm = 0x3FFFFFFF
movslq -0x2c(%rbp), %rbx
movq %rbx, %rdi
movq -0x38(%rbp), %r14
addq %r14, %rdi
movq %r13, %rdx
callq 0x82f0
movq %r14, %rcx
addl %ebx, %r13d
movl %r13d, -0x2c(%rbp)
incl %r15d
addq $0x30, %r12
movq -0x50(%rbp), %rax
movswl 0x42(%rax), %eax
movq -0x58(%rbp), %r14
cmpl %eax, %r15d
jl 0x467f8
movl -0x3c(%rbp), %edi
subl %r13d, %edi
movslq %r13d, %rax
movq -0x38(%rbp), %rsi
addq %rax, %rsi
leaq 0x32e1a(%rip), %rdx     # 0x796d9
movq -0x48(%rbp), %rcx
xorl %eax, %eax
callq 0xb954
movq -0x38(%rbp), %rax
jmp 0x468d5
movb $0x1, 0x50(%r13)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq