// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/dataset.c
// Function: create_kernel_dataset
int create_kernel_dataset(char* datasetname, char* classes, char* directoryname, char* datafilename, char* kernelfilename)
{
 Datasetptr tmp;
 int i, j, classcode;
 char* fname, *st, myline[READLINELENGTH];
 FILE* infile;
 tmp = search_dataset(Datasets, datasetname);
 if (tmp)
  {
   printf(m1120);
   delete_dataset(datasetname);
  }
 tmp = empty_dataset(datasetname, directoryname, datafilename, ' ');
 tmp->storetype = STORE_KERNEL;
 stringlist(kernelfilename, ";", tmp->kernelfiles, &(tmp->kernelcount));
 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;
  }
 fname = dataset_file_name(tmp);
 infile = fopen(fname, "r");
 if (!infile)
  {
   printf(m1121, fname);
   free_dataset(tmp);
   safe_free(fname);
   return 0;
  }
 j = 0;
 while (fgets(myline, READLINELENGTH, infile))
  {
   if (strlen(myline) <= 1)
     continue;
   myline[strlen(myline) - 1] = '\0';
   st = strtok(myline, " ");
   i = 0;
   while (st)
    {
     if (i == 0 && atoi(st) != j)
      {
       printf(m1475, j + 1);
       free_dataset(tmp);
       safe_free(fname);
       return 0;
      }
     if (i == 1 && tmp->classno)
      {
       classcode = listindex(st, tmp->classes, tmp->classno);
       if (classcode == -1)
        {
         printf(m1260, j, 1);
         free_dataset(tmp);
         safe_free(fname);
         return 0;
        }
       tmp->classcounts[classcode]++;
      }
     i++;
     st = strtok(NULL, " ");
    }
   j++;
  }
 fclose(infile);
 tmp->datacount = j;
 tmp->active = NO;
 tmp->classdefno = 1;
 tmp->featurecount = 2;
 tmp->features[0].type = REAL;
 tmp->features[0].min.floatvalue = 0.0;
 tmp->features[0].max.floatvalue = tmp->datacount - 1.0;
 if (tmp->classno)
  {
   tmp->features[1].type = CLASSDEF;
   for (i = 0; i < tmp->classno; i++)
     tmp->features[1].strings[i] = strcopy(tmp->features[1].strings[i], tmp->classes[i]);
   tmp->features[1].valuecount = tmp->classno;
  }
 else
   tmp->features[1].type = REGDEF;
 add_dataset(tmp);
 tmp->kernel = NULL;
 printf(m1126);
 safe_free(fname);
 return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a138, %rsp          # imm = 0x7A138
movq %r8, %r15
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r13
leaq 0xb7e55(%rip), %rax     # 0xcd878
movq (%rax), %rdi
movq %r13, %rsi
callq 0x13da6
testq %rax, %rax
je 0x15a47
leaq 0x81bff(%rip), %rdi     # 0x97639
callq 0x4090
movq %r13, %rdi
callq 0x15cdf
pushq $0x20
popq %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1434b
movq %rax, %rbx
movl $0x3, 0x140713c(%rax)
leaq 0x1407218(%rax), %rdx
leaq 0x1407268(%rax), %rcx
leaq 0x82ff4(%rip), %rsi     # 0x98a6e
movq %r15, %rdi
callq 0x36077
movl $0x501c50, %eax         # imm = 0x501C50
cmpq $0x501c82, %rax         # imm = 0x501C82
je 0x15a98
andl $0x0, (%rbx,%rax,4)
incq %rax
jmp 0x15a87
leaq 0x18(%rbx), %rdx
movq %rbx, %r12
addq $0x10, %r12
leaq 0x82fc4(%rip), %rsi     # 0x98a6e
movq %r14, %rdi
movq %rdx, 0x8(%rsp)
movq %r12, %rcx
callq 0x36077
movl 0x10(%rbx), %esi
cmpl $0x33, %esi
jl 0x15ad7
leaq 0x8140d(%rip), %rdi     # 0x96ed6
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x4030
jmp 0x15ccb
movq %rbx, %rdi
callq 0x14f75
movq %rax, %r15
leaq 0x85d96(%rip), %rsi     # 0x9b87f
movq %rax, %rdi
callq 0x40f0
testq %rax, %rax
je 0x15c31
movq %rax, %rbp
xorl %r13d, %r13d
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rbp, %rdx
callq 0x4120
testq %rax, %rax
je 0x15bb0
movq %r14, %rdi
callq 0x4190
cmpq $0x2, %rax
jb 0x15b05
movq %r15, (%rsp)
movb $0x0, -0x1(%rax,%r14)
movq %r14, %rdi
leaq 0x82b25(%rip), %rsi     # 0x98665
callq 0x4280
xorl %r15d, %r15d
testq %rax, %rax
je 0x15ba4
cmpl $0x1, %r15d
je 0x15b6a
testl %r15d, %r15d
jne 0x15b91
movq %rax, %rdi
callq 0x4200
cmpl %r13d, %eax
je 0x15b91
jmp 0x15c8c
movl (%r12), %edx
testl %edx, %edx
je 0x15b91
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x35f17
cmpl $-0x1, %eax
je 0x15ca4
cltq
incl 0x1407140(%rbx,%rax,4)
incl %r15d
xorl %edi, %edi
leaq 0x82ac8(%rip), %rsi     # 0x98665
callq 0x4280
jmp 0x15b48
incl %r13d
movq (%rsp), %r15
jmp 0x15b05
movq %rbp, %rdi
callq 0x42a0
movl %r13d, 0x1407120(%rbx)
andl $0x0, (%rbx)
movl $0x1, 0x1407128(%rbx)
pushq $0x2
popq %rax
movl %eax, 0x1bc(%rbx)
movl %eax, 0x30f08(%rbx)
andq $0x0, 0x30f10(%rbx)
decl %r13d
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x30f18(%rbx)
movl 0x10(%rbx), %eax
testl %eax, %eax
je 0x15c59
movl $0x3, 0x31248(%rbx)
xorl %r14d, %r14d
movslq %eax, %rcx
cmpq %rcx, %r14
jge 0x15c51
movq 0x31268(%rbx,%r14,8), %rdi
movq 0x18(%rbx,%r14,8), %rsi
callq 0x3604c
movq %rax, 0x31268(%rbx,%r14,8)
incq %r14
movl 0x10(%rbx), %eax
jmp 0x15c07
leaq 0x812c9(%rip), %rdi     # 0x96f01
xorl %ebp, %ebp
movq %r15, %rsi
xorl %eax, %eax
callq 0x4030
movq %rbx, %rdi
callq 0x12723
movq %r15, %rdi
jmp 0x15cc6
movl %eax, 0x31260(%rbx)
jmp 0x15c63
movl $0x4, 0x31248(%rbx)
movq %rbx, %rdi
callq 0x145cf
andq $0x0, 0x1407210(%rbx)
leaq 0x81a22(%rip), %rdi     # 0x9769c
callq 0x4090
movq %r15, %rdi
callq 0x34ff7
pushq $0x1
popq %rbp
jmp 0x15ccb
incl %r13d
leaq 0x81289(%rip), %rdi     # 0x96f1f
xorl %ebp, %ebp
movl %r13d, %esi
xorl %eax, %eax
callq 0x4030
jmp 0x15cba
leaq 0x812b1(%rip), %rdi     # 0x96f5c
xorl %ebp, %ebp
pushq $0x1
popq %rdx
movl %r13d, %esi
xorl %eax, %eax
callq 0x4030
movq %rbx, %rdi
callq 0x12723
movq (%rsp), %rdi
callq 0x34ff7
movl %ebp, %eax
addq $0x7a138, %rsp          # imm = 0x7A138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq