// File: intheswim[P]FractalTubes/m3d.cpp
// Function: M3DDrawer::GetPixelCoordinates(double, double, double, long double, long double, long double, double, double&, double&, double&, double&, double&, double&)
void M3DDrawer::GetPixelCoordinates (double y1, double r, double l, long double alpha, long double beta,
                                     long double coef, double slope,
                                     double & x_real, double & y_real, double & z_real,
                                     double & x_norm, double & y_norm, double & z_norm)
{
	double temp_x ;
    
	x_real = r * cos (alpha);
	y_real = y1 ;
	z_real = r * sin (alpha);
    
	// initial values (assuming l=1)
	// x_norm = cos (coef*alp);
	// y_norm = sin (coef*alp);
    
    x_norm = cos (beta);
    y_norm = sin (beta);
    
	z_norm = 0;
    
	// first, slope (around x=0)
	z_norm = -y_norm * sin (slope);
	y_norm = y_norm * cos (slope); // ignoring z it's 0 anyway
    
	// turn by alpha (around y=0)
    
	temp_x = x_norm;
	x_norm = x_norm * cos(alpha) - z_norm * sin (alpha);
	//y_norm = y_norm;
	z_norm = temp_x * sin (alpha) + z_norm * cos (alpha);
    
	// add to centerpoints
	x_real += x_norm * l;
	y_real += y_norm * l;
	z_real += z_norm * l;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq 0x40(%rbp), %rax
fldt 0x30(%rbp)
fldt 0x20(%rbp)
fldt 0x10(%rbp)
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm2, -0x20(%rbp)
fstpt -0x30(%rbp)
fstpt -0x40(%rbp)
fstpt -0x50(%rbp)
movsd %xmm3, -0x58(%rbp)
movq %rsi, -0x60(%rbp)
movq %rdx, -0x68(%rbp)
movq %rcx, -0x70(%rbp)
movq %r8, -0x78(%rbp)
movq %r9, -0x80(%rbp)
fldl -0x18(%rbp)
fstpt -0x100(%rbp)
fldt -0x30(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0xb1e0
fldt -0x100(%rbp)
fmulp %st, %st(1)
movq -0x60(%rbp), %rax
fstpl (%rax)
movsd -0x10(%rbp), %xmm0
movq -0x68(%rbp), %rax
movsd %xmm0, (%rax)
fldl -0x18(%rbp)
fstpt -0xf4(%rbp)
fldt -0x30(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0xb210
fldt -0xf4(%rbp)
fmulp %st, %st(1)
movq -0x70(%rbp), %rax
fstpl (%rax)
fldt -0x40(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0xb1e0
movq -0x78(%rbp), %rax
fstpl (%rax)
fldt -0x40(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0xb210
movq -0x80(%rbp), %rax
fstpl (%rax)
movq 0x40(%rbp), %rax
movq $0x0, (%rax)
movq -0x80(%rbp), %rax
movsd (%rax), %xmm0
movaps 0x3a1e(%rip), %xmm1     # 0xe4e0
pxor %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0x58(%rbp), %xmm0
callq 0x3090
movaps %xmm0, %xmm1
movsd -0xe8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x80(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0x58(%rbp), %xmm0
callq 0x3710
movaps %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movq -0x80(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x78(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x78(%rbp), %rax
fldl (%rax)
fstpt -0xc0(%rbp)
fldt -0x30(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0xb1e0
fstpt -0xcc(%rbp)
movq 0x40(%rbp), %rax
fldl (%rax)
fstpt -0xd8(%rbp)
fldt -0x30(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0xb210
fldt -0xd8(%rbp)
fldt -0xcc(%rbp)
fldt -0xc0(%rbp)
fxch %st(2)
fmulp %st, %st(3)
fmulp %st, %st(1)
fsubp %st, %st(1)
movq -0x78(%rbp), %rax
fstpl (%rax)
fldl -0x88(%rbp)
fstpt -0x9c(%rbp)
fldt -0x30(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0xb210
fstpt -0xa8(%rbp)
movq 0x40(%rbp), %rax
fldl (%rax)
fstpt -0xb4(%rbp)
fldt -0x30(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0xb1e0
fldt -0xb4(%rbp)
fldt -0xa8(%rbp)
fldt -0x9c(%rbp)
fxch %st(2)
fmulp %st, %st(3)
fmulp %st, %st(1)
faddp %st, %st(1)
fstpl -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
movq 0x40(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x78(%rbp), %rax
movsd (%rax), %xmm0
movsd -0x20(%rbp), %xmm2
movq -0x60(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq -0x80(%rbp), %rax
movsd (%rax), %xmm0
movsd -0x20(%rbp), %xmm2
movq -0x68(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq 0x40(%rbp), %rax
movsd (%rax), %xmm0
movsd -0x20(%rbp), %xmm2
movq -0x70(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopl (%rax)