// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x352fc
testl %eax, %eax
je 0x16e6b
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 %r14, %rsi
callq 0x4270
movb 0x1a8(%rbx), %al
movb %al, 0x8(%rsp)
movw $0xa, 0x9(%rsp)
cmpl $0x4, 0x140713c(%rbx)
movl 0x1bc(%rbx), %edi
movl %ebp, 0x14(%rsp)
jne 0x16ea6
movl 0x10(%rbx), %esi
callq 0x16dff
jmp 0x16eab
callq 0x140fd
movq %rax, %r15
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4280
movq %rax, %rbp
cmpl $0x2, 0x140713c(%rbx)
movq %r14, 0x30(%rsp)
jne 0x16f2c
leaq 0x30f28(%rbx), %rsi
movl 0x30f20(%rbx), %edx
movq %rbp, %rdi
callq 0x35f17
movq (%r15), %rcx
movl %eax, (%rcx)
movq (%r15), %rax
movl (%rax), %eax
movl %eax, 0x10(%rsp)
cmpl $-0x1, %eax
jne 0x16f0a
leaq 0x80225(%rip), %rdi     # 0x97122
movq %r14, %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
pushq $0x1
popq %r12
jmp 0x16f2f
xorl %r12d, %r12d
leaq 0x30f08(%rbx), %rcx
leaq 0x1c4(%rbx), %r14
movq %r15, 0x18(%rsp)
movq %r15, (%rsp)
movl $0x0, 0xc(%rsp)
movq %rcx, 0x20(%rsp)
movq %r14, 0x38(%rsp)
movl %r12d, %eax
leaq (%r14,%rax,4), %r15
testq %rbp, %rbp
je 0x171c6
cmpl $0x0, (%r15)
je 0x17134
cmpb $0x3f, (%rbp)
jne 0x16f81
cmpb $0x0, 0x1(%rbp)
sete %al
jmp 0x16f83
xorl %eax, %eax
movslq %r12d, %r13
cmpl 0x1bc(%rbx), %r12d
jge 0x16fd9
imulq $0x340, %r13, %r14      # imm = 0x340
movl (%rcx,%r14), %esi
cmpq $0x4, %rsi
ja 0x170d8
addq %rcx, %r14
leaq 0x7f516(%rip), %rdx     # 0x964c4
movslq (%rdx,%rsi,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
testb %al, %al
je 0x170e8
movq (%rsp), %rax
movq (%rax), %rax
movabsq $0x419d6f3454000000, %rcx # imm = 0x419D6F3454000000
movq %rcx, (%rax,%r13,8)
jmp 0x1712c
cmpl $0x4, 0x140713c(%rbx)
jne 0x1712c
movq %rbp, %rdi
callq 0x4200
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
movslq 0x1407128(%rbx), %rdx
subq %rdx, %r13
movl %eax, (%rcx,%r13,4)
jmp 0x1712c
leaq 0x20(%r14), %rsi
movl 0x18(%r14), %edx
movq %rbp, %rdi
callq 0x35f17
movq (%rsp), %rdx
movq (%rdx), %rcx
movl %eax, (%rcx,%r13,8)
movq (%rdx), %rax
cmpl $-0x1, (%rax,%r13,8)
jne 0x17044
leaq 0x800ed(%rip), %rdi     # 0x97122
movq 0x30(%rsp), %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4030
cmpl $0x0, 0x14(%rsp)
je 0x1712c
leaq 0x7f58b(%rip), %rdi     # 0x965e1
callq 0x4cdcf
ucomisd 0x7ecb5(%rip), %xmm0    # 0x95d18
jbe 0x1712c
xorpd %xmm0, %xmm0
movsd 0x7e4ab(%rip), %xmm1    # 0x95520
callq 0x35cae
movsd %xmm0, 0x28(%rsp)
leaq 0x7f55a(%rip), %rdi     # 0x965e1
callq 0x4cdcf
ucomisd 0x28(%rsp), %xmm0
jbe 0x1712c
xorl %eax, %eax
callq 0x35c7f
cltd
idivl 0x18(%r14)
movq (%rsp), %rax
movq (%rax), %rax
movl %edx, (%rax,%r13,8)
jmp 0x1712c
testb %al, %al
je 0x170ff
movq (%rsp), %rax
movq (%rax), %rax
movl $0x75bcd15, (%rax,%r13,8) # imm = 0x75BCD15
jmp 0x1712c
testb %al, %al
je 0x17109
movq (%rsp), %rax
movq (%rax), %rax
orl $-0x1, (%rax,%r13,8)
jmp 0x1712c
leaq 0x7f28f(%rip), %rdi     # 0x9636e
xorl %eax, %eax
callq 0x4030
jmp 0x1712c
movq %rbp, %rdi
callq 0x4130
movq (%rsp), %rax
movq (%rax), %rax
movsd %xmm0, (%rax,%r13,8)
jmp 0x1712c
movq %rbp, %rdi
callq 0x4200
jmp 0x17121
movl 0x18(%r14), %edx
addq $0x20, %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0x35f17
cmpl $-0x1, %eax
je 0x1716e
movq (%rsp), %rcx
movq (%rcx), %rcx
movl %eax, (%rcx,%r13,8)
incl %r12d
movq 0x38(%rsp), %r14
xorl %edi, %edi
leaq 0x8(%rsp), %rsi
callq 0x4280
movq %rax, %rbp
cmpl 0x1bc(%rbx), %r12d
jne 0x17160
cmpl $0x2, 0x140713c(%rbx)
sete %al
testq %rbp, %rbp
setne %cl
testb %cl, %al
jne 0x17184
addq $0x4, %r15
movq 0x20(%rsp), %rcx
jmp 0x16f5f
leaq 0x7ffea(%rip), %rdi     # 0x9715f
movq %rbp, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4030
jmp 0x1712c
movl %r12d, %edi
callq 0x140fd
movq (%rsp), %rdx
leaq 0x10(%rdx), %rcx
addq $0x28, %rdx
movl 0xc(%rsp), %esi
testl %esi, %esi
cmovneq %rcx, %rdx
movq %rax, (%rdx)
movq (%rax), %rcx
movl 0x10(%rsp), %edx
movl %edx, (%rcx)
incl %esi
movl %esi, 0xc(%rsp)
pushq $0x1
popq %r12
movq %rax, (%rsp)
movq 0x20(%rsp), %rcx
jmp 0x16f58
movl 0x1bc(%rbx), %eax
cmpl %eax, %r12d
jne 0x171db
movq 0x18(%rsp), %rax
jmp 0x16e59
addl 0x10(%rbx), %eax
cmpl %eax, %r12d
movq 0x18(%rsp), %rax
jne 0x16e57
cmpl $0x4, 0x140713c(%rbx)
jne 0x16e57
jmp 0x16e59