// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %r8, %r14
movq %rcx, -0x78(%rbp)
movq %rdx, -0x68(%rbp)
movq %rsi, %rbx
movq %rdi, %r13
movq $0x0, -0x30(%rbp)
callq 0x12b2e
testl %eax, %eax
je 0x12a23
movq %r14, -0x60(%rbp)
testq %rbx, %rbx
leaq 0x6bbb8(%rip), %r14     # 0x7e360
cmovneq %rbx, %r14
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xc8f4
leaq -0x58(%rbp), %r15
leaq -0x30(%rbp), %r12
xorl %ebx, %ebx
movq %r13, -0x48(%rbp)
cmpb $0x0, (%r14)
je 0x12a4c
movq $0x0, -0x30(%rbp)
movq %r15, (%rsp)
movq %r13, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
xorl %r8d, %r8d
movq %r12, %r9
callq 0x12dde
movl $0x2, %edx
testl %eax, %eax
jne 0x12a10
movq -0x30(%rbp), %rcx
testq %rcx, %rcx
je 0x12a00
movq %rbx, -0x40(%rbp)
movzwl 0x48(%rcx), %ebx
movl %ebx, %eax
shll $0x4, %eax
incq %rax
movq %rax, -0x70(%rbp)
xorl %r12d, %r12d
movq $0x0, -0x50(%rbp)
movq -0x30(%rbp), %rdi
callq 0xf4d2
cmpq $0x0, -0x68(%rbp)
je 0x12970
cmpl $0x64, %eax
jne 0x1294d
testl %r12d, %r12d
movl %eax, -0x34(%rbp)
jne 0x128b2
movq %r13, %rdi
movq -0x70(%rbp), %r12
movl %r12d, %esi
callq 0x115e9
testq %rax, %rax
je 0x129ba
movq %rax, -0x40(%rbp)
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x8200
testq %rbx, %rbx
je 0x128af
movq -0x30(%rbp), %r13
xorl %r12d, %r12d
movq -0x40(%rbp), %r15
movq %r13, %rdi
movl %r12d, %esi
callq 0x10790
movq %rax, (%r15,%r12,8)
incq %r12
cmpq %r12, %rbx
jne 0x12890
movq -0x48(%rbp), %r13
leaq -0x58(%rbp), %r15
movl -0x34(%rbp), %eax
cmpl $0x64, %eax
movq -0x40(%rbp), %r12
jne 0x12905
leaq (%r12,%rbx,8), %rax
movq %rax, -0x50(%rbp)
testq %rbx, %rbx
je 0x12905
xorl %r13d, %r13d
movq -0x30(%rbp), %rdi
movl %r13d, %esi
callq 0x10690
movq -0x50(%rbp), %rcx
movq %rax, (%rcx,%r13,8)
testq %rax, %rax
jne 0x128f9
movq -0x30(%rbp), %rdi
movl %r13d, %esi
callq 0x1075b
cmpl $0x5, %eax
jne 0x129cf
incq %r13
cmpq %r13, %rbx
jne 0x128cb
movq -0x48(%rbp), %r13
movq -0x78(%rbp), %rdi
movl %ebx, %esi
movq -0x50(%rbp), %rdx
movq %r12, %rcx
callq *-0x68(%rbp)
testl %eax, %eax
je 0x12967
movq -0x30(%rbp), %rdi
callq 0xe9e9
movq $0x0, -0x30(%rbp)
movq %r13, %rdi
movl $0x4, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xc8f4
movl $0x4, %eax
movl $0x6, %edx
movl $0x1, %r12d
jmp 0x129b0
movl %eax, %ecx
xorl $0x65, %ecx
orl %r12d, %ecx
jne 0x12970
testb $0x1, 0x2d(%r13)
jne 0x1284f
xorl %r12d, %r12d
jmp 0x12970
movl $0x1, %r12d
movl -0x34(%rbp), %eax
cmpl $0x64, %eax
jne 0x1297e
xorl %edx, %edx
movl $0x64, %eax
jmp 0x129b0
movq -0x30(%rbp), %rdi
callq 0xe9e9
movq $0x0, -0x30(%rbp)
movq -0x58(%rbp), %r14
decq %r14
leaq 0x635c3(%rip), %rcx     # 0x75f60
movzbl 0x1(%r14), %edx
incq %r14
testb $0x1, (%rdx,%rcx)
jne 0x1299d
movl $0x5, %edx
testl %edx, %edx
je 0x12832
jmp 0x129e5
movl $0x6, %edx
movq $0x0, -0x40(%rbp)
xorl %r12d, %r12d
movl -0x34(%rbp), %eax
jmp 0x129b0
movq -0x48(%rbp), %r13
movb $0x1, 0x50(%r13)
movl $0x6, %edx
movl $0x1, %r12d
jmp 0x12977
cmpl $0x5, %edx
jne 0x12a08
movq %r13, %rdi
movl %eax, %ebx
movq -0x40(%rbp), %rsi
callq 0x9c3a
movl %ebx, %eax
xorl %ebx, %ebx
xorl %edx, %edx
jmp 0x12a0c
xorl %eax, %eax
movq -0x58(%rbp), %r14
jmp 0x12a10
movq -0x40(%rbp), %rbx
leaq -0x30(%rbp), %r12
testl %edx, %edx
je 0x12a19
cmpl $0x2, %edx
jne 0x12a50
testl %eax, %eax
je 0x127c8
jmp 0x12a55
leaq 0x6a9ba(%rip), %rsi     # 0x7d3e4
leaq 0x66b08(%rip), %rcx     # 0x79539
movl $0x15, %ebx
movl $0x15, %edi
movl $0x168da, %edx          # imm = 0x168DA
xorl %eax, %eax
callq 0xb8cc
jmp 0x12b1d
xorl %eax, %eax
jmp 0x12a55
cmpl $0x6, %edx
jne 0x12ad0
movl %eax, %r14d
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x12a66
callq 0xe9e9
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9c3a
movq %r13, %rdi
movl %r14d, %esi
callq 0xea22
movl %eax, %ebx
testl %eax, %eax
movq -0x60(%rbp), %r14
je 0x12ac2
movq %r13, %rdi
callq 0x12ba4
testq %r14, %r14
je 0x12ac2
cmpl %eax, %ebx
jne 0x12ac2
movq %r13, %rdi
callq 0x12bfd
testq %rax, %rax
je 0x12ad2
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
incl %r14d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x12aaa
andl $0x3fffffff, %r14d      # imm = 0x3FFFFFFF
incl %r14d
jmp 0x12ad8
testq %r14, %r14
je 0x12b1d
movq $0x0, (%r14)
jmp 0x12b1d
jmp 0x12b1d
movl $0x1, %r14d
movl %r14d, %edi
callq 0xa2a2
movq %rax, %r15
movq -0x60(%rbp), %rax
movq %r15, (%rax)
testq %r15, %r15
je 0x12b07
movq %r13, %rdi
callq 0x12bfd
movl %r14d, %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x82f0
jmp 0x12b1d
movl $0x7, %ebx
movq %r13, %rdi
movl $0x7, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0xc8f4
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq