// File: /workspace/github_c_makefile_star2_O1/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
movq (%rdi,%r13,8), %rdi
cmpl $0x5, (%rdi)
jl 0x1539a
xorl %r14d, %r14d
leaq 0x5ec1(%rip), %r15      # 0x1ae48
leaq 0x18(%rsp), %rbp
movq 0x68(%rdi), %r12
movq 0x8(%r12,%r14,8), %rax
movq 0x768(%rax), %rax
movzbl 0x1c(%rax), %eax
cmpl $0x48, %eax
je 0x15383
movq 0x10(%r12,%r14,8), %rcx
movq 0x768(%rcx), %rcx
movb 0x1c(%rcx), %cl
addb $-0x47, %cl
cmpb $0x2, %cl
jb 0x15383
cmpl $0x47, %eax
je 0x15383
cmpl $0x49, %eax
je 0x15383
movl %r14d, %esi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x4f78
testl %eax, %eax
je 0x15383
movq (%rbx,%r13,8), %rdi
leal 0x3(%r14), %esi
movq %r15, %rdx
leaq 0x1c(%rsp), %rcx
callq 0x4f78
testl %eax, %eax
je 0x15383
movslq 0x18(%rsp), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x2, %rdi
addq (%r12,%r14,8), %rdi
movl $0x188, %ecx            # imm = 0x188
addq %rcx, %rdi
movslq 0x1c(%rsp), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x2, %rsi
addq 0x18(%r12,%r14,8), %rsi
addq %rcx, %rsi
callq 0x40d5
ucomiss 0x5c3d(%rip), %xmm0     # 0x1ac80
ja 0x15383
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 0x5bfa(%rip), %xmm1     # 0x1ac84
movss %xmm2, 0x10(%rsp)
movss 0x5bf0(%rip), %xmm3     # 0x1ac88
movss %xmm4, 0xc(%rsp)
movss 0x5be6(%rip), %xmm5     # 0x1ac8c
movss %xmm6, 0x14(%rsp)
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x153a9
addq $0x10, %rsp
movb $0x31, %r15b
testl %eax, %eax
jne 0x152b3
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x4de9(%rip), %xmm1     # 0x19ec4
movss 0x10(%rsp), %xmm2
movss 0x5ba7(%rip), %xmm3     # 0x1ac90
movss 0xc(%rsp), %xmm4
movss 0x4a01(%rip), %xmm5     # 0x19af8
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x153a9
addq $0x10, %rsp
movb $0x32, %r15b
testl %eax, %eax
jne 0x152b3
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x5b58(%rip), %xmm1     # 0x1ac84
movss 0x10(%rsp), %xmm2
movss 0x5b5a(%rip), %xmm3     # 0x1ac94
movss 0xc(%rsp), %xmm4
movss 0x5b50(%rip), %xmm5     # 0x1ac98
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x153a9
addq $0x10, %rsp
movb $0x33, %r15b
testl %eax, %eax
jne 0x152b3
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x4d47(%rip), %xmm1     # 0x19ec4
movss 0x10(%rsp), %xmm2
movss 0x5b11(%rip), %xmm3     # 0x1ac9c
movss 0xc(%rsp), %xmm4
movss 0x5b07(%rip), %xmm5     # 0x1aca0
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x153a9
addq $0x10, %rsp
movb $0x34, %r15b
testl %eax, %eax
jne 0x152b3
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x5ab6(%rip), %xmm1     # 0x1ac84
movss 0x10(%rsp), %xmm2
movss 0x5ab8(%rip), %xmm3     # 0x1ac94
movss 0xc(%rsp), %xmm4
movss 0x5aa2(%rip), %xmm5     # 0x1ac8c
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x153a9
addq $0x10, %rsp
movb $0x35, %r15b
testl %eax, %eax
jne 0x152b3
xorps %xmm7, %xmm7
movss 0x8(%rsp), %xmm0
movss 0x5a7d(%rip), %xmm1     # 0x1ac9c
movss 0x10(%rsp), %xmm2
movss 0x5a67(%rip), %xmm3     # 0x1ac94
movss 0xc(%rsp), %xmm4
movss 0x5a49(%rip), %xmm5     # 0x1ac84
movss 0x14(%rsp), %xmm6
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x153a9
addq $0x10, %rsp
movb $0x36, %r15b
testl %eax, %eax
jne 0x152b3
movss 0x8(%rsp), %xmm0
movss 0x5a1b(%rip), %xmm1     # 0x1ac84
movss 0x10(%rsp), %xmm2
movss 0x5a11(%rip), %xmm3     # 0x1ac88
movss 0xc(%rsp), %xmm4
movss 0x5a17(%rip), %xmm5     # 0x1ac9c
movss 0x14(%rsp), %xmm6
movss 0x5a01(%rip), %xmm7     # 0x1ac94
pushq $0x42340000             # imm = 0x42340000
pushq $0x41f00000             # imm = 0x41F00000
callq 0x153a9
addq $0x10, %rsp
cmpl $0x1, %eax
movl $0x0, %r15d
adcb $0x37, %r15b
movq (%r12,%r14,8), %rax
movq 0x768(%rax), %rax
cmpb $0x43, 0x1c(%rax)
jne 0x152c8
movb $0x54, 0x1c(%rax)
cmpb $0x43, 0x1c(%rbp)
jne 0x152d2
movb $0x54, 0x1c(%rbp)
movq 0x20(%rsp), %rax
cmpb $0x43, 0x1c(%rax)
jne 0x152e1
movb $0x54, 0x1c(%rax)
movq 0x18(%r12,%r14,8), %rax
movq 0x768(%rax), %rax
cmpb $0x43, 0x1c(%rax)
jne 0x152f7
movb $0x54, 0x1c(%rax)
movq (%rbx,%r13,8), %rax
movslq 0x28(%rax), %rbp
movl $0x1b, %edi
callq 0x595c
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 0x5aca(%rip), %r15      # 0x1ae48
leaq 0x18(%rsp), %rbp
incq %r14
movq (%rbx,%r13,8), %rdi
movslq (%rdi), %rax
addq $-0x4, %rax
cmpq %rax, %r14
jl 0x14f8c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq