// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RNMath/RNPolynomial.cpp
// Function: gaps::RNPolynomialTerm::PartialDerivative(double const* const*, int) const
RNScalar RNPolynomialTerm::
PartialDerivative(double const* const* x, int variable) const
{
  // Check if has variable
  if (!HasVariable(variable)) return 0.0;

  // Evaluate the derivative with respect to variable
  RNScalar result = c;
  for (int i = 0; i < NVariables(); i++) {
    int k = Variable(i);
    if (k == variable) {
      if (e[i] == 1.0) result *= 1.0;
      else if (e[i] == 2.0) result *= 2.0 * x[k][0];
      else if ((e[i] < 1.0) && RNIsZero(x[k][0])) result *= RN_INFINITY;
      else result *= e[i] * pow(x[k][0], e[i] - 1.0);
    }
    else {
      if (e[i] == 1.0) result *= x[k][0];
      else if (e[i] == 2.0) result *= x[k][0] * x[k][0];
      else if ((e[i] < 0) && RNIsZero(x[k][0])) result *= RN_INFINITY;
      else result *= pow(x[k][0], e[i]);
    }
  }
  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
movslq 0x8(%rdi), %rax
testq %rax, %rax
setg %cl
jle 0x21f82
movq 0x18(%r15), %rcx
cmpl %ebx, (%rcx)
je 0x21f8e
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rax
je 0x21f7c
leaq 0x1(%rdx), %rsi
cmpl %ebx, (%rcx,%rdx,4)
jne 0x21f6b
cmpq %rax, %rdx
setb %cl
xorpd %xmm4, %xmm4
testb %cl, %cl
je 0x2211e
movsd 0x10(%r15), %xmm4
cmpl $0x0, 0x8(%r15)
jle 0x2211e
xorl %r12d, %r12d
movsd 0x37066(%rip), %xmm5    # 0x59010
movsd 0x38706(%rip), %xmm6    # 0x5a6b8
leaq 0x5a3df(%rip), %r13     # 0x7c398
leaq 0x5a3e8(%rip), %rbp     # 0x7c3a8
movq 0x18(%r15), %rax
movslq (%rax,%r12,4), %rax
cmpl %ebx, %eax
jne 0x21ffb
movq 0x20(%r15), %rcx
movsd (%rcx,%r12,8), %xmm3
ucomisd %xmm5, %xmm3
jne 0x21fe2
jnp 0x2210e
ucomisd %xmm6, %xmm3
jne 0x2203b
jp 0x2203b
movq (%r14,%rax,8), %rax
movsd (%rax), %xmm0
addsd %xmm0, %xmm0
jmp 0x2210a
movq 0x20(%r15), %rcx
movsd (%rcx,%r12,8), %xmm1
ucomisd %xmm5, %xmm1
jne 0x2201a
jp 0x2201a
movq (%r14,%rax,8), %rax
mulsd (%rax), %xmm4
jmp 0x2210e
ucomisd %xmm6, %xmm1
jne 0x220aa
jp 0x220aa
movq (%r14,%rax,8), %rax
movsd (%rax), %xmm0
mulsd %xmm0, %xmm0
jmp 0x2210a
ucomisd %xmm3, %xmm5
jbe 0x22067
movq (%r14,%rax,8), %rcx
movsd (%rcx), %xmm0
movsd (%r13), %xmm1
movapd %xmm1, %xmm2
xorpd 0x37005(%rip), %xmm2    # 0x59060
ucomisd %xmm2, %xmm0
jb 0x22067
ucomisd %xmm0, %xmm1
jae 0x220da
movq (%r14,%rax,8), %rax
movsd (%rax), %xmm0
movapd %xmm3, %xmm1
addsd 0x3778d(%rip), %xmm1    # 0x59808
movsd %xmm4, 0x8(%rsp)
movsd %xmm3, 0x10(%rsp)
callq 0x44a0
movsd 0x38624(%rip), %xmm6    # 0x5a6b8
movsd 0x36f74(%rip), %xmm5    # 0x59010
movsd 0x8(%rsp), %xmm4
mulsd 0x10(%rsp), %xmm0
jmp 0x2210a
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x220e1
movq (%r14,%rax,8), %rcx
movsd (%rcx), %xmm0
movsd (%r13), %xmm2
movapd %xmm2, %xmm3
xorpd 0x36f92(%rip), %xmm3    # 0x59060
ucomisd %xmm3, %xmm0
jb 0x220e1
ucomisd %xmm0, %xmm2
jb 0x220e1
mulsd (%rbp), %xmm4
jmp 0x2210e
movq (%r14,%rax,8), %rax
movsd (%rax), %xmm0
movsd %xmm4, 0x8(%rsp)
callq 0x44a0
movsd 0x385bc(%rip), %xmm6    # 0x5a6b8
movsd 0x36f0c(%rip), %xmm5    # 0x59010
movsd 0x8(%rsp), %xmm4
mulsd %xmm0, %xmm4
incq %r12
movslq 0x8(%r15), %rax
cmpq %rax, %r12
jl 0x21fc0
movapd %xmm4, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop