// File: 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
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movb %r8b, %al
movl 0x18(%rbp), %r8d
movl 0x10(%rbp), %r8d
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movq %r9, -0x28(%rbp)
movl $0x1, -0x2c(%rbp)
movl $0x1, -0x30(%rbp)
movl $0x8, %edi
movl $0x10, %esi
callq 0x21fc0
movl %eax, %esi
leaq -0x1c0(%rbp), %rdi
callq 0x31d0
leaq -0x1b0(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x34a0
movq %rax, -0x200(%rbp)
jmp 0x219de
movq -0x200(%rbp), %rdi
leaq 0x3bc7(%rip), %rsi      # 0x255b3
callq 0x32a0
jmp 0x219f3
jmp 0x219f5
jmp 0x219f7
movsbl -0x19(%rbp), %eax
cmpl $0x73, %eax
je 0x21a0d
movsbl -0x19(%rbp), %eax
cmpl $0x61, %eax
jne 0x21c3c
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x210(%rbp)
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
subl -0x2c(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x208(%rbp)
movsbl -0x19(%rbp), %eax
cmpl $0x73, %eax
jne 0x21a55
movl $0x1, %eax
movl %eax, -0x214(%rbp)
jmp 0x21a6c
movsbl -0x19(%rbp), %edx
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x61, %edx
cmovel %ecx, %eax
movl %eax, -0x214(%rbp)
movsd -0x210(%rbp), %xmm1
movsd -0x208(%rbp), %xmm0
movl -0x214(%rbp), %eax
cvtsi2sd %eax, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x21aa8
jp 0x21aa8
jmp 0x21b30
leaq -0x1b0(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x34a0
movq %rax, -0x220(%rbp)
jmp 0x21ac0
movq -0x220(%rbp), %rdi
leaq 0x355b(%rip), %rsi      # 0x25029
callq 0x32a0
movq %rax, -0x228(%rbp)
jmp 0x21adc
movq -0x228(%rbp), %rdi
movsd -0x38(%rbp), %xmm0
callq 0x3520
movq %rax, -0x230(%rbp)
jmp 0x21af6
movq -0x230(%rbp), %rdi
leaq 0x3aaf(%rip), %rsi      # 0x255b3
callq 0x32a0
jmp 0x21b0b
jmp 0x21b30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x31c0
jmp 0x21df4
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x10(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x21b73
cvtsi2sdl -0x2c(%rbp), %xmm0
cvtsi2sdl -0x10(%rbp), %xmm1
movsd 0x3724(%rip), %xmm2     # 0x25288
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x21b73
jmp 0x21d98
movl -0x10(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x21c35
cvtsi2sdl -0x2c(%rbp), %xmm0
cvtsi2sdl -0x10(%rbp), %xmm1
movsd 0x36ef(%rip), %xmm2     # 0x25288
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x21c35
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x21bcb
jp 0x21bcb
jmp 0x21c30
leaq -0x1b0(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x34a0
movq %rax, -0x238(%rbp)
jmp 0x21be3
movq -0x238(%rbp), %rdi
leaq 0x3438(%rip), %rsi      # 0x25029
callq 0x32a0
movq %rax, -0x240(%rbp)
jmp 0x21bff
movq -0x240(%rbp), %rdi
movsd -0x38(%rbp), %xmm0
callq 0x3520
movq %rax, -0x248(%rbp)
jmp 0x21c19
movq -0x248(%rbp), %rdi
leaq 0x398c(%rip), %rsi      # 0x255b3
callq 0x32a0
jmp 0x21c2e
jmp 0x21c30
jmp 0x21d98
jmp 0x21c37
jmp 0x21d93
movsbl -0x19(%rbp), %eax
cmpl $0x66, %eax
jne 0x21d91
movl -0x10(%rbp), %eax
cmpl 0x18(%rbp), %eax
je 0x21c74
movl -0x10(%rbp), %esi
movl 0x18(%rbp), %edx
movl 0x10(%rbp), %ecx
leaq 0x3cc4(%rip), %rdi      # 0x25925
xorl %eax, %eax
callq 0x3050
jmp 0x21c6a
movl $0x1, %edi
callq 0x3380
movl $0x0, -0x1d0(%rbp)
movl -0x1d0(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0x21d8f
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x1d4(%rbp)
movl -0x1d4(%rbp), %eax
cmpl 0x18(%rbp), %eax
jge 0x21cfd
movsd -0x38(%rbp), %xmm1
movq -0x28(%rbp), %rax
movslq -0x1d0(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1d4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movl -0x1d4(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x1d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d4(%rbp)
jmp 0x21c9f
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x21d0f
jp 0x21d0f
jmp 0x21d79
leaq -0x1b0(%rbp), %rdi
movl -0x1d0(%rbp), %esi
incl %esi
callq 0x34a0
movq %rax, -0x250(%rbp)
jmp 0x21d2c
movq -0x250(%rbp), %rdi
leaq 0x32ef(%rip), %rsi      # 0x25029
callq 0x32a0
movq %rax, -0x258(%rbp)
jmp 0x21d48
movq -0x258(%rbp), %rdi
movsd -0x38(%rbp), %xmm0
callq 0x3520
movq %rax, -0x260(%rbp)
jmp 0x21d62
movq -0x260(%rbp), %rdi
leaq 0x3843(%rip), %rsi      # 0x255b3
callq 0x32a0
jmp 0x21d77
jmp 0x21d79
jmp 0x21d7b
movl -0x1d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d0(%rbp)
jmp 0x21c7e
jmp 0x21d98
jmp 0x21d93
jmp 0x219f5
movq -0x18(%rbp), %rax
movq %rax, -0x268(%rbp)
leaq -0x1f8(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3290
jmp 0x21db8
leaq -0x1f8(%rbp), %rdi
callq 0x3100
movq -0x268(%rbp), %rdi
movq %rax, %rsi
callq 0x3280
leaq -0x1f8(%rbp), %rdi
callq 0x3170
leaq -0x1c0(%rbp), %rdi
callq 0x31c0
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
movq -0x1c8(%rbp), %rdi
callq 0x34b0