// File: /workspace/github_cpp_makefile_star2_O2/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 0xed10
callq 0x22b0
movq 0x40(%rbx), %r12
testq %r12, %r12
je 0xed5b
leaq -0x8(%r12), %r15
movq -0x8(%r12), %r13
testq %r13, %r13
je 0xed48
addq $-0x188, %r12           # imm = 0xFE78
imulq $0x188, %r13, %rbp      # imm = 0x188
leaq (%r12,%rbp), %rdi
callq 0x13872
addq $-0x188, %rbp           # imm = 0xFE78
jne 0xed36
imulq $0x188, %r13, %rsi      # imm = 0x188
addq $0x8, %rsi
movq %r15, %rdi
callq 0x23f0
xorl %r15d, %r15d
movslq 0x48(%rbx), %rax
movq 0x68(%rbx), %rdi
cmpq %rax, %r15
jge 0xed79
movq (%rdi,%r15,8), %rdi
callq 0x2260
incq %r15
jmp 0xed5e
callq 0x2260
movslq 0x48(%r14), %r13
movl $0x188, %ecx            # imm = 0x188
movq %r13, %rax
mulq %rcx
movq %rax, %r15
seto %al
addq $0x8, %r15
pushq $-0x1
popq %rcx
cmovbq %rcx, %r15
movl %r13d, 0x48(%rbx)
testb %al, %al
cmovneq %rcx, %r15
movq %r15, %rdi
callq 0x2030
leaq 0x8(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq %r13, (%rax)
testq %r13, %r13
je 0xedef
imulq $-0x188, %r13, %r12     # imm = 0xFE78
xorl %ebp, %ebp
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x12d0c
addq $-0x188, %rbp           # imm = 0xFE78
addq $0x188, %r13            # imm = 0x188
cmpq %rbp, %r12
jne 0xedd4
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rbx)
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x48(%rbx), %rax
cmpq %rax, %r12
jge 0xee26
movq 0x40(%r14), %rsi
addq %r15, %rsi
movq 0x40(%rbx), %rdi
addq %r15, %rdi
callq 0x138e4
incq %r12
addq $0x188, %r15            # imm = 0x188
jmp 0xedfe
movslq 0x38(%r14), %rax
leaq (,%rax,8), %rdi
testq %rax, %rax
movl %eax, 0x38(%rbx)
pushq $-0x1
popq %rax
cmovsq %rax, %rdi
callq 0x2030
movq %rax, 0x30(%rbx)
movq %rbx, %rdi
callq 0xe884
movq %rbx, %rdi
callq 0xe8e4
movq %rbx, %rdi
callq 0xe706
movslq 0x48(%rbx), %r15
movq %r15, %rdi
shlq $0x3, %rdi
callq 0x22d0
movq %rax, %r14
movq %rax, 0x68(%rbx)
xorl %r12d, %r12d
testl %r15d, %r15d
movl $0x0, %r13d
cmovgl %r15d, %r13d
movl $0x168, %ebp            # imm = 0x168
pushq $0x18
popq %r15
cmpq %r12, %r13
je 0xeeda
movq %r15, %rdi
callq 0x22d0
movq %rax, (%r14,%r12,8)
movq 0x40(%rbx), %rax
movq 0x68(%rbx), %r14
movq (%rax,%rbp), %rax
movsd 0x10(%rax), %xmm0
movq (%r14,%r12,8), %rcx
movsd %xmm0, (%rcx)
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x8(%rcx)
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x10(%rcx)
incq %r12
addq $0x188, %rbp            # imm = 0x188
jmp 0xee90
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 0xef15
negq %rbp
movq 0x8(%rsp), %r14
addq $-0x180, %r14           # imm = 0xFE80
leaq (%r14,%rbp), %rdi
callq 0x13872
addq $-0x188, %rbp           # imm = 0xFE78
jne 0xef03
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x23f0
movq %rbx, %rdi
callq 0x23a0