// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: codeRowTrigger
static TriggerPrg *codeRowTrigger(
  Parse *pParse,       /* Current parse context */
  Trigger *pTrigger,   /* Trigger to code */
  Table *pTab,         /* The table pTrigger is attached to */
  int orconf           /* ON CONFLICT policy to code trigger program with */
){
  Parse *pTop = sqlite3ParseToplevel(pParse);
  sqlite3 *db = pParse->db;   /* Database handle */
  TriggerPrg *pPrg;           /* Value to return */
  Expr *pWhen = 0;            /* Duplicate of trigger WHEN expression */
  Vdbe *v;                    /* Temporary VM */
  NameContext sNC;            /* Name context for sub-vdbe */
  SubProgram *pProgram = 0;   /* Sub-vdbe for trigger program */
  Parse *pSubParse;           /* Parse context for sub-vdbe */
  int iEndTrigger = 0;        /* Label to jump to if WHEN is false */

  assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
  assert( pTop->pVdbe );

  /* Allocate the TriggerPrg and SubProgram objects. To ensure that they
  ** are freed if an error occurs, link them into the Parse.pTriggerPrg 
  ** list of the top-level Parse object sooner rather than later.  */
  pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));
  if( !pPrg ) return 0;
  pPrg->pNext = pTop->pTriggerPrg;
  pTop->pTriggerPrg = pPrg;
  pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));
  if( !pProgram ) return 0;
  sqlite3VdbeLinkSubProgram(pTop->pVdbe, pProgram);
  pPrg->pTrigger = pTrigger;
  pPrg->orconf = orconf;
  pPrg->aColmask[0] = 0xffffffff;
  pPrg->aColmask[1] = 0xffffffff;

  /* Allocate and populate a new Parse context to use for coding the 
  ** trigger sub-program.  */
  pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
  if( !pSubParse ) return 0;
  memset(&sNC, 0, sizeof(sNC));
  sNC.pParse = pSubParse;
  pSubParse->db = db;
  pSubParse->pTriggerTab = pTab;
  pSubParse->pToplevel = pTop;
  pSubParse->zAuthContext = pTrigger->zName;
  pSubParse->eTriggerOp = pTrigger->op;
  pSubParse->nQueryLoop = pParse->nQueryLoop;

  v = sqlite3GetVdbe(pSubParse);
  if( v ){
    VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)", 
      pTrigger->zName, onErrorText(orconf),
      (pTrigger->tr_tm==TRIGGER_BEFORE ? "BEFORE" : "AFTER"),
        (pTrigger->op==TK_UPDATE ? "UPDATE" : ""),
        (pTrigger->op==TK_INSERT ? "INSERT" : ""),
        (pTrigger->op==TK_DELETE ? "DELETE" : ""),
      pTab->zName
    ));
#ifndef SQLITE_OMIT_TRACE
    sqlite3VdbeChangeP4(v, -1, 
      sqlite3MPrintf(db, "-- TRIGGER %s", pTrigger->zName), P4_DYNAMIC
    );
#endif

    /* If one was specified, code the WHEN clause. If it evaluates to false
    ** (or NULL) the sub-vdbe is immediately halted by jumping to the 
    ** OP_Halt inserted at the end of the program.  */
    if( pTrigger->pWhen ){
      pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0);
      if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) 
       && db->mallocFailed==0 
      ){
        iEndTrigger = sqlite3VdbeMakeLabel(v);
        sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
      }
      sqlite3ExprDelete(db, pWhen);
    }

    /* Code the trigger program into the sub-vdbe. */
    codeTriggerProgram(pSubParse, pTrigger->step_list, orconf);

    /* Insert an OP_Halt at the end of the sub-program. */
    if( iEndTrigger ){
      sqlite3VdbeResolveLabel(v, iEndTrigger);
    }
    sqlite3VdbeAddOp0(v, OP_Halt);
    VdbeComment((v, "End: %s.%s", pTrigger->zName, onErrorText(orconf)));

    transferParseError(pParse, pSubParse);
    if( db->mallocFailed==0 ){
      pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);
    }
    pProgram->nMem = pSubParse->nMem;
    pProgram->nCsr = pSubParse->nTab;
    pProgram->nOnce = pSubParse->nOnce;
    pProgram->token = (void *)pTrigger;
    pPrg->aColmask[0] = pSubParse->oldmask;
    pPrg->aColmask[1] = pSubParse->newmask;
    sqlite3VdbeDelete(v);
  }

  assert( !pSubParse->pAinc       && !pSubParse->pZombieTab );
  assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg );
  sqlite3StackFree(db, pSubParse);

  return pPrg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x1d8(%rax)
je 0x7dcdc
movq -0x10(%rbp), %rax
movq 0x1d8(%rax), %rax
movq %rax, -0xa8(%rbp)
jmp 0x7dce7
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x90(%rbp)
movl $0x0, -0x9c(%rbp)
movq -0x38(%rbp), %rdi
movl $0x28, %esi
callq 0x11ca0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x7dd40
movq $0x0, -0x8(%rbp)
jmp 0x7e084
movq -0x30(%rbp), %rax
movq 0x290(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x290(%rax)
movq -0x38(%rbp), %rdi
movl $0x28, %esi
callq 0x11ca0
movq %rax, %rcx
movq %rcx, -0x90(%rbp)
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
cmpq $0x0, -0x90(%rbp)
jne 0x7dd99
movq $0x0, -0x8(%rbp)
jmp 0x7e084
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x90(%rbp), %rsi
callq 0x7e0a0
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movl -0x24(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x40(%rbp), %rax
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
movq -0x40(%rbp), %rax
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
movq -0x38(%rbp), %rdi
movl $0x298, %esi            # imm = 0x298
callq 0x11ca0
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x7de04
movq $0x0, -0x8(%rbp)
jmp 0x7e084
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x8200
movq -0x98(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x38(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x1e0(%rax)
movq -0x30(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x1d8(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x248(%rax)
movq -0x18(%rbp), %rax
movb 0x10(%rax), %cl
movq -0x98(%rbp), %rax
movb %cl, 0x1f4(%rax)
movq -0x10(%rbp), %rax
movl 0x1e8(%rax), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x1e8(%rax)
movq -0x98(%rbp), %rdi
callq 0x5e000
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x7e06c
movq -0x50(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
leaq 0x329a9(%rip), %rsi     # 0xb0878
movb $0x0, %al
callq 0x137f0
movq -0xb0(%rbp), %rdi
movq %rax, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, %esi
callq 0x13c20
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x7df6a
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rsi
xorl %edx, %edx
callq 0x61690
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x5f5b0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x7df5d
movq -0x38(%rbp), %rax
movzbl 0x50(%rax), %eax
cmpl $0x0, %eax
jne 0x7df5d
movq -0x50(%rbp), %rdi
callq 0x67890
movl %eax, -0x9c(%rbp)
movq -0x98(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x9c(%rbp), %edx
movl $0x8, %ecx
callq 0x67920
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x47330
movq -0x98(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
movl -0x24(%rbp), %edx
callq 0x7e0d0
cmpl $0x0, -0x9c(%rbp)
je 0x7df99
movq -0x50(%rbp), %rdi
movl -0x9c(%rbp), %esi
callq 0x677f0
movq -0x50(%rbp), %rdi
movl $0x14, %esi
callq 0x5e060
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x7e330
movq -0x38(%rbp), %rax
movzbl 0x50(%rax), %eax
cmpl $0x0, %eax
jne 0x7dff0
movq -0x50(%rbp), %rdi
movq -0x90(%rbp), %rsi
addq $0x8, %rsi
movq -0x30(%rbp), %rdx
addq $0x1a8, %rdx            # imm = 0x1A8
callq 0x7e390
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, (%rax)
movq -0x98(%rbp), %rax
movl 0x58(%rax), %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x98(%rbp), %rax
movl 0x54(%rax), %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x98(%rbp), %rax
movl 0x60(%rax), %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x18(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x98(%rbp), %rax
movl 0x1ec(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x98(%rbp), %rax
movl 0x1f0(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x50(%rbp), %rdi
callq 0x2e770
movq -0x38(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x9cd0
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)