// File: /workspace/github_c_makefile_star2_O1/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, 0x20(%rsp)
movq %r8, %r13
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %rbp
movq %rdi, %r15
leaq 0x94549(%rip), %rsi     # 0xa3239
movl $0x50, %edi
movl $0x6, %edx
callq 0x390f5
movq %rax, %rbx
movl %r15d, (%rax)
movl %r14d, 0x4(%rax)
addl %r15d, %r14d
leal (%r14,%r14,2), %eax
movl %eax, 0x8(%rsp)
movq %r15, %rdi
movq %rbp, 0x10(%rsp)
movq %rbp, %rsi
callq 0x3ca3c
movq %rax, 0x20(%rbx)
movq %rdx, 0x28(%rbx)
movl (%rbx), %esi
movq %r13, 0x18(%rsp)
movq %r13, %rdi
callq 0x37088
movq %rax, 0x30(%rbx)
leal (%r14,%r14,2), %ebp
incl %ebp
movslq %ebp, %rdi
movl $0x8, %esi
leaq 0x944e5(%rip), %r14     # 0xa3239
movq %r14, %rdx
movl $0xa, %ecx
callq 0x39210
movq %rax, 0x38(%rbx)
movslq (%rbx), %rax
movslq 0x4(%rbx), %rdi
addq %rax, %rdi
shlq $0x2, %rdi
movq %r14, %rsi
movl $0xb, %edx
callq 0x390f5
movq %rax, 0x48(%rbx)
movslq 0x8(%rsp), %r13
movl $0x4, %esi
movq %r13, %rdi
movq %r14, %rdx
movl $0xc, %ecx
callq 0x39210
movq %rax, 0x40(%rbx)
movl 0x4(%rbx), %edx
addl (%rbx), %edx
addl %edx, %edx
testl %edx, %edx
jle 0xedc8
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
movl 0x4(%rbx), %edx
addl (%rbx), %edx
incq %rcx
addl %edx, %edx
movslq %edx, %rsi
cmpq %rsi, %rcx
jl 0xedaf
movl 0x4(%rbx), %edi
addl (%rbx), %edi
leal (%rdi,%rdi,2), %ecx
movabsq $0x3ff0000000000000, %r15 # imm = 0x3FF0000000000000
cmpl %ecx, %edx
jge 0xee1b
movq 0x38(%rbx), %rcx
movq 0x48(%rbx), %rsi
movslq %edx, %rdx
addl %edi, %edi
movslq %edi, %rdi
shlq $0x2, %rdi
movq %rsi, %r8
subq %rdi, %r8
movl %edx, (%r8,%rdx,4)
movq %r15, (%rcx,%rdx,8)
movl $0x1, (%rax,%rdx,4)
movl 0x4(%rbx), %edi
addl (%rbx), %edi
incq %rdx
leal (%rdi,%rdi,2), %r8d
movslq %r8d, %r8
cmpq %r8, %rdx
jl 0xede9
movl %ebp, %esi
callq 0x3c6e5
movq %rax, 0x10(%rbx)
movq %rdx, 0x18(%rbx)
movq %rbx, 0x8(%rsp)
movslq (%rbx), %rcx
movl %ecx, %r14d
testq %rcx, %rcx
movq %r13, %rax
jle 0xef27
movq 0x8(%rsp), %rsi
movl 0x4(%rsi), %esi
leal (%rsi,%r14), %edi
leal (%rsi,%r14), %r8d
addl %r8d, %r8d
movslq %edi, %rdi
movslq %r8d, %r8
shlq $0x3, %rdi
shlq $0x3, %r8
xorl %r9d, %r9d
leaq (,%r14,8), %r10
movabsq $-0x4010000000000000, %r11 # imm = 0xBFF0000000000000
movapd 0x94351(%rip), %xmm0    # 0xa31d0
movq 0x10(%rsp), %rbx
movq (%rbx,%r9,8), %r13
movq (%rdx,%r9,8), %rbp
xorl %ebx, %ebx
movsd (%r13,%rbx,8), %xmm1
movsd %xmm1, (%rbp,%rbx,8)
incq %rbx
cmpq %rbx, %r14
jne 0xee8e
testl %esi, %esi
jle 0xeeca
movq (%rdx,%r9,8), %r13
addq %r10, %r13
xorl %ebx, %ebx
movq (%r12,%rbx,8), %rbp
movsd (%rbp,%r9,8), %xmm1
movsd %xmm1, (%r13,%rbx,8)
incq %rbx
cmpq %rbx, %rsi
jne 0xeeb0
xorl %r13d, %r13d
cmpq %r13, %r9
jne 0xeedd
movq (%rdx,%r9,8), %rbx
addq %rdi, %rbx
movq %r11, (%rbx,%r13,8)
incq %r13
cmpq %r13, %r14
jne 0xeecd
xorl %r13d, %r13d
cmpq %r13, %r9
jne 0xeef8
movq (%rdx,%r9,8), %rbx
addq %r8, %rbx
movq %r15, (%rbx,%r13,8)
incq %r13
cmpq %r13, %r14
jne 0xeee8
movq 0x18(%rsp), %rbx
movsd (%rbx,%r9,8), %xmm1
xorpd %xmm0, %xmm1
movq (%rdx,%r9,8), %rbx
movq %rax, %r13
movlpd %xmm1, (%rbx,%rax,8)
incq %r9
cmpq %r14, %r9
jne 0xee7f
movq 0x8(%rsp), %rsi
movslq 0x4(%rsi), %rsi
testq %rsi, %rsi
jle 0xefff
leal (%rsi,%r14,2), %edi
leal (%r14,%r14,2), %r8d
leal (%r8,%rsi,2), %r8d
movslq %edi, %rdi
movslq %r8d, %r8
movslq %r14d, %r9
movslq %r14d, %r10
movslq %r14d, %rbx
leaq (%rdx,%r10,8), %r10
movq %r10, 0x10(%rsp)
leaq (%rdx,%r9,8), %r10
leaq (%rdx,%rcx,8), %r11
leaq (%rdx,%rbx,8), %r9
movq %r9, 0x18(%rsp)
shlq $0x3, %rdi
shlq $0x3, %r8
xorl %ebp, %ebp
testl %ecx, %ecx
jle 0xefa0
movq (%r12,%rbp,8), %r9
movq 0x10(%rsp), %rbx
movq (%rbx,%rbp,8), %rbx
xorl %r13d, %r13d
movsd (%r9,%r13,8), %xmm0
movsd %xmm0, (%rbx,%r13,8)
incq %r13
cmpq %r13, %r14
jne 0xef8c
xorl %r9d, %r9d
movq %rax, %r13
cmpq %r9, %rbp
jne 0xefb6
movq (%r10,%rbp,8), %rbx
addq %rdi, %rbx
movq %r15, (%rbx,%r9,8)
incq %r9
cmpq %r9, %rsi
jne 0xefa6
xorl %r9d, %r9d
cmpq %r9, %rbp
jne 0xefd1
movq (%r11,%rbp,8), %rbx
addq %r8, %rbx
movq %r15, (%rbx,%r9,8)
incq %r9
cmpq %r9, %rsi
jne 0xefc1
movq 0x20(%rsp), %r9
movsd (%r9,%rbp,8), %xmm0
movq 0x18(%rsp), %r9
movq (%r9,%rbp,8), %r9
movsd %xmm0, (%r9,%r13,8)
incq %rbp
cmpq %rsi, %rbp
jne 0xef78
movq 0x8(%rsp), %r11
movslq 0x10(%r11), %rdi
testq %rdi, %rdi
jle 0xf063
addl %esi, %ecx
addl %ecx, %ecx
xorl %r8d, %r8d
xorpd %xmm0, %xmm0
movapd 0x941b0(%rip), %xmm1    # 0xa31d0
movq (%rdx,%r8,8), %r9
ucomisd (%r9,%r13,8), %xmm0
jbe 0xf05b
testl %ecx, %ecx
jle 0xf04b
xorl %r10d, %r10d
movsd (%r9,%r10,8), %xmm2
xorpd %xmm1, %xmm2
movlpd %xmm2, (%r9,%r10,8)
incq %r10
cmpq %r10, %rcx
jne 0xf033
movsd (%r9,%r13,8), %xmm2
xorpd %xmm1, %xmm2
movlpd %xmm2, (%r9,%r13,8)
incq %r8
cmpq %rdi, %r8
jne 0xf020
addl %esi, %r14d
movl %r14d, %ecx
xorpd %xmm0, %xmm0
jle 0xf083
xorl %esi, %esi
movq (%rdx,%rsi,8), %rdi
addsd (%rdi,%r13,8), %xmm0
incq %rsi
cmpq %rsi, %rcx
jne 0xf071
xorpd 0x94145(%rip), %xmm0    # 0xa31d0
movq 0x38(%r11), %rsi
movlpd %xmm0, (%rsi,%r13,8)
leal (%r14,%r14), %edi
testl %edi, %edi
jle 0xf0db
movl %edi, %r8d
xorl %r9d, %r9d
movapd 0x94125(%rip), %xmm0    # 0xa31d0
xorpd %xmm1, %xmm1
testl %r14d, %r14d
jle 0xf0c9
xorl %r10d, %r10d
movq (%rdx,%r10,8), %r11
addsd (%r11,%r9,8), %xmm1
incq %r10
cmpq %r10, %rcx
jne 0xf0b7
xorpd %xmm0, %xmm1
movlpd %xmm1, (%rsi,%r9,8)
incq %r9
cmpq %r8, %r9
jne 0xf0ab
movq 0x8(%rsp), %rax
movl %edi, 0xc(%rax)
movl %r14d, 0x8(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq