// File: /workspace/github_c_makefile_star2_O3/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, %r15d
movq %rsi, %r13
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x3a52c
testl %eax, %eax
je 0x18a25
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 %r13, %rsi
callq 0x4270
movb 0x1a8(%rbx), %al
movb %al, 0x8(%rsp)
movw $0xa, 0x9(%rsp)
cmpl $0x4, 0x140713c(%rbx)
movl 0x1bc(%rbx), %edi
jne 0x18a7d
movslq 0x10(%rbx), %r14
callq 0x15391
movq %rax, %r12
shlq $0x2, %r14
leaq 0x8e6fe(%rip), %rsi     # 0xa7167
movq %r14, %rdi
movl $0x3, %edx
callq 0x3a0e1
movq %rax, 0x8(%r12)
jmp 0x18a85
callq 0x15391
movq %rax, %r12
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4280
movq %rax, %rbp
cmpl $0x2, 0x140713c(%rbx)
movq %r12, 0x18(%rsp)
jne 0x18b07
leaq 0x30f28(%rbx), %rsi
movl 0x30f20(%rbx), %edx
movq %rbp, %rdi
callq 0x3b355
movq (%r12), %rcx
movl %eax, (%rcx)
movq (%r12), %rax
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
cmpl $-0x1, %eax
jne 0x18ae3
leaq 0x8e6ac(%rip), %rdi     # 0xa7182
movq %r13, %rsi
movq %rbp, %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, %rbp
movl $0x1, %r12d
jmp 0x18b0a
xorl %r12d, %r12d
testq %rbp, %rbp
je 0x18da3
movq %r13, 0x38(%rsp)
movl %r15d, 0x28(%rsp)
leaq 0x30f08(%rbx), %rcx
movl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %r15
movl %r12d, %r13d
movq %rcx, 0x20(%rsp)
movslq %r13d, %rax
cmpl $0x0, 0x1c4(%rbx,%rax,4)
je 0x18d28
cmpb $0x3f, (%rbp)
jne 0x18b59
cmpb $0x0, 0x1(%rbp)
sete %al
jmp 0x18b5b
xorl %eax, %eax
cmpl 0x1bc(%rbx), %r12d
jge 0x18bad
movslq %r12d, %rdi
imulq $0x340, %rdi, %r14      # imm = 0x340
movl (%rcx,%r14), %esi
cmpq $0x4, %rsi
ja 0x18cad
addq %rcx, %r14
leaq 0x8d9be(%rip), %rdx     # 0xa6544
movslq (%rdx,%rsi,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
testb %al, %al
je 0x18cbd
movq (%r15), %rax
movabsq $0x419d6f3454000000, %rcx # imm = 0x419D6F3454000000
movq %rcx, (%rax,%rdi,8)
jmp 0x18d25
cmpl $0x4, 0x140713c(%rbx)
jne 0x18d25
movq %rbp, %rdi
callq 0x4200
movq 0x8(%r15), %rcx
movslq 0x1407128(%rbx), %rdx
movslq %r12d, %rsi
subq %rdx, %rsi
movl %eax, (%rcx,%rsi,4)
jmp 0x18d25
leaq 0x20(%r14), %rsi
movl 0x18(%r14), %edx
movq %rdi, 0x10(%rsp)
movq %rbp, %rdi
callq 0x3b355
movq (%r15), %rcx
movq 0x10(%rsp), %rdx
movl %eax, (%rcx,%rdx,8)
movq (%r15), %rax
cmpl $-0x1, (%rax,%rdx,8)
jne 0x18c1a
leaq 0x8e577(%rip), %rdi     # 0xa7182
movq 0x38(%rsp), %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4030
cmpl $0x0, 0x28(%rsp)
je 0x18d25
leaq 0x8da15(%rip), %rdi     # 0xa6641
callq 0x549ba
ucomisd 0x8d0cf(%rip), %xmm0    # 0xa5d08
jbe 0x18d25
xorpd %xmm0, %xmm0
movsd 0x8c8d5(%rip), %xmm1    # 0xa5520
callq 0x3af6a
movsd %xmm0, 0x30(%rsp)
leaq 0x8d9e4(%rip), %rdi     # 0xa6641
callq 0x549ba
ucomisd 0x30(%rsp), %xmm0
jbe 0x18d25
xorl %eax, %eax
callq 0x3af20
cltd
idivl 0x18(%r14)
movq (%r15), %rax
movq 0x10(%rsp), %rcx
movl %edx, (%rax,%rcx,8)
jmp 0x18d25
testb %al, %al
je 0x18cd3
movq (%r15), %rax
movl $0x75bcd15, (%rax,%rdi,8) # imm = 0x75BCD15
jmp 0x18d25
testb %al, %al
je 0x18ce7
movq (%r15), %rax
movl $0xffffffff, (%rax,%rdi,8) # imm = 0xFFFFFFFF
jmp 0x18d25
leaq 0x8d6ba(%rip), %rdi     # 0xa636e
xorl %eax, %eax
callq 0x4030
jmp 0x18d25
movq %rdi, %r14
movq %rbp, %rdi
callq 0x4130
movq (%r15), %rax
movsd %xmm0, (%rax,%r14,8)
jmp 0x18d25
movq %rdi, %r14
movq %rbp, %rdi
callq 0x4200
movq (%r15), %rcx
movl %eax, (%rcx,%r14,8)
jmp 0x18d25
movq %rdi, 0x10(%rsp)
movl 0x18(%r14), %edx
addq $0x20, %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3b355
cmpl $-0x1, %eax
je 0x18d11
movq (%r15), %rcx
movq 0x10(%rsp), %rdx
movl %eax, (%rcx,%rdx,8)
jmp 0x18d25
leaq 0x8e4a7(%rip), %rdi     # 0xa71bf
movq %rbp, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4030
incl %r12d
xorl %edi, %edi
leaq 0x8(%rsp), %rsi
callq 0x4280
movq %rax, %rbp
incl %r13d
cmpl 0x1bc(%rbx), %r12d
jne 0x18d95
cmpl $0x2, 0x140713c(%rbx)
sete %al
testq %rbp, %rbp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x18d95
movl %r12d, %edi
callq 0x15391
leaq 0x10(%r15), %rcx
addq $0x28, %r15
movl 0xc(%rsp), %esi
testl %esi, %esi
cmovneq %rcx, %r15
movq %rax, (%r15)
movq (%rax), %rcx
movl 0x2c(%rsp), %edx
movl %edx, (%rcx)
incl %esi
movl %esi, 0xc(%rsp)
movl $0x1, %r13d
movl $0x1, %r12d
movq %rax, %r15
movq 0x20(%rsp), %rcx
testq %rbp, %rbp
jne 0x18b39
movl 0x1bc(%rbx), %eax
cmpl %eax, %r12d
jne 0x18db8
movq 0x18(%rsp), %rax
jmp 0x18a13
addl 0x10(%rbx), %eax
cmpl %eax, %r12d
movq 0x18(%rsp), %rax
jne 0x18a11
cmpl $0x4, 0x140713c(%rbx)
jne 0x18a11
jmp 0x18a13