// File: /workspace/github_c_makefile_star2_O1/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, %r15
movq %rdi, -0x38(%rbp)
movswl 0x42(%rsi), %eax
testl %eax, %eax
jle 0x463d2
movq 0x8(%r15), %rdx
xorl %esi, %esi
xorl %ecx, %ecx
movq (%rdx), %r8
xorl %edi, %edi
movzbl (%r8), %r9d
cmpl $0x22, %r9d
je 0x463b5
testl %r9d, %r9d
jne 0x463b7
jmp 0x463be
incl %edi
incl %edi
incq %r8
jmp 0x463a4
addl %edi, %ecx
addl $0x7, %ecx
incl %esi
addq $0x30, %rdx
cmpl %eax, %esi
jne 0x4639f
addl $0x2, %ecx
jmp 0x463d7
movl $0x2, %ecx
movq (%r15), %rsi
xorl %edx, %edx
movzbl (%rsi), %edi
cmpl $0x22, %edi
je 0x463ea
testl %edi, %edi
jne 0x463ec
jmp 0x463f3
incl %edx
incl %edx
incq %rsi
jmp 0x463dc
addl %edx, %ecx
cmpl $0x32, %ecx
leaq 0x37f61(%rip), %rdx     # 0x7e360
leaq 0x34f4a(%rip), %r13     # 0x7b350
cmovlq %rdx, %r13
leaq 0x34f3c(%rip), %rdx     # 0x7b34d
leaq 0x34f37(%rip), %rsi     # 0x7b34f
cmovlq %rdx, %rsi
movq %rsi, -0x58(%rbp)
leaq 0x34f2e(%rip), %rdx     # 0x7b355
leaq 0x34f26(%rip), %rbx     # 0x7b354
cmovlq %rdx, %rbx
leal (%rax,%rax,2), %eax
leal (%rcx,%rax,2), %r14d
addl $0x23, %r14d
movl %r14d, %edi
callq 0xa2a2
testq %rax, %rax
je 0x4659a
movq %rax, %r12
movq %rbx, -0x48(%rbp)
leaq 0x34efb(%rip), %rdx     # 0x7b357
xorl %ebx, %ebx
movl %r14d, -0x30(%rbp)
movl %r14d, %edi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb859
cmpb $0x0, (%r12,%rbx)
leaq 0x1(%rbx), %rbx
jne 0x4646f
decl %ebx
andl $0x3fffffff, %ebx       # imm = 0x3FFFFFFF
leaq -0x2c(%rbp), %r14
movl %ebx, (%r14)
movq (%r15), %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x4b9b1
movslq (%r14), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r14)
movb $0x28, (%r12,%rax)
cmpw $0x0, 0x42(%r15)
jle 0x46574
movq 0x8(%r15), %rbx
xorl %ecx, %ecx
movq %r15, -0x50(%rbp)
movq %r12, -0x40(%rbp)
movl %ecx, -0x38(%rbp)
movslq -0x2c(%rbp), %r15
movl -0x30(%rbp), %edi
subl %r15d, %edi
movq %r15, %r14
addq %r12, %r14
movq %r14, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0xb859
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incl %eax
cmpb $0x0, (%r14)
leaq 0x1(%r14), %r14
jne 0x464e4
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
addl %r15d, %eax
movl %eax, -0x2c(%rbp)
movq (%rbx), %rdx
movq -0x40(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x4b9b1
movsbq 0x29(%rbx), %rax
leaq 0x4cf29(%rip), %rcx     # 0x93440
movq -0x308(%rcx,%rax,8), %rsi
movq $-0x1, %r13
cmpb $0x0, 0x1(%rsi,%r13)
leaq 0x1(%r13), %r13
jne 0x46526
andl $0x3fffffff, %r13d      # imm = 0x3FFFFFFF
movslq -0x2c(%rbp), %r14
movq %r14, %rdi
movq -0x40(%rbp), %r12
addq %r12, %rdi
movq %r13, %rdx
callq 0x82f0
addl %r14d, %r13d
movl %r13d, -0x2c(%rbp)
movl -0x38(%rbp), %ecx
incl %ecx
addq $0x30, %rbx
movq -0x50(%rbp), %r15
movswl 0x42(%r15), %eax
movq -0x58(%rbp), %r13
cmpl %eax, %ecx
jl 0x464bf
movslq -0x2c(%rbp), %rax
movl -0x30(%rbp), %edi
subl %eax, %edi
movq %r12, %rsi
addq %rax, %rsi
leaq 0x3314f(%rip), %rdx     # 0x796d9
movq -0x48(%rbp), %rcx
xorl %eax, %eax
callq 0xb859
movq %r12, %rax
jmp 0x465a4
movq -0x38(%rbp), %rax
movb $0x1, 0x50(%rax)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq