// File: /workspace/github_c_makefile_star2_O2/josch[P]stride/report.c
// Function: ReportSummary
void ReportSummary(CHAIN **Chain, int NChain, FILE *Out, COMMAND *Cmd)
{
  int Cn, Width, CurrWidth, NBlocks, Tail, i, j, From, To;
  BUFFER Bf, Tmp, Tmp1;

  PrepareBuffer(Bf,Chain);

  sprintf(Tmp,"REM  -------------------- ");
  strcat(Tmp,"Secondary structure summary");
  strcat(Tmp," -------------------");
  Glue(Bf,Tmp,Out);

  for( Cn=0; Cn<NChain; Cn++ ) {

    if( !Chain[Cn]->Valid )
      continue;

    Width = 50;

    Glue(Bf,"REM",Out);

    strncpy(Tmp1,Chain[Cn]->File,40);
    Tmp1[40] = '\0';
    sprintf(Tmp,"CHN  %s %c",Tmp1,SpaceToDash(Chain[Cn]->Id));
    Glue(Bf,Tmp,Out);

    NBlocks = Chain[Cn]->NRes/Width;
    Tail = Chain[Cn]->NRes % Width;
    if( Tail ) NBlocks++;
    
    for( i=0; i<NBlocks; i++ ) {

      Glue(Bf,"REM",Out);
      From = i*Width;
      if( i == NBlocks-1 && Tail ) 
	CurrWidth = Tail;
      else
	CurrWidth = Width;
      To   = From+CurrWidth;

      sprintf(Tmp,"REM       ");
      for( j=0; j<CurrWidth; j++ )
	if( j && (j+1)%10 == 0 )
	  strcat(Tmp,".");
	else
	  strcat(Tmp," ");
      Glue(Bf,Tmp,Out);

      sprintf(Tmp,"SEQ  %-4d ",From+1);
      for( j=From; j<From+Width; j++ ) {
	if( j < To )
	  sprintf(Tmp1,"%c",ThreeToOne(Chain[Cn]->Rsd[j]->ResType));
	else
	  sprintf(Tmp1," ");
	strcat(Tmp,Tmp1);
      }
      sprintf(Tmp1," %4d",To);
      strcat(Tmp,Tmp1);
      Glue(Bf,Tmp,Out);

      sprintf(Tmp,"STR       ");
      for( j=From; j<To; j++ ) {
	if( Chain[Cn]->Rsd[j]->Prop->Asn == 'C' )
	  sprintf(Tmp1," ");
	else
	  sprintf(Tmp1,"%c",Chain[Cn]->Rsd[j]->Prop->Asn);
	strcat(Tmp,Tmp1);
      }
      strcat(Tmp,"     ");
      Glue(Bf,Tmp,Out);
    }

  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc68, %rsp            # imm = 0xC68
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %rsi
leaq 0x860(%rsp), %r14
movq %r14, %rdi
movq %rsi, 0x8(%rsp)
callq 0x111b7
movups 0x90f9(%rip), %xmm0     # 0x193b3
leaq 0x40(%rsp), %r12
movups %xmm0, 0xb(%r12)
movups 0x90dc(%rip), %xmm0     # 0x193a8
movaps %xmm0, (%r12)
movq %r12, %rdi
callq 0x20b0
movups 0x90e3(%rip), %xmm0     # 0x193c3
movups %xmm0, 0x40(%rsp,%rax)
movups 0x90e3(%rip), %xmm0     # 0x193cf
movups %xmm0, 0x4c(%rsp,%rax)
movq %r12, %rdi
callq 0x20b0
movabsq $0x2d2d2d2d2d2d2d, %rcx # imm = 0x2D2D2D2D2D2D2D
movq %rcx, 0x4d(%rsp,%rax)
movups 0x90d0(%rip), %xmm0     # 0x193df
movups %xmm0, 0x40(%rsp,%rax)
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x111f1
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
movq %rbx, 0x30(%rsp)
xorl %ebx, %ebx
movq %r15, 0x18(%rsp)
cmpq 0x30(%rsp), %rbx
je 0x1064c
movq 0x8(%rsp), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x0, 0x58(%rax)
je 0x10644
leaq 0x860(%rsp), %r13
movq %r13, %rdi
leaq 0x8eb2(%rip), %rsi      # 0x19217
movq %r15, %rdx
callq 0x111f1
movq 0x8(%rsp), %r12
movq (%r12,%rbx,8), %r14
movq 0x48(%r14), %rsi
leaq 0x450(%rsp), %rbp
movq %rbp, %rdi
pushq $0x28
popq %rdx
callq 0x2050
movb $0x0, 0x478(%rsp)
movsbl 0x40(%r14), %edi
callq 0x4969
movsbl %al, %ecx
xorl %r14d, %r14d
leaq 0x40(%rsp), %rdi
leaq 0x9043(%rip), %rsi      # 0x193f4
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2230
movq %r13, %rdi
leaq 0x40(%rsp), %rsi
movq %r15, %rdx
callq 0x111f1
movq (%r12,%rbx,8), %rax
movl (%rax), %eax
cltd
pushq $0x32
popq %rcx
idivl %ecx
movl %eax, %ecx
movl %edx, 0x14(%rsp)
cmpl $0x1, %edx
sbbl $-0x1, %ecx
leal -0x1(%rcx), %eax
movl %eax, 0x10(%rsp)
testl %ecx, %ecx
movl $0x0, %eax
movq %rax, 0x20(%rsp)
cmovlel %r14d, %ecx
movq %rcx, 0x38(%rsp)
xorl %eax, %eax
xorl %ebp, %ebp
cmpl 0x38(%rsp), %ebp
je 0x10644
movq %rax, 0x28(%rsp)
leaq 0x860(%rsp), %rdi
leaq 0x8df6(%rip), %rsi      # 0x19217
movq %r15, %rdx
callq 0x111f1
movl %ebp, 0x4(%rsp)
cmpl 0x10(%rsp), %ebp
pushq $0x32
popq %rax
movl %eax, %r12d
movl 0x14(%rsp), %ecx
cmovel %ecx, %r12d
testl %ecx, %ecx
cmovel %eax, %r12d
movabsq $0x20202020204d4552, %rax # imm = 0x20202020204D4552
movq %rax, 0x40(%rsp)
movl $0x202020, 0x47(%rsp)   # imm = 0x202020
xorl %r14d, %r14d
testl %r12d, %r12d
movl $0x0, %r15d
cmovgl %r12d, %r15d
pushq $0x1
popq %rbp
movl %ebp, %eax
xorl %edx, %edx
pushq $0xa
popq %rcx
divl %ecx
cmpl %r14d, %r15d
je 0x104b3
testl %r14d, %r14d
je 0x10497
imull $0xa, %eax, %eax
decl %eax
cmpl %r14d, %eax
pushq $0x20
popq %r13
pushq $0x2e
popq %rax
cmovel %eax, %r13d
jmp 0x1049c
movw $0x20, %r13w
leaq 0x40(%rsp), %rdi
callq 0x20b0
movw %r13w, 0x40(%rsp,%rax)
incl %r14d
incl %ebp
jmp 0x1046f
imull $0x32, 0x4(%rsp), %ebp
addl %ebp, %r12d
leaq 0x860(%rsp), %rdi
leaq 0x40(%rsp), %r13
movq %r13, %rsi
movq 0x18(%rsp), %rdx
callq 0x111f1
incl %ebp
movq %r13, %rdi
leaq 0x8f29(%rip), %rsi      # 0x1940a
movl %ebp, %edx
xorl %eax, %eax
callq 0x2230
pushq $0x32
popq %r14
movq 0x28(%rsp), %rbp
movq %rbp, %r15
subq $0x1, %r14
jb 0x1054b
cmpl %r15d, %r12d
jle 0x1052c
movq 0x8(%rsp), %rax
movq (%rax,%rbx,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%r15,8), %rdi
addq $0xa, %rdi
callq 0x43b0
movb %al, 0x450(%rsp)
movb $0x0, 0x451(%rsp)
jmp 0x10536
movw $0x20, 0x450(%rsp)
movq %r13, %rdi
leaq 0x450(%rsp), %rsi
callq 0x2210
incq %r15
jmp 0x104f6
leaq 0x450(%rsp), %r14
movq %r14, %rdi
leaq 0x90c4(%rip), %rsi      # 0x19621
movl %r12d, %edx
xorl %eax, %eax
callq 0x2230
movq %r13, %rdi
movq %r14, %rsi
callq 0x2210
leaq 0x860(%rsp), %rdi
movq %r13, %rsi
movq 0x18(%rsp), %r15
movq %r15, %rdx
callq 0x111f1
movabsq $0x2020202020525453, %rax # imm = 0x2020202020525453
movq %rax, 0x40(%rsp)
movl $0x202020, 0x47(%rsp)   # imm = 0x202020
movq 0x20(%rsp), %r14
cmpl %ebp, %r12d
jle 0x105fd
movq 0x8(%rsp), %rax
movq (%rax,%rbx,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%r14), %rax
movq 0x768(%rax), %rax
movb 0x1c(%rax), %al
cmpb $0x43, %al
jne 0x105d6
movw $0x20, 0x450(%rsp)
jmp 0x105e5
movb %al, 0x450(%rsp)
movb $0x0, 0x451(%rsp)
movq %r13, %rdi
leaq 0x450(%rsp), %rsi
callq 0x2210
addq $0x8, %r14
incl %ebp
jmp 0x105a6
movq %r13, %rdi
callq 0x20b0
movl $0x20202020, 0x40(%rsp,%rax) # imm = 0x20202020
movw $0x20, 0x44(%rsp,%rax)
leaq 0x860(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x111f1
movl 0x4(%rsp), %ebp
incl %ebp
movq 0x28(%rsp), %rax
addq $0x32, %rax
addq $0x190, 0x20(%rsp)      # imm = 0x190
jmp 0x10403
incq %rbx
jmp 0x10335
addq $0xc68, %rsp            # imm = 0xC68
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq