// File: /workspace/github_c_makefile_star2_O1/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 0x2c3be0
movq %rdi, %r12
movq %rdx, 0x20(%rsp)
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x2c3a89
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 0x2c3a79
jmp 0x2c3a8e
movl $0xffff8000, %ebp       # imm = 0xFFFF8000
movq (%r14), %rdi
movq %r13, 0x38(%r14)
testq %r13, %r13
je 0x2c3aaa
movq %r13, %rax
movq %r14, 0x8(%rax)
movq 0x50(%rax), %rax
testq %rax, %rax
jne 0x2c3a9d
movq %rdi, 0x58(%rsp)
testq %rdi, %rdi
movq %rdi, 0x10(%rsp)
je 0x2c3ac5
callq 0x172f0
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jmp 0x2c3ac7
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, 0x8(%rsp)
movq 0x18(%rax,%rdi), %rax
movq %rax, 0x30(%rsp)
leaq 0x11b5fa(%rip), %rax    # 0x3df0ff
movq %rax, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
cmpl $0x1, %edx
sete 0x38(%rsp)
testq %r13, %r13
je 0x2c3bc7
leaq 0x28(%rsp), %r15
movq 0x10(%r13), %rsi
movq %r15, %rdi
callq 0x2d3c19
testl %eax, %eax
jne 0x2c3bd9
movq 0x28(%r13), %rsi
movq %r15, %rdi
callq 0x2d3da4
testl %eax, %eax
jne 0x2c3bd9
movq 0x30(%r13), %rsi
movq %r15, %rdi
callq 0x2d3e85
testl %eax, %eax
jne 0x2c3bd9
movq 0x20(%r13), %rsi
testq %rsi, %rsi
je 0x2c3b72
movq %r15, %rdi
callq 0x2d357f
testl %eax, %eax
jne 0x2c3bd9
movq 0x40(%r13), %rbx
testq %rbx, %rbx
je 0x2c3bba
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x2d3e85
testl %eax, %eax
jne 0x2c3bd9
movq 0x8(%rbx), %rsi
movq %r15, %rdi
callq 0x2d3da4
testl %eax, %eax
jne 0x2c3bd9
movq 0x10(%rbx), %rsi
movq %r15, %rdi
callq 0x2d3e85
testl %eax, %eax
jne 0x2c3bd9
movq 0x18(%rbx), %rsi
movq %r15, %rdi
callq 0x2d3da4
testl %eax, %eax
jne 0x2c3bd9
movq 0x50(%r13), %r13
testq %r13, %r13
jne 0x2c3b25
movq 0x18(%r14), %rsi
leaq 0x28(%rsp), %rdi
callq 0x2d3da4
testl %eax, %eax
je 0x2c3c05
xorl %r13d, %r13d
movq (%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x27bd0b
movq %r15, %rdi
movq %r13, %rsi
callq 0x2b3155
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x2, 0x11c(%r12)
movq (%rsp), %r15
jb 0x2c3c21
movq %r14, 0x158(%r12)
xorl %r14d, %r14d
jmp 0x2c3c2b
cmpb $0x0, 0xb5(%r15)
je 0x2c3c8b
cmpb $0x0, 0xb5(%r15)
je 0x2c3ce4
movq 0x20(%r15), %rax
movq 0x8(%rsp), %rcx
movq 0x18(%rax,%rcx), %rdi
addq $0x38, %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x2aed98
movq %r15, %rbx
movq %rax, %r15
testq %rax, %rax
je 0x2c3c79
movq %rbx, %rdi
callq 0x2824bb
xorl %r13d, %r13d
movq %r15, %r14
movq %rbx, %r15
jmp 0x2c3be0
movq 0x30(%r14), %rdi
cmpq %rdi, 0x28(%r14)
je 0x2c3cec
xorl %r13d, %r13d
jmp 0x2c3d0e
movq %r12, %rdi
callq 0x2c5ddf
testq %rax, %rax
je 0x2c3ce4
movq %rax, 0x18(%rsp)
movq 0xa0(%r12), %rbx
testq %rbx, %rbx
cmoveq %r12, %rbx
movq %r12, %rdi
movl %ebp, %esi
callq 0x2cbe18
movl $0x1, %eax
movl %ebp, %ecx
shll %cl, %eax
orl %eax, 0x70(%rbx)
movq 0x20(%rsp), %rax
movq (%rax), %rbx
movl 0x8(%rax), %r13d
testq %rbx, %rbx
je 0x2c3d16
leaq 0x1(%r13), %rsi
movq %r15, %rdi
callq 0x28c518
movq %rax, %r15
jmp 0x2c3d19
xorl %r13d, %r13d
jmp 0x2c3be0
addq $0x8, %rdi
movq 0x8(%r14), %rsi
xorl %r13d, %r13d
xorl %edx, %edx
callq 0x2aefdf
movq 0x10(%rax), %rax
movq 0x68(%rax), %rcx
movq %rcx, 0x40(%r14)
movq %r14, 0x68(%rax)
movq %r15, %r14
jmp 0x2c3bdc
xorl %r15d, %r15d
testq %r15, %r15
je 0x2c3d6f
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x17660
movb $0x0, (%r15,%r13)
movq (%rsp), %r13
movq 0x20(%r13), %rax
movq 0x8(%rsp), %rcx
movq (%rax,%rcx), %rdx
movq 0x8(%r14), %r8
leaq 0x11eca3(%rip), %rsi    # 0x3e29f0
movq %r12, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
movq %r15, %r9
xorl %eax, %eax
callq 0x2cdd65
movq %r13, %rdi
movq %r15, %rsi
callq 0x28c3e7
jmp 0x2c3da0
movq (%rsp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rsp), %rcx
movq (%rax,%rcx), %rdx
movq 0x8(%r14), %r8
leaq 0x11ec65(%rip), %rsi    # 0x3e29f0
movq %r12, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
movq %r15, %r9
xorl %eax, %eax
callq 0x2cdd65
movq %r12, %rdi
movl %ebp, %esi
callq 0x2cdeb0
leaq 0x11ec8a(%rip), %rsi    # 0x3e2a3b
xorl %r13d, %r13d
movq (%rsp), %r15
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x284f95
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x2cdedf
testq %rbx, %rbx
jne 0x2c3c2b
jmp 0x2c3be0