// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r15
movq 0x240(%rdi), %r14
movq (%rdi), %r12
movq $0x0, 0x240(%rdi)
cmpl $0x0, 0x50(%rdi)
sete %al
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x445eb
movq %rdi, %r13
movq 0x28(%r14), %rax
testq %rax, %rax
movq %r12, -0x30(%rbp)
je 0x44306
movl 0x28(%r12), %ecx
testl %ecx, %ecx
jle 0x4430e
movq 0x20(%r12), %rsi
addq $0x18, %rsi
xorl %r12d, %r12d
cmpq %rax, (%rsi)
je 0x44311
incq %r12
addq $0x20, %rsi
cmpq %r12, %rcx
jne 0x442f0
movl %ecx, %r12d
jmp 0x44311
movl $0xfff0bdc0, %r12d      # imm = 0xFFF0BDC0
jmp 0x44311
xorl %r12d, %r12d
movq (%r14), %rcx
movq %r15, 0x38(%r14)
testq %r15, %r15
je 0x4432d
movq %r15, %rax
movq %r14, 0x8(%rax)
movq 0x40(%rax), %rax
testq %rax, %rax
jne 0x44320
movq %rcx, -0x58(%rbp)
testq %rcx, %rcx
movq %rcx, -0x40(%rbp)
movq %rdx, -0x38(%rbp)
je 0x44355
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incl %eax
cmpb $0x0, (%rcx)
leaq 0x1(%rcx), %rcx
jne 0x44343
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jmp 0x44357
xorl %eax, %eax
movl %eax, -0x50(%rbp)
testl %r12d, %r12d
sets %al
cmpl $0x1, %r12d
sete %cl
orb %al, %cl
jne 0x443f4
movl %r12d, %eax
shlq $0x5, %rax
movq %r13, -0x80(%rbp)
movq -0x30(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq (%rcx,%rax), %rdx
movq %rdx, -0x70(%rbp)
movq 0x18(%rcx,%rax), %rax
movq %rax, -0x78(%rbp)
leaq 0x38c33(%rip), %rax     # 0x7cfcd
movq %rax, -0x68(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
testq %r15, %r15
je 0x443f4
leaq -0x80(%rbp), %rbx
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0x4c1c9
testl %eax, %eax
jne 0x444be
movq 0x28(%r15), %rsi
movq %rbx, %rdi
callq 0x4c23d
testl %eax, %eax
jne 0x444be
movq 0x30(%r15), %rsi
movq %rbx, %rdi
callq 0x4c2a9
testl %eax, %eax
jne 0x444be
movq 0x40(%r15), %r15
testq %r15, %r15
jne 0x443af
movq -0x30(%rbp), %rax
cmpb $0x0, 0x99(%rax)
je 0x44445
movslq %r12d, %rbx
movq -0x30(%rbp), %r12
movq 0x20(%r12), %rax
shlq $0x5, %rbx
movq 0x18(%rax,%rbx), %rdi
addq $0x38, %rdi
movq -0x40(%rbp), %rsi
testq %rsi, %rsi
je 0x444ca
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rsi, %rax
incl %edx
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x4442f
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
jmp 0x444cc
movq %r13, %rdi
callq 0x45ece
testq %rax, %rax
je 0x444be
movq %rax, -0x48(%rbp)
movq 0x1d8(%r13), %rbx
testq %rbx, %rbx
cmoveq %r13, %rbx
movq %r13, %rdi
movl %r12d, %esi
callq 0x4632f
movl $0x1, %eax
movl %r12d, %ecx
shll %cl, %eax
orl %eax, 0x164(%rbx)
movq -0x38(%rbp), %rax
movq (%rax), %rbx
testq %rbx, %rbx
je 0x44503
movslq 0x8(%rax), %r15
leal 0x1(%r15), %esi
movq -0x30(%rbp), %rdi
callq 0x11721
testq %rax, %rax
je 0x44503
movq %rax, %rdi
movq %rax, -0x38(%rbp)
movq %rbx, %rsi
movq %r15, %rdx
callq 0x82f0
movq -0x38(%rbp), %rsi
movb $0x0, (%rsi,%r15)
jmp 0x44505
xorl %r15d, %r15d
movq -0x30(%rbp), %r12
jmp 0x445eb
xorl %edx, %edx
movq %r14, %rcx
callq 0x34400
testq %rax, %rax
je 0x444ea
movb $0x1, 0x50(%r12)
xorl %r15d, %r15d
movq %rax, %r14
jmp 0x445eb
movq 0x30(%r14), %rdi
xorl %r15d, %r15d
cmpq %rdi, 0x28(%r14)
je 0x445a8
xorl %r14d, %r14d
jmp 0x445eb
xorl %esi, %esi
movq %rsi, -0x38(%rbp)
movslq %r12d, %rbx
movq %rbx, %rax
shlq $0x5, %rax
cmpl $0x1, %r12d
movq -0x30(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq (%rcx,%rax), %rdx
leaq 0x359ef(%rip), %rax     # 0x79f19
leaq 0x359fb(%rip), %rcx     # 0x79f2c
cmoveq %rax, %rcx
movq 0x8(%r14), %r9
movq %rsi, (%rsp)
leaq 0x37faa(%rip), %rsi     # 0x7c4ee
xorl %r15d, %r15d
movq %r13, %rdi
movq -0x40(%rbp), %r8
xorl %eax, %eax
callq 0x468e4
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x9ca4
movq %r13, %rdi
movl %r12d, %esi
callq 0x46a12
leaq 0x37fba(%rip), %rsi     # 0x7c52e
movq -0x30(%rbp), %r13
movq %r13, %rdi
movq -0x40(%rbp), %rdx
xorl %eax, %eax
callq 0x11900
movq -0x48(%rbp), %rdi
movl %r12d, %esi
movq %r13, %r12
movq %rax, %rdx
callq 0x46acc
cmpb $0x0, 0x99(%r13)
jne 0x44408
jmp 0x445eb
movq 0x8(%r14), %rsi
testq %rsi, %rsi
je 0x445cd
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rsi, %rax
incl %r15d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x445ba
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
addq $0x8, %rdi
movl %r15d, %edx
callq 0x3406c
movq 0x60(%rax), %rcx
movq %rcx, 0x40(%r14)
movq %r14, 0x60(%rax)
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %r12, %rdi
movq %r14, %rsi
callq 0x991b
movq %r12, %rdi
movq %r15, %rsi
callq 0x3763a
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq