// File: Chrom3D[P]Chrom3D/src/Chromosome.cpp
// Function: Chromosome::armRotate(unsigned int, double, bool)
CoordinateMatrix Chromosome::armRotate(uint pos, double theta, bool goRight) {
  assert( (pos >= 1) && (pos < this->size()-1) );
  assert( (theta >= 0) && (theta <= 2*util::PI) );
  
  CoordinateVector beadPos = this->getBeadCoordinates(pos);
  CoordinateMatrix mat;
  CoordinateVector point1;
  CoordinateVector point2;
  if(goRight) {
    mat = this->getBeadCoordinates(pos+1, this->size()-1);
    point1 = this->getBeadCoordinates(pos-1);
    point2 = this->getBeadCoordinates(pos);
  }
  else {
    mat = this->getBeadCoordinates(0, pos-1);
    point1 = this->getBeadCoordinates(pos);
    point2 = this->getBeadCoordinates(pos+1);    
  }
  CoordinateMatrix rotated = util::rotatePointsAroundArbitraryAxis(theta, point1, point2, mat);  
  return rotated;
}

// Assembly:
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, 0x20(%rsp)
movb %cl, %al
movq %rdi, %rcx
movq %rcx, 0x28(%rsp)
movq %rdi, 0x1f0(%rsp)
movq %rsi, 0x1e8(%rsp)
movl %edx, 0x1e4(%rsp)
movsd %xmm0, 0x1d8(%rsp)
andb $0x1, %al
movb %al, 0x1d7(%rsp)
movq 0x1e8(%rsp), %rax
movq %rax, 0x30(%rsp)
xorl %eax, %eax
cmpl $0x1, 0x1e4(%rsp)
movb %al, 0x3f(%rsp)
jb 0x16103
movq 0x30(%rsp), %rdi
movl 0x1e4(%rsp), %eax
movl %eax, 0x1c(%rsp)
callq 0x154f0
movl %eax, %ecx
movl 0x1c(%rsp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
setb %al
movb %al, 0x3f(%rsp)
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x1610d
jmp 0x1610f
jmp 0x1612e
leaq 0x39811(%rip), %rdi     # 0x4f927
leaq 0x396e3(%rip), %rsi     # 0x4f800
movl $0x73, %edx
leaq 0x39823(%rip), %rcx     # 0x4f94c
callq 0x8340
movsd 0x1d8(%rsp), %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movb %al, 0x1b(%rsp)
jb 0x1615e
movsd 0x38eca(%rip), %xmm0    # 0x4f018
ucomisd 0x1d8(%rsp), %xmm0
setae %al
movb %al, 0x1b(%rsp)
movb 0x1b(%rsp), %al
testb $0x1, %al
jne 0x16168
jmp 0x1616a
jmp 0x16189
leaq 0x39816(%rip), %rdi     # 0x4f987
leaq 0x39688(%rip), %rsi     # 0x4f800
movl $0x74, %edx
leaq 0x397c8(%rip), %rcx     # 0x4f94c
callq 0x8340
movq 0x30(%rsp), %rsi
movl 0x1e4(%rsp), %edx
leaq 0x1b8(%rsp), %rdi
callq 0x15880
leaq 0x190(%rsp), %rdi
callq 0x17370
jmp 0x161b1
leaq 0x168(%rsp), %rdi
callq 0xbdb0
jmp 0x161c0
leaq 0x150(%rsp), %rdi
callq 0xbdb0
jmp 0x161cf
testb $0x1, 0x1d7(%rsp)
je 0x1638f
movq 0x30(%rsp), %rdi
movl 0x1e4(%rsp), %eax
incl %eax
movl %eax, 0x14(%rsp)
callq 0x154f0
movq 0x30(%rsp), %rsi
movl 0x14(%rsp), %edx
movl %eax, %ecx
decl %ecx
leaq 0x128(%rsp), %rdi
callq 0x155a0
jmp 0x16210
leaq 0x190(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x17400
jmp 0x16227
leaq 0x128(%rsp), %rdi
callq 0xb2d0
movq 0x30(%rsp), %rsi
movl 0x1e4(%rsp), %edx
decl %edx
leaq 0x110(%rsp), %rdi
callq 0x15880
jmp 0x16251
leaq 0x168(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x17460
jmp 0x16268
leaq 0x110(%rsp), %rdi
callq 0xb5b0
movq 0x30(%rsp), %rsi
movl 0x1e4(%rsp), %edx
leaq 0xf8(%rsp), %rdi
callq 0x15880
jmp 0x16290
leaq 0x150(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x17460
jmp 0x162a7
leaq 0xf8(%rsp), %rdi
callq 0xb5b0
jmp 0x164c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x1664a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x1663d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x16630
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x16623
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x128(%rsp), %rdi
callq 0xb2d0
jmp 0x16623
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x110(%rsp), %rdi
callq 0xb5b0
jmp 0x16623
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0xb5b0
jmp 0x16623
movq 0x30(%rsp), %rsi
movl 0x1e4(%rsp), %ecx
decl %ecx
leaq 0xd0(%rsp), %rdi
xorl %edx, %edx
callq 0x155a0
jmp 0x163ae
leaq 0x190(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x17400
jmp 0x163c5
leaq 0xd0(%rsp), %rdi
callq 0xb2d0
movq 0x30(%rsp), %rsi
movl 0x1e4(%rsp), %edx
leaq 0xb8(%rsp), %rdi
callq 0x15880
jmp 0x163ed
leaq 0x168(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x17460
jmp 0x16404
leaq 0xb8(%rsp), %rdi
callq 0xb5b0
movq 0x30(%rsp), %rsi
movl 0x1e4(%rsp), %edx
incl %edx
leaq 0xa0(%rsp), %rdi
callq 0x15880
jmp 0x1642e
leaq 0x150(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x17460
jmp 0x16445
leaq 0xa0(%rsp), %rdi
callq 0xb5b0
jmp 0x164c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0xb2d0
jmp 0x16623
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0xb5b0
jmp 0x16623
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0xb5b0
jmp 0x16623
movb $0x0, 0x9f(%rsp)
movsd 0x1d8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0xb710
jmp 0x164f4
leaq 0x68(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0xb710
jmp 0x16508
leaq 0x40(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0xc450
jmp 0x1651c
movsd 0x8(%rsp), %xmm0
movq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x68(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq 0x8fa0
jmp 0x16540
leaq 0x40(%rsp), %rdi
callq 0xb2d0
leaq 0x68(%rsp), %rdi
callq 0xb5b0
leaq 0x80(%rsp), %rdi
callq 0xb5b0
movb $0x1, 0x9f(%rsp)
testb $0x1, 0x9f(%rsp)
jne 0x165e2
jmp 0x165d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x165c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x165bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x40(%rsp), %rdi
callq 0xb2d0
leaq 0x68(%rsp), %rdi
callq 0xb5b0
leaq 0x80(%rsp), %rdi
callq 0xb5b0
jmp 0x16623
movq 0x20(%rsp), %rdi
callq 0xb2d0
leaq 0x150(%rsp), %rdi
callq 0xb5b0
leaq 0x168(%rsp), %rdi
callq 0xb5b0
leaq 0x190(%rsp), %rdi
callq 0xb2d0
leaq 0x1b8(%rsp), %rdi
callq 0xb5b0
movq 0x28(%rsp), %rax
addq $0x1f8, %rsp            # imm = 0x1F8
retq
leaq 0x150(%rsp), %rdi
callq 0xb5b0
leaq 0x168(%rsp), %rdi
callq 0xb5b0
leaq 0x190(%rsp), %rdi
callq 0xb2d0
leaq 0x1b8(%rsp), %rdi
callq 0xb5b0
movq 0x188(%rsp), %rdi
callq 0x8870
nopw %cs:(%rax,%rax)