// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rax
movq %rdx, %r12
movq %rsi, (%rsp)
movq %rdi, %r15
movslq (%rdi), %rbp
movslq 0x4(%rdi), %rbx
movq $-0x1, %rax
cmpq %rax, %rbx
leaq 0x4(,%rbx,4), %rdi
cmovlq %rax, %rdi
movq $-0x1, %r13
callq 0x3030
movq %rax, %r14
leaq (,%rbp,8), %rdi
testq %rbp, %rbp
movl %ebp, (%r12)
movl %ebx, 0x4(%r12)
cmovsq %r13, %rdi
callq 0x3030
movq %rax, %r13
leaq (,%rbx,8), %rdi
testq %rbx, %rbx
movq %rax, 0x8(%r12)
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x3030
movl %ebx, %ebx
movq %rax, 0x10(%r12)
testq %rbp, %rbp
jle 0x12514
movq 0x8(%r15), %rax
xorl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%r13,%rcx,8)
incq %rcx
cmpq %rcx, %rbp
jne 0x12500
testl %ebx, %ebx
js 0x1252a
leaq 0x4(,%rbx,4), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x3110
testl %ebp, %ebp
jle 0x12563
movq 0x10(%r15), %rcx
xorl %edx, %edx
xorl %eax, %eax
movq (%rcx,%rdx,8), %rsi
movl (%rsi), %edi
cmpl $-0x1, %edi
je 0x12559
addq $0x10, %rsi
movslq %edi, %rdi
incl (%r14,%rdi,4)
incl %eax
movl (%rsi), %edi
addq $0x10, %rsi
cmpl $-0x1, %edi
jne 0x12545
incq %rdx
cmpq %rbp, %rdx
jne 0x12536
jmp 0x12565
xorl %eax, %eax
testl %ebx, %ebx
jle 0x12589
leaq 0x1(%rbx), %rcx
movl (%r14), %edx
movl $0x1, %esi
movl (%r14,%rsi,4), %edi
addl %edi, %edx
incl %edx
movl %edx, (%r14,%rsi,4)
incq %rsi
cmpq %rsi, %rcx
jne 0x12575
addl %ebx, %eax
cltq
movq %rax, %rcx
shlq $0x4, %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x3030
testl %ebx, %ebx
jle 0x125c8
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, %rbx
jne 0x125ac
testl %ebp, %ebp
jle 0x12620
movq 0x10(%r15), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movl (%rsi), %r8d
cmpl $-0x1, %r8d
je 0x12618
leal 0x1(%rdx), %edi
addq $0x10, %rsi
movslq %r8d, %r8
movslq -0x4(%r14,%r8,4), %r9
leal 0x1(%r9), %r10d
shlq $0x4, %r9
movl %edi, (%rax,%r9)
movsd -0x8(%rsi), %xmm0
movsd %xmm0, 0x8(%rax,%r9)
movl %r10d, -0x4(%r14,%r8,4)
movl (%rsi), %r8d
addq $0x10, %rsi
cmpl $-0x1, %r8d
jne 0x125e6
incq %rdx
cmpq %rbp, %rdx
jne 0x125d2
testl %ebx, %ebx
jle 0x1263d
xorl %ecx, %ecx
movslq (%r14,%rcx,4), %rdx
shlq $0x4, %rdx
movl $0xffffffff, (%rax,%rdx) # imm = 0xFFFFFFFF
incq %rcx
cmpq %rcx, %rbx
jne 0x12626
movq (%rsp), %rcx
movq %rax, (%rcx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x32c0