// File: /workspace/github_c_makefile_star2_O3/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
xorl %ecx, %ecx
btl $0x13, %edi
jb 0x5c10b
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 0x5c283
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x5c164
movl $0x1, %ecx
movslq 0x28(%rax), %rdx
testq %rdx, %rdx
jle 0x5c15b
shlq $0x4, %rdx
xorl %esi, %esi
movslq 0x40(%rax,%rsi), %rdi
cmpl $0x0, (%r15,%rdi,4)
jns 0x5c0fa
testl %r14d, %r14d
je 0x5c152
movswl 0x40(%rbx), %r8d
cmpl %r8d, %edi
je 0x5c0fa
addq $0x10, %rsi
cmpq %rsi, %rdx
jne 0x5c137
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x5c128
movq %rbx, %rdi
callq 0x4fce3
movl $0x0, %ecx
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x5c0fa
leaq 0x19f2f(%rip), %rdx     # 0x760b0
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
testq %rax, %rax
jle 0x5c267
movq -0x30(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x38(%rbp)
movswq 0x42(%rbx), %r8
xorl %eax, %eax
testw %r8w, %r8w
jle 0x5c25a
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 0x5c20f
movq (%rcx), %r13
movb (%r13), %dil
testb %dil, %dil
je 0x5c217
incq %r13
movq %r10, %rcx
movzbl %dil, %edi
movb (%rdi,%rdx), %sil
movzbl (%rcx), %r9d
cmpb (%r9,%rdx), %sil
jne 0x5c21c
incq %rcx
movb (%r13), %dil
incq %r13
testb %dil, %dil
jne 0x5c1ec
jmp 0x5c21a
testb $0x1, 0x2a(%rcx)
jne 0x5c229
jmp 0x5c24e
movq %r10, %rcx
xorl %edi, %edi
movb (%rdi,%rdx), %sil
movzbl (%rcx), %ecx
cmpb (%rcx,%rdx), %sil
jne 0x5c24e
movl $0x1, %ecx
cmpl $0x0, (%r15,%r12,4)
jns 0x5c0fa
testl %r14d, %r14d
je 0x5c24e
movswq 0x40(%rbx), %rsi
movl %esi, %esi
cmpq %rsi, %r12
je 0x5c0fa
incq %r12
cmpq %r8, %r12
jne 0x5c1ca
incq %rax
cmpq -0x40(%rbp), %rax
jne 0x5c1a9
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
xorl %ecx, %ecx
movq %rax, -0x30(%rbp)
testq %rax, %rax
jne 0x5c181
jmp 0x5c0fa
movq %rbx, %rdi
callq 0x4fce3
movl $0x1, %ecx
testq %rax, %rax
jne 0x5c0fa
xorl %ecx, %ecx
cmpq $0x0, 0x20(%rbx)
setne %cl
jmp 0x5c0fa