// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/data.c
// Function: normalize_instance
void normalize_instance(Instanceptr myptr, Instance mean, Instance variance)
{
 int i;
 double sum;
 Instanceptr temp;
 NORMALIZATION_TYPE normtype = get_parameter_l("normalization"); 
 temp = myptr;
 if (mustrealize)
  {
   if (normtype == VECTOR_NORMALIZATION)
    {
     sum = 0.0;
     for (i = 0; i < current_dataset->multifeaturecount; i++)
       if (i != current_dataset->classdefno)
         sum += temp->values[i].floatvalue * temp->values[i].floatvalue;
    }
   for (i = 0; i < current_dataset->multifeaturecount; i++)
     if (i != current_dataset->classdefno)
       switch (normtype)
        {
         case        Z_NORMALIZATION:if (variance.values[i].floatvalue != 0)
                                       temp->values[i].floatvalue = (double) ((temp->values[i].floatvalue - mean.values[i].floatvalue) / sqrt(variance.values[i].floatvalue));
                                     break;
         case STANDARD_NORMALIZATION:temp->values[i].floatvalue = (temp->values[i].floatvalue - current_dataset->features[i].min.floatvalue) / (current_dataset->features[i].max.floatvalue - current_dataset->features[i].min.floatvalue);
                                     break;
         case   VECTOR_NORMALIZATION:if (sum != 0)
                                       temp->values[i].floatvalue = temp->values[i].floatvalue / sqrt(sum);
                                     break;
        } 
  }
 else
  {
   if (normtype == VECTOR_NORMALIZATION)
    {
     sum = 0.0;
     for (i = 0; i < current_dataset->featurecount; i++)
       switch (current_dataset->features[i].type)
        {     
         case INTEGER:sum += temp->values[i].intvalue * temp->values[i].intvalue;
                      break;
         case    REAL:sum += temp->values[i].floatvalue * temp->values[i].floatvalue;
                      break;
        }     
    }
   for (i = 0; i < current_dataset->featurecount; i++)
     switch (current_dataset->features[i].type)
      {
       case INTEGER:switch (normtype)
                     {
                      case        Z_NORMALIZATION:if (variance.values[i].floatvalue != 0)
                                                    temp->values[i].floatvalue = (double) ((temp->values[i].intvalue - mean.values[i].floatvalue) / sqrt(variance.values[i].floatvalue));
                                                  else
                                                    temp->values[i].floatvalue = (double) (temp->values[i].intvalue);
                                                  break;
                      case STANDARD_NORMALIZATION:temp->values[i].floatvalue = (temp->values[i].intvalue - current_dataset->features[i].min.intvalue) / (current_dataset->features[i].max.intvalue - current_dataset->features[i].min.intvalue + 0.0);
                                                  break;
                      case   VECTOR_NORMALIZATION:if (sum != 0)
                                                    temp->values[i].floatvalue = temp->values[i].intvalue / sqrt(sum);
                                                  break;
                     }
                    break;
       case    REAL:switch (normtype)
                     {
                      case        Z_NORMALIZATION:if (variance.values[i].floatvalue != 0)
                                                    temp->values[i].floatvalue = (double) ((temp->values[i].floatvalue-mean.values[i].floatvalue) / sqrt(variance.values[i].floatvalue));
                                                  break;
                      case STANDARD_NORMALIZATION:temp->values[i].floatvalue = (temp->values[i].floatvalue - current_dataset->features[i].min.floatvalue) / (current_dataset->features[i].max.floatvalue - current_dataset->features[i].min.floatvalue);
                                                  break;
                      case   VECTOR_NORMALIZATION:if (sum != 0)
                                                    temp->values[i].floatvalue = temp->values[i].floatvalue / sqrt(sum);
                                                  break;
                     }
                    break;
      }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x90(%rsp), %r15
leaq 0x60(%rsp), %r12
leaq 0x95f2f(%rip), %rdi     # 0xa6360
callq 0x54afc
movl %eax, %ebp
leaq 0x3a1b65(%rip), %rax    # 0x3b1fa4
cmpl $0x0, (%rax)
leaq 0xc5427(%rip), %r14     # 0xd5870
movq (%r14), %rax
je 0x10490
movl 0x1c0(%rax), %ecx
cmpl $0x2, %ebp
jne 0x104f5
testl %ecx, %ecx
jle 0x107a3
movl 0x1407128(%rax), %edx
xorpd %xmm3, %xmm3
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x10486
movq (%rbx), %rdi
movsd (%rdi,%rsi,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm3
incq %rsi
cmpq %rsi, %rcx
jne 0x10471
jmp 0x104fd
movl 0x1bc(%rax), %ecx
cmpl $0x2, %ebp
jne 0x1060e
testl %ecx, %ecx
jle 0x107a3
leaq 0x30f08(%rax), %rdx
xorpd %xmm3, %xmm3
xorl %esi, %esi
movl (%rdx), %edi
cmpl $0x2, %edi
je 0x104d1
testl %edi, %edi
jne 0x104e1
movq (%rbx), %rdi
movl (%rdi,%rsi,8), %edi
imull %edi, %edi
xorps %xmm0, %xmm0
cvtsi2sd %edi, %xmm0
jmp 0x104dd
movq (%rbx), %rdi
movsd (%rdi,%rsi,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm3
incq %rsi
addq $0x340, %rdx            # imm = 0x340
cmpq %rsi, %rcx
jne 0x104b4
jmp 0x10616
testl %ecx, %ecx
jle 0x107a3
movq (%r15), %r15
movq (%r12), %rcx
movq %rcx, 0x20(%rsp)
movl $0x61e3, %r13d          # imm = 0x61E3
xorl %r12d, %r12d
xorpd %xmm4, %xmm4
xorps %xmm0, %xmm0
sqrtsd %xmm3, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd %xmm3, 0x10(%rsp)
movl 0x1407128(%rax), %ecx
cmpq %rcx, %r12
je 0x105ef
cmpl $0x2, %ebp
je 0x105a6
cmpl $0x1, %ebp
je 0x1057c
testl %ebp, %ebp
jne 0x105ef
movsd (%r15,%r12,8), %xmm0
ucomisd %xmm4, %xmm0
jne 0x1055c
jnp 0x105ef
movq (%rbx), %rax
movsd (%rax,%r12,8), %xmm1
movq 0x20(%rsp), %rax
subsd (%rax,%r12,8), %xmm1
ucomisd %xmm4, %xmm0
jb 0x105c7
sqrtsd %xmm0, %xmm0
jmp 0x105e2
movq (%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
movsd -0x8(%rax,%r13,8), %xmm1
movsd (%rax,%r13,8), %xmm2
subsd %xmm1, %xmm0
subsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, (%rcx,%r12,8)
jmp 0x105ef
ucomisd %xmm4, %xmm3
jne 0x105ae
jnp 0x105ef
movq (%rbx), %rax
movsd (%rax,%r12,8), %xmm1
ucomisd %xmm4, %xmm3
movsd 0x18(%rsp), %xmm0
jae 0x105e2
movapd %xmm3, %xmm0
movsd %xmm1, 0x8(%rsp)
callq 0x4300
movsd 0x8(%rsp), %xmm1
xorpd %xmm4, %xmm4
movsd 0x10(%rsp), %xmm3
divsd %xmm0, %xmm1
movq (%rbx), %rax
movsd %xmm1, (%rax,%r12,8)
incq %r12
movq (%r14), %rax
movslq 0x1c0(%rax), %rcx
addq $0x68, %r13
cmpq %rcx, %r12
jl 0x10529
jmp 0x107a3
testl %ecx, %ecx
jle 0x107a3
movq (%r15), %r15
movq (%r12), %rcx
movq %rcx, 0x20(%rsp)
movl $0x61e3, %r13d          # imm = 0x61E3
xorl %r12d, %r12d
xorpd %xmm4, %xmm4
xorps %xmm0, %xmm0
sqrtsd %xmm3, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd %xmm3, 0x10(%rsp)
movl -0x10(%rax,%r13,8), %ecx
cmpl $0x2, %ecx
je 0x10689
testl %ecx, %ecx
jne 0x10789
cmpl $0x2, %ebp
je 0x1072a
cmpl $0x1, %ebp
je 0x106d8
testl %ebp, %ebp
jne 0x10789
movsd (%r15,%r12,8), %xmm0
ucomisd %xmm4, %xmm0
movq (%rbx), %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rax,%r12,8), %xmm1
jne 0x106ba
jp 0x106ba
jmp 0x10783
cmpl $0x2, %ebp
je 0x10740
cmpl $0x1, %ebp
je 0x10700
testl %ebp, %ebp
jne 0x10789
movsd (%r15,%r12,8), %xmm0
ucomisd %xmm4, %xmm0
jne 0x106b1
jnp 0x10789
movq (%rbx), %rax
movsd (%rax,%r12,8), %xmm1
movq 0x20(%rsp), %rax
subsd (%rax,%r12,8), %xmm1
ucomisd %xmm4, %xmm0
jb 0x10761
sqrtsd %xmm0, %xmm0
jmp 0x1077c
movq (%rbx), %rcx
movl (%rcx,%r12,8), %edx
movl -0x8(%rax,%r13,8), %esi
movl (%rax,%r13,8), %eax
subl %esi, %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
subl %esi, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
jmp 0x10722
movq (%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
movsd -0x8(%rax,%r13,8), %xmm1
movsd (%rax,%r13,8), %xmm2
subsd %xmm1, %xmm0
subsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, (%rcx,%r12,8)
jmp 0x10789
ucomisd %xmm4, %xmm3
jne 0x10732
jnp 0x10789
movq (%rbx), %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rax,%r12,8), %xmm1
jmp 0x10751
ucomisd %xmm4, %xmm3
jne 0x10748
jnp 0x10789
movq (%rbx), %rax
movsd (%rax,%r12,8), %xmm1
ucomisd %xmm4, %xmm3
movsd 0x18(%rsp), %xmm0
jae 0x1077c
movapd %xmm3, %xmm0
movsd %xmm1, 0x8(%rsp)
callq 0x4300
movsd 0x8(%rsp), %xmm1
xorpd %xmm4, %xmm4
movsd 0x10(%rsp), %xmm3
divsd %xmm0, %xmm1
movq (%rbx), %rax
movsd %xmm1, (%rax,%r12,8)
incq %r12
movq (%r14), %rax
movslq 0x1bc(%rax), %rcx
addq $0x68, %r13
cmpq %rcx, %r12
jl 0x10642
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq