// File: /workspace/github_cpp_makefile_star2_O1/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 0x4bd5e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4bd5e
movsd (%r14), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x18b43
jp 0x18b43
movsd 0x8(%r14), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18b43
jp 0x18b43
movsd 0x10(%r14), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jne 0x18b43
jnp 0x18cd5
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18b6d
jp 0x18b6d
movsd 0x8(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18b6d
jp 0x18b6d
movsd 0x10(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18b6d
jnp 0x18cd5
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x4bf06
movsd (%rbp), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x18bb5
jp 0x18bb5
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x18bb5
jp 0x18bb5
movsd 0x18(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x18bb5
jnp 0x18cd5
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x4b84a
ucomisd 0xab456(%rip), %xmm0    # 0xc4020
jae 0x18cd5
movsd 0xab4d8(%rip), %xmm1    # 0xc40b0
ucomisd %xmm0, %xmm1
jae 0x18c9f
leaq 0x50(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movsd %xmm0, (%rsp)
callq 0x4bf82
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x4c28b
movsd 0xab409(%rip), %xmm0    # 0xc4020
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 0x4c268
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movsd (%rsp), %xmm0
callq 0x4bf82
movq %r14, %rdi
movq %r12, %rsi
callq 0x4b84a
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x4bf82
movq %r14, %rdi
movq %r13, %rsi
callq 0x4bfd2
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4b84a
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4bf82
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4bfd2
jmp 0x18cd5
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4c248
movq %r14, %rdi
movq %r15, %rsi
callq 0x4bd5e
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4c248
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4bd5e
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq