// File: /workspace/github_c_makefile_star2_O1/josch[P]stride/sheet.c
// Function: Bridge
void Bridge(char *Asn1, char *Asn2, CHAIN **Chain, int Cn1, int Cn2, PATTERN **Pat, int NPat)
{

  register int i;
  int B_Res;
  
  for( i=0; i<NPat; i++ ) {
    if( Pat[i]->Nei1 != NULL || Pat[i]->Nei2 != NULL ) continue;

    if( !strcmp(Pat[i]->Type,"1331") && 
       ( Cn1 != Cn2 || abs(Pat[i]->Hb1->Dnr->D_Res-Pat[i]->Hb1->Acc->A_Res) >= 3 ) ) {
      
      if( Pat[i]->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) {
	if( Asn1[Pat[i]->Hb1->Dnr->D_Res] == 'C' )
	  Asn1[Pat[i]->Hb1->Dnr->D_Res] = 'B';
	if( Asn2[Pat[i]->Hb1->Acc->A_Res] == 'C' )
	  Asn2[Pat[i]->Hb1->Acc->A_Res] = 'B';
      }
      else {
	if( Asn2[Pat[i]->Hb1->Dnr->D_Res] == 'C' )
	  Asn2[Pat[i]->Hb1->Dnr->D_Res] = 'B';
	if( Asn1[Pat[i]->Hb1->Acc->A_Res] == 'C' )
	  Asn1[Pat[i]->Hb1->Acc->A_Res] = 'B';
      }

    }
    else
      if( !strcmp(Pat[i]->Type,"3124") && 
	 ( Cn1 != Cn2 || 
	  (abs(Pat[i]->Hb1->Dnr->D_Res-Pat[i]->Hb1->Acc->A_Res) >= 2 &&
	   abs(Pat[i]->Hb2->Dnr->D_Res-Pat[i]->Hb2->Acc->A_Res) >= 2 ) ) ) {
      
	if( Pat[i]->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) {
	
	  if( Pat[i]->Hb1->Dnr->D_Res > Pat[i]->Hb2->Acc->A_Res )
	    B_Res = Pat[i]->Hb1->Dnr->D_Res-1;
	  else
	    B_Res = Pat[i]->Hb1->Dnr->D_Res+1;

	  if( Asn1[B_Res] == 'C' )
	    Asn1[B_Res] = 'B';

	  if( Pat[i]->Hb2->Dnr->D_Res > Pat[i]->Hb1->Acc->A_Res )
	    B_Res = Pat[i]->Hb2->Dnr->D_Res-1;
	  else
	    B_Res = Pat[i]->Hb2->Dnr->D_Res+1;

	  if( Asn2[B_Res] == 'C' )
	    Asn2[B_Res] = 'B';
	}
	else {
	  if( Pat[i]->Hb1->Dnr->D_Res > Pat[i]->Hb2->Acc->A_Res )
	    B_Res = Pat[i]->Hb1->Dnr->D_Res-1;
	  else
	    B_Res = Pat[i]->Hb1->Dnr->D_Res+1;

	  if( Asn2[B_Res] == 'C' )
	    Asn2[B_Res] = 'B';

	  if( Pat[i]->Hb2->Dnr->D_Res > Pat[i]->Hb1->Acc->A_Res )
	    B_Res = Pat[i]->Hb2->Dnr->D_Res-1;
	  else
	    B_Res = Pat[i]->Hb2->Dnr->D_Res+1;

	  if( Asn1[B_Res] == 'C' )
	    Asn1[B_Res] = 'B';
	}
      }
      else
	if( ( ( !strcmp(Pat[i]->Type,"3123") || !strcmp(Pat[i]->Type,"1341") ) &&
	     ( Cn1 != Cn2 ||
	      (abs(Pat[i]->Hb1->Dnr->D_Res-Pat[i]->Hb1->Acc->A_Res) > 3 &&
	       abs(Pat[i]->Hb2->Dnr->D_Res-Pat[i]->Hb2->Acc->A_Res) > 3 ) ) ) ) { 

	  if( Pat[i]->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) {
	  
	    if( Pat[i]->Hb1->Dnr->D_Res == Pat[i]->Hb2->Acc->A_Res ) {
	    
	      if( Asn1[Pat[i]->Hb1->Dnr->D_Res] == 'C' )
		Asn1[Pat[i]->Hb1->Dnr->D_Res] = 'B';
	    
	      if( Pat[i]->Hb2->Dnr->D_Res > Pat[i]->Hb1->Acc->A_Res )
		B_Res = Pat[i]->Hb2->Dnr->D_Res-1;
	      else
		B_Res = Pat[i]->Hb2->Dnr->D_Res+1;
	    
	      if( Asn2[B_Res] == 'C' )
		Asn2[B_Res] = 'B';
	    }
	    else {
	      if( Pat[i]->Hb2->Dnr->D_Res == Pat[i]->Hb1->Acc->A_Res )
	      
		if( Asn2[Pat[i]->Hb2->Dnr->D_Res] == 'C' )
		  Asn2[Pat[i]->Hb2->Dnr->D_Res] = 'B';
	    
	      if( Pat[i]->Hb1->Dnr->D_Res > Pat[i]->Hb2->Acc->A_Res )
		B_Res = Pat[i]->Hb1->Dnr->D_Res-1;
	      else
		B_Res = Pat[i]->Hb1->Dnr->D_Res+1;
	    
	      if( Asn1[B_Res] == 'C' )
		Asn1[B_Res] = 'B';
	    }
	  }
	}
	else
	  if( ( !strcmp(Pat[i]->Type,"13B1") || !strcmp(Pat[i]->Type,"133A") ) &&
	     ( Cn1 != Cn2 ||
	      (abs(Pat[i]->Hb1->Dnr->D_Res-Pat[i]->Hb1->Acc->A_Res) > 4 &&
	       abs(Pat[i]->Hb2->Dnr->D_Res-Pat[i]->Hb2->Acc->A_Res) > 4 ) ) ) { 

	    if( Pat[i]->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) {
	  
	      if( Pat[i]->Hb1->Dnr->D_Res == Pat[i]->Hb2->Acc->A_Res ) {
	    
		if( Asn1[Pat[i]->Hb1->Dnr->D_Res] == 'C' )
		  Asn1[Pat[i]->Hb1->Dnr->D_Res] = 'B';
	    
		if( Pat[i]->Hb2->Dnr->D_Res > Pat[i]->Hb1->Acc->A_Res )
		  B_Res = Pat[i]->Hb2->Dnr->D_Res-1;
		else
		  B_Res = Pat[i]->Hb2->Dnr->D_Res+1;
	    
		if( Asn2[B_Res] == 'C' )
		  Asn2[B_Res] = 'B';
	      }
	      else {
		if( Pat[i]->Hb2->Dnr->D_Res == Pat[i]->Hb1->Acc->A_Res )
	      
		  if( Asn2[Pat[i]->Hb2->Dnr->D_Res] == 'C' )
		    Asn2[Pat[i]->Hb2->Dnr->D_Res] = 'b';
	    
		if( Pat[i]->Hb1->Dnr->D_Res > Pat[i]->Hb2->Acc->A_Res )
		  B_Res = Pat[i]->Hb1->Dnr->D_Res-1;
		else
		  B_Res = Pat[i]->Hb1->Dnr->D_Res+1;
	    
		if( Asn1[B_Res] == 'C' )
		  Asn1[B_Res] = 'b';
	      }
	    }
	  }
    
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0x14(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, (%rsp)
movq %rdi, 0x8(%rsp)
movl 0x60(%rsp), %eax
testl %eax, %eax
jle 0x7e8f
movq %r9, %rbx
movl %ecx, %r14d
movslq %ecx, %rcx
movq %rcx, 0x18(%rsp)
movl %eax, %r12d
xorl %r13d, %r13d
movq (%rbx,%r13,8), %rbp
cmpq $0x0, 0x10(%rbp)
jne 0x7a71
cmpq $0x0, 0x18(%rbp)
je 0x7a7e
incq %r13
cmpq %r13, %r12
jne 0x7a5f
jmp 0x7e8f
leaq 0x24(%rbp), %r15
movq %r15, %rdi
leaq 0x12144(%rip), %rsi     # 0x19bd0
callq 0x2150
testl %eax, %eax
je 0x7ba5
movq %r15, %rdi
leaq 0x12132(%rip), %rsi     # 0x19bd5
callq 0x2150
testl %eax, %eax
je 0x7ce6
movq %r15, %rdi
leaq 0x12136(%rip), %rsi     # 0x19bf0
callq 0x2150
testl %eax, %eax
je 0x7ada
movq %r15, %rdi
leaq 0x12128(%rip), %rsi     # 0x19bf5
callq 0x2150
testl %eax, %eax
jne 0x7c1d
cmpl 0x14(%rsp), %r14d
jne 0x7b23
movq (%rbp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movl 0x8(%rcx), %ecx
subl 0x8(%rax), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x4, %eax
jb 0x7c1d
movq 0x8(%rbp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movl 0x8(%rcx), %ecx
subl 0x8(%rax), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x4, %eax
jb 0x7c1d
movq (%rbp), %rax
movq (%rax), %rcx
movq (%rcx), %rdx
movb 0x40(%rdx), %dl
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
movq (%rsi,%rdi,8), %rsi
cmpb 0x40(%rsi), %dl
jne 0x7a71
movslq 0x8(%rcx), %rcx
movq 0x8(%rbp), %rdx
movq 0x8(%rdx), %rsi
cmpl 0x8(%rsi), %ecx
je 0x7cc9
movq (%rdx), %rcx
movslq 0x8(%rcx), %rcx
movq 0x8(%rax), %rax
cmpl 0x8(%rax), %ecx
jne 0x7b7e
movq (%rsp), %rax
cmpb $0x43, (%rax,%rcx)
jne 0x7b7e
movq (%rsp), %rax
movb $0x42, (%rax,%rcx)
movq (%rbx,%r13,8), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movq (%rcx), %rcx
movl 0x8(%rcx), %ecx
movq 0x8(%rax), %rax
xorl %edx, %edx
cmpl 0x8(%rax), %ecx
setle %dl
leal (%rcx,%rdx,2), %eax
decl %eax
jmp 0x7e0d
cmpl 0x14(%rsp), %r14d
jne 0x7bcd
movq (%rbp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movl 0x8(%rcx), %ecx
subl 0x8(%rax), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x3, %eax
jb 0x7a99
movq (%rbp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movb 0x40(%rcx), %cl
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rsi
movq (%rdx,%rsi,8), %rdx
movslq 0x8(%rax), %rax
cmpb 0x40(%rdx), %cl
jne 0x7db6
movq 0x8(%rsp), %rcx
cmpb $0x43, (%rcx,%rax)
jne 0x7c09
movq 0x8(%rsp), %rcx
movb $0x42, (%rcx,%rax)
movq (%rbx,%r13,8), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq 0x8(%rax), %rax
jmp 0x7da2
movq %r15, %rdi
leaq 0x11fbe(%rip), %rsi     # 0x19be5
callq 0x2150
testl %eax, %eax
je 0x7c47
movq %r15, %rdi
leaq 0x11fa0(%rip), %rsi     # 0x19bda
callq 0x2150
testl %eax, %eax
jne 0x7a71
cmpl 0x14(%rsp), %r14d
jne 0x7c90
movq (%rbp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movl 0x8(%rcx), %ecx
subl 0x8(%rax), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x5, %eax
jb 0x7a71
movq 0x8(%rbp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movl 0x8(%rcx), %ecx
subl 0x8(%rax), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x5, %eax
jb 0x7a71
movq (%rbp), %rax
movq (%rax), %rcx
movq (%rcx), %rdx
movb 0x40(%rdx), %dl
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
movq (%rsi,%rdi,8), %rsi
cmpb 0x40(%rsi), %dl
jne 0x7a71
movslq 0x8(%rcx), %rcx
movq 0x8(%rbp), %rdx
movq 0x8(%rdx), %rsi
cmpl 0x8(%rsi), %ecx
jne 0x7e2c
movq 0x8(%rsp), %rax
cmpb $0x43, (%rax,%rcx)
jne 0x7d7e
movq 0x8(%rsp), %rax
movb $0x42, (%rax,%rcx)
jmp 0x7d7e
cmpl 0x14(%rsp), %r14d
jne 0x7d2f
movq (%rbp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movl 0x8(%rcx), %ecx
subl 0x8(%rax), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x2, %eax
jb 0x7ab0
movq 0x8(%rbp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movl 0x8(%rcx), %ecx
subl 0x8(%rax), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x2, %eax
jb 0x7ab0
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
movq (%rax), %rax
movq (%rax), %rdx
movb 0x40(%rdx), %dl
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
movq (%rsi,%rdi,8), %rsi
movl 0x8(%rax), %eax
movq 0x8(%rcx), %rcx
xorl %edi, %edi
cmpl 0x8(%rcx), %eax
setle %dil
leal (%rax,%rdi,2), %eax
decl %eax
cltq
cmpb 0x40(%rsi), %dl
jne 0x7dd9
movq 0x8(%rsp), %rcx
cmpb $0x43, (%rcx,%rax)
jne 0x7d7e
movq 0x8(%rsp), %rcx
movb $0x42, (%rcx,%rax)
movq (%rbx,%r13,8), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
movq 0x8(%rcx), %rcx
xorl %edx, %edx
cmpl 0x8(%rcx), %eax
setle %dl
leal (%rax,%rdx,2), %eax
decl %eax
cltq
movq (%rsp), %rcx
cmpb $0x43, (%rcx,%rax)
jne 0x7a71
movq (%rsp), %rcx
jmp 0x7e23
movq (%rsp), %rcx
cmpb $0x43, (%rcx,%rax)
jne 0x7dc8
movq (%rsp), %rcx
movb $0x42, (%rcx,%rax)
movq (%rbx,%r13,8), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq 0x8(%rax), %rax
jmp 0x7e0f
movq (%rsp), %rcx
cmpb $0x43, (%rcx,%rax)
jne 0x7deb
movq (%rsp), %rcx
movb $0x42, (%rcx,%rax)
movq (%rbx,%r13,8), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
movq 0x8(%rcx), %rcx
xorl %edx, %edx
cmpl 0x8(%rcx), %eax
setle %dl
leal (%rax,%rdx,2), %eax
decl %eax
cltq
movq 0x8(%rsp), %rcx
cmpb $0x43, (%rcx,%rax)
jne 0x7a71
movq 0x8(%rsp), %rcx
movb $0x42, (%rcx,%rax)
jmp 0x7a71
movq (%rdx), %rcx
movslq 0x8(%rcx), %rcx
movq 0x8(%rax), %rax
cmpl 0x8(%rax), %ecx
jne 0x7e4e
movq (%rsp), %rax
cmpb $0x43, (%rax,%rcx)
jne 0x7e4e
movq (%rsp), %rax
movb $0x62, (%rax,%rcx)
movq (%rbx,%r13,8), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movq (%rcx), %rcx
movl 0x8(%rcx), %ecx
movq 0x8(%rax), %rax
xorl %edx, %edx
cmpl 0x8(%rax), %ecx
setle %dl
leal (%rcx,%rdx,2), %eax
decl %eax
cltq
movq 0x8(%rsp), %rcx
cmpb $0x43, (%rcx,%rax)
jne 0x7a71
movq 0x8(%rsp), %rcx
movb $0x62, (%rcx,%rax)
jmp 0x7a71
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop