// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movq %rdx, %r14
movsd %xmm0, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, %r12
leaq 0x882f4(%rip), %rax     # 0x95238
movq %rax, (%rdi)
movq %rsi, 0x8(%rdi)
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x18(%rax)
movq %rax, 0x10(%r12)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
movq %rax, 0x18(%r12)
leaq 0x30(%r12), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r12)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0xcea2
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x40(%r12)
leaq 0x48(%r12), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0xe746
movq %r13, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x58(%r12), %r15
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0xcea2
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x68(%r12), %r13
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %r13, %rdi
callq 0xcea2
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x78(%r12), %rbp
leaq 0x10(%rsp), %rdx
movq %rbp, %rdi
movq %rax, %rsi
callq 0xd4b4
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x90(%r12), %rbx
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %rbx, %rdi
callq 0xcea2
movq 0x8(%r12), %rdi
movq 0x58(%r12), %rsi
movq 0x68(%r12), %rdx
movq (%rdi), %rax
callq *0x30(%rax)
leaq 0x20(%r12), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
xorl %r14d, %r14d
movq 0x8(%r12), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
cmpq %rax, %r14
jge 0xd16b
movq %r15, %rdi
movq %r14, %rsi
callq 0xd27a
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd27a
movsd 0x8(%rsp), %xmm0
ucomisd (%rax), %xmm0
jne 0xd0ba
jp 0xd0ba
movq 0x78(%r12), %rax
movl $0x1, (%rax,%r14,4)
incq 0x20(%r12)
cmpq $0x0, 0x28(%r12)
je 0xd163
jmp 0xd18b
movq %r15, %rdi
movq %r14, %rsi
callq 0xd27a
movsd 0x44343(%rip), %xmm0    # 0x51410
ucomisd (%rax), %xmm0
jae 0xd138
movq 0x78(%r12), %rax
movl $0x2, (%rax,%r14,4)
incq 0x28(%r12)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd27a
movsd (%rax), %xmm0
ucomisd 0x442ec(%rip), %xmm0    # 0x513e8
jae 0xd138
movq %r15, %rdi
movq %r14, %rsi
callq 0xd27a
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0xd27a
movsd 0x8(%rsp), %xmm0
ucomisd (%rax), %xmm0
jne 0xd12c
jnp 0xd138
movq (%rbp), %rax
movl $0x3, (%rax,%r14,4)
movq %r15, %rdi
movq %r14, %rsi
callq 0xd27a
movsd 0x442c5(%rip), %xmm0    # 0x51410
ucomisd (%rax), %xmm0
jb 0xd163
movq 0x78(%r12), %rax
movl $0x4, (%rax,%r14,4)
incq 0x28(%r12)
incq %r14
jmp 0xd055
movq 0x28(%r12), %rax
addq 0x20(%r12), %rax
movq %rax, 0x18(%r12)
je 0xd1ae
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x89e1e(%rip), %rdi     # 0x96fb0
leaq 0x442a9(%rip), %rsi     # 0x51442
callq 0x9330
movq %rax, %rdi
callq 0x9170
pushq $0x1
popq %rdi
callq 0x93d0
leaq 0x442bd(%rip), %rdi     # 0x51472
leaq 0x442d9(%rip), %rsi     # 0x51495
leaq 0x442ef(%rip), %rcx     # 0x514b2
pushq $0x40
popq %rdx
callq 0x9210
jmp 0xd1ea
jmp 0xd1cf
movq %rax, %r14
jmp 0xd1fd
movq %rax, %r14
jmp 0xd21c
movq %rax, %r14
jmp 0xd1f5
movq %rax, %r14
jmp 0xd205
movq %rax, %r14
jmp 0xd20d
jmp 0xd1ea
movq %rax, %r14
movq %rbx, %rdi
callq 0xbee0
movq %rbp, %rdi
callq 0xd85a
movq %r13, %rdi
callq 0xbee0
movq %r15, %rdi
callq 0xbee0
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %rdi
callq 0xbee0
movq %r15, %rdi
callq 0xbee0
movq %r14, %rdi
callq 0x9640