// File: /workspace/github_c_makefile_star2_O1/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 0xa010(%rip), %xmm0     # 0x1a1e0
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 0xa1d5(%rip), %xmm0     # 0x1a3e8
leaq 0x50(%rsp), %r15
movaps %xmm0, (%r15)
movups 0xa1d0(%rip), %xmm0     # 0x1a3f3
movups %xmm0, 0xb(%r15)
movq %r15, %rdi
callq 0x20b0
movups 0xa1cc(%rip), %xmm0     # 0x1a403
movups %xmm0, 0x50(%rsp,%rax)
movups 0xa1cc(%rip), %xmm0     # 0x1a40f
movups %xmm0, 0x5c(%rsp,%rax)
movq %r15, %rdi
callq 0x20b0
movabsq $0x2d2d2d2d2d2d2d, %rcx # imm = 0x2D2D2D2D2D2D2D
movq %rcx, 0x5d(%rsp,%rax)
movups 0xa1b9(%rip), %xmm0     # 0x1a41f
movups %xmm0, 0x50(%rsp,%rax)
leaq 0x870(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x112df
testl %ebp, %ebp
jle 0x105c7
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 0x105b4
movq %r12, %rdi
leaq 0x9f8d(%rip), %rsi      # 0x1a257
movq %r14, %rdx
callq 0x112df
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 0x517a
movsbl %al, %ecx
movq %rbp, %rdi
leaq 0xa126(%rip), %rsi      # 0x1a434
movq %r13, %rdx
xorl %eax, %eax
callq 0x2220
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x112df
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 0x105b4
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 0x9ecc(%rip), %rsi      # 0x1a257
movq %r14, %rdx
callq 0x112df
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 0x1041e
xorl %r15d, %r15d
movl $0x1, %r12d
testl %r15d, %r15d
je 0x10402
movl %r12d, %eax
movl $0xcccccccd, %ecx       # imm = 0xCCCCCCCD
imulq %rcx, %rax
shrq $0x23, %rax
leal (%rax,%rax,4), %eax
leal -0x1(,%rax,2), %eax
movw $0x2e, %bx
cmpl %r15d, %eax
je 0x10406
movw $0x20, %bx
movq %rbp, %rdi
callq 0x20b0
movw %bx, 0x50(%rsp,%rax)
incl %r15d
incl %r12d
cmpl %r15d, %r14d
jne 0x103da
imull $0x32, 0xc(%rsp), %r12d
leal (%r14,%r12), %r15d
leaq 0x870(%rsp), %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %rdx
callq 0x112df
orl $0x1, %r12d
movq %rbp, %rdi
leaq 0x9fff(%rip), %rsi      # 0x1a44a
movl %r12d, %edx
xorl %eax, %eax
callq 0x2220
movl $0x32, %r12d
movq 0x18(%rsp), %rbx
cmpl %ebx, %r15d
jle 0x10494
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 0x4ba4
movb %al, 0x460(%rsp)
movb $0x0, 0x461(%rsp)
jmp 0x1049e
movw $0x20, 0x460(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2200
incq %rbx
decq %r12
jne 0x10460
movq %r13, %rdi
leaq 0xa1a6(%rip), %rsi      # 0x1a661
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 0x112df
movabsq $0x2020202020525453, %rax # imm = 0x2020202020525453
movq %rax, 0x50(%rsp)
movl $0x202020, 0x57(%rsp)   # imm = 0x202020
testl %r14d, %r14d
jle 0x10563
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 0x1053d
movw $0x20, 0x460(%rsp)
jmp 0x1054c
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 0x1051b
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 0x112df
movl 0xc(%rsp), %ebx
incl %ebx
addq $0x32, 0x18(%rsp)
addq $0x190, 0x38(%rsp)      # imm = 0x190
cmpl 0x30(%rsp), %ebx
jne 0x10381
movq 0x10(%rsp), %rcx
incq %rcx
cmpq 0x40(%rsp), %rcx
jne 0x102a9
addq $0xc78, %rsp            # imm = 0xC78
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq