// File: /workspace/github_c_makefile_star2_O3/josch[P]stride/turn.c
// Function: GammaTurn
void GammaTurn(CHAIN **Chain, int Cn, HBOND **HBond)
{

  register int i;
  RESIDUE **r;
  TURN *t;
  int Tn;
  float Phi2, Psi2;
  char TurnType, Asn;

  for( i=0; i<Chain[Cn]->NRes-2; i++ ) {

    r = &Chain[Cn]->Rsd[i-1];

    Asn = r[2]->Prop->Asn;

    if( Asn == 'H' || Asn == 'T' || Asn == 'G' || Asn == 'I' ||
        FindBnd(HBond,r[3],r[1]) == ERR ||
        (i > 0 && FindBnd(HBond,r[3],r[0]) != ERR) || 
        (i < Chain[Cn]->NRes-3 && FindBnd(HBond,r[4],r[1]) != ERR) )
      continue;
    
    Phi2 = r[2]->Prop->Phi;
    Psi2 = r[2]->Prop->Psi;
    
    if( Phi2 > 0.0 && Psi2 < 0.0 )
      TurnType = '@';
    else
    if( Phi2 < 0.0 && Psi2 > 0.0 )
      TurnType = '&';
    else 
      continue;

    if( r[1]->Prop->Asn == 'C' )
      r[1]->Prop->Asn = 'T';
    
    if( r[2]->Prop->Asn == 'C' )
      r[2]->Prop->Asn = 'T';
    
    if( r[3]->Prop->Asn == 'C' )
      r[3]->Prop->Asn = 'T';
    
    Tn = Chain[Cn]->NAssignedTurn;
    Chain[Cn]->AssignedTurn[Tn] = (TURN *)ckalloc(sizeof(TURN));
    t = Chain[Cn]->AssignedTurn[Tn];
    strcpy(t->Res1,r[1]->ResType);
    strcpy(t->Res2,r[3]->ResType);
    strcpy(t->PDB_ResNumb1,r[1]->PDB_ResNumb);
    strcpy(t->PDB_ResNumb2,r[3]->PDB_ResNumb);
    t->TurnType = TurnType;
    Chain[Cn]->NAssignedTurn++;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movslq %esi, %r12
movq (%rdi,%r12,8), %rax
cmpl $0x3, (%rax)
jl 0x15563
movq %rdx, %r15
movq %rdi, %r14
xorl %r13d, %r13d
movl $0x2007, %ebp           # imm = 0x2007
movq %rdx, 0x10(%rsp)
movq 0x68(%rax), %rbx
movq 0x8(%rbx,%r13,8), %rax
movq 0x768(%rax), %rax
movzbl 0x1c(%rax), %eax
addl $-0x47, %eax
cmpl $0xd, %eax
ja 0x15401
btl %eax, %ebp
jae 0x15401
incq %r13
movq (%r14,%r12,8), %rax
movslq (%rax), %rcx
addq $-0x2, %rcx
cmpq %rcx, %r13
jl 0x153c8
jmp 0x15563
movq (%rbx,%r13,8), %rdx
movq 0x10(%rbx,%r13,8), %rsi
movq %r15, %rdi
callq 0xa434
cmpl $-0x1, %eax
je 0x153e9
testq %r13, %r13
je 0x15433
movq -0x8(%rbx,%r13,8), %rdx
movq 0x10(%rbx,%r13,8), %rsi
movq %r15, %rdi
callq 0xa434
cmpl $-0x1, %eax
jne 0x153e9
movq (%r14,%r12,8), %rax
movslq (%rax), %rax
addq $-0x3, %rax
cmpq %rax, %r13
jge 0x15459
movq (%rbx,%r13,8), %rdx
movq 0x18(%rbx,%r13,8), %rsi
movq %r15, %rdi
callq 0xa434
cmpl $-0x1, %eax
jne 0x153e9
movq 0x8(%rbx,%r13,8), %rax
movq 0x768(%rax), %rax
movss (%rax), %xmm1
movss 0x4(%rax), %xmm0
ucomiss 0x4a63(%rip), %xmm1     # 0x19ed8
jbe 0x15481
movb $0x40, %cl
xorps %xmm2, %xmm2
ucomiss %xmm0, %xmm2
ja 0x1549c
xorps %xmm2, %xmm2
ucomiss %xmm1, %xmm2
jbe 0x153e9
movb $0x26, %cl
ucomiss 0x4a42(%rip), %xmm0     # 0x19ed8
jbe 0x153e9
movb %cl, 0xf(%rsp)
movq (%rbx,%r13,8), %rcx
movq 0x768(%rcx), %rcx
cmpb $0x43, 0x1c(%rcx)
jne 0x154b5
movb $0x54, 0x1c(%rcx)
cmpb $0x43, 0x1c(%rax)
jne 0x154bf
movb $0x54, 0x1c(%rax)
movq 0x10(%rbx,%r13,8), %rax
movq 0x768(%rax), %rax
cmpb $0x43, 0x1c(%rax)
jne 0x154d5
movb $0x54, 0x1c(%rax)
movq (%r14,%r12,8), %rax
movslq 0x28(%rax), %r15
movl $0x1b, %edi
callq 0x5880
movq (%r14,%r12,8), %rcx
movq 0x98(%rcx), %rcx
movq %rax, (%rcx,%r15,8)
movq (%r14,%r12,8), %rax
movq 0x98(%rax), %rax
movq (%rax,%r15,8), %r15
movq (%rbx,%r13,8), %rsi
addq $0xa, %rsi
movq %r15, %rdi
callq 0x2070
leaq 0x6(%r15), %rdi
movq 0x10(%rbx,%r13,8), %rsi
addq $0xa, %rsi
callq 0x2070
leaq 0xc(%r15), %rdi
movq (%rbx,%r13,8), %rsi
addq $0x4, %rsi
callq 0x2070
leaq 0x12(%r15), %rdi
movq 0x10(%rbx,%r13,8), %rsi
addq $0x4, %rsi
callq 0x2070
movb 0xf(%rsp), %al
movb %al, 0x1a(%r15)
movq (%r14,%r12,8), %rax
incl 0x28(%rax)
movq 0x10(%rsp), %r15
jmp 0x153e9
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop