// File: /workspace/github_c_makefile_star2_O2/josch[P]stride/turn.c
// Function: BetaTurn
void BetaTurn(CHAIN **Chain, int Cn)
{

  register int i;
  RESIDUE **r;
  TURN *t;
  int CA1, CA4, Tn;
  float Phi2, Phi3, Psi2, Psi3, Range1 = 30.0, Range2 = 45.0;
  char TurnType;

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

    r = &Chain[Cn]->Rsd[i];
    
    if( r[1]->Prop->Asn == 'H' || r[2]->Prop->Asn == 'H' || 
        r[1]->Prop->Asn == 'G' || r[2]->Prop->Asn == 'G' || 
        r[1]->Prop->Asn == 'I' || r[2]->Prop->Asn == 'G' || 
       !FindAtom(Chain[Cn],i,"CA",&CA1) || !FindAtom(Chain[Cn],i+3,"CA",&CA4) ||
       Dist(r[0]->Coord[CA1],r[3]->Coord[CA4]) > 7.0 )
      continue;
    
    Phi2 = r[1]->Prop->Phi;
    Psi2 = r[1]->Prop->Psi;
    Phi3 = r[2]->Prop->Phi;
    Psi3 = r[2]->Prop->Psi;
    
    if( TurnCondition(Phi2,-60.0,Psi2,-30,Phi3,-90.0,Psi3,0,Range1,Range2) )
      TurnType = '1';
    else
    if( TurnCondition(Phi2,60.0,Psi2,30,Phi3,90.0,Psi3,0,Range1,Range2) )
      TurnType = '2';
    else
    if( TurnCondition(Phi2,-60.0,Psi2,120,Phi3,80.0,Psi3,0,Range1,Range2) )
      TurnType = '3';
    else
    if( TurnCondition(Phi2,60.0,Psi2,-120,Phi3,-80.0,Psi3,0,Range1,Range2) )
      TurnType = '4';
    else
    if( TurnCondition(Phi2,-60.0,Psi2,120,Phi3,-90.0,Psi3,0,Range1,Range2) )
      TurnType = '5';
    else
    if( TurnCondition(Phi2,-120.0,Psi2,120,Phi3,-60.0,Psi3,0,Range1,Range2) )
      TurnType = '6';
    else
    if( TurnCondition(Phi2,-60.0,Psi2,-30,Phi3,-120.0,Psi3,120,Range1,Range2) )
      TurnType = '7';
    else
      TurnType = '8';
  
    if( r[0]->Prop->Asn == 'C' ) 
      r[0]->Prop->Asn = 'T';
    
    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[0]->ResType);
    strcpy(t->Res2,r[3]->ResType);
    strcpy(t->PDB_ResNumb1,r[0]->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 $0x28, %rsp
movq %rdi, %rbx
movslq %esi, %r13
xorl %r14d, %r14d
leaq 0x550a(%rip), %r15      # 0x19de8
leaq 0x18(%rsp), %rbp
movq (%rbx,%r13,8), %rdi
movslq (%rdi), %rax
addq $-0x4, %rax
cmpq %rax, %r14
jge 0x14cde
movq 0x68(%rdi), %r12
movq 0x8(%r12,%r14,8), %rax
movq 0x768(%rax), %rax
movzbl 0x1c(%rax), %eax
cmpl $0x48, %eax
je 0x14cd6
movq 0x10(%r12,%r14,8), %rcx
movq 0x768(%rcx), %rcx
movb 0x1c(%rcx), %cl
addb $-0x47, %cl
cmpb $0x2, %cl
jb 0x14cd6
cmpl $0x47, %eax
je 0x14cd6
cmpl $0x49, %eax
je 0x14cd6
movl %r14d, %esi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x4777
testl %eax, %eax
je 0x14cd6
movq (%rbx,%r13,8), %rdi
leal 0x3(%r14), %esi
movq %r15, %rdx
leaq 0x1c(%rsp), %rcx
callq 0x4777
testl %eax, %eax
je 0x14cd6
movslq 0x18(%rsp), %rax
imulq $0xc, %rax, %rdi
addq (%r12,%r14,8), %rdi
movl $0x188, %ecx            # imm = 0x188
addq %rcx, %rdi
movslq 0x1c(%rsp), %rax
imulq $0xc, %rax, %rsi
addq 0x18(%r12,%r14,8), %rsi
addq %rcx, %rsi
callq 0x3abc
ucomiss 0x527a(%rip), %xmm0     # 0x19c20
ja 0x14cd6
movq 0x8(%r12,%r14,8), %rax
movq 0x10(%r12,%r14,8), %rcx
movq 0x768(%rax), %rbp
movss (%rbp), %xmm0
movss 0x4(%rbp), %xmm2
movq 0x768(%rcx), %rax
movss (%rax), %xmm4
movq %rax, 0x20(%rsp)
movss 0x4(%rax), %xmm6
xorps %xmm7, %xmm7
movss %xmm0, 0x8(%rsp)
movss 0x5237(%rip), %xmm1     # 0x19c24
movss %xmm2, 0x10(%rsp)
movss 0x522d(%rip), %xmm3     # 0x19c28
movss %xmm4, 0xc(%rsp)
movss 0x5223(%rip), %xmm5     # 0x19c2c
movss %xmm6, 0x14(%rsp)
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x14ced
popq %rcx
popq %rdx
movb $0x31, %r15b
testl %eax, %eax
jne 0x14c08
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x4460(%rip), %xmm1     # 0x18e9c
movss 0x10(%rsp), %xmm2
movss 0x51e6(%rip), %xmm3     # 0x19c30
movss 0xc(%rsp), %xmm4
movss 0x40b0(%rip), %xmm5     # 0x18b08
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x14ced
popq %rcx
popq %rdx
movb $0x32, %r15b
testl %eax, %eax
jne 0x14c08
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x5199(%rip), %xmm1     # 0x19c24
movss 0x10(%rsp), %xmm2
movss 0x519b(%rip), %xmm3     # 0x19c34
movss 0xc(%rsp), %xmm4
movss 0x5191(%rip), %xmm5     # 0x19c38
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x14ced
popq %rcx
popq %rdx
movb $0x33, %r15b
testl %eax, %eax
jne 0x14c08
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x43c2(%rip), %xmm1     # 0x18e9c
movss 0x10(%rsp), %xmm2
movss 0x5154(%rip), %xmm3     # 0x19c3c
movss 0xc(%rsp), %xmm4
movss 0x514a(%rip), %xmm5     # 0x19c40
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x14ced
popq %rcx
popq %rdx
movb $0x34, %r15b
testl %eax, %eax
jne 0x14c08
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x50fb(%rip), %xmm1     # 0x19c24
movss 0x10(%rsp), %xmm2
movss 0x50fd(%rip), %xmm3     # 0x19c34
movss 0xc(%rsp), %xmm4
movss 0x50e7(%rip), %xmm5     # 0x19c2c
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x14ced
popq %rcx
popq %rdx
movb $0x35, %r15b
testl %eax, %eax
jne 0x14c08
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x50c4(%rip), %xmm1     # 0x19c3c
movss 0x10(%rsp), %xmm2
movss 0x50ae(%rip), %xmm3     # 0x19c34
movss 0xc(%rsp), %xmm4
movss 0x5090(%rip), %xmm5     # 0x19c24
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x14ced
popq %rcx
popq %rdx
movb $0x36, %r15b
testl %eax, %eax
jne 0x14c08
movss 0x8(%rsp), %xmm0
movss 0x5064(%rip), %xmm1     # 0x19c24
movss 0x10(%rsp), %xmm2
movss 0x505a(%rip), %xmm3     # 0x19c28
movss 0xc(%rsp), %xmm4
movss 0x5060(%rip), %xmm5     # 0x19c3c
movss 0x14(%rsp), %xmm6
movss 0x504a(%rip), %xmm7     # 0x19c34
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x14ced
popq %rcx
popq %rdx
cmpl $0x1, %eax
movl $0x0, %r15d
adcb $0x37, %r15b
movq (%r12,%r14,8), %rax
movq 0x768(%rax), %rax
cmpb $0x43, 0x1c(%rax)
jne 0x14c1d
movb $0x54, 0x1c(%rax)
cmpb $0x43, 0x1c(%rbp)
jne 0x14c27
movb $0x54, 0x1c(%rbp)
movq 0x20(%rsp), %rax
cmpb $0x43, 0x1c(%rax)
jne 0x14c36
movb $0x54, 0x1c(%rax)
movq 0x18(%r12,%r14,8), %rax
movq 0x768(%rax), %rax
cmpb $0x43, 0x1c(%rax)
jne 0x14c4c
movb $0x54, 0x1c(%rax)
movq (%rbx,%r13,8), %rax
movslq 0x28(%rax), %rbp
pushq $0x1b
popq %rdi
callq 0x50f4
movq (%rbx,%r13,8), %rcx
movq 0x98(%rcx), %rcx
movq %rax, (%rcx,%rbp,8)
movq (%rbx,%r13,8), %rax
movq 0x98(%rax), %rax
movq (%rax,%rbp,8), %rbp
movq (%r12,%r14,8), %rsi
addq $0xa, %rsi
movq %rbp, %rdi
callq 0x2070
leaq 0x6(%rbp), %rdi
movq 0x18(%r12,%r14,8), %rsi
addq $0xa, %rsi
callq 0x2070
leaq 0xc(%rbp), %rdi
movq (%r12,%r14,8), %rsi
addq $0x4, %rsi
callq 0x2070
leaq 0x12(%rbp), %rdi
movq 0x18(%r12,%r14,8), %rsi
addq $0x4, %rsi
callq 0x2070
movb %r15b, 0x1a(%rbp)
movq (%rbx,%r13,8), %rax
incl 0x28(%rax)
leaq 0x5117(%rip), %r15      # 0x19de8
leaq 0x18(%rsp), %rbp
incq %r14
jmp 0x148e3
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq