// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/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(pParse);
  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) ){
        int kk = sqlite3TableColumnToStorage(pTab, iCol);
        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+kk+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 already deleted the row that the cursor was
    ** pointing to.
    **
    ** Also disable the iIdxNoSeek optimization since the BEFORE trigger
    ** may have moved that cursor.
    */
    if( addrStart<sqlite3VdbeCurrentAddr(v) ){
      sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);
      VdbeCoverageIf(v, opSeek==OP_NotExists);
      VdbeCoverageIf(v, opSeek==OP_NotFound);
      testcase( iIdxNoSeek>=0 );
      iIdxNoSeek = -1;
    }

    /* 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 variable 'count' is non-zero, then this OP_Delete instruction should
  ** invoke the update-hook. The pre-update-hook, on the other hand should
  ** be invoked unless table pTab is a system table. The difference is that
  ** the update-hook is not invoked for rows removed by REPLACE, but the
  ** pre-update-hook is.
  */
  if( pTab->pSelect==0 ){
    u8 p5 = 0;
    sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek);
    sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0));
    if( pParse->nested==0 || 0==sqlite3_stricmp(pTab->zName, "sqlite_stat1") ){
      sqlite3VdbeAppendP4(v, (char*)pTab, P4_TABLE);
    }
    if( eMode!=ONEPASS_OFF ){
      sqlite3VdbeChangeP5(v, OPFLAG_AUXDELETE);
    }
    if( iIdxNoSeek>=0 && iIdxNoSeek!=iDataCur ){
      sqlite3VdbeAddOp1(v, OP_Delete, iIdxNoSeek);
    }
    if( eMode==ONEPASS_MULTI ) p5 |= OPFLAG_SAVEPOSITION;
    sqlite3VdbeChangeP5(v, p5);
  }

  /* 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
subq $0x70, %rsp
movl 0x30(%rbp), %eax
movb 0x28(%rbp), %al
movb 0x20(%rbp), %al
movb 0x18(%rbp), %al
movw 0x10(%rbp), %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x8(%rbp), %rdi
callq 0x42d540
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %edx
andl $0x80, %edx
movl $0x1d, %eax
movl $0x20, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movb %al, -0x39(%rbp)
movzbl 0x28(%rbp), %eax
cmpl $0x0, %eax
jne 0x45aa73
movq -0x30(%rbp), %rdi
movzbl -0x39(%rbp), %esi
movl -0x1c(%rbp), %edx
movl -0x38(%rbp), %ecx
movl -0x24(%rbp), %r8d
movswl 0x10(%rbp), %r9d
callq 0x3cb970
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x45a320
cmpl $0x0, %eax
jne 0x45aa96
cmpq $0x0, -0x18(%rbp)
je 0x45ac16
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %r9
movzbl 0x20(%rbp), %eax
xorl %ecx, %ecx
movl %ecx, %edx
xorl %ecx, %ecx
movl $0x3, %r8d
movl %eax, (%rsp)
callq 0x45b0d0
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x45b1b0
orl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movswl 0x46(%rax), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
addl 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %edx
movl -0x34(%rbp), %ecx
movl $0x4d, %esi
callq 0x410100
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0x46(%rcx), %ecx
cmpl %ecx, %eax
jge 0x45ab7d
cmpl $-0x1, -0x40(%rbp)
je 0x45ab3e
cmpl $0x1f, -0x44(%rbp)
jg 0x45ab70
movl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x45ab70
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %eax
movswl %ax, %esi
callq 0x42bae0
cwtl
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x44(%rbp), %ecx
movl -0x34(%rbp), %r8d
addl -0x4c(%rbp), %r8d
addl $0x1, %r8d
callq 0x42e610
jmp 0x45ab72
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x45ab0d
movq -0x30(%rbp), %rdi
callq 0x430ae0
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %r9
movl -0x34(%rbp), %r11d
movzbl 0x20(%rbp), %r10d
movl -0x38(%rbp), %eax
movl $0x7e, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x45b340
movl -0x48(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rdi
callq 0x430ae0
movl %eax, %ecx
movl -0x54(%rbp), %eax
cmpl %ecx, %eax
jge 0x45abfb
movq -0x30(%rbp), %rdi
movzbl -0x39(%rbp), %esi
movl -0x1c(%rbp), %edx
movl -0x38(%rbp), %ecx
movl -0x24(%rbp), %r8d
movswl 0x10(%rbp), %r9d
callq 0x3cb970
movl $0xffffffff, 0x30(%rbp) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x34(%rbp), %edx
xorl %r9d, %r9d
xorl %eax, %eax
movl %eax, %r8d
movl %r9d, %ecx
callq 0x45b3e0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x45acfa
movb $0x0, -0x4d(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl 0x30(%rbp), %r9d
xorl %eax, %eax
movl %eax, %r8d
callq 0x45ba60
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %edx
movzbl 0x18(%rbp), %esi
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %esi
cmovnel %eax, %ecx
movl $0x7a, %esi
callq 0x410100
movq -0x8(%rbp), %rax
movzbl 0x1e(%rax), %eax
cmpl $0x0, %eax
je 0x45ac8f
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x150f92(%rip), %rsi    # 0x5abc14
callq 0x3c3e00
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x45aca1
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0xfffffffa, %edx       # imm = 0xFFFFFFFA
callq 0x42a320
movzbl 0x28(%rbp), %eax
cmpl $0x0, %eax
je 0x45acb8
movq -0x30(%rbp), %rdi
movl $0x4, %esi
callq 0x3cb9f0
cmpl $0x0, 0x30(%rbp)
jl 0x45acd7
movl 0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0x45acd7
movq -0x30(%rbp), %rdi
movl 0x30(%rbp), %edx
movl $0x7a, %esi
callq 0x42ba70
movzbl 0x28(%rbp), %eax
cmpl $0x2, %eax
jne 0x45acea
movzbl -0x4d(%rbp), %eax
orl $0x2, %eax
movb %al, -0x4d(%rbp)
movq -0x30(%rbp), %rdi
movzbl -0x4d(%rbp), %eax
movzwl %ax, %esi
callq 0x3cb9f0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x34(%rbp), %ecx
xorl %eax, %eax
movl %eax, %r8d
xorl %r9d, %r9d
movq %r8, %rdx
callq 0x45bc00
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %r9
movl -0x34(%rbp), %r11d
movzbl 0x20(%rbp), %r10d
movl -0x38(%rbp), %eax
movl $0x7e, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x45b340
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x42dc90
addq $0x70, %rsp
popq %rbp
retq
nop