// File: /workspace/github_cpp_makefile_star2_O3/gjoni[P]iPot/src/Chain.cpp
// Function: Chain::operator=(Chain const&)
Chain & Chain::operator =(const Chain & source) {

	delete[] atom;
	delete[] residue;
	for (int i = 0; i < nRes; i++) {
		free(ca_trace[i]);
	}
	free(ca_trace);

	/* copy residues */
	nRes = source.nRes;
	residue = new Residue[nRes];
	for (int i = 0; i < nRes; i++) {
		residue[i] = source.residue[i];
	}

	/* set pointers to atoms */
	nAtoms = source.nAtoms;
	atom = new Atom*[nAtoms];

	SetAtomPointers();

	SetKD();

	//resmap = source.resmap;
	SetResMap();

	/* initialize CA trace */
	ca_trace = (double**) malloc(nRes * sizeof(double*));
	for (int i = 0; i < nRes; i++) {
		ca_trace[i] = (double*) malloc(3 * sizeof(double));
		ca_trace[i][0] = residue[i].CA->x;
		ca_trace[i][1] = residue[i].CA->y;
		ca_trace[i][2] = residue[i].CA->z;
	}

	return *this;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
testq %rdi, %rdi
je 0xf5ec
callq 0x22b0
movq 0x40(%rbx), %r12
testq %r12, %r12
je 0xf637
leaq -0x8(%r12), %r15
movq -0x8(%r12), %r13
testq %r13, %r13
je 0xf624
addq $-0x188, %r12           # imm = 0xFE78
imulq $0x188, %r13, %rbp      # imm = 0x188
leaq (%r12,%rbp), %rdi
callq 0x1486e
addq $-0x188, %rbp           # imm = 0xFE78
jne 0xf612
imulq $0x188, %r13, %rsi      # imm = 0x188
addq $0x8, %rsi
movq %r15, %rdi
callq 0x23c0
cmpl $0x0, 0x48(%rbx)
jle 0xf659
xorl %r15d, %r15d
movq 0x68(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x2260
incq %r15
movslq 0x48(%rbx), %rax
cmpq %rax, %r15
jl 0xf640
movq 0x68(%rbx), %rdi
callq 0x2260
movslq 0x48(%r14), %r13
movl $0x188, %ecx            # imm = 0x188
movq %r13, %rax
mulq %rcx
movq %rax, %r15
seto %al
addq $0x8, %r15
movq $-0x1, %rcx
cmovbq %rcx, %r15
movl %r13d, 0x48(%rbx)
testb %al, %al
cmovneq %rcx, %r15
movq %r15, %rdi
callq 0x2030
leaq 0x8(%rax), %rcx
movq %r13, (%rax)
testq %r13, %r13
je 0xf712
movq %rax, 0x8(%rsp)
imulq $-0x188, %r13, %r12     # imm = 0xFE78
xorl %ebp, %ebp
movq %rcx, 0x10(%rsp)
movq %rcx, %r13
movq %r13, %rdi
callq 0x13ae8
addq $-0x188, %rbp           # imm = 0xFE78
addq $0x188, %r13            # imm = 0x188
cmpq %rbp, %r12
jne 0xf6ba
cmpl $0x0, 0x48(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rbx)
jle 0xf716
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x40(%r14), %rsi
addq %r15, %rsi
movq 0x40(%rbx), %rdi
addq %r15, %rdi
callq 0x148ee
incq %r12
movslq 0x48(%rbx), %rax
addq $0x188, %r15            # imm = 0x188
cmpq %rax, %r12
jl 0xf6ea
jmp 0xf716
movq %rcx, 0x40(%rbx)
movslq 0x38(%r14), %rax
leaq (,%rax,8), %rcx
testq %rax, %rax
movl %eax, 0x38(%rbx)
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0x30(%rbx)
movq %rbx, %rdi
callq 0xf12a
movq %rbx, %rdi
callq 0xf18e
movq %rbx, %rdi
callq 0xef7a
movslq 0x48(%rbx), %r15
leaq (,%r15,8), %rdi
callq 0x22c0
movq %rax, 0x68(%rbx)
testq %r15, %r15
jle 0xf7c4
movq %rax, %r14
movl $0x168, %r12d           # imm = 0x168
xorl %r13d, %r13d
movl $0x18, %edi
callq 0x22c0
movq %rax, (%r14,%r13,8)
movq 0x40(%rbx), %rax
movq 0x68(%rbx), %r14
movq (%rax,%r12), %rax
movsd 0x10(%rax), %xmm0
movq (%r14,%r13,8), %rcx
movsd %xmm0, (%rcx)
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x8(%rcx)
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x10(%rcx)
incq %r13
addq $0x188, %r12            # imm = 0x188
cmpq %r13, %r15
jne 0xf77a
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testq %rbp, %rbp
je 0xf7ff
negq %rbp
movq 0x8(%rsp), %r14
addq $-0x180, %r14           # imm = 0xFE80
leaq (%r14,%rbp), %rdi
callq 0x1486e
addq $-0x188, %rbp           # imm = 0xFE78
jne 0xf7ed
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x23c0
movq %rbx, %rdi
callq 0x2380