// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
callq 0x8aec
cmpl $0x0, 0x4(%rbx)
je 0x5f6a
xorl %r15d, %r15d
movq %rsp, %r14
movq %rbx, %rdi
callq 0x4c26
movl (%rbx), %eax
testq %rax, %rax
je 0x5f53
movq 0xc8(%rbx), %rsi
xorpd %xmm0, %xmm0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %edi, %edi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq (%rsi), %r8
movsd (%r8,%r15,8), %xmm1
ucomisd %xmm1, %xmm0
cmoval %edi, %edx
minsd %xmm0, %xmm1
cmoval %r15d, %ecx
incq %rdi
addq $0x18, %rsi
movapd %xmm1, %xmm0
cmpq %rdi, %rax
jne 0x5f04
shlq $0x20, %rcx
movl %edx, %eax
orq %rcx, %rax
movq %rax, (%rsp)
cmpl $-0x1, %edx
je 0x5f5b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4eb8
movq %rbx, %rdi
callq 0x5d42
jmp 0x5f5b
movq $-0x1, (%rsp)
incq %r15
movl 0x4(%rbx), %eax
cmpq %rax, %r15
jb 0x5ede
movq %rbx, %rdi
callq 0x6184
movq 0x904f(%rip), %rdi      # 0xefc8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq 0x9034(%rip), %rdi      # 0xefc8
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq %rax, %r14
leaq 0x5388(%rip), %rsi      # 0xb333
movl $0x2f, %edx
movq %rax, %rdi
callq 0x32a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq 0x8fe2(%rip), %r14      # 0xefc8
leaq 0x5376(%rip), %rsi      # 0xb363
movl $0xf, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq 0x8fb0(%rip), %rdi      # 0xefc8
callq 0x3030
movq %rax, %rdi
callq 0x3170
leaq 0xb0(%rbx), %r14
leaq 0xf8(%rbx), %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x6206
movq 0x8f83(%rip), %r12      # 0xefc8
leaq 0x5327(%rip), %rsi      # 0xb373
movl $0x18, %edx
movq %r12, %rdi
callq 0x32a0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq 0x8f50(%rip), %rdi      # 0xefc8
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x6372
movq 0x8f34(%rip), %rdi      # 0xefc8
leaq 0x52f1(%rip), %rsi      # 0xb38c
movl $0x15, %edx
callq 0x32a0
movq %r14, %rsi
movq %r15, %rdx
callq 0x645c
movq 0x8f11(%rip), %rdi      # 0xefc8
callq 0x3370
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq 0x8edb(%rip), %rbx      # 0xefc8
leaq 0x523f(%rip), %rsi      # 0xb333
movl $0x2f, %edx
movq %rbx, %rdi
callq 0x32a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq 0x8ea9(%rip), %rdi      # 0xefc8
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
leaq 0x8(%rsp), %rdi
callq 0x8b60
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x616e
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x8b60
movq %rbx, %rdi
callq 0x33d0
nop