// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/convex.c
// Function: prepare_quadratic_program
Quadraticprogramptr prepare_quadratic_program(matrix Q, matrix A, double* c, double* b)
{
 int i, j, totalvariables;
 Quadraticprogramptr program;
 double sum;
 program = safemalloc(sizeof(Quadraticprogram), "read_quadratic_program", 6);
 program->n = Q.row;
 program->m = A.row;
 totalvariables = 3 * program->n + 3 * program->m;
 program->Q = matrix_copy(Q);
 program->c = clone_array(c, program->n);
 program->objectives = safecalloc(totalvariables + 1, sizeof(double), "read_quadratic_program", 10);
 program->basic = safemalloc((program->n + program->m) * sizeof(int), "read_quadratic_program", 11);
 program->isbasic = safecalloc(totalvariables, sizeof(BOOLEAN), "read_quadratic_program", 12);
 for (i = 0; i < 2 * program->n + 2 * program->m; i++)
   program->isbasic[i] = BOOLEAN_FALSE;
 for (i = 2 * program->n + 2 * program->m; i < 3 * program->n + 3 * program->m; i++)
  {
   program->basic[i - (2 * program->n + 2 * program->m)] = i;
   program->objectives[i] = 1;
   program->isbasic[i] = BOOLEAN_TRUE;
  }
 program->constraints = matrix_alloc(program->n + program->m, totalvariables + 1);
 for (i = 0; i < program->n; i++)
  {
   for (j = 0; j < program->n; j++)
     program->constraints.values[i][j] = Q.values[i][j];
   for (j = 0; j < program->m; j++)
     program->constraints.values[i][program->n + j] = A.values[j][i];
   for (j = 0; j < program->n; j++)
     if (j == i)
       program->constraints.values[i][program->m + program->n + j] = -1;
   for (j = 0; j < program->n; j++)
     if (j == i)
       program->constraints.values[i][2 * program->m + 2 * program->n + j] = 1;
   program->constraints.values[i][totalvariables] = -c[i];
  }
 for (i = 0; i < program->m; i++)
  {
   for (j = 0; j < program->n; j++)
     program->constraints.values[program->n + i][j] = A.values[i][j];
   for (j = 0; j < program->m; j++)
     if (j == i)
       program->constraints.values[program->n + i][program->m + 2 * program->n + j] = 1;
   for (j = 0; j < program->m; j++)
     if (j == i)
       program->constraints.values[program->n + i][2 * program->m + 3 * program->n + j] = 1;
   program->constraints.values[program->n + i][totalvariables] = b[i];
  }
 for (i = 0; i < program->constraints.row; i++)
   if (program->constraints.values[i][totalvariables] < 0)
    {
     for (j = 0; j < 2 * program->m + 2 * program->n; j++)
       program->constraints.values[i][j] *= - 1;
     program->constraints.values[i][totalvariables] *= - 1;
    }
 sum = 0;
 for (i = 0; i < program->m + program->n; i++)
   sum += program->constraints.values[i][totalvariables];
 program->objectives[totalvariables] = -sum;
 for (i = 0; i < 2 * program->m + 2 * program->n; i++)
  {
   sum = 0;
   for (j = 0; j < program->m + program->n; j++)
     sum += program->constraints.values[j][i];
   program->objectives[i] = -sum;
  }
 program->variablecount = 2 * program->m + 2 * program->n;
 program->constraintcount = program->m + program->n;
 return program;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %rbp
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
leaq 0x974e7(%rip), %rsi     # 0xa6239
movl $0x50, %edi
movl $0x6, %edx
callq 0x3a0e1
movq %rax, %rbx
movl %r15d, (%rax)
movl %r14d, 0x4(%rax)
addl %r15d, %r14d
leal (%r14,%r14,2), %eax
movl %eax, (%rsp)
movq %r15, %rdi
movq %r13, 0x18(%rsp)
movq %r13, %rsi
callq 0x3dae3
movq %rax, 0x20(%rbx)
movq %rdx, 0x28(%rbx)
movl (%rbx), %esi
movq %rbp, 0x20(%rsp)
movq %rbp, %rdi
callq 0x37a28
movq %rax, 0x30(%rbx)
leal (%r14,%r14,2), %ebp
incl %ebp
movslq %ebp, %rdi
movl $0x8, %esi
leaq 0x97484(%rip), %r15     # 0xa6239
movq %r15, %rdx
movl $0xa, %ecx
callq 0x3a1fc
movq %rax, 0x38(%rbx)
movslq (%rbx), %rax
movslq 0x4(%rbx), %rdi
addq %rax, %rdi
shlq $0x2, %rdi
movq %r15, %rsi
movl $0xb, %edx
callq 0x3a0e1
movq %rax, 0x48(%rbx)
movslq (%rsp), %r14
movl $0x4, %esi
movq %r14, %rdi
movq %r15, %rdx
movl $0xc, %ecx
callq 0x3a1fc
movq %rax, 0x40(%rbx)
movl 0x4(%rbx), %edi
addl (%rbx), %edi
leal (%rdi,%rdi), %esi
testl %esi, %esi
jle 0xee2a
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
movl 0x4(%rbx), %edi
addl (%rbx), %edi
incq %rcx
leal (%rdi,%rdi), %esi
movslq %esi, %rdx
cmpq %rdx, %rcx
jl 0xee10
leal (%rdi,%rdi,2), %ecx
movabsq $0x3ff0000000000000, %r15 # imm = 0x3FF0000000000000
cmpl %ecx, %esi
jge 0xee78
movq 0x38(%rbx), %rcx
movq 0x48(%rbx), %rdx
movslq %esi, %rsi
addl %edi, %edi
movslq %edi, %rdi
shlq $0x2, %rdi
movq %rdx, %r8
subq %rdi, %r8
movl %esi, (%r8,%rsi,4)
movq %r15, (%rcx,%rsi,8)
movl $0x1, (%rax,%rsi,4)
movl 0x4(%rbx), %edi
addl (%rbx), %edi
incq %rsi
leal (%rdi,%rdi,2), %r8d
movslq %r8d, %r8
cmpq %r8, %rsi
jl 0xee46
movl %ebp, %esi
callq 0x3d79d
movq %rax, 0x8(%rsp)
movq %rax, 0x10(%rbx)
movq %rdx, 0x18(%rbx)
movslq (%rbx), %rax
movl %eax, %ecx
movl 0x4(%rbx), %esi
movq %rax, (%rsp)
testq %rax, %rax
jle 0xef79
movq (%rsp), %rax
addl %esi, %eax
movslq %eax, %r8
addl %eax, %eax
movslq %eax, %r9
xorl %r10d, %r10d
leaq (,%rcx,8), %rax
movabsq $-0x4010000000000000, %rdi # imm = 0xBFF0000000000000
movapd 0x97304(%rip), %xmm0    # 0xa61d0
movq 0x18(%rsp), %r11
movq (%r11,%r10,8), %r13
movq (%rdx,%r10,8), %rbp
xorl %r11d, %r11d
movsd (%r13,%r11,8), %xmm1
movsd %xmm1, (%rbp,%r11,8)
incq %r11
cmpq %r11, %rcx
jne 0xeedc
testl %esi, %esi
jle 0xef18
movq (%rdx,%r10,8), %r13
addq %rax, %r13
xorl %ebp, %ebp
movq (%r12,%rbp,8), %r11
movsd (%r11,%r10,8), %xmm1
movsd %xmm1, (%r13,%rbp,8)
incq %rbp
cmpq %rbp, %rsi
jne 0xeeff
leaq (,%r10,8), %r13
xorl %ebp, %ebp
cmpq %rbp, %r10
jne 0xef32
movq (%rdx,%r10,8), %r11
addq %r13, %r11
movq %rdi, (%r11,%r8,8)
incq %rbp
cmpq %rbp, %rcx
jne 0xef22
xorl %ebp, %ebp
cmpq %rbp, %r10
jne 0xef4c
movq (%rdx,%r10,8), %r11
addq %r13, %r11
movq %r15, (%r11,%r9,8)
incq %rbp
cmpq %rbp, %rcx
jne 0xef3c
movq 0x20(%rsp), %r11
movsd (%r11,%r10,8), %xmm1
xorpd %xmm0, %xmm1
movq (%rdx,%r10,8), %r11
movlpd %xmm1, (%r11,%r14,8)
incq %r10
cmpq %rcx, %r10
jne 0xeecc
testl %esi, %esi
movq 0x10(%rsp), %rbp
jle 0xf01c
leal (%rsi,%rcx,2), %eax
movq (%rsp), %r9
leal (%r9,%r9,2), %edi
leal (%rdi,%rsi,2), %r8d
movslq %eax, %rdi
movslq %r8d, %r8
leaq (%rdx,%r9,8), %r9
xorl %r10d, %r10d
testl %ecx, %ecx
jle 0xefc5
movq (%r12,%r10,8), %r11
movq (%r9,%r10,8), %r13
xorl %eax, %eax
movsd (%r11,%rax,8), %xmm0
movsd %xmm0, (%r13,%rax,8)
incq %rax
cmpq %rax, %rcx
jne 0xefb0
leaq (,%r10,8), %r11
xorl %r13d, %r13d
cmpq %r13, %r10
jne 0xefe0
movq (%r9,%r10,8), %rax
addq %r11, %rax
movq %r15, (%rax,%rdi,8)
incq %r13
cmpq %r13, %rsi
jne 0xefd0
xorl %r13d, %r13d
cmpq %r13, %r10
jne 0xeffb
movq (%r9,%r10,8), %rax
addq %r11, %rax
movq %r15, (%rax,%r8,8)
incq %r13
cmpq %r13, %rsi
jne 0xefeb
movq (%r9,%r10,8), %rax
movsd (%rbp,%r10,8), %xmm0
movsd %xmm0, (%rax,%r14,8)
incq %r10
cmpq %rsi, %r10
jne 0xefa2
addl %esi, %ecx
movq 0x8(%rsp), %rax
testl %eax, %eax
jle 0xf085
leal (%rcx,%rcx), %esi
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %edi, %edi
xorpd %xmm0, %xmm0
movapd 0x97193(%rip), %xmm1    # 0xa61d0
movq (%rdx,%rdi,8), %r8
movsd (%r8,%r14,8), %xmm2
ucomisd %xmm2, %xmm0
jbe 0xf07d
testl %esi, %esi
jle 0xf073
xorl %r9d, %r9d
movupd (%r8,%r9,8), %xmm2
xorpd %xmm1, %xmm2
movupd %xmm2, (%r8,%r9,8)
addq $0x2, %r9
cmpq %r9, %rsi
jne 0xf054
movsd (%r8,%r14,8), %xmm2
xorpd %xmm1, %xmm2
movlpd %xmm2, (%r8,%r14,8)
incq %rdi
cmpq %rax, %rdi
jne 0xf03d
movl %ecx, %eax
xorpd %xmm0, %xmm0
testl %ecx, %ecx
jle 0xf0a3
xorl %esi, %esi
movq (%rdx,%rsi,8), %rdi
addsd (%rdi,%r14,8), %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0xf091
xorpd 0x97125(%rip), %xmm0    # 0xa61d0
movq 0x38(%rbx), %rsi
movlpd %xmm0, (%rsi,%r14,8)
leal (%rcx,%rcx), %edi
testl %edi, %edi
jle 0xf0f9
movl %edi, %r8d
xorl %r9d, %r9d
movapd 0x97106(%rip), %xmm0    # 0xa61d0
xorpd %xmm1, %xmm1
testl %ecx, %ecx
jle 0xf0e7
xorl %r10d, %r10d
movq (%rdx,%r10,8), %r11
addsd (%r11,%r9,8), %xmm1
incq %r10
cmpq %r10, %rax
jne 0xf0d5
xorpd %xmm0, %xmm1
movlpd %xmm1, (%rsi,%r9,8)
incq %r9
cmpq %r8, %r9
jne 0xf0ca
movl %edi, 0xc(%rbx)
movl %ecx, 0x8(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq