// File: iu-vail[P]iprimal/iPrimal.cpp
// Function: Primal::GreedyApprox1(std::vector<unsigned int, std::allocator<unsigned int>>&)
void
Primal::GreedyApprox1(vector<uint>& _asgn){

  _asgn.clear();
  _asgn.resize(row_size);
  set<uint> mem_rows;
  //column-wise searching
  for(uint j=0; j<col_size; j++){
    double min_val = std::numeric_limits<double>::infinity(); 
    uint min_row = row_size;
    for(uint i=0; i<row_size; i++){
      if(orig_matrix[i][j] < min_val &&
      		mem_rows.find(i) == mem_rows.end()){
	min_val = orig_matrix[i][j];
	min_row = i;	
      }
    }
    _asgn[min_row] = j;
    mem_rows.insert(min_row);
  }

  //double check if the assignment is meaningful
  set<uint> test(_asgn.begin(), _asgn.end());
  assert(test.size()==row_size);
  _cout("Approximate assignment: "<<endl);
  DisplayVec<uint>(_asgn);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x45b0
movq -0xd0(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0xa450
leaq -0x40(%rbp), %rdi
callq 0xa8a0
movl $0x0, -0x44(%rbp)
movq -0xd0(%rbp), %rcx
movl -0x44(%rbp), %eax
cmpl 0x4(%rcx), %eax
jae 0x702d
callq 0xa8c0
movq -0xd0(%rbp), %rax
movsd %xmm0, -0x50(%rbp)
movl (%rax), %eax
movl %eax, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movq -0xd0(%rbp), %rcx
movl -0x58(%rbp), %eax
cmpl (%rcx), %eax
jae 0x6fcd
movq -0xd0(%rbp), %rdi
addq $0xb0, %rdi
movl -0x58(%rbp), %eax
movl %eax, %esi
callq 0x4330
movq %rax, %rdi
movl -0x44(%rbp), %eax
movl %eax, %esi
callq 0x43e0
movsd (%rax), %xmm1
movsd -0x50(%rbp), %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
movb %al, -0xd1(%rbp)
jbe 0x6f6a
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xa900
movq %rax, -0xe0(%rbp)
jmp 0x6f3f
movq -0xe0(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xa940
movq %rax, -0x78(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xa8d0
movb %al, -0xd1(%rbp)
movb -0xd1(%rbp), %al
testb $0x1, %al
jne 0x6f76
jmp 0x6fbd
movq -0xd0(%rbp), %rdi
addq $0xb0, %rdi
movl -0x58(%rbp), %eax
movl %eax, %esi
callq 0x4330
movq %rax, %rdi
movl -0x44(%rbp), %eax
movl %eax, %esi
callq 0x43e0
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x6fbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x70ec
jmp 0x6fbf
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x6edb
movl -0x44(%rbp), %eax
movl %eax, -0xf0(%rbp)
movq -0x10(%rbp), %rdi
movl -0x54(%rbp), %eax
movl %eax, %esi
callq 0xa4e0
movl -0xf0(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x40(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0xa970
movb %dl, -0xe9(%rbp)
movq %rax, -0xe8(%rbp)
jmp 0x7008
movb -0xe9(%rbp), %al
movq -0xe8(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movb %al, -0x80(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x6eab
movq -0x10(%rbp), %rdi
callq 0x65c0
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6410
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0xa9c0
jmp 0x7069
leaq -0xb8(%rbp), %rdi
callq 0xaa40
movq -0xd0(%rbp), %rcx
movl (%rcx), %ecx
cmpq %rcx, %rax
jne 0x7085
jmp 0x70a4
leaq 0x13077(%rip), %rdi     # 0x1a103
leaq 0x13034(%rip), %rsi     # 0x1a0c7
movl $0x67, %edx
leaq 0x1307a(%rip), %rcx     # 0x1a119
callq 0x3190
movq -0xd0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xaa60
jmp 0x70b6
leaq -0xb8(%rbp), %rdi
callq 0xaac0
leaq -0x40(%rbp), %rdi
callq 0xaac0
addq $0xf0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xaac0
leaq -0x40(%rbp), %rdi
callq 0xaac0
movq -0x68(%rbp), %rdi
callq 0x3490
nop