// File: /workspace/github_cpp_makefile_star2_O2/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), %r13
movslq 0x4(%rdi), %rbx
pushq $-0x1
popq %rbp
cmpq %rbp, %rbx
leaq 0x4(,%rbx,4), %rdi
cmovlq %rbp, %rdi
callq 0x3030
movq %rax, %r14
movq %r13, 0x8(%rsp)
leaq (,%r13,8), %rdi
testq %r13, %r13
movl %r13d, (%r12)
movl %ebx, 0x4(%r12)
cmovsq %rbp, %rdi
callq 0x3030
movq %rax, %r13
leaq (,%rbx,8), %rdi
testq %rbx, %rbx
movq %rax, 0x8(%r12)
cmovsq %rbp, %rdi
callq 0x3030
movq %rax, 0x10(%r12)
xorl %eax, %eax
movq 0x8(%rsp), %rcx
testl %ecx, %ecx
movl $0x0, %ebp
cmovgl %ecx, %ebp
cmpq %rax, %rbp
je 0x11378
movq 0x8(%r15), %rcx
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%r13,%rax,8)
incq %rax
jmp 0x1135e
xorl %eax, %eax
cmpq %rbx, %rax
jg 0x11389
andl $0x0, (%r14,%rax,4)
incq %rax
jmp 0x1137a
xorl %ecx, %ecx
xorl %eax, %eax
cmpq %rbp, %rcx
je 0x113b4
movq 0x10(%r15), %rdx
movq (%rdx,%rcx,8), %rdx
movslq (%rdx), %rsi
cmpq $-0x1, %rsi
je 0x113af
incl %eax
incl (%r14,%rsi,4)
addq $0x10, %rdx
jmp 0x1139a
incq %rcx
jmp 0x1138d
xorl %ecx, %ecx
testl %ebx, %ebx
movl $0x0, %r13d
cmovgl %ebx, %r13d
cmpq %rcx, %r13
je 0x113de
movl (%r14,%rcx,4), %edx
movl 0x4(%r14,%rcx,4), %esi
addl %esi, %edx
incl %edx
movl %edx, 0x4(%r14,%rcx,4)
incq %rcx
jmp 0x113c2
addl %ebx, %eax
cltq
movq %rax, %rdi
shlq $0x4, %rdi
testl %eax, %eax
pushq $-0x1
popq %rax
cmovsq %rax, %rdi
callq 0x3030
xorl %ecx, %ecx
cmpq %rcx, %r13
je 0x11417
movslq (%r14,%rcx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movq 0x10(%r12), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
jmp 0x113f9
xorl %ecx, %ecx
cmpq %rbp, %rcx
je 0x11458
movq 0x10(%r15), %rdx
movq (%rdx,%rcx,8), %rdx
incq %rcx
movslq (%rdx), %rsi
cmpq $-0x1, %rsi
je 0x11419
movslq -0x4(%r14,%rsi,4), %rdi
leal 0x1(%rdi), %r8d
shlq $0x4, %rdi
movl %ecx, (%rax,%rdi)
movsd 0x8(%rdx), %xmm0
movsd %xmm0, 0x8(%rax,%rdi)
movl %r8d, -0x4(%r14,%rsi,4)
addq $0x10, %rdx
jmp 0x11429
xorl %ecx, %ecx
cmpq %rcx, %r13
je 0x11470
movslq (%r14,%rcx,4), %rdx
shlq $0x4, %rdx
orl $-0x1, (%rax,%rdx)
incq %rcx
jmp 0x1145a
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 0x32f0