// File: iu-vail[P]iprimal/iPrimal.cpp
// Function: Primal::PrimalAlgo()
void
Primal::PrimalAlgo(void){

  //initiation is moved outside
  //RandInitAlgo();

  Utils utils;
  cell next;

  for(uint i=0; i<col_size; i++){
    
      InitStage();
      next = NextStartEntry(i);

      //_cout("Root cell_node: ("<<next.row_idx<<", "<<next.col_idx<<")"<<endl);
      if(next.row_idx != -1){

/*
#ifdef USE_HEAP
        Preprocess();
#endif
*/
        SearchSwapLoop(next);
        SwapTasks();

      }//if

  }//for

  // double check the reduced cost to see if all become feasible
  DoubleCheck();

//#ifdef DEBUG
  cout<<endl<<"***********************************************"<<endl;
  cout<<"Final solution:"<<endl;
  DisplayMatrix(orig_matrix, assignment);
  cout<<"Assigned row-col pairs: "<<endl;
  DisplayAssignment();
  cout<<"Minimization result: "<<ComputeCostSum(orig_matrix, assignment)<<endl;
  cout<<"***********************************************"<<endl<<endl;
//#else
//  cout<<"Minimization result: "<<ComputeCostSum(orig_matrix, assignment)<<endl;
//#endif

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x15850
movl $0x0, -0x24(%rbp)
movq -0x48(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x4(%rcx), %eax
jae 0x991f
movq -0x48(%rbp), %rdi
callq 0x7770
jmp 0x98be
movq -0x48(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x7a40
movq %rax, -0x3c(%rbp)
movq -0x3c(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpl $-0x1, -0x20(%rbp)
je 0x9912
movq -0x48(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x7c10
jmp 0x98eb
movq -0x48(%rbp), %rdi
callq 0x9530
jmp 0x98f6
jmp 0x9912
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x158c0
jmp 0x9aad
jmp 0x9914
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x98a7
movq -0x48(%rbp), %rdi
callq 0x9ac0
jmp 0x992a
movq 0x1d697(%rip), %rdi     # 0x26fc8
movq 0x1d678(%rip), %rsi     # 0x26fb0
callq 0x32b0
movq %rax, -0x50(%rbp)
jmp 0x9943
movq -0x50(%rbp), %rdi
leaq 0x10995(%rip), %rsi     # 0x1a2e3
callq 0x3270
movq %rax, -0x58(%rbp)
jmp 0x9959
movq -0x58(%rbp), %rdi
movq 0x1d64c(%rip), %rsi     # 0x26fb0
callq 0x32b0
jmp 0x996b
movq 0x1d656(%rip), %rdi     # 0x26fc8
leaq 0x1099a(%rip), %rsi     # 0x1a313
callq 0x3270
movq %rax, -0x60(%rbp)
jmp 0x9984
movq -0x60(%rbp), %rdi
movq 0x1d621(%rip), %rsi     # 0x26fb0
callq 0x32b0
jmp 0x9996
movq -0x48(%rbp), %rdi
movq %rdi, %rsi
addq $0xb0, %rsi
movq %rdi, %rdx
addq $0xf8, %rdx
callq 0x9bc0
jmp 0x99b5
movq 0x1d60c(%rip), %rdi     # 0x26fc8
leaq 0x10960(%rip), %rsi     # 0x1a323
callq 0x3270
movq %rax, -0x68(%rbp)
jmp 0x99ce
movq -0x68(%rbp), %rdi
movq 0x1d5d7(%rip), %rsi     # 0x26fb0
callq 0x32b0
jmp 0x99e0
movq -0x48(%rbp), %rdi
callq 0x9d60
jmp 0x99eb
movq 0x1d5d6(%rip), %rdi     # 0x26fc8
leaq 0x10943(%rip), %rsi     # 0x1a33c
callq 0x3270
movq %rax, -0x70(%rbp)
jmp 0x9a04
movq -0x48(%rbp), %rdi
movq %rdi, %rsi
addq $0xb0, %rsi
movq %rdi, %rdx
addq $0xf8, %rdx
callq 0x9e30
movsd %xmm0, -0x78(%rbp)
jmp 0x9a28
movsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rdi
callq 0x34e0
movq %rax, -0x80(%rbp)
jmp 0x9a3c
movq -0x80(%rbp), %rdi
movq 0x1d569(%rip), %rsi     # 0x26fb0
callq 0x32b0
jmp 0x9a4e
movq 0x1d573(%rip), %rdi     # 0x26fc8
leaq 0x10887(%rip), %rsi     # 0x1a2e3
callq 0x3270
movq %rax, -0x88(%rbp)
jmp 0x9a6a
movq -0x88(%rbp), %rdi
movq 0x1d538(%rip), %rsi     # 0x26fb0
callq 0x32b0
movq %rax, -0x90(%rbp)
jmp 0x9a86
movq -0x90(%rbp), %rdi
movq 0x1d51c(%rip), %rsi     # 0x26fb0
callq 0x32b0
jmp 0x9a9b
leaq -0x18(%rbp), %rdi
callq 0x158c0
addq $0x90, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x3490
nopw %cs:(%rax,%rax)