// File: tomfunkhouser[P]gaps/pkgs/RNMath/RNSystemOfEquations.cpp
// Function: gaps::RNSystemOfEquations::RNSystemOfEquations(gaps::RNSystemOfEquations const&)
RNSystemOfEquations::
RNSystemOfEquations(const RNSystemOfEquations& system)
  : lower_bounds(NULL),
    upper_bounds(NULL),
    nvariables(system.nvariables),
    equations()
{
  // Allocate memory for variable counting
  index_to_variable = new int [ nvariables ];
  variable_to_index = new int [ nvariables ];
  variable_marks = new int [ nvariables ];
  for (int i = 0; i < nvariables; i++) variable_marks[i] = 0;
  current_mark = 1;

  // Copy equations
  equations.Resize(system.NEquations());
  for (int i = 0; i < system.NEquations(); i++) {
    RNEquation *equation = system.Equation(i);
    InsertEquation(new RNEquation(*equation));
  }

  // Copy lower bounds
  if (system.lower_bounds) {
    lower_bounds = new RNScalar [ nvariables ];
    for (int i = 0; i < nvariables; i++) {
      lower_bounds[i] = system.lower_bounds[i];
    }
  }
  
  // Copy upper bounds
  if (system.upper_bounds) {
    upper_bounds = new RNScalar [ nvariables ];
    for (int i = 0; i < nvariables; i++) {
      upper_bounds[i] = system.upper_bounds[i];
    }
  }
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq 0x90(%rsp), %rdi
movq %rdi, 0x50(%rsp)
movq $0x0, 0x20(%rdi)
movq $0x0, 0x28(%rdi)
movq 0x88(%rsp), %rax
movl 0x30(%rax), %eax
movl %eax, 0x30(%rdi)
addq $0x38, %rdi
movq %rdi, 0x48(%rsp)
callq 0x48860
movq 0x50(%rsp), %rax
movslq 0x30(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x4030
movq %rax, 0x58(%rsp)
jmp 0x4744b
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
movq %rcx, (%rax)
movslq 0x30(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x4030
movq %rax, 0x40(%rsp)
jmp 0x4747e
movq 0x50(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rcx, 0x8(%rax)
movslq 0x30(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x4030
movq %rax, 0x38(%rsp)
jmp 0x474b2
movq 0x50(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0x10(%rax)
movl $0x0, 0x78(%rsp)
movq 0x50(%rsp), %rcx
movl 0x78(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0x4750e
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x78(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x474c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
jmp 0x4773f
movq 0x50(%rsp), %rax
movl $0x1, 0x18(%rax)
addq $0x38, %rax
movq %rax, 0x28(%rsp)
movq 0x88(%rsp), %rdi
callq 0xb4e0
movl %eax, 0x34(%rsp)
jmp 0x47536
movl 0x34(%rsp), %esi
movq 0x28(%rsp), %rdi
callq 0x494d0
jmp 0x47546
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
movl %eax, 0x20(%rsp)
movq 0x88(%rsp), %rdi
callq 0xb4e0
movl %eax, 0x24(%rsp)
jmp 0x47569
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
cmpl %ecx, %eax
jge 0x47605
movq 0x88(%rsp), %rdi
movl 0x74(%rsp), %esi
callq 0x48880
movq %rax, 0x18(%rsp)
jmp 0x47591
movq 0x18(%rsp), %rax
movq %rax, 0x68(%rsp)
movl $0x40, %edi
callq 0x4280
movq %rax, 0x10(%rsp)
jmp 0x475ac
movq 0x10(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x48c20
jmp 0x475bd
movq 0x10(%rsp), %rsi
movq 0x50(%rsp), %rdi
callq 0x47760
jmp 0x475ce
jmp 0x475d0
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x4754e
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
movl $0x40, %esi
callq 0x4290
jmp 0x4773f
movq 0x88(%rsp), %rax
cmpq $0x0, 0x20(%rax)
je 0x4769f
movq 0x50(%rsp), %rax
movslq 0x30(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x4030
movq %rax, 0x8(%rsp)
jmp 0x47643
movq 0x50(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x20(%rax)
movl $0x0, 0x64(%rsp)
movq 0x50(%rsp), %rcx
movl 0x64(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0x4769d
movq 0x50(%rsp), %rax
movq 0x88(%rsp), %rcx
movq 0x20(%rcx), %rcx
movslq 0x64(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x20(%rax), %rax
movslq 0x64(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x47659
jmp 0x4769f
movq 0x88(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x47737
movq 0x50(%rsp), %rax
movslq 0x30(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x4030
movq %rax, (%rsp)
jmp 0x476dc
movq 0x50(%rsp), %rax
movq (%rsp), %rcx
movq %rcx, 0x28(%rax)
movl $0x0, 0x60(%rsp)
movq 0x50(%rsp), %rcx
movl 0x60(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0x47735
movq 0x50(%rsp), %rax
movq 0x88(%rsp), %rcx
movq 0x28(%rcx), %rcx
movslq 0x60(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x28(%rax), %rax
movslq 0x60(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x476f1
jmp 0x47737
addq $0x98, %rsp
retq
movq 0x48(%rsp), %rdi
callq 0x48870
movq 0x80(%rsp), %rdi
callq 0x44b0
nopw %cs:(%rax,%rax)