// File: /workspace/github_c_makefile_star2_O0/ComplexNetworks-DCC-FCUP[P]gtrieScanner/GTrie.cpp
// Function: GTrieNode::insertConditionsFiltered(std::__cxx11::list<std::pair<int, int>, std::allocator<std::pair<int, int>>>*)
void GTrieNode::insertConditionsFiltered(list<iPair> *conditions) {

  // Already has "empty set" of conditions
  if (cond_ok && cond_this_ok) return;

  list<iPair> aux;
  list<int>   aux_this_node;
  list<iPair>::iterator jj, kk;
  iPair p;


  /*for (jj=conditions->begin(); jj!=conditions->end(); jj++)
    printf("%d < %d  |  ", jj->first, jj->second);
    putchar('\n');*/
  

  // A bit slow but works (search a<b and b<c: remove a<c)
  for (jj=conditions->begin(); jj!=conditions->end(); jj++)
    for (kk=conditions->begin(); kk!=conditions->end(); kk++)
      if (jj->second == kk->first) {
	p.first  = jj->first;
	p.second = kk->second;
	conditions->remove(p); // does not invalidade jj and kk
      }

  /*for (jj=conditions->begin(); jj!=conditions->end(); jj++)
    printf("%d < %d  |  ", jj->first, jj->second);
    putchar('\n');*/

  for (jj=conditions->begin(); jj!=conditions->end(); jj++) {
    if (max(jj->first, jj->second)<=depth-1) // HERE!
      aux.push_back(*jj);
    if (jj->second == depth-1)
      aux_this_node.push_back(jj->first);
 } 

  // Deal with ancestor conditions
  if (!cond_ok) {

    if (aux.size()==0) {
      cond_ok = true;
      cond.clear();
    } else {

      list< list<iPair> >::iterator mm;
      bool is_contained = false;
      // A bit slow, but saves a lot of conditions
      for (mm=cond.begin(); mm!=cond.end();) {
	if (_is_pairset_included(*mm, aux)) {
	  is_contained = true;
	  break;
	}
	else if (_is_pairset_included(aux, *mm)) {
	  //printf("Erasing old condition (ancestors) !!\n");
	  mm = cond.erase(mm);
	  if (mm == cond.end()) break;
	}
	else mm++;
      }

      if (!is_contained) cond.push_back(aux);
      //else printf("avoid insertion (ancestors)!\n");
    }
  }

  return;

 // Deal with this node conditions {
  if (!cond_this_ok) {
    
    if (aux_this_node.size()==0) {
      cond_this_ok = true;
      this_node_cond.clear();
      } else {
    
      list< list<int> >::iterator mm;

      bool is_contained = false;
      // A bit slow, but saves a lot of conditions
      for (mm=this_node_cond.begin(); mm!=this_node_cond.end(); mm++) {
        if (_is_intset_included(*mm, aux_this_node)) {
            is_contained = true;
            break;
        }
        if (_is_intset_included(aux_this_node, *mm)) {
          //printf("Erasing old condition (this_node) !!\n");
          mm = this_node_cond.erase(mm);
       }
      }

      if (!is_contained) this_node_cond.push_back(aux_this_node);
      //else printf("avoid insertion (this_node)!\n");      
    }
  }

   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x158(%rbp)
testb $0x1, 0x48(%rax)
je 0x10d36
movq -0x158(%rbp), %rax
testb $0x1, 0x49(%rax)
je 0x10d36
jmp 0x11233
leaq -0x28(%rbp), %rdi
callq 0x15940
leaq -0x40(%rbp), %rdi
callq 0x15960
leaq -0x48(%rbp), %rdi
callq 0xc9b0
leaq -0x50(%rbp), %rdi
callq 0xc9b0
leaq -0x58(%rbp), %rdi
callq 0xc9d0
jmp 0x10d65
movq -0x10(%rbp), %rdi
callq 0x15560
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0xd700
movq %rax, -0x78(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x15590
testb $0x1, %al
jne 0x10d9d
jmp 0x10e74
movq -0x10(%rbp), %rdi
callq 0x15560
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0xd700
movq %rax, -0x88(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x15590
testb $0x1, %al
jne 0x10ddb
jmp 0x10e5b
leaq -0x48(%rbp), %rdi
callq 0x155c0
movl 0x4(%rax), %eax
movl %eax, -0x15c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x155c0
movq %rax, %rcx
movl -0x15c(%rbp), %eax
cmpl (%rcx), %eax
jne 0x10e42
leaq -0x48(%rbp), %rdi
callq 0x155c0
movl (%rax), %eax
movl %eax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x155c0
movl 0x4(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x15980
jmp 0x10e2f
jmp 0x10e42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1121f
jmp 0x10e44
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x155e0
movq %rax, -0x90(%rbp)
jmp 0x10db2
jmp 0x10e5d
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x155e0
movq %rax, -0x98(%rbp)
jmp 0x10d7a
movq -0x10(%rbp), %rdi
callq 0x15560
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0xd700
movq %rax, -0xa8(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x15590
testb $0x1, %al
jne 0x10eb8
jmp 0x10f79
leaq -0x48(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x155c0
movq -0x178(%rbp), %rdi
movq %rax, -0x170(%rbp)
callq 0x155c0
movq -0x170(%rbp), %rdi
movq %rax, %rsi
addq $0x4, %rsi
callq 0x15aa0
movq %rax, -0x168(%rbp)
jmp 0x10ef7
movq -0x158(%rbp), %rcx
movq -0x168(%rbp), %rax
movl (%rax), %eax
movl 0x4c(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x10f2a
leaq -0x48(%rbp), %rdi
callq 0x15ae0
movq %rax, %rsi
leaq -0x28(%rbp), %rdi
callq 0xca80
jmp 0x10f28
jmp 0x10f2a
leaq -0x48(%rbp), %rdi
callq 0x155c0
movq -0x158(%rbp), %rcx
movl 0x4(%rax), %eax
movl 0x4c(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x10f60
leaq -0x48(%rbp), %rdi
callq 0x155c0
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x15b00
jmp 0x10f5e
jmp 0x10f60
jmp 0x10f62
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x155e0
movq %rax, -0xb0(%rbp)
jmp 0x10e8f
movq -0x158(%rbp), %rax
testb $0x1, 0x48(%rax)
jne 0x1120b
leaq -0x28(%rbp), %rdi
callq 0x15b40
cmpq $0x0, %rax
jne 0x10fb2
movq -0x158(%rbp), %rdi
movb $0x1, 0x48(%rdi)
addq $0x18, %rdi
callq 0x152d0
jmp 0x11209
leaq -0xb8(%rbp), %rdi
callq 0x15490
movq -0x158(%rbp), %rdi
movb $0x0, -0xb9(%rbp)
addq $0x18, %rdi
callq 0x154b0
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x158(%rbp), %rdi
addq $0x18, %rdi
callq 0x15510
movq %rax, -0xd0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x154e0
testb $0x1, %al
jne 0x1101d
jmp 0x111e6
leaq -0xb8(%rbp), %rdi
callq 0x15540
movq %rax, %rsi
leaq -0xe8(%rbp), %rdi
callq 0x15b70
jmp 0x1103a
leaq -0x100(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x15b70
jmp 0x1104c
movq -0x158(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
leaq -0x100(%rbp), %rdx
callq 0x113a0
movb %al, -0x179(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x15c10
leaq -0xe8(%rbp), %rdi
callq 0x15c10
movb -0x179(%rbp), %al
testb $0x1, %al
jne 0x11090
jmp 0x110b9
movb $0x1, -0xb9(%rbp)
jmp 0x111e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x15c10
jmp 0x1121f
leaq -0x118(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x15b70
jmp 0x110cb
leaq -0xb8(%rbp), %rdi
callq 0x15540
movq %rax, %rsi
leaq -0x130(%rbp), %rdi
callq 0x15b70
jmp 0x110e8
movq -0x158(%rbp), %rdi
leaq -0x118(%rbp), %rsi
leaq -0x130(%rbp), %rdx
callq 0x113a0
movb %al, -0x17a(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x15c10
leaq -0x118(%rbp), %rdi
callq 0x15c10
movb -0x17a(%rbp), %al
testb $0x1, %al
jne 0x1112f
jmp 0x111ca
movq -0x158(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x188(%rbp)
leaq -0x140(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x15c80
movq -0x188(%rbp), %rdi
movq -0x140(%rbp), %rsi
callq 0x15c30
movq -0x158(%rbp), %rdi
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq %rax, -0xb8(%rbp)
addq $0x18, %rdi
callq 0x15510
movq %rax, -0x148(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x15ca0
testb $0x1, %al
jne 0x111ac
jmp 0x111c8
jmp 0x111e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x15c10
jmp 0x1121f
jmp 0x111df
leaq -0xb8(%rbp), %rdi
xorl %esi, %esi
callq 0x15610
movq %rax, -0x150(%rbp)
jmp 0x111e1
jmp 0x10fea
testb $0x1, -0xb9(%rbp)
jne 0x11207
movq -0x158(%rbp), %rdi
addq $0x18, %rdi
leaq -0x28(%rbp), %rsi
callq 0x15cd0
jmp 0x11205
jmp 0x11207
jmp 0x11209
jmp 0x1120b
leaq -0x40(%rbp), %rdi
callq 0x15d10
leaq -0x28(%rbp), %rdi
callq 0x15c10
jmp 0x11233
leaq -0x40(%rbp), %rdi
callq 0x15d10
leaq -0x28(%rbp), %rdi
callq 0x15c10
jmp 0x1123c
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x3440
nopw %cs:(%rax,%rax)