// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rcx, %r12
movq %rdx, -0x58(%rbp)
movq %rsi, %r14
movq %rdi, %r15
andq $0x0, -0x30(%rbp)
callq 0x116ef
testl %eax, %eax
je 0x11679
movq %rbx, -0x68(%rbp)
testq %r14, %r14
leaq 0x5ef22(%rip), %rbx     # 0x70345
cmovneq %r14, %rbx
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xbdb1
pushq $-0x1
popq %r14
xorl %r13d, %r13d
testl %r13d, %r13d
jne 0x115e6
cmpb $0x0, (%rbx)
je 0x115e6
andq $0x0, -0x30(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
movl %r14d, %edx
leaq -0x30(%rbp), %rcx
leaq -0x60(%rbp), %r8
callq 0x11728
movl %eax, %r13d
testl %eax, %eax
jne 0x1143c
movq -0x30(%rbp), %rax
testq %rax, %rax
je 0x115dd
movq %r12, -0x50(%rbp)
movq %r15, -0x38(%rbp)
movzwl 0x48(%rax), %r15d
movl %r15d, %eax
shll $0x4, %eax
incl %eax
movl %eax, -0x44(%rbp)
xorl %r12d, %r12d
xorl %r14d, %r14d
movq $0x0, -0x40(%rbp)
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0xe65d
movl %eax, %r13d
cmpq $0x0, -0x58(%rbp)
je 0x11588
cmpl $0x64, %r13d
jne 0x114ca
testl %r14d, %r14d
jne 0x11525
jmp 0x114eb
cmpl $0x65, %r13d
jne 0x11596
testl %r14d, %r14d
jne 0x11596
movq -0x38(%rbp), %rax
testb $0x1, 0x2d(%rax)
je 0x11596
movq -0x38(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0xf4ae
testq %rax, %rax
je 0x116e3
movq %rax, %r12
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x1151f
movq %rbx, %rdi
movl %r14d, %esi
callq 0xf73d
movq %rax, (%r12,%r14,8)
incq %r14
jmp 0x11506
cmpl $0x64, %r13d
jne 0x1156b
leaq (%r12,%r15,8), %rax
movq %rax, -0x40(%rbp)
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x1156b
movq -0x30(%rbp), %rdi
movl %r14d, %esi
callq 0xf68b
movq -0x40(%rbp), %rcx
movq %rax, (%rcx,%r14,8)
testq %rax, %rax
jne 0x11566
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %esi
callq 0xf719
cmpl $0x5, %eax
jne 0x11697
incq %r14
jmp 0x11530
movq -0x50(%rbp), %rdi
movl %r15d, %esi
movq -0x40(%rbp), %rdx
movq %r12, %rcx
callq *-0x58(%rbp)
testl %eax, %eax
jne 0x116b9
pushq $0x1
popq %r14
cmpl $0x64, %r13d
je 0x114a3
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0xdc20
andq $0x0, -0x30(%rbp)
movl %eax, %r13d
movq -0x60(%rbp), %rbx
decq %rbx
movq -0x38(%rbp), %r15
pushq $-0x1
popq %r14
leaq 0x569b4(%rip), %rcx     # 0x67f70
movzbl 0x1(%rbx), %eax
incq %rbx
testb $0x1, (%rax,%rcx)
jne 0x115bc
movq %r15, %rdi
movq %r12, %rsi
callq 0x968b
movq -0x50(%rbp), %r12
jmp 0x1143c
movq -0x60(%rbp), %rbx
jmp 0x11439
movq -0x30(%rbp), %rbx
xorl %r12d, %r12d
testq %rbx, %rbx
je 0x115fa
movq %rbx, %rdi
callq 0xdc20
movq %r15, %rdi
movq %r12, %rsi
callq 0x968b
movq %r15, %rdi
movl %r13d, %esi
callq 0xdc59
movl %eax, %ebx
testl %eax, %eax
movq -0x68(%rbp), %r12
je 0x1166d
movq %r15, %rdi
callq 0x11748
testq %r12, %r12
je 0x1166d
cmpl %eax, %ebx
jne 0x1166d
movq %r15, %rdi
callq 0x11788
movq %rax, %rdi
callq 0x8f8e
movl %eax, %r14d
incl %r14d
movl %r14d, %edi
callq 0x9c40
movq %r15, %rdi
movq %rax, (%r12)
testq %rax, %rax
je 0x116a9
movq %rax, %r15
callq 0x11788
movl %r14d, %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x82c0
jmp 0x11686
testq %r12, %r12
je 0x11686
andq $0x0, (%r12)
jmp 0x11686
movl $0x168da, %edi          # imm = 0x168DA
callq 0x9008
pushq $0x15
popq %rbx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x38(%rbp), %r15
movb $0x1, 0x50(%r15)
pushq $0x64
popq %r13
jmp 0x115ed
pushq $0x7
popq %rbx
movl %ebx, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xbdb1
jmp 0x11686
movq -0x30(%rbp), %rdi
callq 0xdc20
andq $0x0, -0x30(%rbp)
pushq $0x4
popq %r13
movq -0x38(%rbp), %r15
movq %r15, %rdi
movl %r13d, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xbdb1
jmp 0x115fa
xorl %r12d, %r12d
movq -0x38(%rbp), %r15
jmp 0x115ed