// File: /workspace/github_c_makefile_star2_O3/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, %r13
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x914a1(%rip), %rdx     # 0xa68a8
movq %rcx, %rdi
movq %rcx, %rsi
movl $0x20, %ecx
callq 0x155f1
movq %rax, %r14
movl 0x1407128(%rbx), %eax
xorl %ecx, %ecx
cmpl $-0x1, %eax
sete %cl
subl %ecx, %r12d
movl %r12d, 0x1b8(%r14)
movl %r12d, 0x1bc(%r14)
movl %r12d, 0x1c0(%r14)
testl %r12d, %r12d
jle 0x15475
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 0x15456
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)
testl %eax, %eax
jle 0x154bc
xorl %r15d, %r15d
movq 0x18(%r14,%r15,8), %rdi
movq 0x18(%rbx,%r15,8), %rsi
callq 0x3b494
movq %rax, 0x18(%r14,%r15,8)
incq %r15
movslq 0x10(%rbx), %rax
cmpq %rax, %r15
jl 0x1549c
movl 0x1407128(%rbx), %ecx
xorl %edx, %edx
cmpl $-0x1, %ecx
sete %dl
addl %r12d, %edx
decl %edx
testl %edx, %edx
jle 0x1552e
movq %r13, %r15
leaq 0x30f08(%r14), %r13
movl %edx, 0x4(%rsp)
movl %edx, %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 0x10ecf
movl $0x0, 0x18(%r13)
incq %r12
addq $0x340, %r13            # imm = 0x340
cmpq %r12, %rbp
jne 0x154e6
movl 0x1407128(%rbx), %ecx
movl 0x10(%rbx), %eax
movl 0x4(%rsp), %edx
cmpl $-0x1, %ecx
je 0x155a0
movslq %edx, %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movabsq $0x300000003, %rdx      # imm = 0x300000003
movq %rdx, 0x30f08(%r14,%rcx)
movl %eax, 0x30f20(%r14,%rcx)
testl %eax, %eax
jle 0x155d1
leaq (%r14,%rcx), %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 0x3b494
movq %rax, 0x20(%r15,%r13,8)
incq %r13
movslq 0x10(%rbx), %rax
cmpq %rax, %r13
jl 0x15570
movq 0x1407120(%rbx), %rcx
movq %rcx, 0x1407120(%r14)
testl %eax, %eax
jle 0x155df
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 0x155b4
jmp 0x155df
movq 0x1407120(%rbx), %rax
movq %rax, 0x1407120(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq