// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3FkRequired
SQLITE_PRIVATE int sqlite3FkRequired(
  Parse *pParse,                  /* Parse context */
  Table *pTab,                    /* Table being modified */
  int *aChange,                   /* Non-NULL for UPDATE operations */
  int chngRowid                   /* True for UPDATE that affects rowid */
){
  if( pParse->db->flags&SQLITE_ForeignKeys ){
    if( !aChange ){
      /* A DELETE operation. Foreign key processing is required if the 
      ** table in question is either the child or parent table for any 
      ** foreign key constraint.  */
      return (sqlite3FkReferences(pTab) || pTab->pFKey);
    }else{
      /* This is an UPDATE. Foreign key processing is only required if the
      ** operation modifies one or more child or parent key columns. */
      int i;
      FKey *p;

      /* Check if any child key columns are being modified. */
      for(p=pTab->pFKey; p; p=p->pNextFrom){
        for(i=0; i<p->nCol; i++){
          int iChildKey = p->aCol[i].iFrom;
          if( aChange[iChildKey]>=0 ) return 1;
          if( iChildKey==pTab->iPKey && chngRowid ) return 1;
        }
      }

      /* Check if any parent key columns are being modified. */
      for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
        for(i=0; i<p->nCol; i++){
          char *zKey = p->aCol[i].zCol;
          int iKey;
          for(iKey=0; iKey<pTab->nCol; iKey++){
            Column *pCol = &pTab->aCol[iKey];
            if( (zKey ? !sqlite3StrICmp(pCol->zName, zKey)
                      : (pCol->colFlags & COLFLAG_PRIMKEY)!=0) ){
              if( aChange[iKey]>=0 ) return 1;
              if( iKey==pTab->iPKey && chngRowid ) return 1;
            }
          }
        }
      }
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r14d
movq (%rdi), %rax
xorl %ecx, %ecx
testb $0x8, 0x2e(%rax)
jne 0x5c224
movl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r15
movq %rsi, %rbx
testq %rdx, %rdx
je 0x5c397
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x5c27d
movl $0x1, %ecx
movslq 0x28(%rax), %rdx
testq %rdx, %rdx
jle 0x5c274
shlq $0x4, %rdx
xorl %esi, %esi
movslq 0x40(%rax,%rsi), %rdi
cmpl $0x0, (%r15,%rdi,4)
jns 0x5c213
testl %r14d, %r14d
je 0x5c26b
movswl 0x40(%rbx), %r8d
cmpl %r8d, %edi
je 0x5c213
addq $0x10, %rsi
cmpq %rsi, %rdx
jne 0x5c250
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x5c241
movq %rbx, %rdi
callq 0x4fce9
movl $0x0, %ecx
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x5c213
leaq 0x19dc6(%rip), %rdx     # 0x76060
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
testq %rax, %rax
jle 0x5c37b
movq -0x30(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x38(%rbp)
movswq 0x42(%rbx), %r8
xorl %eax, %eax
testw %r8w, %r8w
jle 0x5c36e
movq %rax, %rcx
shlq $0x4, %rcx
movq -0x38(%rbp), %rsi
movq 0x8(%rsi,%rcx), %r10
movq 0x8(%rbx), %r11
xorl %r12d, %r12d
leaq (%r12,%r12,2), %rcx
shlq $0x4, %rcx
addq %r11, %rcx
testq %r10, %r10
je 0x5c322
movq (%rcx), %rdi
movb (%rdi), %cl
testb %cl, %cl
je 0x5c32a
incq %rdi
movq %r10, %r13
movzbl %cl, %esi
movb (%rsi,%rdx), %sil
movzbl (%r13), %r9d
cmpb (%r9,%rdx), %sil
jne 0x5c32d
incq %r13
movb (%rdi), %cl
incq %rdi
testb %cl, %cl
jne 0x5c302
jmp 0x5c32d
testb $0x1, 0x2a(%rcx)
jne 0x5c33d
jmp 0x5c362
movq %r10, %r13
movzbl %cl, %ecx
movb (%rcx,%rdx), %cl
movzbl (%r13), %esi
cmpb (%rsi,%rdx), %cl
jne 0x5c362
movl $0x1, %ecx
cmpl $0x0, (%r15,%r12,4)
jns 0x5c213
testl %r14d, %r14d
je 0x5c362
movswq 0x40(%rbx), %rsi
movl %esi, %esi
cmpq %rsi, %r12
je 0x5c213
incq %r12
cmpq %r8, %r12
jne 0x5c2e3
incq %rax
cmpq -0x40(%rbp), %rax
jne 0x5c2c2
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
xorl %ecx, %ecx
movq %rax, -0x30(%rbp)
testq %rax, %rax
jne 0x5c29a
jmp 0x5c213
movq %rbx, %rdi
callq 0x4fce9
movl $0x1, %ecx
testq %rax, %rax
jne 0x5c213
xorl %ecx, %ecx
cmpq $0x0, 0x20(%rbx)
setne %cl
jmp 0x5c213