// File: /workspace/github_cpp_makefile_star2_O1/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 0xf780
callq 0x22c0
movq 0x40(%rbx), %r12
testq %r12, %r12
je 0xf7cb
leaq -0x8(%r12), %r15
movq -0x8(%r12), %r13
testq %r13, %r13
je 0xf7b8
addq $-0x188, %r12           # imm = 0xFE78
imulq $0x188, %r13, %rbp      # imm = 0x188
leaq (%r12,%rbp), %rdi
callq 0x14a50
addq $-0x188, %rbp           # imm = 0xFE78
jne 0xf7a6
imulq $0x188, %r13, %rsi      # imm = 0x188
addq $0x8, %rsi
movq %r15, %rdi
callq 0x23d0
cmpl $0x0, 0x48(%rbx)
jle 0xf7ed
xorl %r15d, %r15d
movq 0x68(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x2270
incq %r15
movslq 0x48(%rbx), %rax
cmpq %rax, %r15
jl 0xf7d4
movq 0x68(%rbx), %rdi
callq 0x2270
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 %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq %r13, (%rax)
testq %r13, %r13
je 0xf86b
imulq $-0x188, %r13, %r12     # imm = 0xFE78
xorl %ebp, %ebp
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x13cd0
addq $-0x188, %rbp           # imm = 0xFE78
addq $0x188, %r13            # imm = 0x188
cmpq %rbp, %r12
jne 0xf850
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rbx)
cmpl $0x0, 0x48(%rbx)
jle 0xf8a6
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x40(%r14), %rsi
addq %r15, %rsi
movq 0x40(%rbx), %rdi
addq %r15, %rdi
callq 0x14ad0
incq %r12
movslq 0x48(%rbx), %rax
addq $0x188, %r15            # imm = 0x188
cmpq %rax, %r12
jl 0xf880
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 0xf2c4
movq %rbx, %rdi
callq 0xf328
movq %rbx, %rdi
callq 0xf114
movslq 0x48(%rbx), %r14
leaq (,%r14,8), %rdi
callq 0x22d0
movq %rax, 0x68(%rbx)
testq %r14, %r14
jle 0xf955
movl $0x168, %r15d           # imm = 0x168
xorl %r12d, %r12d
movl $0x18, %edi
callq 0x22d0
movq 0x68(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x40(%rbx), %rax
movq 0x68(%rbx), %rcx
movq (%rax,%r15), %rax
movsd 0x10(%rax), %xmm0
movq (%rcx,%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, %r15            # imm = 0x188
cmpq %r12, %r14
jne 0xf907
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 0xf990
negq %rbp
movq 0x8(%rsp), %r14
addq $-0x180, %r14           # imm = 0xFE80
leaq (%r14,%rbp), %rdi
callq 0x14a50
addq $-0x188, %rbp           # imm = 0xFE78
jne 0xf97e
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x23d0
movq %rbx, %rdi
callq 0x2390
nop