// File: /workspace/github_cpp_makefile_star2_O1/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 0x84ffd
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0x3c9c8
movsd 0xd50(%r14), %xmm2
movsd 0xd58(%r14), %xmm1
movsd (%rsp), %xmm4
divsd %xmm4, %xmm2
movsd 0x10b241(%rip), %xmm3   # 0x153598
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 0x10e83d(%rip), %rsi    # 0x156bcd
movl $0x2, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x483ba
movq %r15, %rdi
callq 0x41e0
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x483d1
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
leaq 0x10f0ae(%rip), %r15    # 0x157486
movl $0x1, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x44e0
leaq 0x10b413(%rip), %rsi    # 0x153802
movl $0x11, %edx
movq %rbx, %rdi
callq 0x44e0
movq %rbx, %rdi
movsd (%rsp), %xmm0
callq 0x46b0
movq %rax, %r12
leaq 0x10b401(%rip), %rsi    # 0x153814
movl $0xc, %edx
movq %rax, %rdi
callq 0x44e0
movq %r12, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x46b0
leaq 0x107059(%rip), %rsi    # 0x14f48e
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x10baf5(%rip), %rsi    # 0x153f3e
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 0x10bac8(%rip), %rsi    # 0x153f49
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 0x10baa3(%rip), %rsi    # 0x153f59
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 0x10ba52(%rip), %rsi    # 0x153f3d
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 0x10ba25(%rip), %rsi    # 0x153f48
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 0x10ba00(%rip), %rsi    # 0x153f58
movl $0xc, %edx
movq %r12, %rdi
callq 0x44e0
movq %r12, %rdi
movsd 0x28(%rsp), %xmm0
callq 0x46b0
leaq 0x10cfb4(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x10b2c7(%rip), %rsi    # 0x153855
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 0x10b9ce(%rip), %rsi    # 0x153f8a
movl $0x1b, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xdc0(%r14), %rax
cmpq %rax, 0xdc8(%r14)
je 0x48622
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x106ea8(%rip), %r15    # 0x14f48f
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 0x485e7
leaq 0x10b257(%rip), %rsi    # 0x153880
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 0x10b94f(%rip), %rsi    # 0x153fa6
movl $0x1a, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xdd8(%r14), %rax
cmpq %rax, 0xde0(%r14)
je 0x486bd
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x106e0d(%rip), %r15    # 0x14f48f
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 0x48682
leaq 0x10ce6a(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x44e0