// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/msh2prp/msh2prp.cpp
// Function: rot_coord_sys(gaps::R3Vector const&, gaps::R3Vector const&, gaps::R3Vector const&, gaps::R3Vector&, gaps::R3Vector&)
static void rot_coord_sys(const R3Vector &old_u, const R3Vector &old_v,
			  const R3Vector &new_norm,
			  R3Vector &new_u, R3Vector &new_v)
{
  new_u = old_u;
  new_v = old_v;
  if (new_u.IsZero()) return;
  if (new_v.IsZero()) return;
  R3Vector old_norm = old_u % old_v;
  if (old_norm.IsZero()) return;
  RNScalar ndot = old_norm.Dot(new_norm);
  if (ndot >= 1.0) return;
  if (ndot <= -1.0) {
    new_u = -new_u;
    new_v = -new_v;
    return;
  }
  R3Vector perp_old = new_norm - ndot * old_norm;
  R3Vector dperp = 1.0f / (1 + ndot) * (old_norm + new_norm);
  new_u -= dperp * new_u.Dot(perp_old);
  new_v -= dperp * new_v.Dot(perp_old);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movq %rcx, %rdi
movq %r13, %rsi
callq 0x4b706
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4b706
movsd (%r14), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x18a49
jp 0x18a49
movsd 0x8(%r14), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18a49
jp 0x18a49
movsd 0x10(%r14), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jne 0x18a49
jnp 0x18bdb
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18a73
jp 0x18a73
movsd 0x8(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18a73
jp 0x18a73
movsd 0x10(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18a73
jnp 0x18bdb
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x4b8ae
movsd (%rbp), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x18abb
jp 0x18abb
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18abb
jp 0x18abb
movsd 0x18(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x18abb
jnp 0x18bdb
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x4b206
ucomisd 0xa9550(%rip), %xmm0    # 0xc2020
jae 0x18bdb
movsd 0xa95d2(%rip), %xmm1    # 0xc20b0
ucomisd %xmm0, %xmm1
jae 0x18ba5
leaq 0x50(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movsd %xmm0, (%rsp)
callq 0x4b916
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x4bbf7
movsd 0xa9503(%rip), %xmm0    # 0xc2020
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4bbd4
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movsd (%rsp), %xmm0
callq 0x4b916
movq %r14, %rdi
movq %r12, %rsi
callq 0x4b206
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x4b916
movq %r14, %rdi
movq %r13, %rsi
callq 0x4b966
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4b206
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4b916
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4b966
jmp 0x18bdb
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4bbb4
movq %r14, %rdi
movq %r15, %rsi
callq 0x4b706
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4bbb4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4b706
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq