// File: /workspace/github_c_makefile_star2_O1/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, %ebx
movl %edx, %ebp
movl %esi, 0x14(%rsp)
movq %rdi, %r15
leaq 0xa30fb(%rip), %rax     # 0xd2870
movq (%rax), %rdi
movl 0x1c0(%rdi), %eax
movq %rax, 0x38(%rsp)
decl %eax
movl %eax, 0x24(%rsp)
movl %eax, %r12d
cmpl $-0x2, %ecx
je 0x2f799
callq 0x13726
movl %eax, %r12d
xorl %edi, %edi
testq %r15, %r15
je 0x2f7ae
movq %r15, %rax
incl %edi
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0x2f7a3
leal 0x1(%r12), %esi
callq 0x3c6e5
movq %rax, 0x50(%rsp)
testq %r15, %r15
movl 0x24(%rsp), %eax
je 0x2fa00
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x58(%rsp)
movslq %r12d, %rcx
movq %rcx, 0x18(%rsp)
movl %eax, %eax
movq %rax, 0x68(%rsp)
movl 0x14(%rsp), %eax
movq %rax, 0x60(%rsp)
xorl %r14d, %r14d
movq %rdx, 0x8(%rsp)
movl %ebx, 0x34(%rsp)
movl %ebp, 0x30(%rsp)
cmpl $-0x2, %ebx
jne 0x2f856
leaq 0xa3068(%rip), %rax     # 0xd2870
movq (%rax), %rax
cmpl $0x2, 0x1c0(%rax)
jl 0x2f945
xorl %r12d, %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0x2e4b6
movq 0x8(%rsp), %rdx
movq (%rdx,%r14,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
leaq 0xa3031(%rip), %rax     # 0xd2870
movq (%rax), %rax
movslq 0x1c0(%rax), %rax
decq %rax
cmpq %rax, %r12
jl 0x2f81b
jmp 0x2f945
cmpl $-0x3, %ebx
jne 0x2f945
cmpl $0x2, 0x38(%rsp)
jl 0x2f90d
movq %r15, 0x40(%rsp)
movq %r14, 0x48(%rsp)
movq $0x0, 0x28(%rsp)
xorl %ebx, %ebx
movq %rbx, %r13
shlq $0x20, %r13
movslq %ebx, %rbx
movq 0x28(%rsp), %rax
movl %eax, %ebp
movabsq $0x100000000, %r14      # imm = 0x100000000
movq 0x48(%rsp), %r15
movq 0x40(%rsp), %r12
addq %r14, %r13
movq %r12, %rdi
movq 0x28(%rsp), %rsi
callq 0x2e4b6
movsd %xmm0, 0x70(%rsp)
movq %r12, %rdi
movl %ebp, %esi
callq 0x2e4b6
movq 0x8(%rsp), %rdx
mulsd 0x70(%rsp), %xmm0
movq (%rdx,%r15,8), %rax
movsd %xmm0, (%rax,%rbx,8)
movl 0x24(%rsp), %eax
incq %rbx
incl %ebp
cmpl %eax, %ebp
jl 0x2f8a4
movq 0x28(%rsp), %rcx
incl %ecx
movq %rcx, 0x28(%rsp)
cmpl %eax, %ecx
jne 0x2f87f
sarq $0x20, %r13
movl 0x34(%rsp), %ebx
movl 0x30(%rsp), %ebp
movq 0x48(%rsp), %r14
movq 0x40(%rsp), %r15
jmp 0x2f910
xorl %r13d, %r13d
cmpl $0x2, 0x38(%rsp)
jl 0x2f945
shlq $0x3, %r13
xorl %r12d, %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0x2e4b6
movq 0x8(%rsp), %rdx
movq (%rdx,%r14,8), %rax
addq %r13, %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
cmpl %r12d, 0x68(%rsp)
jne 0x2f91e
cmpl $0x3, 0x14(%rsp)
ja 0x2f9c4
movq 0x60(%rsp), %rax
leaq 0x7613c(%rip), %rcx     # 0xa5a94
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
callq 0x2eaca
movq 0x8(%rsp), %rdx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
jmp 0x2f9b4
movq %r15, %rdi
callq 0x2eaca
movq 0x8(%rsp), %rdx
movq (%rdx,%r14,8), %rcx
cmpl %ebp, %eax
jne 0x2f9dd
movq 0x18(%rsp), %rax
movq $0x0, (%rcx,%rax,8)
jmp 0x2f9f0
movq (%rdx,%r14,8), %rax
movsd 0x58(%rsp), %xmm0
jmp 0x2f9b8
movq %r15, %rdi
callq 0x2eaee
movq 0x8(%rsp), %rdx
movq (%rdx,%r14,8), %rax
movq 0x18(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x2f9f0
leaq 0x760d9(%rip), %rdi     # 0xa5aa4
movl 0x14(%rsp), %esi
xorl %eax, %eax
callq 0x4030
movq 0x8(%rsp), %rdx
jmp 0x2f9f0
movq 0x18(%rsp), %rax
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movq %rsi, (%rcx,%rax,8)
movq 0x10(%r15), %r15
incq %r14
testq %r15, %r15
jne 0x2f7fc
movq 0x50(%rsp), %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq