// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movq %rcx, %r12
movq %rdx, %r14
movq %rdi, %rbx
cmpl $0x0, 0x14(%rdi)
sete %al
testq %rdx, %rdx
setne %cl
andb %al, %cl
movl %esi, %eax
shll %cl, %eax
movl 0x1c(%rdi), %edx
addl %eax, %edx
movl 0x10(%rdi), %ecx
cmpl %ecx, %edx
movl %esi, -0x30(%rbp)
jle 0x13296
leal (%rax,%rcx,2), %r13d
movl %r13d, 0x10(%rbx)
movq (%rbx), %r15
callq 0x9d1f
testl %eax, %eax
je 0x13278
xorl %eax, %eax
jmp 0x13287
shll $0x3, %r13d
movq %r15, %rdi
movl %r13d, %esi
callq 0xa37d
testq %rax, %rax
je 0x1339d
movq %rax, (%rbx)
movl -0x30(%rbp), %esi
cmpl $0x0, 0x14(%rbx)
je 0x132c8
cmpl %esi, 0x18(%rbx)
je 0x1330a
movq 0x8(%rbx), %rdi
callq 0xa2e8
leaq 0x678a2(%rip), %rdi     # 0x7ab53
xorl %eax, %eax
callq 0xb76d
movq %rax, 0x8(%rbx)
movl $0x1, 0x20(%rbx)
jmp 0x133a4
movl %esi, 0x18(%rbx)
testl %esi, %esi
jle 0x1330a
movl -0x30(%rbp), %r15d
xorl %r13d, %r13d
movq (%r12,%r13,8), %rsi
leaq 0x663f8(%rip), %rdi     # 0x796d9
xorl %eax, %eax
callq 0xb76d
testq %rax, %rax
je 0x1339d
movq (%rbx), %rcx
movslq 0x1c(%rbx), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x1c(%rbx)
movq %rax, (%rcx,%rdx,8)
incq %r13
cmpq %r13, %r15
jne 0x132d6
xorl %eax, %eax
testq %r14, %r14
je 0x133a9
movl -0x30(%rbp), %eax
testl %eax, %eax
jle 0x13396
movl %eax, %eax
movq %rax, -0x30(%rbp)
xorl %r12d, %r12d
movq (%r14,%r12,8), %rax
testq %rax, %rax
je 0x13358
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
incl %r15d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x13334
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
incl %r15d
callq 0x9d1f
testl %eax, %eax
je 0x1335d
xorl %r13d, %r13d
jmp 0x13368
xorl %r13d, %r13d
jmp 0x1337c
movl %r15d, %edi
callq 0xa2a2
movq %rax, %r13
testq %r13, %r13
je 0x1339d
movq (%r14,%r12,8), %rsi
movl %r15d, %edx
movq %r13, %rdi
callq 0x82f0
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 0x13325
incl 0x14(%rbx)
xorl %eax, %eax
jmp 0x133a9
movl $0x7, 0x20(%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq