// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/data.c
// Function: find_class_means
Instanceptr find_class_means(Instanceptr myptr,int *counts)
{
 /*!Last Changed 11.08.2007 added allocate_feature_counts and free_feature_counts*/
 /*!Last Changed 22.03.2005 added empty_instance*/
 /*!Last Changed 02.02.2004 added safemalloc and safecalloc*/
 /*!Last Changed 20.03.2002*/
 int i,j;
 int*** feature_counts = NULL;
 Instanceptr temp, temp1, result;
 if (!mustrealize)
   result = empty_link_list_of_instances(current_dataset->featurecount, current_dataset->classno);
 else
   result = empty_link_list_of_instances(current_dataset->multifeaturecount, current_dataset->classno);
 if (!mustrealize)
   feature_counts = allocate_feature_counts();
 temp1 = result;
 while (temp1)/*Initializing class means*/
  {
   if (mustrealize)
    {
     for (i = 0; i < current_dataset->multifeaturecount; i++)
       if (i != current_dataset->classdefno)
         temp1->values[i].floatvalue = 0;
    }
   else
    {
     for (i = 0; i < current_dataset->featurecount;i++)
       switch (current_dataset->features[i].type)
        {
         case INTEGER:temp1->values[i].floatvalue = 0;
                      break;
         case    REAL:temp1->values[i].floatvalue = 0;
                      break;
        }
    }
   temp1 = temp1->next;
  }
 temp = myptr;
 while (temp)/*Adding values to total*/
  {
   i = give_classno(temp);
   temp1 = data_x(result, i);
   if (mustrealize)
    {
     for (i = 0; i < current_dataset->multifeaturecount; i++)
       if (i != current_dataset->classdefno)
         temp1->values[i].floatvalue += temp->values[i].floatvalue;
    }
   else
    {
     for (j = 0; j < current_dataset->featurecount; j++)
       switch (current_dataset->features[j].type)
        {
         case INTEGER:temp1->values[j].floatvalue += temp->values[j].intvalue;
                      break;
         case    REAL:temp1->values[j].floatvalue += temp->values[j].floatvalue;
                      break;
         case  STRING:feature_counts[i][j][temp->values[j].stringindex]++;
                      break;
        }
    }
   temp = temp->next;
  }
 temp1 = result;
 j = 0;
 while (temp1)
  {
   if (mustrealize)
    {
     for (i = 0; i < current_dataset->multifeaturecount; i++)
       if (i != current_dataset->classdefno)
        {
         if (counts[j] != 0)
           temp1->values[i].floatvalue /= counts[j];
         else
           temp1->values[i].floatvalue = 0;         
        }
    }
   else
    {
     for (i = 0; i < current_dataset->featurecount; i++)
       switch (current_dataset->features[i].type)
        {
         case INTEGER:if (counts[j] != 0)
                        temp1->values[i].floatvalue /= counts[j];
                      else
                        temp1->values[i].floatvalue = 0;
                      break;
         case    REAL:if (counts[j]!=0)
                        temp1->values[i].floatvalue /= counts[j];
                      else
                        temp1->values[i].floatvalue = 0;
                      break;
         case  STRING:temp1->values[i].stringindex = find_max_in_list(feature_counts[j][i], current_dataset->features[i].valuecount);
                      break;
        }
    }
   temp1 = temp1->next;
   j++;
  }
 if (!mustrealize)
   free_feature_counts(feature_counts);
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
leaq 0x3c9695(%rip), %rax    # 0x3e1f74
cmpl $0x0, (%rax)
jne 0x1890c
leaq 0xecf55(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x1bc(%rax), %edi
leaq 0xecf45(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %esi
callq 0x18580
movq %rax, -0x38(%rbp)
jmp 0x18932
leaq 0xecf2d(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x1c0(%rax), %edi
leaq 0xecf1d(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %esi
callq 0x18580
movq %rax, -0x38(%rbp)
leaq 0x3c963b(%rip), %rax    # 0x3e1f74
cmpl $0x0, (%rax)
jne 0x18947
callq 0x185f0
movq %rax, -0x20(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x18a4f
leaq 0x3c9613(%rip), %rax    # 0x3e1f74
cmpl $0x0, (%rax)
je 0x189bc
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0xecec9(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1c0(%rcx), %eax
jge 0x189b7
movl -0x14(%rbp), %eax
leaq 0xeceb4(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1407128(%rcx), %eax
je 0x189aa
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x189ac
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1896d
jmp 0x18a3e
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0xece73(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x18a3c
leaq 0xece61(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x3c(%rbp)
testl %eax, %eax
je 0x18a07
jmp 0x189fd
movl -0x3c(%rbp), %eax
subl $0x2, %eax
je 0x18a1c
jmp 0x18a2f
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18a2f
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18a31
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x189c3
jmp 0x18a3e
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x1894f
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x18be8
movq -0x28(%rbp), %rdi
callq 0x43530
movl %eax, -0x14(%rbp)
movq -0x38(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x46c40
movq %rax, -0x30(%rbp)
leaq 0x3c94ef(%rip), %rax    # 0x3e1f74
cmpl $0x0, (%rax)
je 0x18af2
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0xecda5(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1c0(%rcx), %eax
jge 0x18aed
movl -0x14(%rbp), %eax
leaq 0xecd90(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1407128(%rcx), %eax
je 0x18ae0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18ae2
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x18a91
jmp 0x18bd7
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
leaq 0xecd3d(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x18bd5
leaq 0xecd27(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x40(%rbp)
testl %eax, %eax
je 0x18b4b
jmp 0x18b37
movl -0x40(%rbp), %eax
subl $0x1, %eax
je 0x18b99
jmp 0x18b41
movl -0x40(%rbp), %eax
subl $0x2, %eax
je 0x18b72
jmp 0x18bc5
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18bc5
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18bc5
movq -0x20(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x18(%rbp), %rdx
movslq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x18bc7
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x18af9
jmp 0x18bd7
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x18a57
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x18(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x18e12
leaq 0x3c936b(%rip), %rax    # 0x3e1f74
cmpl $0x0, (%rax)
je 0x18ca3
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0xecc1d(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1c0(%rcx), %eax
jge 0x18c9e
movl -0x14(%rbp), %eax
leaq 0xecc08(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1407128(%rcx), %eax
je 0x18c8e
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x18c79
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm1
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18c8c
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18c8e
jmp 0x18c90
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x18c19
jmp 0x18df8
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0xecb8c(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x18df6
leaq 0xecb76(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x44(%rbp)
testl %eax, %eax
je 0x18d03
jmp 0x18ce8
movl -0x44(%rbp), %eax
subl $0x1, %eax
je 0x18d9c
jmp 0x18cf6
movl -0x44(%rbp), %eax
subl $0x2, %eax
je 0x18d51
jmp 0x18de6
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x18d39
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm1
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18d4c
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18de6
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x18d87
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm1
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18d9a
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x18de6
movq -0x20(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xeca89(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x14(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl 0x18(%rax), %esi
callq 0x50070
movl %eax, %edx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x14(%rbp), %rcx
movl %edx, (%rax,%rcx,8)
jmp 0x18de8
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x18caa
jmp 0x18df8
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x18bf7
leaq 0x3c915b(%rip), %rax    # 0x3e1f74
cmpl $0x0, (%rax)
jne 0x18e27
movq -0x20(%rbp), %rdi
callq 0x18730
movq -0x38(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)