// File: /workspace/github_c_makefile_star2_O2/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
movq %r9, %rbx
movl %r8d, 0x14(%rsp)
movl %ecx, %r14d
movq %rdx, 0x20(%rsp)
movq %rsi, (%rsp)
movq %rdi, 0x8(%rsp)
movl 0x60(%rsp), %r12d
movslq %ecx, %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
testl %r12d, %r12d
cmovlel %r13d, %r12d
cmpq %r13, %r12
je 0x72d6
movq (%rbx,%r13,8), %rbp
cmpq $0x0, 0x10(%rbp)
jne 0x6ec3
cmpq $0x0, 0x18(%rbp)
je 0x6ec8
incq %r13
jmp 0x6ea8
leaq 0x24(%rbp), %r15
movq %r15, %rdi
leaq 0x11d0a(%rip), %rsi     # 0x18be0
callq 0x2150
testl %eax, %eax
je 0x6feb
movq %r15, %rdi
leaq 0x11cf8(%rip), %rsi     # 0x18be5
callq 0x2150
testl %eax, %eax
je 0x712c
movq %r15, %rdi
leaq 0x11cfc(%rip), %rsi     # 0x18c00
callq 0x2150
testl %eax, %eax
je 0x6f24
movq %r15, %rdi
leaq 0x11cee(%rip), %rsi     # 0x18c05
callq 0x2150
testl %eax, %eax
jne 0x705c
movq (%rbp), %rax
movq (%rax), %rcx
cmpl 0x14(%rsp), %r14d
jne 0x6f6d
movl 0x8(%rcx), %edx
movq 0x8(%rax), %rsi
subl 0x8(%rsi), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x4, %esi
jb 0x705c
movq 0x8(%rbp), %rdx
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
movl 0x8(%rsi), %esi
subl 0x8(%rdx), %esi
movl %esi, %edx
negl %edx
cmovsl %esi, %edx
cmpl $0x4, %edx
jb 0x705c
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 0x6ec3
movl 0x8(%rcx), %ecx
movq 0x8(%rbp), %rsi
movq 0x8(%rsi), %rdx
movl 0x8(%rdx), %edx
cmpl %edx, %ecx
je 0x7102
movq (%rsi), %rsi
movslq 0x8(%rsi), %rsi
movq 0x8(%rax), %rax
cmpl 0x8(%rax), %esi
jne 0x6fda
movq (%rsp), %rax
cmpb $0x43, (%rax,%rsi)
jne 0x6fda
movq (%rsp), %rax
movb $0x42, (%rax,%rsi)
movq (%rbx,%r13,8), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movq (%rcx), %rcx
movl 0x8(%rcx), %ecx
movq 0x8(%rax), %rax
movl 0x8(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
setle %al
leal (%rcx,%rax,2), %eax
decl %eax
jmp 0x7252
movq (%rbp), %rax
movq (%rax), %rcx
cmpl 0x14(%rsp), %r14d
jne 0x7013
movl 0x8(%rcx), %edx
movq 0x8(%rax), %rsi
subl 0x8(%rsi), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x3, %esi
jb 0x6ee3
movq (%rcx), %rdx
movb 0x40(%rdx), %dl
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
movq (%rsi,%rdi,8), %rsi
movslq 0x8(%rcx), %rcx
cmpb 0x40(%rsi), %dl
jne 0x71fb
movq 0x8(%rsp), %rdx
cmpb $0x43, (%rdx,%rcx)
jne 0x704f
movq 0x8(%rsp), %rax
movb $0x42, (%rax,%rcx)
movq (%rbx,%r13,8), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq 0x8(%rax), %rax
jmp 0x71e7
movq %r15, %rdi
leaq 0x11b8f(%rip), %rsi     # 0x18bf5
callq 0x2150
testl %eax, %eax
je 0x7086
movq %r15, %rdi
leaq 0x11b71(%rip), %rsi     # 0x18bea
callq 0x2150
testl %eax, %eax
jne 0x6ec3
movq (%rbp), %rax
movq (%rax), %rcx
cmpl 0x14(%rsp), %r14d
jne 0x70cf
movl 0x8(%rcx), %edx
movq 0x8(%rax), %rsi
subl 0x8(%rsi), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x5, %esi
jb 0x6ec3
movq 0x8(%rbp), %rdx
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
movl 0x8(%rsi), %esi
subl 0x8(%rdx), %esi
movl %esi, %edx
negl %edx
cmovsl %esi, %edx
cmpl $0x5, %edx
jb 0x6ec3
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 0x6ec3
movl 0x8(%rcx), %ecx
movq 0x8(%rbp), %rsi
movq 0x8(%rsi), %rdx
movl 0x8(%rdx), %edx
cmpl %edx, %ecx
jne 0x7271
movslq %ecx, %rcx
movq 0x8(%rsp), %rdx
cmpb $0x43, (%rdx,%rcx)
jne 0x7124
movq 0x8(%rsp), %rax
movb $0x42, (%rax,%rcx)
movq (%rbx,%r13,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rsi
movq (%rsi), %rcx
jmp 0x71d1
movq (%rbp), %rax
movq (%rax), %rcx
cmpl 0x14(%rsp), %r14d
jne 0x7175
movl 0x8(%rcx), %edx
movq 0x8(%rax), %rsi
subl 0x8(%rsi), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x2, %esi
jb 0x6efa
movq 0x8(%rbp), %rdx
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
movl 0x8(%rsi), %esi
subl 0x8(%rdx), %esi
movl %esi, %edx
negl %edx
cmovsl %esi, %edx
cmpl $0x2, %edx
jb 0x6efa
movq (%rcx), %rdx
movb 0x40(%rdx), %sil
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rdi
movq (%rdx,%rdi,8), %rdi
movl 0x8(%rcx), %edx
movq 0x8(%rbp), %rcx
movq 0x8(%rcx), %r8
xorl %r9d, %r9d
cmpl 0x8(%r8), %edx
setle %r9b
leal (%rdx,%r9,2), %edx
decl %edx
movslq %edx, %rdx
cmpb 0x40(%rdi), %sil
jne 0x721e
movq 0x8(%rsp), %rsi
cmpb $0x43, (%rsi,%rdx)
jne 0x71ce
movq 0x8(%rsp), %rax
movb $0x42, (%rax,%rdx)
movq (%rbx,%r13,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
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 (%rsp), %rcx
cmpb $0x43, (%rcx,%rax)
jne 0x6ec3
movq (%rsp), %rcx
jmp 0x7268
movq (%rsp), %rdx
cmpb $0x43, (%rdx,%rcx)
jne 0x7214
movq (%rsp), %rax
movb $0x42, (%rax,%rcx)
movq (%rbx,%r13,8), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq 0x8(%rax), %rax
jmp 0x7254
movq (%rsp), %rsi
cmpb $0x43, (%rsi,%rdx)
jne 0x723b
movq (%rsp), %rax
movb $0x42, (%rax,%rdx)
movq (%rbx,%r13,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
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 0x6ec3
movq 0x8(%rsp), %rcx
movb $0x42, (%rcx,%rax)
jmp 0x6ec3
movq (%rsi), %rsi
movslq 0x8(%rsi), %rsi
movq 0x8(%rax), %rax
cmpl 0x8(%rax), %esi
jne 0x72ab
movq (%rsp), %rax
cmpb $0x43, (%rax,%rsi)
jne 0x72ab
movq (%rsp), %rax
movb $0x62, (%rax,%rsi)
movq (%rbx,%r13,8), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movq (%rcx), %rcx
movl 0x8(%rcx), %ecx
movq 0x8(%rax), %rax
movl 0x8(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
setle %al
leal (%rcx,%rax,2), %eax
decl %eax
cltq
movq 0x8(%rsp), %rcx
cmpb $0x43, (%rcx,%rax)
jne 0x6ec3
movq 0x8(%rsp), %rcx
movb $0x62, (%rcx,%rax)
jmp 0x6ec3
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)