// File: /workspace/github_cpp_makefile_star2_O1/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 0x5f06
cmpl $0x0, 0x104(%rbx)
jle 0x3411
leaq -0x1(%r14), %rax
imulq %r14, %rax
addq $-0x2, %r14
imulq %rax, %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
cmpl $0x0, 0x104(%rbx)
jle 0x33f6
xorl %esi, %esi
cmpq (%rsp), %rsi
je 0x33e3
cmpl $0x0, 0x104(%rbx)
jle 0x33e3
xorl %r14d, %r14d
movq %rsi, 0x10(%rsp)
cmpq %rsi, %r14
sete %al
cmpq (%rsp), %r14
sete %cl
orb %al, %cl
jne 0x33d0
movl $0x1, %ebp
cmpq %r14, %rsi
setae %al
cmpq $0x5, %rbp
setb %cl
testb %cl, %al
jne 0x33c3
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 0x54a2
movq %rbx, %rdi
movl %r12d, %esi
movl %r15d, %edx
movl %eax, %ecx
movl 0x1c(%rsp), %r8d
movsd 0x8(%rsp), %xmm0
callq 0x5660
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x32f0
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 0x32e1
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0x20(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x50(%rbx)
jmp 0x32f0
movq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x6890
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 0x33be
movq 0x9ca9(%rip), %rdi      # 0xcfd8
movq %r13, %rsi
callq 0x20d0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5d68(%rip), %rsi      # 0x90b1
callq 0x2270
movq %r15, %rdi
movq 0x40(%rsp), %rsi
callq 0x20d0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5d58(%rip), %rsi      # 0x90c5
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 0x3230
incq %r14
movslq 0x104(%rbx), %rax
cmpq %rax, %r14
jl 0x3216
incq %rsi
movslq 0x104(%rbx), %rax
cmpq %rax, %rsi
jl 0x31f7
movq (%rsp), %rdx
incq %rdx
movslq 0x104(%rbx), %rax
movq %rdx, (%rsp)
cmpq %rax, %rdx
jl 0x31e8
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq