// File: /workspace/github_cpp_makefile_star2_O1/cjlin1[P]liblinear/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;
	size_t nnz = 0;
	size_t *col_ptr = new size_t [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)
movslq (%rdi), %rbx
movq %rdi, 0x8(%rsp)
movslq 0x4(%rdi), %rbp
movq $-0x1, %r15
cmpq %r15, %rbp
leaq 0x8(,%rbp,8), %rdi
cmovlq %r15, %rdi
callq 0x2030
movq %rax, %r14
leaq (,%rbx,8), %rdi
testq %rbx, %rbx
movl %ebx, (%r12)
movl %ebp, 0x4(%r12)
cmovsq %r15, %rdi
callq 0x2030
movq %rax, %r13
leaq (,%rbp,8), %rdi
testq %rbp, %rbp
movq %rax, 0x8(%r12)
cmovsq %r15, %rdi
callq 0x2030
movl %ebp, %r15d
movq %rax, 0x10(%r12)
testq %rbx, %rbx
jle 0xba19
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
xorl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%r13,%rcx,8)
incq %rcx
cmpq %rcx, %rbx
jne 0xba05
testl %ebp, %ebp
js 0xba2f
leaq 0x8(,%r15,8), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20c0
testl %ebx, %ebx
jle 0xba6e
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
xorl %edx, %edx
xorl %eax, %eax
movq (%rcx,%rdx,8), %rsi
movl (%rsi), %edi
cmpl $-0x1, %edi
je 0xba64
addq $0x10, %rsi
movslq %edi, %rdi
incq (%r14,%rdi,8)
incq %rax
movl (%rsi), %edi
addq $0x10, %rsi
cmpl $-0x1, %edi
jne 0xba4f
incq %rdx
cmpq %rbx, %rdx
jne 0xba40
jmp 0xba70
xorl %eax, %eax
testl %r15d, %r15d
jle 0xba97
leaq 0x1(%r15), %rcx
movq (%r14), %rdx
movl $0x1, %esi
movq (%r14,%rsi,8), %rdi
addq %rdi, %rdx
incq %rdx
movq %rdx, (%r14,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0xba81
addq %rbp, %rax
movq %rax, %rcx
shrq $0x3c, %rcx
shlq $0x4, %rax
xorl %edi, %edi
negq %rcx
sbbq %rdi, %rdi
orq %rax, %rdi
callq 0x2030
testl %r15d, %r15d
jle 0xbad8
xorl %ecx, %ecx
movq (%r14,%rcx,8), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movq 0x10(%r12), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0xbabc
testl %ebx, %ebx
jle 0xbb37
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movl (%rsi), %r8d
cmpl $-0x1, %r8d
je 0xbb2f
leal 0x1(%rdx), %edi
addq $0x10, %rsi
movslq %r8d, %r8
movq -0x8(%r14,%r8,8), %r9
movq %r9, %r10
shlq $0x4, %r10
movl %edi, (%rax,%r10)
movsd -0x8(%rsi), %xmm0
movsd %xmm0, 0x8(%rax,%r10)
incq %r9
movq %r9, -0x8(%r14,%r8,8)
movl (%rsi), %r8d
addq $0x10, %rsi
cmpl $-0x1, %r8d
jne 0xbafb
incq %rdx
cmpq %rbx, %rdx
jne 0xbae7
testl %r15d, %r15d
jle 0xbb55
xorl %ecx, %ecx
movq (%r14,%rcx,8), %rdx
shlq $0x4, %rdx
movl $0xffffffff, (%rax,%rdx) # imm = 0xFFFFFFFF
incq %rcx
cmpq %rcx, %rbp
jne 0xbb3e
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 0x21e0