// File: /workspace/github_cpp_makefile_star2_O1/gjoni[P]iPot/src/Residue.cpp
// Function: Residue::MinDist(Residue const&, Residue const&, int)
double Residue::MinDist(const Residue &R1, const Residue &R2, int mode) {

	double dmin = 9999.99;

	switch (mode) {

	case 0: /* SC + BB */
		for (int i = 0; i < R1.nAtoms; i++) {
			if (R1.atom[i].type == 'H') {
				continue;
			}
			for (int j = 0; j < R2.nAtoms; j++) {
				if (R2.atom[j].type == 'H') {
					continue;
				}
				double d = Atom::Dist(R1.atom[i], R2.atom[j]);
				dmin = d < dmin ? d : dmin;
			}
		}
		break;

	case 1: /* SC */
		for (int i = 0; i < R1.nAtoms; i++) {
			Atom *A = &(R1.atom[i]);
			if (A == R1.C || A == R1.CA || A == R1.N || A == R1.O) {
				continue;
			}
			if (R1.atom[i].type == 'H') {
				continue;
			}
			for (int j = 0; j < R2.nAtoms; j++) {
				Atom *B = &(R2.atom[j]);
				if (B == R2.C || B == R2.CA || B == R2.N || B == R2.O) {
					continue;
				}
				if (R2.atom[j].type == 'H') {
					continue;
				}
				double d = Atom::Dist(R1.atom[i], R2.atom[j]);
				dmin = d < dmin ? d : dmin;
			}
		}
		break;

	case 2: /* BB */
		for (int i = 0; i < R1.nAtoms; i++) {
			Atom *A = &(R1.atom[i]);
			if (A != R1.C && A != R1.CA && A != R1.N && A != R1.O) {
				continue;
			}
			if (R1.atom[i].type == 'H') {
				continue;
			}
			for (int j = 0; j < R2.nAtoms; j++) {
				Atom *B = &(R2.atom[j]);
				if (B != R2.C && B != R2.CA && B != R2.N && B != R2.O) {
					continue;
				}
				if (R2.atom[j].type == 'H') {
					continue;
				}
				double d = Atom::Dist(R1.atom[i], R2.atom[j]);
				dmin = d < dmin ? d : dmin;
			}
		}
		break;

	default:
		return dmin;
		break;

	}

	return dmin;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movsd 0xa99f(%rip), %xmm0     # 0x1f648
testl %edx, %edx
je 0x14e59
cmpl $0x1, %edx
je 0x14d8f
cmpl $0x2, %edx
jne 0x14ecb
cmpl $0x0, 0x18(%r14)
jle 0x14ecb
movsd 0xa972(%rip), %xmm0     # 0x1f648
xorl %r15d, %r15d
movq 0x10(%r14), %rax
leaq (%r15,%r15,2), %r12
shlq $0x5, %r12
leaq (%rax,%r12), %rcx
cmpq 0x170(%r14), %rcx
je 0x14d0d
cmpq 0x168(%r14), %rcx
je 0x14d0d
cmpq 0x160(%r14), %rcx
je 0x14d0d
cmpq 0x178(%r14), %rcx
jne 0x14d7a
cmpb $0x48, 0x58(%rax,%r12)
je 0x14d7a
cmpl $0x0, 0x18(%rbx)
jle 0x14d7a
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x10(%rbx), %rax
leaq (%rax,%r13), %rsi
cmpq 0x170(%rbx), %rsi
je 0x14d4c
cmpq 0x168(%rbx), %rsi
je 0x14d4c
cmpq 0x160(%rbx), %rsi
je 0x14d4c
cmpq 0x178(%rbx), %rsi
jne 0x14d6a
cmpb $0x48, 0x58(%rax,%r13)
je 0x14d6a
movq 0x10(%r14), %rdi
addq %r12, %rdi
movsd %xmm0, (%rsp)
callq 0xe73e
minsd (%rsp), %xmm0
incq %rbp
movslq 0x18(%rbx), %rax
addq $0x60, %r13
cmpq %rax, %rbp
jl 0x14d20
incq %r15
movslq 0x18(%r14), %rax
cmpq %rax, %r15
jl 0x14cd9
jmp 0x14ecb
cmpl $0x0, 0x18(%r14)
jle 0x14ecb
movsd 0xa8a6(%rip), %xmm0     # 0x1f648
xorl %r15d, %r15d
leaq (%r15,%r15,2), %r12
shlq $0x5, %r12
movq 0x10(%r14), %rax
addq %r12, %rax
cmpq 0x170(%r14), %rax
je 0x14e47
cmpq 0x168(%r14), %rax
je 0x14e47
cmpq 0x160(%r14), %rax
je 0x14e47
cmpq 0x178(%r14), %rax
je 0x14e47
cmpb $0x48, 0x58(%rax)
je 0x14e47
cmpl $0x0, 0x18(%rbx)
jle 0x14e47
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x10(%rbx), %rax
leaq (%rax,%r13), %rsi
cmpq 0x170(%rbx), %rsi
je 0x14e37
cmpq 0x168(%rbx), %rsi
je 0x14e37
cmpq 0x160(%rbx), %rsi
je 0x14e37
cmpq 0x178(%rbx), %rsi
je 0x14e37
cmpb $0x48, 0x58(%rax,%r13)
je 0x14e37
movq 0x10(%r14), %rdi
addq %r12, %rdi
movsd %xmm0, (%rsp)
callq 0xe73e
minsd (%rsp), %xmm0
incq %rbp
movslq 0x18(%rbx), %rax
addq $0x60, %r13
cmpq %rax, %rbp
jl 0x14ded
incq %r15
movslq 0x18(%r14), %rax
cmpq %rax, %r15
jl 0x14da5
jmp 0x14ecb
cmpl $0x0, 0x18(%r14)
jle 0x14ecb
movsd 0xa7e0(%rip), %xmm0     # 0x1f648
xorl %r15d, %r15d
movq 0x10(%r14), %rax
leaq (%r15,%r15,2), %r12
shlq $0x5, %r12
cmpb $0x48, 0x58(%rax,%r12)
je 0x14ebf
cmpl $0x0, 0x18(%rbx)
jle 0x14ebf
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x10(%rbx), %rsi
cmpb $0x48, 0x58(%rsi,%r13)
je 0x14eaf
addq %r13, %rsi
movq 0x10(%r14), %rdi
addq %r12, %rdi
movsd %xmm0, (%rsp)
callq 0xe73e
minsd (%rsp), %xmm0
incq %rbp
movslq 0x18(%rbx), %rax
addq $0x60, %r13
cmpq %rax, %rbp
jl 0x14e8a
incq %r15
movslq 0x18(%r14), %rax
cmpq %rax, %r15
jl 0x14e6b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq