// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/instancelist.c
// Function: instancelist_to_matrix
matrix instancelist_to_matrix(Instanceptr list, int problemtype, int positive, MULTIVARIATE_TYPE multivariate_type)
{
 /*!Last Changed 28.05.2004*/
 /*!Last Changed 22.03.2004*/
 matrix result;
 int i, dim, matrixdim, x, j;
 Instanceptr tmp;
 long int dataindex;
 dim = current_dataset->multifeaturecount - 1;
 if (multivariate_type == MULTIVARIATE_LINEAR)
   matrixdim = dim;
 else
   matrixdim = multifeaturecount_2d(current_dataset);
 result = matrix_alloc(data_size(list), matrixdim + 1);
 tmp = list;
 dataindex = 0;
 while (tmp)
  {
   if (multivariate_type == MULTIVARIATE_LINEAR)
     for (i = 0; i < current_dataset->multifeaturecount - 1; i++)
       result.values[dataindex][i] = real_feature(tmp, i);
   else
     if (multivariate_type == MULTIVARIATE_QUADRATIC)
      {
       x = 0;
       for (i = 0; i < dim; i++)
         for (j = i; j < dim; j++)
          {
           result.values[dataindex][x] = real_feature(tmp, i) * real_feature(tmp, j);
           x++;
          }
       for (i = 0; i < dim; i++)
        {
         result.values[dataindex][x] = real_feature(tmp, i);
         x++;
        }
      }
   switch (problemtype)
    {
     case CLASSIFICATION:result.values[dataindex][matrixdim] = give_classno(tmp);
                         break;
     case REGRESSION    :result.values[dataindex][matrixdim] = give_regressionvalue(tmp);
                         break;
     case 2             :if (give_classno(tmp) == positive)
                           result.values[dataindex][matrixdim] = 0;
                         else
                           result.values[dataindex][matrixdim] = 1;
                         break;
     case 3             :result.values[dataindex][matrixdim] = positive;
                         break;
     default            :printf(m1241, problemtype);
                         break;
    }
   tmp = tmp->next;
   dataindex++;
  }
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %ecx, %ebp
movl %edx, 0x20(%rsp)
movl %esi, 0x14(%rsp)
movq %rdi, %r15
leaq 0xa171e(%rip), %r13     # 0xcd870
movq (%r13), %rdi
movl 0x1c0(%rdi), %eax
movq %rax, 0x28(%rsp)
decl %eax
movl %eax, 0x24(%rsp)
movl %eax, %r12d
cmpl $-0x2, %ecx
je 0x2c177
callq 0x126ea
movl %eax, %r12d
movq %r15, %rdi
callq 0x2c3cc
leal 0x1(%r12), %esi
movl %eax, %edi
callq 0x380d3
movq %rax, 0x50(%rsp)
cvtsi2sdl 0x20(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movq %rdx, 0x8(%rsp)
movslq %r12d, %rax
movq %rax, 0x18(%rsp)
movl 0x24(%rsp), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, 0x48(%rsp)
movq 0x28(%rsp), %rax
addl $-0x2, %eax
movq %rax, 0x28(%rsp)
movl 0x14(%rsp), %eax
movq %rax, 0x60(%rsp)
xorl %r14d, %r14d
movl %ebp, 0x34(%rsp)
testq %r15, %r15
je 0x2c3b3
cmpl $-0x2, %ebp
jne 0x2c220
xorl %r12d, %r12d
movq (%r13), %rax
movslq 0x1c0(%rax), %rax
decq %rax
cmpq %rax, %r12
jge 0x2c305
movq %r15, %rdi
movl %r12d, %esi
callq 0x2aea2
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
jmp 0x2c1ea
cmpl $-0x3, %ebp
jne 0x2c305
xorl %edx, %edx
movl 0x24(%rsp), %ecx
movl %ecx, %esi
movq 0x28(%rsp), %rax
xorl %edi, %edi
xorl %ebp, %ebp
cmpl 0x48(%rsp), %ebp
je 0x2c2ce
movl %eax, 0x3c(%rsp)
movl %edx, 0x44(%rsp)
movl %esi, 0x40(%rsp)
movslq %esi, %rbx
movslq %edi, %r13
movq %rcx, 0x68(%rsp)
leal (%rcx,%r13), %eax
movl %eax, 0x38(%rsp)
movl %ebp, %r12d
cmpq %r13, %rbx
je 0x2c2a3
movq %r15, %rdi
movl %ebp, %esi
callq 0x2aea2
movsd %xmm0, 0x70(%rsp)
movq %r15, %rdi
movl %r12d, %esi
callq 0x2aea2
mulsd 0x70(%rsp), %xmm0
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
incl %r12d
jmp 0x2c266
incl %ebp
movl 0x40(%rsp), %esi
movl 0x3c(%rsp), %eax
addl %eax, %esi
decl %eax
movl 0x44(%rsp), %edx
movq 0x68(%rsp), %rcx
addl %ecx, %edx
decl %ecx
leaq 0xa15ab(%rip), %r13     # 0xcd870
movl 0x38(%rsp), %edi
jmp 0x2c23a
movslq %edx, %rbx
shlq $0x3, %rbx
xorl %r12d, %r12d
movl 0x34(%rsp), %ebp
cmpl %r12d, 0x48(%rsp)
je 0x2c305
movq %r15, %rdi
movl %r12d, %esi
callq 0x2aea2
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rax
addq %rbx, %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
jmp 0x2c2dc
cmpl $0x3, 0x14(%rsp)
ja 0x2c380
movq 0x60(%rsp), %rax
leaq 0x6c774(%rip), %rcx     # 0x98a8c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
callq 0x2b47e
cvtsi2sd %eax, %xmm0
jmp 0x2c36b
movq %r15, %rdi
callq 0x2b47e
movq 0x8(%rsp), %rcx
movq (%rcx,%r14,8), %rcx
cmpl 0x20(%rsp), %eax
jne 0x2c394
movq 0x18(%rsp), %rax
andq $0x0, (%rcx,%rax,8)
jmp 0x2c3a7
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rax
movsd 0x58(%rsp), %xmm0
jmp 0x2c374
movq %r15, %rdi
callq 0x2b4a0
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rax
movq 0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x2c3a7
leaq 0x6c715(%rip), %rdi     # 0x98a9c
movl 0x14(%rsp), %esi
xorl %eax, %eax
callq 0x4030
jmp 0x2c3a7
movq 0x18(%rsp), %rax
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movq %rdx, (%rcx,%rax,8)
movq 0x10(%r15), %r15
incq %r14
jmp 0x2c1d9
movq 0x50(%rsp), %rax
movq 0x8(%rsp), %rdx
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq