// File: /workspace/github_c_makefile_star2_O1/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 0x595c
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 0x9032
movl 0x40(%rsp), %eax
movl %r13d, %edx
leaq 0x111a9(%rip), %rsi     # 0x19ecc
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
addq $0x14, %rcx
testl %r15d, %r15d
je 0x8f59
leaq 0x10bce(%rip), %rdx     # 0x1990e
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leal -0x1(%r15), %esi
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x11893(%rip), %rdx     # 0x1a5f4
movq %r12, %rdi
callq 0x4f78
jmp 0x8f6a
cmpl $0x3, %eax
je 0x8fe1
cmpl $0x2, %eax
je 0x8fd4
cmpl $0x1, %eax
jne 0x9032
addq $0x14, %rcx
leaq 0x111d1(%rip), %rdx     # 0x19f65
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x111b7(%rip), %rdx     # 0x19f68
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x1119f(%rip), %rdx     # 0x19f62
jmp 0x901b
addq $0x14, %rcx
leaq 0x11d73(%rip), %rdx     # 0x1ab46
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x11178(%rip), %rdx     # 0x19f68
jmp 0x8efc
addq $0x14, %rcx
leaq 0x11154(%rip), %rdx     # 0x19f54
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x1113b(%rip), %rdx     # 0x19f58
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x1112c(%rip), %rdx     # 0x19f5b
jmp 0x901b
addq $0x14, %rcx
leaq 0x1111f(%rip), %rdx     # 0x19f5e
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x11106(%rip), %rdx     # 0x19f62
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x110ea(%rip), %rdx     # 0x19f58
jmp 0x901b
addq $0x14, %rcx
leaq 0x11100(%rip), %rdx     # 0x19f7e
jmp 0x8f3d
addq $0x14, %rcx
leaq 0x110ba(%rip), %rdx     # 0x19f48
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x110a1(%rip), %rdx     # 0x19f4c
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x11093(%rip), %rdx     # 0x19f50
jmp 0x901b
cmpl $0x2, %eax
je 0x8f98
cmpl $0x1, %eax
jne 0x9032
addq $0x14, %rcx
leaq 0x11075(%rip), %rdx     # 0x19f54
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x1105c(%rip), %rdx     # 0x19f58
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x11065(%rip), %rdx     # 0x19f73
jmp 0x901b
addq $0x14, %rcx
leaq 0x1105d(%rip), %rdx     # 0x19f7b
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x11c0e(%rip), %rdx     # 0x1ab3e
jmp 0x8f4f
addq $0x14, %rcx
leaq 0x11044(%rip), %rdx     # 0x19f81
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x1100c(%rip), %rdx     # 0x19f5b
movl $0x18, %ecx
jmp 0x9020
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, (%rcx)
movslq (%rbx), %rcx
movq (%r14,%rcx,8), %rcx
movl %eax, 0x18(%rcx)
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x1c, %rcx
leaq 0x11ecc(%rip), %rdx     # 0x1ae48
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x11c52(%rip), %rdx     # 0x1abe0
movl $0x20, %ecx
jmp 0x9020
addq $0x14, %rcx
leaq 0x10fbb(%rip), %rdx     # 0x19f5e
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10fb3(%rip), %rdx     # 0x19f73
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x10fa5(%rip), %rdx     # 0x19f77
jmp 0x901b
addq $0x14, %rcx
leaq 0x10f8c(%rip), %rdx     # 0x19f6b
jmp 0x8fec
addq $0x14, %rcx
leaq 0x10f83(%rip), %rdx     # 0x19f6f
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
movslq (%rbx), %rax
movq (%r14,%rax,8), %rcx
addq $0x18, %rcx
leaq 0x10f5f(%rip), %rdx     # 0x19f68
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
leaq 0x10f4a(%rip), %rdx     # 0x19f65
movl $0x1c, %ecx
movslq (%rbx), %rax
addq (%r14,%rax,8), %rcx
movq %r12, %rdi
movl %r15d, %esi
callq 0x4f78
movslq (%rbx), %rax
movq (%r14,%rax,8), %rdi
cmpl $-0x1, 0x20(%rdi)
je 0x9059
cmpl $-0x1, 0x14(%rdi)
je 0x9059
cmpl $-0x1, 0x18(%rdi)
je 0x9059
testl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jne 0x906f
cmpl $-0x1, 0x1c(%rdi)
jne 0x906f
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 0x9060