// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
addq $0x80, %rdi
callq 0x83b30
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0x3c5a8
movsd 0xd50(%r14), %xmm2
movsd 0xd58(%r14), %xmm1
movsd (%rsp), %xmm4
divsd %xmm4, %xmm2
movsd 0x109b72(%rip), %xmm3   # 0x151628
mulsd %xmm3, %xmm2
movsd %xmm2, 0x10(%rsp)
divsd %xmm0, %xmm2
movsd %xmm2, 0x18(%rsp)
divsd %xmm4, %xmm1
mulsd %xmm3, %xmm1
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x8(%rsp)
divsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
leaq 0x10d1f6(%rip), %rsi    # 0x154ce5
movl $0x2, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x47b19
movq %r15, %rdi
callq 0x41e0
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x47b30
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
leaq 0x10da9f(%rip), %r15    # 0x1555d6
movl $0x1, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0x109d64(%rip), %rsi    # 0x1518b2
movl $0x11, %edx
movq %rbx, %rdi
callq 0x44e0
movq %rbx, %rdi
movsd (%rsp), %xmm0
callq 0x46b0
movq %rax, %r12
leaq 0x109d52(%rip), %rsi    # 0x1518c4
movl $0xc, %edx
movq %rax, %rdi
callq 0x44e0
movq %r12, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x46b0
leaq 0x10594a(%rip), %rsi    # 0x14d4de
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x10a446(%rip), %rsi    # 0x151fee
movl $0x9, %edx
movq %rbx, %rdi
callq 0x44e0
movsd 0xd50(%r14), %xmm0
movq %rbx, %rdi
callq 0x46b0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0x10a419(%rip), %rsi    # 0x151ff9
movl $0xe, %edx
movq %r12, %rdi
callq 0x44e0
movq %r12, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x46b0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0x10a3f4(%rip), %rsi    # 0x152009
movl $0xb, %edx
movq %r12, %rdi
callq 0x44e0
movq %r12, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x46b0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0x10a3a3(%rip), %rsi    # 0x151fed
movl $0xa, %edx
movq %r12, %rdi
callq 0x44e0
movsd 0xd58(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0x10a376(%rip), %rsi    # 0x151ff8
movl $0xf, %edx
movq %r12, %rdi
callq 0x44e0
movq %r12, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x46b0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0x10a351(%rip), %rsi    # 0x152008
movl $0xc, %edx
movq %r12, %rdi
callq 0x44e0
movq %r12, %rdi
movsd 0x28(%rsp), %xmm0
callq 0x46b0
leaq 0x10b945(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x109c18(%rip), %rsi    # 0x151905
movl $0x14, %edx
movq %rbx, %rdi
callq 0x44e0
movq 0xdc8(%r14), %rsi
subq 0xdc0(%r14), %rsi
sarq $0x3, %rsi
movq %rbx, %rdi
callq 0x42b0
leaq 0x10a31f(%rip), %rsi    # 0x15203a
movl $0x1b, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xdc0(%r14), %rax
cmpq %rax, 0xdc8(%r14)
je 0x47d81
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x105799(%rip), %r15    # 0x14d4df
movsd (%rax,%rcx,8), %xmm0
movq %rbx, %rdi
callq 0x46b0
movl $0x2, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x44e0
movl %ebp, %ecx
movq 0xdc0(%r14), %rax
movq 0xdc8(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x47d46
leaq 0x109ba8(%rip), %rsi    # 0x151930
movl $0x14, %edx
movq %rbx, %rdi
callq 0x44e0
movq 0xde0(%r14), %rsi
subq 0xdd8(%r14), %rsi
sarq $0x3, %rsi
movq %rbx, %rdi
callq 0x42b0
leaq 0x10a2a0(%rip), %rsi    # 0x152056
movl $0x1a, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xdd8(%r14), %rax
cmpq %rax, 0xde0(%r14)
je 0x47e1c
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x1056fe(%rip), %r15    # 0x14d4df
movsd (%rax,%rcx,8), %xmm0
movq %rbx, %rdi
callq 0x46b0
movl $0x2, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x44e0
movl %ebp, %ecx
movq 0xdd8(%r14), %rax
movq 0xde0(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x47de1
leaq 0x10b7fb(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x44e0