// File: /workspace/github_c_makefile_star2_O3/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
movl $0x30, %edi
callq 0x5880
movslq (%rbx), %rcx
movq %rax, (%r14,%rcx,8)
movq %r12, (%rax)
movq (%r14,%rcx,8), %rax
movl %r15d, 0x8(%rax)
testl %r13d, %r13d
je 0x8c33
movslq (%rbx), %rax
movq (%r14,%rax,8), %rax
movl %r15d, 0xc(%rax)
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)
decl %r13d
cmpl $0x8, %r13d
ja 0x8f36
movl 0x40(%rsp), %eax
leaq 0x112f1(%rip), %rdx     # 0x19edc
movslq (%rdx,%r13,4), %rsi
addq %rdx, %rsi
jmpq *%rsi
addq $0x14, %rcx
leaq 0x11351(%rip), %rdx     # 0x19f50
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x11338(%rip), %rdx     # 0x19f54
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x1132a(%rip), %rdx     # 0x19f58
jmp 0x8f1f
leal -0x1(%r15), %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 $0x0, 0x28(%rax)
movslq (%rbx), %rax
movq (%r14,%rax,8), %rax
leaq 0x14(%rax), %rcx
movl %r15d, %r13d
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x2c(%rax)
subl $0x1, %r13d
jae 0x8c96
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, (%rcx)
movslq (%rbx), %rcx
movq (%r14,%rcx,8), %rcx
movl %eax, 0x18(%rcx)
jmp 0x8cc5
leaq 0x10c81(%rip), %rdx     # 0x1991e
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x1192a(%rip), %rdx     # 0x1a5e4
movq %r12, %rdi
movl %r13d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x1c, %rcx
leaq 0x12161(%rip), %rdx     # 0x1ae38
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x11ee7(%rip), %rdx     # 0x1abd0
movl $0x20, %ecx
jmp 0x8f24
cmpl $0x2, %eax
je 0x8e9c
cmpl $0x1, %eax
jne 0x8f36
addq $0x14, %rcx
leaq 0x1124c(%rip), %rdx     # 0x19f5c
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x11233(%rip), %rdx     # 0x19f60
jmp 0x8e85
addq $0x14, %rcx
leaq 0x11229(%rip), %rdx     # 0x19f66
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x11210(%rip), %rdx     # 0x19f6a
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x111f4(%rip), %rdx     # 0x19f60
jmp 0x8f1f
cmpl $0x3, %eax
je 0x8ee5
cmpl $0x2, %eax
je 0x8ed8
cmpl $0x1, %eax
jne 0x8f36
addq $0x14, %rcx
leaq 0x111d6(%rip), %rdx     # 0x19f6d
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x111bc(%rip), %rdx     # 0x19f70
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x111a4(%rip), %rdx     # 0x19f6a
jmp 0x8f1f
addq $0x14, %rcx
leaq 0x111b3(%rip), %rdx     # 0x19f89
jmp 0x8e41
addq $0x14, %rcx
leaq 0x11179(%rip), %rdx     # 0x19f5c
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x11160(%rip), %rdx     # 0x19f60
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x11151(%rip), %rdx     # 0x19f63
jmp 0x8f1f
addq $0x14, %rcx
leaq 0x11161(%rip), %rdx     # 0x19f83
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x11cfa(%rip), %rdx     # 0x1ab2e
jmp 0x8e53
addq $0x14, %rcx
leaq 0x11145(%rip), %rdx     # 0x19f86
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x11110(%rip), %rdx     # 0x19f63
movl $0x18, %ecx
jmp 0x8f24
addq $0x14, %rcx
leaq 0x11cce(%rip), %rdx     # 0x1ab36
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x110eb(%rip), %rdx     # 0x19f70
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x110e4(%rip), %rdx     # 0x19f7b
jmp 0x8f1f
addq $0x14, %rcx
leaq 0x110bf(%rip), %rdx     # 0x19f66
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x110b7(%rip), %rdx     # 0x19f7b
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x110a9(%rip), %rdx     # 0x19f7f
jmp 0x8f1f
addq $0x14, %rcx
leaq 0x11090(%rip), %rdx     # 0x19f73
jmp 0x8ef0
addq $0x14, %rcx
leaq 0x11087(%rip), %rdx     # 0x19f77
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x11063(%rip), %rdx     # 0x19f70
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
leaq 0x1104e(%rip), %rdx     # 0x19f6d
movl $0x1c, %ecx
movslq (%rbx), %rax
addq (%r14,%rax,8), %rcx
movq %r12, %rdi
movl %r15d, %esi
callq 0x4ea0
movslq (%rbx), %rax
movq (%r14,%rax,8), %rdi
cmpl $-0x1, 0x20(%rdi)
je 0x8f5d
cmpl $-0x1, 0x14(%rdi)
je 0x8f5d
cmpl $-0x1, 0x18(%rdi)
je 0x8f5d
testl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jne 0x8f73
cmpl $-0x1, 0x1c(%rdi)
jne 0x8f73
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)
movl $0x1, %eax
jmp 0x8f64