// File: 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
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdx, -0x98(%rbp)
movl %edi, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpl $0x1, -0x10(%rbp)
jne 0x6eb42
movq -0x98(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x11900
movsd -0xa0(%rbp), %xmm0
movl (%rax), %eax
cvtsi2sd %rax, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6eb35
movq -0x98(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movl -0xc(%rbp), %eax
incl %eax
movl %eax, %esi
callq 0x11900
movsd -0xa8(%rbp), %xmm1
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
ucomisd %xmm1, %xmm0
jb 0x6eb35
movsd 0xa2e5(%rip), %xmm0     # 0x78e10
movsd %xmm0, -0x8(%rbp)
jmp 0x6f1c5
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x6f1c5
cmpl $0x1, -0x10(%rbp)
jbe 0x6f1b8
movq -0x98(%rbp), %rdi
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xac(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x11900
movq %rax, %rcx
movl -0xac(%rbp), %eax
subl (%rcx), %eax
cmpl $0x0, %eax
jne 0x6ecff
movq -0x98(%rbp), %rdi
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xb0(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x11900
movq %rax, %rcx
movl -0xb0(%rbp), %eax
subl (%rcx), %eax
cmpl $0x0, %eax
je 0x6ecff
movq -0x98(%rbp), %rdi
movl -0xc(%rbp), %eax
movl -0x10(%rbp), %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rsi
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
movsd -0x18(%rbp), %xmm1
movsd %xmm1, -0xc8(%rbp)
subsd %xmm1, %xmm0
movsd %xmm0, -0xd8(%rbp)
movl -0xc(%rbp), %eax
incl %eax
movl %eax, -0xd0(%rbp)
movl -0x10(%rbp), %eax
decl %eax
movl %eax, -0xcc(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x10400
movl -0xd0(%rbp), %edi
movl -0xcc(%rbp), %esi
movsd -0xc8(%rbp), %xmm0
movq -0xc0(%rbp), %rdx
callq 0x12260
movsd %xmm0, -0xb8(%rbp)
jmp 0x6ec67
movq -0x98(%rbp), %rdi
movsd -0xb8(%rbp), %xmm1
movsd -0xd8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movl -0xc(%rbp), %eax
movl -0x10(%rbp), %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xdc(%rbp)
movl -0xc(%rbp), %eax
incl %eax
movl %eax, %esi
callq 0x11900
movsd -0xe8(%rbp), %xmm0
movq %rax, %rcx
movl -0xdc(%rbp), %eax
movl (%rcx), %ecx
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x12390
jmp 0x6f1c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x12390
jmp 0x6f1d3
movq -0x98(%rbp), %rdi
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xec(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x11900
movq %rax, %rcx
movl -0xec(%rbp), %eax
subl (%rcx), %eax
cmpl $0x0, %eax
jne 0x6eec4
movq -0x98(%rbp), %rdi
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xf0(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x11900
movq %rax, %rcx
movl -0xf0(%rbp), %eax
subl (%rcx), %eax
cmpl $0x0, %eax
je 0x6eec4
movq -0x98(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x120(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x11900
movsd -0x120(%rbp), %xmm0
movq -0x98(%rbp), %rsi
movl (%rax), %eax
cvtsi2sd %rax, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x118(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x110(%rbp)
movl -0x10(%rbp), %eax
decl %eax
movl %eax, -0x10c(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x10400
movl -0x110(%rbp), %edi
movl -0x10c(%rbp), %esi
movsd -0x108(%rbp), %xmm0
movq -0x100(%rbp), %rdx
callq 0x12260
movsd %xmm0, -0xf8(%rbp)
jmp 0x6ee28
movq -0x98(%rbp), %rdi
movsd -0xf8(%rbp), %xmm1
movsd -0x118(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x130(%rbp)
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal -0x1(%rax,%rcx), %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x124(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x11900
movsd -0x130(%rbp), %xmm0
movq %rax, %rcx
movl -0x124(%rbp), %eax
movl (%rcx), %ecx
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x12390
jmp 0x6f1c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x12390
jmp 0x6f1d3
movq -0x98(%rbp), %rdi
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x134(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x11900
movq %rax, %rcx
movl -0x134(%rbp), %eax
subl (%rcx), %eax
cmpl $0x0, %eax
jne 0x6ef57
movq -0x98(%rbp), %rdi
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x138(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x11900
movq %rax, %rcx
movl -0x138(%rbp), %eax
subl (%rcx), %eax
cmpl $0x0, %eax
jne 0x6ef57
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x6f1c5
movq -0x98(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x168(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x11900
movsd -0x168(%rbp), %xmm0
movq -0x98(%rbp), %rsi
movl (%rax), %eax
cvtsi2sd %rax, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x160(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x158(%rbp)
movl -0x10(%rbp), %eax
decl %eax
movl %eax, -0x154(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x150(%rbp)
leaq -0x78(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x10400
movl -0x158(%rbp), %edi
movl -0x154(%rbp), %esi
movsd -0x150(%rbp), %xmm0
movq -0x148(%rbp), %rdx
callq 0x12260
movsd %xmm0, -0x140(%rbp)
jmp 0x6eff2
movq -0x98(%rbp), %rdi
movsd -0x140(%rbp), %xmm1
movsd -0x160(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x198(%rbp)
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal -0x1(%rax,%rcx), %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x18c(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x11900
movsd -0x198(%rbp), %xmm0
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl -0x18c(%rbp), %eax
movl (%rcx), %ecx
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x188(%rbp)
movl -0xc(%rbp), %eax
movl -0x10(%rbp), %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rsi
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
movsd -0x18(%rbp), %xmm1
movsd %xmm1, -0x180(%rbp)
subsd %xmm1, %xmm0
movsd %xmm0, -0x178(%rbp)
movl -0xc(%rbp), %eax
incl %eax
movl %eax, -0x170(%rbp)
movl -0x10(%rbp), %eax
decl %eax
movl %eax, -0x16c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x10400
jmp 0x6f0ca
movsd -0x180(%rbp), %xmm0
movl -0x16c(%rbp), %esi
movl -0x170(%rbp), %edi
leaq -0x90(%rbp), %rdx
callq 0x12260
movsd %xmm0, -0x1a0(%rbp)
jmp 0x6f0f4
movq -0x98(%rbp), %rdi
movsd -0x1a0(%rbp), %xmm1
movsd -0x178(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x1b0(%rbp)
movl -0xc(%rbp), %eax
movl -0x10(%rbp), %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x11900
movq -0x98(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x1a4(%rbp)
movl -0xc(%rbp), %eax
incl %eax
movl %eax, %esi
callq 0x11900
movsd -0x1b0(%rbp), %xmm1
movsd -0x188(%rbp), %xmm0
movq %rax, %rcx
movl -0x1a4(%rbp), %eax
movl (%rcx), %ecx
subl %ecx, %eax
cvtsi2sd %rax, %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x12390
leaq -0x78(%rbp), %rdi
callq 0x12390
jmp 0x6f1c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x6f1ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x12390
leaq -0x78(%rbp), %rdi
callq 0x12390
jmp 0x6f1d3
movsd 0x96a0(%rip), %xmm0     # 0x78860
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x11f50
nopl (%rax)