// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3_exec
SQLITE_API int sqlite3_exec(
  sqlite3 *db,                /* The database on which the SQL executes */
  const char *zSql,           /* The SQL to be executed */
  sqlite3_callback xCallback, /* Invoke this callback routine */
  void *pArg,                 /* First argument to xCallback() */
  char **pzErrMsg             /* Write error messages here */
){
  int rc = SQLITE_OK;         /* Return code */
  const char *zLeftover;      /* Tail of unprocessed SQL */
  sqlite3_stmt *pStmt = 0;    /* The current SQL statement */
  char **azCols = 0;          /* Names of result columns */
  int callbackIsInit;         /* True if callback data is initialized */

  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
  if( zSql==0 ) zSql = "";

  sqlite3_mutex_enter(db->mutex);
  sqlite3Error(db, SQLITE_OK, 0);
  while( rc==SQLITE_OK && zSql[0] ){
    int nCol;
    char **azVals = 0;

    pStmt = 0;
    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
    assert( rc==SQLITE_OK || pStmt==0 );
    if( rc!=SQLITE_OK ){
      continue;
    }
    if( !pStmt ){
      /* this happens for a comment or white-space */
      zSql = zLeftover;
      continue;
    }

    callbackIsInit = 0;
    nCol = sqlite3_column_count(pStmt);

    while( 1 ){
      int i;
      rc = sqlite3_step(pStmt);

      /* Invoke the callback function if required */
      if( xCallback && (SQLITE_ROW==rc || 
          (SQLITE_DONE==rc && !callbackIsInit
                           && db->flags&SQLITE_NullCallback)) ){
        if( !callbackIsInit ){
          azCols = sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1);
          if( azCols==0 ){
            goto exec_out;
          }
          for(i=0; i<nCol; i++){
            azCols[i] = (char *)sqlite3_column_name(pStmt, i);
            /* sqlite3VdbeSetColName() installs column names as UTF8
            ** strings so there is no way for sqlite3_column_name() to fail. */
            assert( azCols[i]!=0 );
          }
          callbackIsInit = 1;
        }
        if( rc==SQLITE_ROW ){
          azVals = &azCols[nCol];
          for(i=0; i<nCol; i++){
            azVals[i] = (char *)sqlite3_column_text(pStmt, i);
            if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){
              db->mallocFailed = 1;
              goto exec_out;
            }
          }
        }
        if( xCallback(pArg, nCol, azVals, azCols) ){
          rc = SQLITE_ABORT;
          sqlite3VdbeFinalize((Vdbe *)pStmt);
          pStmt = 0;
          sqlite3Error(db, SQLITE_ABORT, 0);
          goto exec_out;
        }
      }

      if( rc!=SQLITE_ROW ){
        rc = sqlite3VdbeFinalize((Vdbe *)pStmt);
        pStmt = 0;
        zSql = zLeftover;
        while( sqlite3Isspace(zSql[0]) ) zSql++;
        break;
      }
    }

    sqlite3DbFree(db, azCols);
    azCols = 0;
  }

exec_out:
  if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);
  sqlite3DbFree(db, azCols);

  rc = sqlite3ApiExit(db, rc);
  if( rc!=SQLITE_OK && ALWAYS(rc==sqlite3_errcode(db)) && pzErrMsg ){
    int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db));
    *pzErrMsg = sqlite3Malloc(nErrMsg);
    if( *pzErrMsg ){
      memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg);
    }else{
      rc = SQLITE_NOMEM;
      sqlite3Error(db, SQLITE_NOMEM, 0);
    }
  }else if( pzErrMsg ){
    *pzErrMsg = 0;
  }

  assert( (rc&db->errMask)==rc );
  sqlite3_mutex_leave(db->mutex);
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r12
movq %rcx, -0x68(%rbp)
movq %rdx, -0x58(%rbp)
movq %rsi, %r14
movq %rdi, %r15
movq $0x0, -0x38(%rbp)
callq 0x12bc6
testl %eax, %eax
je 0x12a80
testq %r14, %r14
leaq 0x6bb02(%rip), %rbx     # 0x7e3b0
cmovneq %r14, %rbx
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xca2d
leaq -0x50(%rbp), %r13
movq %r15, %r14
movq %r15, -0x48(%rbp)
movq %r12, -0x40(%rbp)
cmpb $0x0, (%rbx)
je 0x12aec
movq $0x0, -0x38(%rbp)
movq %r13, (%rsp)
movq %r14, %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
xorl %r8d, %r8d
leaq -0x38(%rbp), %r9
callq 0x12ed6
testl %eax, %eax
jne 0x12a7b
movq -0x38(%rbp), %rax
testq %rax, %rax
je 0x12a6d
movzwl 0x48(%rax), %r12d
movl %r12d, %eax
shll $0x4, %eax
incq %rax
movq %rax, -0x60(%rbp)
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r13d, %r13d
movq -0x38(%rbp), %rdi
callq 0xf576
cmpq $0x0, -0x58(%rbp)
je 0x12a1d
cmpl $0x64, %eax
movl %eax, -0x2c(%rbp)
jne 0x12951
testl %ebx, %ebx
jne 0x129c1
jmp 0x1296d
cmpl $0x65, %eax
jne 0x12a26
testl %ebx, %ebx
jne 0x12a26
testb $0x1, 0x2d(%r14)
je 0x12a26
movq %r14, %rdi
movq -0x60(%rbp), %rbx
movl %ebx, %esi
callq 0x11721
testq %rax, %rax
je 0x12ae6
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x8200
testq %r12, %r12
je 0x129b7
movq -0x38(%rbp), %rbx
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x10889
movq %rax, (%r15,%r14,8)
incq %r14
cmpq %r14, %r12
jne 0x129a0
cmpl $0x64, -0x2c(%rbp)
movq -0x48(%rbp), %r14
jne 0x129fd
leaq (%r15,%r12,8), %r13
testq %r12, %r12
je 0x129fd
xorl %ebx, %ebx
movq -0x38(%rbp), %rdi
movl %ebx, %esi
callq 0x10789
movq %rax, (%r13,%rbx,8)
testq %rax, %rax
jne 0x129f5
movq -0x38(%rbp), %rdi
movl %ebx, %esi
callq 0x10854
cmpl $0x5, %eax
jne 0x12aa9
incq %rbx
cmpq %rbx, %r12
jne 0x129cc
movq -0x68(%rbp), %rdi
movl %r12d, %esi
movq %r13, %rdx
movq %r15, %rcx
callq *-0x58(%rbp)
movl $0x1, %ebx
testl %eax, %eax
jne 0x12abb
movl -0x2c(%rbp), %eax
cmpl $0x64, %eax
je 0x1292f
movq -0x38(%rbp), %rdi
callq 0xeac6
movl %eax, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x50(%rbp), %rbx
decq %rbx
movq -0x40(%rbp), %r12
leaq 0x63564(%rip), %rcx     # 0x75fb0
movzbl 0x1(%rbx), %eax
incq %rbx
testb $0x1, (%rax,%rcx)
jne 0x12a4c
movq %r14, %rdi
movq %r15, %rsi
callq 0x9ca4
leaq -0x50(%rbp), %r13
movl -0x2c(%rbp), %eax
jmp 0x12a73
xorl %eax, %eax
movq -0x50(%rbp), %rbx
testl %eax, %eax
je 0x128cf
movl %eax, -0x2c(%rbp)
jmp 0x12af3
leaq 0x6a95d(%rip), %rsi     # 0x7d3e4
leaq 0x66aab(%rip), %rcx     # 0x79539
movl $0x15, %ebx
movl $0x15, %edi
movl $0x168da, %edx          # imm = 0x168DA
xorl %eax, %eax
callq 0xb9c7
jmp 0x12bb5
movb $0x1, 0x50(%r14)
movl $0x64, -0x2c(%rbp)
movq -0x40(%rbp), %r12
jmp 0x12af6
movq -0x38(%rbp), %rdi
callq 0xeac6
movq $0x0, -0x38(%rbp)
movl $0x4, -0x2c(%rbp)
movq %r14, %rdi
movl $0x4, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xca2d
jmp 0x12ab5
movq -0x40(%rbp), %r12
jmp 0x12af3
movl $0x0, -0x2c(%rbp)
xorl %r15d, %r15d
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x12b04
callq 0xeac6
movq %r14, %rdi
movq %r15, %rsi
callq 0x9ca4
movq %r14, %rdi
movl -0x2c(%rbp), %esi
callq 0xeaff
movl %eax, %ebx
testl %eax, %eax
je 0x12b5c
movq %r14, %rdi
callq 0x12c49
testq %r12, %r12
je 0x12b5c
cmpl %eax, %ebx
jne 0x12b5c
movq %r14, %rdi
callq 0x12cc6
testq %rax, %rax
je 0x12b6b
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
incl %r14d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x12b44
andl $0x3fffffff, %r14d      # imm = 0x3FFFFFFF
incl %r14d
jmp 0x12b71
testq %r12, %r12
je 0x12bb5
movq $0x0, (%r12)
jmp 0x12bb5
movl $0x1, %r14d
movl %r14d, %edi
callq 0xa38c
movq %rax, (%r12)
testq %rax, %rax
je 0x12b9e
movq %rax, %r15
movq -0x48(%rbp), %rdi
callq 0x12cc6
movl %r14d, %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x82f0
jmp 0x12bb5
movl $0x7, %ebx
movq -0x48(%rbp), %rdi
movl $0x7, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xca2d
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq