// File: /workspace/github_cpp_makefile_star2_O2/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)
movq %rdi, %r15
movslq (%rdi), %r13
movslq 0x4(%rdi), %rbx
pushq $-0x1
popq %rbp
cmpq %rbp, %rbx
leaq 0x8(,%rbx,8), %rdi
cmovlq %rbp, %rdi
callq 0x2030
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 0x2030
movq %rax, %r13
leaq (,%rbx,8), %rdi
testq %rbx, %rbx
movq %rax, 0x8(%r12)
cmovsq %rbp, %rdi
callq 0x2030
movq %rax, 0x10(%r12)
xorl %eax, %eax
movq 0x8(%rsp), %rcx
testl %ecx, %ecx
movl $0x0, %ebp
cmovgl %ecx, %ebp
cmpq %rax, %rbp
je 0xab44
movq 0x8(%r15), %rcx
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%r13,%rax,8)
incq %rax
jmp 0xab2a
xorl %eax, %eax
cmpq %rbx, %rax
jg 0xab55
andq $0x0, (%r14,%rax,8)
incq %rax
jmp 0xab46
xorl %ecx, %ecx
xorl %eax, %eax
cmpq %rbp, %rcx
je 0xab81
movq 0x10(%r15), %rdx
movq (%rdx,%rcx,8), %rdx
movslq (%rdx), %rsi
cmpq $-0x1, %rsi
je 0xab7c
incq %rax
incq (%r14,%rsi,8)
addq $0x10, %rdx
jmp 0xab66
incq %rcx
jmp 0xab59
xorl %ecx, %ecx
testl %ebx, %ebx
movl $0x0, %r13d
cmovgl %ebx, %r13d
cmpq %rcx, %r13
je 0xabad
movq (%r14,%rcx,8), %rdx
movq 0x8(%r14,%rcx,8), %rsi
addq %rsi, %rdx
incq %rdx
movq %rdx, 0x8(%r14,%rcx,8)
incq %rcx
jmp 0xab8f
addq %rbx, %rax
movq %rax, %rcx
shrq $0x3c, %rcx
shlq $0x4, %rax
xorl %ebx, %ebx
negq %rcx
movl $0x0, %edi
sbbq %rdi, %rdi
orq %rax, %rdi
callq 0x2030
cmpq %rbx, %r13
je 0xabee
movq (%r14,%rbx,8), %rcx
shlq $0x4, %rcx
addq %rax, %rcx
movq 0x10(%r12), %rdx
movq %rcx, (%rdx,%rbx,8)
incq %rbx
jmp 0xabd0
xorl %ecx, %ecx
cmpq %rbp, %rcx
je 0xac33
movq 0x10(%r15), %rdx
movq (%rdx,%rcx,8), %rdx
incq %rcx
movslq (%rdx), %rsi
cmpq $-0x1, %rsi
je 0xabf0
movq -0x8(%r14,%rsi,8), %rdi
movq %rdi, %r8
shlq $0x4, %r8
movl %ecx, (%rax,%r8)
movsd 0x8(%rdx), %xmm0
movsd %xmm0, 0x8(%rax,%r8)
incq %rdi
movq %rdi, -0x8(%r14,%rsi,8)
addq $0x10, %rdx
jmp 0xac00
xorl %ecx, %ecx
cmpq %rcx, %r13
je 0xac4b
movq (%r14,%rcx,8), %rdx
shlq $0x4, %rdx
orl $-0x1, (%rax,%rdx)
incq %rcx
jmp 0xac35
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