// File: 8igMac[P]random-forest/src/decision_tree.cpp
// Function: random_forest::classify(data_inst)
int random_forest::classify(data_inst valiInst)
{
	// vote
	vector<int> vote(valiInst.num_cls,0);
	for (vector<decision_tree>::iterator itr = treeSet.begin();
			 itr != treeSet.end(); itr++)
		vote.at(itr->classify(valiInst))++;

	// reach consensus among trees
	int majorVote=0;
	for (int i=1; i<(int)vote.size(); i++)
	{
		if (vote[majorVote] < vote[i])
			majorVote = i;
		else if (vote[majorVote] == vote[i])
		{
			// break tie by select random
			if (rand()%2 == 0)
				majorVote = i;
		}
	}

	return majorVote;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rsi, -0xa8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movslq 0x24(%rsi), %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0x2c(%rbp)
leaq -0x2d(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x7a50
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rcx
leaq -0x28(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x8050
jmp 0x7044
leaq -0x2d(%rbp), %rdi
callq 0x7ae0
movq -0xa0(%rbp), %rdi
callq 0x88b0
movq %rax, -0x48(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x8920
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x88e0
testb $0x1, %al
jne 0x7083
jmp 0x7148
leaq -0x48(%rbp), %rdi
callq 0x8950
movq -0xa8(%rbp), %rsi
movq %rax, -0xb0(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x44d0
jmp 0x70a5
movq -0xb0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x6b80
movl %eax, -0xb4(%rbp)
jmp 0x70bd
movl -0xb4(%rbp), %eax
movslq %eax, %rsi
leaq -0x28(%rbp), %rdi
callq 0x89b0
movq %rax, -0xc0(%rbp)
jmp 0x70d8
movq -0xc0(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
leaq -0x78(%rbp), %rdi
callq 0x3540
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x8970
movq %rax, -0x80(%rbp)
jmp 0x705d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2d(%rbp), %rdi
callq 0x7ae0
jmp 0x725f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x7256
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3540
jmp 0x7256
movl $0x0, -0x84(%rbp)
movl $0x1, -0x88(%rbp)
movl -0x88(%rbp), %eax
movl %eax, -0xc4(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x7f80
movq %rax, %rcx
movl -0xc4(%rbp), %eax
cmpl %ecx, %eax
jge 0x7232
movslq -0x84(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x7b00
movl (%rax), %eax
movl %eax, -0xc8(%rbp)
movslq -0x88(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x7b00
movq %rax, %rcx
movl -0xc8(%rbp), %eax
cmpl (%rcx), %eax
jge 0x71c5
movl -0x88(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x721c
movslq -0x84(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x7b00
movl (%rax), %eax
movl %eax, -0xcc(%rbp)
movslq -0x88(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x7b00
movq %rax, %rcx
movl -0xcc(%rbp), %eax
cmpl (%rcx), %eax
jne 0x721a
callq 0x2070
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x7218
movl -0x88(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x721a
jmp 0x721c
jmp 0x721e
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x715c
movl -0x84(%rbp), %eax
movl %eax, -0xd0(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x7c40
movl -0xd0(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x7c40
movq -0x38(%rbp), %rdi
callq 0x2270
nopl (%rax,%rax)