// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/interactions_tnm.c
// Function: Select_pairs
void Select_pairs(int *selected, struct interaction **res12, int n12)
{
  int k, kopt=0, nsel=0; float w=0;
  //selected: 0=not yet -1=discarded 1=selected
  for(k=0; k<n12; k++)selected[k]=0;
  while(kopt>=0){
    kopt=-1;
    for(k=0; k<n12; k++){
      if(selected[k])continue;
      if(res12[k]->sec_der==1){
	if((kopt<0)||(res12[k]->r0 < w)){
	  kopt=k; w=res12[k]->r0; 
	}
      }else{
	if((kopt<0)||(res12[k]->sec_der > w)){
	  kopt=k; w=res12[k]->sec_der;
	}
      } 
    }
    if(kopt<0)return;
    selected[kopt]=1; nsel++;
    int i1=res12[kopt]->i1, i2=res12[kopt]->i2;
    for(k=0; k<n12; k++){
      if(selected[k])continue;
      if((res12[k]->i1==i1)||(res12[k]->i2==i2))selected[k]=-1;
    }
  }
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x22ace
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x22aac
jmp 0x22ad0
cmpl $0x0, -0x1c(%rbp)
jl 0x22c75
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x22bc8
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x22b07
jmp 0x22bba
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsd 0x28(%rax), %xmm0
movsd 0x53528(%rip), %xmm1    # 0x76048
ucomisd %xmm1, %xmm0
jne 0x22b70
jp 0x22b70
cmpl $0x0, -0x1c(%rbp)
jl 0x22b4e
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsd 0x20(%rax), %xmm1
movss -0x24(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x22b6e
movl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsd 0x20(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x22bb8
cmpl $0x0, -0x1c(%rbp)
jl 0x22b96
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsd 0x28(%rax), %xmm0
movss -0x24(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x22bb6
movl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsd 0x28(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x22bb8
jmp 0x22bba
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x22ae8
cmpl $0x0, -0x1c(%rbp)
jge 0x22bd3
jmp 0x22c77
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x22c70
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x22c2d
jmp 0x22c65
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
cmpl -0x28(%rbp), %eax
je 0x22c54
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
cmpl -0x2c(%rbp), %eax
jne 0x22c63
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x22c65
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x22c15
jmp 0x22ad0
jmp 0x22c77
popq %rbp
retq
nopl (%rax)