// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/sphere_approx.cc
// Function: setupHighAccuracyAtomNetwork(ATOM_NETWORK*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void setupHighAccuracyAtomNetwork(ATOM_NETWORK *atmnet, std::string AccSetting){

 double minr,maxr;

/* analyze the original atom network */
 for(unsigned int i = 0; i < atmnet->atoms.size(); i++)
   {
   if(i == 0) {
     minr = atmnet->atoms.at(i).radius; maxr = minr;
     } else{
     if( atmnet->atoms.at(i).radius < minr) minr = atmnet->atoms.at(i).radius;
     if( atmnet->atoms.at(i).radius > maxr) maxr = atmnet->atoms.at(i).radius;
    };
   };
 
 cout << "Radii analysis: the smallest atom r = " << minr << " while the largest atoms r = " << maxr << ".\n";


 if(minr < SPHERE_APPROX_MIN_R || maxr > SPHERE_APPROX_MAX_R)
   {
   cerr << "HIGH ACCURACY CANNOT BE APPLIED!\n"
        << "The current version of high accuracy routine is using parameters derived from analysis of \n" 
        << "CCDC database. The radii defined for the current system are outside of predefined range.\n"
        << "If you are a pro-user, change the source code (sphere_approx.cc) or contact the authors.\n"
        << "Exiting the -ha routines without any changes..." << "\n";
   }else
 {

/* start replacing the atoms */

 std::vector <ATOM> newAtomList;

 for(unsigned int i = 0; i < atmnet->atoms.size(); i++)
   {

   if(atmnet->atoms.at(i).radius == minr)
     {
     // in case of the smallest atoms, copy them without modifications
     newAtomList.push_back(atmnet->atoms[i]);
     atmnet->IDmapping.push_back(i);
     }else
     {
     // in case of larger atoms, run atom modification routines

     if(AccSetting == "OCC" ||
        AccSetting == "FCC" ||
        AccSetting == "ACC" ||
        AccSetting == "AQC" ||
        AccSetting == "DDH" ||
        AccSetting == "TIH" ||
        AccSetting == "ICH" ||
        AccSetting == "ICC" ||
        AccSetting == "RIH" ||
        AccSetting == "S4" ||
        AccSetting == "S10" ||
        AccSetting == "S20" ||
        AccSetting == "S30" ||
        AccSetting == "S40" ||
        AccSetting == "S50" ||
        AccSetting == "S100" ||
        AccSetting == "S500" ||
        AccSetting == "S1000" ||
        AccSetting == "S10000")
        {
        AtomCluster cluster(atmnet->atoms[i], minr);
        cluster.replaceAtomByCluster(AccSetting, atmnet->atoms.at(i).radius);
        cluster.copyReplacementAtoms(atmnet, i, &newAtomList);
        }
     else if(AccSetting == "HI")
        {
        AccSetting = "S50";
        AtomCluster cluster(atmnet->atoms[i], minr);
        cluster.replaceAtomByCluster(AccSetting, atmnet->atoms.at(i).radius);
        cluster.copyReplacementAtoms(atmnet, i, &newAtomList);
        }
     else if(AccSetting == "MED")
        {
        AccSetting = "S30";
        AtomCluster cluster(atmnet->atoms[i], minr);
        cluster.replaceAtomByCluster(AccSetting, atmnet->atoms.at(i).radius);
        cluster.copyReplacementAtoms(atmnet, i, &newAtomList);
        }
     else if(AccSetting == "LOW")
        {
        AccSetting = "S10";
        AtomCluster cluster(atmnet->atoms[i], minr);
        cluster.replaceAtomByCluster(AccSetting, atmnet->atoms.at(i).radius);
        cluster.copyReplacementAtoms(atmnet, i, &newAtomList);
        }
     else // equal to (AccSetting == "DEF")
        {
        if(atmnet->atoms.at(i).radius/minr < LARGE_RATIO)
          {
          AccSetting = "S30";
          } else{ 
          AccSetting = "S50";
          };
        AtomCluster cluster(atmnet->atoms[i], minr);
        cluster.replaceAtomByCluster(AccSetting, atmnet->atoms.at(i).radius);
        cluster.copyReplacementAtoms(atmnet, i, &newAtomList);
        };

     };
   }; // ends loop over all atoms in original atom list


/* finishing with replacement of old atom list with the new one */

 atmnet->atoms = newAtomList;
 atmnet->numAtoms = newAtomList.size();

 }; // ends if statement checking if minr and maxr are within the accaptable range

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x528, %rsp            # imm = 0x528
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x2f0(%rdi), %r14
xorl %r12d, %r12d
movl $0x98, %r13d
movl %r12d, %r12d
movq 0x2f8(%rbx), %rax
subq 0x2f0(%rbx), %rax
cqto
idivq %r13
cmpq %r12, %rax
jbe 0x6dae1
movq %r14, %rdi
movq %r12, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
testq %r12, %r12
je 0x6dac7
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x6da99
movq %r14, %rdi
movq %r12, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
movsd 0x18(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x6dacf
movq %r14, %rdi
movq %r12, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
jmp 0x6dad3
movsd %xmm0, 0x10(%rsp)
jmp 0x6dad3
movapd %xmm1, %xmm0
incl %r12d
movsd %xmm0, 0x18(%rsp)
jmp 0x6da47
movq 0xe24d8(%rip), %rdi     # 0x14ffc0
leaq 0x971ff(%rip), %rsi     # 0x104cee
callq 0x4480
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x46c0
leaq 0x9720c(%rip), %rsi     # 0x104d15
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x46c0
leaq 0xa0cdc(%rip), %rsi     # 0x10e802
movq %rax, %rdi
callq 0x4480
movsd 0x8e502(%rip), %xmm0    # 0xfc038
ucomisd 0x10(%rsp), %xmm0
ja 0x6e112
movsd 0x18(%rsp), %xmm0
ucomisd 0x97128(%rip), %xmm0    # 0x104c78
ja 0x6e112
xorpd %xmm0, %xmm0
leaq 0x20(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x308(%rbx), %rax
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
leaq 0x340(%rsp), %r12
movq %r15, 0x8(%rsp)
movl %ebp, %r13d
movq 0x2f8(%rbx), %rax
subq 0x2f0(%rbx), %rax
cqto
movl $0x98, %ecx
idivq %rcx
cmpq %r13, %rax
jbe 0x6e181
movq %r14, %rdi
movq %r13, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
ucomisd 0x10(%rsp), %xmm0
jne 0x6dbee
jp 0x6dbee
imulq $0x98, %r13, %rsi
addq (%r14), %rsi
leaq 0x20(%rsp), %rdi
callq 0xa7d8
movl %ebp, 0x340(%rsp)
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x10324
jmp 0x6de18
movq %r15, %rdi
leaq 0x97090(%rip), %rsi     # 0x104c88
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x9707d(%rip), %rsi     # 0x104c8c
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x9706a(%rip), %rsi     # 0x104c90
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x97057(%rip), %rsi     # 0x104c94
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x97044(%rip), %rsi     # 0x104c98
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x97031(%rip), %rsi     # 0x104c9c
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x9701e(%rip), %rsi     # 0x104ca0
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x9700b(%rip), %rsi     # 0x104ca4
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96ff8(%rip), %rsi     # 0x104ca8
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96fe5(%rip), %rsi     # 0x104cac
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96fd1(%rip), %rsi     # 0x104caf
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96fbe(%rip), %rsi     # 0x104cb3
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96fab(%rip), %rsi     # 0x104cb7
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96f9c(%rip), %rsi     # 0x104cbb
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96f8d(%rip), %rsi     # 0x104cbf
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96f7e(%rip), %rsi     # 0x104cc3
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96f70(%rip), %rsi     # 0x104cc8
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96f62(%rip), %rsi     # 0x104ccd
callq 0x36bf4
testb %al, %al
jne 0x6dd8b
movq %r15, %rdi
leaq 0x96f55(%rip), %rsi     # 0x104cd3
callq 0x36bf4
testb %al, %al
je 0x6de1f
imulq $0x98, %r13, %rsi
addq (%r14), %rsi
leaq 0x490(%rsp), %r15
movq %r15, %rdi
callq 0xa75c
movq %r12, %rdi
movq %r15, %rsi
movsd 0x10(%rsp), %xmm0
callq 0x6abe0
movq %r15, %rdi
callq 0xa808
leaq 0xc0(%rsp), %rdi
movq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x45d0
movq %r14, %rdi
movq %r13, %rsi
callq 0xa73a
leaq 0xc0(%rsp), %r13
movsd 0x30(%rax), %xmm0
movq %r12, %rdi
movq %r13, %rsi
callq 0x6af22
movq %r13, %rdi
callq 0x4210
movq %r12, %rdi
movq %rbx, %rsi
movl %ebp, %edx
leaq 0x20(%rsp), %rcx
callq 0x6acac
movq %r12, %rdi
callq 0x6e354
incl %ebp
jmp 0x6db83
movq %r15, %rdi
leaq 0x9706c(%rip), %rsi     # 0x104e95
callq 0x36bf4
testb %al, %al
je 0x6ded7
movq 0x8(%rsp), %rdi
leaq 0x96e7d(%rip), %rsi     # 0x104cbf
callq 0x4810
imulq $0x98, %r13, %rsi
addq (%r14), %rsi
leaq 0x2a8(%rsp), %rdi
callq 0xa75c
movq %r12, %rdi
leaq 0x2a8(%rsp), %rsi
movsd 0x10(%rsp), %xmm0
callq 0x6abe0
leaq 0x2a8(%rsp), %rdi
callq 0xa808
leaq 0xa0(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x45d0
movq %r14, %rdi
movq %r13, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
movq %r12, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x6af22
leaq 0xa0(%rsp), %rdi
callq 0x4210
movq %r12, %rdi
movq %rbx, %rsi
movl %ebp, %edx
leaq 0x20(%rsp), %rcx
callq 0x6acac
jmp 0x6e100
movq 0x8(%rsp), %rdi
leaq 0x96fb5(%rip), %rsi     # 0x104e98
callq 0x36bf4
testb %al, %al
je 0x6df91
movq 0x8(%rsp), %rdi
leaq 0x96dbb(%rip), %rsi     # 0x104cb7
callq 0x4810
imulq $0x98, %r13, %rsi
addq (%r14), %rsi
leaq 0x210(%rsp), %rdi
callq 0xa75c
movq %r12, %rdi
leaq 0x210(%rsp), %rsi
movsd 0x10(%rsp), %xmm0
callq 0x6abe0
leaq 0x210(%rsp), %rdi
callq 0xa808
leaq 0x80(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x45d0
movq %r14, %rdi
movq %r13, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
movq %r12, %rdi
leaq 0x80(%rsp), %rsi
callq 0x6af22
leaq 0x80(%rsp), %rdi
callq 0x4210
movq %r12, %rdi
movq %rbx, %rsi
movl %ebp, %edx
leaq 0x20(%rsp), %rcx
callq 0x6acac
jmp 0x6e100
movq 0x8(%rsp), %rdi
leaq 0x96eff(%rip), %rsi     # 0x104e9c
callq 0x36bf4
testb %al, %al
je 0x6e042
movq 0x8(%rsp), %rdi
leaq 0x96cf9(%rip), %rsi     # 0x104caf
callq 0x4810
imulq $0x98, %r13, %rsi
addq (%r14), %rsi
leaq 0x178(%rsp), %rdi
callq 0xa75c
movq %r12, %rdi
leaq 0x178(%rsp), %rsi
movsd 0x10(%rsp), %xmm0
callq 0x6abe0
leaq 0x178(%rsp), %rdi
callq 0xa808
leaq 0x60(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x45d0
movq %r14, %rdi
movq %r13, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
callq 0x6af22
leaq 0x60(%rsp), %rdi
callq 0x4210
movq %r12, %rdi
movq %rbx, %rsi
movl %ebp, %edx
leaq 0x20(%rsp), %rcx
callq 0x6acac
jmp 0x6e100
movq %r14, %rdi
movq %r13, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
divsd 0x10(%rsp), %xmm0
movsd 0x96c20(%rip), %xmm1    # 0x104c80
ucomisd %xmm0, %xmm1
leaq 0x96c4c(%rip), %rsi     # 0x104cb7
ja 0x6e074
leaq 0x96c4b(%rip), %rsi     # 0x104cbf
movq 0x8(%rsp), %rdi
callq 0x4810
imulq $0x98, %r13, %rsi
addq (%r14), %rsi
leaq 0xe0(%rsp), %rdi
callq 0xa75c
movq %r12, %rdi
leaq 0xe0(%rsp), %rsi
movsd 0x10(%rsp), %xmm0
callq 0x6abe0
leaq 0xe0(%rsp), %rdi
callq 0xa808
leaq 0x40(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x45d0
movq %r14, %rdi
movq %r13, %rsi
callq 0xa73a
movsd 0x30(%rax), %xmm0
movq %r12, %rdi
leaq 0x40(%rsp), %rsi
callq 0x6af22
leaq 0x40(%rsp), %rdi
callq 0x4210
movq %r12, %rdi
movq %rbx, %rsi
movl %ebp, %edx
leaq 0x20(%rsp), %rcx
callq 0x6acac
movq %r12, %rdi
callq 0x6e354
movq 0x8(%rsp), %r15
jmp 0x6de18
movq 0xe1ed7(%rip), %rdi     # 0x14fff0
leaq 0x96c13(%rip), %rsi     # 0x104d33
callq 0x4480
leaq 0x96c29(%rip), %rsi     # 0x104d55
movq %rax, %rdi
callq 0x4480
leaq 0x96c76(%rip), %rsi     # 0x104db1
movq %rax, %rdi
callq 0x4480
leaq 0x96cc1(%rip), %rsi     # 0x104e0b
movq %rax, %rdi
callq 0x4480
leaq 0x96d0c(%rip), %rsi     # 0x104e65
movq %rax, %rdi
callq 0x4480
leaq 0x94416(%rip), %rsi     # 0x10257e
movq %rax, %rdi
addq $0x528, %rsp            # imm = 0x528
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4480
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x4b2da
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rax
subq (%rdi), %rax
movl $0x98, %ecx
cqto
idivq %rcx
movl %eax, 0x110(%rbx)
callq 0xb110
addq $0x528, %rsp            # imm = 0x528
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6e254
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x6e264
jmp 0x6e254
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
jmp 0x6e249
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x6e264
jmp 0x6e278
movq %rax, %rbx
leaq 0x2a8(%rsp), %rdi
jmp 0x6e249
jmp 0x6e254
jmp 0x6e278
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x6e264
jmp 0x6e254
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
jmp 0x6e249
jmp 0x6e278
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x6e264
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
jmp 0x6e249
jmp 0x6e278
jmp 0x6e278
movq %rax, %rbx
leaq 0x490(%rsp), %rdi
callq 0xa808
jmp 0x6e27b
jmp 0x6e278
jmp 0x6e278
movq %rax, %rbx
jmp 0x6e269
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x4210
leaq 0x340(%rsp), %rdi
callq 0x6e354
jmp 0x6e27b
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xb110
movq %rbx, %rdi
callq 0x4780
nop