// File: /workspace/github_cpp_makefile_star2_O3/fukunagatsu[P]LogicomeProfiler/logicome_profiler.cpp
// Function: LogicomeProfiler::FirstScreeningForFWER()
void LogicomeProfiler::FirstScreeningForFWER(){
  int N = _number_of_samples;
  
  long long int count = 0;
  long long int ne = _number_of_elements;
  long long int max_size_count = 4*ne*(ne-1)*(ne-2); 
  double bf_threshold = _alpha/max_size_count;
  _result_vector.reserve(10000);

  for(int c = 0; c < _number_of_elements; c++){
    for(int a = 0; a < _number_of_elements; a++){
      if(a!=c){
	for(int b = 0; b < _number_of_elements; b++){
	  if(b!=a && b!=c){
	    for(int l = 1; l <=6; l++){
	      if(l>=5 || a < b){
		count++;
		int x = _logic_occurrence_tensor[a][b][l];
		int y = _count_vector[c];
		int z = CountLogicOccurrence(a,b,c,l);
		double prob = CalcProb(x,y,z,N,bf_threshold);
		
		if(prob < bf_threshold){
		  Node new_node(a,b,c,l,prob);
		  _result_vector.push_back(new_node);
		}

		if(count%1000000 == 0){
		  cout << count<< "/" << max_size_count << " " << _result_vector.size() << endl;
		}
	      }
	    }
	  }
	}
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movl 0x100(%rdi), %eax
movl %eax, 0x1c(%rsp)
movslq 0x104(%rdi), %r14
movsd 0x108(%rdi), %xmm0
movsd %xmm0, 0x8(%rsp)
addq $0x48, %rdi
movl $0x2710, %esi           # imm = 0x2710
movq %rdi, 0x38(%rsp)
callq 0x5e30
movl 0x104(%rbx), %eax
testl %eax, %eax
jle 0x33c2
leaq -0x1(%r14), %rcx
imulq %r14, %rcx
addq $-0x2, %r14
imulq %rcx, %r14
shlq $0x2, %r14
movq %r14, 0x40(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq $0x0, (%rsp)
xorl %r13d, %r13d
testl %eax, %eax
jle 0x33ab
xorl %esi, %esi
cmpq (%rsp), %rsi
je 0x339c
testl %eax, %eax
jle 0x339c
xorl %r14d, %r14d
movq %rsi, 0x10(%rsp)
cmpq %rsi, %r14
sete %cl
cmpq (%rsp), %r14
sete %dl
orb %cl, %dl
jne 0x338d
movl $0x1, %ebp
cmpq %r14, %rsi
setae %al
cmpq $0x5, %rbp
setb %cl
testb %cl, %al
jne 0x337a
leaq (%rsi,%rsi,2), %rax
movq (%rbx), %rcx
movq 0x30(%rbx), %rdx
movq (%rcx,%rax,8), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax,%rbp,4), %r12d
movq (%rsp), %rcx
movl (%rdx,%rcx,4), %r15d
movq %rbx, %rdi
movl %r14d, %edx
movl %ebp, %r8d
callq 0x5422
movq %rbx, %rdi
movl %r12d, %esi
movl %r15d, %edx
movl %eax, %ecx
movl 0x1c(%rsp), %r8d
movsd 0x8(%rsp), %xmm0
callq 0x55de
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x32a7
movq 0x10(%rsp), %rax
movl %eax, 0x20(%rsp)
movl %r14d, 0x24(%rsp)
movq (%rsp), %rax
movl %eax, 0x28(%rsp)
movl %ebp, 0x2c(%rsp)
movsd %xmm0, 0x30(%rsp)
movq 0x50(%rbx), %rsi
cmpq 0x58(%rbx), %rsi
je 0x3298
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0x20(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x50(%rbx)
jmp 0x32a7
movq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x67a0
incq %r13
movq %r13, %rax
movabsq $0x790fb65668c26139, %rcx # imm = 0x790FB65668C26139
imulq %rcx, %rax
movabsq $0x218def416bd80, %rcx  # imm = 0x218DEF416BD80
addq %rcx, %rax
rorq $0x6, %rax
movabsq $0x10c6f7a0b5ec, %rcx   # imm = 0x10C6F7A0B5EC
cmpq %rcx, %rax
ja 0x3375
movq 0x9cf2(%rip), %rdi      # 0xcfd8
movq %r13, %rsi
callq 0x20d0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5dd1(%rip), %rsi      # 0x90d1
callq 0x2270
movq %r15, %rdi
movq 0x40(%rsp), %rsi
callq 0x20d0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5dc1(%rip), %rsi      # 0x90e5
callq 0x2270
movq 0x50(%rbx), %rsi
subq 0x48(%rbx), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
movq %r15, %rdi
callq 0x2160
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
movq 0x10(%rsp), %rsi
incq %rbp
cmpq $0x7, %rbp
jne 0x31e7
movl 0x104(%rbx), %eax
incq %r14
movslq %eax, %rcx
cmpq %rcx, %r14
jl 0x31cd
incq %rsi
movslq %eax, %rcx
cmpq %rcx, %rsi
jl 0x31b3
movq (%rsp), %rsi
incq %rsi
movslq %eax, %rcx
movq %rsi, (%rsp)
cmpq %rcx, %rsi
jl 0x31a9
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop