// File: /workspace/github_c_makefile_star2_O1/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), %rbx
movq $0x0, 0x240(%rdi)
cmpl $0x0, 0x50(%rdi)
sete %al
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x4427a
movq %rdi, %r12
movq 0x28(%r14), %rax
testq %rax, %rax
movq %rdx, -0x38(%rbp)
je 0x43f8a
movl 0x28(%rbx), %ecx
testl %ecx, %ecx
jle 0x43f92
movq 0x20(%rbx), %rdx
addq $0x18, %rdx
xorl %r13d, %r13d
cmpq %rax, (%rdx)
je 0x43f95
incq %r13
addq $0x20, %rdx
cmpq %r13, %rcx
jne 0x43f74
movl %ecx, %r13d
jmp 0x43f95
movl $0xfff0bdc0, %r13d      # imm = 0xFFF0BDC0
jmp 0x43f95
xorl %r13d, %r13d
movq (%r14), %rdx
movq %r15, 0x38(%r14)
testq %r15, %r15
je 0x43fb1
movq %r15, %rax
movq %r14, 0x8(%rax)
movq 0x40(%rax), %rax
testq %rax, %rax
jne 0x43fa4
movq %rdx, -0x58(%rbp)
testq %rdx, %rdx
movq %rbx, -0x30(%rbp)
je 0x43fd8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rdx, %rcx
incl %eax
cmpb $0x0, (%rcx)
leaq 0x1(%rcx), %rcx
jne 0x43fc6
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jmp 0x43fda
xorl %eax, %eax
movq %rdx, -0x40(%rbp)
movl %eax, -0x50(%rbp)
testl %r13d, %r13d
sets %al
cmpl $0x1, %r13d
sete %cl
orb %al, %cl
jne 0x4407b
movq %r12, -0x80(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl %r13d, %ecx
shlq $0x5, %rcx
movq (%rax,%rcx), %rdx
movq %rdx, -0x70(%rbp)
movq 0x18(%rax,%rcx), %rax
movq %rax, -0x78(%rbp)
leaq 0x38fac(%rip), %rax     # 0x7cfcd
movq %rax, -0x68(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
testq %r15, %r15
je 0x4407b
leaq -0x80(%rbp), %rbx
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0x4c0a3
testl %eax, %eax
jne 0x4417a
movq 0x28(%r15), %rsi
movq %rbx, %rdi
callq 0x4c117
testl %eax, %eax
jne 0x4417a
movq 0x30(%r15), %rsi
movq %rbx, %rdi
callq 0x4c183
testl %eax, %eax
jne 0x4417a
movq 0x40(%r15), %r15
testq %r15, %r15
jne 0x44036
movq -0x30(%rbp), %rbx
cmpb $0x0, 0x99(%rbx)
je 0x440f4
xorl %r15d, %r15d
cmpb $0x0, 0x99(%rbx)
je 0x4427a
movq 0x20(%rbx), %rax
movslq %r13d, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %rdi
addq $0x38, %rdi
movq -0x40(%rbp), %rsi
testq %rsi, %rsi
je 0x440d1
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rsi, %rax
incl %r15d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x440be
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
movl %r15d, %edx
movq %r14, %rcx
callq 0x33cea
movq %rax, %r12
testq %rax, %rax
je 0x44189
movb $0x1, 0x50(%rbx)
xorl %r15d, %r15d
jmp 0x4427d
movq %r12, %rdi
callq 0x45b57
testq %rax, %rax
je 0x441dc
movq %rax, -0x48(%rbp)
movq 0x1d8(%r12), %rbx
testq %rbx, %rbx
cmoveq %r12, %rbx
movq %r12, %rdi
movl %r13d, %esi
callq 0x45ff7
movl $0x1, %eax
movl %r13d, %ecx
shll %cl, %eax
orl %eax, 0x164(%rbx)
movq -0x38(%rbp), %rax
movq (%rax), %rbx
testq %rbx, %rbx
je 0x441e4
movslq 0x8(%rax), %r15
leal 0x1(%r15), %esi
movq -0x30(%rbp), %rdi
callq 0x115e9
movq %rax, %rdi
testq %rax, %rax
je 0x441e6
movq %rdi, -0x38(%rbp)
movq %rbx, %rsi
movq %r15, %rdx
callq 0x82f0
movq -0x38(%rbp), %rdi
movb $0x0, (%rdi,%r15)
jmp 0x441e6
movq %r14, %r12
xorl %r15d, %r15d
movq -0x30(%rbp), %rbx
jmp 0x4427d
movq 0x30(%r14), %rdi
xorl %r15d, %r15d
cmpq %rdi, 0x28(%r14)
jne 0x4427d
movq 0x8(%r14), %rsi
testq %rsi, %rsi
je 0x441bf
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rsi, %rax
incl %r15d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x441ac
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
addq $0x8, %rdi
movl %r15d, %edx
callq 0x3396f
movq 0x60(%rax), %rcx
movq %rcx, 0x40(%r14)
movq %r14, 0x60(%rax)
jmp 0x440ec
xorl %r15d, %r15d
jmp 0x4427a
xorl %edi, %edi
movq %rdi, -0x38(%rbp)
movslq %r13d, %rax
shlq $0x5, %rax
cmpl $0x1, %r13d
movq -0x30(%rbp), %rbx
movq 0x20(%rbx), %rcx
movq (%rcx,%rax), %rdx
leaq 0x35d11(%rip), %rax     # 0x79f19
leaq 0x35d1d(%rip), %rcx     # 0x79f2c
cmoveq %rax, %rcx
movq 0x8(%r14), %r9
movq %rdi, (%rsp)
leaq 0x382cc(%rip), %rsi     # 0x7c4ee
xorl %r15d, %r15d
movq %r12, %rdi
movq -0x40(%rbp), %r8
xorl %eax, %eax
callq 0x465b3
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq 0x9c3a
movq %r12, %rdi
movl %r13d, %esi
callq 0x466e1
leaq 0x382dd(%rip), %rsi     # 0x7c52e
movq %rbx, %rdi
movq -0x40(%rbp), %rdx
xorl %eax, %eax
callq 0x117e2
movq -0x48(%rbp), %r12
movq %r12, %rdi
movl %r13d, %esi
movq %rax, %rdx
callq 0x4679b
testq %r12, %r12
jne 0x44088
movq %r14, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x98df
movq %rbx, %rdi
movq %r15, %rsi
callq 0x36f4e
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq