// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/convex.c
// Function: find_variable_to_bring_into_basis_qp_random
int find_variable_to_bring_into_basis_qp_random(Quadraticprogramptr program)
{
 int i, index = -2, pos, complementary, newnonbasic, *candidate, size;
 Linklistptr candidates;
 candidates = link_list();
 for (i = 0; i < program->variablecount + program->constraintcount; i++)
   if (!program->isbasic[i] && program->objectives[i] < 0)
    {
     complementary = complementary_variable(program->m, program->n, i);
     newnonbasic = find_variable_to_remove_from_basis(program->constraints, program->constraintcount, i);
     if ((i >= 2 * program->m + 2 * program->n) || !program->isbasic[complementary] || (newnonbasic >= 0 && program->basic[newnonbasic] == complementary))
      {
       candidate = safemalloc(sizeof(int), "find_variable_to_bring_into_basis_qp", 10);
       *candidate = i;
       link_list_insert(candidates, candidate);
      }
    }
 size = link_list_size(candidates);
 if (size != 0)
  {
   pos = myrand() % size;
   candidate = (int*) link_list_get_i(candidates, pos);
   index = *candidate;
  }
 else
   index = -1;
 free_link_list(candidates, safe_free);
 return index;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
xorl %eax, %eax
callq 0x1bccb
movq %rax, %rbx
movl 0x8(%r14), %eax
movl 0xc(%r14), %ecx
movl %eax, %edx
addl %ecx, %edx
jle 0xf5ad
xorl %r12d, %r12d
xorpd %xmm3, %xmm3
leaq 0x96da5(%rip), %r15     # 0xa6250
movq 0x40(%r14), %rdx
cmpl $0x0, (%rdx,%r12,4)
jne 0xf59b
movq 0x38(%r14), %rsi
ucomisd (%rsi,%r12,8), %xmm3
jbe 0xf59b
movl (%r14), %edi
addl 0x4(%r14), %edi
movslq %edi, %r8
movl %r8d, %esi
negl %esi
cmpq %r8, %r12
cmovll %edi, %esi
testl %eax, %eax
jle 0xf542
movq 0x18(%r14), %r9
movq 0x10(%r14), %r10
movabsq $-0x100000000, %r8      # imm = 0xFFFFFFFF00000000
addq %r8, %r10
sarq $0x20, %r10
movl %eax, %r11d
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %ebp, %ebp
movsd 0x96009(%rip), %xmm0    # 0xa5518
movq (%r9,%rbp,8), %r13
movsd (%r13,%r12,8), %xmm2
ucomisd %xmm3, %xmm2
jbe 0xf538
movsd (%r13,%r10,8), %xmm1
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xf538
movl %ebp, %r8d
movapd %xmm1, %xmm0
incq %rbp
cmpq %rbp, %r11
jne 0xf50f
jmp 0xf548
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
addl %edi, %edi
movslq %edi, %rdi
cmpq %rdi, %r12
jge 0xf56f
addl %r12d, %esi
movslq %esi, %rdi
cmpl $0x0, (%rdx,%rdi,4)
je 0xf56f
testl %r8d, %r8d
js 0xf59b
movq 0x48(%r14), %rdx
movl %r8d, %edi
cmpl %esi, (%rdx,%rdi,4)
jne 0xf59b
movl $0x4, %edi
movq %r15, %rsi
movl $0xa, %edx
callq 0x3a0e1
movl %r12d, (%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1bcea
xorpd %xmm3, %xmm3
movl 0x8(%r14), %eax
movl 0xc(%r14), %ecx
incq %r12
leal (%rax,%rcx), %edx
movslq %edx, %rdx
cmpq %rdx, %r12
jl 0xf4ab
movq %rbx, %rdi
callq 0x1be00
testl %eax, %eax
je 0xf5d3
movl %eax, %ebp
xorl %eax, %eax
callq 0x3af20
cltd
idivl %ebp
movq %rbx, %rdi
movl %edx, %esi
callq 0x1be13
movl (%rax), %ebp
jmp 0xf5d8
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x2aba1(%rip), %rsi     # 0x3a180
movq %rbx, %rdi
callq 0x1be40
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq