// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3_get_table
SQLITE_API int sqlite3_get_table(
  sqlite3 *db,                /* The database on which the SQL executes */
  const char *zSql,           /* The SQL to be executed */
  char ***pazResult,          /* Write the result table here */
  int *pnRow,                 /* Write the number of rows in the result here */
  int *pnColumn,              /* Write the number of columns of result here */
  char **pzErrMsg             /* Write error messages here */
){
  int rc;
  TabResult res;

  *pazResult = 0;
  if( pnColumn ) *pnColumn = 0;
  if( pnRow ) *pnRow = 0;
  if( pzErrMsg ) *pzErrMsg = 0;
  res.zErrMsg = 0;
  res.nRow = 0;
  res.nColumn = 0;
  res.nData = 1;
  res.nAlloc = 20;
  res.rc = SQLITE_OK;
  res.azResult = sqlite3_malloc(sizeof(char*)*res.nAlloc );
  if( res.azResult==0 ){
     db->errCode = SQLITE_NOMEM;
     return SQLITE_NOMEM;
  }
  res.azResult[0] = 0;
  rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);
  assert( sizeof(res.azResult[0])>= sizeof(res.nData) );
  res.azResult[0] = SQLITE_INT_TO_PTR(res.nData);
  if( (rc&0xff)==SQLITE_ABORT ){
    sqlite3_free_table(&res.azResult[1]);
    if( res.zErrMsg ){
      if( pzErrMsg ){
        sqlite3_free(*pzErrMsg);
        *pzErrMsg = sqlite3_mprintf("%s",res.zErrMsg);
      }
      sqlite3_free(res.zErrMsg);
    }
    db->errCode = res.rc;  /* Assume 32-bit assignment is atomic */
    return res.rc;
  }
  sqlite3_free(res.zErrMsg);
  if( rc!=SQLITE_OK ){
    sqlite3_free_table(&res.azResult[1]);
    return rc;
  }
  if( res.nAlloc>res.nData ){
    char **azNew;
    azNew = sqlite3_realloc( res.azResult, sizeof(char*)*res.nData );
    if( azNew==0 ){
      sqlite3_free_table(&res.azResult[1]);
      db->errCode = SQLITE_NOMEM;
      return SQLITE_NOMEM;
    }
    res.azResult = azNew;
  }
  *pazResult = &res.azResult[1];
  if( pnColumn ) *pnColumn = res.nColumn;
  if( pnRow ) *pnRow = res.nRow;
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r13
movq %r8, %r15
movq %rcx, %r14
movq %rsi, %rbx
movq %rdi, %r12
movq %rdx, -0x60(%rbp)
movq $0x0, (%rdx)
testq %r8, %r8
je 0x1308b
movl $0x0, (%r15)
testq %r14, %r14
je 0x13097
movl $0x0, (%r14)
testq %r13, %r13
je 0x130a4
movq $0x0, (%r13)
movq $0x0, -0x50(%rbp)
movaps 0x662ed(%rip), %xmm0    # 0x793a0
movups %xmm0, -0x48(%rbp)
movl $0x0, -0x38(%rbp)
callq 0x9d1f
testl %eax, %eax
je 0x130cb
xorl %eax, %eax
jmp 0x130d5
movl $0xa0, %edi
callq 0xa2a2
movq %rax, -0x58(%rbp)
testq %rax, %rax
je 0x1316d
movq $0x0, (%rax)
leaq 0x137(%rip), %rdx       # 0x13227
movq %r12, %rdi
leaq -0x58(%rbp), %r12
movq %rdi, -0x30(%rbp)
movq %rbx, %rsi
movq %r12, %rcx
movq %r13, %r8
callq 0x12763
movl %eax, %ebx
movslq 0x1c(%r12), %rax
movq (%r12), %rcx
movq %rax, (%rcx)
cmpb $0x4, %bl
jne 0x13180
movq -0x58(%rbp), %rdi
addq $0x8, %rdi
callq 0x133b8
cmpq $0x0, -0x50(%rbp)
movq -0x30(%rbp), %r14
je 0x13161
testq %r13, %r13
je 0x13158
movq (%r13), %rdi
callq 0xa2e8
movq -0x50(%rbp), %rsi
leaq 0x6658c(%rip), %rdi     # 0x796d9
xorl %eax, %eax
callq 0xb76d
movq %rax, (%r13)
movq -0x50(%rbp), %rdi
callq 0xa2e8
movl -0x38(%rbp), %ebx
movl %ebx, 0x44(%r14)
jmp 0x13216
movl $0x7, 0x44(%r12)
movl $0x7, %ebx
jmp 0x13216
movq -0x50(%rbp), %rdi
callq 0xa2e8
testl %ebx, %ebx
je 0x1319c
movq -0x58(%rbp), %rdi
addq $0x8, %rdi
callq 0x133b8
jmp 0x13216
movl -0x3c(%rbp), %ebx
cmpl %ebx, -0x48(%rbp)
jle 0x131ef
movq -0x58(%rbp), %r13
callq 0x9d1f
testl %eax, %eax
je 0x131b5
xorl %ebx, %ebx
jmp 0x131c5
shll $0x3, %ebx
movq %r13, %rdi
movl %ebx, %esi
callq 0xa37d
movq %rax, %rbx
movq -0x30(%rbp), %r12
testq %rbx, %rbx
je 0x131d4
movq %rbx, -0x58(%rbp)
jmp 0x131ea
movq -0x58(%rbp), %rdi
addq $0x8, %rdi
callq 0x133b8
movl $0x7, 0x44(%r12)
testq %rbx, %rbx
je 0x13176
movq -0x58(%rbp), %rax
addq $0x8, %rax
movq -0x60(%rbp), %rcx
movq %rax, (%rcx)
testq %r15, %r15
je 0x13209
movl -0x40(%rbp), %eax
movl %eax, (%r15)
xorl %ebx, %ebx
testq %r14, %r14
je 0x13216
movl -0x44(%rbp), %eax
movl %eax, (%r14)
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq