// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/data.c
// Function: find_mean_with_missing
Instance find_mean_with_missing(Instanceptr myptr)
{
 /*!Last Changed 02.02.2004 Added safemalloc and safecalloc*/
 int i, *counts;
 Instanceptr temp;
 Instance result;
 int** featurevalues;
 featurevalues = (int **)safemalloc(current_dataset->featurecount * sizeof(int*), "find_mean_with_missing", 5);
 counts = (int *)safecalloc(current_dataset->featurecount, sizeof(int), "find_mean_with_missing", 6);
 temp = myptr;
 result.values = (union value *)safemalloc(current_dataset->featurecount * sizeof(union value), "find_mean_with_missing", 7);
 for (i = 0; i < current_dataset->featurecount; i++)
   switch (current_dataset->features[i].type)
    {
     case INTEGER:result.values[i].intvalue = 0;
                  break;
     case    REAL:result.values[i].floatvalue = 0;
                  break;
     case  STRING:featurevalues[i] = (int *)safecalloc(current_dataset->features[i].valuecount, sizeof(int), "find_mean_with_missing", 15);
                  break;
    }
 while (temp)
  {
   for (i = 0; i < current_dataset->featurecount; i++)
     switch (current_dataset->features[i].type)
      {
       case INTEGER:if (temp->values[i].intvalue != ISELL)
                     {
                      result.values[i].intvalue += temp->values[i].intvalue;
                      counts[i]++;
                     }
                    break;
       case    REAL:if (temp->values[i].floatvalue != ISELL)
                     {
                      result.values[i].floatvalue += temp->values[i].floatvalue;
                      counts[i]++;
                     }
                    break;
       case  STRING:if (temp->values[i].stringindex != -1)
                      featurevalues[i][temp->values[i].stringindex]++;
                    break;
      }
   temp = temp->next;
  }
 for (i = 0; i < current_dataset->featurecount; i++)
   switch (current_dataset->features[i].type)
    {
     case INTEGER:if (counts[i] != 0)
                    result.values[i].intvalue /= counts[i];
                  break;
     case    REAL:if (counts[i] != 0)
                    result.values[i].floatvalue /= counts[i];
                  break;
     case  STRING:result.values[i].stringindex = find_max_in_list(featurevalues[i], current_dataset->features[i].valuecount);
                  break;
    }
 for (i = 0; i < current_dataset->featurecount; i++)
   if (current_dataset->features[i].type == STRING)
     safe_free(featurevalues[i]);
 safe_free(featurevalues);
 safe_free(counts);
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x30(%rbp)
movq %rdi, -0x38(%rbp)
movq %rsi, -0x8(%rbp)
leaq 0xec575(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0xc9d9e(%rip), %rsi     # 0xe307e
movl $0x5, %edx
callq 0x52d70
movq %rax, -0x28(%rbp)
leaq 0xec54b(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1bc(%rax), %rdi
movl $0x4, %esi
leaq 0xc9d73(%rip), %rdx     # 0xe307e
movl $0x6, %ecx
callq 0x52f40
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq 0xec518(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0xc9d41(%rip), %rsi     # 0xe307e
movl $0x7, %edx
callq 0x52d70
movq -0x30(%rbp), %rdi
movq %rax, (%rdi)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xec4e1(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x19427
leaq 0xec4cb(%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 0x193a7
jmp 0x19393
movl -0x3c(%rbp), %eax
subl $0x1, %eax
je 0x193d0
jmp 0x1939d
movl -0x3c(%rbp), %eax
subl $0x2, %eax
je 0x193bb
jmp 0x19417
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movl $0x0, (%rax,%rcx,8)
jmp 0x19417
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x19417
leaq 0xec469(%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 0xc9c80(%rip), %rdx     # 0xe307e
movl $0xf, %ecx
callq 0x52f40
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x19419
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19355
jmp 0x19429
cmpq $0x0, -0x20(%rbp)
je 0x1958f
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xec3fb(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x1957e
leaq 0xec3e5(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x40(%rbp)
testl %eax, %eax
je 0x19494
jmp 0x19479
movl -0x40(%rbp), %eax
subl $0x1, %eax
je 0x19537
jmp 0x19487
movl -0x40(%rbp), %eax
subl $0x2, %eax
je 0x194dd
jmp 0x1956e
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
cmpl $0x75bcd15, (%rax,%rcx,8) # imm = 0x75BCD15
je 0x194d8
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
movslq -0xc(%rbp), %rdx
movl (%rcx,%rdx,8), %edx
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
addl (%rax,%rcx,8), %edx
movl %edx, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x1956e
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0xc94a3(%rip), %xmm1    # 0xe2998
ucomisd %xmm1, %xmm0
jne 0x194ff
jp 0x194ff
jmp 0x19535
movq -0x30(%rbp), %rax
movq -0x20(%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)
movq -0x18(%rbp), %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x1956e
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,8)
je 0x1956c
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x20(%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 0x1956e
jmp 0x19570
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1943b
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x19429
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xec2a0(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x196ac
leaq 0xec28a(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x44(%rbp)
testl %eax, %eax
je 0x195eb
jmp 0x195d4
movl -0x44(%rbp), %eax
subl $0x1, %eax
je 0x1965a
jmp 0x195de
movl -0x44(%rbp), %eax
subl $0x2, %eax
je 0x19624
jmp 0x1969c
movq -0x18(%rbp), %rax
movslq -0xc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x19622
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0xc(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,8), %eax
cltd
idivl %esi
movl %eax, %edx
movq -0x50(%rbp), %rax
movl %edx, (%rax,%rcx,8)
jmp 0x1969c
movq -0x18(%rbp), %rax
movslq -0xc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x19658
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0xc(%rbp), %rdx
cvtsi2sdl (%rcx,%rdx,4), %xmm1
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1969c
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xec1d3(%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 0x1969e
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19596
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0xec183(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x19709
leaq 0xec171(%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 0x196fc
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x52e80
jmp 0x196fe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x196b3
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x18(%rbp), %rdi
callq 0x52e80
movq -0x38(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)