// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movl %ecx, %r15d
movq (%rdi), %rcx
xorl %eax, %eax
testb $0x8, 0x2e(%rcx)
je 0x52fd0
movq %rdx, %r12
movq %rsi, %r14
testq %rdx, %rdx
je 0x52fb4
leaq 0x20(%r14), %r10
xorl %ecx, %ecx
pushq $0x1
popq %rax
movq (%r10), %r10
testq %r10, %r10
je 0x52fdf
movl 0x28(%r10), %edx
testl %edx, %edx
cmovlel %ecx, %edx
shlq $0x4, %rdx
addq $0x10, %rdx
xorl %edi, %edi
leaq 0x10(%rdi), %rsi
cmpq %rsi, %rdx
je 0x52fae
movslq 0x40(%r10,%rdi), %r8
cmpl $0x0, (%r12,%r8,4)
jns 0x52fd0
movq %rsi, %rdi
testl %r15d, %r15d
je 0x52f82
movswl 0x40(%r14), %r9d
movq %rsi, %rdi
cmpl %r9d, %r8d
jne 0x52f82
jmp 0x52fd0
addq $0x8, %r10
jmp 0x52f67
movq %r14, %rdi
callq 0x4a434
testq %rax, %rax
je 0x52fc6
pushq $0x1
popq %rax
jmp 0x52fd0
xorl %eax, %eax
cmpq $0x0, 0x20(%r14)
setne %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x4a434
xorl %edx, %edx
movq %r14, -0x50(%rbp)
testq %rax, %rax
je 0x530bd
movl 0x28(%rax), %ecx
leaq 0x40(%rax), %rsi
movq %rsi, -0x40(%rbp)
testl %ecx, %ecx
cmovlel %edx, %ecx
xorl %esi, %esi
movq %rax, -0x38(%rbp)
movq %rcx, -0x30(%rbp)
cmpq %rcx, %rsi
je 0x530b4
movq %rsi, -0x48(%rbp)
movq %rsi, %rax
shlq $0x4, %rax
movzwl 0x42(%r14), %ecx
testw %cx, %cx
cmovlel %edx, %ecx
movq -0x40(%rbp), %rdx
movq 0x8(%rdx,%rax), %r13
movzwl %cx, %eax
movq %rax, -0x58(%rbp)
xorl %ecx, %ecx
xorl %ebx, %ebx
cmpq %rbx, -0x58(%rbp)
je 0x5309e
movq 0x8(%r14), %rax
testq %r13, %r13
je 0x5306e
movq (%rax,%rcx), %rdi
movq %r13, %rsi
movq %rcx, %r14
callq 0xb1bf
movq %r14, %rcx
movq -0x50(%rbp), %r14
testl %eax, %eax
jne 0x53095
jmp 0x53075
testb $0x1, 0x2a(%rax,%rcx)
je 0x53095
cmpl $0x0, (%r12,%rbx,4)
jns 0x52fc1
testl %r15d, %r15d
je 0x53095
movswq 0x40(%r14), %rax
movl %eax, %eax
cmpq %rax, %rbx
je 0x52fc1
incq %rbx
addq $0x30, %rcx
jmp 0x53043
movq -0x48(%rbp), %rsi
incq %rsi
movq -0x38(%rbp), %rax
xorl %edx, %edx
movq -0x30(%rbp), %rcx
jmp 0x53010
movq 0x18(%rax), %rax
jmp 0x52fed
xorl %eax, %eax
jmp 0x52fd0