// File: /workspace/github_cpp_makefile_star2_O1/pitzl[P]bobyqa/bobyqa.cc
// Function: update(long, long, double*, double*, long, double*, double, double, long, double*)
static void
update(const INTEGER n, const INTEGER npt, REAL* bmat,
       REAL* zmat, const INTEGER ndim, REAL* vlag, const REAL beta,
       const REAL denom, const INTEGER knew, REAL* w)
{
  /* The arrays BMAT and ZMAT are updated, as required by the new position of
     the interpolation point that has the index KNEW.  The vector VLAG has
     N+NPT components, set on entry to the first NPT and last N components of
     the product Hw in equation (4.11) of the Powell (2006) paper on NEWUOA.
     Further, BETA is set on entry to the value of the parameter with that
     name, and DENOM is set to the denominator of the updating formula.
     Elements of ZMAT may be treated as zero if their moduli are at most ZTEST.
     The first NDIM elements of W are used for working space. */

  /* Constants. */
  const REAL one = 1.0;
  const REAL zero = 0.0;

  /* Local variables. */
  REAL alpha, tau, temp, tempa, tempb, ztest;
  INTEGER i, j, jp, k, nptm;

  /* Parameter adjustments to comply with FORTRAN indexing. */
  zmat -= 1 + npt;
  bmat -= 1 + ndim;
  vlag -= 1;
  w    -= 1;
#define BMAT(a1,a2) bmat[(a2)*ndim + a1]
#define ZMAT(a1,a2) zmat[(a2)*npt + a1]

  /* Initialization. */
  nptm = npt - n - 1;
  ztest = zero;
  LOOP(k,npt ) {
    LOOP(j,nptm ) {
      temp = ABS(ZMAT(k,j));
      ztest = MAX(ztest, temp);
    }
  }
  ztest *= 1e-20;

  /* Apply the rotations that put zeros in the KNEW-th row of ZMAT. */
  for( j = 2; j <= nptm; ++j ) {
    if( ABS(ZMAT(knew,j)) > ztest ) {
      tempa = ZMAT(knew,1);
      tempb = ZMAT(knew,j);
      temp = SQRT(tempa*tempa + tempb*tempb);
      tempa /= temp;
      tempb /= temp;
      LOOP(i,npt ) {
        temp = tempa*ZMAT(i,1) + tempb*ZMAT(i,j);
        ZMAT(i,j) = tempa*ZMAT(i,j) - tempb*ZMAT(i,1);
        ZMAT(i,1) = temp;
      }
    }
    ZMAT(knew, j) = zero;
  }

  /* Put the first NPT components of the KNEW-th column of HLAG into W, and
     calculate the parameters of the updating formula. */
  LOOP(i,npt ) {
    w[i] = ZMAT(knew,1)*ZMAT(i,1);
  }
  alpha = w[knew];
  tau = vlag[knew];
  vlag[knew] -= one;

  /* Complete the updating of ZMAT. */
  temp = SQRT(denom);
  tempb = ZMAT(knew,1)/temp;
  tempa = tau/temp;
  LOOP(i,npt ) {
    ZMAT(i,1) = tempa*ZMAT(i,1) - tempb*vlag[i];
  }

  /* Finally, update the matrix BMAT. */
  LOOP(j,n ) {
    jp = npt + j;
    w[jp] = BMAT(knew, j);
    tempa = (alpha*vlag[jp] - tau*w[jp])/denom;
    tempb = (-beta*w[jp] - tau*vlag[jp])/denom;
    LOOP(i,jp ) {
      BMAT(i,j) = BMAT(i,j) + tempa*vlag[i] + tempb*w[i];
      if( i > npt ) {
        BMAT(jp, i - npt) = BMAT(i,j);
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movsd %xmm1, 0x18(%rsp)
movapd %xmm0, %xmm5
movq %r9, %rbx
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rax
notq %rax
addq %rsi, %rax
testq %rsi, %rsi
movq %r8, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
jle 0x8d4a
leaq (,%r12,8), %rcx
xorpd %xmm6, %xmm6
movl $0x1, %esi
movapd 0x1334(%rip), %xmm0     # 0xa030
movq %rbp, %rdx
testq %rax, %rax
jle 0x8d30
movq %rdx, %r10
movq %rax, %r9
movsd (%r10), %xmm1
andpd %xmm0, %xmm1
movapd %xmm1, %xmm2
cmplesd %xmm6, %xmm2
andpd %xmm2, %xmm6
andnpd %xmm1, %xmm2
orpd %xmm2, %xmm6
addq %rcx, %r10
decq %r9
jne 0x8d0a
leaq 0x1(%rsi), %r9
addq $0x8, %rdx
cmpq %r12, %rsi
movq %r9, %rsi
jne 0x8cff
mulsd 0x13d0(%rip), %xmm6     # 0xa118
jmp 0x8d4e
xorpd %xmm6, %xmm6
movq 0xb0(%rsp), %r10
cmpq $0x2, %rax
movapd %xmm5, 0x50(%rsp)
jl 0x8edd
movq %r12, %rax
notq %rax
leaq (,%rax,8), %rcx
addq %rbp, %rcx
movq %r12, %rdx
subq 0x10(%rsp), %rdx
leaq (,%r12,8), %rsi
leaq (,%r12,8), %r13
addq %rbp, %r13
movl $0x2, %r14d
movapd 0x1290(%rip), %xmm7     # 0xa030
xorpd %xmm8, %xmm8
movapd %xmm6, 0x60(%rsp)
movq %rcx, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %r14, %rax
imulq %r12, %rax
leaq (%rcx,%rax,8), %rdi
movsd (%rdi,%r10,8), %xmm9
movapd %xmm9, %xmm0
andpd %xmm7, %xmm0
ucomisd %xmm6, %xmm0
jbe 0x8ec6
movsd -0x8(%rbp,%r10,8), %xmm10
movapd %xmm9, %xmm1
mulsd %xmm9, %xmm1
movapd %xmm10, %xmm0
mulsd %xmm10, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm8, %xmm0
jb 0x8e0a
sqrtsd %xmm0, %xmm0
jmp 0x8e63
movq %rdi, (%rsp)
movapd %xmm9, 0x20(%rsp)
movsd %xmm10, 0x48(%rsp)
callq 0x1040
movsd 0x48(%rsp), %xmm10
movapd 0x20(%rsp), %xmm9
movq (%rsp), %rdi
xorpd %xmm8, %xmm8
movapd 0x11f0(%rip), %xmm7     # 0xa030
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
movapd 0x60(%rsp), %xmm6
movq 0xb0(%rsp), %r10
movapd 0x50(%rsp), %xmm5
testq %r12, %r12
jle 0x8ec6
divsd %xmm0, %xmm10
divsd %xmm0, %xmm9
movapd %xmm9, %xmm0
xorpd 0x1181(%rip), %xmm0     # 0xa000
xorl %eax, %eax
movsd (%rbp,%rax,8), %xmm1
movsd (%r13,%rax,8), %xmm2
movapd %xmm9, %xmm3
mulsd %xmm2, %xmm3
movapd %xmm10, %xmm4
mulsd %xmm1, %xmm4
addsd %xmm3, %xmm4
mulsd %xmm0, %xmm1
mulsd %xmm10, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%r13,%rax,8)
movsd %xmm4, (%rbp,%rax,8)
incq %rax
cmpq %rax, %r12
jne 0x8e81
movq $0x0, (%rdi,%r10,8)
incq %r14
addq %rsi, %r13
cmpq %rdx, %r14
jne 0x8dba
movq 0xb8(%rsp), %r13
testq %r12, %r12
jle 0x8f08
xorl %eax, %eax
movsd -0x8(%rbp,%r10,8), %xmm0
mulsd (%rbp,%rax,8), %xmm0
movsd %xmm0, (%r13,%rax,8)
incq %rax
cmpq %rax, %r12
jne 0x8eec
movsd -0x8(%r13,%r10,8), %xmm6
movsd -0x8(%rbx,%r10,8), %xmm7
movsd 0x1162(%rip), %xmm0     # 0xa080
addsd %xmm7, %xmm0
movsd %xmm0, -0x8(%rbx,%r10,8)
xorpd %xmm0, %xmm0
movsd 0x18(%rsp), %xmm4
ucomisd %xmm0, %xmm4
movq 0x10(%rsp), %r14
jb 0x8f47
xorps %xmm0, %xmm0
sqrtsd %xmm4, %xmm0
jmp 0x8f7a
movapd %xmm4, %xmm0
movsd %xmm6, (%rsp)
movapd %xmm7, 0x20(%rsp)
callq 0x1040
movapd 0x20(%rsp), %xmm7
movsd (%rsp), %xmm6
movq 0xb0(%rsp), %r10
movapd 0x50(%rsp), %xmm5
movsd 0x18(%rsp), %xmm4
movq 0x8(%rsp), %r11
testq %r12, %r12
jle 0x8fc6
movapd %xmm7, %xmm1
divsd %xmm0, %xmm1
movsd -0x8(%rbp,%r10,8), %xmm2
xorpd 0x1065(%rip), %xmm2     # 0xa000
divsd %xmm0, %xmm2
xorl %eax, %eax
movsd (%rbx,%rax,8), %xmm0
mulsd %xmm2, %xmm0
movsd (%rbp,%rax,8), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
movsd %xmm3, (%rbp,%rax,8)
incq %rax
cmpq %rax, %r12
jne 0x8fa1
testq %r14, %r14
jle 0x90cb
movq %r11, %rax
notq %rax
leaq (%r15,%rax,8), %rax
movapd 0x101f(%rip), %xmm0     # 0xa000
xorpd %xmm0, %xmm7
xorpd %xmm0, %xmm5
movq %r12, %rcx
negq %rcx
leaq (,%r11,8), %rdx
movl $0x8, %esi
subq %rdx, %rsi
imulq %r12, %rsi
addq %r15, %rsi
movl $0x1, %edi
leaq (%rdi,%r12), %r8
movq %rdi, %r9
imulq %r11, %r9
leaq (%rax,%r9,8), %r9
movsd (%r9,%r10,8), %xmm2
movsd %xmm2, -0x8(%r13,%r8,8)
testq %r8, %r8
jle 0x90a9
movsd -0x8(%rbx,%r8,8), %xmm0
movapd %xmm5, %xmm3
mulsd %xmm2, %xmm3
mulsd %xmm7, %xmm2
movapd %xmm6, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm1
divsd %xmm4, %xmm1
mulsd %xmm7, %xmm0
addsd %xmm3, %xmm0
divsd %xmm4, %xmm0
movl $0x1, %r8d
movq %rsi, %r9
movsd -0x8(%rbx,%r8,8), %xmm3
mulsd %xmm1, %xmm3
addsd -0x8(%r15,%r8,8), %xmm3
movsd -0x8(%r13,%r8,8), %xmm2
mulsd %xmm0, %xmm2
addsd %xmm3, %xmm2
movsd %xmm2, -0x8(%r15,%r8,8)
cmpq %r12, %r8
jle 0x9096
movsd %xmm2, (%r9)
leaq (%rcx,%r8), %r10
incq %r10
incq %r8
addq %rdx, %r9
cmpq $0x2, %r10
jne 0x9064
leaq 0x1(%rdi), %r8
decq %rcx
addq $0x8, %rsi
addq %rdx, %r15
cmpq %r14, %rdi
movq %r8, %rdi
movq 0xb0(%rsp), %r10
jne 0x900b
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq