// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/area_and_volume.cc
// Function: NEWcalcASAprint(MATERIAL*, std::ostream&, char*)
void NEWcalcASAprint(MATERIAL *Mat, ostream &output, char *filename) {

  bool ExtendedOutputFlag = false;

  double ucVolume    = calcDeterminant(Mat->atmnet.ucVectors);   
  double rho_crystal = calcDensity(&(Mat->atmnet));
  double saPerVolume = (Mat->ASAtotal/ucVolume)*pow(10.0,4.0); // Units of m^2/cm^3
  double saPerMass   = saPerVolume/rho_crystal;          // Units of m^2/g

  double saPerVolume_inaxs = (Mat->ASAtotal_inaxs/ucVolume)*pow(10.0,4.0); // Units of m^2/cm^3
  double saPerMass_inaxs   = saPerVolume_inaxs/rho_crystal;          // Units of m^2/g

  output << "@ " << filename << " ";
  output << "Unitcell_volume: " << ucVolume << "   Density: " << rho_crystal << "   ";
  output << "ASA_A^2: " << Mat->ASAtotal << " "
         << "ASA_m^2/cm^3: " << saPerVolume << " "
         << "ASA_m^2/g: " << saPerMass << " "
         << "NASA_A^2: " << Mat->ASAtotal_inaxs << " "
         << "NASA_m^2/cm^3: " << saPerVolume_inaxs << " "
         << "NASA_m^2/g: " << saPerMass_inaxs << "\n";

  // Surface composition histogram
  if(ExtendedOutputFlag){
    double metalFrac = 0, metalFrac_inaxs = 0;

    for(int i = 0; i < Mat->atmnet.numAtoms; i++)
       {
       if(isMetal(Mat->atmnet.atoms[i].type) == true) 
         {
         metalFrac+= Mat->ASAhistogramSAperAtom.at(i).first;
         metalFrac_inaxs += Mat->ASAhistogramSAperAtom.at(i).second;
         };
       };

    metalFrac = metalFrac / Mat->ASAtotal;
    metalFrac_inaxs = metalFrac_inaxs / Mat->ASAtotal_inaxs;

    output << "Metal fraction in ASA and NASA: " << metalFrac << "   " << metalFrac_inaxs << "\n";
  };

  // extended output
  output << "Number_of_channels: " << Mat->ASA_inChannel.size()  << " Channel_surface_area_A^2: ";
  for(unsigned int i = 0; i < Mat->ASA_inChannel.size(); i++)
    {
    output << Mat->ASA_inChannel[i] << "  ";
    };
  output << "\nNumber_of_pockets: " << Mat->ASA_inPocket.size()  << " Pocket_surface_area_A^2: ";
  for(unsigned int i = 0; i < Mat->ASA_inPocket.size(); i++)
    {
    output << Mat->ASA_inPocket[i] << "  ";
    };
  output << "\n";


}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
addq $0x80, %rdi
callq 0x63835
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0x2d85c
movsd %xmm0, 0x10(%rsp)
movsd 0xd50(%r14), %xmm2
movsd 0xd58(%r14), %xmm1
movsd 0x8(%rsp), %xmm4
divsd %xmm4, %xmm2
movsd 0xca2e6(%rip), %xmm3    # 0x1005a0
mulsd %xmm3, %xmm2
movsd %xmm2, 0x18(%rsp)
divsd %xmm0, %xmm2
movsd %xmm2, 0x20(%rsp)
divsd %xmm4, %xmm1
mulsd %xmm3, %xmm1
movsd %xmm1, 0x28(%rsp)
divsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
leaq 0xcd950(%rip), %rsi     # 0x103c3d
movq %rbx, %rdi
callq 0x4480
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xce20b(%rip), %r15     # 0x104512
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xca509(%rip), %rsi     # 0x100822
movq %rbx, %rdi
callq 0x4480
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x46c0
leaq 0xca4fe(%rip), %rsi     # 0x100834
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x46c0
leaq 0xc617b(%rip), %rsi     # 0xfc4ce
movq %rax, %rdi
callq 0x4480
leaq 0xcabfc(%rip), %rsi     # 0x100f5e
movq %rbx, %rdi
callq 0x4480
movsd 0xd50(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xcabdc(%rip), %rsi     # 0x100f69
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x46c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xcabc4(%rip), %rsi     # 0x100f79
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x46c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xcab80(%rip), %rsi     # 0x100f5d
movq %rax, %rdi
callq 0x4480
movsd 0xd58(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xcab60(%rip), %rsi     # 0x100f68
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movsd 0x28(%rsp), %xmm0
callq 0x46c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xcab48(%rip), %rsi     # 0x100f78
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movsd 0x30(%rsp), %xmm0
callq 0x46c0
leaq 0xcc131(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xca419(%rip), %rsi     # 0x100875
movq %rbx, %rdi
callq 0x4480
movq 0xdc8(%r14), %rsi
subq 0xdc0(%r14), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x42e0
leaq 0xcab25(%rip), %rsi     # 0x100faa
movq %rax, %rdi
callq 0x4480
xorl %eax, %eax
leaq 0xc6039(%rip), %r15     # 0xfc4cf
movl %eax, %r12d
movq 0xdc0(%r14), %rax
movq 0xdc8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
jbe 0x364d3
movsd (%rax,%r12,8), %xmm0
movq %rbx, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leal 0x1(%r12), %eax
jmp 0x36496
leaq 0xca3c6(%rip), %rsi     # 0x1008a0
movq %rbx, %rdi
callq 0x4480
movq 0xde0(%r14), %rsi
subq 0xdd8(%r14), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x42e0
leaq 0xcaac3(%rip), %rsi     # 0x100fc6
movq %rax, %rdi
callq 0x4480
xorl %eax, %eax
leaq 0xc5fbb(%rip), %r15     # 0xfc4cf
movl %eax, %r12d
movq 0xdd8(%r14), %rax
movq 0xde0(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
jbe 0x36551
movsd (%rax,%r12,8), %xmm0
movq %rbx, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leal 0x1(%r12), %eax
jmp 0x36514
leaq 0xcc026(%rip), %rsi     # 0x10257e
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x4480