// File: /workspace/github_cpp_makefile_star2_O2/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 0x2a99d
movq %rdx, %rbx
movl %esi, %r12d
movl %edi, %r13d
cmpl $0x1, %esi
jne 0x2a9aa
movl %r13d, %ecx
movq (%rbx), %rax
movl (%rax,%rcx,4), %ecx
cvtsi2sd %rcx, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2a994
incl %r13d
movl (%rax,%r13,4), %eax
cvtsi2sd %rax, %xmm1
ucomisd %xmm0, %xmm1
jae 0x2ab3e
xorpd %xmm1, %xmm1
jmp 0x2abb6
movsd 0x4ecb(%rip), %xmm1     # 0x2f870
jmp 0x2abb6
leal (%r12,%r13), %ecx
leal (%r12,%r13), %r14d
decl %r14d
movq (%rbx), %rax
movl %r13d, %edi
movl (%rax,%rdi,4), %esi
leal 0x1(%r13), %edx
movq %rcx, -0x50(%rbp)
movl (%rax,%rcx,4), %r15d
movl (%rax,%rdx,4), %ecx
movl %esi, -0x3c(%rbp)
cmpl %esi, (%rax,%r14,4)
jne 0x2a9ee
cmpl %ecx, %r15d
jne 0x2ab48
xorpd %xmm1, %xmm1
cmpl (%rax,%rdx,4), %r15d
jne 0x2aa61
jmp 0x2abb6
cmpl %ecx, %r15d
jne 0x2aa61
movq %rdi, -0x38(%rbp)
decl %r12d
leaq -0xa8(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movsd %xmm0, -0x30(%rbp)
callq 0xb270
movl %r13d, %edi
movl %r12d, %esi
movsd -0x30(%rbp), %xmm0
movq %r15, %rdx
callq 0xc760
movl -0x3c(%rbp), %eax
cvtsi2sd %rax, %xmm1
movsd -0x30(%rbp), %xmm2
subsd %xmm1, %xmm2
movq (%rbx), %rax
movl (%rax,%r14,4), %ecx
movq -0x38(%rbp), %rdx
subl (%rax,%rdx,4), %ecx
mulsd %xmm0, %xmm2
cvtsi2sd %rcx, %xmm0
divsd %xmm0, %xmm2
movsd %xmm2, -0x30(%rbp)
leaq -0xa8(%rbp), %rdi
jmp 0x2abac
movq %rdi, -0x38(%rbp)
movq %rdx, -0x60(%rbp)
decl %r12d
leaq -0x90(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movsd %xmm0, -0x30(%rbp)
callq 0xb270
movl %r13d, %edi
movl %r12d, %esi
movsd -0x30(%rbp), %xmm0
movq %r15, -0x48(%rbp)
movq %r15, %rdx
callq 0xc760
movsd %xmm0, -0x58(%rbp)
movq -0x50(%rbp), %r15
movq (%rbx), %rax
movl (%rax,%r14,4), %r13d
movq -0x38(%rbp), %rcx
subl (%rax,%rcx,4), %r13d
movl (%rax,%r15,4), %eax
movq %rax, -0x38(%rbp)
leaq -0x78(%rbp), %rdi
movq %rbx, %rsi
callq 0xb270
leaq -0x78(%rbp), %rdx
movq -0x60(%rbp), %r14
movl %r14d, %edi
movl %r12d, %esi
movsd -0x30(%rbp), %xmm0
callq 0xc760
movl -0x3c(%rbp), %eax
cvtsi2sd %rax, %xmm1
movsd -0x30(%rbp), %xmm3
movapd %xmm3, %xmm2
subsd %xmm1, %xmm2
mulsd -0x58(%rbp), %xmm2
cvtsi2sd %r13, %xmm1
divsd %xmm1, %xmm2
cvtsi2sdq -0x38(%rbp), %xmm1
subsd %xmm3, %xmm1
mulsd %xmm0, %xmm1
movq (%rbx), %rax
movl (%rax,%r15,4), %ecx
subl (%rax,%r14,4), %ecx
cvtsi2sd %rcx, %xmm0
divsd %xmm0, %xmm1
addsd %xmm2, %xmm1
movsd %xmm1, -0x30(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xb560
leaq -0x90(%rbp), %rdi
jmp 0x2abac
movsd 0x535a(%rip), %xmm1     # 0x2fea0
jmp 0x2abb6
decl %r12d
leaq -0xc0(%rbp), %r13
movq %rdx, %r14
movq %r13, %rdi
movq %rbx, %rsi
movsd %xmm0, -0x30(%rbp)
callq 0xb270
movl %r14d, %edi
movl %r12d, %esi
movsd -0x30(%rbp), %xmm0
movq %r13, %rdx
callq 0xc760
movl %r15d, %eax
cvtsi2sd %rax, %xmm1
subsd -0x30(%rbp), %xmm1
movq (%rbx), %rax
movq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
subl (%rax,%r14,4), %ecx
mulsd %xmm0, %xmm1
cvtsi2sd %rcx, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xb560
movsd -0x30(%rbp), %xmm1
movapd %xmm1, %xmm0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, -0x48(%rbp)
jmp 0x2abe6
movq %r15, -0x48(%rbp)
jmp 0x2abe6
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0xb560
jmp 0x2abe9
movq %rax, %rbx
movq -0x48(%rbp), %rdi
callq 0xb560
movq %rbx, %rdi
callq 0xc520