// File: /workspace/github_c_makefile_star2_O2/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 %rdi, %rbx
movl 0x14(%rdi), %eax
testl %eax, %eax
sete %dil
movq %rdx, -0x38(%rbp)
testq %rdx, %rdx
setne %cl
andb %dil, %cl
movq %rsi, %rdx
movq %rsi, -0x30(%rbp)
shll %cl, %edx
movl 0x10(%rbx), %ecx
movl 0x1c(%rbx), %esi
addl %edx, %esi
cmpl %ecx, %esi
jle 0x11cfe
leal (%rdx,%rcx,2), %esi
movl %esi, 0x10(%rbx)
movq (%rbx), %rdi
shll $0x3, %esi
callq 0x9ce9
testq %rax, %rax
je 0x11dde
movq %rax, (%rbx)
movl 0x14(%rbx), %eax
testl %eax, %eax
je 0x11d8f
movq -0x30(%rbp), %rax
cmpl %eax, 0x18(%rbx)
jne 0x11de7
cmpq $0x0, -0x38(%rbp)
je 0x11e11
xorl %r15d, %r15d
movq -0x30(%rbp), %r14
testl %r14d, %r14d
cmovlel %r15d, %r14d
cmpq %r15, %r14
je 0x11e0e
movq -0x38(%rbp), %rax
movq (%rax,%r15,8), %rdi
testq %rdi, %rdi
je 0x11d76
callq 0x8f8e
movl %eax, %r13d
incl %r13d
movl %r13d, %edi
callq 0x9c1c
testq %rax, %rax
je 0x11dde
movq %rax, %r12
movq -0x38(%rbp), %rax
movq (%rax,%r15,8), %rsi
movl %r13d, %edx
movq %r12, %rdi
callq 0x82c0
jmp 0x11d79
xorl %r12d, %r12d
movq (%rbx), %rax
movslq 0x1c(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x1c(%rbx)
movq %r12, (%rax,%rcx,8)
incq %r15
jmp 0x11d2c
movq -0x30(%rbp), %rax
movl %eax, 0x18(%rbx)
testl %eax, %eax
movl $0x0, %r15d
cmovgl %eax, %r15d
leaq 0x59950(%rip), %r14     # 0x6b6f9
xorl %r13d, %r13d
cmpq %r13, %r15
je 0x11d13
movq (%r12,%r13,8), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0xae3e
testq %rax, %rax
je 0x11dde
movq (%rbx), %rcx
movslq 0x1c(%rbx), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x1c(%rbx)
movq %rax, (%rcx,%rdx,8)
incq %r13
jmp 0x11dac
movl $0x7, 0x20(%rbx)
jmp 0x11e09
movq 0x8(%rbx), %rdi
callq 0x9c7b
leaq 0x5ad7c(%rip), %rdi     # 0x6cb73
xorl %eax, %eax
callq 0xae3e
movq %rax, 0x8(%rbx)
movl $0x1, 0x20(%rbx)
pushq $0x1
popq %rax
jmp 0x11e13
incl 0x14(%rbx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq