// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x1, -0x1c(%rbp)
movl $0x20, %edi
leaq 0xcce47(%rip), %rsi     # 0xe2f89
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x18(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x16164
movq -0x8(%rbp), %rdi
callq 0x15040
movl %eax, -0x24(%rbp)
jmp 0x16170
movq -0x8(%rbp), %rdi
callq 0x15290
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x16182
movl $0x3, -0x1c(%rbp)
jmp 0x1622a
cmpl $-0x2, -0x24(%rbp)
jne 0x16194
movl $0x0, -0x1c(%rbp)
jmp 0x1622a
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %edx
movl -0x24(%rbp), %ecx
movq 0x10(%rax), %rdi
movq 0x18(%rax), %rsi
callq 0x151d0
movl %eax, -0x28(%rbp)
cmpl $-0x1, -0x28(%rbp)
jne 0x161c1
movl $0x2, -0x1c(%rbp)
jmp 0x1622a
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x38(%rcx), %rdx
movl -0x28(%rbp), %ecx
movl -0x24(%rbp), %r8d
movq 0x10(%rax), %rdi
movq 0x18(%rax), %rsi
callq 0x153f0
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x24(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x48(%rcx), %rcx
movslq -0x28(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x24(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x16150
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0xc(%rcx), %ecx
movq -0x8(%rbp), %rdx
addl 0x8(%rdx), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x18(%rbp), %rax
movsd 0x8(%rax), %xmm0
leaq 0xccd3f(%rip), %rdi     # 0xe2fa0
movb $0x1, %al
callq 0x4030
movq -0x8(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movslq 0x18(%rax), %rdi
movl $0x8, %esi
leaq 0xcccf7(%rip), %rdx     # 0xe2f89
movl $0x17, %ecx
callq 0x52f40
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x16321
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x16314
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movl 0xc(%rcx), %ecx
movq -0x8(%rbp), %rdx
addl 0x8(%rdx), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x48(%rcx), %rcx
movslq -0x20(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x16316
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x162ae
movq -0x18(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)