// File: /workspace/github_c_makefile_star2_O3/markpeerdeman[P]mbemm/src/general/elements.c
// Function: element_dll
element element_dll( element thedll, const int command, const int label )
{ element thecopy;
  int found=0;
  /* make a copy of the incoming element for certain commands: */
  if ( (command==APPEND)||(command==NEW) ) thecopy = newelement();
    switch(command) {
    case START:  { while(thedll->PREV!=(element)NULL) thedll=thedll->PREV;
                   thedll=thedll->NEXT;
		   return thedll;
		 }
	case END:    { while((thedll!=(element)NULL)&&
	               (thedll->NEXT!=(element)NULL)) thedll=thedll->NEXT;
		           return thedll;
		 }
    case SEARCH: { thedll=element_dll(thedll,START,0);
		   while((thedll->label!=label)&&(thedll->NEXT!=(element)NULL))
			 thedll=thedll->NEXT;
		   if (thedll->label==label) return thedll;
		   else
		   {   evaluate_level(YELLOW,71); 
		       return (element)NULL;
		   }
		 }
	case SEARCHNODE:
		 { thedll=element_dll(thedll,START,0);
		   found=0;
		   while((found==0)&&(thedll->NEXT!=(element)NULL))
			 { thedll=thedll->NEXT;
			   if (label==thedll->p1) found=1;
			   if (label==thedll->p2) found=1;
			   if (label==thedll->p3) found=1;
			 }
		   if (found==0) return (element)NULL; else return thedll;
		 }
	case APPEND: { thedll = element_dll(thedll,END,0);
		   thedll->NEXT=thecopy;
		   thecopy->NEXT=(element)NULL;
		   thecopy->PREV=thedll;
		   return thecopy;
		 }
	case NEW:    { thecopy->PREV=(element)NULL;
		   thecopy->NEXT=(element)NULL;
		   return thecopy;
		 }
	case KILL:   { thedll=element_dll(thedll,END,0);
		   while(thedll->PREV!=(element)NULL)
		   { thedll=thedll->PREV;
			 myfree(thedll->NEXT);
		   }
		   myfree(thedll);
		   return (element)NULL;
		 }
	default:     { evaluate_level(YELLOW,72);
		 }
  } /* switch */
return (element)NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %r14
leal -0x3(%r15), %ecx
cmpl $0x1, %ecx
ja 0xb58b
callq 0xb52c
cmpl $0x6, %r15d
ja 0xb68f
movl %r15d, %ecx
leaq 0x3fe1(%rip), %rdx      # 0xf580
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq %r14, %rax
movq (%r14), %r14
testq %r14, %r14
jne 0xb5a8
movq 0x8(%rax), %rax
jmp 0xb6a0
movq %r14, %rax
movq (%r14), %r14
testq %r14, %r14
jne 0xb5bc
movq 0x8(%rax), %rax
cmpl %ebx, 0x14(%rax)
je 0xb6a0
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0xb5cb
movl $0x1, %edi
movl $0x47, %esi
jmp 0xb699
movq %r14, %rax
movq (%r14), %r14
testq %r14, %r14
jne 0xb5ec
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0xb69e
cmpl %ebx, 0x20(%rax)
je 0xb6a0
cmpl %ebx, 0x1c(%rax)
je 0xb6a0
cmpl %ebx, 0x18(%rax)
jne 0xb5fb
jmp 0xb6a0
movq %r14, %rcx
testq %r14, %r14
je 0xb632
movq 0x8(%rcx), %r14
testq %r14, %r14
jne 0xb621
movq %rax, 0x8(%rcx)
movq $0x0, 0x8(%rax)
movq %rcx, (%rax)
jmp 0xb6a0
testq %r14, %r14
je 0xb69e
movq %r14, %rax
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0xb643
jmp 0xb6a0
movq %r14, %rbx
testq %r14, %r14
je 0xb675
movq 0x8(%rbx), %r14
testq %r14, %r14
jne 0xb656
jmp 0xb675
movq %rax, %rbx
movq 0x8(%rax), %rdi
callq 0xcbb0
movq (%rbx), %rax
testq %rax, %rax
jne 0xb669
movq %rbx, %rdi
callq 0xcbb0
jmp 0xb69e
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
jmp 0xb6a0
movl $0x1, %edi
movl $0x48, %esi
callq 0xb980
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq