// File: /workspace/github_c_makefile_star2_O1/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 0x92f57(%rip), %rdi     # 0xa3360
callq 0x535f7
movl %eax, %ebp
leaq 0x39eb8d(%rip), %rax    # 0x3aefa4
cmpl $0x0, (%rax)
je 0x1046a
cmpl $0x2, %ebp
jne 0x104dd
leaq 0xc2444(%rip), %rax     # 0xd2870
movq (%rax), %rcx
movslq 0x1c0(%rcx), %rax
testq %rax, %rax
jle 0x104d9
movl 0x1407128(%rcx), %ecx
xorpd %xmm3, %xmm3
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x10460
movq (%rbx), %rsi
movsd (%rsi,%rdx,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm3
incq %rdx
cmpq %rdx, %rax
jne 0x1044b
jmp 0x104dd
cmpl $0x2, %ebp
jne 0x10609
leaq 0xc23f6(%rip), %rax     # 0xd2870
movq (%rax), %rax
movslq 0x1bc(%rax), %rcx
testq %rcx, %rcx
jle 0x10605
addq $0x30f08, %rax          # imm = 0x30F08
xorpd %xmm3, %xmm3
xorl %edx, %edx
movl (%rax), %esi
cmpl $0x2, %esi
je 0x104b6
testl %esi, %esi
jne 0x104c6
movq (%rbx), %rsi
movl (%rsi,%rdx,8), %esi
imull %esi, %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
jmp 0x104c2
movq (%rbx), %rsi
movsd (%rsi,%rdx,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm3
incq %rdx
addq $0x340, %rax            # imm = 0x340
cmpq %rdx, %rcx
jne 0x10499
jmp 0x10609
xorpd %xmm3, %xmm3
leaq 0xc238c(%rip), %r14     # 0xd2870
movq (%r14), %rax
cmpl $0x0, 0x1c0(%rax)
jle 0x107ad
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 0x105e6
cmpl $0x2, %ebp
je 0x1059d
cmpl $0x1, %ebp
je 0x10573
testl %ebp, %ebp
jne 0x105e6
movsd (%r15,%r12,8), %xmm0
ucomisd %xmm4, %xmm0
jne 0x10553
jnp 0x105e6
movq (%rbx), %rax
movsd (%rax,%r12,8), %xmm1
movq 0x20(%rsp), %rax
subsd (%rax,%r12,8), %xmm1
ucomisd %xmm4, %xmm0
jb 0x105be
sqrtsd %xmm0, %xmm0
jmp 0x105d9
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 0x105e6
ucomisd %xmm4, %xmm3
jne 0x105a5
jnp 0x105e6
movq (%rbx), %rax
movsd (%rax,%r12,8), %xmm1
ucomisd %xmm4, %xmm3
movsd 0x18(%rsp), %xmm0
jae 0x105d9
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 0x10520
jmp 0x107ad
xorpd %xmm3, %xmm3
leaq 0xc2260(%rip), %r14     # 0xd2870
movq (%r14), %rax
cmpl $0x0, 0x1bc(%rax)
jle 0x107ad
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 0x10693
testl %ecx, %ecx
jne 0x10793
cmpl $0x2, %ebp
je 0x10734
cmpl $0x1, %ebp
je 0x106e2
testl %ebp, %ebp
jne 0x10793
movsd (%r15,%r12,8), %xmm0
ucomisd %xmm4, %xmm0
movq (%rbx), %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rax,%r12,8), %xmm1
jne 0x106c4
jp 0x106c4
jmp 0x1078d
cmpl $0x2, %ebp
je 0x1074a
cmpl $0x1, %ebp
je 0x1070a
testl %ebp, %ebp
jne 0x10793
movsd (%r15,%r12,8), %xmm0
ucomisd %xmm4, %xmm0
jne 0x106bb
jnp 0x10793
movq (%rbx), %rax
movsd (%rax,%r12,8), %xmm1
movq 0x20(%rsp), %rax
subsd (%rax,%r12,8), %xmm1
ucomisd %xmm4, %xmm0
jb 0x1076b
sqrtsd %xmm0, %xmm0
jmp 0x10786
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 0x1072c
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 0x10793
ucomisd %xmm4, %xmm3
jne 0x1073c
jnp 0x10793
movq (%rbx), %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rax,%r12,8), %xmm1
jmp 0x1075b
ucomisd %xmm4, %xmm3
jne 0x10752
jnp 0x10793
movq (%rbx), %rax
movsd (%rax,%r12,8), %xmm1
ucomisd %xmm4, %xmm3
movsd 0x18(%rsp), %xmm0
jae 0x10786
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 0x1064c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq