// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/dataset.c
// Function: create_instance
Instanceptr create_instance(Datasetptr dataset, char *myline, int withnoise)
{
 /*!Last Changed 07.01.2007 added sublist and continuous data*/
 /*!Last Changed 08.05.2004 can now handle exceptions*/
 /*!Last Changed 10.03.2004 Extended to regression*/
 /*!Last Changed 02.02.2004 added safemalloc*/
 Instanceptr currentinstance, subinstance, firstinstance;
 int j, k, unknown, tmp, cno, framecount, currentframe = 0;
 char st1[4];
 char *st, tmpline[READLINELENGTH];
 if (is_line_comment(myline))
   return NULL;
 strcpy(tmpline, myline);
 st1[0] = dataset->separator;
 st1[1] = '\n';
 st1[2] = '\0';
 if (dataset->storetype == STORE_MULTILABEL)
   currentinstance = empty_multi_label_instance(dataset->featurecount, dataset->classno);
 else
   currentinstance = empty_instance(dataset->featurecount);
 firstinstance = currentinstance;
 j = 0;
 k = 0;
 st = (char *) strtok(tmpline, st1);
 if (dataset->storetype == STORE_SEQUENTIAL)
  {
   currentinstance->values[0].stringindex = listindex(st, dataset->features[0].strings, dataset->features[0].valuecount);
   cno = currentinstance->values[0].stringindex;
   if (cno == -1)
     printf(m1263, myline, st);
   st = (char *) strtok(NULL, st1);
   framecount = atoi(st);
   currentframe = 0;
   st = (char *) strtok(NULL, st1);
   j = 1;
   k = 1;
  }
 while (st)
  {
   if (dataset->availability[j])
    {
     if (strcmp(st, "?") == 0)
       unknown = 1;
     else
       unknown = 0;
     if (k < dataset->featurecount)
      {
       switch (dataset->features[k].type){
         case INTEGER :if (!unknown)
                         currentinstance->values[k].intvalue = atoi(st);
                       else
                         currentinstance->values[k].intvalue = ISELL;
                       break;
         case REGDEF  :
         case REAL    :if (!unknown)
                         currentinstance->values[k].floatvalue = (double)atof(st);
                       else
                         currentinstance->values[k].floatvalue = ISELL;
                       break;
         case STRING  :if (!unknown)
                        {
                         tmp = listindex(st, dataset->features[k].strings, dataset->features[k].valuecount);
                         if (tmp == -1)
                           printf(m1262, st, k);
                         else
                           currentinstance->values[k].stringindex = tmp;
                        }
                       else
                         currentinstance->values[k].stringindex = -1;
                       break;
         case CLASSDEF:currentinstance->values[k].stringindex = listindex(st, dataset->features[k].strings, dataset->features[k].valuecount);
                       if (currentinstance->values[k].stringindex == -1)
                         printf(m1263, myline, st);
                       if (withnoise && get_parameter_f("noiselevel") > 0.0)
                         if (produce_random_value(0.0, 1.0) < get_parameter_f("noiselevel"))
                           currentinstance->values[k].stringindex = myrand() % dataset->features[k].valuecount;
                       break;
         default      :printf(m1238, dataset->features[k].type);
                       break;
       }
      }
     else
       if (dataset->storetype == STORE_MULTILABEL)
         currentinstance->class_labels[k - dataset->classdefno] = atoi(st);
     k++;
    }
   st = (char *) strtok(NULL, st1);
   j++;
   if (k == dataset->featurecount && dataset->storetype == STORE_SEQUENTIAL && st)
    {
     subinstance = empty_instance(dataset->featurecount);
     if (currentframe == 0)
       currentinstance->sublist = subinstance;
     else
       currentinstance->next = subinstance;
     subinstance->values[0].stringindex = cno;
     currentframe++;
     j = 1;
     k = 1;
     currentinstance = subinstance;
    }
  }
 if (k == dataset->featurecount || (k == dataset->featurecount + dataset->classno && dataset->storetype == STORE_MULTILABEL))
   return firstinstance;
 else
   return NULL;  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a168, %rsp          # imm = 0x7A168
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x39520
testl %eax, %eax
je 0x184b7
xorl %eax, %eax
addq $0x7a168, %rsp          # imm = 0x7A168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x4270
movb 0x1a8(%rbx), %al
movb %al, 0x8(%rsp)
movw $0xa, 0x9(%rsp)
cmpl $0x4, 0x140713c(%rbx)
movl 0x1bc(%rbx), %edi
jne 0x1850e
movslq 0x10(%rbx), %r14
callq 0x152fc
movq %rax, %r13
shlq $0x2, %r14
leaq 0x8bc2a(%rip), %rsi     # 0xa4125
movq %r14, %rdi
movl $0x3, %edx
callq 0x390f5
movq %rax, 0x8(%r13)
jmp 0x18516
callq 0x152fc
movq %rax, %r13
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4280
movq %rax, %r14
cmpl $0x2, 0x140713c(%rbx)
jne 0x18593
leaq 0x30f28(%rbx), %rsi
movl 0x30f20(%rbx), %edx
movq %r14, %rdi
callq 0x3a2c5
movq (%r13), %rcx
movl %eax, (%rcx)
movq (%r13), %rax
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
cmpl $-0x1, %eax
jne 0x1856f
leaq 0x8bbde(%rip), %rdi     # 0xa4140
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x4030
leaq 0x8(%rsp), %r14
xorl %edi, %edi
movq %r14, %rsi
callq 0x4280
xorl %edi, %edi
movq %r14, %rsi
callq 0x4280
movq %rax, %r14
movl $0x1, %r12d
jmp 0x18596
xorl %r12d, %r12d
testq %r14, %r14
movq %r13, 0x20(%rsp)
je 0x18838
movq %r15, 0x30(%rsp)
movl %ebp, 0x18(%rsp)
leaq 0x30f08(%rbx), %r15
movl $0x0, 0xc(%rsp)
movq %r13, %rbp
movl %r12d, %r13d
movq %r15, 0x38(%rsp)
movslq %r13d, %rax
cmpl $0x0, 0x1c4(%rbx,%rax,4)
je 0x187c2
movq %r14, %rdi
leaq 0x8b9d3(%rip), %rsi     # 0xa3fb5
callq 0x4260
cmpl 0x1bc(%rbx), %r12d
jge 0x18642
movslq %r12d, %rdi
imulq $0x340, %rdi, %r15      # imm = 0x340
movq 0x38(%rsp), %rcx
movl (%rcx,%r15), %esi
cmpq $0x4, %rsi
ja 0x1876d
addq %rcx, %r15
leaq 0x8aee9(%rip), %rdx     # 0xa3500
movslq (%rdx,%rsi,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
testl %eax, %eax
je 0x1877d
movq %rdi, %r15
movq %r14, %rdi
callq 0x4130
movq (%rbp), %rax
movsd %xmm0, (%rax,%r15,8)
jmp 0x187bf
cmpl $0x4, 0x140713c(%rbx)
jne 0x187bf
movq %r14, %rdi
callq 0x4200
movq 0x8(%rbp), %rcx
movslq 0x1407128(%rbx), %rdx
movslq %r12d, %rsi
subq %rdx, %rsi
movl %eax, (%rcx,%rsi,4)
jmp 0x187bf
leaq 0x20(%r15), %rsi
movl 0x18(%r15), %edx
movq %rdi, 0x10(%rsp)
movq %r14, %rdi
callq 0x3a2c5
movq (%rbp), %rcx
movq 0x10(%rsp), %rdx
movl %eax, (%rcx,%rdx,8)
movq (%rbp), %rax
cmpl $-0x1, (%rax,%rdx,8)
jne 0x186b1
leaq 0x8ba9e(%rip), %rdi     # 0xa4140
movq 0x30(%rsp), %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x4030
cmpl $0x0, 0x18(%rsp)
je 0x187bf
leaq 0x8af3a(%rip), %rdi     # 0xa35fd
callq 0x534b6
ucomisd 0x8a638(%rip), %xmm0    # 0xa2d08
jbe 0x187bf
xorpd %xmm0, %xmm0
movsd 0x89e3e(%rip), %xmm1    # 0xa2520
callq 0x39f62
movsd %xmm0, 0x28(%rsp)
leaq 0x8af09(%rip), %rdi     # 0xa35fd
callq 0x534b6
ucomisd 0x28(%rsp), %xmm0
jbe 0x187bf
xorl %eax, %eax
callq 0x39f18
cltd
idivl 0x18(%r15)
movq (%rbp), %rax
movq 0x10(%rsp), %rcx
movl %edx, (%rax,%rcx,8)
jmp 0x187bf
testl %eax, %eax
je 0x18791
movq %rdi, %r15
movq %r14, %rdi
callq 0x4200
movq (%rbp), %rcx
movl %eax, (%rcx,%r15,8)
jmp 0x187bf
testl %eax, %eax
je 0x1879e
movq %rdi, 0x10(%rsp)
movl 0x18(%r15), %edx
addq $0x20, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3a2c5
cmpl $-0x1, %eax
je 0x187ab
movq (%rbp), %rcx
movq 0x10(%rsp), %rdx
movl %eax, (%rcx,%rdx,8)
jmp 0x187bf
leaq 0x8abfa(%rip), %rdi     # 0xa336e
xorl %eax, %eax
callq 0x4030
jmp 0x187bf
movq (%rbp), %rax
movabsq $0x419d6f3454000000, %rcx # imm = 0x419D6F3454000000
movq %rcx, (%rax,%rdi,8)
jmp 0x187bf
movq (%rbp), %rax
movl $0x75bcd15, (%rax,%rdi,8) # imm = 0x75BCD15
jmp 0x187bf
movq (%rbp), %rax
movl $0xffffffff, (%rax,%rdi,8) # imm = 0xFFFFFFFF
jmp 0x187bf
leaq 0x8b9cb(%rip), %rdi     # 0xa417d
movq %r14, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4030
incl %r12d
xorl %edi, %edi
leaq 0x8(%rsp), %rsi
callq 0x4280
movq %rax, %r14
incl %r13d
movl 0x1bc(%rbx), %edi
cmpl %edi, %r12d
jne 0x1882f
cmpl $0x2, 0x140713c(%rbx)
sete %al
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1882f
callq 0x152fc
leaq 0x10(%rbp), %rcx
addq $0x28, %rbp
movl 0xc(%rsp), %esi
testl %esi, %esi
cmovneq %rcx, %rbp
movq %rax, (%rbp)
movq (%rax), %rcx
movl 0x1c(%rsp), %edx
movl %edx, (%rcx)
incl %esi
movl %esi, 0xc(%rsp)
movl $0x1, %r13d
movl $0x1, %r12d
movq %rax, %rbp
testq %r14, %r14
jne 0x185c7
movl 0x1bc(%rbx), %eax
cmpl %eax, %r12d
jne 0x1884d
movq 0x20(%rsp), %rax
jmp 0x184a5
addl 0x10(%rbx), %eax
cmpl %eax, %r12d
movq 0x20(%rsp), %rax
jne 0x184a3
cmpl $0x4, 0x140713c(%rbx)
jne 0x184a3
jmp 0x184a5