// File: gjoni[P]iPot/src/Chain.cpp
// Function: Chain::Chain(Chain const&)
Chain::Chain(const Chain & source) :
		resmap(source.resmap), atom(NULL), nAtoms(source.nAtoms), residue(NULL), nRes(
				source.nRes), kd(
		NULL), kdCA(NULL), kdCent(NULL), ca_trace(
		NULL) {

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

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

	SetAtomPointers();

	SetKD();

	/* 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));
		memcpy(ca_trace[i], source.ca_trace[i], 3 * sizeof(double));
	}

	SetResMap();

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x48(%rbp)
movq -0x10(%rbp), %rsi
callq 0x1bc80
movq -0x48(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x10(%rbp), %rcx
movl 0x38(%rcx), %ecx
movl %ecx, 0x38(%rax)
movq $0x0, 0x40(%rax)
movq -0x10(%rbp), %rcx
movl 0x48(%rcx), %ecx
movl %ecx, 0x48(%rax)
movq $0x0, 0x50(%rax)
movq $0x0, 0x58(%rax)
movq $0x0, 0x60(%rax)
movq $0x0, 0x68(%rax)
movslq 0x48(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x188, %ecx            # imm = 0x188
mulq %rcx
movq -0x48(%rbp), %rdx
movq %rax, %rdi
seto %cl
addq $0x8, %rdi
movq $-0x1, %rax
cmovbq %rax, %rdi
movq %rdx, -0x40(%rbp)
testb %cl, %cl
cmovneq %rax, %rdi
movq %rdi, -0x38(%rbp)
callq 0x3030
movq %rax, -0x30(%rbp)
jmp 0x1a3ee
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, -0x58(%rbp)
cmpq $0x0, %rax
je 0x1a44a
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rcx
imulq $0x188, %rcx, %rdx      # imm = 0x188
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x68(%rbp)
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x279a0
jmp 0x1a433
movq -0x68(%rbp), %rcx
movq -0x70(%rbp), %rax
addq $0x188, %rax            # imm = 0x188
cmpq %rcx, %rax
movq %rax, -0x60(%rbp)
jne 0x1a424
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, 0x40(%rax)
movl $0x0, -0x20(%rbp)
movq -0x40(%rbp), %rcx
movl -0x20(%rbp), %eax
cmpl 0x48(%rcx), %eax
jge 0x1a505
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movslq -0x20(%rbp), %rax
imulq $0x188, %rax, %rax      # imm = 0x188
addq %rax, %rsi
movq 0x40(%rcx), %rdi
addq %rax, %rdi
callq 0x29350
jmp 0x1a495
jmp 0x1a497
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1a45d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x1a5ef
movq -0x58(%rbp), %rcx
movq %rax, %rsi
movq -0x70(%rbp), %rax
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq %rax, %rcx
movq %rax, -0x78(%rbp)
je 0x1a4f3
movq -0x78(%rbp), %rdi
addq $-0x188, %rdi           # imm = 0xFE78
movq %rdi, -0x80(%rbp)
callq 0x29280
movq -0x58(%rbp), %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x78(%rbp)
jne 0x1a4ce
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0x34a0
jmp 0x1a5ef
movq -0x40(%rbp), %rax
movslq 0x38(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0x88(%rbp)
jmp 0x1a531
movq -0x40(%rbp), %rdi
movq -0x88(%rbp), %rax
movq %rax, 0x30(%rdi)
callq 0x1a010
jmp 0x1a547
movq -0x40(%rbp), %rdi
callq 0x1a0c0
jmp 0x1a552
movq -0x40(%rbp), %rax
movslq 0x48(%rax), %rdi
shlq $0x3, %rdi
callq 0x3390
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x68(%rax)
movl $0x0, -0x24(%rbp)
movq -0x40(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x48(%rcx), %eax
jge 0x1a5db
movl $0x18, %edi
callq 0x3390
movq %rax, %rsi
movq -0x40(%rbp), %rax
movq 0x68(%rax), %rcx
movslq -0x24(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x68(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x10(%rbp), %rcx
movq 0x68(%rcx), %rcx
movslq -0x24(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1a575
movq -0x40(%rbp), %rdi
callq 0x19da0
jmp 0x1a5e6
addq $0x90, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x1b980
movq -0x18(%rbp), %rdi
callq 0x3460
nopw %cs:(%rax,%rax)