// File: 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
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0x14c50
movq -0x78(%rbp), %rax
leaq 0x18b3d4(%rip), %rcx    # 0x19f0f8
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
addq $0x10, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movq %rax, -0x68(%rbp)
jmp 0x13d4a
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rcx
movq -0x68(%rbp), %rdx
movq %rdx, (%rcx)
addq $0x18, %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq %rax, -0x80(%rbp)
jmp 0x13d77
movq -0x78(%rbp), %rax
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %rdx
movq %rdx, (%rcx)
movq $0x0, 0x20(%rax)
movq $0x0, 0x28(%rax)
addq $0x30, %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq %rax, -0x90(%rbp)
jmp 0x13dba
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x13bd0
jmp 0x13dd7
movq -0x78(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
movsd %xmm0, 0x40(%rdi)
addq $0x48, %rdi
movq %rdi, -0xa0(%rbp)
movq -0x20(%rbp), %rsi
callq 0x144f0
jmp 0x13dfb
movq -0x78(%rbp), %rax
addq $0x58, %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq %rax, -0xa8(%rbp)
jmp 0x13e20
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x40(%rbp), %rsi
callq 0x13bd0
jmp 0x13e3d
movq -0x78(%rbp), %rax
addq $0x68, %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq %rax, -0xb8(%rbp)
jmp 0x13e62
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rsi
callq 0x13bd0
jmp 0x13e7f
movq -0x78(%rbp), %rax
addq $0x78, %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq %rax, -0xc8(%rbp)
jmp 0x13ea4
leaq -0x49(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x14c70
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0xd8(%rbp), %rdx
callq 0x14c90
jmp 0x13ed0
leaq -0x49(%rbp), %rdi
callq 0x14d00
movq -0x78(%rbp), %rax
addq $0x90, %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq %rax, -0xe0(%rbp)
jmp 0x13f00
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rsi
callq 0x13bd0
jmp 0x13f1d
movq -0x78(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0xf8(%rbp)
addq $0x58, %rdi
callq 0x13cd0
movq %rax, -0xf0(%rbp)
jmp 0x13f3e
movq -0x78(%rbp), %rdi
addq $0x68, %rdi
callq 0x13cd0
movq %rax, -0x100(%rbp)
jmp 0x13f54
movq -0x100(%rbp), %rdx
movq -0xf0(%rbp), %rsi
movq -0xf8(%rbp), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
jmp 0x13f74
movq -0x78(%rbp), %rax
movq $0x0, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq $0x0, -0x60(%rbp)
movq -0x78(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, -0x110(%rbp)
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq %rax, -0x108(%rbp)
jmp 0x13fb5
movq -0x110(%rbp), %rax
movq -0x108(%rbp), %rcx
cmpq %rcx, %rax
jge 0x142c4
movq -0x78(%rbp), %rdi
addq $0x58, %rdi
movq -0x60(%rbp), %rsi
callq 0x145f0
movq %rax, -0x118(%rbp)
jmp 0x13fe6
movq -0x78(%rbp), %rdi
movq -0x118(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x128(%rbp)
addq $0x68, %rdi
movq -0x60(%rbp), %rsi
callq 0x145f0
movq %rax, -0x120(%rbp)
jmp 0x14013
movsd -0x128(%rbp), %xmm0
movq -0x120(%rbp), %rax
ucomisd (%rax), %xmm0
jne 0x14144
jp 0x14144
movq -0x78(%rbp), %rdi
addq $0x78, %rdi
movq -0x60(%rbp), %rsi
callq 0x145d0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movl $0x1, (%rcx)
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
cmpq $0x0, 0x28(%rax)
je 0x1413f
movq 0x18cf42(%rip), %rdi    # 0x1a0fb0
leaq 0xf739d(%rip), %rsi     # 0x10b412
callq 0xa440
movq %rax, -0x130(%rbp)
jmp 0x14083
movq -0x130(%rbp), %rdi
movq 0x18cecf(%rip), %rsi    # 0x1a0f60
callq 0xa4a0
jmp 0x14098
movl $0x1, %edi
callq 0xa540
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14340
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14334
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14328
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x1431c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14310
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x14d00
jmp 0x14310
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14304
movq -0xe8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0xff40
jmp 0x14304
jmp 0x142b1
movq -0x78(%rbp), %rdi
addq $0x58, %rdi
movq -0x60(%rbp), %rsi
callq 0x145f0
movq %rax, -0x138(%rbp)
jmp 0x1415e
movq -0x138(%rbp), %rax
movsd (%rax), %xmm0
movsd 0xf723f(%rip), %xmm1    # 0x10b3b0
ucomisd %xmm1, %xmm0
jne 0x1417e
jp 0x1417e
jmp 0x14250
movq -0x78(%rbp), %rdi
addq $0x78, %rdi
movq -0x60(%rbp), %rsi
callq 0x145d0
movq -0x78(%rbp), %rdi
movl $0x2, (%rax)
movq 0x28(%rdi), %rax
incq %rax
movq %rax, 0x28(%rdi)
addq $0x68, %rdi
movq -0x60(%rbp), %rsi
callq 0x145f0
movq %rax, -0x140(%rbp)
jmp 0x141ba
movq -0x140(%rbp), %rax
movsd (%rax), %xmm0
movsd 0xf71d3(%rip), %xmm1    # 0x10b3a0
ucomisd %xmm1, %xmm0
jne 0x141d7
jp 0x141d7
jmp 0x1424e
movq -0x78(%rbp), %rdi
addq $0x58, %rdi
movq -0x60(%rbp), %rsi
callq 0x145f0
movq %rax, -0x148(%rbp)
jmp 0x141f1
movq -0x78(%rbp), %rdi
movq -0x148(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x158(%rbp)
addq $0x68, %rdi
movq -0x60(%rbp), %rsi
callq 0x145f0
movq %rax, -0x150(%rbp)
jmp 0x1421e
movsd -0x158(%rbp), %xmm0
movq -0x150(%rbp), %rax
ucomisd (%rax), %xmm0
jne 0x14237
jp 0x14237
jmp 0x1424e
movq -0x78(%rbp), %rdi
addq $0x78, %rdi
movq -0x60(%rbp), %rsi
callq 0x145d0
movl $0x3, (%rax)
jmp 0x14250
movq -0x78(%rbp), %rdi
addq $0x58, %rdi
movq -0x60(%rbp), %rsi
callq 0x145f0
movq %rax, -0x160(%rbp)
jmp 0x1426a
movq -0x160(%rbp), %rax
movsd (%rax), %xmm0
movsd 0xf7133(%rip), %xmm1    # 0x10b3b0
ucomisd %xmm1, %xmm0
jne 0x142af
jp 0x142af
movq -0x78(%rbp), %rdi
addq $0x78, %rdi
movq -0x60(%rbp), %rsi
callq 0x145d0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movl $0x4, (%rcx)
movq 0x28(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x28(%rax)
jmp 0x142b1
jmp 0x142b3
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x13f90
movq -0x78(%rbp), %rcx
movq 0x20(%rcx), %rax
addq 0x28(%rcx), %rax
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
je 0x142dc
jmp 0x142fb
leaq 0xf715f(%rip), %rdi     # 0x10b442
leaq 0xf717b(%rip), %rsi     # 0x10b465
movl $0x40, %edx
leaq 0xf718c(%rip), %rcx     # 0x10b482
callq 0xa2b0
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0x14b50
movq -0xc0(%rbp), %rdi
callq 0xff40
movq -0xb0(%rbp), %rdi
callq 0xff40
movq -0xa0(%rbp), %rdi
callq 0xff40
movq -0x98(%rbp), %rdi
callq 0xff40
movq -0x78(%rbp), %rdi
callq 0x15450
movq -0x28(%rbp), %rdi
callq 0xa7c0
nopw %cs:(%rax,%rax)
nopl (%rax)