// File: /workspace/github_c_makefile_star2_O2/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 $0x7a178, %rsp          # imm = 0x7A178
movq %r9, %rbx
movq %r8, %rbp
movq %rcx, %r12
movl %edx, %r14d
movq %rsi, 0x10(%rsp)
movq %rdi, %r13
leaq 0xb76dd(%rip), %rax     # 0xcd878
movq (%rax), %rdi
movq %r13, %rsi
callq 0x13da6
testq %rax, %rax
je 0x161bf
leaq 0x81487(%rip), %rdi     # 0x97639
callq 0x4090
movq %r13, %rdi
callq 0x15cdf
movq 0x7a1b0(%rsp), %r15
movq 0x10(%rsp), %rax
movsbl (%rax), %ecx
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x1434b
movq %rax, %rbx
movl $0x1, 0x1407120(%rax)
andl $0x0, 0x1b8(%rax)
movl %r14d, 0x1407128(%rax)
movl $0x501c50, %eax         # imm = 0x501C50
cmpq $0x501c82, %rax         # imm = 0x501C82
je 0x1620e
andl $0x0, (%rbx,%rax,4)
incq %rax
jmp 0x161fd
leaq 0x18(%rbx), %rdx
leaq 0x10(%rbx), %rcx
leaq 0x82851(%rip), %rsi     # 0x98a6e
movq %r12, %rdi
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
callq 0x36077
movl 0x10(%rbx), %esi
cmpl $0x33, %esi
jl 0x1624c
leaq 0x80c98(%rip), %rdi     # 0x96ed6
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x4030
jmp 0x16532
movq %r15, %rdi
callq 0x2d8d0
movq %rax, 0x28(%rsp)
movq %rbx, %rdi
callq 0x14f75
movq %rax, %r15
leaq 0x85614(%rip), %rsi     # 0x9b87f
movq %rax, %rdi
callq 0x40f0
testq %rax, %rax
je 0x1644d
movq %rax, %r12
leaq 0x50(%rsp), %r13
movq %r13, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rax, %rdx
callq 0x4120
testq %rax, %rax
je 0x164a6
movq %r12, 0x18(%rsp)
movq %r15, 0x8(%rsp)
movq %r13, %rdi
callq 0x4190
movb $0x0, -0x1(%rax,%r13)
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x4280
movq %rax, %r12
leaq 0x30f08(%rbx), %r15
movslq %r14d, %rax
movq %rax, 0x40(%rsp)
imulq $0x340, %rax, %rax      # imm = 0x340
addq %rbx, %rax
addq $0x30f08, %rax          # imm = 0x30F08
movq %rax, 0x20(%rsp)
movq %rbx, %rax
addq $0x30f28, %rax          # imm = 0x30F28
movq %rax, 0x48(%rsp)
xorl %ebp, %ebp
testq %r12, %r12
je 0x16475
cmpb $0x3f, (%r12)
jne 0x16315
cmpb $0x0, 0x1(%r12)
je 0x164bf
movl 0x1b8(%rbx), %esi
cmpl %r14d, %esi
jne 0x16387
movq 0x38(%rsp), %rax
movl (%rax), %edx
testl %edx, %edx
je 0x163dd
movq 0x20(%rsp), %rax
movl $0x3, (%rax)
movq 0x48(%rsp), %r13
xorl %ebp, %ebp
movslq %edx, %rcx
movslq 0x1407128(%rbx), %rax
imulq $0x340, %rax, %rax      # imm = 0x340
cmpq %rcx, %rbp
jge 0x163b3
movq (%r13,%rax), %rdi
movq -0x30f10(%r13), %rsi
callq 0x3604c
movslq 0x1407128(%rbx), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movq %rax, (%r13,%rcx)
incq %rbp
movl 0x10(%rbx), %edx
addq $0x8, %r13
jmp 0x16341
movq 0x28(%rsp), %rdi
callq 0x2d8b6
testl %eax, %eax
je 0x16421
movl 0x1b8(%rbx), %ecx
movslq %ecx, %rdx
imulq $0x340, %rdx, %rax      # imm = 0x340
movl $0x1, (%r15,%rax)
jmp 0x163f5
movl %edx, 0x18(%r15,%rax)
movq %r12, %rdi
movq 0x30(%rsp), %rsi
callq 0x35f17
cltq
movl $0x1, 0x1407140(%rbx,%rax,4)
movl 0x1b8(%rbx), %ecx
movslq %ecx, %rdx
jmp 0x163f0
movq 0x20(%rsp), %rax
movl $0x4, (%rax)
movq 0x40(%rsp), %rdx
movl %r14d, %ecx
pushq $0x1
popq %rax
movl %eax, %ebp
imulq $0x340, %rdx, %rax      # imm = 0x340
movl $0x1, 0x1c(%r15,%rax)
incl %ecx
movl %ecx, 0x1b8(%rbx)
xorl %edi, %edi
movq 0x10(%rsp), %rsi
callq 0x4280
movq %rax, %r12
jmp 0x162f9
movq %r12, %rdi
callq 0x356ca
movl 0x1b8(%rbx), %ecx
movslq %ecx, %rdx
imulq $0x340, %rdx, %rsi      # imm = 0x340
addq %r15, %rsi
testl %eax, %eax
je 0x16445
andl $0x0, (%rsi)
jmp 0x163f5
movl $0x2, (%rsi)
jmp 0x163f5
leaq 0x80aad(%rip), %rdi     # 0x96f01
xorl %ebp, %ebp
movq %r15, %rsi
xorl %eax, %eax
callq 0x4030
movq %rbx, %rdi
callq 0x12723
movq %r15, %rdi
callq 0x34ff7
jmp 0x16532
testl %ebp, %ebp
je 0x16505
movl 0x1b8(%rbx), %eax
cmpl $0x1, %eax
jg 0x164da
movq %rbx, %rdi
callq 0x12723
movq 0x8(%rsp), %rdi
callq 0x34ff7
leaq 0x8113c(%rip), %rdi     # 0x975dd
jmp 0x1652b
movq %rbx, %rdi
callq 0x12723
movq %r15, %rdi
callq 0x34ff7
leaq 0x810bc(%rip), %rdi     # 0x97579
jmp 0x1652b
movq %rbx, %rdi
callq 0x12723
movq 0x8(%rsp), %rdi
callq 0x34ff7
leaq 0x81137(%rip), %rdi     # 0x9760f
jmp 0x1652b
cmpl $0x61a8, %eax           # imm = 0x61A8
jbe 0x16546
movq %rbx, %rdi
callq 0x12723
movq 0x8(%rsp), %rdi
callq 0x34ff7
movl 0x1b8(%rbx), %esi
leaq 0x80a99(%rip), %rdi     # 0x96f99
jmp 0x1623e
cmpl $-0x1, 0x1407128(%rbx)
je 0x1647d
movq %rbx, %rdi
callq 0x12723
movq 0x8(%rsp), %rdi
callq 0x34ff7
leaq 0x8107e(%rip), %rdi     # 0x975a9
callq 0x4090
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x7a178, %rsp          # imm = 0x7A178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rbp
movq 0x18(%rsp), %r12
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r12, %rdx
callq 0x4120
testq %rax, %rax
je 0x16695
movq %r14, %rdi
callq 0x4190
cmpq $0x2, %rax
jb 0x16553
movb $0x0, -0x1(%rax,%r14)
incl 0x1407120(%rbx)
movq %r14, %rdi
movq 0x10(%rsp), %rsi
callq 0x4280
movq %rax, %r12
movq %r15, %r13
movl %ebp, %r14d
testq %r12, %r12
je 0x1661c
cmpb $0x3f, (%r12)
jne 0x165b0
cmpb $0x0, 0x1(%r12)
je 0x16601
movl (%r13), %eax
cmpl $0x3, %eax
je 0x165df
testl %eax, %eax
jne 0x16601
movq %r12, %rdi
callq 0x356ca
testl %eax, %eax
jne 0x16601
movq %r12, %rdi
callq 0x3567d
testl %eax, %eax
je 0x16601
movl $0x2, (%r13)
jmp 0x16601
movq 0x38(%rsp), %rax
movl (%rax), %edx
movq %r12, %rdi
movq 0x30(%rsp), %rsi
callq 0x35f17
cmpl $-0x1, %eax
je 0x1666a
cltq
incl 0x1407140(%rbx,%rax,4)
xorl %edi, %edi
movq 0x10(%rsp), %rsi
callq 0x4280
movq %rax, %r12
incl %r14d
addq $0x340, %r13            # imm = 0x340
jmp 0x1659c
subl 0x1b8(%rbx), %r14d
cmpl $0x1, %r14d
movq 0x18(%rsp), %r12
leaq 0x50(%rsp), %r14
je 0x16553
movq %rbx, %rdi
callq 0x12723
movq 0x8(%rsp), %rdi
callq 0x34ff7
movl 0x1407120(%rbx), %esi
movl 0x1b8(%rbx), %edx
leaq 0x8096b(%rip), %rdi     # 0x96fc7
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x4030
jmp 0x16532
movl 0x1407120(%rbx), %esi
leaq 0x808e5(%rip), %rdi     # 0x96f5c
xorl %ebp, %ebp
movl %r14d, %edx
xorl %eax, %eax
callq 0x4030
movq %rbx, %rdi
callq 0x12723
movq 0x8(%rsp), %rdi
jmp 0x1646b
movslq 0x1b8(%rbx), %rax
movl %eax, 0x1bc(%rbx)
xorl %ecx, %ecx
movq 0x8(%rsp), %r14
cmpq %rax, %rcx
jge 0x166be
movl $0x1, 0x1c4(%rbx,%rcx,4)
incq %rcx
jmp 0x166a9
movq %r12, %rdi
callq 0x42a0
andl $0x0, (%rbx)
movq %rbx, %rdi
callq 0x145cf
leaq 0x80fc4(%rip), %rdi     # 0x9769c
callq 0x4090
movq %r14, %rdi
callq 0x34ff7
movq 0x28(%rsp), %rdi
callq 0x2d888
pushq $0x1
popq %rbp
jmp 0x16532