// File: /workspace/github_cpp_makefile_star2_O3/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
movl 0xe8(%rdi), %ecx
testl %ecx, %ecx
jle 0x15722
cvtsd2ss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
movq 0xe0(%rbx), %rax
xorl %r13d, %r13d
movsd %xmm0, 0x10(%rsp)
imulq $0x188, %r13, %r15      # imm = 0x188
cmpl $0x0, 0x18(%rax,%r15)
jle 0x15713
movq %r13, %rbp
shlq $0x20, %rbp
xorl %r14d, %r14d
movq 0x10(%rax,%r15), %rcx
leaq (%r14,%r14,2), %rdx
shlq $0x5, %rdx
cmpb $0x48, 0x58(%rcx,%rdx)
je 0x156fc
addq %rdx, %rcx
movq 0x80(%rbx), %rdi
movsd 0x10(%rcx), %xmm4
movq 0x10(%rdi), %rdx
movq 0x8(%rdx), %rsi
movsd (%rsi), %xmm1
subsd %xmm0, %xmm1
ucomisd %xmm4, %xmm1
ja 0x156fc
movsd 0x18(%rcx), %xmm1
movsd 0x8(%rsi), %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
ja 0x156fc
movsd 0x20(%rcx), %xmm2
movsd 0x10(%rsi), %xmm3
subsd %xmm0, %xmm3
ucomisd %xmm2, %xmm3
ja 0x156fc
movq 0x10(%rdx), %rcx
movsd (%rcx), %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm4
ja 0x156fc
movsd 0x8(%rcx), %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm1
ja 0x156fc
movsd 0x10(%rcx), %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm2
ja 0x156fc
xorps %xmm0, %xmm0
cvtsd2ss %xmm4, %xmm0
cvtsd2ss %xmm1, %xmm1
cvtsd2ss %xmm2, %xmm2
movss 0xc(%rsp), %xmm3
callq 0x17fd5
movq %rax, %r12
movq %rax, %rdi
callq 0x18006
testl %eax, %eax
jne 0x156e7
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x18026
movq (%rax), %rax
cmpb $0x48, 0x58(%rax)
je 0x156da
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 %rbp, %rax
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x18(%rsp), %rsi
callq 0x1639c
movq %r12, %rdi
callq 0x18011
movq %r12, %rdi
jmp 0x15677
movq %r12, %rdi
callq 0x17a3c
movq 0xe0(%rbx), %rax
movsd 0x10(%rsp), %xmm0
incq %r14
movslq 0x18(%rax,%r15), %rcx
cmpq %rcx, %r14
jl 0x155aa
movl 0xe8(%rbx), %ecx
incq %r13
movslq %ecx, %rdx
cmpq %rdx, %r13
jl 0x1558d
movq %rbx, %rdi
callq 0x1573a
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop