// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/instancelist.c
// Function: create_instancelist_from_rules
Instanceptr create_instancelist_from_rules(Decisionconditionptr rules, int count, Instanceptr* list)
{
 /*!Last Changed 09.04.2003*/
 int i, found, featureindex;
 double value, datavalue;
 char comparison;
 Instanceptr result = NULL, tmp = (*list), last = NULL, next, tmpbefore = NULL;
 while (tmp)
  {
   found = 0;
   for (i = 0; i < count; i++)
    {
     featureindex = rules[i].featureindex;
     value = rules[i].value;
     comparison = rules[i].comparison;
     switch (current_dataset->features[featureindex].type)
      {
       case INTEGER:datavalue = tmp->values[featureindex].intvalue;
                    if (comparison=='<' && datavalue>value)
                      found = 1;
                    if (comparison=='>' && datavalue<=value)
                      found = 1;
                    break;
       case    REAL:datavalue = tmp->values[featureindex].floatvalue;
                    if (comparison=='<' && datavalue>value)
                      found = 1;
                    if (comparison=='>' && datavalue<=value)
                      found = 1;
                    break;
       case  STRING:if (tmp->values[featureindex].stringindex != value)
                      found = 1;
                    break;
      }
     if (found)
       break;
    }
   next = tmp->next;
   if (!found)
    {
     if (last)
       last -> next = tmp;
     else
       result = tmp;
     last = tmp;
    }
   else
    {
     if (tmpbefore)
       tmpbefore -> next = tmp;
     else
       (*list) = tmp;
     tmpbefore = tmp;
    }
   tmp = next;
  }
 if (last)
   last -> next = NULL;
 if (!tmpbefore)
   (*list) = NULL;
 else
   tmpbefore -> next = NULL;   
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq (%rdx), %rbx
testq %rbx, %rbx
je 0x31331
movl %esi, %eax
imulq $0x70, %rax, %r8
xorl %ecx, %ecx
leaq 0xa4640(%rip), %r9      # 0xd5870
movl $0x30f08, %r10d         # imm = 0x30F08
xorl %r11d, %r11d
xorl %eax, %eax
testl %esi, %esi
jle 0x312d9
movq (%r9), %r14
addq %r10, %r14
xorl %r15d, %r15d
movslq (%rdi,%r15), %r12
movsd 0x8(%rdi,%r15), %xmm0
movb 0x4(%rdi,%r15), %bpl
imulq $0x340, %r12, %r13      # imm = 0x340
movl (%r14,%r13), %r13d
cmpl $0x2, %r13d
je 0x3129e
cmpl $0x1, %r13d
je 0x31287
testl %r13d, %r13d
jne 0x312cc
movq (%rbx), %r13
xorps %xmm1, %xmm1
cvtsi2sdl (%r13,%r12,8), %xmm1
jmp 0x312a8
movq (%rbx), %r13
xorps %xmm1, %xmm1
cvtsi2sdl (%r13,%r12,8), %xmm1
ucomisd %xmm1, %xmm0
jne 0x312ee
jnp 0x312cc
jmp 0x312ee
movq (%rbx), %r13
movsd (%r13,%r12,8), %xmm1
cmpb $0x3c, %bpl
sete %r13b
ucomisd %xmm0, %xmm1
seta %r12b
andb %r13b, %r12b
cmpb $0x3e, %bpl
jne 0x312c7
ucomisd %xmm1, %xmm0
jae 0x312ee
testb %r12b, %r12b
jne 0x312ee
addq $0x70, %r15
cmpq %r15, %r8
jne 0x3124c
movq 0x10(%rbx), %r14
testq %r11, %r11
je 0x31305
addq $0x10, %r11
movq %r11, %r15
movq %rbx, %r11
jmp 0x31300
movq 0x10(%rbx), %r14
leaq 0x10(%rcx), %r15
testq %rcx, %rcx
cmoveq %rdx, %r15
movq %rbx, %rcx
movq %rbx, (%r15)
jmp 0x3130b
movq %rbx, %rax
movq %rbx, %r11
movq %r14, %rbx
testq %r14, %r14
jne 0x3123b
testq %r11, %r11
je 0x31324
movq $0x0, 0x10(%r11)
leaq 0x10(%rcx), %rsi
testq %rcx, %rcx
cmovneq %rsi, %rdx
jmp 0x31333
xorl %eax, %eax
movq $0x0, (%rdx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq