// File: /workspace/github_cpp_makefile_star2_O3/sundale[P]gcode/rs274ngc/nurbs_additional_functions.cc
// Function: Nmix(unsigned int, unsigned int, double, std::vector<unsigned int, std::allocator<unsigned int>>)
double Nmix(unsigned int i, unsigned int k, double u, 
                    std::vector<unsigned int> knot_vector) {

    if (k == 1){
        if ((u >= knot_vector[i]) && (u <= knot_vector[i+1])) {
            return 1;
        } else {
            return 0;}
    } else if (k > 1) {
        if ((knot_vector[i+k-1]-knot_vector[i] == 0) && 
            (knot_vector[i+k]-knot_vector[i+1] != 0)) {
            return ((knot_vector[i+k] - u)*Nmix(i+1,k-1,u,knot_vector))/
                    (knot_vector[i+k]-knot_vector[i+1]);
        } else if ((knot_vector[i+k]-knot_vector[i+1] == 0) && 
            (knot_vector[i+k-1]-knot_vector[i] != 0)) {
            return ((u - knot_vector[i])*Nmix(i,k-1,u,knot_vector))/
                    (knot_vector[i+k-1]-knot_vector[i]);
        } else if ((knot_vector[i+k-1]-knot_vector[i] == 0) && 
            (knot_vector[i+k]-knot_vector[i+1] == 0)) {
            return 0;
        } else {
            return ((u - knot_vector[i])*Nmix(i,k-1,u,knot_vector))/
                    (knot_vector[i+k-1]-knot_vector[i]) + ((knot_vector[i+k] - u)*
                    Nmix(i+1,k-1,u,knot_vector))/(knot_vector[i+k]-knot_vector[i+1]);
        }
    }
    else return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
testl %esi, %esi
je 0x2d73d
movq %rdx, %rbx
movl %esi, %r15d
movl %edi, %r12d
cmpl $0x1, %esi
jne 0x2d74a
movl %r12d, %ecx
movq (%rbx), %rax
movl (%rax,%rcx,4), %ecx
cvtsi2sd %rcx, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2d734
incl %r12d
movl (%rax,%r12,4), %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
ucomisd %xmm0, %xmm1
jae 0x2d885
xorpd %xmm2, %xmm2
jmp 0x2d993
movsd 0x612b(%rip), %xmm2     # 0x33870
jmp 0x2d993
leal (%r15,%r12), %eax
leal (%r15,%r12), %r13d
decl %r13d
movq (%rbx), %rcx
movl %r12d, %edi
movl (%rcx,%rdi,4), %esi
leal 0x1(%r12), %edx
movq %rax, -0x38(%rbp)
movl (%rcx,%rax,4), %r14d
movq %rdx, -0x50(%rbp)
movl (%rcx,%rdx,4), %eax
movl %esi, -0x3c(%rbp)
cmpl %esi, (%rcx,%r13,4)
jne 0x2d804
xorpd %xmm2, %xmm2
cmpl %eax, %r14d
je 0x2d993
decl %r15d
leaq -0xb8(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movsd %xmm0, -0x30(%rbp)
callq 0xa240
movq -0x50(%rbp), %r13
movl %r13d, %edi
movl %r15d, %esi
movsd -0x30(%rbp), %xmm0
movq %r12, %rdx
callq 0xb5f0
movl %r14d, %eax
xorps %xmm2, %xmm2
cvtsi2sd %rax, %xmm2
subsd -0x30(%rbp), %xmm2
movq (%rbx), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
subl (%rax,%r13,4), %ecx
cvtsi2sd %rcx, %xmm1
mulsd %xmm0, %xmm2
divsd %xmm1, %xmm2
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x2d993
movq -0xa8(%rbp), %rsi
jmp 0x2d981
movq %rdi, -0x48(%rbp)
movsd %xmm0, -0x30(%rbp)
decl %r15d
cmpl %eax, %r14d
jne 0x2d892
leaq -0xa0(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa240
movl %r12d, %edi
movl %r15d, %esi
movsd -0x30(%rbp), %xmm0
movq %r14, %rdx
callq 0xb5f0
movl -0x3c(%rbp), %eax
cvtsi2sd %rax, %xmm1
movsd -0x30(%rbp), %xmm2
subsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
movq (%rbx), %rax
movl (%rax,%r13,4), %ecx
movq -0x48(%rbp), %rdx
subl (%rax,%rdx,4), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
divsd %xmm0, %xmm2
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x2d993
movq -0x90(%rbp), %rsi
jmp 0x2d981
movsd 0x6613(%rip), %xmm2     # 0x33ea0
jmp 0x2d993
leaq -0x88(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa240
movl %r12d, %edi
movl %r15d, %esi
movsd -0x30(%rbp), %xmm0
movq %r14, %rdx
callq 0xb5f0
movsd %xmm0, -0x58(%rbp)
movq (%rbx), %rax
movl (%rax,%r13,4), %r12d
movq -0x48(%rbp), %rcx
subl (%rax,%rcx,4), %r12d
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %r14d
leaq -0x70(%rbp), %rdi
movq %rbx, %rsi
callq 0xa240
leaq -0x70(%rbp), %rdx
movq -0x50(%rbp), %r13
movl %r13d, %edi
movl %r15d, %esi
movsd -0x30(%rbp), %xmm0
callq 0xb5f0
movl -0x3c(%rbp), %eax
cvtsi2sd %rax, %xmm1
movsd -0x30(%rbp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm1, %xmm2
mulsd -0x58(%rbp), %xmm2
xorps %xmm1, %xmm1
cvtsi2sd %r12, %xmm1
cvtsi2sd %r14, %xmm3
divsd %xmm1, %xmm2
subsd %xmm4, %xmm3
movq (%rbx), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
subl (%rax,%r13,4), %ecx
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
mulsd %xmm0, %xmm3
divsd %xmm1, %xmm3
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x2d96d
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
movsd %xmm2, -0x30(%rbp)
movsd %xmm3, -0x38(%rbp)
callq 0xaae0
movsd -0x38(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
addsd %xmm3, %xmm2
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x2d993
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
movsd %xmm2, -0x30(%rbp)
callq 0xaae0
movsd -0x30(%rbp), %xmm2
movapd %xmm2, %xmm0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x2d9f1
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
jmp 0x2d9f1
leaq -0x90(%rbp), %rcx
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
jmp 0x2d9e7
leaq -0xa8(%rbp), %rcx
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
jne 0x2da01
jmp 0x2da0c
movq %rax, %rbx
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x2da0c
leaq -0x78(%rbp), %rcx
movq (%rcx), %rsi
subq %rdi, %rsi
callq 0xaae0
movq %rbx, %rdi
callq 0xb3b0