// File: /workspace/github_cpp_makefile_star2_O2/0asa[P]TTree-source/Scorer.cpp
// Function: Scorer::getRandNumericalScore(std::vector<unsigned int, std::allocator<unsigned int>>&, unsigned int, ScoreInfo&)
void Scorer::getRandNumericalScore(std::vector<unsigned int> &obj, unsigned int att, ScoreInfo &si) {		
	Score score;
	ContingencyTable ctable(2,2);

	std::vector<TUPLET> values;
	for (int i = 0 ; i < obj.size() ; ++i) {
		TUPLET a; a.value = db->getAttVal(obj[i], att) ; a.ind = obj[i];
		//printf("%d > %f\n",db->getAttVal(obj[i], att),a.value);
		values.push_back(a);
	}
	sort(values.begin(), values.end(),cmp);

	// get all the possible tresholds on values
	std::vector<double> th;
	double v = values[0].value;
	for (int i = 1 ; i < values.size() ; ++i) {
		if (v != values[i].value) {
			th.push_back((v+values[i].value)/2.0);
			v = values[i].value;
		}
	}
	if (th.size() > 0) {
	int r = rand() % th.size(); // got a random treshold
	// now use it to fill the ctable
	for (int i = 0 ; i < obj.size() ; ++i) {
		if (db->getAttVal(obj[i], att) < th[r])
			ctable.addLess(db->getOutput(obj[i]), db->getWeight(obj[i]));
		else
			ctable.addGeq(db->getOutput(obj[i]), db->getWeight(obj[i]));
	}
	si.update(att,th[r],score.getScore(ctable));
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, 0x40(%rsp)
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r12
movl $0x1, 0x1c(%rsp)
leaq 0x50(%rsp), %rdi
pushq $0x2
popq %rdx
movl %edx, %esi
callq 0xa834
leaq 0x20(%rsp), %r13
andq $0x0, 0x10(%r13)
xorps %xmm0, %xmm0
movaps %xmm0, (%r13)
xorl %r14d, %r14d
movq %rsp, %rbp
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x110b1
movq (%r12), %rcx
movl (%rax,%r14,4), %eax
movl 0x24(%rcx), %edx
imull %eax, %edx
addl %ebx, %edx
movq 0x40(%rcx), %rcx
movswl (%rcx,%rdx,2), %ecx
cvtsi2ss %ecx, %xmm0
movss %xmm0, (%rsp)
movl %eax, 0x4(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x11636
incq %r14
jmp 0x11069
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
leaq -0x109(%rip), %rdx      # 0x10fb9
callq 0x11de9
xorps %xmm0, %xmm0
movq %rsp, %r13
andq $0x0, 0x10(%r13)
movaps %xmm0, (%r13)
movq 0x20(%rsp), %rax
cvtss2sd (%rax), %xmm0
pushq $0x1
popq %r14
leaq 0x48(%rsp), %rbp
movq 0x28(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jbe 0x11135
cvtss2sd (%rax,%r14,8), %xmm1
ucomisd %xmm1, %xmm0
jne 0x11108
jnp 0x11130
addsd %xmm1, %xmm0
mulsd 0x1efc(%rip), %xmm0     # 0x13010
movsd %xmm0, 0x48(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xb214
movq 0x20(%rsp), %rax
cvtss2sd (%rax,%r14,8), %xmm0
incq %r14
jmp 0x110e9
movq 0x8(%rsp), %rax
cmpq (%rsp), %rax
je 0x11205
callq 0x30a0
cltq
movq 0x8(%rsp), %rcx
subq (%rsp), %rcx
sarq $0x3, %rcx
xorl %ebp, %ebp
xorl %edx, %edx
divq %rcx
movslq %edx, %r14
shlq $0x3, %r14
leaq 0x50(%rsp), %r13
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbp, %rcx
jbe 0x111d1
movq (%r12), %rcx
movl (%rax,%rbp,4), %eax
movl 0x24(%rcx), %edx
imull %eax, %edx
addl %ebx, %edx
movq 0x40(%rcx), %rsi
movswl (%rsi,%rdx,2), %edx
cvtsi2sd %edx, %xmm0
movq (%rsp), %rdx
movsd (%rdx,%r14), %xmm1
ucomisd %xmm0, %xmm1
movq 0x8(%rcx), %rdx
movq 0x28(%rcx), %rcx
movswl (%rcx,%rax,2), %esi
movsd (%rdx,%rax,8), %xmm0
jbe 0x111c4
movq %r13, %rdi
callq 0xab62
jmp 0x111cc
movq %r13, %rdi
callq 0xab42
incq %rbp
jmp 0x1116b
movq (%rsp), %rax
movsd (%rax,%r14), %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0x1c(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x101dc
movaps %xmm0, %xmm1
movq 0x40(%rsp), %rdi
movl %ebx, %esi
movsd 0x38(%rsp), %xmm0
callq 0x105c6
movq %rsp, %rdi
callq 0x6de4
leaq 0x20(%rsp), %rdi
callq 0x11c72
leaq 0x50(%rsp), %rdi
callq 0xa982
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11246
jmp 0x11239
jmp 0x11239
movq %rax, %rbx
movq %rsp, %rdi
callq 0x6de4
jmp 0x11249
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x11c72
leaq 0x50(%rsp), %rdi
callq 0xa982
movq %rbx, %rdi
callq 0x3330
nop