// File: /workspace/github_c_makefile_star2_O2/josch[P]stride/hydrbond.c
// Function: DefineDnr
int DefineDnr(CHAIN *Chain, DONOR **Dnr, int *dc, int Res, enum HYBRID Hybrid, enum GROUP Group,
	      float HB_Radius, int N)
{

  Dnr[*dc] = (DONOR *)ckalloc(sizeof(DONOR));
  
  Dnr[*dc]->Chain = Chain;
  Dnr[*dc]->D_Res = Res;
  if( Group != Peptide )
    Dnr[*dc]->DD_Res = Res;
  else
    Dnr[*dc]->DD_Res = Res-1;
  Dnr[*dc]->DDI_Res = Res;
  Dnr[*dc]->Hybrid = Hybrid;
  Dnr[*dc]->Group = Group;
  Dnr[*dc]->HB_Radius = HB_Radius;
  
  if( Group == Peptide ) {
    if( Res != 0 ) {
      FindAtom(Chain,Res,"N",&Dnr[*dc]->D_At);
      FindAtom(Chain,Res-1,"C",&Dnr[*dc]->DD_At);
    }
    else {
      Dnr[*dc]->D_At  = ERR;
      Dnr[*dc]->DD_At = ERR;
    }
    FindAtom(Chain,Res,"CA",&Dnr[*dc]->DDI_At);
    FindAtom(Chain,Res,"H",&Dnr[*dc]->H);
  }
  else if( Group == Trp ) {
    FindAtom(Chain,Res,"NE1",&Dnr[*dc]->D_At);
    FindAtom(Chain,Res,"CE2",&Dnr[*dc]->DD_At);
    FindAtom(Chain,Res,"CD1",&Dnr[*dc]->DDI_At);
  }
  else if( Group == Asn ) {
    FindAtom(Chain,Res,"ND1",&Dnr[*dc]->D_At);
    FindAtom(Chain,Res,"CG",&Dnr[*dc]->DD_At);
    FindAtom(Chain,Res,"CB",&Dnr[*dc]->DDI_At);
  }
  else if( Group == Gln ) {
    FindAtom(Chain,Res,"NE2",&Dnr[*dc]->D_At);
    FindAtom(Chain,Res,"CD",&Dnr[*dc]->DD_At);
    FindAtom(Chain,Res,"CG",&Dnr[*dc]->DDI_At);
  }
  else if( Group == Arg ) {
    if( N == 1 ) {
      FindAtom(Chain,Res,"NE",&Dnr[*dc]->D_At);
      FindAtom(Chain,Res,"CZ",&Dnr[*dc]->DD_At);
      FindAtom(Chain,Res,"CD",&Dnr[*dc]->DDI_At);
    }
    else
    if( N == 2 ) {
      FindAtom(Chain,Res,"NH1",&Dnr[*dc]->D_At);
      FindAtom(Chain,Res,"CZ",&Dnr[*dc]->DD_At);
      FindAtom(Chain,Res,"NE",&Dnr[*dc]->DDI_At);
    }
    else
    if( N == 3 ) {
      FindAtom(Chain,Res,"NH2",&Dnr[*dc]->D_At);
      FindAtom(Chain,Res,"CZ",&Dnr[*dc]->DD_At);
      FindAtom(Chain,Res,"NE",&Dnr[*dc]->DDI_At);
    }
  }
  else if( Group == His ) {
      if( N == 1 ) {
	FindAtom(Chain,Res,"ND1",&Dnr[*dc]->D_At);
	FindAtom(Chain,Res,"CG",&Dnr[*dc]->DD_At);
	FindAtom(Chain,Res,"CE1",&Dnr[*dc]->DDI_At);
      }
      else if( N == 2 ) {
	FindAtom(Chain,Res,"NE2",&Dnr[*dc]->D_At);
	FindAtom(Chain,Res,"CE1",&Dnr[*dc]->DD_At);
	FindAtom(Chain,Res,"CD2",&Dnr[*dc]->DDI_At);
      }
    }
  else if( Group == Tyr ) {
    FindAtom(Chain,Res,"OH",&Dnr[*dc]->D_At);
    FindAtom(Chain,Res,"CZ",&Dnr[*dc]->DD_At);
    FindAtom(Chain,Res,"CE1",&Dnr[*dc]->DDI_At);
  }
  else if( Group == Lys ) {
    FindAtom(Chain,Res,"NZ",&Dnr[*dc]->D_At);
    FindAtom(Chain,Res,"CE",&Dnr[*dc]->DD_At);
  }
  else if( Group == Ser ) {
    FindAtom(Chain,Res,"OG",&Dnr[*dc]->D_At);
    FindAtom(Chain,Res,"CB",&Dnr[*dc]->DD_At);
  }
  else if( Group == Thr ) {
    FindAtom(Chain,Res,"OG1",&Dnr[*dc]->D_At);
    FindAtom(Chain,Res,"CB",&Dnr[*dc]->DD_At);
  }      
  
  if( Dnr[*dc]->H == ERR || Dnr[*dc]->D_At   == ERR || Dnr[*dc]->DD_At  == ERR ||
      (Dnr[*dc]->DDI_At == ERR && (Hybrid == Nsp2 || Hybrid == Osp2 )) ) {
    free(Dnr[*dc]); return(FAILURE);
  }
  else (*dc)++;
  return(SUCCESS);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movss %xmm0, 0x4(%rsp)
movl %r9d, %r13d
movl %r8d, %ebp
movl %ecx, %r15d
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
pushq $0x30
popq %rdi
callq 0x50f4
movslq (%rbx), %rcx
movq %rax, (%r14,%rcx,8)
movq %r12, (%rax)
movq (%r14,%rcx,8), %rax
movl %r15d, 0x8(%rax)
cmpl $0x1, %r13d
movl %r15d, %eax
sbbl $0x0, %eax
movslq (%rbx), %rcx
movq (%r14,%rcx,8), %rcx
movl %eax, 0xc(%rcx)
movslq (%rbx), %rax
movq (%r14,%rax,8), %rax
movl %r15d, 0x10(%rax)
movslq (%rbx), %rax
movq (%r14,%rax,8), %rax
movl %ebp, 0x24(%rax)
movslq (%rbx), %rax
movq (%r14,%rax,8), %rax
movl %r13d, 0x28(%rax)
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x2c(%rcx)
cmpl $0x9, %r13d
ja 0x8319
movl 0x40(%rsp), %eax
movl %r13d, %edx
leaq 0x10e8f(%rip), %rsi     # 0x18ea4
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
addq $0x14, %rcx
testl %r15d, %r15d
je 0x8248
leaq 0x108ec(%rip), %rdx     # 0x1891e
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leal -0x1(%r15), %esi
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x11561(%rip), %rdx     # 0x195b4
movq %r12, %rdi
callq 0x4777
jmp 0x8256
cmpl $0x3, %eax
je 0x82ca
cmpl $0x2, %eax
je 0x82bd
cmpl $0x1, %eax
jne 0x8319
addq $0x14, %rcx
leaq 0x10eb7(%rip), %rdx     # 0x18f3d
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10e9d(%rip), %rdx     # 0x18f40
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x10e85(%rip), %rdx     # 0x18f3a
jmp 0x8304
addq $0x14, %rcx
leaq 0x11a21(%rip), %rdx     # 0x19ae6
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10e5e(%rip), %rdx     # 0x18f40
jmp 0x81ee
addq $0x14, %rcx
leaq 0x10e3a(%rip), %rdx     # 0x18f2c
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10e21(%rip), %rdx     # 0x18f30
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x10e12(%rip), %rdx     # 0x18f33
jmp 0x8304
addq $0x14, %rcx
leaq 0x10e05(%rip), %rdx     # 0x18f36
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10dec(%rip), %rdx     # 0x18f3a
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x10dd0(%rip), %rdx     # 0x18f30
jmp 0x8304
addq $0x14, %rcx
leaq 0x10de6(%rip), %rdx     # 0x18f56
jmp 0x822f
addq $0x14, %rcx
leaq 0x10da0(%rip), %rdx     # 0x18f20
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10d87(%rip), %rdx     # 0x18f24
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x10d79(%rip), %rdx     # 0x18f28
jmp 0x8304
cmpl $0x2, %eax
je 0x8281
cmpl $0x1, %eax
jne 0x8319
addq $0x14, %rcx
leaq 0x10d5b(%rip), %rdx     # 0x18f2c
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10d42(%rip), %rdx     # 0x18f30
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x10d4b(%rip), %rdx     # 0x18f4b
jmp 0x8304
addq $0x14, %rcx
leaq 0x10d43(%rip), %rdx     # 0x18f53
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x118bc(%rip), %rdx     # 0x19ade
jmp 0x8241
addq $0x14, %rcx
leaq 0x10d2a(%rip), %rdx     # 0x18f59
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x10cf2(%rip), %rdx     # 0x18f33
pushq $0x18
jmp 0x8306
orl $-0x1, (%rcx)
movslq (%rbx), %rax
movq (%r14,%rax,8), %rax
orl $-0x1, 0x18(%rax)
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x1c, %rcx
leaq 0x11b80(%rip), %rdx     # 0x19de8
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x11906(%rip), %rdx     # 0x19b80
pushq $0x20
jmp 0x8306
addq $0x14, %rcx
leaq 0x10caa(%rip), %rdx     # 0x18f36
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10ca2(%rip), %rdx     # 0x18f4b
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x10c94(%rip), %rdx     # 0x18f4f
jmp 0x8304
addq $0x14, %rcx
leaq 0x10c7b(%rip), %rdx     # 0x18f43
jmp 0x82d5
addq $0x14, %rcx
leaq 0x10c72(%rip), %rdx     # 0x18f47
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10c4e(%rip), %rdx     # 0x18f40
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
leaq 0x10c39(%rip), %rdx     # 0x18f3d
pushq $0x1c
popq %rcx
movslq (%rbx), %rax
addq (%r14,%rax,8), %rcx
movq %r12, %rdi
movl %r15d, %esi
callq 0x4777
movslq (%rbx), %rax
movq (%r14,%rax,8), %rdi
cmpl $-0x1, 0x20(%rdi)
je 0x8340
cmpl $-0x1, 0x14(%rdi)
je 0x8340
cmpl $-0x1, 0x18(%rdi)
je 0x8340
testl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jne 0x8356
cmpl $-0x1, 0x1c(%rdi)
jne 0x8356
callq 0x2040
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incl %eax
movl %eax, (%rbx)
pushq $0x1
popq %rax
jmp 0x8347