// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/data.c
// Function: find_mean
Instance find_mean(Instanceptr myptr)
{
 /*!Last Changed 02.02.2004 added safemalloc and safecalloc*/
 /*!Last Changed 19.03.2002*/
 int i,count=0;
 Instanceptr temp=myptr;
 int** feature_counts;
 Instance result;
 if (mustrealize)
  {
   result.values = (union value *)safemalloc(current_dataset->multifeaturecount*sizeof(union value), "find_mean", 7);
   for (i = 0;i < current_dataset->multifeaturecount; i++)
     if (i != current_dataset->classdefno)
       result.values[i].floatvalue = 0;
   while (temp)
    {
     for (i = 0;i < current_dataset->multifeaturecount; i++)
       if (i != current_dataset->classdefno)
         result.values[i].floatvalue += temp->values[i].floatvalue;
     count++;
     temp = temp->next;
    }
   for (i = 0; i < current_dataset->multifeaturecount; i++)
     if (i != current_dataset->classdefno)
       result.values[i].floatvalue /= count;
  }
 else
  {
   feature_counts = (int **)safemalloc(current_dataset->featurecount * sizeof(int *), "find_mean", 25);
   for (i = 0; i < current_dataset->featurecount; i++)
     if (current_dataset->features[i].type == STRING)
       feature_counts[i] = (int *)safecalloc(current_dataset->features[i].valuecount, sizeof(int), "find_mean", 28);
   result.values = (union value *)safemalloc(current_dataset->featurecount * sizeof(union value), "find_mean", 29);
   for (i = 0; i < current_dataset->featurecount; i++)
     switch (current_dataset->features[i].type)
      {
       case INTEGER:result.values[i].floatvalue = 0;
                    break;
       case    REAL:result.values[i].floatvalue = 0;
                    break;
      }
   while (temp)/*Adding values to total*/
    {
     for (i = 0; i < current_dataset->featurecount; i++)
       switch (current_dataset->features[i].type)
        {
         case INTEGER:result.values[i].floatvalue += temp->values[i].intvalue;
                      break;
         case    REAL:result.values[i].floatvalue += temp->values[i].floatvalue;
                      break;
         case  STRING:feature_counts[i][temp->values[i].stringindex]++;
                      break;
        }
     count++;
     temp = temp->next;
    }
   for (i = 0; i < current_dataset->featurecount; i++)
     switch (current_dataset->features[i].type)
      {
       case INTEGER:result.values[i].floatvalue /= count;
                    break;
       case    REAL:result.values[i].floatvalue /= count;
                    break;
       case  STRING:result.values[i].stringindex = find_max_in_list(feature_counts[i], current_dataset->features[i].valuecount);
                    break;
      }
   for (i = 0; i < current_dataset->featurecount; i++)
     if (current_dataset->features[i].type == STRING)     
       safe_free(feature_counts[i]);
   safe_free(feature_counts);
  }
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x30(%rbp)
movq %rdi, -0x28(%rbp)
movq %rsi, -0x8(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq 0x3c841a(%rip), %rax    # 0x3e1f74
cmpl $0x0, (%rax)
je 0x19ccb
leaq 0xebcd6(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1c0(%rax), %rdi
shlq $0x3, %rdi
leaq 0xc9516(%rip), %rsi     # 0xe3095
movl $0x7, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xebc9c(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1c0(%rcx), %eax
jge 0x19be4
movl -0xc(%rbp), %eax
leaq 0xebc87(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1407128(%rcx), %eax
je 0x19bd7
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x19bd9
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19b9a
jmp 0x19be6
cmpq $0x0, -0x18(%rbp)
je 0x19c6a
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xebc42(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1c0(%rcx), %eax
jge 0x19c50
movl -0xc(%rbp), %eax
leaq 0xebc2d(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1407128(%rcx), %eax
je 0x19c43
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movslq -0xc(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x19c45
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19bf4
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x19be6
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xebbc5(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1c0(%rcx), %eax
jge 0x19cc6
movl -0xc(%rbp), %eax
leaq 0xebbb0(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1407128(%rcx), %eax
je 0x19cb9
movq -0x30(%rbp), %rax
cvtsi2sdl -0x10(%rbp), %xmm1
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x19cbb
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19c71
jmp 0x1a091
leaq 0xebb6e(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0xc93ae(%rip), %rsi     # 0xe3095
movl $0x19, %edx
callq 0x52d70
movq %rax, -0x20(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xebb3a(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x19d8b
leaq 0xebb28(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0x19d7b
leaq 0xebb05(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq 0x18(%rax), %rdi
movl $0x4, %esi
leaq 0xc9333(%rip), %rdx     # 0xe3095
movl $0x1c, %ecx
callq 0x52f40
movq %rax, %rdx
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x19d7d
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19cfc
leaq 0xebaae(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0xc92ee(%rip), %rsi     # 0xe3095
movl $0x1d, %edx
callq 0x52d70
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xeba74(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x19e3b
leaq 0xeba62(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
testl %eax, %eax
je 0x19e06
jmp 0x19dfc
movl -0x34(%rbp), %eax
subl $0x2, %eax
je 0x19e1b
jmp 0x19e2e
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x19e2e
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x19e30
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19dc2
jmp 0x19e3d
cmpq $0x0, -0x18(%rbp)
je 0x19f3d
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xeb9e7(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x19f23
leaq 0xeb9d1(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
testl %eax, %eax
je 0x19ea1
jmp 0x19e8d
movl -0x38(%rbp), %eax
subl $0x1, %eax
je 0x19eef
jmp 0x19e97
movl -0x38(%rbp), %eax
subl $0x2, %eax
je 0x19ec8
jmp 0x19f13
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movslq -0xc(%rbp), %rdx
cvtsi2sdl (%rcx,%rdx,8), %xmm0
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x19f13
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movslq -0xc(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x19f13
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movslq -0xc(%rbp), %rdx
movslq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x19f15
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19e4f
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x19e3d
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xeb8f2(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x1a02b
leaq 0xeb8dc(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x3c(%rbp)
testl %eax, %eax
je 0x19f99
jmp 0x19f82
movl -0x3c(%rbp), %eax
subl $0x1, %eax
je 0x19fd9
jmp 0x19f8c
movl -0x3c(%rbp), %eax
subl $0x2, %eax
je 0x19fb9
jmp 0x1a01b
movq -0x30(%rbp), %rax
cvtsi2sdl -0x10(%rbp), %xmm1
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1a01b
movq -0x30(%rbp), %rax
cvtsi2sdl -0x10(%rbp), %xmm1
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1a01b
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xeb854(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0xc(%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 -0xc(%rbp), %rcx
movl %edx, (%rax,%rcx,8)
jmp 0x1a01d
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19f44
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xeb804(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x1a088
leaq 0xeb7f2(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0x1a07b
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x52e80
jmp 0x1a07d
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1a032
movq -0x20(%rbp), %rdi
callq 0x52e80
movq -0x28(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)