// File: /workspace/github_cpp_makefile_star2_O1/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 0xfc42
leaq 0x90(%r15), %rsi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x1022e
movq 0x20(%r15), %rax
movq 0x48(%r15), %rcx
testq %rcx, %rcx
sete %dl
testq %rax, %rax
setns %sil
orb %dl, %sil
je 0xfb3f
testq %rax, %rax
js 0xfb20
cmpq %rax, 0x50(%r15)
jl 0xfb20
cmpq %rax, 0x10(%rsp)
jl 0xfb20
movq 0x8(%rsp), %rdx
movq %rax, %rdi
testb $0x7, %dl
jne 0xf705
movl %edx, %edi
shrl $0x3, %edi
andl $0x1, %edi
cmpq %rax, %rdi
cmovgeq %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
jle 0xf745
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 0xf727
addq %rdi, %rsi
cmpq $0x2, %r8
jl 0xf772
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 0xf756
cmpq %rax, %rsi
jge 0xf792
movsd (%rcx,%rsi,8), %xmm1
divsd %xmm0, %xmm1
addsd (%rdx,%rsi,8), %xmm1
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0xf777
movq 0x28(%r15), %rcx
movq 0x48(%r15), %rax
testq %rax, %rax
sete %dl
testq %rcx, %rcx
setns %sil
orb %dl, %sil
je 0xfb3f
movq 0x50(%r15), %rdx
movq %rdx, %r9
subq %rcx, %r9
movq %r9, %rsi
orq %rcx, %rsi
js 0xfb20
testq %rcx, %rcx
js 0xfb5e
movq 0x10(%rsp), %rsi
movq %rsi, %r8
subq %rcx, %r8
movq %r8, %rdi
orq %rcx, %rdi
js 0xfb20
movq %rbp, 0x30(%rsp)
movq 0x8(%rsp), %rdi
leaq (%rdi,%r8,8), %r8
movq %rcx, %r10
testb $0x7, %r8b
jne 0xf80f
movl %r8d, %r10d
shrl $0x3, %r10d
andl $0x1, %r10d
cmpq %rcx, %r10
cmovgeq %rcx, %r10
leaq (%rax,%r9,8), %r11
movsd 0x40(%r15), %xmm0
movq %rcx, %rbp
subq %r10, %rbp
movq %rbp, %r9
shrq $0x3f, %r9
addq %rbp, %r9
andq $-0x2, %r9
testq %r10, %r10
jle 0xf853
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 0xf835
addq %r10, %r9
cmpq $0x2, %rbp
jl 0xf883
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 0xf864
subq %rcx, %r9
jge 0xf8ab
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 0xf890
movq 0x28(%r15), %rax
testq %rax, %rax
je 0xf929
movq 0x20(%r15), %rcx
movq 0x78(%r15), %rdx
movq 0x8(%rsp), %rsi
xorpd %xmm0, %xmm0
movl (%rdx,%rcx,4), %edi
cmpl $0x4, %edi
je 0xf8fe
cmpl $0x2, %edi
jne 0xf921
testq %rcx, %rcx
js 0xfb01
cmpq %rcx, 0x10(%rsp)
jle 0xfb01
movsd (%rsi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xf8f9
movq $0x0, (%rsi,%rcx,8)
cmpl $0x4, %edi
jne 0xf921
testq %rcx, %rcx
js 0xfb01
cmpq %rcx, 0x10(%rsp)
jle 0xfb01
ucomisd (%rsi,%rcx,8), %xmm0
jbe 0xf921
movq $0x0, (%rsi,%rcx,8)
incq %rcx
decq %rax
jne 0xf8c5
movsd 0x40(%r15), %xmm1
movq %r14, 0x18(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0xf971
movsd %xmm1, 0x28(%rsp)
jle 0xfb9c
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 0xff64
movsd 0x28(%rsp), %xmm1
jmp 0xf975
xorpd %xmm0, %xmm0
mulsd 0x4ca4b(%rip), %xmm1    # 0x5c3c8
mulsd %xmm0, %xmm1
addsd (%r13), %xmm1
movsd %xmm1, (%r13)
movq 0x10(%r15), %rbp
testq %rbp, %rbp
js 0xfb7d
je 0xf9fe
movq %rbp, %rax
shrq $0x3d, %rax
jne 0xf9d0
leaq (,%rbp,8), %rdi
callq 0x9440
movq %rax, %r13
cmpq $0x1, %rbp
setne %al
testb $0xf, %r13b
setne %cl
testb %cl, %al
jne 0xfbbb
testq %r13, %r13
jne 0xfa01
movl $0x8, %edi
callq 0x9180
movq 0x785cf(%rip), %rcx     # 0x87fb0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x785d9(%rip), %rsi     # 0x87fc8
movq 0x7859a(%rip), %rdx     # 0x87f90
movq %rax, %rdi
callq 0x9630
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
testq %rax, %rax
js 0xfb5e
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 0x100fe
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 0xfa5f
movl %ebx, %ecx
shrl $0x3, %ecx
andl $0x1, %ecx
cmpq %rbp, %rcx
cmovgeq %rbp, %rcx
movq %rbp, %rdx
subq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
andq $-0x2, %rax
testq %rcx, %rcx
jle 0xfa93
xorl %esi, %esi
movsd (%r13,%rsi,8), %xmm0
addsd (%rbx,%rsi,8), %xmm0
movsd %xmm0, (%rbx,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0xfa7a
addq %rcx, %rax
cmpq $0x2, %rdx
jl 0xfab6
movupd (%r13,%rcx,8), %xmm0
addpd (%rbx,%rcx,8), %xmm0
movapd %xmm0, (%rbx,%rcx,8)
addq $0x2, %rcx
cmpq %rax, %rcx
jl 0xfa9c
cmpq %rbp, %rax
jge 0xfad4
movsd (%r13,%rax,8), %xmm0
addsd (%rbx,%rax,8), %xmm0
movsd %xmm0, (%rbx,%rax,8)
incq %rax
cmpq %rax, %rbp
jne 0xfabb
movq 0x18(%rsp), %rdi
callq 0x93c0
movq %r13, %rdi
callq 0x93c0
movq 0x8(%rsp), %rdi
callq 0x93c0
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4d71d(%rip), %rdi     # 0x5d225
leaq 0x4d733(%rip), %rsi     # 0x5d242
leaq 0x4d74f(%rip), %rcx     # 0x5d265
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x9200
leaq 0x4cca4(%rip), %rdi     # 0x5c7cb
leaq 0x4cbc8(%rip), %rsi     # 0x5c6f6
leaq 0x4cbda(%rip), %rcx     # 0x5c70f
movl $0x93, %edx
callq 0x9200
leaq 0x4cd14(%rip), %rdi     # 0x5c85a
leaq 0x4cdb7(%rip), %rsi     # 0x5c904
leaq 0x4cdcb(%rip), %rcx     # 0x5c91f
movl $0xaf, %edx
callq 0x9200
leaq 0x4c9d7(%rip), %rdi     # 0x5c53c
leaq 0x4ca65(%rip), %rsi     # 0x5c5d1
leaq 0x4ca80(%rip), %rcx     # 0x5c5f3
movl $0x4a, %edx
callq 0x9200
leaq 0x4d003(%rip), %rdi     # 0x5cb87
leaq 0x4cd79(%rip), %rsi     # 0x5c904
leaq 0x4d002(%rip), %rcx     # 0x5cb94
movl $0xa3, %edx
callq 0x9200
leaq 0x4ce2e(%rip), %rdi     # 0x5c9d1
leaq 0x4ce6b(%rip), %rsi     # 0x5ca15
leaq 0x4ce7d(%rip), %rcx     # 0x5ca2e
movl $0x19d, %edx            # imm = 0x19D
callq 0x9200
leaq 0x4d18a(%rip), %rdi     # 0x5cd4c
leaq 0x4d23d(%rip), %rsi     # 0x5ce06
leaq 0x4d255(%rip), %rcx     # 0x5ce25
movl $0xa1, %edx
callq 0x9200
jmp 0xfbf8
movq %rax, %rbx
movq 0x18(%rsp), %rdi
callq 0x93c0
jmp 0xfbee
movq %rax, %rbx
movq %r13, %rdi
callq 0x93c0
jmp 0xfbfb
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x93c0
movq %rbx, %rdi
callq 0x9670
nop