// File: /workspace/github_cpp_makefile_star2_O1/canzarlab[P]Trajan/geno/augmentedLagrangian.cpp
// Function: AugmentedNLP::AugmentedNLP(GenoNLP&, double, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&)
AugmentedNLP(GenoNLP& genoNLP, Scalar rho, const Vector& y)
    :
    _genoNLP(genoNLP),
    _n(genoNLP.getN()),
    _m(genoNLP.getM()),
    _mEqualities(0),
    _mInequalities(0),
    _constraintValues(Vector(genoNLP.getM())),
//    _jacobian(Matrix(genoNLP.getM(), genoNLP.getN())),
    _rho(rho),
    _y(y),
    _cl(Vector(genoNLP.getM())),
    _cu(Vector(genoNLP.getM())),
    _cType(std::vector<int>(genoNLP.getM())),
    _constraintError(Vector(genoNLP.getM()))
  {
    _genoNLP.getBoundsConstraints(_cl.data(), _cu.data());

    _mEqualities = 0;
    _mInequalities = 0;
    for (Index i = 0; i < _genoNLP.getM(); ++i)
    {
      if (_cl(i) == _cu(i)) {
	_cType[i] = 1;   // equality constraint
	++_mEqualities;
	if (_mInequalities) {
	  std::cout << "Error : Equalitites must precede inequalitites!" 
		    << std::endl;
	  exit(1);
	}
      } else {
	if (_cl(i) != -INF) {
	  _cType[i] = 2;   // has lower bound
	  ++_mInequalities;
	  //	  std::cout << "Error : No lower bounds allowed!"
	  //		    << std::endl;
	  //	  exit(1);
 
	  if ((_cu(i) != INF) && (_cl(i) != _cu(i))) {
	    _cType[i] = 3;
	    //   	    std::cout << "Error : Upper bounds and lower bound are not allowed at the same time!" << std::endl;
		    //	    	    exit(1);
		    //		    		    _cType[i] = 2;
	  }
	}
	if (_cl(i) == -INF) {
	  _cType[i] = 4;      // no lower bound
	  ++_mInequalities;
	}
      }
    }
    //    _s = Vector::Zero(_mInequalities);
    assert(_m = _mEqualities + _mInequalities);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movsd %xmm0, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x7728c(%rip), %rax     # 0x861b0
movq %rax, (%rdi)
movq %rsi, 0x8(%rdi)
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x18(%rax)
movq %rax, 0x10(%r15)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
movq %rax, 0x18(%r15)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%r15)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x30(%r15)
testq %rax, %rax
js 0xf1a6
leaq 0x30(%r15), %r14
movl $0x1, %ecx
movq %r14, %rdi
movq %rax, %rsi
movq %rax, %rdx
movq %r14, 0x10(%rsp)
callq 0x10056
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x40(%r15)
leaq 0x48(%r15), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x1022e
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, 0x8(%rsp)
callq *0x20(%rax)
leaq 0x58(%r15), %r12
xorpd %xmm0, %xmm0
movupd %xmm0, (%r12)
testq %rax, %rax
js 0xf1a6
movl $0x1, %ecx
movq %r12, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0x10056
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x68(%r15), %r13
xorpd %xmm0, %xmm0
movupd %xmm0, (%r13)
testq %rax, %rax
js 0xf1a6
movl $0x1, %ecx
movq %r13, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0x10056
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x78(%r15), %rbp
leaq 0x7(%rsp), %rdx
movq %rbp, %rdi
movq %rax, %rsi
callq 0xf540
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x90(%r15), %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
testq %rax, %rax
js 0xf1a6
movl $0x1, %ecx
movq %rbx, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0x10056
movq 0x8(%r15), %rdi
movq 0x58(%r15), %rsi
movq 0x68(%r15), %rdx
movq (%rdi), %rax
callq *0x30(%rax)
leaq 0x20(%r15), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
xorl %r14d, %r14d
movq 0x8(%r15), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
cmpq %rax, %r14
jge 0xf13c
cmpq %r14, 0x60(%r15)
jle 0xf159
cmpq %r14, 0x70(%r15)
jle 0xf159
movq 0x58(%r15), %rax
movsd (%rax,%r14,8), %xmm0
movq (%r13), %rax
movsd (%rax,%r14,8), %xmm1
ucomisd %xmm1, %xmm0
jne 0xf0de
jp 0xf0de
movq 0x78(%r15), %rax
movl $0x1, (%rax,%r14,4)
incq 0x20(%r15)
cmpq $0x0, 0x28(%r15)
je 0xf134
jmp 0xf178
movsd 0x4d2f2(%rip), %xmm2    # 0x5c3d8
ucomisd %xmm0, %xmm2
jae 0xf116
movq 0x78(%r15), %rax
movl $0x2, (%rax,%r14,4)
incq 0x28(%r15)
ucomisd 0x4d2ac(%rip), %xmm1    # 0x5c3b0
jae 0xf116
ucomisd %xmm1, %xmm0
jne 0xf10e
jnp 0xf116
movl $0x3, (%rax,%r14,4)
movsd 0x4d2ba(%rip), %xmm1    # 0x5c3d8
ucomisd %xmm0, %xmm1
jb 0xf134
movq 0x78(%r15), %rax
movl $0x4, (%rax,%r14,4)
incq 0x28(%r15)
incq %r14
jmp 0xf07f
movq 0x28(%r15), %rax
addq 0x20(%r15), %rax
movq %rax, 0x18(%r15)
je 0xf1c5
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4e0c5(%rip), %rdi     # 0x5d225
leaq 0x4e0db(%rip), %rsi     # 0x5d242
leaq 0x4e0f7(%rip), %rcx     # 0x5d265
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x9200
movq 0x78e41(%rip), %rdi     # 0x87fc0
leaq 0x4d2b4(%rip), %rsi     # 0x5c43a
movl $0x2f, %edx
callq 0x93a0
movq 0x78e29(%rip), %rdi     # 0x87fc0
callq 0x9170
movl $0x1, %edi
callq 0x93d0
leaq 0x4da80(%rip), %rdi     # 0x5cc2d
leaq 0x4db03(%rip), %rsi     # 0x5ccb7
leaq 0x4db1f(%rip), %rcx     # 0x5ccda
movl $0x138, %edx            # imm = 0x138
callq 0x9200
leaq 0x4d29e(%rip), %rdi     # 0x5c46a
leaq 0x4d2ba(%rip), %rsi     # 0x5c48d
leaq 0x4d2d0(%rip), %rcx     # 0x5c4aa
movl $0x40, %edx
callq 0x9200
jmp 0xf20b
jmp 0xf20b
movq %rax, %r14
jmp 0xf216
jmp 0xf1f1
jmp 0xf1f1
movq %rax, %r14
jmp 0xf22e
jmp 0xf1f8
movq %rax, %r14
jmp 0xf237
movq %rax, %r14
jmp 0xf240
jmp 0xf204
movq %rax, %r14
jmp 0xf24d
jmp 0xf20b
movq %rax, %r14
movq (%rbx), %rdi
callq 0x93c0
movq (%rbp), %rdi
testq %rdi, %rdi
je 0xf22e
movq 0x88(%r15), %rsi
subq %rdi, %rsi
callq 0x9340
movq (%r13), %rdi
callq 0x93c0
movq (%r12), %rdi
callq 0x93c0
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x93c0
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x93c0
movq %r14, %rdi
callq 0x9670