// File: /workspace/github_c_makefile_star2_O1/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, -0x8(%rsp)
movq (%rdx), %rbx
testq %rbx, %rbx
je 0x30a95
testl %esi, %esi
setg %cl
movslq %esi, %r8
movl %r8d, %r10d
addq $0x8, %rdi
negq %r10
xorl %r9d, %r9d
xorl %r11d, %r11d
movq $0x0, -0x10(%rsp)
movq %rdi, %rdx
movl %ecx, %ebp
testl %esi, %esi
jle 0x30a4f
leaq 0xa1ed2(%rip), %rax     # 0xd2870
movq (%rax), %r12
movl $0x30f08, %eax          # imm = 0x30F08
addq %rax, %r12
movl $0x1, %r13d
movq %rdx, %rdi
movl %ecx, %ebp
movslq -0x8(%rdi), %r15
movsd (%rdi), %xmm0
movb -0x4(%rdi), %al
imulq $0x340, %r15, %r14      # imm = 0x340
movl (%r12,%r14), %r14d
cmpl $0x2, %r14d
je 0x309ff
cmpl $0x1, %r14d
je 0x309e9
testl %r14d, %r14d
jne 0x30a30
movq (%rbx), %r14
xorps %xmm1, %xmm1
cvtsi2sdl (%r14,%r15,8), %xmm1
jmp 0x30a08
movq (%rbx), %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rax,%r15,8), %xmm1
ucomisd %xmm1, %xmm0
jne 0x30a4f
jnp 0x30a30
jmp 0x30a4f
movq (%rbx), %r14
movsd (%r14,%r15,8), %xmm1
cmpb $0x3c, %al
sete %r14b
ucomisd %xmm0, %xmm1
seta %r15b
andb %r14b, %r15b
cmpb $0x3e, %al
sete %r14b
ucomisd %xmm1, %xmm0
setae %al
andb %r14b, %al
orb %r15b, %al
testb %al, %al
jne 0x30a4f
cmpq %r8, %r13
setl %bpl
addq $0x70, %rdi
leaq (%r10,%r13), %rax
incq %rax
incq %r13
cmpq $0x1, %rax
jne 0x309b4
movq 0x10(%rbx), %rdi
testb $0x1, %bpl
je 0x30a6b
leaq 0x10(%r9), %rax
testq %r9, %r9
cmoveq -0x8(%rsp), %rax
movq %rbx, %r9
jmp 0x30a7a
testq %r11, %r11
je 0x30a8b
addq $0x10, %r11
movq %r11, %rax
movq %rbx, %r11
movq %rbx, (%rax)
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x3098d
jmp 0x30aa4
movq %rbx, -0x10(%rsp)
movq %rbx, %r11
jmp 0x30a7d
movq $0x0, -0x10(%rsp)
xorl %r11d, %r11d
xorl %r9d, %r9d
testq %r11, %r11
je 0x30ab1
movq $0x0, 0x10(%r11)
leaq 0x10(%r9), %rax
testq %r9, %r9
cmoveq -0x8(%rsp), %rax
movq $0x0, (%rax)
movq -0x10(%rsp), %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq