// File: /workspace/github_cpp_makefile_star2_O2/qmmlib[P]QmmLibrary/transform_line.cpp
// Function: transform_line
void transform_line(double * read_line, int y, int max_idx, char * line, char structured_w, double ** tmx, int tmx_r, int tmx_c)
{
	int curr_idx=1;
	int print_idx=1;
	double curr_val;
	
	stringstream ss (stringstream::in | stringstream::out);

	ss<<y<<" ";
	
	while(1)
	{
		if(structured_w=='s' || structured_w=='a')
		{
			curr_val = read_line[curr_idx] + (read_line[max_idx+1-curr_idx] * (structured_w=='s'?1:(structured_w=='a'?-1:0)));
			
			if(curr_val!=0)
				ss<< print_idx<<":"<<curr_val<<" ";
			
			curr_idx++;
			print_idx++;
			
			if(max_idx%2==0 && curr_idx>((double)max_idx)/2.0f)
				break;
			else if(max_idx%2!=0 && curr_idx>((double)max_idx)/2.0f)
			{
				curr_val = read_line[curr_idx];
				if(curr_val!=0)
					ss<< print_idx<<":"<<curr_val<<" ";
				break;
			}
		}			
		else if(structured_w=='f')
		{
			if(max_idx!=tmx_c)
			{
				printf("\nmax_idx: %d ncols: %d nrows: %d\n",max_idx,tmx_c,tmx_r);
				exit(1);
			}
			
			for(int j = 0; j < tmx_r; j++)
			{
				curr_val = 0;
				for(int i = 0; i<tmx_c; i++)
					curr_val = curr_val + (tmx[j][i] * read_line[i+1]);
				if(curr_val!=0)
					ss<<j+1<<":"<<curr_val<<" ";
			}
			
			break;
		}
	}
	
	strcpy(line, ss.str().c_str());
	// printf("%s\n",line);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %r9, %r13
movl %r8d, %ebx
movq %rcx, 0x18(%rsp)
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %r12
leaq 0x40(%rsp), %rdi
pushq $0x18
popq %rsi
callq 0x3170
leaq 0x50(%rsp), %rdi
movl %ebp, %esi
callq 0x3420
leaq 0x285d(%rip), %rsi      # 0x16673
movq %rax, %rdi
callq 0x3210
cmpb $0x61, %bl
je 0x13e29
xorpd %xmm0, %xmm0
jmp 0x13e31
movsd 0x246f(%rip), %xmm0     # 0x162a0
movsd %xmm0, 0x8(%rsp)
cmpb $0x73, %bl
jne 0x13e4a
movsd 0x2454(%rip), %xmm0     # 0x16298
movsd %xmm0, 0x8(%rsp)
cmpb $0x66, %bl
jne 0x13f08
movl 0x208(%rsp), %edx
movl 0x200(%rsp), %ebp
cmpl %edx, %r14d
jne 0x1404d
xorl %ebx, %ebx
testl %r14d, %r14d
cmovlel %ebx, %r14d
testl %ebp, %ebp
cmovlel %ebx, %ebp
leaq 0x27f4(%rip), %r15      # 0x16673
cmpq %rbp, %rbx
je 0x14008
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
xorl %eax, %eax
cmpq %rax, %r14
je 0x13ebc
movq (%r13,%rbx,8), %rcx
movsd (%rcx,%rax,8), %xmm0
mulsd 0x8(%r12,%rax,8), %xmm0
incq %rax
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
jmp 0x13e93
incq %rbx
movsd (%rsp), %xmm0
ucomisd 0x1174(%rip), %xmm0     # 0x15040
jne 0x13ed0
jnp 0x13e7f
leaq 0x50(%rsp), %rdi
movl %ebx, %esi
callq 0x3420
movq %rax, %rdi
leaq 0x13ed(%rip), %rsi      # 0x152d3
callq 0x3210
movq %rax, %rdi
movsd (%rsp), %xmm0
callq 0x33f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x3210
jmp 0x13e7f
cvtsi2sd %r14d, %xmm0
leal 0x1(%r14), %r15d
mulsd 0x21e7(%rip), %xmm0     # 0x16100
movsd %xmm0, 0x10(%rsp)
pushq $0x1
popq %rbp
movsbl %bl, %ebx
leaq 0x2747(%rip), %r13      # 0x16673
cmpl $0x73, %ebx
je 0x13f36
cmpl $0x61, %ebx
jne 0x13f2c
movl %ebp, %eax
movl %r15d, %ecx
subl %ebp, %ecx
movslq %ecx, %rcx
movsd (%r12,%rcx,8), %xmm0
mulsd 0x8(%rsp), %xmm0
addsd (%r12,%rax,8), %xmm0
movsd %xmm0, (%rsp)
ucomisd 0x10e1(%rip), %xmm0     # 0x15040
jne 0x13f63
jnp 0x13f96
leaq 0x50(%rsp), %rdi
movl %ebp, %esi
callq 0x3420
movq %rax, %rdi
leaq 0x135a(%rip), %rsi      # 0x152d3
callq 0x3210
movq %rax, %rdi
movsd (%rsp), %xmm0
callq 0x33f0
movq %rax, %rdi
movq %r13, %rsi
callq 0x3210
incl %ebp
cvtsi2sd %ebp, %xmm0
testb $0x1, %r14b
jne 0x13fac
ucomisd 0x10(%rsp), %xmm0
jbe 0x13f2c
jmp 0x14008
ucomisd 0x10(%rsp), %xmm0
jbe 0x13f2c
movl %ebp, %eax
movsd (%r12,%rax,8), %xmm1
xorpd %xmm0, %xmm0
movsd %xmm1, (%rsp)
ucomisd %xmm0, %xmm1
jne 0x13fd1
jnp 0x14008
leaq 0x50(%rsp), %rdi
movl %ebp, %esi
callq 0x3420
leaq 0x12ef(%rip), %rsi      # 0x152d3
movq %rax, %rdi
callq 0x3210
movq %rax, %rdi
movsd (%rsp), %xmm0
callq 0x33f0
leaq 0x2673(%rip), %rsi      # 0x16673
movq %rax, %rdi
callq 0x3210
leaq 0x58(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x33e0
leaq 0x20(%rsp), %rbx
movq (%rbx), %rsi
movq 0x18(%rsp), %rdi
callq 0x3200
movq %rbx, %rdi
callq 0x3100
leaq 0x40(%rsp), %rdi
callq 0x3160
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x298c(%rip), %rdi      # 0x169e0
movl %r14d, %esi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x3050
pushq $0x1
popq %rdi
callq 0x32c0
jmp 0x1406e
jmp 0x1406e
jmp 0x1406e
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3160
movq %rbx, %rdi
callq 0x3430
nop