// File: /workspace/github_cpp_makefile_star2_O1/sundale[P]gcode/rs274ngc/nurbs_additional_functions.cc
// Function: nurbs_tangent(double, unsigned int, std::vector<CONTROL_POINT, std::allocator<CONTROL_POINT>>, std::vector<unsigned int, std::allocator<unsigned int>>)
PLANE_POINT nurbs_tangent(double u, unsigned int k,
                  std::vector<CONTROL_POINT> nurbs_control_points,
                  std::vector<unsigned int> knot_vector) {
    unsigned int n = nurbs_control_points.size() - 1;
    double umax = n - k + 2;
    double ulo = std::max(0.0, u-DU), uhi = std::min(umax, u+DU);
    PLANE_POINT P1 = nurbs_point(ulo, k, nurbs_control_points, knot_vector);
    PLANE_POINT P3 = nurbs_point(uhi, k, nurbs_control_points, knot_vector);
    PLANE_POINT r = {(P3.X - P1.X) / (uhi-ulo), (P3.Y - P1.Y) / (uhi-ulo)};
    unit(r);
    return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebx
movsd %xmm0, -0x30(%rbp)
movq 0x8(%rsi), %r12
subq (%rsi), %r12
leaq -0xb0(%rbp), %rdi
callq 0xa5e0
leaq -0x98(%rbp), %rdi
movq %r14, %rsi
callq 0xa240
movsd 0xc1ed(%rip), %xmm0     # 0x3d9f8
addsd -0x30(%rbp), %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm1, %xmm0
leaq -0xb0(%rbp), %rsi
leaq -0x98(%rbp), %rdx
movsd %xmm0, -0x50(%rbp)
movl %ebx, %edi
callq 0xaca0
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x48(%rbp)
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0x31857
movq -0x88(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x31872
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
leaq -0x80(%rbp), %rdi
movq %r15, %rsi
callq 0xa5e0
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
callq 0xa240
shrq $0x3, %r12
imull $0xaaaaaaab, %r12d, %eax # imm = 0xAAAAAAAB
subl %ebx, %eax
incl %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movsd -0x30(%rbp), %xmm0
addsd 0xc152(%rip), %xmm0     # 0x3da00
minsd %xmm1, %xmm0
leaq -0x80(%rbp), %rsi
leaq -0x68(%rbp), %rdx
movsd %xmm0, -0x30(%rbp)
movl %ebx, %edi
callq 0xaca0
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x28(%rbp)
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x318e5
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x318fa
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
movsd -0x38(%rbp), %xmm0
subsd -0x40(%rbp), %xmm0
movsd -0x30(%rbp), %xmm2
subsd -0x50(%rbp), %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x28(%rbp), %xmm1
subsd -0x48(%rbp), %xmm1
divsd %xmm2, %xmm1
movsd %xmm1, -0x28(%rbp)
callq 0xa290
movapd %xmm0, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
movsd -0x38(%rbp), %xmm0
movapd %xmm0, %xmm1
divsd %xmm2, %xmm0
jne 0x31950
jp 0x31950
movapd %xmm1, %xmm0
movsd -0x28(%rbp), %xmm1
divsd %xmm2, %xmm1
jne 0x31962
jp 0x31962
movsd -0x28(%rbp), %xmm1
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x3198f
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
jmp 0x3198f
movq %rax, %rbx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x319df
leaq -0x70(%rbp), %rax
jmp 0x319d4
movq %rax, %rbx
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0x319c1
movq -0x88(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
jmp 0x319c1
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x319df
leaq -0xa0(%rbp), %rax
movq (%rax), %rsi
subq %rdi, %rsi
callq 0xaae0
movq %rbx, %rdi
callq 0xb3b0
nop