// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3GenerateRowDelete
SQLITE_PRIVATE void sqlite3GenerateRowDelete(
  Parse *pParse,     /* Parsing context */
  Table *pTab,       /* Table containing the row to be deleted */
  Trigger *pTrigger, /* List of triggers to (potentially) fire */
  int iDataCur,      /* Cursor from which column data is extracted */
  int iIdxCur,       /* First index cursor */
  int iPk,           /* First memory cell containing the PRIMARY KEY */
  i16 nPk,           /* Number of PRIMARY KEY memory cells */
  u8 count,          /* If non-zero, increment the row change counter */
  u8 onconf,         /* Default ON CONFLICT policy for triggers */
  u8 eMode,          /* ONEPASS_OFF, _SINGLE, or _MULTI.  See above */
  int iIdxNoSeek     /* Cursor number of cursor that does not need seeking */
){
  Vdbe *v = pParse->pVdbe;        /* Vdbe */
  int iOld = 0;                   /* First register in OLD.* array */
  int iLabel;                     /* Label resolved to end of generated code */
  u8 opSeek;                      /* Seek opcode */

  /* Vdbe is guaranteed to have been allocated by this stage. */
  assert( v );
  VdbeModuleComment((v, "BEGIN: GenRowDel(%d,%d,%d,%d)",
                         iDataCur, iIdxCur, iPk, (int)nPk));

  /* Seek cursor iCur to the row to delete. If this row no longer exists 
  ** (this can happen if a trigger program has already deleted it), do
  ** not attempt to delete it or fire any DELETE triggers.  */
  iLabel = sqlite3VdbeMakeLabel(v);
  opSeek = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
  if( eMode==ONEPASS_OFF ){
    sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);
    VdbeCoverageIf(v, opSeek==OP_NotExists);
    VdbeCoverageIf(v, opSeek==OP_NotFound);
  }
 
  /* If there are any triggers to fire, allocate a range of registers to
  ** use for the old.* references in the triggers.  */
  if( sqlite3FkRequired(pParse, pTab, 0, 0) || pTrigger ){
    u32 mask;                     /* Mask of OLD.* columns in use */
    int iCol;                     /* Iterator used while populating OLD.* */
    int addrStart;                /* Start of BEFORE trigger programs */

    /* TODO: Could use temporary registers here. Also could attempt to
    ** avoid copying the contents of the rowid register.  */
    mask = sqlite3TriggerColmask(
        pParse, pTrigger, 0, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onconf
    );
    mask |= sqlite3FkOldmask(pParse, pTab);
    iOld = pParse->nMem+1;
    pParse->nMem += (1 + pTab->nCol);

    /* Populate the OLD.* pseudo-table register array. These values will be 
    ** used by any BEFORE and AFTER triggers that exist.  */
    sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);
    for(iCol=0; iCol<pTab->nCol; iCol++){
      testcase( mask!=0xffffffff && iCol==31 );
      testcase( mask!=0xffffffff && iCol==32 );
      if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){
        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);
      }
    }

    /* Invoke BEFORE DELETE trigger programs. */
    addrStart = sqlite3VdbeCurrentAddr(v);
    sqlite3CodeRowTrigger(pParse, pTrigger, 
        TK_DELETE, 0, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel
    );

    /* If any BEFORE triggers were coded, then seek the cursor to the 
    ** row to be deleted again. It may be that the BEFORE triggers moved
    ** the cursor or of already deleted the row that the cursor was
    ** pointing to.
    */
    if( addrStart<sqlite3VdbeCurrentAddr(v) ){
      sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);
      VdbeCoverageIf(v, opSeek==OP_NotExists);
      VdbeCoverageIf(v, opSeek==OP_NotFound);
    }

    /* Do FK processing. This call checks that any FK constraints that
    ** refer to this table (i.e. constraints attached to other tables) 
    ** are not violated by deleting this row.  */
    sqlite3FkCheck(pParse, pTab, iOld, 0, 0, 0);
  }

  /* Delete the index and table entries. Skip this step if pTab is really
  ** a view (in which case the only effect of the DELETE statement is to
  ** fire the INSTEAD OF triggers).  */ 
  if( pTab->pSelect==0 ){
    sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek);
    sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0));
    if( count ){
      sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);
    }
    if( iIdxNoSeek>=0 ){
      sqlite3VdbeAddOp1(v, OP_Delete, iIdxNoSeek);
    }
    sqlite3VdbeChangeP5(v, eMode==ONEPASS_MULTI);
  }

  /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to
  ** handle rows (possibly in other tables) that refer via a foreign key
  ** to the row just deleted. */ 
  sqlite3FkActions(pParse, pTab, 0, iOld, 0, 0);

  /* Invoke AFTER DELETE trigger programs. */
  sqlite3CodeRowTrigger(pParse, pTrigger, 
      TK_DELETE, 0, TRIGGER_AFTER, pTab, iOld, onconf, iLabel
  );

  /* Jump here if the row had already been deleted before any BEFORE
  ** trigger programs were invoked. Or if a trigger program throws a 
  ** RAISE(IGNORE) exception.  */
  sqlite3VdbeResolveLabel(v, iLabel);
  VdbeModuleComment((v, "END: GenRowDel()"));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, -0x34(%rbp)
movl %r8d, -0x6c(%rbp)
movl %ecx, -0x30(%rbp)
movq %rdx, -0x60(%rbp)
movq %rsi, %r14
movq %rdi, %r13
movl 0x30(%rbp), %eax
movl %eax, -0x4c(%rbp)
movb 0x28(%rbp), %r15b
movb 0x20(%rbp), %al
movb %al, -0x40(%rbp)
movb 0x18(%rbp), %al
movb %al, -0x29(%rbp)
movzwl 0x10(%rbp), %r12d
movq 0x10(%rdi), %rbx
movq %rbx, %rdi
callq 0x4b9c2
testb $0x20, 0x46(%r14)
sete %cl
shlb $0x2, %cl
addb $0x46, %cl
movzbl %cl, %ecx
movl %ecx, -0x44(%rbp)
movswl %r12w, %ecx
movl %ecx, -0x48(%rbp)
movq %rax, %r12
movb %r15b, -0x2a(%rbp)
testb %r15b, %r15b
jne 0x5de79
movq %rbx, %rdi
movl -0x44(%rbp), %esi
movl -0x30(%rbp), %edx
movl %r12d, %ecx
movl -0x34(%rbp), %r8d
movl -0x48(%rbp), %r9d
callq 0x1373a
xorl %r15d, %r15d
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x5d9ef
movzbl -0x40(%rbp), %ecx
movq %rcx, -0x40(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x5dea2
testl %eax, %eax
je 0x5dfb3
movq %r12, -0x68(%rbp)
subq $0x8, %rsp
xorl %r15d, %r15d
pushq $0x3
popq %r8
movq %r13, %rdi
movq -0x60(%rbp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r9
pushq -0x40(%rbp)
callq 0x5e331
popq %rcx
popq %rdx
movl %eax, %r12d
movq %r13, %rdi
movq %r14, %rsi
callq 0x5e3cb
movq %r13, %rdx
movl %eax, %r13d
orl %r12d, %r13d
movl 0x54(%rdx), %r12d
leal 0x1(%r12), %ecx
movswl 0x3e(%r14), %eax
addl %r12d, %eax
incl %eax
movq %rdx, -0x78(%rbp)
movl %eax, 0x54(%rdx)
pushq $0x1f
popq %rsi
movq %rbx, %rdi
movl -0x34(%rbp), %edx
movq %rcx, -0x58(%rbp)
callq 0x4a1ab
addl $0x2, %r12d
movswl 0x3e(%r14), %eax
cmpl %eax, %r15d
jge 0x5df46
cmpl $-0x1, %r13d
je 0x5df2c
cmpl $0x1f, %r15d
ja 0x5df41
btl %r15d, %r13d
jae 0x5df41
leal (%r12,%r15), %r8d
movq %rbx, %rdi
movq %r14, %rsi
movl -0x30(%rbp), %edx
movl %r15d, %ecx
callq 0x4c8f3
incl %r15d
jmp 0x5df10
movl 0x3c(%rbx), %r15d
subq $0x8, %rsp
pushq $0x6d
popq %rdx
pushq $0x1
popq %r8
movq -0x78(%rbp), %r13
movq %r13, %rdi
movq -0x60(%rbp), %rsi
xorl %ecx, %ecx
movq %r14, %r9
movq -0x68(%rbp), %r12
pushq %r12
pushq -0x40(%rbp)
pushq -0x58(%rbp)
callq 0x5e4b1
addq $0x20, %rsp
cmpl 0x3c(%rbx), %r15d
jge 0x5df99
movq %rbx, %rdi
movl -0x44(%rbp), %esi
movl -0x30(%rbp), %edx
movl %r12d, %ecx
movl -0x34(%rbp), %r8d
movl -0x48(%rbp), %r9d
callq 0x1373a
movq %r13, %rdi
movq %r14, %rsi
movq -0x58(%rbp), %r15
movl %r15d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5e52a
cmpq $0x0, 0x18(%r14)
jne 0x5e039
movq %r12, -0x68(%rbp)
movq %r15, -0x58(%rbp)
movq %r13, %rdi
movq %r14, %rsi
movl -0x30(%rbp), %r15d
movl %r15d, %edx
movl -0x6c(%rbp), %ecx
xorl %r8d, %r8d
movl -0x4c(%rbp), %r9d
callq 0x5ea49
xorl %ecx, %ecx
movb -0x29(%rbp), %r12b
testb %r12b, %r12b
setne %cl
pushq $0x63
popq %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x4a1ab
testb %r12b, %r12b
je 0x5e00d
movq (%r14), %rdx
pushq $-0x1
popq %rsi
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x1385d
movl -0x4c(%rbp), %edx
testl %edx, %edx
js 0x5e01f
pushq $0x63
popq %rsi
movq %rbx, %rdi
callq 0x4b9b3
xorl %esi, %esi
cmpb $0x2, -0x2a(%rbp)
sete %sil
movq %rbx, %rdi
callq 0x13770
movq -0x58(%rbp), %r15
movq -0x68(%rbp), %r12
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl %r15d, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5eb46
subq $0x8, %rsp
pushq $0x6d
popq %rdx
pushq $0x2
popq %r8
movq %r13, %rdi
movq -0x60(%rbp), %rsi
xorl %ecx, %ecx
movq %r14, %r9
pushq %r12
pushq -0x40(%rbp)
pushq %r15
callq 0x5e4b1
addq $0x20, %rsp
movq %rbx, %rdi
movl %r12d, %esi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4bacf