// File: /workspace/github_c_makefile_star2_O1/josch[P]stride/fillasn.c
// Function: MakeEnds
int MakeEnds(int *Beg1, int ResBeg1, int NeiBeg1, char *Beg1Cn, char ResBeg1Cn, int *End1, 
	     int ResEnd1, int NeiEnd1, char ResEnd1Cn, int *Beg2, int ResBeg2, int NeiBeg2, 
	     char *Beg2Cn, char ResBeg2Cn, int *End2, int ResEnd2, int NeiEnd2, 
	     char ResEnd2Cn, PATTERN **Pat, int NPat)
{

  register int i;
  int Flag1 = 0, Flag2 = 0;


  if( ResBeg1 <= NeiBeg1 && NeiBeg1 <= NeiEnd1 && NeiEnd1 <= ResEnd1 &&
      ResBeg2 <= NeiBeg2 && NeiBeg2 <= NeiEnd2 && NeiEnd2 <= ResEnd2 &&
      ResBeg1Cn == ResEnd1Cn && ResBeg2Cn == ResEnd2Cn ) {

    *Beg1 = ResBeg1;
    *End1 = ResEnd1;
    *Beg2 = ResBeg2;
    *End2 = ResEnd2;
    *Beg1Cn = ResBeg1Cn;
    *Beg2Cn = ResBeg2Cn;
    
    for( i=0; i<NPat && (Flag1 == 0 || Flag2 == 0); i++ ) {
      if( ( (Pat[i]->Hb1->Dnr->D_Res == (*Beg1) 
	     && Pat[i]->Hb1->Acc->A_Res == (*End2)
	     && Pat[i]->Hb1->Dnr->Chain->Id == (*Beg1Cn)
	     && Pat[i]->Hb1->Acc->Chain->Id == (*Beg2Cn) ) 
	   ||
	   (Pat[i]->Hb1->Acc->A_Res == (*Beg1) 
	    && Pat[i]->Hb1->Dnr->D_Res == (*End2) 
	    && Pat[i]->Hb1->Acc->Chain->Id == (*Beg1Cn)
	    && Pat[i]->Hb1->Dnr->Chain->Id == (*Beg2Cn) ) ) 
	 && Pat[i]->Hb1->Dnr->D_Res == Pat[i]->Hb2->Acc->A_Res 
	 && Pat[i]->Hb2->Dnr->D_Res == Pat[i]->Hb1->Acc->A_Res )
	Flag1 = 1; 
      if( ( (Pat[i]->Hb1->Dnr->D_Res == (*Beg2) 
	     && Pat[i]->Hb1->Acc->A_Res == (*End1) 
	     && Pat[i]->Hb1->Dnr->Chain->Id == (*Beg2Cn)
	     && Pat[i]->Hb1->Acc->Chain->Id == (*Beg1Cn) ) 
	   ||
	   (Pat[i]->Hb1->Acc->A_Res == (*Beg2) 
	    && Pat[i]->Hb1->Dnr->D_Res == (*End1) 
	    && Pat[i]->Hb1->Acc->Chain->Id == (*Beg2Cn)
	    && Pat[i]->Hb1->Dnr->Chain->Id == (*Beg1Cn) ) ) 
	 && Pat[i]->Hb1->Dnr->D_Res == Pat[i]->Hb2->Acc->A_Res 
	 && Pat[i]->Hb2->Dnr->D_Res == Pat[i]->Hb1->Acc->A_Res )
	Flag2 = 1; 
    }
    
    if( !Flag1 ) {
      if( *Beg1 != NeiBeg1 ) (*Beg1)++;
      if( *End2 != NeiEnd2 ) (*End2)--;
    }
    
    if( !Flag2 ) {
      if( *End1 != NeiEnd1 ) (*End1)--;
      if( *Beg2 != NeiBeg2 ) (*Beg2)++;
    }
    return(SUCCESS);
  }
  
  return(FAILURE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movb 0x70(%rsp), %r10b
xorl %eax, %eax
cmpb 0x90(%rsp), %r10b
jne 0xd98b
cmpb 0x48(%rsp), %r8b
jne 0xd98b
movl 0x88(%rsp), %r12d
movl 0x80(%rsp), %r10d
cmpl %r10d, %r12d
jg 0xd98b
movl 0x40(%rsp), %ebp
movl 0x38(%rsp), %r11d
cmpl %r11d, %ebp
jg 0xd98b
cmpl %edx, %esi
jg 0xd98b
cmpl %ebp, %edx
jg 0xd98b
movl 0x60(%rsp), %r14d
movl 0x58(%rsp), %r15d
cmpl %r14d, %r15d
jg 0xd98b
cmpl %r12d, %r14d
jg 0xd98b
movl 0xa0(%rsp), %ebx
movl %r10d, %eax
movq 0x78(%rsp), %r10
movq 0x50(%rsp), %r13
movl %esi, (%rdi)
movl %r11d, (%r9)
movl %r15d, (%r13)
movl %eax, (%r10)
movb %r8b, (%rcx)
movb 0x70(%rsp), %sil
movq 0x68(%rsp), %rax
movb %sil, (%rax)
testl %ebx, %ebx
jle 0xd93f
movl %edx, -0x4(%rsp)
movl %ebx, %r12d
xorl %r13d, %r13d
xorl %esi, %esi
xorl %r15d, %r15d
testl %r15d, %r15d
je 0xd80a
testl %esi, %esi
jne 0xd91d
movq 0x98(%rsp), %rax
movq (%rax,%r13,8), %r10
movq (%r10), %r11
movq (%r11), %r14
movl 0x8(%r14), %ebx
movl (%rdi), %edx
cmpl %edx, %ebx
jne 0xd851
movq 0x8(%r11), %rax
movl 0x8(%rax), %ebp
movq 0x78(%rsp), %r8
cmpl (%r8), %ebp
jne 0xd851
movq (%r14), %rbp
movb 0x40(%rbp), %bpl
cmpb (%rcx), %bpl
jne 0xd851
movq (%rax), %rax
movb 0x70(%rsp), %r8b
cmpb %r8b, 0x40(%rax)
je 0xd879
movq 0x8(%r11), %rax
cmpl %edx, 0x8(%rax)
jne 0xd89c
movq 0x78(%rsp), %rdx
cmpl (%rdx), %ebx
jne 0xd89c
movq (%rax), %rax
movb 0x40(%rax), %al
cmpb (%rcx), %al
jne 0xd89c
movq (%r14), %rax
movb 0x70(%rsp), %dl
cmpb %dl, 0x40(%rax)
jne 0xd89c
movq 0x8(%r10), %rax
movq 0x8(%rax), %rdx
cmpl 0x8(%rdx), %ebx
jne 0xd89c
movq (%rax), %rax
movl 0x8(%rax), %eax
movq 0x8(%r11), %rdx
cmpl 0x8(%rdx), %eax
movl $0x1, %eax
cmovel %eax, %r15d
movq 0x50(%rsp), %rax
movl (%rax), %edx
cmpl %edx, %ebx
jne 0xd8cb
movq 0x8(%r11), %rax
movl 0x8(%rax), %ebp
cmpl (%r9), %ebp
jne 0xd8cb
movq (%r14), %rbp
movb 0x70(%rsp), %r8b
cmpb %r8b, 0x40(%rbp)
jne 0xd8cb
movq (%rax), %rax
movb 0x40(%rax), %al
cmpb (%rcx), %al
je 0xd8ef
movq 0x8(%r11), %rax
cmpl %edx, 0x8(%rax)
jne 0xd911
cmpl (%r9), %ebx
jne 0xd911
movq (%rax), %rax
movb 0x70(%rsp), %dl
cmpb %dl, 0x40(%rax)
jne 0xd911
movq (%r14), %rax
movb 0x40(%rax), %al
cmpb (%rcx), %al
jne 0xd911
movq 0x8(%r10), %rax
movq 0x8(%rax), %rdx
cmpl 0x8(%rdx), %ebx
jne 0xd911
movq (%rax), %rax
movl 0x8(%rax), %eax
movq 0x8(%r11), %rdx
cmpl 0x8(%rdx), %eax
movl $0x1, %eax
cmovel %eax, %esi
incq %r13
cmpq %r13, %r12
jne 0xd7fd
testl %r15d, %r15d
sete %al
testl %esi, %esi
sete %cl
movl 0x40(%rsp), %ebp
movl 0x60(%rsp), %r14d
movl -0x4(%rsp), %edx
movl 0x88(%rsp), %r12d
jmp 0xd943
movb $0x1, %al
movb $0x1, %cl
testb %al, %al
je 0xd966
movl (%rdi), %eax
cmpl %edx, %eax
je 0xd951
incl %eax
movl %eax, (%rdi)
movq 0x78(%rsp), %rax
movl (%rax), %eax
cmpl %r12d, %eax
je 0xd966
decl %eax
movq 0x78(%rsp), %rdx
movl %eax, (%rdx)
movl $0x1, %eax
testb %cl, %cl
je 0xd98b
movl (%r9), %ecx
cmpl %ebp, %ecx
je 0xd97b
decl %ecx
movl %ecx, (%r9)
movq 0x50(%rsp), %rdx
movl (%rdx), %ecx
cmpl %r14d, %ecx
je 0xd98b
incl %ecx
movl %ecx, (%rdx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq