// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/dataset.c
// Function: create_dataset
int create_dataset(char* datasetname, char* separator, int classdefno, char* classes, char* directoryname, char* filename, char* discretefeatures)
{
 /*!Last Changed 13.03.2007 added selected for features*/
 /*!Last Changed 19.08.2006 added regression definition*/
 /*!Last Changed 09.05.2005 changed including discrete feature definitions*/
 /*!Last Changed 02.02.2004 added safemalloc and safecalloc*/
 /*!Last Changed 31.01.2004*/
 Datasetptr tmp;
 int found = 0, i, classcode;
 char* fname, *st, myline[READLINELENGTH];
 FILE* infile;
 Intervalptr intervals;
 tmp = search_dataset(Datasets, datasetname);
 if (tmp)
  {
   printf(m1120);
   delete_dataset(datasetname);
  }
 tmp = empty_dataset(datasetname, directoryname, filename, separator[0]);
 tmp->datacount = 1;
 tmp->allfeatures = 0;
 tmp->classdefno = classdefno;
 for (i = 0; i < MAXCLASSES; i++)
   tmp->classcounts[i] = 0;
 stringlist(classes, ";", tmp->classes, &(tmp->classno));
 if (tmp->classno > MAXCLASSES)
  {
   printf(m1419, tmp->classno);
   return 0;
  }
 intervals = create_intervals(discretefeatures);
 fname = dataset_file_name(tmp);
 infile = fopen(fname, "r");
 if (!infile)
  {
   printf(m1121, fname);
   free_dataset(tmp);
   safe_free(fname);
   return 0;
  }
 if (fgets(myline,READLINELENGTH,infile))
  {
   myline[strlen(myline) - 1]='\0';
   st = strtok(myline, separator);
   while (st)
    {
     if (strcmp(st,"?") == 0)
      {
       free_dataset(tmp);
       safe_free(fname);
       printf(m1127);
       return 0;     
      }
     if (tmp->allfeatures == classdefno)
      {
       if (tmp->classno)
        {
         tmp->features[tmp->allfeatures].type = CLASSDEF;
         for (i = 0; i < tmp->classno; i++)
           tmp->features[tmp->classdefno].strings[i] = strcopy(tmp->features[tmp->classdefno].strings[i], tmp->classes[i]);
         tmp->features[tmp->classdefno].valuecount = tmp->classno;
         tmp->classcounts[listindex(st, tmp->classes, tmp->classno)] = 1;
        }
       else
         tmp->features[tmp->allfeatures].type = REGDEF;
       found = 1;
      }
     else
       if (is_in_interval(intervals, tmp->allfeatures))
         tmp->features[tmp->allfeatures].type = STRING;
       else
         if (isinteger(st))
           tmp->features[tmp->allfeatures].type = INTEGER;
         else
           tmp->features[tmp->allfeatures].type = REAL;
     tmp->features[tmp->allfeatures].selected = YES;
     tmp->allfeatures++;
     st = strtok(NULL, separator);
    }
   if (!found && tmp->classdefno != -1)
    {
     free_dataset(tmp);
     safe_free(fname);
     printf(m1125);
     return 0;     
    }
   if (tmp->allfeatures <= 1)
    {
     free_dataset(tmp);
     safe_free(fname);
     printf(m1123);
     return 0;
    }
   if (tmp->allfeatures > MAXFEATURES)
    {
     free_dataset(tmp);
     safe_free(fname);
     printf(m1421, tmp->allfeatures);
     return 0;
    }
  }
 else
  {
   free_dataset(tmp);
   safe_free(fname);
   printf(m1122);
   return 0;
  }
 while (fgets(myline, READLINELENGTH, infile))
  {
   if (strlen(myline) <= 1)
     continue;
   myline[strlen(myline) - 1] = '\0';
   tmp->datacount++;
   st = strtok(myline, separator);
   i = 0;
   while (st)
    {
     if (strcmp(st,"?") != 0)
       switch (tmp->features[i].type)
        {
         case  INTEGER:if (!isinteger(st) && isfloat(st))
                         tmp->features[i].type = REAL;
                       break;
         case CLASSDEF:classcode = listindex(st, tmp->classes, tmp->classno);
                       if (classcode == -1)
                        {
                         printf(m1260, tmp->datacount, i+1);
                         free_dataset(tmp);
                         safe_free(fname);
                         return 0;
                        }
                       else
                         tmp->classcounts[classcode]++;
                       break;
        }
     i++;
     st = strtok(NULL, separator);
    }
   if (i != tmp->allfeatures)
    {
     free_dataset(tmp);
     safe_free(fname);
     printf(m1261, tmp->datacount, tmp->allfeatures);
     return 0;          
    }
  }
 tmp->featurecount = tmp->allfeatures;
 for (i = 0; i < tmp->featurecount; i++)
   tmp->availability[i] = 1;
 fclose(infile);
 tmp->active = NO;
 add_dataset(tmp);
 printf(m1126);
 safe_free(fname);
 free_intervals(intervals);
 return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a168, %rsp          # imm = 0x7A168
movq %r9, %rbx
movq %r8, %r12
movq %rcx, %r13
movl %edx, %r14d
movq %rsi, 0x8(%rsp)
movq %rdi, %rbp
leaq 0xbb279(%rip), %rax     # 0xd2878
movq (%rax), %r15
testq %r15, %r15
je 0x17634
movq 0x8(%r15), %rdi
movq %rbp, %rsi
callq 0x4260
testl %eax, %eax
je 0x17620
movq 0x1407270(%r15), %r15
jmp 0x17602
leaq 0x8d030(%rip), %rdi     # 0xa4657
callq 0x4090
movq %rbp, %rdi
callq 0x170a0
movq 0x8(%rsp), %rax
movsbl (%rax), %ecx
movq %rbp, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x15559
movq %rax, %rbx
movl $0x1, 0x1407120(%rax)
movl $0x0, 0x1b8(%rax)
movl %r14d, 0x1407128(%rax)
leaq 0x1407140(%rax), %rdi
xorl %r12d, %r12d
movl $0xc8, %edx
xorl %esi, %esi
callq 0x4050
leaq 0x18(%rbx), %rdx
leaq 0x10(%rbx), %rbp
leaq 0x8e3e9(%rip), %rsi     # 0xa5a76
movq %r13, %rdi
movq %rdx, 0x38(%rsp)
movq %rbp, %rcx
callq 0x3a431
movl 0x10(%rbx), %esi
cmpl $0x33, %esi
jl 0x176b8
leaq 0x8c846(%rip), %rdi     # 0xa3ef2
xorl %eax, %eax
callq 0x4030
jmp 0x1798b
movq 0x7a1a0(%rsp), %rdi
callq 0x3115a
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
callq 0x16285
movq %rax, %r15
leaq 0x911b3(%rip), %rsi     # 0xa888f
movq %rax, %rdi
callq 0x40f0
testq %rax, %rax
je 0x178d4
movq %rax, %r13
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rax, %rdx
callq 0x4120
testq %rax, %rax
je 0x178fd
movq %r12, %rdi
callq 0x4190
movb $0x0, -0x1(%rax,%r12)
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x4280
testq %rax, %rax
movq %rbp, 0x30(%rsp)
je 0x1793f
movq %rax, %r12
movq %r13, 0x10(%rsp)
movq %r15, 0x28(%rsp)
leaq 0x30f08(%rbx), %r13
leaq 0x30f28(%rbx), %rax
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
movq 0x20(%rsp), %r15
movq %r12, %rdi
leaq 0x8c84d(%rip), %rsi     # 0xa3fb5
callq 0x4260
testl %eax, %eax
je 0x17916
movslq 0x1b8(%rbx), %rsi
cmpl %r14d, %esi
jne 0x17827
movq 0x30(%rsp), %rcx
cmpl $0x0, (%rcx)
je 0x1784c
imulq $0x340, %rsi, %rax      # imm = 0x340
movl $0x3, (%r13,%rax)
movl (%rcx), %edx
testl %edx, %edx
jle 0x177f8
movq 0x18(%rsp), %rbp
xorl %r15d, %r15d
movslq 0x1407128(%rbx), %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movq (%rbp,%rax), %rdi
movq -0x30f10(%rbp), %rsi
callq 0x3a404
movslq 0x1407128(%rbx), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movq %rax, (%rbp,%rcx)
incq %r15
movslq 0x10(%rbx), %rdx
addq $0x8, %rbp
cmpq %rdx, %r15
jl 0x177b1
movq 0x20(%rsp), %r15
movslq 0x1407128(%rbx), %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movl %edx, 0x18(%r13,%rax)
movq %r12, %rdi
movq 0x38(%rsp), %rsi
callq 0x3a2c5
cltq
movl $0x1, 0x1407140(%rbx,%rax,4)
jmp 0x1785c
movq %r15, %rdi
callq 0x3113e
testl %eax, %eax
je 0x1789d
movslq 0x1b8(%rbx), %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movl $0x1, (%r13,%rax)
jmp 0x17861
imulq $0x340, %rsi, %rax      # imm = 0x340
movl $0x4, (%r13,%rax)
movl $0x1, %ebp
movslq 0x1b8(%rbx), %rax
imulq $0x340, %rax, %rcx      # imm = 0x340
movl $0x1, 0x1c(%r13,%rcx)
incl %eax
movl %eax, 0x1b8(%rbx)
xorl %edi, %edi
movq 0x8(%rsp), %rsi
callq 0x4280
movq %rax, %r12
testq %rax, %rax
jne 0x1775e
jmp 0x17931
movq %r12, %rdi
callq 0x3992c
movslq 0x1b8(%rbx), %rcx
testl %eax, %eax
je 0x178c2
imulq $0x340, %rcx, %rax      # imm = 0x340
movl $0x0, (%r13,%rax)
jmp 0x17861
imulq $0x340, %rcx, %rax      # imm = 0x340
movl $0x2, (%r13,%rax)
jmp 0x17861
leaq 0x8c642(%rip), %rdi     # 0xa3f1d
xorl %r12d, %r12d
movq %r15, %rsi
xorl %eax, %eax
callq 0x4030
movq %rbx, %rdi
callq 0x13765
movq %r15, %rdi
callq 0x39194
jmp 0x1798b
movq %rbx, %rdi
callq 0x13765
movq %r15, %rdi
callq 0x39194
leaq 0x8cc83(%rip), %rdi     # 0xa4597
jmp 0x17983
movq %rbx, %rdi
callq 0x13765
movq 0x28(%rsp), %rdi
callq 0x39194
leaq 0x8ccfe(%rip), %rdi     # 0xa462d
jmp 0x17983
testl %ebp, %ebp
movq 0x28(%rsp), %r15
movq 0x10(%rsp), %r13
jne 0x17961
cmpl $-0x1, 0x1407128(%rbx)
je 0x17961
movq %rbx, %rdi
callq 0x13765
movq %r15, %rdi
callq 0x39194
leaq 0x8cc68(%rip), %rdi     # 0xa45c7
jmp 0x17983
movl 0x1b8(%rbx), %eax
cmpl $0x1, %eax
jg 0x179a0
movq %rbx, %rdi
callq 0x13765
movq %r15, %rdi
callq 0x39194
leaq 0x8cc78(%rip), %rdi     # 0xa45fb
callq 0x4090
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x7a168, %rsp          # imm = 0x7A168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x61a8, %eax           # imm = 0x61A8
jle 0x179cc
movq %rbx, %rdi
callq 0x13765
movq %r15, %rdi
callq 0x39194
movl 0x1b8(%rbx), %esi
leaq 0x8c5f3(%rip), %rdi     # 0xa3fb7
xorl %r12d, %r12d
jmp 0x176ac
leaq 0x40(%rsp), %rbp
movq %rbp, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r13, %rdx
callq 0x4120
testq %rax, %rax
je 0x17afd
movq %rbx, %rax
addq $0x30f08, %rax          # imm = 0x30F08
movq %rax, 0x18(%rsp)
leaq 0x8c5b6(%rip), %r12     # 0xa3fb5
movq %r13, 0x10(%rsp)
movq %rbp, %rdi
callq 0x4190
cmpq $0x1, %rax
jbe 0x17ae4
movb $0x0, -0x1(%rax,%rbp)
incl 0x1407120(%rbx)
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq 0x4280
testq %rax, %rax
je 0x17acf
movq %rax, %r13
movl $0x1, %r14d
movq 0x18(%rsp), %rbp
movq %r13, %rdi
movq %r12, %rsi
callq 0x4260
testl %eax, %eax
je 0x17aa7
movl (%rbp), %eax
cmpl $0x3, %eax
je 0x17a81
testl %eax, %eax
jne 0x17aa7
movq %r13, %rdi
callq 0x3992c
testl %eax, %eax
jne 0x17aa7
movq %r13, %rdi
callq 0x398e1
testl %eax, %eax
je 0x17aa7
movl $0x2, (%rbp)
jmp 0x17aa7
movq 0x30(%rsp), %rax
movl (%rax), %edx
movq %r13, %rdi
movq 0x38(%rsp), %rsi
callq 0x3a2c5
cmpl $-0x1, %eax
je 0x17b88
cltq
incl 0x1407140(%rbx,%rax,4)
xorl %edi, %edi
movq 0x8(%rsp), %rsi
callq 0x4280
movq %rax, %r13
incl %r14d
addq $0x340, %rbp            # imm = 0x340
testq %rax, %rax
jne 0x17a45
decl %r14d
leaq 0x40(%rsp), %rbp
jmp 0x17ad2
xorl %r14d, %r14d
cmpl 0x1b8(%rbx), %r14d
movq 0x10(%rsp), %r13
jne 0x17ba7
movq %rbp, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r13, %rdx
callq 0x4120
testq %rax, %rax
jne 0x17a04
movl 0x1b8(%rbx), %eax
movl %eax, 0x1bc(%rbx)
testl %eax, %eax
jle 0x17b29
xorl %eax, %eax
movl $0x1, 0x1c4(%rbx,%rax,4)
incq %rax
movslq 0x1bc(%rbx), %rcx
cmpq %rcx, %rax
jl 0x17b0f
movq %r13, %rdi
callq 0x42a0
movl $0x0, (%rbx)
leaq 0xbad3a(%rip), %rcx     # 0xd2878
movq (%rcx), %rax
testq %rax, %rax
je 0x17b5c
movq %rax, %rcx
movq 0x1407270(%rax), %rax
testq %rax, %rax
jne 0x17b46
addq $0x1407270, %rcx        # imm = 0x1407270
movq %rbx, (%rcx)
leaq 0x8cb54(%rip), %rdi     # 0xa46ba
callq 0x4090
movq %r15, %rdi
callq 0x39194
movq 0x20(%rsp), %rdi
callq 0x31110
movl $0x1, %r12d
jmp 0x1798b
movl 0x1407120(%rbx), %esi
leaq 0x8c3e3(%rip), %rdi     # 0xa3f78
xorl %r12d, %r12d
movl %r14d, %edx
xorl %eax, %eax
callq 0x4030
jmp 0x178e8
movq %rbx, %rdi
callq 0x13765
movq %r15, %rdi
callq 0x39194
movl 0x1407120(%rbx), %esi
movl 0x1b8(%rbx), %edx
leaq 0x8c41b(%rip), %rdi     # 0xa3fe5
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x4030
jmp 0x1798b