// File: /workspace/github_cpp_makefile_star2_O3/qmmlib[P]QmmLibrary/linear.cpp
// Function: transpose(problem const*, feature_node**, problem*)
static void transpose(const problem *prob, feature_node **x_space_ret, problem *prob_col)
{
	int i;
	int l = prob->l;
	int n = prob->n;
	int nnz = 0;
	int *col_ptr = new int[n+1];
	feature_node *x_space;
	prob_col->l = l;
	prob_col->n = n;
	prob_col->y = new double[l];
	prob_col->x = new feature_node*[n];

	for(i=0; i<l; i++)
		prob_col->y[i] = prob->y[i];

	for(i=0; i<n+1; i++)
		col_ptr[i] = 0;
	for(i=0; i<l; i++)
	{
		feature_node *x = prob->x[i];
		while(x->index != -1)
		{
			nnz++;
			col_ptr[x->index]++;
			x++;
		}
	}
	for(i=1; i<n+1; i++)
		col_ptr[i] += col_ptr[i-1] + 1;

	x_space = new feature_node[nnz+n];
	for(i=0; i<n; i++)
		prob_col->x[i] = &x_space[col_ptr[i]];

	for(i=0; i<l; i++)
	{
		feature_node *x = prob->x[i];
		while(x->index != -1)
		{
			int ind = x->index-1;
			x_space[col_ptr[ind]].index = i+1; // starts from 1
			x_space[col_ptr[ind]].value = x->value;
			col_ptr[ind]++;
			x++;
		}
	}
	for(i=0; i<n; i++)
		x_space[col_ptr[i]].index = -1;

	*x_space_ret = x_space;

	delete [] col_ptr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
movslq (%rdi), %rbx
movslq 0x4(%rdi), %rbp
leal 0x1(%rbp), %eax
movl %eax, 0xc(%rsp)
movslq %eax, %rdi
shlq $0x2, %rdi
movq $-0x1, %rax
cmpq %rax, %rbp
cmovlq %rax, %rdi
movq $-0x1, %r13
callq 0x3030
movq %rax, %r14
leaq (,%rbx,8), %rdi
testq %rbx, %rbx
movl %ebx, (%r12)
movl %ebp, 0x4(%r12)
cmovsq %r13, %rdi
callq 0x3030
movq %rax, %r13
leaq (,%rbp,8), %rdi
testq %rbp, %rbp
movq %rax, 0x8(%r12)
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x3030
movq %rax, 0x10(%r12)
testq %rbx, %rbx
jle 0x13ff5
movq 0x8(%r15), %rax
xorl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%r13,%rcx,8)
incq %rcx
cmpq %rcx, %rbx
jne 0x13fe1
movl 0xc(%rsp), %r13d
testl %ebp, %ebp
js 0x14010
leaq (,%r13,4), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x3110
testl %ebx, %ebx
jle 0x14049
movq 0x10(%r15), %rcx
xorl %edx, %edx
xorl %eax, %eax
movq (%rcx,%rdx,8), %rsi
movl (%rsi), %edi
cmpl $-0x1, %edi
je 0x1403f
addq $0x10, %rsi
movslq %edi, %rdi
incl (%r14,%rdi,4)
incl %eax
movl (%rsi), %edi
addq $0x10, %rsi
cmpl $-0x1, %edi
jne 0x1402b
incq %rdx
cmpq %rbx, %rdx
jne 0x1401c
jmp 0x1404b
xorl %eax, %eax
testl %ebp, %ebp
jle 0x1406b
movl (%r14), %ecx
movl $0x1, %edx
movl (%r14,%rdx,4), %esi
addl %esi, %ecx
incl %ecx
movl %ecx, (%r14,%rdx,4)
incq %rdx
cmpq %rdx, %r13
jne 0x14057
addl %ebp, %eax
cltq
movq %rax, %rcx
shlq $0x4, %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x3030
testl %ebp, %ebp
jle 0x140aa
xorl %ecx, %ecx
movslq (%r14,%rcx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movq 0x10(%r12), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %rbp
jne 0x1408e
testl %ebx, %ebx
jle 0x140fb
movq 0x10(%r15), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movl (%rsi), %edi
incq %rdx
cmpl $-0x1, %edi
je 0x140f6
addq $0x10, %rsi
movslq %edi, %rdi
movslq -0x4(%r14,%rdi,4), %r8
leal 0x1(%r8), %r9d
shlq $0x4, %r8
movl %edx, (%rax,%r8)
movsd -0x8(%rsi), %xmm0
movsd %xmm0, 0x8(%rax,%r8)
movl %r9d, -0x4(%r14,%rdi,4)
movl (%rsi), %edi
addq $0x10, %rsi
cmpl $-0x1, %edi
jne 0x140c6
cmpq %rbx, %rdx
jne 0x140b4
testl %ebp, %ebp
jle 0x14118
xorl %ecx, %ecx
movslq (%r14,%rcx,4), %rdx
shlq $0x4, %rdx
movl $0xffffffff, (%rax,%rdx) # imm = 0xFFFFFFFF
incq %rcx
cmpq %rcx, %rbp
jne 0x14101
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x32d0