// File: iu-vail[P]iprimal/iPrimal.cpp
// Function: Primal::DualUpdates(_cell&, std::queue<_tree_node*, std::deque<_tree_node*, std::allocator<_tree_node*>>>&)
int
Primal::DualUpdates(cell& _start_cell, queue<tree_node*>& _bfs){

  // search the epsilon (minimal value) for varibles adjustments
  // it must satisfy 3 conditions: 
  // 1. >=0 in oprt_matrix; 2. in exploited rows; 3. in un-exploited cols

  // define and init epsilon as a largest positive value
  double epsilon = std::numeric_limits<double>::infinity();
  bool updated_epsilon = false;

#ifdef USE_HEAP

  /**** lines below are version using min-heaps, relatively faster ****/
  // search for min epsilon
  for(uint row_index=0; row_index<row_size; row_index++){
    if(exploited_rows.find(row_index) != exploited_rows.end()){
      //expose the first unvisited entry
      while(!min_heaps[row_index].empty()){ 
	if(exploited_cols.find(min_heaps[row_index].top().first) != exploited_cols.end())
	  min_heaps[row_index].pop();
        else
	  break;
      }
      if(!min_heaps[row_index].empty()){
        double cell_val = min_heaps[row_index].top().second + deltas[min_heaps[row_index].top().first] - deltas[GetAssignedCol(row_index)];
        if(cell_val < epsilon){
	  epsilon = cell_val;
          updated_epsilon = true;
        }
      }//if !min
    }//if exploited row
  }//for row_index

  // one more round traversal to find all qualified entries
  queue<cell> tmp_q;
  cell qual_c;
  if(updated_epsilon){
    for(uint row_index=0; row_index<row_size; row_index++)
      if(exploited_rows.find(row_index) != exploited_rows.end()){
        while(!min_heaps[row_index].empty()){ 
	  if(exploited_cols.find(min_heaps[row_index].top().first) != exploited_cols.end()){
            min_heaps[row_index].pop();
          }
          else{
            double cell_val = min_heaps[row_index].top().second + deltas[min_heaps[row_index].top().first] - deltas[GetAssignedCol(row_index)];
            if(fabs(cell_val - epsilon)<DOUBLE_EPSILON){
              qual_c.row_idx = row_index;
	      qual_c.col_idx = min_heaps[row_index].top().first;
              tmp_q.push(qual_c);
	      //this entry will be colored as visited later, so remove it here
	      // and this also expose next available entry for judging
	      min_heaps[row_index].pop();
            }
	    else if( cell_val - epsilon > DOUBLE_EPSILON){
              // stop at encountering the first uncolored entry that > epsilon
	      break;
	    }
            else {
	      cerr<<"Very weired thing happens."<<endl;
	      assert(0);
            }
          }//else
        }//while
      }//if exploited rows
  }//if updated epsilon

#else

  /**** lines below are version NOT using min-heaps, relatively slower ****/
  for(uint row_index=0; row_index<row_size; row_index++)
    if(exploited_rows.find(row_index) != exploited_rows.end())
      for(uint col_index=0; col_index<col_size; col_index++)
        if(exploited_cols.find(col_index) == exploited_cols.end()){
	  //double cell_val = oprt_matrix[row_index][col_index] - deltas[col_index];
	  double cell_val = oprt_matrix[row_index][col_index] + deltas[col_index] - deltas[GetAssignedCol(row_index)];
          if(cell_val > 0 && cell_val < epsilon){
            epsilon = cell_val;
            updated_epsilon = true;
          }
        }

  // one more round traversal to find all qualified entries
  queue<cell> tmp_q;
  cell qual_c;
  if(updated_epsilon){
    for(uint row_index=0; row_index<row_size; row_index++)
      if(exploited_rows.find(row_index) != exploited_rows.end())
        for(uint col_index=0; col_index<col_size; col_index++)
          if(exploited_cols.find(col_index) == exploited_cols.end()){
	    double cell_val = oprt_matrix[row_index][col_index] + deltas[col_index] - deltas[GetAssignedCol(row_index)];
            if(fabs(cell_val - epsilon)<DOUBLE_EPSILON){
              qual_c.row_idx = row_index;
	      qual_c.col_idx = col_index;
              tmp_q.push(qual_c);
            }
          }
  }//if

#endif

  // if found nothing, i.e., all available entries are <=0, leaving a void set
  if(!updated_epsilon)
    epsilon = - (oprt_matrix[_start_cell.row_idx][_start_cell.col_idx] 
		+ deltas[_start_cell.col_idx] - deltas[GetAssignedCol(_start_cell.row_idx)]);
  assert(epsilon > 0 && epsilon < std::numeric_limits<double>::infinity());

  _cout("# epsilon: "<<epsilon<<endl);

  // delta update
  for(uint col_index=0; col_index<col_size; col_index++)
    if(exploited_cols.find(col_index) != exploited_cols.end())
      deltas[col_index] += epsilon;  

  _cout("Updated deltas: "<<endl);
  DisplayVec<double>(deltas);

  vector<double> tmp_d(row_size);
  
  for(uint row_index=0; row_index<row_size; row_index++){
    tmp_d[row_index] = oprt_matrix[row_index][_start_cell.col_idx] + deltas[_start_cell.col_idx] - deltas[GetAssignedCol(row_index)];
  }

  _cout("Updated column ["<<_start_cell.col_idx<<"]:"<<endl);
  DisplayVec<double>(tmp_d);

  double min_d = std::numeric_limits<double>::infinity();
  uint new_start_row = row_size;
  for(uint i=0; i<row_size; i++)
    if(tmp_d[i] < min_d){ 
      min_d = tmp_d[i];
      new_start_row = i;
    }
  assert(new_start_row != row_size);
  _cout("Updated root: ("<<new_start_row<<", "<<_start_cell.col_idx<<")"<<endl);

  //terminate this stage if conditions below occur
  if(min_d >= 0){
    _cout("No loop, but the whole column is feasible!"<<endl);
    swap_loop.clear();

    return 0;
  }
  else if(new_start_row !=(uint)_start_cell.row_idx)
    if(exploited_rows.find(new_start_row) != exploited_rows.end()){
      _cout("Loop already exists!"<<endl);
      //update the starting cell
      _start_cell.row_idx = new_start_row;
      //now search the loop or notify the upper funciton to search it
      assert(asgn_ptrs[new_start_row]!=NULL);
      tree_node* tmp_ptr = asgn_ptrs[new_start_row];
      swap_loop.clear();
      while(tmp_ptr->asgn != -1){
        swap_loop.push_back(tmp_ptr->c);
        tmp_ptr=tmp_ptr->parent;
      }
      //finally append the updated root 
      swap_loop.push_back(_start_cell); 

      return 1;
    }
 
  while(!tmp_q.empty()){
    cell cur_c = tmp_q.front();
    tmp_q.pop();
    tree_node* p_cur_tree_node = asgn_ptrs[cur_c.row_idx];
    _cout("Current dead-end entry is: ("<<p_cur_tree_node->c.row_idx<<", "<<p_cur_tree_node->c.col_idx<<")"<<endl);
/*
    for(uint col_index=0; col_index<col_size; col_index++){
      //if(exploited_cols.find(col_index) == exploited_cols.end() && oprt_matrix[epsilon_row_idx][col_index] == oprt_matrix[epsilon_row_idx][epsilon_col_idx] ){
      if(fabs(oprt_matrix[epsilon_row_idx][col_index] + deltas[col_index] - deltas[GetAssignedCol(epsilon_row_idx)]) < DOUBLE_EPSILON
                && exploited_cols.find(col_index) == exploited_cols.end()
                && col_index != (uint)p_cur_tree_node->c.col_idx){
          //current new cell
          cell cur_c;
          cur_c.row_idx = epsilon_row_idx;
          cur_c.col_idx = col_index;
*/
          _cout("  found a new 0: ("
	  	<<cur_c.row_idx<<", "<<cur_c.col_idx<<")"<<endl);

	  //create a new tree_node
          tree_node* new_tree_node = new tree_node;
	  new_tree_node->c = cur_c;
	  new_tree_node->asgn = 0;
	  new_tree_node->parent = p_cur_tree_node;
          // check if it already has siblings
	  if(p_cur_tree_node->child == NULL){
            p_cur_tree_node->child = new_tree_node;
	    sib_ptrs[cur_c.row_idx] = new_tree_node;
          }
          else{
	    assert(sib_ptrs[cur_c.row_idx] != NULL);
	    sib_ptrs[cur_c.row_idx]->next_sibling = new_tree_node;
	    sib_ptrs[cur_c.row_idx] = new_tree_node;
	  }

	  //push the new cell_node in the BFS queue
	  _bfs.push(new_tree_node);
      //}//if
    //}//for
  }//while tmp_q

  return -1;  // did not form loop, countinue searching outside
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x178(%rbp)
callq 0xa8c0
movsd %xmm0, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x178(%rbp), %rcx
movl -0x30(%rbp), %eax
cmpl (%rcx), %eax
jae 0x88a5
movq -0x178(%rbp), %rdi
addq $0x50, %rdi
leaq -0x30(%rbp), %rsi
callq 0xa900
movq -0x178(%rbp), %rdi
movq %rax, -0x38(%rbp)
addq $0x50, %rdi
callq 0xa940
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xb200
testb $0x1, %al
jne 0x86cb
jmp 0x8895
jmp 0x86cd
movq -0x178(%rbp), %rdi
addq $0xe0, %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb230
xorb $-0x1, %al
testb $0x1, %al
jne 0x86f8
jmp 0x878e
movq -0x178(%rbp), %rdi
movq %rdi, %rax
addq $0x80, %rax
movq %rax, -0x180(%rbp)
addq $0xe0, %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb250
movq -0x180(%rbp), %rdi
movq %rax, %rsi
callq 0xa900
movq -0x178(%rbp), %rdi
movq %rax, -0x48(%rbp)
addq $0x80, %rdi
callq 0xa940
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xb200
testb $0x1, %al
jne 0x8765
jmp 0x8787
movq -0x178(%rbp), %rdi
addq $0xe0, %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb270
jmp 0x8789
jmp 0x878e
jmp 0x86cd
movq -0x178(%rbp), %rdi
addq $0xe0, %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb230
testb $0x1, %al
jne 0x8893
movq -0x178(%rbp), %rdi
addq $0xe0, %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb250
movq -0x178(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x198(%rbp)
movq %rdi, %rax
addq $0x38, %rax
movq %rax, -0x1a0(%rbp)
addq $0xe0, %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb250
movq -0x1a0(%rbp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0x43e0
movsd -0x198(%rbp), %xmm0
movq -0x178(%rbp), %rdi
addsd (%rax), %xmm0
movsd %xmm0, -0x188(%rbp)
movq %rdi, %rax
addq $0x38, %rax
movq %rax, -0x190(%rbp)
movl -0x30(%rbp), %esi
callq 0xb100
movq -0x190(%rbp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x43e0
movsd -0x188(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x8891
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movb $0x1, -0x29(%rbp)
jmp 0x8893
jmp 0x8895
jmp 0x8897
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x8677
leaq -0xa8(%rbp), %rdi
callq 0xb2d0
testb $0x1, -0x29(%rbp)
je 0x8c87
movl $0x0, -0xb4(%rbp)
movq -0x178(%rbp), %rcx
movl -0xb4(%rbp), %eax
cmpl (%rcx), %eax
jae 0x8c85
movq -0x178(%rbp), %rdi
addq $0x50, %rdi
leaq -0xb4(%rbp), %rsi
callq 0xa900
movq %rax, -0x1a8(%rbp)
jmp 0x88fa
movq -0x178(%rbp), %rdi
movq -0x1a8(%rbp), %rax
movq %rax, -0xc0(%rbp)
addq $0x50, %rdi
callq 0xa940
movq %rax, -0xd8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xb200
testb $0x1, %al
jne 0x893b
jmp 0x8c6f
jmp 0x893d
movq -0x178(%rbp), %rdi
addq $0xe0, %rdi
movl -0xb4(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb230
movb %al, -0x1a9(%rbp)
jmp 0x8968
movb -0x1a9(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x8979
jmp 0x8c6d
movq -0x178(%rbp), %rdi
movq %rdi, %rax
subq $-0x80, %rax
movq %rax, -0x1c0(%rbp)
addq $0xe0, %rdi
movl -0xb4(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb250
movq %rax, -0x1b8(%rbp)
jmp 0x89b3
movq -0x1b8(%rbp), %rsi
movq -0x1c0(%rbp), %rdi
callq 0xa900
movq %rax, -0x1c8(%rbp)
jmp 0x89cf
movq -0x178(%rbp), %rdi
movq -0x1c8(%rbp), %rax
movq %rax, -0xe0(%rbp)
addq $0x80, %rdi
callq 0xa940
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xb200
testb $0x1, %al
jne 0x8a10
jmp 0x8a51
movq -0x178(%rbp), %rdi
addq $0xe0, %rdi
movl -0xb4(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb270
jmp 0x8a35
jmp 0x8c68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x9510
movq -0x178(%rbp), %rdi
addq $0xe0, %rdi
movl -0xb4(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb250
movq %rax, -0x1d0(%rbp)
jmp 0x8a7d
movq -0x178(%rbp), %rdi
movq -0x1d0(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x1e8(%rbp)
movq %rdi, %rax
addq $0x38, %rax
movq %rax, -0x1e0(%rbp)
addq $0xe0, %rdi
movl -0xb4(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb250
movq %rax, -0x1d8(%rbp)
jmp 0x8acb
movq -0x1e0(%rbp), %rdi
movq -0x1d8(%rbp), %rax
movl (%rax), %eax
movl %eax, %esi
callq 0x43e0
movsd -0x1e8(%rbp), %xmm0
movq -0x178(%rbp), %rdi
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x200(%rbp)
movq %rdi, %rax
addq $0x38, %rax
movq %rax, -0x1f8(%rbp)
movl -0xb4(%rbp), %esi
callq 0xb100
movl %eax, -0x1ec(%rbp)
jmp 0x8b22
movq -0x1f8(%rbp), %rdi
movl -0x1ec(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x43e0
movsd -0x200(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0xf0(%rbp)
movsd -0xf0(%rbp), %xmm1
subsd -0x28(%rbp), %xmm1
movaps 0x11540(%rip), %xmm0    # 0x1a0a0
pand %xmm0, %xmm1
movsd 0x11524(%rip), %xmm0    # 0x1a090
ucomisd %xmm1, %xmm0
jbe 0x8bf9
movq -0x178(%rbp), %rdi
movl -0xb4(%rbp), %eax
movl %eax, -0xb0(%rbp)
addq $0xe0, %rdi
movl -0xb4(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb250
movq %rax, -0x208(%rbp)
jmp 0x8bae
movq -0x208(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xac(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xb300
jmp 0x8bd2
movq -0x178(%rbp), %rdi
addq $0xe0, %rdi
movl -0xb4(%rbp), %eax
movl %eax, %esi
callq 0xaf50
movq %rax, %rdi
callq 0xb270
jmp 0x8bf7
jmp 0x8c66
movsd -0xf0(%rbp), %xmm0
subsd -0x28(%rbp), %xmm0
movsd 0x11482(%rip), %xmm1    # 0x1a090
ucomisd %xmm1, %xmm0
jbe 0x8c16
jmp 0x8c6d
movq 0x1e3d3(%rip), %rdi     # 0x26ff0
leaq 0x1158f(%rip), %rsi     # 0x1a1b3
callq 0x3270
movq %rax, -0x210(%rbp)
jmp 0x8c32
movq -0x210(%rbp), %rdi
movq 0x1e370(%rip), %rsi     # 0x26fb0
callq 0x32b0
jmp 0x8c47
leaq 0x1163f(%rip), %rdi     # 0x1a28d
leaq 0x11472(%rip), %rsi     # 0x1a0c7
movl $0x201, %edx            # imm = 0x201
leaq 0x1156d(%rip), %rcx     # 0x1a1ce
callq 0x3190
jmp 0x8c68
jmp 0x893d
jmp 0x8c6f
jmp 0x8c71
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x88c5
jmp 0x8c87
testb $0x1, -0x29(%rbp)
jne 0x8d56
movq -0x178(%rbp), %rdi
addq $0xc8, %rdi
movq -0x18(%rbp), %rax
movslq (%rax), %rsi
callq 0x4330
movq %rax, %rdi
movq -0x18(%rbp), %rax
movslq 0x4(%rax), %rsi
callq 0x43e0
movq -0x178(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x228(%rbp)
addq $0x38, %rdi
movq %rdi, -0x230(%rbp)
movq -0x18(%rbp), %rax
movslq 0x4(%rax), %rsi
callq 0x43e0
movsd -0x228(%rbp), %xmm0
movq -0x178(%rbp), %rdi
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x220(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0xb100
movl %eax, -0x214(%rbp)
jmp 0x8d18
movq -0x230(%rbp), %rdi
movl -0x214(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x43e0
movsd -0x220(%rbp), %xmm0
subsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movb %al, -0x231(%rbp)
jbe 0x8d93
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x240(%rbp)
callq 0xa8c0
movsd -0x240(%rbp), %xmm1
ucomisd %xmm1, %xmm0
seta %al
movb %al, -0x231(%rbp)
movb -0x231(%rbp), %al
testb $0x1, %al
jne 0x8d9f
jmp 0x8da1
jmp 0x8dc0
leaq 0x1145c(%rip), %rdi     # 0x1a204
leaq 0x11318(%rip), %rsi     # 0x1a0c7
movl $0x22e, %edx            # imm = 0x22E
leaq 0x11413(%rip), %rcx     # 0x1a1ce
callq 0x3190
movl $0x0, -0xf4(%rbp)
movq -0x178(%rbp), %rcx
movl -0xf4(%rbp), %eax
cmpl 0x4(%rcx), %eax
jae 0x8e8c
movq -0x178(%rbp), %rdi
subq $-0x80, %rdi
leaq -0xf4(%rbp), %rsi
callq 0xa900
movq %rax, -0x248(%rbp)
jmp 0x8e00
movq -0x178(%rbp), %rdi
movq -0x248(%rbp), %rax
movq %rax, -0x100(%rbp)
addq $0x80, %rdi
callq 0xa940
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xb200
testb $0x1, %al
jne 0x8e41
jmp 0x8e76
movq -0x178(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x250(%rbp)
addq $0x38, %rdi
movl -0xf4(%rbp), %eax
movl %eax, %esi
callq 0x43e0
movsd -0x250(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x8e78
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x8dca
movq -0x178(%rbp), %rdi
movq %rdi, %rsi
addq $0x38, %rsi
callq 0xb330
jmp 0x8ea1
movq -0x178(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x260(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x4650
movq -0x260(%rbp), %rsi
movq -0x258(%rbp), %rdx
leaq -0x120(%rbp), %rdi
callq 0xb390
jmp 0x8ee0
leaq -0x121(%rbp), %rdi
callq 0x5d30
movl $0x0, -0x128(%rbp)
movq -0x178(%rbp), %rcx
movl -0x128(%rbp), %eax
cmpl (%rcx), %eax
jae 0x902b
movq -0x178(%rbp), %rdi
addq $0xc8, %rdi
movl -0x128(%rbp), %eax
movl %eax, %esi
callq 0x4330
movq %rax, %rdi
movq -0x18(%rbp), %rax
movslq 0x4(%rax), %rsi
callq 0x43e0
movq -0x178(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x278(%rbp)
addq $0x38, %rdi
movq %rdi, -0x280(%rbp)
movq -0x18(%rbp), %rax
movslq 0x4(%rax), %rsi
callq 0x43e0
movsd -0x278(%rbp), %xmm0
movq -0x178(%rbp), %rdi
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x270(%rbp)
movl -0x128(%rbp), %esi
callq 0xb100
movl %eax, -0x264(%rbp)
jmp 0x8f93
movq -0x280(%rbp), %rdi
movl -0x264(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x43e0
movsd -0x270(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0x288(%rbp)
movl -0x128(%rbp), %eax
movl %eax, %esi
leaq -0x120(%rbp), %rdi
callq 0x43e0
movsd -0x288(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x128(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x128(%rbp)
jmp 0x8ef6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x121(%rbp), %rdi
callq 0x5d30
jmp 0x9510
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x9504
movq -0x178(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xb330
jmp 0x9040
callq 0xa8c0
movq -0x178(%rbp), %rax
movsd %xmm0, -0x130(%rbp)
movl (%rax), %eax
movl %eax, -0x134(%rbp)
movl $0x0, -0x138(%rbp)
movq -0x178(%rbp), %rcx
movl -0x138(%rbp), %eax
cmpl (%rcx), %eax
jae 0x90dc
movl -0x138(%rbp), %eax
movl %eax, %esi
leaq -0x120(%rbp), %rdi
callq 0x43e0
movsd (%rax), %xmm1
movsd -0x130(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x90c9
movl -0x138(%rbp), %eax
movl %eax, %esi
leaq -0x120(%rbp), %rdi
callq 0x43e0
movsd (%rax), %xmm0
movsd %xmm0, -0x130(%rbp)
movl -0x138(%rbp), %eax
movl %eax, -0x134(%rbp)
jmp 0x90cb
movl -0x138(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x138(%rbp)
jmp 0x9066
movq -0x178(%rbp), %rcx
movl -0x134(%rbp), %eax
cmpl (%rcx), %eax
je 0x90ef
jmp 0x910e
leaq 0x1114f(%rip), %rdi     # 0x1a245
leaq 0x10fca(%rip), %rsi     # 0x1a0c7
movl $0x24a, %edx            # imm = 0x24A
leaq 0x110c5(%rip), %rcx     # 0x1a1ce
callq 0x3190
movsd -0x130(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9148
movq -0x178(%rbp), %rdi
addq $0x110, %rdi            # imm = 0x110
callq 0xb150
movl $0x0, -0x4(%rbp)
movl $0x1, -0x13c(%rbp)
jmp 0x94e0
movl -0x134(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
je 0x92af
movq -0x178(%rbp), %rdi
addq $0x50, %rdi
leaq -0x134(%rbp), %rsi
callq 0xa900
movq %rax, -0x290(%rbp)
jmp 0x917a
movq -0x178(%rbp), %rdi
movq -0x290(%rbp), %rax
movq %rax, -0x148(%rbp)
addq $0x50, %rdi
callq 0xa940
movq %rax, -0x150(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xb200
testb $0x1, %al
jne 0x91bb
jmp 0x92ad
movq -0x178(%rbp), %rdi
movl -0x134(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
addq $0x128, %rdi            # imm = 0x128
movl -0x134(%rbp), %eax
movl %eax, %esi
callq 0xb130
cmpq $0x0, (%rax)
je 0x91ea
jmp 0x9209
leaq 0x1106e(%rip), %rdi     # 0x1a25f
leaq 0x10ecf(%rip), %rsi     # 0x1a0c7
movl $0x25a, %edx            # imm = 0x25A
leaq 0x10fca(%rip), %rcx     # 0x1a1ce
callq 0x3190
movq -0x178(%rbp), %rdi
addq $0x128, %rdi            # imm = 0x128
movl -0x134(%rbp), %eax
movl %eax, %esi
callq 0xb130
movq -0x178(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x158(%rbp)
addq $0x110, %rdi            # imm = 0x110
callq 0xb150
movq -0x158(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
je 0x927e
movq -0x178(%rbp), %rdi
addq $0x110, %rdi            # imm = 0x110
movq -0x158(%rbp), %rsi
callq 0xb180
jmp 0x926a
movq -0x158(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x158(%rbp)
jmp 0x9241
movq -0x178(%rbp), %rdi
addq $0x110, %rdi            # imm = 0x110
movq -0x18(%rbp), %rsi
callq 0xb180
jmp 0x9297
movl $0x1, -0x4(%rbp)
movl $0x1, -0x13c(%rbp)
jmp 0x94e0
jmp 0x92af
jmp 0x92b1
jmp 0x92b3
leaq -0xa8(%rbp), %rdi
callq 0xb400
movb %al, -0x291(%rbp)
jmp 0x92c7
movb -0x291(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x92d8
jmp 0x94cf
leaq -0xa8(%rbp), %rdi
callq 0xb420
movq %rax, -0x2a0(%rbp)
jmp 0x92ed
movq -0x2a0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x160(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xb440
jmp 0x930c
movq -0x178(%rbp), %rdi
addq $0x128, %rdi            # imm = 0x128
movslq -0x160(%rbp), %rsi
callq 0xb130
movq (%rax), %rax
movq %rax, -0x168(%rbp)
movl $0x28, %edi
callq 0x3280
movq %rax, -0x2a8(%rbp)
jmp 0x9343
movq -0x2a8(%rbp), %rdi
callq 0xb040
jmp 0x9351
movq -0x2a8(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
movq -0x160(%rbp), %rcx
movq %rcx, (%rax)
movq -0x170(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x168(%rbp), %rcx
movq -0x170(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x168(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x940f
movq -0x178(%rbp), %rdi
movq -0x170(%rbp), %rcx
movq -0x168(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x170(%rbp), %rax
movq %rax, -0x2b0(%rbp)
addq $0x140, %rdi            # imm = 0x140
movslq -0x160(%rbp), %rsi
callq 0xb130
movq -0x2b0(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x94b8
movq -0x2a8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
movl $0x28, %esi
callq 0x3290
jmp 0x9504
movq -0x178(%rbp), %rdi
addq $0x140, %rdi            # imm = 0x140
movslq -0x160(%rbp), %rsi
callq 0xb130
cmpq $0x0, (%rax)
je 0x9431
jmp 0x9450
leaq 0x10d37(%rip), %rdi     # 0x1a16f
leaq 0x10c88(%rip), %rsi     # 0x1a0c7
movl $0x285, %edx            # imm = 0x285
leaq 0x10d83(%rip), %rcx     # 0x1a1ce
callq 0x3190
movq -0x178(%rbp), %rdi
movq -0x170(%rbp), %rax
movq %rax, -0x2c0(%rbp)
addq $0x140, %rdi            # imm = 0x140
movslq -0x160(%rbp), %rsi
callq 0xb130
movq -0x2c0(%rbp), %rcx
movq -0x178(%rbp), %rdi
movq (%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x170(%rbp), %rax
movq %rax, -0x2b8(%rbp)
addq $0x140, %rdi            # imm = 0x140
movslq -0x160(%rbp), %rsi
callq 0xb130
movq -0x2b8(%rbp), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0xb070
jmp 0x94ca
jmp 0x92b3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x13c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x4490
leaq -0xa8(%rbp), %rdi
callq 0xb460
movl -0x4(%rbp), %eax
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
leaq -0x120(%rbp), %rdi
callq 0x4490
leaq -0xa8(%rbp), %rdi
callq 0xb460
movq -0xc8(%rbp), %rdi
callq 0x3490
nopl (%rax,%rax)