// File: /workspace/github_cpp_makefile_star2_O3/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), %rbx
movslq 0x4(%rdi), %rbp
leal 0x1(%rbp), %eax
movl %eax, 0xc(%rsp)
movslq %eax, %rdi
shlq $0x3, %rdi
movq $-0x1, %rax
cmpq %rax, %rbp
cmovlq %rax, %rdi
movq $-0x1, %r13
callq 0x2030
movq %rax, %r14
leaq (,%rbx,8), %rdi
testq %rbx, %rbx
movl %ebx, (%r12)
movl %ebp, 0x4(%r12)
cmovsq %r13, %rdi
callq 0x2030
movq %rax, %r13
leaq (,%rbp,8), %rdi
testq %rbp, %rbp
movq %rax, 0x8(%r12)
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x2030
movq %rax, 0x10(%r12)
testq %rbx, %rbx
jle 0xc54d
movq 0x8(%r15), %rax
xorl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%r13,%rcx,8)
incq %rcx
cmpq %rcx, %rbx
jne 0xc539
movl 0xc(%rsp), %r13d
testl %ebp, %ebp
js 0xc568
leaq (,%r13,8), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20c0
testl %ebx, %ebx
jle 0xc5a2
movq 0x10(%r15), %rcx
xorl %edx, %edx
xorl %eax, %eax
movq (%rcx,%rdx,8), %rsi
movl (%rsi), %edi
cmpl $-0x1, %edi
je 0xc598
addq $0x10, %rsi
movslq %edi, %rdi
incq (%r14,%rdi,8)
incq %rax
movl (%rsi), %edi
addq $0x10, %rsi
cmpl $-0x1, %edi
jne 0xc583
incq %rdx
cmpq %rbx, %rdx
jne 0xc574
jmp 0xc5a4
xorl %eax, %eax
testl %ebp, %ebp
jle 0xc5c6
movq (%r14), %rcx
movl $0x1, %edx
movq (%r14,%rdx,8), %rsi
addq %rsi, %rcx
incq %rcx
movq %rcx, (%r14,%rdx,8)
incq %rdx
cmpq %rdx, %r13
jne 0xc5b0
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 %ebp, %ebp
jle 0xc606
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, %rbp
jne 0xc5ea
testl %ebx, %ebx
jle 0xc659
movq 0x10(%r15), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movl (%rsi), %edi
incq %rdx
cmpl $-0x1, %edi
je 0xc654
addq $0x10, %rsi
movslq %edi, %rdi
movq -0x8(%r14,%rdi,8), %r8
movq %r8, %r9
shlq $0x4, %r9
movl %edx, (%rax,%r9)
movsd -0x8(%rsi), %xmm0
movsd %xmm0, 0x8(%rax,%r9)
incq %r8
movq %r8, -0x8(%r14,%rdi,8)
movl (%rsi), %edi
addq $0x10, %rsi
cmpl $-0x1, %edi
jne 0xc622
cmpq %rbx, %rdx
jne 0xc610
testl %ebp, %ebp
jle 0xc676
xorl %ecx, %ecx
movq (%r14,%rcx,8), %rdx
shlq $0x4, %rdx
movl $0xffffffff, (%rax,%rdx) # imm = 0xFFFFFFFF
incq %rcx
cmpq %rcx, %rbp
jne 0xc65f
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