// File: /workspace/github_c_makefile_star2_O2/josch[P]stride/report.c
// Function: ReportHydrBonds
void ReportHydrBonds(CHAIN **Chain, int NChain, HBOND **HBond, FILE *Out,
		     COMMAND *Cmd)
{
  register int i, k, Cn;
  int Cnt, Res;
  BUFFER Bf, Tmp, Tmp1;
  HBOND *p;
  RESIDUE *r;

  PrepareBuffer(Bf,Chain);

  Glue(Bf,"REM",Out);
  sprintf(Tmp,"REM  ------------------ ");
  strcat(Tmp,"Mainchain hydrogen bonds");
  strcat(Tmp," ------------------------");
  Glue(Bf,Tmp,Out);
  Glue(Bf,"REM",Out);

  Glue(Bf,"REM  Definition of Stickle et al., J.Mol.Biol. 226:1143-1159, 1992",Out);
  Glue(Bf,"REM  A1 is the angle between the planes of donor complex and O..N-C",Out);
  Glue(Bf,"REM  A2 is the angle between the planes of acceptor complex and N..O=C",Out);
  Glue(Bf,"REM",Out);

  sprintf(Tmp,"HBT  %-6d",Chain[0]->NHydrBondTotal);
  Glue(Bf,Tmp,Out);
  sprintf(Tmp,"HBI  %-6d",Chain[0]->NHydrBondInterchain);
  Glue(Bf,Tmp,Out);
  for( Cn=0; Cn<NChain; Cn++ )
    if( Chain[Cn]->Valid ) {

      sprintf(Tmp,"HBC  %-6d  %s %c %4d",
	      Chain[Cn]->NHydrBond,Chain[Cn]->File,SpaceToDash(Chain[Cn]->Id),Chain[Cn]->NRes);
      Glue(Bf,Tmp,Out);
    }
  Glue(Bf,"REM",Out);

  Glue(Bf,"REM  |--Residue 1--|     |--Residue 2--|  N-O N..O=C O..N-C     A1     A2",Out);

  for( Cn=0; Cn<NChain; Cn++ ) {

    if( !Chain[Cn]->Valid )
      continue;
    
    for( i=0; i<Chain[Cn]->NRes; i++ ) {

      r = Chain[Cn]->Rsd[i];

      Cnt = 0;
      for( k=0; k<r->Inv->NBondDnr; k++ ) {
	p = HBond[r->Inv->HBondDnr[k]];
	if( p->ExistHydrBondRose ) {
	  Res = p->Acc->A_Res;
	  sprintf(Tmp,"DNR %4s %c %4s %4d -> ",
		  r->ResType,SpaceToDash(Chain[Cn]->Id),r->PDB_ResNumb,i);

	  sprintf(Tmp1,"%4s %c %4s %4d %4.1f %6.1f %6.1f %6.1f %6.1f ",
		  p->Acc->Chain->Rsd[Res]->ResType,
		  /* patch replace SpaceToDash(Chain[Cn]->Id), */
		  SpaceToDash(p->Acc->Chain->Id),
		  p->Acc->Chain->Rsd[Res]->PDB_ResNumb,Res,p->AccDonDist,p->AccAng,
		  p->DonAng,p->AccDonAng,p->DonAccAng);
	  strcat(Tmp,Tmp1);
	  Glue(Bf,Tmp,Out);
	  Cnt++;
	}
      }

      Cnt = 0;
      for( k=0; k<r->Inv->NBondAcc; k++ ) {
	p = HBond[r->Inv->HBondAcc[k]];
	if( p->ExistHydrBondRose ) {
	  Res = p->Dnr->D_Res;
	  sprintf(Tmp,"ACC %4s %c %4s %4d -> ",
		  r->ResType,SpaceToDash(Chain[Cn]->Id),r->PDB_ResNumb,i);

	  sprintf(Tmp1,"%4s %c %4s %4d %4.1f %6.1f %6.1f %6.1f %6.1f ",
		  p->Dnr->Chain->Rsd[Res]->ResType,
		  /* patch replace SpaceToDash(Chain[Cn]->Id), */
		  SpaceToDash(p->Dnr->Chain->Id),
		  p->Dnr->Chain->Rsd[Res]->PDB_ResNumb,Res,p->AccDonDist,
		  p->AccAng,p->DonAng,p->AccDonAng,p->DonAccAng);
	  strcat(Tmp,Tmp1);
	  Glue(Bf,Tmp,Out);
	  Cnt++;
	}
      }

    }
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc68, %rsp            # imm = 0xC68
movq %rcx, %r13
movq %rdx, 0x38(%rsp)
movl %esi, %ebp
movq %rdi, %r14
leaq 0x450(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x111b7
leaq 0x84c1(%rip), %r12      # 0x19217
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x111f1
movups 0x8781(%rip), %xmm0     # 0x194ec
leaq 0x40(%rsp), %r15
movups %xmm0, 0x9(%r15)
movups 0x8767(%rip), %xmm0     # 0x194e3
movaps %xmm0, (%r15)
movq %r15, %rdi
callq 0x20b0
movups 0x876d(%rip), %xmm0     # 0x194fc
movups %xmm0, 0x40(%rsp,%rax)
movups 0x876a(%rip), %xmm0     # 0x19505
movups %xmm0, 0x49(%rsp,%rax)
movq %r15, %rdi
callq 0x20b0
movups 0x8766(%rip), %xmm0     # 0x19515
movups %xmm0, 0x40(%rsp,%rax)
movups 0x8764(%rip), %xmm0     # 0x1951f
movups %xmm0, 0x4a(%rsp,%rax)
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x111f1
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x111f1
leaq 0x874c(%rip), %rsi      # 0x1952f
movq %rbx, %rdi
movq %r13, %rdx
callq 0x111f1
leaq 0x877d(%rip), %rsi      # 0x19572
movq %rbx, %rdi
movq %r13, %rdx
callq 0x111f1
leaq 0x87af(%rip), %rsi      # 0x195b6
movq %rbx, %rdi
movq %r13, %rdx
callq 0x111f1
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x111f1
movq (%r14), %rax
movl 0x38(%rax), %edx
leaq 0x87d0(%rip), %rsi      # 0x195fd
xorl %r12d, %r12d
movq %r15, %rdi
xorl %eax, %eax
callq 0x2230
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x111f1
movq %r14, 0x8(%rsp)
movq (%r14), %rax
movl 0x34(%rax), %edx
leaq 0x87ad(%rip), %rsi      # 0x19607
movq %r15, %rdi
xorl %eax, %eax
callq 0x2230
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, (%rsp)
movq %r13, %rdx
callq 0x111f1
testl %ebp, %ebp
cmovlel %r12d, %ebp
movq %rbp, 0x10(%rsp)
leaq 0x8789(%rip), %r14      # 0x19611
xorl %r13d, %r13d
movq 0x8(%rsp), %rbx
cmpq %r13, 0x10(%rsp)
je 0x10ee7
movq (%rbx,%r13,8), %rax
cmpl $0x0, 0x58(%rax)
je 0x10ee2
movl 0x30(%rax), %ebp
movq 0x48(%rax), %r12
movsbl 0x40(%rax), %edi
callq 0x4969
movsbl %al, %r8d
movq (%rbx,%r13,8), %rax
movl (%rax), %r9d
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2230
leaq 0x450(%rsp), %rdi
movq %r15, %rsi
movq (%rsp), %rdx
callq 0x111f1
incq %r13
jmp 0x10e90
leaq 0x8329(%rip), %rsi      # 0x19217
leaq 0x450(%rsp), %r14
movq %r14, %rdi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0x111f1
leaq 0x871a(%rip), %rsi      # 0x19626
movq %r14, %rdi
movq %rbx, %rdx
callq 0x111f1
leaq 0x40(%rsp), %r15
xorl %edi, %edi
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rdi
je 0x111a5
movq (%rsi,%rdi,8), %rax
cmpl $0x0, 0x58(%rax)
je 0x1119d
xorl %r13d, %r13d
movq %rdi, 0x18(%rsp)
movslq (%rax), %rcx
cmpq %rcx, %r13
jge 0x1119d
movq 0x68(%rax), %rax
movq (%rax,%r13,8), %rbp
leaq 0xa(%rbp), %rax
movq %rax, 0x28(%rsp)
leaq 0x4(%rbp), %rax
movq %rax, 0x20(%rsp)
xorl %ebx, %ebx
movq %r13, 0x30(%rsp)
movq 0x770(%rbp), %rax
movslq 0x30(%rax), %rcx
cmpq %rcx, %rbx
jge 0x11081
movslq (%rax,%rbx,4), %rax
movq 0x38(%rsp), %rcx
movq (%rcx,%rax,8), %r12
cmpl $0x0, 0x14(%r12)
je 0x11079
movq 0x8(%r12), %rax
movslq 0x8(%rax), %r14
movq (%rsi,%rdi,8), %rax
movsbl 0x40(%rax), %edi
callq 0x4969
movsbl %al, %ecx
movq %r15, %rdi
leaq 0x86af(%rip), %rsi      # 0x19670
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %r8
movl %r13d, %r9d
xorl %eax, %eax
callq 0x2230
movq 0x8(%r12), %rax
movq (%rax), %rax
movq 0x68(%rax), %rcx
movq (%rcx,%r14,8), %r13
addq $0xa, %r13
movsbl 0x40(%rax), %edi
callq 0x4969
movsbl %al, %ecx
movq 0x8(%r12), %rax
movq (%rax), %rax
movq 0x68(%rax), %rax
movq (%rax,%r14,8), %r8
addq $0x4, %r8
cvtss2sd 0x38(%r12), %xmm0
cvtss2sd 0x48(%r12), %xmm1
cvtss2sd 0x4c(%r12), %xmm2
cvtss2sd 0x50(%r12), %xmm3
cvtss2sd 0x54(%r12), %xmm4
leaq 0x860(%rsp), %r12
movq %r12, %rdi
leaq 0x8649(%rip), %rsi      # 0x19687
movq %r13, %rdx
movq 0x30(%rsp), %r13
movl %r14d, %r9d
movb $0x5, %al
callq 0x2230
movq %r15, %rdi
movq %r12, %rsi
callq 0x2210
leaq 0x450(%rsp), %rdi
movq %r15, %rsi
movq (%rsp), %rdx
callq 0x111f1
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
incq %rbx
jmp 0x10f71
xorl %ebx, %ebx
movslq 0x34(%rax), %rcx
cmpq %rcx, %rbx
jge 0x11191
movslq 0x18(%rax,%rbx,4), %rcx
movq 0x38(%rsp), %rdx
movq (%rdx,%rcx,8), %r12
cmpl $0x0, 0x14(%r12)
je 0x11189
movq (%r12), %rax
movslq 0x8(%rax), %r14
movq (%rsi,%rdi,8), %rax
movsbl 0x40(%rax), %edi
callq 0x4969
movsbl %al, %ecx
movq %r15, %rdi
leaq 0x85e9(%rip), %rsi      # 0x196b5
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %r8
movl %r13d, %r9d
xorl %eax, %eax
callq 0x2230
movq (%r12), %rax
movq (%rax), %rax
movq 0x68(%rax), %rcx
movq (%rcx,%r14,8), %r13
addq $0xa, %r13
movsbl 0x40(%rax), %edi
callq 0x4969
movsbl %al, %ecx
movq (%r12), %rax
movq (%rax), %rax
movq 0x68(%rax), %rax
movq (%rax,%r14,8), %r8
addq $0x4, %r8
cvtss2sd 0x38(%r12), %xmm0
cvtss2sd 0x48(%r12), %xmm1
cvtss2sd 0x4c(%r12), %xmm2
cvtss2sd 0x50(%r12), %xmm3
cvtss2sd 0x54(%r12), %xmm4
leaq 0x860(%rsp), %r12
movq %r12, %rdi
leaq 0x8540(%rip), %rsi      # 0x19687
movq %r13, %rdx
movq 0x30(%rsp), %r13
movl %r14d, %r9d
movb $0x5, %al
callq 0x2230
movq %r15, %rdi
movq %r12, %rsi
callq 0x2210
leaq 0x450(%rsp), %rdi
movq %r15, %rsi
movq (%rsp), %rdx
callq 0x111f1
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x770(%rbp), %rax
incq %rbx
jmp 0x11083
incq %r13
movq (%rsi,%rdi,8), %rax
jmp 0x10f44
incq %rdi
jmp 0x10f23
addq $0xc68, %rsp            # imm = 0xC68
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq