// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3_get_table_cb
static int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
  TabResult *p = (TabResult*)pArg;  /* Result accumulator */
  int need;                         /* Slots needed in p->azResult[] */
  int i;                            /* Loop counter */
  char *z;                          /* A single column of result */

  /* Make sure there is enough space in p->azResult to hold everything
  ** we need to remember from this invocation of the callback.
  */
  if( p->nRow==0 && argv!=0 ){
    need = nCol*2;
  }else{
    need = nCol;
  }
  if( p->nData + need > p->nAlloc ){
    char **azNew;
    p->nAlloc = p->nAlloc*2 + need;
    azNew = sqlite3_realloc( p->azResult, sizeof(char*)*p->nAlloc );
    if( azNew==0 ) goto malloc_failed;
    p->azResult = azNew;
  }

  /* If this is the first row, then generate an extra row containing
  ** the names of all columns.
  */
  if( p->nRow==0 ){
    p->nColumn = nCol;
    for(i=0; i<nCol; i++){
      z = sqlite3_mprintf("%s", colv[i]);
      if( z==0 ) goto malloc_failed;
      p->azResult[p->nData++] = z;
    }
  }else if( p->nColumn!=nCol ){
    sqlite3_free(p->zErrMsg);
    p->zErrMsg = sqlite3_mprintf(
       "sqlite3_get_table() called with two or more incompatible queries"
    );
    p->rc = SQLITE_ERROR;
    return 1;
  }

  /* Copy over the row data
  */
  if( argv!=0 ){
    for(i=0; i<nCol; i++){
      if( argv[i]==0 ){
        z = 0;
      }else{
        int n = sqlite3Strlen30(argv[i])+1;
        z = sqlite3_malloc( n );
        if( z==0 ) goto malloc_failed;
        memcpy(z, argv[i], n);
      }
      p->azResult[p->nData++] = z;
    }
    p->nRow++;
  }
  return 0;

malloc_failed:
  p->rc = SQLITE_NOMEM;
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rdx, %r14
movq %rdi, %rbx
movl 0x14(%rdi), %eax
testl %eax, %eax
sete %dl
testq %r14, %r14
setne %cl
andb %dl, %cl
movl %esi, %edx
shll %cl, %edx
movl 0x10(%rdi), %ecx
movl 0x1c(%rdi), %edi
addl %edx, %edi
cmpl %ecx, %edi
jle 0x1339d
movl %esi, %r15d
leal (%rdx,%rcx,2), %r13d
movl %r13d, 0x10(%rbx)
movq (%rbx), %rax
movq %rax, -0x38(%rbp)
callq 0x9d86
testl %eax, %eax
je 0x1337f
movl $0x7, 0x20(%rbx)
jmp 0x133cb
shll $0x3, %r13d
movq -0x38(%rbp), %rdi
movl %r13d, %esi
callq 0xa45c
testq %rax, %rax
je 0x13376
movq %rax, (%rbx)
movl 0x14(%rbx), %eax
movl %r15d, %esi
testl %eax, %eax
movl %esi, -0x30(%rbp)
je 0x133df
cmpl %esi, 0x18(%rbx)
je 0x13421
movq 0x8(%rbx), %rdi
callq 0xa3c7
leaq 0x6779a(%rip), %rdi     # 0x7ab53
xorl %eax, %eax
callq 0xb868
movq %rax, 0x8(%rbx)
movl $0x1, 0x20(%rbx)
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, 0x18(%rbx)
testl %esi, %esi
jle 0x13421
movl -0x30(%rbp), %r13d
xorl %r15d, %r15d
movq (%r12,%r15,8), %rsi
leaq 0x662e1(%rip), %rdi     # 0x796d9
xorl %eax, %eax
callq 0xb868
testq %rax, %rax
je 0x13376
movq (%rbx), %rcx
movslq 0x1c(%rbx), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x1c(%rbx)
movq %rax, (%rcx,%rdx,8)
incq %r15
cmpq %r15, %r13
jne 0x133ed
xorl %eax, %eax
testq %r14, %r14
je 0x133d0
movl -0x30(%rbp), %eax
testl %eax, %eax
jle 0x134ac
movl %eax, %eax
movq %rax, -0x30(%rbp)
xorl %r12d, %r12d
movq (%r14,%r12,8), %rax
testq %rax, %rax
je 0x1348f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
incl %r15d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x13447
callq 0x9d86
testl %eax, %eax
jne 0x13376
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
incl %r15d
movl %r15d, %edi
callq 0xa38c
testq %rax, %rax
je 0x13376
movq %rax, %r13
movq (%r14,%r12,8), %rsi
movl %r15d, %edx
movq %rax, %rdi
callq 0x82f0
jmp 0x13492
xorl %r13d, %r13d
movq (%rbx), %rax
movslq 0x1c(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x1c(%rbx)
movq %r13, (%rax,%rcx,8)
incq %r12
cmpq -0x30(%rbp), %r12
jne 0x13438
incl 0x14(%rbx)
xorl %eax, %eax
jmp 0x133d0