// File: 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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movq -0x8(%rbp), %rdi
addq $0x80, %rdi
callq 0xe9390
movsd %xmm0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x74f60
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movsd 0xd50(%rax), %xmm0
divsd -0x28(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd 0x1732f1(%rip), %xmm0   # 0x1f6620
movsd 0x1732f1(%rip), %xmm1   # 0x1f6628
callq 0x58e0
movaps %xmm0, %xmm1
movsd -0xb0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
divsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movsd 0xd58(%rax), %xmm0
divsd -0x28(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd 0x1732a0(%rip), %xmm0   # 0x1f6620
movsd 0x1732a0(%rip), %xmm1   # 0x1f6628
callq 0x58e0
movaps %xmm0, %xmm1
movsd -0xa8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
divsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x17857a(%rip), %rsi    # 0x1fb935
callq 0x5540
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x5540
movq %rax, %rdi
leaq 0x178ed8(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq -0x10(%rbp), %rdi
leaq 0x17349c(%rip), %rsi    # 0x1f6882
callq 0x5540
movq %rax, %rdi
movsd -0x28(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x173492(%rip), %rsi    # 0x1f6894
callq 0x5540
movq %rax, %rdi
movsd -0x30(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x16f069(%rip), %rsi    # 0x1f2487
callq 0x5540
movq -0x10(%rbp), %rdi
leaq 0x173bbc(%rip), %rsi    # 0x1f6fea
callq 0x5540
movq %rax, %rdi
movq -0x8(%rbp), %rax
movsd 0xd50(%rax), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x178e5d(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, %rdi
leaq 0x173b95(%rip), %rsi    # 0x1f6ff5
callq 0x5540
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x178e32(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, %rdi
leaq 0x173b7a(%rip), %rsi    # 0x1f7005
callq 0x5540
movq %rax, %rdi
movsd -0x40(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x178e07(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, %rdi
leaq 0x173b33(%rip), %rsi    # 0x1f6fe9
callq 0x5540
movq %rax, %rdi
movq -0x8(%rbp), %rax
movsd 0xd58(%rax), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x178dd5(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, %rdi
leaq 0x173b0c(%rip), %rsi    # 0x1f6ff4
callq 0x5540
movq %rax, %rdi
movsd -0x48(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x178daa(%rip), %rsi    # 0x1fc2ae
callq 0x5540
movq %rax, %rdi
leaq 0x173af1(%rip), %rsi    # 0x1f7004
callq 0x5540
movq %rax, %rdi
movsd -0x50(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x1760f6(%rip), %rsi    # 0x1f9625
callq 0x5540
testb $0x1, -0x19(%rbp)
je 0x836c0
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x110(%rcx), %eax
jge 0x8364c
movq -0x8(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x64(%rbp), %rsi
callq 0xfcc0
movq %rax, %rsi
addq $0x40, %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x5220
movq -0xc0(%rbp), %rdi
callq 0x46d20
movb %al, -0xb1(%rbp)
jmp 0x835aa
movb -0xb1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0xc4(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x5300
movl -0xc4(%rbp), %eax
cmpl $0x1, %eax
jne 0x8363c
movq -0x8(%rbp), %rdi
addq $0xdf0, %rdi            # imm = 0xDF0
movslq -0x64(%rbp), %rsi
callq 0x85150
movsd (%rax), %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
addq $0xdf0, %rdi            # imm = 0xDF0
movslq -0x64(%rbp), %rsi
callq 0x85150
movsd 0x8(%rax), %xmm0
addsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x8363c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x5300
jmp 0x83875
jmp 0x8363e
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x83555
movsd -0x58(%rbp), %xmm0
movq -0x8(%rbp), %rax
divsd 0xd50(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x60(%rbp), %xmm0
movq -0x8(%rbp), %rax
divsd 0xd58(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x173992(%rip), %rsi    # 0x1f7015
callq 0x5540
movq %rax, %rdi
movsd -0x58(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x16ede8(%rip), %rsi    # 0x1f2487
callq 0x5540
movq %rax, %rdi
movsd -0x60(%rbp), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x175f6a(%rip), %rsi    # 0x1f9625
callq 0x5540
movq -0x10(%rbp), %rdi
leaq 0x17320a(%rip), %rsi    # 0x1f68d5
callq 0x5540
movq %rax, -0xd0(%rbp)
movq -0x8(%rbp), %rdi
addq $0xdc0, %rdi            # imm = 0xDC0
callq 0xf990
movq -0xd0(%rbp), %rdi
movq %rax, %rsi
callq 0x5160
movq %rax, %rdi
leaq 0x173936(%rip), %rsi    # 0x1f7036
callq 0x5540
movl $0x0, -0x98(%rbp)
movl -0x98(%rbp), %eax
movq %rax, -0xd8(%rbp)
movq -0x8(%rbp), %rdi
addq $0xdc0, %rdi            # imm = 0xDC0
callq 0xf990
movq %rax, %rcx
movq -0xd8(%rbp), %rax
cmpq %rcx, %rax
jae 0x8378e
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x8(%rbp), %rdi
addq $0xdc0, %rdi            # imm = 0xDC0
movl -0x98(%rbp), %eax
movl %eax, %esi
callq 0xedb0
movq -0xe0(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x16ed10(%rip), %rsi    # 0x1f2488
callq 0x5540
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x8370f
movq -0x10(%rbp), %rdi
leaq 0x173167(%rip), %rsi    # 0x1f6900
callq 0x5540
movq %rax, -0xe8(%rbp)
movq -0x8(%rbp), %rdi
addq $0xdd8, %rdi            # imm = 0xDD8
callq 0xf990
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
callq 0x5160
movq %rax, %rdi
leaq 0x173884(%rip), %rsi    # 0x1f7052
callq 0x5540
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movq %rax, -0xf0(%rbp)
movq -0x8(%rbp), %rdi
addq $0xdd8, %rdi            # imm = 0xDD8
callq 0xf990
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
jae 0x8385c
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x8(%rbp), %rdi
addq $0xdd8, %rdi            # imm = 0xDD8
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0xedb0
movq -0xf8(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x5980
movq %rax, %rdi
leaq 0x16ec42(%rip), %rsi    # 0x1f2488
callq 0x5540
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x837dd
movq -0x10(%rbp), %rdi
leaq 0x175dbe(%rip), %rsi    # 0x1f9625
callq 0x5540
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x58f0
nopw %cs:(%rax,%rax)