// File: /workspace/github_c_makefile_star2_O2/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 0x87f4f(%rip), %rsi     # 0x96239
pushq $0x50
popq %rdi
pushq $0x6
popq %rdx
callq 0x34f59
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, %rsi
callq 0x383f4
movq %rax, 0x20(%rbx)
movq %rdx, 0x28(%rbx)
movl (%rbx), %esi
movq %r13, 0x10(%rsp)
movq %r13, %rdi
callq 0x3325d
movq %rax, 0x30(%rbx)
leal (%r14,%r14,2), %r13d
incl %r13d
movslq %r13d, %rdi
pushq $0x8
popq %rsi
pushq $0xa
popq %rcx
leaq 0x87ef2(%rip), %r15     # 0x96239
movq %r15, %rdx
callq 0x35067
movq %rax, 0x38(%rbx)
movslq (%rbx), %rax
movslq 0x4(%rbx), %rdi
addq %rax, %rdi
shlq $0x2, %rdi
pushq $0xb
popq %rdx
movq %r15, %rsi
callq 0x34f59
movq %rax, 0x48(%rbx)
movslq 0x8(%rsp), %r14
pushq $0x4
popq %rsi
pushq $0xc
popq %rcx
movq %r14, %rdi
movq %r15, %rdx
callq 0x35067
movq %rax, 0x40(%rbx)
xorl %esi, %esi
movl (%rbx), %edx
movl 0x4(%rbx), %edi
leal (%rdi,%rdx), %ecx
addl %ecx, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rsi
jge 0xe3a7
andl $0x0, (%rax,%rsi,4)
incq %rsi
jmp 0xe38c
movabsq $0x3ff0000000000000, %r15 # imm = 0x3FF0000000000000
addl %edx, %edi
leal (%rdi,%rdi,2), %edx
movslq %edx, %rdx
cmpq %rdx, %rcx
jge 0xe3ea
movq 0x48(%rbx), %rdx
addl %edi, %edi
movslq %edi, %rsi
shlq $0x2, %rsi
subq %rsi, %rdx
movl %ecx, (%rdx,%rcx,4)
movq 0x38(%rbx), %rdx
movq %r15, (%rdx,%rcx,8)
movl $0x1, (%rax,%rcx,4)
incq %rcx
movl (%rbx), %edx
movl 0x4(%rbx), %edi
jmp 0xe3b1
movl %r13d, %esi
callq 0x380d3
movq %rax, 0x8(%rsp)
movq %rax, 0x10(%rbx)
movq %rdx, 0x18(%rbx)
movl (%rbx), %ecx
movslq %ecx, %rax
xorl %r8d, %r8d
testl %eax, %eax
movl $0x0, %esi
cmovgl %eax, %esi
movq %rax, 0x18(%rsp)
leaq (,%rax,8), %r9
movapd 0x87daa(%rip), %xmm0    # 0x961d0
movabsq $-0x4010000000000000, %r10 # imm = 0xBFF0000000000000
cmpq %rsi, %r8
je 0xe4fe
xorl %eax, %eax
cmpq %rax, %rcx
je 0xe458
movq (%rbp,%r8,8), %rdi
movsd (%rdi,%rax,8), %xmm1
movq (%rdx,%r8,8), %rdi
movsd %xmm1, (%rdi,%rax,8)
incq %rax
jmp 0xe43b
movl 0x4(%rbx), %r11d
testl %r11d, %r11d
movl $0x0, %edi
cmovgl %r11d, %edi
xorl %eax, %eax
cmpq %rax, %rdi
je 0xe48d
movq (%r12,%rax,8), %r13
movsd (%r13,%r8,8), %xmm1
movq (%rdx,%r8,8), %r13
addq %r9, %r13
movsd %xmm1, (%r13,%rax,8)
incq %rax
jmp 0xe46a
addl %ecx, %r11d
movslq %r11d, %rdi
xorl %r13d, %r13d
cmpq %r13, %rcx
je 0xe4b5
cmpq %r13, %r8
jne 0xe4b0
leaq (,%r8,8), %rax
addq (%rdx,%r8,8), %rax
movq %r10, (%rax,%rdi,8)
incq %r13
jmp 0xe496
addl %r11d, %r11d
movslq %r11d, %rdi
xorl %r11d, %r11d
cmpq %r11, %rcx
je 0xe4dd
cmpq %r11, %r8
jne 0xe4d8
leaq (,%r8,8), %rax
addq (%rdx,%r8,8), %rax
movq %r15, (%rax,%rdi,8)
incq %r11
jmp 0xe4be
movq 0x10(%rsp), %rax
movsd (%rax,%r8,8), %xmm1
xorpd %xmm0, %xmm1
movq (%rdx,%r8,8), %rax
movlpd %xmm1, (%rax,%r14,8)
incq %r8
jmp 0xe430
movl 0x4(%rbx), %r8d
leal (%r8,%rcx,2), %eax
leal (%rcx,%rcx,2), %edi
leal (%rdi,%r8,2), %edi
movslq %eax, %r9
movslq %edi, %r10
xorl %r11d, %r11d
testl %r8d, %r8d
movl $0x0, %eax
cmovgl %r8d, %eax
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rax
leaq (%rdx,%rax,8), %rdi
cmpq 0x10(%rsp), %r11
je 0xe5bd
xorl %r13d, %r13d
cmpq %r13, %rsi
je 0xe55e
movq (%r12,%r11,8), %rbp
movsd (%rbp,%r13,8), %xmm1
movq (%rdi,%r11,8), %rbp
movsd %xmm1, (%rbp,%r13,8)
incq %r13
jmp 0xe53e
leaq (,%r11,8), %rbp
xorl %r13d, %r13d
cmpq %r13, %r8
je 0xe583
cmpq %r13, %r11
jne 0xe57e
movq (%rdi,%r11,8), %rax
addq %rbp, %rax
movq %r15, (%rax,%r9,8)
incq %r13
jmp 0xe569
xorl %r13d, %r13d
cmpq %r13, %r8
je 0xe5a0
cmpq %r13, %r11
jne 0xe59b
movq (%rdi,%r11,8), %rax
addq %rbp, %rax
movq %r15, (%rax,%r10,8)
incq %r13
jmp 0xe586
movq 0x20(%rsp), %rax
movsd (%rax,%r11,8), %xmm1
movq (%rdi,%r11,8), %rax
movsd %xmm1, (%rax,%r14,8)
incq %r11
jmp 0xe530
addl %r8d, %ecx
leal (%rcx,%rcx), %esi
xorl %r8d, %r8d
testl %esi, %esi
movl $0x0, %edi
cmovgl %esi, %edi
movq 0x8(%rsp), %r10
testl %r10d, %r10d
cmovlel %r8d, %r10d
xorpd %xmm1, %xmm1
cmpq %r10, %r8
je 0xe622
movq (%rdx,%r8,8), %r9
ucomisd (%r9,%r14,8), %xmm1
jbe 0xe61d
xorl %eax, %eax
cmpq %rax, %rdi
je 0xe60d
movsd (%r9,%rax,8), %xmm2
xorpd %xmm0, %xmm2
movlpd %xmm2, (%r9,%rax,8)
incq %rax
jmp 0xe5f3
movsd (%r9,%r14,8), %xmm2
xorpd %xmm0, %xmm2
movlpd %xmm2, (%r9,%r14,8)
incq %r8
jmp 0xe5e0
xorl %r8d, %r8d
testl %ecx, %ecx
movl $0x0, %eax
cmovgl %ecx, %eax
xorpd %xmm1, %xmm1
cmpq %r8, %rax
je 0xe647
movq (%rdx,%r8,8), %r9
addsd (%r9,%r14,8), %xmm1
incq %r8
jmp 0xe633
xorpd 0x87b81(%rip), %xmm1    # 0x961d0
movq 0x38(%rbx), %r8
movlpd %xmm1, (%r8,%r14,8)
xorl %r9d, %r9d
cmpq %rdi, %r9
je 0xe68b
xorpd %xmm1, %xmm1
xorl %r10d, %r10d
cmpq %r10, %rax
je 0xe67c
movq (%rdx,%r10,8), %r11
addsd (%r11,%r9,8), %xmm1
incq %r10
jmp 0xe668
xorpd %xmm0, %xmm1
movlpd %xmm1, (%r8,%r9,8)
incq %r9
jmp 0xe65c
movl %esi, 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