// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/networkstorage.cc
// Function: ATOM_NETWORK::find_tetrahedra(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<double> ATOM_NETWORK::find_tetrahedra(string element) {
    vector<double> tetras;
    double d_ij = -1, d_ik = -1, d_il = -1, d_jk = -1, d_jl = -1, d_kl = -1; //stores distances between each pair of atoms in a potential tetrahedral arrangement
    double maxDist = 5, minDist = 0.1; //four atoms are considered to be in a tetrahedral arrangement if they are each within this distance range of each other - if this is true, we then calculate the index of tetrahedral distortion
    for(int i=0; i<numAtoms; i++) {
        if(atoms.at(i).type.compare(element)==0) {
            for(int j=i+1; j<numAtoms; j++) {
                if(atoms.at(j).type.compare(element)==0) {
                    d_ij = getDistCalc().minimum_periodic_distance(atoms.at(i).a_coord, atoms.at(i).b_coord, atoms.at(i).c_coord, atoms.at(j).a_coord, atoms.at(j).b_coord, atoms.at(j).c_coord);
                    if(d_ij>minDist && d_ij<maxDist) {
                        for(int k=j+1; k<numAtoms; k++) {
                            if(atoms.at(k).type.compare(element)==0) {
                                d_ik = getDistCalc().minimum_periodic_distance(atoms.at(i).a_coord, atoms.at(i).b_coord, atoms.at(i).c_coord, atoms.at(k).a_coord, atoms.at(k).b_coord, atoms.at(k).c_coord);
                                if(d_ik>minDist && d_ik<maxDist) {
                                    d_jk = getDistCalc().minimum_periodic_distance(atoms.at(j).a_coord, atoms.at(j).b_coord, atoms.at(j).c_coord, atoms.at(k).a_coord, atoms.at(k).b_coord, atoms.at(k).c_coord);
                                    if(d_jk>minDist && d_jk<maxDist) {
                                        for(int l=k+1; l<numAtoms; l++) {
                                            if(atoms.at(l).type.compare(element)==0) {
                                                d_il = getDistCalc().minimum_periodic_distance(atoms.at(i).a_coord, atoms.at(i).b_coord, atoms.at(i).c_coord, atoms.at(l).a_coord, atoms.at(l).b_coord, atoms.at(l).c_coord);
                                                if(d_il>minDist && d_il<maxDist) {
                                                    d_jl = getDistCalc().minimum_periodic_distance(atoms.at(j).a_coord, atoms.at(j).b_coord, atoms.at(j).c_coord, atoms.at(l).a_coord, atoms.at(l).b_coord, atoms.at(l).c_coord);
                                                    if(d_jl>minDist && d_jl<maxDist) {
                                                        d_kl = getDistCalc().minimum_periodic_distance(atoms.at(k).a_coord, atoms.at(k).b_coord, atoms.at(k).c_coord, atoms.at(l).a_coord, atoms.at(l).b_coord, atoms.at(l).c_coord);
                                                        if(d_kl>minDist && d_kl<maxDist) {
                                                            //we have found four atoms within the tolerance
                                                            double t = CalculateTetrahedrality4Atoms(atoms.at(i), atoms.at(j), atoms.at(k), atoms.at(l));
                                                            tetras.push_back(t);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //sort before returning
    sort(tetras.begin(), tetras.end());
    return tetras;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, 0x40(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rdi)
movq %rdi, 0x28(%rsp)
movq $0x0, 0x10(%rdi)
cmpl $0x0, 0x110(%rsi)
jle 0x54add
movq %rsi, %r12
movl $0x3, 0x20(%rsp)
movl $0x2, %eax
movq %rax, 0xc8(%rsp)
movl $0x1, %eax
movq %rax, 0xc0(%rsp)
xorl %esi, %esi
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0x54c12
movq %rsi, 0x10(%rsp)
imulq $0x98, %rsi, %rcx
movq %rcx, 0x38(%rsp)
leaq (%rax,%rcx), %rdi
addq $0x40, %rdi
movq 0x40(%rsp), %rsi
callq 0x4050
testl %eax, %eax
jne 0x54ab0
movq 0x10(%rsp), %rsi
leaq 0x1(%rsi), %rcx
movslq 0x110(%r12), %rdx
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
movl 0x20(%rsp), %edi
movl %edi, 0x24(%rsp)
movq %rsi, %rbx
cmpq %rdx, %rcx
jge 0x54ab0
movq %rax, %rsi
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0x54b84
movq %rsi, 0x18(%rsp)
imulq $0x98, %rsi, %rcx
movq %rcx, 0x30(%rsp)
leaq (%rax,%rcx), %rdi
addq $0x40, %rdi
movq 0x40(%rsp), %rsi
callq 0x4050
testl %eax, %eax
je 0x54311
movq 0x18(%rsp), %rbx
leaq 0x1(%rbx), %rax
incl 0x24(%rsp)
incq 0xd0(%rsp)
cmpl %eax, 0x110(%r12)
jg 0x54295
jmp 0x54ab0
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x52aea
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
jbe 0x54bdb
cmpq %rcx, %rdx
jbe 0x54bd6
movq 0x38(%rsp), %rcx
movsd 0x28(%rax,%rcx), %xmm2
movsd 0x18(%rax,%rcx), %xmm0
movsd 0x20(%rax,%rcx), %xmm1
movq 0x30(%rsp), %rcx
movsd 0x18(%rax,%rcx), %xmm3
movsd 0x20(%rax,%rcx), %xmm4
movsd 0x28(%rax,%rcx), %xmm5
leaq 0x48(%rsp), %rdi
callq 0x78f3c
movapd %xmm0, %xmm1
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm0, 0x8(%rsp)
je 0x543be
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x543db
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x543f8
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
ucomisd 0xfac68(%rip), %xmm1    # 0x14f068
jbe 0x542ed
movsd 0x1002aa(%rip), %xmm0   # 0x1546b8
ucomisd %xmm1, %xmm0
jbe 0x542ed
addl $0x2, %ebx
movq 0xd0(%rsp), %r14
movl 0x24(%rsp), %eax
movl %eax, %ebp
cmpl 0x110(%r12), %ebx
jge 0x542ed
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq %r14, %rdx
jbe 0x54b43
imulq $0x98, %r14, %r15
leaq (%rax,%r15), %rdi
addq $0x40, %rdi
movq 0x40(%rsp), %rsi
callq 0x4050
movl %ebp, %ebp
testl %eax, %eax
je 0x54498
incq %r14
incl %ebp
cmpl %r14d, 0x110(%r12)
jg 0x54437
jmp 0x542ed
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x52aea
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq 0x10(%rsp), %rdx
jbe 0x54b71
cmpq %r14, %rdx
jbe 0x54b6c
movq 0x38(%rsp), %rcx
movsd 0x28(%rax,%rcx), %xmm2
movsd 0x18(%rax,%rcx), %xmm0
movsd 0x20(%rax,%rcx), %xmm1
movsd 0x18(%rax,%r15), %xmm3
movsd 0x20(%rax,%r15), %xmm4
movsd 0x28(%rax,%r15), %xmm5
leaq 0x48(%rsp), %rdi
callq 0x78f3c
movapd %xmm0, %xmm1
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm0, 0x8(%rsp)
je 0x5453e
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x5455b
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x54578
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
ucomisd 0xfaae8(%rip), %xmm1    # 0x14f068
jbe 0x54484
movsd 0x10012a(%rip), %xmm0   # 0x1546b8
ucomisd %xmm1, %xmm0
jbe 0x54484
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x52aea
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq 0x18(%rsp), %rdx
jbe 0x54baa
cmpq %r14, %rdx
jbe 0x54bb1
movq 0x30(%rsp), %rcx
movsd 0x28(%rax,%rcx), %xmm2
movsd 0x18(%rax,%rcx), %xmm0
movsd 0x20(%rax,%rcx), %xmm1
movsd 0x18(%rax,%r15), %xmm3
movsd 0x20(%rax,%r15), %xmm4
movsd 0x28(%rax,%r15), %xmm5
leaq 0x48(%rsp), %rdi
callq 0x78f3c
movapd %xmm0, %xmm1
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm0, 0x8(%rsp)
je 0x5463e
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x5465b
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x54678
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
ucomisd 0xfa9e8(%rip), %xmm1    # 0x14f068
jbe 0x54484
movsd 0x10002a(%rip), %xmm0   # 0x1546b8
ucomisd %xmm1, %xmm0
jbe 0x54484
leal 0x1(%r14), %eax
cmpl 0x110(%r12), %eax
jge 0x54484
imulq $0x98, %rbp, %r13
movq %rbp, %rbx
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq %rbx, %rdx
jbe 0x54b32
leaq (%rax,%r13), %rdi
addq $0x40, %rdi
movq 0x40(%rsp), %rsi
callq 0x4050
testl %eax, %eax
je 0x54711
incq %rbx
addq $0x98, %r13
cmpl %ebx, 0x110(%r12)
jg 0x546b4
jmp 0x54484
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x52aea
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq 0x10(%rsp), %rdx
jbe 0x54b59
cmpq %rbx, %rdx
jbe 0x54b54
movq 0x38(%rsp), %rcx
movsd 0x28(%rax,%rcx), %xmm2
movsd 0x18(%rax,%rcx), %xmm0
movsd 0x20(%rax,%rcx), %xmm1
movsd 0x18(%rax,%r13), %xmm3
movsd 0x20(%rax,%r13), %xmm4
movsd 0x28(%rax,%r13), %xmm5
leaq 0x48(%rsp), %rdi
callq 0x78f3c
movapd %xmm0, %xmm1
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm0, 0x8(%rsp)
je 0x547b7
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x547d4
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x547f1
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
ucomisd 0xfa86f(%rip), %xmm1    # 0x14f068
jbe 0x546f8
movsd 0xffeb1(%rip), %xmm0    # 0x1546b8
ucomisd %xmm1, %xmm0
jbe 0x546f8
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x52aea
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq 0x18(%rsp), %rdx
jbe 0x54b92
cmpq %rbx, %rdx
jbe 0x54b99
movq 0x30(%rsp), %rcx
movsd 0x28(%rax,%rcx), %xmm2
movsd 0x18(%rax,%rcx), %xmm0
movsd 0x20(%rax,%rcx), %xmm1
movsd 0x18(%rax,%r13), %xmm3
movsd 0x20(%rax,%r13), %xmm4
movsd 0x28(%rax,%r13), %xmm5
leaq 0x48(%rsp), %rdi
callq 0x78f3c
movapd %xmm0, %xmm1
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm0, 0x8(%rsp)
je 0x548b7
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x548d4
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x548f1
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
ucomisd 0xfa76f(%rip), %xmm1    # 0x14f068
jbe 0x546f8
movsd 0xffdb1(%rip), %xmm0    # 0x1546b8
ucomisd %xmm1, %xmm0
jbe 0x546f8
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x52aea
movq 0x2f0(%r12), %rax
movq 0x2f8(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq %r14, %rdx
jbe 0x54bc5
cmpq %rbx, %rdx
jbe 0x54bc2
movsd 0x28(%rax,%r15), %xmm2
movsd 0x18(%rax,%r15), %xmm0
movsd 0x20(%rax,%r15), %xmm1
movsd 0x18(%rax,%r13), %xmm3
movsd 0x20(%rax,%r13), %xmm4
movsd 0x28(%rax,%r13), %xmm5
leaq 0x48(%rsp), %rdi
callq 0x78f3c
movapd %xmm0, %xmm1
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm0, 0x8(%rsp)
je 0x549b3
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x549d0
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x549ed
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x8(%rsp), %xmm1
ucomisd 0xfa673(%rip), %xmm1    # 0x14f068
jbe 0x546f8
movsd 0xffcb5(%rip), %xmm0    # 0x1546b8
ucomisd %xmm1, %xmm0
jbe 0x546f8
movq 0x2f0(%r12), %r8
movq 0x2f8(%r12), %rdx
subq %r8, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rax # imm = 0x86BCA1AF286BCA1B
imulq %rax, %rdx
cmpq 0x10(%rsp), %rdx
jbe 0x54bee
cmpq 0x18(%rsp), %rdx
jbe 0x54bf5
cmpq %r14, %rdx
jbe 0x54bfc
cmpq %rbx, %rdx
jbe 0x54c01
movq 0x38(%rsp), %rax
leaq (%r8,%rax), %rsi
movq 0x30(%rsp), %rax
leaq (%r8,%rax), %rdx
leaq (%r8,%r15), %rcx
addq %r13, %r8
movq %r12, %rdi
callq 0x54c8a
movsd %xmm0, 0x48(%rsp)
movq 0x28(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x54aa1
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x546f8
leaq 0x48(%rsp), %rdx
callq 0x148c4
jmp 0x546f8
movq 0x10(%rsp), %rsi
incq %rsi
movslq 0x110(%r12), %rax
incl 0x20(%rsp)
incq 0xc8(%rsp)
incq 0xc0(%rsp)
cmpq %rax, %rsi
jl 0x541ff
movq 0x28(%rsp), %rax
movq (%rax), %rbx
movq 0x8(%rax), %r14
cmpq %r14, %rbx
je 0x54b1b
movq %r14, %rax
subq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c033
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c12c
movq 0x28(%rsp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfab6c(%rip), %rdi     # 0x14f6a5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xfab5b(%rip), %rdi     # 0x14f6a5
movq %r14, %rsi
xorl %eax, %eax
callq 0x4630
movq %rbx, %rsi
jmp 0x54b5e
movq 0x10(%rsp), %rsi
leaq 0xfab40(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
movq %r14, %rsi
jmp 0x54b76
movq 0x10(%rsp), %rsi
leaq 0xfab28(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
leaq 0xfab1a(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
movq 0x18(%rsp), %rsi
jmp 0x54b9c
movq %rbx, %rsi
leaq 0xfab02(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
movq 0x18(%rsp), %rsi
jmp 0x54bb4
movq %r14, %rsi
leaq 0xfaaea(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
movq %rbx, %r14
leaq 0xfaad9(%rip), %rdi     # 0x14f6a5
movq %r14, %rsi
xorl %eax, %eax
callq 0x4630
movq %rcx, 0x10(%rsp)
leaq 0xfaac3(%rip), %rdi     # 0x14f6a5
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x4630
movq 0x10(%rsp), %rsi
jmp 0x54c04
movq 0x18(%rsp), %rsi
jmp 0x54c04
movq %r14, %rsi
jmp 0x54c04
movq %rbx, %rsi
leaq 0xfaa9a(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
leaq 0xfaa8c(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
jmp 0x54c65
jmp 0x54c65
jmp 0x54c65
jmp 0x54c65
jmp 0x54c65
jmp 0x54c54
jmp 0x54c54
jmp 0x54c65
jmp 0x54c54
jmp 0x54c65
jmp 0x54c54
jmp 0x54c54
jmp 0x54c65
jmp 0x54c54
jmp 0x54c65
jmp 0x54c65
jmp 0x54c65
jmp 0x54c54
jmp 0x54c65
jmp 0x54c54
jmp 0x54c54
jmp 0x54c65
jmp 0x54c54
jmp 0x54c54
jmp 0x54c65
jmp 0x54c65
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x38a78
jmp 0x54c68
jmp 0x54c65
movq %rax, %rbx
movq 0x28(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x54c81
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780
nop