// File: /workspace/github_c_makefile_star2_O3/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 $0xc78, %rsp            # imm = 0xC78
movq %rdx, %r14
movl %esi, %ebp
movaps 0x9e54(%rip), %xmm0     # 0x1a1d0
leaq 0x8bb(%rsp), %r15
movaps %xmm0, -0x4b(%r15)
movaps %xmm0, -0x3b(%r15)
movaps %xmm0, -0x2b(%r15)
movaps %xmm0, -0x1b(%r15)
movaps %xmm0, -0xb(%r15)
movl $0xb0, %esi
movq %rdi, (%rsp)
addq (%rdi), %rsi
movq %r15, %rdi
callq 0x2070
movw $0xa, 0x4(%r15)
movups 0xa019(%rip), %xmm0     # 0x1a3d8
leaq 0x50(%rsp), %r15
movaps %xmm0, (%r15)
movups 0xa014(%rip), %xmm0     # 0x1a3e3
movups %xmm0, 0xb(%r15)
movq %r15, %rdi
callq 0x20b0
movups 0xa010(%rip), %xmm0     # 0x1a3f3
movups %xmm0, 0x50(%rsp,%rax)
movups 0xa010(%rip), %xmm0     # 0x1a3ff
movups %xmm0, 0x5c(%rsp,%rax)
movq %r15, %rdi
callq 0x20b0
movabsq $0x2d2d2d2d2d2d2d, %rcx # imm = 0x2D2D2D2D2D2D2D
movq %rcx, 0x5d(%rsp,%rax)
movups 0x9ffd(%rip), %xmm0     # 0x1a40f
movups %xmm0, 0x50(%rsp,%rax)
leaq 0x870(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x114b3
testl %ebp, %ebp
jle 0x1077b
movl %ebp, %eax
movq %rax, 0x40(%rsp)
leaq 0x870(%rsp), %r12
leaq 0x460(%rsp), %r13
leaq 0x50(%rsp), %rbp
xorl %ecx, %ecx
movq %r14, 0x20(%rsp)
movq (%rsp), %rax
movq %rcx, 0x10(%rsp)
movq (%rax,%rcx,8), %rax
cmpl $0x0, 0x58(%rax)
je 0x10768
movq %r12, %rdi
leaq 0x9dd1(%rip), %rsi      # 0x1a247
movq %r14, %rdx
callq 0x114b3
movq 0x10(%rsp), %r15
movq (%rsp), %rax
movq (%rax,%r15,8), %rbx
movq 0x48(%rbx), %rsi
movl $0x28, %edx
movq %r13, %rdi
callq 0x2050
movb $0x0, 0x488(%rsp)
movsbl 0x40(%rbx), %edi
callq 0x50a2
movsbl %al, %ecx
movq %rbp, %rdi
leaq 0x9f6a(%rip), %rsi      # 0x1a424
movq %r13, %rdx
xorl %eax, %eax
callq 0x2220
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x114b3
movq (%rsp), %rax
movq (%rax,%r15,8), %rax
movslq (%rax), %rdx
imulq $0x51eb851f, %rdx, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x24, %rax
addl %ecx, %eax
imull $0x32, %eax, %ecx
xorl %esi, %esi
subl %ecx, %edx
movq %rdx, 0x48(%rsp)
setne %sil
addl %eax, %esi
movq %rsi, 0x30(%rsp)
jle 0x10768
movq 0x30(%rsp), %rax
decl %eax
movl %eax, 0x2c(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x18(%rsp)
xorl %ebx, %ebx
movq %r12, %rdi
leaq 0x9d10(%rip), %rsi      # 0x1a247
movq %r14, %rdx
callq 0x114b3
movl %ebx, 0xc(%rsp)
cmpl 0x2c(%rsp), %ebx
movl $0x32, %r14d
movq 0x48(%rsp), %rax
cmovel %eax, %r14d
testl %eax, %eax
movl $0x32, %eax
cmovel %eax, %r14d
movabsq $0x20202020204d4552, %rax # imm = 0x20202020204D4552
movq %rax, 0x50(%rsp)
movl $0x202020, 0x57(%rsp)   # imm = 0x202020
testl %r14d, %r14d
jle 0x105d2
xorl %r15d, %r15d
movl $0x1, %r12d
testl %r15d, %r15d
je 0x105b6
movl %r12d, %eax
movl $0xcccccccd, %ecx       # imm = 0xCCCCCCCD
imulq %rcx, %rax
shrq $0x23, %rax
leal (%rax,%rax,4), %eax
leal -0x1(,%rax,2), %eax
movl $0x2e, %ebx
cmpl %r15d, %eax
je 0x105ba
movl $0x20, %ebx
jmp 0x105ba
movw $0x20, %bx
movq %rbp, %rdi
callq 0x20b0
movw %bx, 0x50(%rsp,%rax)
incl %r15d
incl %r12d
cmpl %r15d, %r14d
jne 0x10586
imull $0x32, 0xc(%rsp), %r12d
leal (%r14,%r12), %r15d
leaq 0x870(%rsp), %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %rdx
callq 0x114b3
orl $0x1, %r12d
movq %rbp, %rdi
leaq 0x9e3b(%rip), %rsi      # 0x1a43a
movl %r12d, %edx
xorl %eax, %eax
callq 0x2220
movl $0x32, %r12d
movq 0x18(%rsp), %rbx
cmpl %ebx, %r15d
jle 0x10648
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbx,8), %rdi
addq $0xa, %rdi
callq 0x4acc
movb %al, 0x460(%rsp)
movb $0x0, 0x461(%rsp)
jmp 0x10652
movw $0x20, 0x460(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2200
incq %rbx
decq %r12
jne 0x10614
movq %r13, %rdi
leaq 0x9fe2(%rip), %rsi      # 0x1a651
movl %r15d, %edx
xorl %eax, %eax
callq 0x2220
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2200
leaq 0x870(%rsp), %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %rdx
callq 0x114b3
movabsq $0x2020202020525453, %rax # imm = 0x2020202020525453
movq %rax, 0x50(%rsp)
movl $0x202020, 0x57(%rsp)   # imm = 0x202020
testl %r14d, %r14d
jle 0x10717
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rbx
movq 0x18(%rsp), %rax
movl %eax, %r14d
movq 0x38(%rsp), %r12
movq 0x68(%rbx), %rax
movq (%rax,%r12), %rax
movq 0x768(%rax), %rax
movb 0x1c(%rax), %al
cmpb $0x43, %al
jne 0x106f1
movw $0x20, 0x460(%rsp)
jmp 0x10700
movb %al, 0x460(%rsp)
movb $0x0, 0x461(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2200
addq $0x8, %r12
incl %r14d
cmpl %r14d, %r15d
jg 0x106cf
movq %rbp, %rdi
callq 0x20b0
movl $0x20202020, 0x50(%rsp,%rax) # imm = 0x20202020
movw $0x20, 0x54(%rsp,%rax)
leaq 0x870(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %r14
movq %r14, %rdx
callq 0x114b3
movl 0xc(%rsp), %ebx
incl %ebx
addq $0x32, 0x18(%rsp)
addq $0x190, 0x38(%rsp)      # imm = 0x190
cmpl 0x30(%rsp), %ebx
jne 0x1052d
movq 0x10(%rsp), %rcx
incq %rcx
cmpq 0x40(%rsp), %rcx
jne 0x10455
addq $0xc78, %rsp            # imm = 0xC78
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq