// File: /workspace/github_cpp_makefile_star2_O3/canzarlab[P]Trajan/geno/augmentedLagrangian.cpp
// Function: AugmentedNLP::functionValueAndGradient(double const*, double&, double*)
virtual bool functionValueAndGradient(const Scalar* x,
					Scalar& functionValue,
					Scalar* gradient)
  {
    _genoNLP.functionValueAndGradient(x, functionValue, gradient);

    _genoNLP.functionValueConstraints(x, _constraintValues.data());

    computeConstraintError();
    
    Vector toAdd(_constraintError);
    // for equality constraints
    toAdd.head(_mEqualities) += _y.head(_mEqualities) / _rho;

    // for inequality constraints
    toAdd.tail(_mInequalities) += _y.tail(_mInequalities) / _rho;
    for (size_t i = 0; i < _mInequalities; ++i) {
      if (_cType[i+_mEqualities] == 2)
        if (toAdd(_mEqualities + i) > 0)
          toAdd(_mEqualities + i) = 0;

      if (_cType[i+_mEqualities] == 4)
	if (toAdd(_mEqualities + i) < 0)
	  toAdd(_mEqualities + i) = 0;
    }
    functionValue += _rho/2 * toAdd.squaredNorm();

    Vector::MapType gradientMapX(gradient, _n);
    Vector gradientX(_n);

    Vector v = _rho * toAdd;
    _genoNLP.gradientConstraintsTimesVector(x, v.data(), gradientX.data());

    gradientMapX += gradientX;
    //    std::cout << "const " << _constraintValues.transpose() << std::endl;
    //    std::cout << "toAdd " << toAdd.transpose() << std::endl;
    return true;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %rbx
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %r15
movq 0x8(%rdi), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq 0x8(%r15), %rdi
movq 0x30(%r15), %rdx
movq (%rdi), %rax
movq %rbp, %rsi
callq *0x70(%rax)
movq %r15, %rdi
callq 0xfb98
leaq 0x90(%r15), %rsi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x10120
movq 0x20(%r15), %rax
movq 0x48(%r15), %rcx
testq %rcx, %rcx
sete %dl
testq %rax, %rax
setns %sil
orb %dl, %sil
je 0xfa96
testq %rax, %rax
js 0xfa77
cmpq %rax, 0x50(%r15)
jl 0xfa77
cmpq %rax, 0x10(%rsp)
jl 0xfa77
movq 0x8(%rsp), %rdx
movq %rax, %rdi
testb $0x7, %dl
jne 0xf647
movl %edx, %edi
shrl $0x3, %edi
andl $0x1, %edi
cmpq %rax, %rdi
cmovaeq %rax, %rdi
movsd 0x40(%r15), %xmm0
movq %rax, %r8
subq %rdi, %r8
movq %r8, %rsi
shrq $0x3f, %rsi
addq %r8, %rsi
andq $-0x2, %rsi
testq %rdi, %rdi
je 0xf687
xorl %r9d, %r9d
movsd (%rcx,%r9,8), %xmm1
divsd %xmm0, %xmm1
addsd (%rdx,%r9,8), %xmm1
movsd %xmm1, (%rdx,%r9,8)
incq %r9
cmpq %r9, %rdi
jne 0xf669
addq %rdi, %rsi
cmpq $0x2, %r8
jl 0xf6b4
movapd %xmm0, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movupd (%rcx,%rdi,8), %xmm2
divpd %xmm1, %xmm2
addpd (%rdx,%rdi,8), %xmm2
movapd %xmm2, (%rdx,%rdi,8)
addq $0x2, %rdi
cmpq %rsi, %rdi
jl 0xf698
cmpq %rax, %rsi
jge 0xf6d4
movsd (%rcx,%rsi,8), %xmm1
divsd %xmm0, %xmm1
addsd (%rdx,%rsi,8), %xmm1
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0xf6b9
movq 0x28(%r15), %rcx
movq 0x48(%r15), %rax
testq %rax, %rax
sete %dl
testq %rcx, %rcx
setns %sil
orb %dl, %sil
je 0xfa96
movq 0x50(%r15), %rdx
movq %rdx, %r9
subq %rcx, %r9
movq %r9, %rsi
orq %rcx, %rsi
js 0xfa77
testq %rcx, %rcx
js 0xfab5
movq 0x10(%rsp), %rsi
movq %rsi, %r8
subq %rcx, %r8
movq %r8, %rdi
orq %rcx, %rdi
js 0xfa77
movq %rbp, 0x30(%rsp)
movq 0x8(%rsp), %rdi
leaq (%rdi,%r8,8), %r8
movq %rcx, %r10
testb $0x7, %r8b
jne 0xf751
movl %r8d, %r10d
shrl $0x3, %r10d
andl $0x1, %r10d
cmpq %rcx, %r10
cmovaeq %rcx, %r10
movsd 0x40(%r15), %xmm0
leaq (%rax,%r9,8), %r11
movq %rcx, %rbp
subq %r10, %rbp
movq %rbp, %r9
shrq $0x3f, %r9
addq %rbp, %r9
andq $-0x2, %r9
testq %r10, %r10
je 0xf795
xorl %r12d, %r12d
movsd (%r11,%r12,8), %xmm1
divsd %xmm0, %xmm1
addsd (%r8,%r12,8), %xmm1
movsd %xmm1, (%r8,%r12,8)
incq %r12
cmpq %r12, %r10
jne 0xf777
addq %r10, %r9
cmpq $0x2, %rbp
jl 0xf7c5
movapd %xmm0, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movupd (%r11,%r10,8), %xmm2
divpd %xmm1, %xmm2
addpd (%r8,%r10,8), %xmm2
movapd %xmm2, (%r8,%r10,8)
addq $0x2, %r10
cmpq %r9, %r10
jl 0xf7a6
subq %rcx, %r9
jge 0xf7ed
leaq (%rax,%rdx,8), %rax
leaq (%rdi,%rsi,8), %rcx
movsd (%rax,%r9,8), %xmm1
divsd %xmm0, %xmm1
addsd (%rcx,%r9,8), %xmm1
movsd %xmm1, (%rcx,%r9,8)
incq %r9
jne 0xf7d2
movq 0x28(%r15), %rax
testq %rax, %rax
je 0xf880
movq 0x20(%r15), %rcx
movq 0x78(%r15), %rdx
movq 0x8(%rsp), %rsi
leaq (%rsi,%rcx,8), %rdi
xorl %r8d, %r8d
xorpd %xmm0, %xmm0
movq %rcx, %r9
movl (%rdx,%r9,4), %r10d
cmpl $0x4, %r10d
je 0xf84d
cmpl $0x2, %r10d
jne 0xf871
testq %r9, %r9
js 0xfa58
cmpq %r9, 0x10(%rsp)
jle 0xfa58
movsd (%rdi), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xf871
leaq (%rcx,%r8), %r10
leaq (%rsi,%r10,8), %r10
jmp 0xf86a
testq %r9, %r9
js 0xfa58
cmpq %r9, 0x10(%rsp)
jle 0xfa58
ucomisd (%rdi), %xmm0
movq %rdi, %r10
jbe 0xf871
movq $0x0, (%r10)
incq %r8
incq %r9
addq $0x8, %rdi
decq %rax
jne 0xf815
movsd 0x40(%r15), %xmm1
movq %r14, 0x18(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0xf8c8
movsd %xmm1, 0x28(%rsp)
jle 0xfaf3
movq 0x8(%rsp), %rax
leaq 0x38(%rsp), %rdi
movq %rax, 0x8(%rdi)
leaq 0x18(%rsp), %rax
movq %rax, 0x18(%rdi)
leaq 0x7(%rsp), %rsi
callq 0xfe82
movsd 0x28(%rsp), %xmm1
jmp 0xf8cc
xorpd %xmm0, %xmm0
mulsd 0x4cb44(%rip), %xmm1    # 0x5c418
mulsd %xmm0, %xmm1
addsd (%r13), %xmm1
movsd %xmm1, (%r13)
movq 0x10(%r15), %rbp
testq %rbp, %rbp
js 0xfad4
je 0xf955
movq %rbp, %rax
shrq $0x3d, %rax
jne 0xf927
leaq (,%rbp,8), %rdi
callq 0x9450
movq %rax, %r13
cmpq $0x1, %rbp
setne %al
testb $0xf, %r13b
setne %cl
testb %cl, %al
jne 0xfb12
testq %r13, %r13
jne 0xf958
movl $0x8, %edi
callq 0x9180
movq 0x76678(%rip), %rcx     # 0x85fb0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x76682(%rip), %rsi     # 0x85fc8
movq 0x76643(%rip), %rdx     # 0x85f90
movq %rax, %rdi
callq 0x9640
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
testq %rax, %rax
js 0xfab5
movsd 0x40(%r15), %xmm0
leaq 0x38(%rsp), %rsi
movq %rax, 0x8(%rsi)
movsd %xmm0, 0x18(%rsi)
movq %r14, 0x20(%rsi)
leaq 0x18(%rsp), %rdi
callq 0xfff4
movq 0x8(%r15), %rdi
movq 0x18(%rsp), %rdx
movq (%rdi), %rax
movq 0x30(%rsp), %rsi
movq %r13, %rcx
callq *0x78(%rax)
movq %rbp, %rcx
testb $0x7, %bl
jne 0xf9b6
movl %ebx, %ecx
shrl $0x3, %ecx
andl $0x1, %ecx
cmpq %rbp, %rcx
cmovaeq %rbp, %rcx
movq %rbp, %rdx
subq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
andq $-0x2, %rax
testq %rcx, %rcx
je 0xf9ea
xorl %esi, %esi
movsd (%r13,%rsi,8), %xmm0
addsd (%rbx,%rsi,8), %xmm0
movsd %xmm0, (%rbx,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0xf9d1
addq %rcx, %rax
cmpq $0x2, %rdx
jl 0xfa0d
movupd (%r13,%rcx,8), %xmm0
addpd (%rbx,%rcx,8), %xmm0
movapd %xmm0, (%rbx,%rcx,8)
addq $0x2, %rcx
cmpq %rax, %rcx
jl 0xf9f3
cmpq %rbp, %rax
jge 0xfa2b
movsd (%r13,%rax,8), %xmm0
addsd (%rbx,%rax,8), %xmm0
movsd %xmm0, (%rbx,%rax,8)
incq %rax
cmpq %rax, %rbp
jne 0xfa12
movq 0x18(%rsp), %rdi
callq 0x93d0
movq %r13, %rdi
callq 0x93d0
movq 0x8(%rsp), %rdi
callq 0x93d0
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4d7e6(%rip), %rdi     # 0x5d245
leaq 0x4d7fc(%rip), %rsi     # 0x5d262
leaq 0x4d818(%rip), %rcx     # 0x5d285
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x9200
leaq 0x4cd6d(%rip), %rdi     # 0x5c7eb
leaq 0x4cc91(%rip), %rsi     # 0x5c716
leaq 0x4cca3(%rip), %rcx     # 0x5c72f
movl $0x93, %edx
callq 0x9200
leaq 0x4cddd(%rip), %rdi     # 0x5c87a
leaq 0x4ce80(%rip), %rsi     # 0x5c924
leaq 0x4ce94(%rip), %rcx     # 0x5c93f
movl $0xaf, %edx
callq 0x9200
leaq 0x4caa0(%rip), %rdi     # 0x5c55c
leaq 0x4cb2e(%rip), %rsi     # 0x5c5f1
leaq 0x4cb49(%rip), %rcx     # 0x5c613
movl $0x4a, %edx
callq 0x9200
leaq 0x4d0cc(%rip), %rdi     # 0x5cba7
leaq 0x4ce42(%rip), %rsi     # 0x5c924
leaq 0x4d0cb(%rip), %rcx     # 0x5cbb4
movl $0xa3, %edx
callq 0x9200
leaq 0x4cef7(%rip), %rdi     # 0x5c9f1
leaq 0x4cf34(%rip), %rsi     # 0x5ca35
leaq 0x4cf46(%rip), %rcx     # 0x5ca4e
movl $0x19d, %edx            # imm = 0x19D
callq 0x9200
leaq 0x4d253(%rip), %rdi     # 0x5cd6c
leaq 0x4d306(%rip), %rsi     # 0x5ce26
leaq 0x4d31e(%rip), %rcx     # 0x5ce45
movl $0xa1, %edx
callq 0x9200
jmp 0xfb4f
movq %rax, %rbx
movq 0x18(%rsp), %rdi
callq 0x93d0
jmp 0xfb45
movq %rax, %rbx
movq %r13, %rdi
callq 0x93d0
jmp 0xfb52
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x93d0
movq %rbx, %rdi
callq 0x9680