// File: gjoni[P]iPot/src/Residue.cpp
// Function: Residue::Residue(std::vector<AtomRecord, std::allocator<AtomRecord>> const&)
Residue::Residue(const std::vector<AtomRecord>& source) :
		seqNum(source[0].resNum), insCode(source[0].insCode), atom(NULL), nAtoms(
				source.size()), chainId(source[0].chainId), ntFlag(false), ctFlag(
				false), N(NULL), CA(NULL), C(
		NULL), O(NULL), CB(NULL) {

	assert(nAtoms > 0); /* pedantic check */

	strcpy(name, source[0].resName); /* first atom is used to name the residue*/

	atom = new Atom[nAtoms];
	int idx = 0;
	for (int i = 0; i < nAtoms; i++) {
		atom[i] = Atom(source[i]);
		atom[i].residue = this;
		idx++;
	}

	SetBBAtoms(); /* N, CA, C, O, CB are pointers - they need to be reinitialized */

	type = SetType(name);

	SetCentroid();

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29ae0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movl 0x10(%rcx), %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29ae0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movb 0x14(%rcx), %cl
movb %cl, 0xc(%rax)
movq $0x0, 0x10(%rax)
movq -0x10(%rbp), %rdi
callq 0x1b8f0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29ae0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movb 0xe(%rcx), %cl
movb %cl, 0x1c(%rax)
addq $0x38, %rax
movq %rax, -0xa0(%rbp)
movq %rax, %rcx
addq $0x120, %rcx            # imm = 0x120
movq %rcx, -0x98(%rbp)
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x18b10
jmp 0x2822b
movq -0x98(%rbp), %rcx
movq -0xb0(%rbp), %rax
addq $0x60, %rax
cmpq %rcx, %rax
movq %rax, -0x90(%rbp)
jne 0x28216
movq -0xa8(%rbp), %rax
movb $0x0, 0x158(%rax)
movb $0x0, 0x159(%rax)
movq $0x0, 0x160(%rax)
movq $0x0, 0x168(%rax)
movq $0x0, 0x170(%rax)
movq $0x0, 0x178(%rax)
movq $0x0, 0x180(%rax)
cmpl $0x0, 0x18(%rax)
jle 0x2829d
jmp 0x28316
leaq 0x12cd4(%rip), %rdi     # 0x3af78
leaq 0x12cd8(%rip), %rsi     # 0x3af83
movl $0x39, %edx
leaq 0x12cfe(%rip), %rcx     # 0x3afb5
callq 0x31b0
movq -0xa0(%rbp), %rcx
movq %rax, %rsi
movq -0xb0(%rbp), %rax
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq %rax, %rcx
movq %rax, -0xb8(%rbp)
je 0x28311
movq -0xb8(%rbp), %rdi
addq $-0x60, %rdi
movq %rdi, -0xc0(%rbp)
callq 0x18e20
movq -0xa0(%rbp), %rcx
movq -0xc0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0xb8(%rbp)
jne 0x282e0
jmp 0x285e5
movq -0xa8(%rbp), %rax
incq %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29ae0
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
addq $0xa, %rsi
callq 0x3270
movq -0xa8(%rbp), %rax
movslq 0x18(%rax), %rax
movq %rax, -0xd8(%rbp)
movl $0x60, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
addq $0x8, %rdi
movq $-0x1, %rax
cmovbq %rax, %rdi
testb %cl, %cl
cmovneq %rax, %rdi
movq %rdi, -0xd0(%rbp)
callq 0x3030
movq %rax, -0xc8(%rbp)
jmp 0x28391
movq -0xd8(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, -0xe8(%rbp)
cmpq $0x0, %rax
je 0x2840c
movq -0xe8(%rbp), %rax
movq -0xd8(%rbp), %rcx
imulq $0x60, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0xf8(%rbp)
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x18b10
jmp 0x283ee
movq -0xf8(%rbp), %rcx
movq -0x100(%rbp), %rax
addq $0x60, %rax
cmpq %rcx, %rax
movq %rax, -0xf0(%rbp)
jne 0x283d9
movq -0xa8(%rbp), %rax
movq -0xe8(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0xa8(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x18(%rcx), %eax
jge 0x28557
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x29ae0
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x18c80
jmp 0x2845d
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x24(%rbp), %rax
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
addq %rax, %rdi
leaq -0x88(%rbp), %rsi
callq 0x18e30
jmp 0x28485
leaq -0x88(%rbp), %rdi
callq 0x18e20
movq -0xa8(%rbp), %rcx
movq 0x10(%rcx), %rax
movslq -0x24(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x40(%rax)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2842c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x2859e
movq -0xe8(%rbp), %rcx
movq %rax, %rsi
movq -0x100(%rbp), %rax
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq %rax, %rcx
movq %rax, -0x108(%rbp)
je 0x28528
movq -0x108(%rbp), %rdi
addq $-0x60, %rdi
movq %rdi, -0x110(%rbp)
callq 0x18e20
movq -0xe8(%rbp), %rcx
movq -0x110(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x108(%rbp)
jne 0x284f7
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdi
callq 0x34a0
jmp 0x2859e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x18e20
jmp 0x2859e
movq -0xa8(%rbp), %rdi
callq 0x27e40
jmp 0x28565
movq -0xa8(%rbp), %rdi
movq %rdi, %rsi
incq %rsi
callq 0x285f0
movb %al, -0x111(%rbp)
jmp 0x2857f
movq -0xa8(%rbp), %rdi
movb -0x111(%rbp), %al
movb %al, (%rdi)
callq 0x28650
jmp 0x28595
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0xa0(%rbp), %rax
addq $0x120, %rax            # imm = 0x120
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rdi
addq $-0x60, %rdi
movq %rdi, -0x128(%rbp)
callq 0x18e20
movq -0xa0(%rbp), %rcx
movq -0x128(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x120(%rbp)
jne 0x285b2
jmp 0x285e5
movq -0x18(%rbp), %rdi
callq 0x3460
nop