// File: /workspace/github_c_makefile_star2_O3/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 0x7d53
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 0x7938
cmpq $0x0, 0x18(%rbp)
je 0x7945
incq %r13
cmpq %r13, %r12
jne 0x7926
jmp 0x7d53
leaq 0x24(%rbp), %r15
movq %r15, %rdi
leaq 0x1228d(%rip), %rsi     # 0x19be0
callq 0x2150
testl %eax, %eax
je 0x7a68
movq %r15, %rdi
leaq 0x1227b(%rip), %rsi     # 0x19be5
callq 0x2150
testl %eax, %eax
je 0x7ba9
movq %r15, %rdi
leaq 0x1227f(%rip), %rsi     # 0x19c00
callq 0x2150
testl %eax, %eax
je 0x79a1
movq %r15, %rdi
leaq 0x12271(%rip), %rsi     # 0x19c05
callq 0x2150
testl %eax, %eax
jne 0x7ad9
movq (%rbp), %rax
movq (%rax), %rcx
cmpl 0x14(%rsp), %r14d
jne 0x79ea
movl 0x8(%rcx), %edx
movq 0x8(%rax), %rsi
subl 0x8(%rsi), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x4, %esi
jb 0x7ad9
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 0x7ad9
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 0x7938
movl 0x8(%rcx), %ecx
movq 0x8(%rbp), %rsi
movq 0x8(%rsi), %rdx
movl 0x8(%rdx), %edx
cmpl %edx, %ecx
je 0x7b7f
movq (%rsi), %rsi
movslq 0x8(%rsi), %rsi
movq 0x8(%rax), %rax
cmpl 0x8(%rax), %esi
jne 0x7a57
movq (%rsp), %rax
cmpb $0x43, (%rax,%rsi)
jne 0x7a57
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 0x7ccf
movq (%rbp), %rax
movq (%rax), %rcx
cmpl 0x14(%rsp), %r14d
jne 0x7a90
movl 0x8(%rcx), %edx
movq 0x8(%rax), %rsi
subl 0x8(%rsi), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x3, %esi
jb 0x7960
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 0x7c78
movq 0x8(%rsp), %rdx
cmpb $0x43, (%rdx,%rcx)
jne 0x7acc
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 0x7c64
movq %r15, %rdi
leaq 0x12112(%rip), %rsi     # 0x19bf5
callq 0x2150
testl %eax, %eax
je 0x7b03
movq %r15, %rdi
leaq 0x120f4(%rip), %rsi     # 0x19bea
callq 0x2150
testl %eax, %eax
jne 0x7938
movq (%rbp), %rax
movq (%rax), %rcx
cmpl 0x14(%rsp), %r14d
jne 0x7b4c
movl 0x8(%rcx), %edx
movq 0x8(%rax), %rsi
subl 0x8(%rsi), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x5, %esi
jb 0x7938
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 0x7938
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 0x7938
movl 0x8(%rcx), %ecx
movq 0x8(%rbp), %rsi
movq 0x8(%rsi), %rdx
movl 0x8(%rdx), %edx
cmpl %edx, %ecx
jne 0x7cee
movslq %ecx, %rcx
movq 0x8(%rsp), %rdx
cmpb $0x43, (%rdx,%rcx)
jne 0x7ba1
movq 0x8(%rsp), %rax
movb $0x42, (%rax,%rcx)
movq (%rbx,%r13,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rsi
movq (%rsi), %rcx
jmp 0x7c4e
movq (%rbp), %rax
movq (%rax), %rcx
cmpl 0x14(%rsp), %r14d
jne 0x7bf2
movl 0x8(%rcx), %edx
movq 0x8(%rax), %rsi
subl 0x8(%rsi), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x2, %esi
jb 0x7977
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 0x7977
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 0x7c9b
movq 0x8(%rsp), %rsi
cmpb $0x43, (%rsi,%rdx)
jne 0x7c4b
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 0x7938
movq (%rsp), %rcx
jmp 0x7ce5
movq (%rsp), %rdx
cmpb $0x43, (%rdx,%rcx)
jne 0x7c91
movq (%rsp), %rax
movb $0x42, (%rax,%rcx)
movq (%rbx,%r13,8), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq 0x8(%rax), %rax
jmp 0x7cd1
movq (%rsp), %rsi
cmpb $0x43, (%rsi,%rdx)
jne 0x7cb8
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 0x7938
movq 0x8(%rsp), %rcx
movb $0x42, (%rcx,%rax)
jmp 0x7938
movq (%rsi), %rsi
movslq 0x8(%rsi), %rsi
movq 0x8(%rax), %rax
cmpl 0x8(%rax), %esi
jne 0x7d28
movq (%rsp), %rax
cmpb $0x43, (%rax,%rsi)
jne 0x7d28
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 0x7938
movq 0x8(%rsp), %rcx
movb $0x62, (%rcx,%rax)
jmp 0x7938
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop