// File: /workspace/github_cpp_makefile_star2_O1/gjoni[P]iPot/src/Complex.cpp
// Function: Complex::SetInterface1(double)
void Complex::SetInterface1(double d) {

	/* search for interface residues */
	kdres *res;
	double pos[3];
	for (int i = 0; i < Ligand.nRes; i++) {

		for (int j = 0; j < Ligand.residue[i].nAtoms; j++) {

			Atom *A = &(Ligand.residue[i].atom[j]);

			if (A->type == 'H') { /* exclude hydrogens */
				continue;
			}

			/* check whether the current atom is within the bounding box
			 * of the Receptor */
			kdtree *kd = Receptor.kd;
			if (A->x < kd->rect->min[0] - d || A->y < kd->rect->min[1] - d
					|| A->z < kd->rect->min[2] - d
					|| A->x > kd->rect->max[0] + d
					|| A->y > kd->rect->max[1] + d
					|| A->z > kd->rect->max[2] + d) {

				continue;

			}

			/* find neighbors of A in the Receptor */
			res = kd_nearest_range3f(kd, A->x, A->y, A->z, d);
			while (!kd_res_end(res)) {

				Atom *B = *((Atom**) kd_res_item(res, pos));
				if (B->type != 'H') { /* exclude hydrogens */
					int idx = B->residue - Receptor.residue;
					intRec[idx] = true;
					intLig[i] = true;
					contacts.push_back(std::make_pair(idx, i));
				}
				kd_res_next(res);
			}
			kd_res_free(res);

		}
	}

	ArrangeContatcs();

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
cmpl $0x0, 0xe8(%rdi)
jle 0x15881
cvtsd2ss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
xorl %r13d, %r13d
movsd %xmm0, 0x10(%rsp)
movq 0xe0(%rbx), %rax
imulq $0x188, %r13, %r15      # imm = 0x188
cmpl $0x0, 0x18(%rax,%r15)
jle 0x1586e
movq %r13, %r14
shlq $0x20, %r14
xorl %ebp, %ebp
movq 0x10(%rax,%r15), %rax
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
shlq $0x5, %rcx
cmpb $0x48, 0x58(%rax,%rcx)
je 0x15856
addq %rcx, %rax
movq 0x80(%rbx), %rdi
movsd 0x10(%rax), %xmm4
movq 0x10(%rdi), %rcx
movq 0x8(%rcx), %rdx
movsd (%rdx), %xmm1
subsd %xmm0, %xmm1
ucomisd %xmm4, %xmm1
ja 0x15856
movsd 0x18(%rax), %xmm1
movsd 0x8(%rdx), %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
ja 0x15856
movsd 0x20(%rax), %xmm2
movsd 0x10(%rdx), %xmm3
subsd %xmm0, %xmm3
ucomisd %xmm2, %xmm3
ja 0x15856
movq 0x10(%rcx), %rax
movsd (%rax), %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm4
ja 0x15856
movsd 0x8(%rax), %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm1
ja 0x15856
movsd 0x10(%rax), %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm2
ja 0x15856
xorps %xmm0, %xmm0
cvtsd2ss %xmm4, %xmm0
cvtsd2ss %xmm1, %xmm1
cvtsd2ss %xmm2, %xmm2
movss 0xc(%rsp), %xmm3
callq 0x181ac
movq %rax, %r12
movq %rax, %rdi
callq 0x181e8
testl %eax, %eax
jne 0x15848
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x18208
movq (%rax), %rax
cmpb $0x48, 0x58(%rax)
je 0x1583b
movq 0x40(%rax), %rax
subq 0x70(%rbx), %rax
sarq $0x3, %rax
movabsq $0x7d6343eb1a1f58d1, %rcx # imm = 0x7D6343EB1A1F58D1
imulq %rcx, %rax
movq 0x18(%rbx), %rcx
cltq
movb $0x1, %dl
movb %dl, (%rcx,%rax)
movq 0x20(%rbx), %rcx
movb %dl, (%rcx,%r13)
movl %eax, %eax
orq %r14, %rax
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x18(%rsp), %rsi
callq 0x16534
movq %r12, %rdi
callq 0x181f3
movq %r12, %rdi
jmp 0x157d8
movq %r12, %rdi
callq 0x17c0b
movsd 0x10(%rsp), %xmm0
incq %rbp
movq 0xe0(%rbx), %rax
movslq 0x18(%rax,%r15), %rcx
cmpq %rcx, %rbp
jl 0x15704
incq %r13
movslq 0xe8(%rbx), %rax
cmpq %rax, %r13
jl 0x156e1
movq %rbx, %rdi
callq 0x15898
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq