// File: /workspace/github_c_makefile_star2_O0/skeeto[P]flappy/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 bNoSeek         /* iDataCur is already pointing to the row to delete */
){
  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( !bNoSeek ) sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);
 
  /* 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++){
      if( mask==0xffffffff || mask&(1<<iCol) ){
        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);
    }

    /* 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);
    sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0));
    if( count ){
      sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);
    }
  }

  /* 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
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 -0x30(%rbp), %rdi
callq 0x662a0
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x48(%rax), %edx
andl $0x20, %edx
movl $0x3f, %eax
movl $0x41, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movb %al, -0x39(%rbp)
cmpb $0x0, 0x28(%rbp)
jne 0x83f1b
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 0x640a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x83a40
cmpl $0x0, %eax
jne 0x83f3e
cmpq $0x0, -0x18(%rbp)
je 0x8409e
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 0x845e0
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x846c0
orl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movl 0x58(%rax), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movswl 0x42(%rax), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
addl 0x58(%rax), %ecx
movl %ecx, 0x58(%rax)
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %edx
movl -0x34(%rbp), %ecx
movl $0x1e, %esi
callq 0x63980
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0x42(%rcx), %ecx
cmpl %ecx, %eax
jge 0x8400c
cmpl $-0x1, -0x40(%rbp)
je 0x83fe0
movl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x83fff
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x44(%rbp), %ecx
movl -0x34(%rbp), %r8d
addl -0x44(%rbp), %r8d
addl $0x1, %r8d
callq 0x678d0
jmp 0x84001
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x83fb5
movq -0x30(%rbp), %rdi
callq 0x63ea0
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 $0x6b, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x84840
movl -0x48(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rdi
callq 0x63ea0
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jge 0x84083
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 0x640a0
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 0x848e0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x84102
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x84ef0
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 $0x48, %esi
callq 0x63980
cmpb $0x0, 0x18(%rbp)
je 0x84100
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x16e40
jmp 0x84102
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 0x85030
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 $0x6b, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x84840
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x66470
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)