// File: /workspace/github_c_makefile_star2_O1/josch[P]stride/phipsi.c
// Function: DiscrPhiPsi
void DiscrPhiPsi(CHAIN **Chain, int NChain, COMMAND *Cmd)
{

  register int i, Res, Cn;
  RESIDUE *r;

  for( Cn=0; Cn<NChain; Cn++ ) {
    
    for( Res=0; Res<Chain[Cn]->NRes; Res++ ) {
      
      r = Chain[Cn]->Rsd[Res];
      
      r->Prop->PhiZn = ERR;
      r->Prop->PsiZn = ERR;
      
      if( Res != 0 ) {
	for( i=0; i<Cmd->NPixel; i++ )
	  if( r->Prop->Phi  >  MINPHIPSI+(float)(i)*Cmd->PhiPsiStep && 
	      r->Prop->Phi <=  MINPHIPSI+(float)(i+1)*Cmd->PhiPsiStep ) {
	    r->Prop->PhiZn = i;
	    break;
	  }
      }
      
      if( Res != Chain[Cn]->NRes-1 ) {
	for( i=0; i<Cmd->NPixel; i++ )
	  if( r->Prop->Psi  >  MINPHIPSI+(float)(i)*Cmd->PhiPsiStep && 
	      r->Prop->Psi <=  MINPHIPSI+(float)(i+1)*Cmd->PhiPsiStep ) {
	    r->Prop->PsiZn = i;
	    break;
	  }
      }
      
    }
    
    for(Res=0; Res<Chain[Cn]->NRes; Res++ )  {
      r = Chain[Cn]->Rsd[Res];
      if( Res != 0 && r->Prop->PsiZn == ERR )
	r->Prop->PsiZn = Chain[Cn]->Rsd[Res-1]->Prop->PsiZn;
      if( Res != Chain[Cn]->NRes-1 && r->Prop->PhiZn == ERR )
	r->Prop->PhiZn = Chain[Cn]->Rsd[Res+1]->Prop->PhiZn;
    }

  }
}

// Assembly:
testl %esi, %esi
jle 0x83a1
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %eax
xorl %ecx, %ecx
movsd 0x11b60(%rip), %xmm0    # 0x19d80
movq (%rdi,%rcx,8), %r8
movslq (%r8), %rsi
testq %rsi, %rsi
jle 0x8329
movq 0x68(%r8), %r9
leal -0x1(%rsi), %r10d
xorl %r11d, %r11d
movq (%r9,%r11,8), %rbx
movq 0x768(%rbx), %rbx
movq $-0x1, 0xc(%rbx)
testq %r11, %r11
je 0x82b5
movl 0x1cf4(%rdx), %ebp
testl %ebp, %ebp
jle 0x82b5
xorps %xmm1, %xmm1
cvtss2sd (%rbx), %xmm1
movss 0x1d08(%rdx), %xmm2
xorl %r14d, %r14d
xorps %xmm3, %xmm3
cvtsi2ss %r14d, %xmm3
mulss %xmm2, %xmm3
cvtss2sd %xmm3, %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm1
jbe 0x82a7
leal 0x1(%r14), %r15d
xorps %xmm3, %xmm3
cvtsi2ss %r15d, %xmm3
mulss %xmm2, %xmm3
cvtss2sd %xmm3, %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jae 0x82b1
incl %r14d
cmpl %r14d, %ebp
jne 0x826f
jmp 0x82b5
movl %r14d, 0xc(%rbx)
cmpq %r10, %r11
je 0x831d
movl 0x1cf4(%rdx), %ebp
testl %ebp, %ebp
jle 0x831d
xorps %xmm1, %xmm1
cvtss2sd 0x4(%rbx), %xmm1
movss 0x1d08(%rdx), %xmm2
xorl %r14d, %r14d
xorps %xmm3, %xmm3
cvtsi2ss %r14d, %xmm3
mulss %xmm2, %xmm3
cvtss2sd %xmm3, %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm1
jbe 0x830f
leal 0x1(%r14), %r15d
xorps %xmm3, %xmm3
cvtsi2ss %r15d, %xmm3
mulss %xmm2, %xmm3
cvtss2sd %xmm3, %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jae 0x8319
incl %r14d
cmpl %r14d, %ebp
jne 0x82d7
jmp 0x831d
movl %r14d, 0x10(%rbx)
incq %r11
cmpq %rsi, %r11
jne 0x823b
testl %esi, %esi
jle 0x838f
movq 0x68(%r8), %r8
leal -0x1(%rsi), %r9d
xorl %r10d, %r10d
movq (%r8,%r10,8), %r11
testq %r10, %r10
je 0x8361
movq 0x768(%r11), %rbx
cmpl $-0x1, 0x10(%rbx)
jne 0x8361
movq -0x8(%r8,%r10,8), %r14
movq 0x768(%r14), %r14
movl 0x10(%r14), %ebp
movl %ebp, 0x10(%rbx)
cmpq %r10, %r9
je 0x8387
movq 0x768(%r11), %r11
cmpl $-0x1, 0xc(%r11)
jne 0x8387
movq 0x8(%r8,%r10,8), %rbx
movq 0x768(%rbx), %rbx
movl 0xc(%rbx), %ebx
movl %ebx, 0xc(%r11)
incq %r10
cmpq %r10, %rsi
jne 0x8338
incq %rcx
cmpq %rax, %rcx
jne 0x8220
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop