// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movq %rdi, %rbx
movl 0x100(%rdi), %eax
movl %eax, 0x24(%rsp)
movslq 0x104(%rdi), %rcx
leaq -0x1(%rcx), %rax
imulq %rcx, %rax
addq $-0x2, %rcx
imulq %rax, %rcx
shlq $0x2, %rcx
movsd 0x108(%rdi), %xmm1
movq %rcx, 0x30(%rsp)
cvtsi2sd %rcx, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
addq $0x48, %rdi
movl $0x2710, %esi           # imm = 0x2710
movq %rdi, 0x38(%rsp)
callq 0x4754
movq %rbx, 0x8(%rsp)
movl 0x104(%rbx), %eax
xorl %ecx, %ecx
xorl %ebx, %ebx
movq 0x8(%rsp), %r14
movslq %eax, %rdx
cmpq %rdx, %rcx
jge 0x30d0
xorl %esi, %esi
movq %rcx, 0x10(%rsp)
movslq %eax, %rdx
cmpq %rdx, %rsi
jge 0x30c8
cmpq %rcx, %rsi
jne 0x2f60
incq %rsi
jmp 0x2f4a
xorl %r15d, %r15d
movq %rsi, 0x18(%rsp)
movslq %eax, %rdx
cmpq %rdx, %r15
jge 0x2f5b
cmpq %rsi, %r15
sete %dil
cmpq %rcx, %r15
sete %dl
orb %dil, %dl
jne 0x30c0
pushq $0x1
popq %rbp
cmpq $0x7, %rbp
je 0x30b5
cmpq %r15, %rsi
setae %al
cmpq $0x5, %rbp
setb %dl
testb %dl, %al
jne 0x30ad
imulq $0x18, %rsi, %rax
movq (%r14), %rdi
movq 0x30(%r14), %rdx
movq (%rdi,%rax), %rax
imulq $0x18, %r15, %rdi
movq (%rax,%rdi), %rax
movl (%rax,%rbp,4), %r12d
movl (%rdx,%rcx,4), %r13d
movq %r14, %rdi
movl %r15d, %edx
movl %ebp, %r8d
callq 0x3eea
movq %r14, %rdi
movl %r12d, %esi
movl %r13d, %edx
movl %eax, %ecx
movl 0x24(%rsp), %r8d
movsd 0x28(%rsp), %xmm0
callq 0x4034
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x302c
movq 0x18(%rsp), %rax
movl %eax, 0x40(%rsp)
movl %r15d, 0x44(%rsp)
movq 0x10(%rsp), %rax
movl %eax, 0x48(%rsp)
movl %ebp, 0x4c(%rsp)
movsd %xmm0, 0x50(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x483a
incq %rbx
movq %rbx, %rax
cqto
movl $0xf4240, %ecx          # imm = 0xF4240
idivq %rcx
testq %rdx, %rdx
jne 0x30a3
movq 0x9f90(%rip), %rdi      # 0xcfd8
movq %rbx, %rsi
callq 0x20b0
movq %rax, %rdi
leaq 0x5057(%rip), %rsi      # 0x80b1
callq 0x21b0
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x20b0
movq %rax, %rdi
leaq 0x504f(%rip), %rsi      # 0x80c5
callq 0x21b0
movq %rax, %rdi
movq 0x8(%rsp), %rcx
movq 0x50(%rcx), %rax
subq 0x48(%rcx), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %rsi
callq 0x2140
movq %rax, %rdi
callq 0x2100
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rsi
incq %rbp
jmp 0x2f89
movq 0x8(%rsp), %rax
movl 0x104(%rax), %eax
incq %r15
jmp 0x2f68
incq %rcx
jmp 0x2f37
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop