// File: /workspace/github_c_makefile_star2_O0/josch[P]stride/sheet.c
// Function: Link
int Link(HBOND **HBond, CHAIN **Chain, int Cn1, int Cn2, RESIDUE *Res1_1, 
	 RESIDUE *Res1_2, RESIDUE *Res2_2, RESIDUE *Res2_1, RESIDUE *CRes1, 
	 RESIDUE *CRes2, float **PhiPsiMap, PATTERN **Pattern, int *NumPat, 
	 char *Text, float Treshold, COMMAND *Cmd, int Test)
{

  int BondNumber1, BondNumber2, Flag = 0;
  static char *Result[2] = {" NO \n"," YES \n"};
  float Prob1, Prob2, Conf, Coeff;

  if( (BondNumber1 = FindPolInt(HBond,Res1_1,Res1_2)) == ERR ) 
    return(FAILURE);

  if( (BondNumber2 = FindPolInt(HBond,Res2_2,Res2_1)) == ERR ) 
    return(FAILURE);

  if( CRes1 == NULL ) {
    if( CRes2->Prop->PhiZn == ERR || CRes2->Prop->PsiZn == ERR )
      return(FAILURE);
    Conf = PhiPsiMap[CRes2->Prop->PhiZn][CRes2->Prop->PsiZn];
  }
  else
  if( CRes2 == NULL ) {
    if( CRes1->Prop->PhiZn == ERR || CRes1->Prop->PsiZn == ERR )
      return(FAILURE);
    Conf = PhiPsiMap[CRes1->Prop->PhiZn][CRes1->Prop->PsiZn];
  }
  else {
    if( CRes2->Prop->PhiZn == ERR || CRes2->Prop->PsiZn == ERR ||
        CRes1->Prop->PhiZn == ERR || CRes1->Prop->PsiZn == ERR )
      return(FAILURE);
    Conf = 
      0.5*(PhiPsiMap[CRes1->Prop->PhiZn][CRes1->Prop->PsiZn]+
	   PhiPsiMap[CRes2->Prop->PhiZn][CRes2->Prop->PsiZn]);
  }
  Coeff = 1+Cmd->C1_E+Cmd->C2_E*Conf;
  Prob1 = HBond[BondNumber1]->Energy*Coeff;
  Prob2 = HBond[BondNumber2]->Energy*Coeff;

  if( Prob1 < Treshold && Prob2 < Treshold ) {

    if( !Test ) {
      Pattern[*NumPat] = (PATTERN *)ckalloc(sizeof(PATTERN));
      Pattern[*NumPat]->ExistPattern = YES;
      Pattern[*NumPat]->Hb1 = HBond[BondNumber1];
      Pattern[*NumPat]->Hb2 = HBond[BondNumber2];
      Pattern[*NumPat]->Nei1 = NULL;
      Pattern[*NumPat]->Nei2 = NULL;
      strcpy(Pattern[*NumPat]->Type,Text);
      (*NumPat)++;
    }
    Flag = 1;
  }

  if( Cmd->Info && Flag ) {
    fprintf(stdout,"%s %c: %3s %c: %3s | %c: %3s %c: %3s | ",
	    Text,
	    Chain[Cn1]->Id,Res1_1->PDB_ResNumb,
	    Chain[Cn2]->Id,Res1_2->PDB_ResNumb,
	    Chain[Cn2]->Id,Res2_2->PDB_ResNumb,
	    Chain[Cn1]->Id,Res2_1->PDB_ResNumb);
    fprintf(stdout,"%8.6f %6.4f | ", Prob1,HBond[BondNumber1]->Energy);
    fprintf(stdout,"%8.6f %6.4f | ", Prob2,HBond[BondNumber2]->Energy);

    if( CRes1 != NULL && 
        CRes1->Prop->PhiZn != ERR && CRes1->Prop->PsiZn != ERR )
      fprintf(stdout,"%6.4f %2d %2d | ",   
	      PhiPsiMap[CRes1->Prop->PhiZn][CRes1->Prop->PsiZn],
	      CRes1->Prop->PhiZn,CRes1->Prop->PsiZn);
    else
      fprintf(stdout,"000000 00 00 | ");

    if( CRes2 != NULL &&
        CRes2->Prop->PhiZn != ERR && CRes2->Prop->PsiZn != ERR )
      fprintf(stdout,"%6.4f %2d %2d | ",   
	      PhiPsiMap[CRes2->Prop->PhiZn][CRes2->Prop->PsiZn],
	      CRes2->Prop->PhiZn,CRes2->Prop->PsiZn);
    else
      fprintf(stdout,"000000 00 00 | ");
    
    fprintf(stdout,"%s",Result[Flag]);
  }
  
  return(Flag);
  
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x78, %rsp
movl 0xd8(%rsp), %eax
movq 0xd0(%rsp), %rax
movq 0xc8(%rsp), %rax
movq 0xc0(%rsp), %rax
movq 0xb8(%rsp), %rax
movq 0xb0(%rsp), %rax
movq 0xa8(%rsp), %rax
movq 0xa0(%rsp), %rax
movq 0x98(%rsp), %rax
movq 0x90(%rsp), %rax
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movl %edx, 0x5c(%rsp)
movl %ecx, 0x58(%rsp)
movq %r8, 0x50(%rsp)
movq %r9, 0x48(%rsp)
movss %xmm0, 0x44(%rsp)
movl $0x0, 0x38(%rsp)
movq 0x68(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
callq 0x10860
movl %eax, 0x40(%rsp)
cmpl $-0x1, %eax
jne 0x9cda
movl $0x0, 0x74(%rsp)
jmp 0xa3c8
movq 0x68(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
callq 0x10860
movl %eax, 0x3c(%rsp)
cmpl $-0x1, %eax
jne 0x9d0a
movl $0x0, 0x74(%rsp)
jmp 0xa3c8
cmpq $0x0, 0xa0(%rsp)
jne 0x9d8e
movq 0xa8(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0xc(%rax)
je 0x9d3f
movq 0xa8(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0x10(%rax)
jne 0x9d4c
movl $0x0, 0x74(%rsp)
jmp 0xa3c8
movq 0xb0(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0xc(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0xa8(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0x10(%rcx), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, 0x2c(%rsp)
jmp 0x9efd
cmpq $0x0, 0xa8(%rsp)
jne 0x9e12
movq 0xa0(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0xc(%rax)
je 0x9dc3
movq 0xa0(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0x10(%rax)
jne 0x9dd0
movl $0x0, 0x74(%rsp)
jmp 0xa3c8
movq 0xb0(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0xc(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0xa0(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0x10(%rcx), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, 0x2c(%rsp)
jmp 0x9efb
movq 0xa8(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0xc(%rax)
je 0x9e66
movq 0xa8(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0x10(%rax)
je 0x9e66
movq 0xa0(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0xc(%rax)
je 0x9e66
movq 0xa0(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0x10(%rax)
jne 0x9e73
movl $0x0, 0x74(%rsp)
jmp 0xa3c8
movq 0xb0(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0xc(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0xa0(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0x10(%rcx), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0xb0(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0xc(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0xa8(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0x10(%rcx), %rcx
addss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x21c1b(%rip), %xmm0    # 0x2bb08
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x2c(%rsp)
jmp 0x9efd
movq 0xd0(%rsp), %rax
movss 0x2111b(%rip), %xmm1    # 0x2b028
addss 0x1d40(%rax), %xmm1
movq 0xd0(%rsp), %rax
movss 0x1d44(%rax), %xmm0
movss 0x2c(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x28(%rsp)
movq 0x68(%rsp), %rax
movslq 0x40(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movss 0x1c(%rax), %xmm0
mulss 0x28(%rsp), %xmm0
movss %xmm0, 0x34(%rsp)
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movss 0x1c(%rax), %xmm0
mulss 0x28(%rsp), %xmm0
movss %xmm0, 0x30(%rsp)
movss 0x34(%rsp), %xmm1
movss 0x44(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xa0bf
movss 0x30(%rsp), %xmm1
movss 0x44(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0xa0bf
cmpl $0x0, 0xd8(%rsp)
jne 0xa0b7
movl $0x428, %edi            # imm = 0x428
callq 0x7360
movq %rax, %rdx
movq 0xb8(%rsp), %rax
movq 0xc0(%rsp), %rcx
movslq (%rcx), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0xb8(%rsp), %rax
movq 0xc0(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movl $0x1, 0x20(%rax)
movq 0x68(%rsp), %rax
movslq 0x40(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0xb8(%rsp), %rax
movq 0xc0(%rsp), %rdx
movslq (%rdx), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0xb8(%rsp), %rax
movq 0xc0(%rsp), %rdx
movslq (%rdx), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movq 0xb8(%rsp), %rax
movq 0xc0(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x10(%rax)
movq 0xb8(%rsp), %rax
movq 0xc0(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x18(%rax)
movq 0xb8(%rsp), %rax
movq 0xc0(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x24, %rdi
movq 0xc8(%rsp), %rsi
callq 0x2060
movq 0xc0(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl $0x1, 0x38(%rsp)
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x1d60(%rax)
je 0xa3c0
cmpl $0x0, 0x38(%rsp)
je 0xa3c0
movq 0x25ef2(%rip), %rax     # 0x2ffd8
movq (%rax), %rdi
movq 0xc8(%rsp), %rdx
movq 0x60(%rsp), %rax
movslq 0x5c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x40(%rax), %ecx
movq 0x50(%rsp), %r8
addq $0x4, %r8
movq 0x60(%rsp), %rax
movslq 0x58(%rsp), %rsi
movq (%rax,%rsi,8), %rax
movsbl 0x40(%rax), %r9d
movq 0x48(%rsp), %r14
addq $0x4, %r14
movq 0x60(%rsp), %rax
movslq 0x58(%rsp), %rsi
movq (%rax,%rsi,8), %rax
movsbl 0x40(%rax), %ebx
movq 0x90(%rsp), %r11
addq $0x4, %r11
movq 0x60(%rsp), %rax
movslq 0x5c(%rsp), %rsi
movq (%rax,%rsi,8), %rax
movsbl 0x40(%rax), %r10d
movq 0x98(%rsp), %rax
addq $0x4, %rax
leaq 0x21a04(%rip), %rsi     # 0x2bb70
movq %r14, (%rsp)
movl %ebx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movb $0x0, %al
callq 0x2140
movq 0x25e47(%rip), %rax     # 0x2ffd8
movq (%rax), %rdi
movss 0x34(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x68(%rsp), %rax
movslq 0x40(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movss 0x1c(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x219dc(%rip), %rsi     # 0x2bb98
movb $0x2, %al
callq 0x2140
movq 0x25e0e(%rip), %rax     # 0x2ffd8
movq (%rax), %rdi
movss 0x30(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movss 0x1c(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x219a3(%rip), %rsi     # 0x2bb98
movb $0x2, %al
callq 0x2140
cmpq $0x0, 0xa0(%rsp)
je 0xa2b2
movq 0xa0(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0xc(%rax)
je 0xa2b2
movq 0xa0(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0x10(%rax)
je 0xa2b2
movq 0x25d98(%rip), %rax     # 0x2ffd8
movq (%rax), %rdi
movq 0xb0(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0xc(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0xa0(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0x10(%rcx), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0xa0(%rsp), %rax
movq 0x768(%rax), %rax
movl 0xc(%rax), %edx
movq 0xa0(%rsp), %rax
movq 0x768(%rax), %rax
movl 0x10(%rax), %ecx
leaq 0x218fe(%rip), %rsi     # 0x2bba7
movb $0x1, %al
callq 0x2140
jmp 0xa2ca
movq 0x25d1f(%rip), %rax     # 0x2ffd8
movq (%rax), %rdi
leaq 0x218f5(%rip), %rsi     # 0x2bbb8
movb $0x0, %al
callq 0x2140
cmpq $0x0, 0xa8(%rsp)
je 0xa380
movq 0xa8(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0xc(%rax)
je 0xa380
movq 0xa8(%rsp), %rax
movq 0x768(%rax), %rax
cmpl $-0x1, 0x10(%rax)
je 0xa380
movq 0x25cca(%rip), %rax     # 0x2ffd8
movq (%rax), %rdi
movq 0xb0(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0xc(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0xa8(%rsp), %rcx
movq 0x768(%rcx), %rcx
movslq 0x10(%rcx), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0xa8(%rsp), %rax
movq 0x768(%rax), %rax
movl 0xc(%rax), %edx
movq 0xa8(%rsp), %rax
movq 0x768(%rax), %rax
movl 0x10(%rax), %ecx
leaq 0x21830(%rip), %rsi     # 0x2bba7
movb $0x1, %al
callq 0x2140
jmp 0xa398
movq 0x25c51(%rip), %rax     # 0x2ffd8
movq (%rax), %rdi
leaq 0x21827(%rip), %rsi     # 0x2bbb8
movb $0x0, %al
callq 0x2140
movq 0x25c39(%rip), %rax     # 0x2ffd8
movq (%rax), %rdi
movslq 0x38(%rsp), %rcx
leaq 0x25e32(%rip), %rax     # 0x301e0
movq (%rax,%rcx,8), %rdx
leaq 0x2180f(%rip), %rsi     # 0x2bbc8
movb $0x0, %al
callq 0x2140
movl 0x38(%rsp), %eax
movl %eax, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
popq %rbx
popq %r14
retq
nopw %cs:(%rax,%rax)