// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/dataset.c
// Function: dimension_reduced_dataset
Datasetptr dimension_reduced_dataset(Datasetptr d, int dimension, Instanceptr reduceddata, char* datasetname)
{
 /*dimension includes the class definition feature*/
 Datasetptr newdataset;
 int i;
 newdataset = empty_dataset(datasetname, datasetname, "dataset.txt", ' ');
 if (d->classdefno == -1)
   dimension--;
 newdataset->allfeatures = dimension;
 newdataset->featurecount = dimension;
 newdataset->multifeaturecount = dimension;
 for (i = 0; i < dimension; i++)
  {
   newdataset->availability[i] = YES;
   newdataset->features[i].selected = YES;
  }
 if (d->classdefno != -1)
   newdataset->classdefno = newdataset->newclassdefno = dimension - 1;
 else
   newdataset->classdefno = newdataset->newclassdefno = -1;
 newdataset->classno = d->classno;
 for (i = 0; i < d->classno; i++)
   newdataset->classes[i] = strcopy(newdataset->classes[i], d->classes[i]);
 if (d->classdefno == -1)
   dimension++;
 for (i = 0; i < dimension - 1; i++)
  {
   newdataset->features[i].type = REAL;
   newdataset->features[i].oldtype = REAL;
   find_bounds_of_feature(newdataset, reduceddata, i, &(newdataset->features[i].min.floatvalue), &(newdataset->features[i].max.floatvalue));
   newdataset->features[i].valuecount = 0;
  }
 if (d->classdefno != -1)
  {
   newdataset->features[dimension - 1].type = CLASSDEF; 
   newdataset->features[dimension - 1].oldtype = CLASSDEF; 
   newdataset->features[dimension - 1].valuecount = d->classno;
   for (i = 0; i < d->classno; i++)
     if (d->classdefno == d->newclassdefno)
       newdataset->features[dimension - 1].strings[i] = strcopy(newdataset->features[dimension - 1].strings[i], d->features[d->classdefno].strings[i]);
     else
       newdataset->features[dimension - 1].strings[i] = strcopy(newdataset->features[dimension - 1].strings[i], d->features[d->newclassdefno].strings[i]);
  }
 newdataset->traincount = d->traincount;
 newdataset->datacount = d->datacount;
 for (i = 0; i < d->classno; i++)
   newdataset->classcounts[i] = d->classcounts[i];
 return newdataset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x8e4f2(%rip), %rdx     # 0xa3864
movq %rcx, %rdi
movq %rcx, %rsi
movl $0x20, %ecx
callq 0x15559
movq %rax, %r14
xorl %eax, %eax
cmpl $-0x1, 0x1407128(%rbx)
sete %al
subl %eax, %r12d
movl %r12d, 0x1b8(%r14)
movl %r12d, 0x1bc(%r14)
movl %r12d, 0x1c0(%r14)
testl %r12d, %r12d
jle 0x153d8
movl %r12d, %eax
leaq 0x30f24(%r14), %rcx
xorl %edx, %edx
movl $0x1, %esi
movl %esi, 0x1c4(%r14,%rdx,4)
movl %esi, (%rcx)
incq %rdx
addq $0x340, %rcx            # imm = 0x340
cmpq %rdx, %rax
jne 0x153bf
movq %r15, %r13
movl 0x1407128(%rbx), %eax
leal -0x1(%r12), %ecx
cmpl $-0x1, %eax
cmovel %eax, %ecx
movl %ecx, 0x1407138(%r14)
movl %ecx, 0x1407128(%r14)
movl 0x10(%rbx), %eax
movl %eax, 0x10(%r14)
cmpl $0x0, 0x10(%rbx)
jle 0x1542a
xorl %r15d, %r15d
movq 0x18(%r14,%r15,8), %rdi
movq 0x18(%rbx,%r15,8), %rsi
callq 0x3a404
movq %rax, 0x18(%r14,%r15,8)
incq %r15
movslq 0x10(%rbx), %rax
cmpq %rax, %r15
jl 0x1540a
xorl %eax, %eax
cmpl $-0x1, 0x1407128(%rbx)
sete %al
addl %r12d, %eax
decl %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
jle 0x1548f
movq %r13, %r15
leaq 0x30f08(%r14), %r13
movl 0x4(%rsp), %ebp
xorl %r12d, %r12d
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, (%r13)
leaq 0x8(%r13), %rcx
leaq 0x10(%r13), %r8
movq %r14, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x10ef3
movl $0x0, 0x18(%r13)
incq %r12
addq $0x340, %r13            # imm = 0x340
cmpq %r12, %rbp
jne 0x15454
cmpl $-0x1, 0x1407128(%rbx)
je 0x1550a
movslq 0x4(%rsp), %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movabsq $0x300000003, %rcx      # imm = 0x300000003
movq %rcx, 0x30f08(%r14,%rax)
movl 0x10(%rbx), %ecx
movl %ecx, 0x30f20(%r14,%rax)
testl %ecx, %ecx
jle 0x1550a
leaq (%r14,%rax), %r15
addq $0x30f08, %r15          # imm = 0x30F08
leaq 0x30f28(%rbx), %r12
xorl %r13d, %r13d
movslq 0x1407138(%rbx), %rax
movq 0x20(%r15,%r13,8), %rdi
imulq $0x340, %rax, %rax      # imm = 0x340
addq %r12, %rax
movq (%rax,%r13,8), %rsi
callq 0x3a404
movq %rax, 0x20(%r15,%r13,8)
incq %r13
movslq 0x10(%rbx), %rax
cmpq %rax, %r13
jl 0x154da
movl 0x1407124(%rbx), %eax
movl %eax, 0x1407124(%r14)
movl 0x1407120(%rbx), %eax
movl %eax, 0x1407120(%r14)
cmpl $0x0, 0x10(%rbx)
jle 0x15547
xorl %eax, %eax
movl 0x1407140(%rbx,%rax,4), %ecx
movl %ecx, 0x1407140(%r14,%rax,4)
incq %rax
movslq 0x10(%rbx), %rcx
cmpq %rcx, %rax
jl 0x1552c
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq