// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/convex.c
// Function: solve_qp_using_simplex
Convexsolutionptr solve_qp_using_simplex(Quadraticprogramptr program, BOOLEAN random)
{
 Convexsolutionptr solution;
 SOLUTION_TYPE solutiontype = NO_SOLUTION;
 int i, newbasic, newnonbasic;
 solution = safemalloc(sizeof(Convexsolution), "solve_qp_using_simplex", 4);
 while (BOOLEAN_TRUE)
  {
   /*print_simplex_tableau(program->constraints, program->basic, program->objectives);*/
   if (random)
     newbasic = find_variable_to_bring_into_basis_qp_random(program);
   else
     newbasic = find_variable_to_bring_into_basis_qp(program);
   if (newbasic == -1)
    {
     solutiontype = INFINITE_SOLUTION;
     break;
    }
   if (newbasic == -2)
    {
     solutiontype = SINGLE_SOLUTION;
     break;
    }
   newnonbasic = find_variable_to_remove_from_basis(program->constraints, program->constraintcount, newbasic);
   if (newnonbasic == -1)
    {
     solutiontype = UNBOUNDED_SOLUTION;
     break;
    }
   pivot_on_the_new_variables(program->constraints, program->objectives, newnonbasic, newbasic);
   program->isbasic[newbasic] = BOOLEAN_TRUE;
   program->isbasic[program->basic[newnonbasic]] = BOOLEAN_FALSE;
   program->basic[newnonbasic] = newbasic;
  }
 solution->optimalvalue = program->objectives[program->variablecount + program->constraintcount];
 printf("Optimal:%f\n", solution->optimalvalue);
 solution->variablecount = program->n;
 solution->solutiontype = solutiontype;
 solution->variables = safecalloc(solution->variablecount, sizeof(double), "solve_qp_using_simplex", 23);
 for (i = 0; i < program->constraintcount; i++)
   if (program->basic[i] < program->n)
     solution->variables[program->basic[i]] = program->constraints.values[i][program->variablecount + program->constraintcount];
 return solution;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, 0xc(%rsp)
movq %rdi, %rbx
leaq 0x86f3d(%rip), %rsi     # 0x962d7
pushq $0x20
popq %rdi
pushq $0x4
popq %rdx
callq 0x34f59
movq %rax, 0x10(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0xf3bb
movq %rbx, %rdi
callq 0xe9ca
jmp 0xf3c3
movq %rbx, %rdi
callq 0xeb36
movl %eax, %r15d
xorl %ebp, %ebp
cmpl $-0x2, %eax
je 0xf432
cmpl $-0x1, %r15d
je 0xf42e
movl 0x8(%rbx), %edx
movq 0x10(%rbx), %r13
movq 0x18(%rbx), %r14
movq %r13, %rdi
movq %r14, %rsi
movl %r15d, %ecx
callq 0xeadb
cmpl $-0x1, %eax
je 0xf437
movl %eax, %r12d
movq 0x38(%rbx), %rdx
movq %r13, %rdi
movq %r14, %rsi
movl %eax, %ecx
movl %r15d, %r8d
callq 0xec3d
movq 0x40(%rbx), %rax
movslq %r15d, %rcx
movl $0x1, (%rax,%rcx,4)
movq 0x48(%rbx), %rcx
movslq %r12d, %rdx
movslq (%rcx,%rdx,4), %rsi
andl $0x0, (%rax,%rsi,4)
movl %r15d, (%rcx,%rdx,4)
jmp 0xf3aa
pushq $0x3
jmp 0xf439
xorl %r15d, %r15d
jmp 0xf43b
pushq $0x2
popq %r15
movq 0x38(%rbx), %rax
movslq 0xc(%rbx), %rcx
movslq 0x8(%rbx), %rdx
addq %rcx, %rdx
movsd (%rax,%rdx,8), %xmm0
movq 0x10(%rsp), %r14
movsd %xmm0, 0x8(%r14)
leaq 0x86e8d(%rip), %rdi     # 0x962ee
movb $0x1, %al
callq 0x4030
movslq (%rbx), %rdi
movl %edi, 0x18(%r14)
movl %r15d, (%r14)
leaq 0x86e5e(%rip), %rdx     # 0x962d7
pushq $0x8
popq %rsi
pushq $0x17
popq %rcx
callq 0x35067
movq %rax, 0x10(%r14)
movslq 0x8(%rbx), %rcx
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
cmpq %rbp, %rdx
je 0xf4c6
movq 0x48(%rbx), %rsi
movslq (%rsi,%rbp,4), %rsi
cmpl (%rbx), %esi
jge 0xf4c1
movq 0x18(%rbx), %rdi
movq (%rdi,%rbp,8), %rdi
movslq 0xc(%rbx), %r8
addq %rcx, %r8
movsd (%rdi,%r8,8), %xmm0
movsd %xmm0, (%rax,%rsi,8)
incq %rbp
jmp 0xf496
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq