// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3FinishTrigger
SQLITE_PRIVATE void sqlite3FinishTrigger(
  Parse *pParse,          /* Parser context */
  TriggerStep *pStepList, /* The triggered program */
  Token *pAll             /* Token that describes the complete CREATE TRIGGER */
){
  Trigger *pTrig = pParse->pNewTrigger;   /* Trigger being finished */
  char *zName;                            /* Name of trigger */
  sqlite3 *db = pParse->db;               /* The database */
  DbFixer sFix;                           /* Fixer object */
  int iDb;                                /* Database containing the trigger */
  Token nameToken;                        /* Trigger name for error reporting */

  pParse->pNewTrigger = 0;
  if( NEVER(pParse->nErr) || !pTrig ) goto triggerfinish_cleanup;
  zName = pTrig->zName;
  iDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);
  pTrig->step_list = pStepList;
  while( pStepList ){
    pStepList->pTrig = pTrig;
    pStepList = pStepList->pNext;
  }
  nameToken.z = pTrig->zName;
  nameToken.n = sqlite3Strlen30(nameToken.z);
  if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", &nameToken) 
          && sqlite3FixTriggerStep(&sFix, pTrig->step_list) ){
    goto triggerfinish_cleanup;
  }

  /* if we are not initializing,
  ** build the sqlite_master entry
  */
  if( !db->init.busy ){
    Vdbe *v;
    char *z;

    /* Make an entry in the sqlite_master table */
    v = sqlite3GetVdbe(pParse);
    if( v==0 ) goto triggerfinish_cleanup;
    sqlite3BeginWriteOperation(pParse, 0, iDb);
    z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);
    sqlite3NestedParse(pParse,
       "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",
       db->aDb[iDb].zName, SCHEMA_TABLE(iDb), zName,
       pTrig->table, z);
    sqlite3DbFree(db, z);
    sqlite3ChangeCookie(pParse, iDb);
    sqlite3VdbeAddParseSchemaOp(v, iDb,
        sqlite3MPrintf(db, "type='trigger' AND name='%q'", zName));
  }

  if( db->init.busy ){
    Trigger *pLink = pTrig;
    Hash *pHash = &db->aDb[iDb].pSchema->trigHash;
    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
    pTrig = sqlite3HashInsert(pHash, zName, sqlite3Strlen30(zName), pTrig);
    if( pTrig ){
      db->mallocFailed = 1;
    }else if( pLink->pSchema==pLink->pTabSchema ){
      Table *pTab;
      int n = sqlite3Strlen30(pLink->table);
      pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table, n);
      assert( pTab!=0 );
      pLink->pNext = pTab->pTrigger;
      pTab->pTrigger = pLink;
    }
  }

triggerfinish_cleanup:
  sqlite3DeleteTrigger(db, pTrig);
  assert( !pParse->pNewTrigger );
  sqlite3DeleteTriggerStep(db, pStepList);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x240(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, 0x240(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x50(%rax)
jne 0x5bf11
cmpq $0x0, -0x20(%rbp)
jne 0x5bf16
jmp 0x5c1cf
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x13940
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x38(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x5bf65
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x5bf44
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x92f0
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rsi
movl -0x5c(%rbp), %edx
leaq -0x58(%rbp), %rdi
leaq 0x55b48(%rip), %rcx     # 0xb1ad6
leaq -0x70(%rbp), %r8
callq 0x66d20
cmpl $0x0, %eax
je 0x5bfb7
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rsi
leaq -0x58(%rbp), %rdi
callq 0x827d0
cmpl $0x0, %eax
je 0x5bfb7
jmp 0x5c1cf
movq -0x30(%rbp), %rax
cmpb $0x0, 0x99(%rax)
jne 0x5c0b6
movq -0x8(%rbp), %rdi
callq 0x5e000
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x5bfe1
jmp 0x5c1cf
movq -0x8(%rbp), %rdi
movl -0x5c(%rbp), %edx
xorl %esi, %esi
callq 0x5ec70
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x4a7a0
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x5c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movl -0x5c(%rbp), %esi
leaq 0x529fa(%rip), %rcx     # 0xaea28
leaq 0x529e0(%rip), %rax     # 0xaea15
cmpl $0x1, %esi
cmoveq %rax, %rcx
movq -0x28(%rbp), %r8
movq -0x20(%rbp), %rax
movq 0x8(%rax), %r9
movq -0x80(%rbp), %rax
leaq 0x54f97(%rip), %rsi     # 0xb0fea
movq %rax, (%rsp)
movb $0x0, %al
callq 0x5f320
movq -0x30(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x9cd0
movq -0x8(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x5f4a0
movq -0x78(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0xa0(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x54f90(%rip), %rsi     # 0xb102a
movb $0x0, %al
callq 0x137f0
movq -0xa8(%rbp), %rdi
movl -0xa0(%rbp), %esi
movq %rax, %rdx
callq 0x5f530
movq -0x30(%rbp), %rax
cmpb $0x0, 0x99(%rax)
je 0x5c1cd
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x5c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
addq $0x38, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x28(%rbp), %rdi
callq 0x92f0
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movl %eax, %edx
movq -0x20(%rbp), %rcx
callq 0x46e00
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x5c147
movq -0x30(%rbp), %rax
movb $0x1, 0x50(%rax)
jmp 0x5c1cb
movq -0x88(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x88(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jne 0x5c1c9
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x92f0
movl %eax, -0x9c(%rbp)
movq -0x88(%rbp), %rax
movq 0x30(%rax), %rdi
addq $0x8, %rdi
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x9c(%rbp), %edx
callq 0x468b0
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq 0x60(%rax), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x88(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x60(%rax)
jmp 0x5c1cb
jmp 0x5c1cd
jmp 0x5c1cf
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x99b0
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x4c2e0
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)