// File: /workspace/github_c_makefile_star2_O2/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), %r14
leaq 0x60(%rsp), %r15
leaq 0x86bf0(%rip), %rdi     # 0x96360
callq 0x4cf11
movl %eax, %ebp
leaq 0x39a826(%rip), %rax    # 0x3a9fa4
cmpl $0x0, (%rax)
je 0xf8e0
cmpl $0x2, %ebp
jne 0xf7cc
leaq 0xbe0dd(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x1c0(%rax), %ecx
xorl %edx, %edx
testl %ecx, %ecx
cmovlel %edx, %ecx
xorpd %xmm3, %xmm3
cmpq %rdx, %rcx
je 0xf7cc
movl 0x1407128(%rax), %esi
cmpq %rsi, %rdx
je 0xf7c7
movq (%rbx), %rsi
movsd (%rsi,%rdx,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm3
incq %rdx
jmp 0xf7a7
movq (%r14), %r14
movq (%r15), %rax
movq %rax, 0x20(%rsp)
movl $0x61e3, %r12d          # imm = 0x61E3
xorl %r13d, %r13d
leaq 0xbe089(%rip), %r15     # 0xcd870
xorpd %xmm4, %xmm4
sqrtsd %xmm3, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd %xmm3, 0x10(%rsp)
movq (%r15), %rax
movslq 0x1c0(%rax), %rcx
cmpq %rcx, %r13
jge 0xfac9
movl 0x1407128(%rax), %ecx
cmpq %rcx, %r13
je 0xf8d4
cmpl $0x2, %ebp
je 0xf88b
cmpl $0x1, %ebp
je 0xf861
testl %ebp, %ebp
jne 0xf8d4
movsd (%r14,%r13,8), %xmm0
ucomisd %xmm4, %xmm0
jne 0xf841
jnp 0xf8d4
movq (%rbx), %rax
movsd (%rax,%r13,8), %xmm1
movq 0x20(%rsp), %rax
subsd (%rax,%r13,8), %xmm1
ucomisd %xmm4, %xmm0
jb 0xf8ac
sqrtsd %xmm0, %xmm0
jmp 0xf8c7
movq (%rbx), %rcx
movsd (%rcx,%r13,8), %xmm0
movsd -0x8(%rax,%r12,8), %xmm1
movsd (%rax,%r12,8), %xmm2
subsd %xmm1, %xmm0
subsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, (%rcx,%r13,8)
jmp 0xf8d4
ucomisd %xmm4, %xmm3
jne 0xf893
jnp 0xf8d4
movq (%rbx), %rax
movsd (%rax,%r13,8), %xmm1
ucomisd %xmm4, %xmm3
movsd 0x18(%rsp), %xmm0
jae 0xf8c7
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,%r13,8)
incq %r13
addq $0x68, %r12
jmp 0xf7fb
cmpl $0x2, %ebp
jne 0xf940
leaq 0xbdf84(%rip), %rax     # 0xcd870
movq (%rax), %rax
movl 0x1bc(%rax), %ecx
addq $0x30f08, %rax          # imm = 0x30F08
xorl %edx, %edx
testl %ecx, %ecx
cmovlel %edx, %ecx
xorpd %xmm3, %xmm3
cmpq %rdx, %rcx
je 0xf940
movl (%rax), %esi
cmpl $0x2, %esi
je 0xf925
testl %esi, %esi
jne 0xf935
movq (%rbx), %rsi
movl (%rsi,%rdx,8), %esi
imull %esi, %esi
cvtsi2sd %esi, %xmm0
jmp 0xf931
movq (%rbx), %rsi
movsd (%rsi,%rdx,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm3
incq %rdx
addq $0x340, %rax            # imm = 0x340
jmp 0xf906
movq (%r14), %r14
movq (%r15), %rax
movq %rax, 0x20(%rsp)
movl $0x61e3, %r12d          # imm = 0x61E3
xorl %r13d, %r13d
leaq 0xbdf15(%rip), %r15     # 0xcd870
xorpd %xmm4, %xmm4
sqrtsd %xmm3, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd %xmm3, 0x10(%rsp)
movq (%r15), %rax
movslq 0x1bc(%rax), %rcx
cmpq %rcx, %r13
jge 0xfac9
movl -0x10(%rax,%r12,8), %ecx
cmpl $0x2, %ecx
je 0xf9c6
testl %ecx, %ecx
jne 0xfabd
cmpl $0x2, %ebp
je 0xfa61
cmpl $0x1, %ebp
je 0xfa15
testl %ebp, %ebp
jne 0xfabd
movsd (%r14,%r13,8), %xmm0
ucomisd %xmm4, %xmm0
movq (%rbx), %rax
cvtsi2sdl (%rax,%r13,8), %xmm1
jne 0xf9f7
jp 0xf9f7
jmp 0xfab7
cmpl $0x2, %ebp
je 0xfa74
cmpl $0x1, %ebp
je 0xfa37
testl %ebp, %ebp
jne 0xfabd
movsd (%r14,%r13,8), %xmm0
ucomisd %xmm4, %xmm0
jne 0xf9ee
jnp 0xfabd
movq (%rbx), %rax
movsd (%rax,%r13,8), %xmm1
movq 0x20(%rsp), %rax
subsd (%rax,%r13,8), %xmm1
ucomisd %xmm4, %xmm0
jb 0xfa95
sqrtsd %xmm0, %xmm0
jmp 0xfab0
movq (%rbx), %rcx
movl (%rcx,%r13,8), %edx
movl -0x8(%rax,%r12,8), %esi
movl (%rax,%r12,8), %eax
subl %esi, %edx
cvtsi2sd %edx, %xmm0
subl %esi, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
jmp 0xfa59
movq (%rbx), %rcx
movsd (%rcx,%r13,8), %xmm0
movsd -0x8(%rax,%r12,8), %xmm1
movsd (%rax,%r12,8), %xmm2
subsd %xmm1, %xmm0
subsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, (%rcx,%r13,8)
jmp 0xfabd
ucomisd %xmm4, %xmm3
jne 0xfa69
jnp 0xfabd
movq (%rbx), %rax
cvtsi2sdl (%rax,%r13,8), %xmm1
jmp 0xfa85
ucomisd %xmm4, %xmm3
jne 0xfa7c
jnp 0xfabd
movq (%rbx), %rax
movsd (%rax,%r13,8), %xmm1
ucomisd %xmm4, %xmm3
movsd 0x18(%rsp), %xmm0
jae 0xfab0
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,%r13,8)
incq %r13
addq $0x68, %r12
jmp 0xf96f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq