// File: /workspace/github_cpp_makefile_star2_O2/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
cvtsd2ss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
xorl %r13d, %r13d
movsd %xmm0, 0x10(%rsp)
movslq 0xe8(%rbx), %rax
cmpq %rax, %r13
jge 0x145c4
movq %r13, %r15
shlq $0x20, %r15
imulq $0x188, %r13, %r14      # imm = 0x188
xorl %ebp, %ebp
movq 0xe0(%rbx), %rax
movslq 0x18(%rax,%r14), %rcx
cmpq %rcx, %rbp
jge 0x145bc
addq %r14, %rax
movq 0x10(%rax), %rax
imulq $0x60, %rbp, %rcx
cmpb $0x48, 0x58(%rax,%rcx)
je 0x145b4
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 0x145b4
movsd 0x18(%rax), %xmm1
movsd 0x8(%rdx), %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
ja 0x145b4
movsd 0x20(%rax), %xmm2
movsd 0x10(%rdx), %xmm3
subsd %xmm0, %xmm3
ucomisd %xmm2, %xmm3
ja 0x145b4
movq 0x10(%rcx), %rax
movsd (%rax), %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm4
ja 0x145b4
movsd 0x8(%rax), %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm1
ja 0x145b4
movsd 0x10(%rax), %xmm3
addsd %xmm0, %xmm3
ucomisd %xmm3, %xmm2
ja 0x145b4
cvtsd2ss %xmm4, %xmm0
cvtsd2ss %xmm1, %xmm1
cvtsd2ss %xmm2, %xmm2
movss 0xc(%rsp), %xmm3
callq 0x16d86
movq %rax, %r12
movq %r12, %rdi
callq 0x16db1
testl %eax, %eax
jne 0x145a6
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x16dd1
movq (%rax), %rax
cmpb $0x48, 0x58(%rax)
je 0x1459c
movq 0x40(%rax), %rax
subq 0x70(%rbx), %rax
cqto
movl $0x188, %ecx            # imm = 0x188
idivq %rcx
movq 0x18(%rbx), %rcx
cltq
movb $0x1, %dl
movb %dl, (%rcx,%rax)
movq 0x20(%rbx), %rcx
movb %dl, (%rcx,%r13)
movl %eax, %eax
orq %r15, %rax
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x18(%rsp), %rsi
callq 0x151fa
movq %r12, %rdi
callq 0x16dbc
jmp 0x1453e
movq %r12, %rdi
callq 0x167ec
movsd 0x10(%rsp), %xmm0
incq %rbp
jmp 0x14464
incq %r13
jmp 0x14444
movq %rbx, %rdi
callq 0x145dc
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop