// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/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;
  }
  sqlite3TokenInit(&nameToken, pTrig->zName);
  sqlite3FixInit(&sFix, pParse, iDb, "trigger", &nameToken);
  if( sqlite3FixTriggerStep(&sFix, pTrig->step_list)
   || sqlite3FixExpr(&sFix, pTrig->pWhen)
  ){
    goto triggerfinish_cleanup;
  }

#ifndef SQLITE_OMIT_ALTERTABLE
  if( IN_RENAME_OBJECT ){
    assert( !db->init.busy );
    pParse->pNewTrigger = pTrig;
    pTrig = 0;
  }else
#endif

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

    /* Make an entry in the sqlite_schema table */
    v = sqlite3GetVdbe(pParse);
    if( v==0 ) goto triggerfinish_cleanup;
    sqlite3BeginWriteOperation(pParse, 0, iDb);
    z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);
    testcase( z==0 );
    sqlite3NestedParse(pParse,
       "INSERT INTO %Q." DFLT_SCHEMA_TABLE
       " VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",
       db->aDb[iDb].zDbSName, 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) );
    assert( pLink!=0 );
    pTrig = sqlite3HashInsert(pHash, zName, pTrig);
    if( pTrig ){
      sqlite3OomFault(db);
    }else if( pLink->pSchema==pLink->pTabSchema ){
      Table *pTab;
      pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table);
      assert( pTab!=0 );
      pLink->pNext = pTab->pTrigger;
      pTab->pTrigger = pLink;
    }
  }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r13
movq (%rdi), %r15
movq 0x158(%rdi), %r14
movq $0x0, 0x158(%rdi)
cmpl $0x0, 0x30(%rdi)
sete %al
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x2ba470
movq %rdi, %r12
movq %rdx, 0x20(%rsp)
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x2ba319
movq 0x20(%r15), %rcx
addq $0x18, %rcx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
incl %ebp
leaq 0x20(%rcx), %rdx
cmpq %rax, (%rcx)
movq %rdx, %rcx
jne 0x2ba309
jmp 0x2ba31e
movl $0xffff8000, %ebp       # imm = 0xFFFF8000
movq (%r14), %rdi
movq %r13, 0x38(%r14)
testq %r13, %r13
je 0x2ba33a
movq %r13, %rax
movq %r14, 0x8(%rax)
movq 0x50(%rax), %rax
testq %rax, %rax
jne 0x2ba32d
movq %rdi, 0x58(%rsp)
testq %rdi, %rdi
movq %rdi, 0x18(%rsp)
je 0x2ba355
callq 0x172f0
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jmp 0x2ba357
xorl %eax, %eax
leaq 0x58(%rsp), %rcx
movl %eax, 0x8(%rcx)
movq %r12, 0x28(%rsp)
movq %r15, (%rsp)
movq 0x20(%r15), %rax
movslq %ebp, %rdx
movq %rdx, %rdi
shlq $0x5, %rdi
movq (%rax,%rdi), %rsi
movq %rsi, 0x40(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x18(%rax,%rdi), %rax
cmpl $0x1, %edx
sete 0x38(%rsp)
movq %rax, 0x30(%rsp)
leaq 0x11b60e(%rip), %rax    # 0x3d59ab
movq %rax, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
testq %r13, %r13
je 0x2ba457
leaq 0x28(%rsp), %r15
movq 0x10(%r13), %rsi
movq %r15, %rdi
callq 0x2ca34d
testl %eax, %eax
jne 0x2ba469
movq 0x28(%r13), %rsi
movq %r15, %rdi
callq 0x2ca4b9
testl %eax, %eax
jne 0x2ba469
movq 0x30(%r13), %rsi
movq %r15, %rdi
callq 0x2ca59a
testl %eax, %eax
jne 0x2ba469
movq 0x20(%r13), %rsi
testq %rsi, %rsi
je 0x2ba402
movq %r15, %rdi
callq 0x2c9cb8
testl %eax, %eax
jne 0x2ba469
movq 0x40(%r13), %rbx
testq %rbx, %rbx
je 0x2ba44a
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x2ca59a
testl %eax, %eax
jne 0x2ba469
movq 0x8(%rbx), %rsi
movq %r15, %rdi
callq 0x2ca4b9
testl %eax, %eax
jne 0x2ba469
movq 0x10(%rbx), %rsi
movq %r15, %rdi
callq 0x2ca59a
testl %eax, %eax
jne 0x2ba469
movq 0x18(%rbx), %rsi
movq %r15, %rdi
callq 0x2ca4b9
testl %eax, %eax
jne 0x2ba469
movq 0x50(%r13), %r13
testq %r13, %r13
jne 0x2ba3b5
movq 0x18(%r14), %rsi
leaq 0x28(%rsp), %rdi
callq 0x2ca4b9
testl %eax, %eax
je 0x2ba495
xorl %r13d, %r13d
movq (%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2723de
movq %r15, %rdi
movq %r13, %rsi
callq 0x2a952d
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x2, 0x11c(%r12)
movq (%rsp), %r15
jb 0x2ba4b4
movq %r14, 0x158(%r12)
xorl %r14d, %r14d
jmp 0x2ba5d0
cmpb $0x0, 0xb5(%r15)
jne 0x2ba5d0
movq %r12, %rdi
callq 0x2bc630
testq %rax, %rax
je 0x2ba61a
movq %rax, 0x8(%rsp)
movq 0xa0(%r12), %rbx
testq %rbx, %rbx
cmoveq %r12, %rbx
movq %r12, %rdi
movl %ebp, %esi
callq 0x2c26e5
movl $0x1, %eax
movl %ebp, %ecx
shll %cl, %eax
orl %eax, 0x70(%rbx)
movq 0x20(%rsp), %rax
movq (%rax), %r13
testq %r13, %r13
je 0x2ba536
movl 0x8(%rax), %ebx
leaq 0x1(%rbx), %rsi
movq %r15, %rdi
callq 0x282a35
testq %rax, %rax
je 0x2ba536
movq %rax, %r15
movq %rax, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x17660
movb $0x0, (%r15,%rbx)
jmp 0x2ba539
xorl %r15d, %r15d
movq 0x8(%rsp), %r13
movq (%rsp), %rbx
movq 0x20(%rbx), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx), %rdx
movq 0x8(%r14), %r8
leaq 0x11ed41(%rip), %rsi    # 0x3d929b
movq %r12, %rdi
movq 0x18(%rsp), %rcx
movq %r15, %r9
xorl %eax, %eax
callq 0x2c461b
testq %r15, %r15
je 0x2ba57c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x282904
movq (%r12), %rax
movq 0x10(%r12), %rdi
movq 0x20(%rax), %rax
movq 0x10(%rsp), %rcx
movq 0x18(%rax,%rcx), %rax
movl (%rax), %r8d
incl %r8d
movl $0x5e, %esi
movl %ebp, %edx
movl $0x1, %ecx
callq 0x2a83e1
leaq 0x11ed35(%rip), %rsi    # 0x3d92e6
movq %rbx, %rdi
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x27b56a
movq %r13, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x2c4766
movq %rbx, %r15
cmpb $0x0, 0xb5(%r15)
je 0x2ba61a
movq 0x20(%r15), %rax
movq 0x10(%rsp), %rcx
movq 0x18(%rax,%rcx), %rdi
addq $0x38, %rdi
movq 0x18(%rsp), %rsi
movq %r14, %rdx
callq 0x2a5210
testq %rax, %rax
je 0x2ba622
movq %r15, %rbx
movq %rax, %r15
movq %rbx, %rdi
callq 0x278b1c
xorl %r13d, %r13d
movq %r15, %r14
movq %rbx, %r15
jmp 0x2ba470
xorl %r13d, %r13d
jmp 0x2ba470
movq 0x30(%r14), %rdi
cmpq %rdi, 0x28(%r14)
je 0x2ba634
xorl %r14d, %r14d
jmp 0x2ba469
addq $0x8, %rdi
movq 0x8(%r14), %rsi
xorl %r13d, %r13d
xorl %edx, %edx
callq 0x2a547e
movq 0x10(%rax), %rax
movq 0x68(%rax), %rcx
movq %rcx, 0x40(%r14)
movq %r14, 0x68(%rax)
xorl %r14d, %r14d
jmp 0x2ba46c