// File: /workspace/github_cpp_makefile_star2_O2/DavidLBruce[P]sim3dof/build/../src/FcTseO.cpp
// Function: FcTseO::IntegrateRK2(Matrix&, double)
Matrix FcTseO::IntegrateRK2( Matrix &XX, double deltaTime  )
{
  double   half = 0.5;
  Matrix   stateDerivK(3,1);
  Matrix   stateDerivKp1(3,1);
  Matrix   stateIncrement(3,1);
  Matrix   stateTemp(3,1);

  //
  // Get derivative at current time
  //
  stateDerivK = CalcStateDeriv( XX );

  //
  // Get derivative at next time step
  //
  stateIncrement = stateDerivK * deltaTime;

  stateTemp = XX + stateIncrement;

  stateDerivKp1 = CalcStateDeriv( stateTemp );

  //
  // The final state increment is calculated from the average of the current
  // and next state derivatives.
  //
  stateIncrement = (stateDerivK + stateDerivKp1) * deltaTime * half;

  return( XX + stateIncrement );

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
movsd %xmm0, -0x28(%rbp)
movq %rdx, %r14
movq %rdi, %rbx
leaq -0x58(%rbp), %rdi
pushq $0x3
popq %r15
pushq $0x1
popq %r12
xorps %xmm0, %xmm0
movl %r15d, %esi
movl %r12d, %edx
callq 0x12cf8
leaq -0x88(%rbp), %rdi
xorps %xmm0, %xmm0
movl %r15d, %esi
movl %r12d, %edx
callq 0x12cf8
leaq -0x40(%rbp), %rdi
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
xorps %xmm0, %xmm0
callq 0x12cf8
leaq -0x70(%rbp), %rdi
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
xorps %xmm0, %xmm0
callq 0x12cf8
leaq -0x178(%rbp), %rdi
movq %r14, %rdx
callq 0x587a
leaq -0x1f0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x178(%rbp), %rdx
callq 0x13296
leaq -0x1f0(%rbp), %rdi
callq 0x12dd8
leaq -0x178(%rbp), %rdi
callq 0x12dd8
leaq -0x160(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movsd -0x28(%rbp), %xmm0
callq 0x136c2
leaq -0x1d8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x160(%rbp), %rdx
callq 0x13296
leaq -0x1d8(%rbp), %rdi
callq 0x12dd8
leaq -0x160(%rbp), %rdi
callq 0x12dd8
leaq -0x130(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x12d48
leaq -0x148(%rbp), %rdi
leaq -0x130(%rbp), %rdx
movq %r14, %rsi
callq 0x1331e
leaq -0x1c0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x148(%rbp), %rdx
callq 0x13296
leaq -0x1c0(%rbp), %rdi
callq 0x12dd8
leaq -0x148(%rbp), %rdi
callq 0x12dd8
leaq -0x130(%rbp), %rdi
callq 0x12dd8
leaq -0x118(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x587a
leaq -0x1a8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x13296
leaq -0x1a8(%rbp), %rdi
callq 0x12dd8
leaq -0x118(%rbp), %rdi
callq 0x12dd8
leaq -0xb8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x12d48
leaq -0xd0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x1331e
leaq -0xe8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movsd -0x28(%rbp), %xmm0
callq 0x136c2
leaq -0x100(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
movsd 0xfa85(%rip), %xmm0     # 0x15168
callq 0x136c2
leaq -0x190(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x100(%rbp), %rdx
callq 0x13296
leaq -0x190(%rbp), %rdi
callq 0x12dd8
leaq -0x100(%rbp), %rdi
callq 0x12dd8
leaq -0xe8(%rbp), %rdi
callq 0x12dd8
leaq -0xd0(%rbp), %rdi
callq 0x12dd8
leaq -0xb8(%rbp), %rdi
callq 0x12dd8
leaq -0xa0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x12d48
leaq -0xa0(%rbp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1331e
leaq -0xa0(%rbp), %rdi
callq 0x12dd8
leaq -0x70(%rbp), %rdi
callq 0x12dd8
leaq -0x40(%rbp), %rdi
callq 0x12dd8
leaq -0x88(%rbp), %rdi
callq 0x12dd8
leaq -0x58(%rbp), %rdi
callq 0x12dd8
movq %rbx, %rax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
jmp 0x5832
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x12dd8
jmp 0x57c6
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x12dd8
jmp 0x57d7
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x12dd8
jmp 0x57e8
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
jmp 0x5832
jmp 0x5848
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
jmp 0x5832
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x12dd8
jmp 0x5813
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
jmp 0x5832
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
jmp 0x5832
movq %rax, %rbx
leaq -0x178(%rbp), %rdi
callq 0x12dd8
jmp 0x584b
movq %rax, %rbx
jmp 0x5854
movq %rax, %rbx
jmp 0x585d
movq %rax, %rbx
jmp 0x5869
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x12dd8
leaq -0x40(%rbp), %rdi
callq 0x12dd8
leaq -0x88(%rbp), %rdi
callq 0x12dd8
leaq -0x58(%rbp), %rdi
callq 0x12dd8
movq %rbx, %rdi
callq 0x3320