// File: /workspace/github_c_makefile_star2_O1/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 0x1b64f
movq %rax, %rbx
movl 0x8(%r14), %esi
movl 0xc(%r14), %eax
addl %esi, %eax
jle 0xf58a
xorl %r12d, %r12d
xorpd %xmm3, %xmm3
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
leaq 0x93db5(%rip), %r15     # 0xa3250
movq 0x40(%r14), %rax
cmpl $0x0, (%rax,%r12,4)
jne 0xf573
movq 0x38(%r14), %rcx
ucomisd (%rcx,%r12,8), %xmm3
jbe 0xf573
movl (%r14), %edx
addl 0x4(%r14), %edx
movslq %edx, %rdi
movl %edi, %ecx
negl %ecx
cmpq %rdi, %r12
cmovll %edx, %ecx
testl %esi, %esi
jle 0xf525
movq 0x18(%r14), %rdi
movq 0x10(%r14), %r8
addq %r13, %r8
sarq $0x20, %r8
movl %esi, %r9d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %r10d, %r10d
movsd 0x93024(%rip), %xmm0    # 0xa2518
movq (%rdi,%r10,8), %r11
movsd (%r11,%r12,8), %xmm2
ucomisd %xmm3, %xmm2
jbe 0xf51b
movsd (%r11,%r8,8), %xmm1
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xf51b
movl %r10d, %esi
movapd %xmm1, %xmm0
incq %r10
cmpq %r10, %r9
jne 0xf4f4
jmp 0xf52a
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
addl %edx, %edx
movslq %edx, %rdx
cmpq %rdx, %r12
jge 0xf54f
addl %r12d, %ecx
movslq %ecx, %rdx
cmpl $0x0, (%rax,%rdx,4)
je 0xf54f
testl %esi, %esi
js 0xf573
movq 0x48(%r14), %rax
movl %esi, %edx
cmpl %ecx, (%rax,%rdx,4)
jne 0xf573
movl $0x4, %edi
movq %r15, %rsi
movl $0xa, %edx
callq 0x390f5
movl %r12d, (%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1b66e
xorpd %xmm3, %xmm3
incq %r12
movslq 0xc(%r14), %rax
movslq 0x8(%r14), %rsi
addq %rsi, %rax
cmpq %rax, %r12
jl 0xf49b
movq %rbx, %rdi
callq 0x1b784
testl %eax, %eax
je 0xf5b0
movl %eax, %ebp
xorl %eax, %eax
callq 0x39f18
cltd
idivl %ebp
movq %rbx, %rdi
movl %edx, %esi
callq 0x1b797
movl (%rax), %ebp
jmp 0xf5b5
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x29bd8(%rip), %rsi     # 0x39194
movq %rbx, %rdi
callq 0x1b7c4
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq