// File: /workspace/github_c_makefile_star2_O0/Alessandro-Barbieri[P]SpaceLib/src/SPACELI4.c
// Function: intersection
void intersection(LINE l1, LINE l2, LINEP lmindist, real * mindist, PLANE pl,
		  POINT I, int *inttype)
{
	VECTOR deltap,v1,v2,u3;
	POINT A,B;
	real a,c1,c2,alpha,beta,zero;

	zero = zerom();          /* machine zero */
	vect(l2.P,l1.P,deltap);  /* deltap=(P2-P1) */
	cross(l1.dir,l2.dir,u3); /* u3 is orthogonal to l1 and l2 */

				 /* l1 and l2 are not parallel */
	if (aabs(u3[X]) > zero || aabs(u3[Y]) > zero || aabs(u3[Z]) > zero)
	{
		c1 = dot(l1.dir,deltap); /* c1=U1t*(P2-P1) */
		c2 = dot(l2.dir,deltap); /* c2=U2t*(P2-P1) */
		a = dot(l1.dir,l2.dir);  /* a=U1t*U2 */
		alpha = (real) ( (a*c2-c1) / (pow(a,2)-1) );
		beta = (real) ( (c2-a*c1) / (pow(a,2)-1) );
		vector(l1.dir,alpha,v1); /* builds vector l1.P->A */
		vector(l2.dir,beta,v2);  /* builds vector l2.P->B */
		sumv(l1.P,v1,A);         /* point A in the reference frame */
		sumv(l2.P,v2,B);         /* point B in the reference frame */
		A[U]=B[U]=1;
		*mindist = dist(A,B);    /* minimum distance between l1, l2 */
		middle(A,B,I);           /* middle point between A and B */
		pcopy(I,lmindist->P);    /* origin of minimum distance line */
		vcopy(u3,lmindist->dir); /* u3 is the dir. of this line */
		unitv(lmindist->dir,lmindist->dir);
		plane2(I,u3,pl);         /* builds the minimum distance pl. */
		if ( (*mindist) > zero ) /* l1 and l2 are oblique lines */
			*inttype=1;      /* intersection is middle point */
		else			 /* l1 and l2 are incident lines */
		{
			*mindist=0.;
			*inttype=0;      /* I is the real intersection */
		}
	}
	else                              /* l1 is parallel to l2 */
	{
		cross(deltap,l1.dir,v1);
		*mindist = mod(v1);	  /* min. dist. between l1, l2 */
		if ( (*mindist) < zero)   /* l1==l2 */
			*inttype = -1;
		else 			  /* l1!=l2 */
		{
			*inttype = 2; 	  /* no intersection between l1, l2 */
			cross(deltap,l1.dir,v1); /* dir. of min. dist. line */
			cross(v1,l1.dir,v2);
			unitv(v2,lmindist->dir);
			pcopy(l1.P,lmindist->P);
			plane2(l1.P,v1,pl); 	 /* pl. containing l1, l2 */
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
leaq 0x48(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x120(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
callq 0x2370
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdi
movsd %xmm0, -0x110(%rbp)
leaq -0x40(%rbp), %rdx
callq 0x2440
movq -0x120(%rbp), %rdi
movq -0x118(%rbp), %rsi
addq $0x20, %rdi
addq $0x20, %rsi
leaq -0xa0(%rbp), %rdx
callq 0x23b0
movsd -0xa0(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x827e
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x128(%rbp)
jmp 0x82a5
movsd -0xa0(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x128(%rbp)
movsd -0x128(%rbp), %xmm0
ucomisd -0x110(%rbp), %xmm0
ja 0x8377
movsd -0x98(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x82de
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x130(%rbp)
jmp 0x8305
movsd -0x98(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x130(%rbp)
movsd -0x130(%rbp), %xmm0
ucomisd -0x110(%rbp), %xmm0
ja 0x8377
movsd -0x90(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x833a
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x138(%rbp)
jmp 0x8361
movsd -0x90(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x138(%rbp)
movsd -0x138(%rbp), %xmm0
ucomisd -0x110(%rbp), %xmm0
jbe 0x8624
movq -0x120(%rbp), %rdi
addq $0x20, %rdi
leaq -0x40(%rbp), %rsi
callq 0x2030
movq -0x118(%rbp), %rdi
movsd %xmm0, -0xf0(%rbp)
addq $0x20, %rdi
leaq -0x40(%rbp), %rsi
callq 0x2030
movq -0x120(%rbp), %rdi
movq -0x118(%rbp), %rsi
movsd %xmm0, -0xf8(%rbp)
addq $0x20, %rdi
addq $0x20, %rsi
callq 0x2030
movsd %xmm0, -0xe8(%rbp)
movsd -0xe8(%rbp), %xmm0
movsd -0xf8(%rbp), %xmm2
movsd -0xf0(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x148(%rbp)
movsd -0xe8(%rbp), %xmm0
movsd 0x6e07(%rip), %xmm1     # 0xf228
callq 0x20a0
movaps %xmm0, %xmm1
movsd -0x148(%rbp), %xmm0
movsd 0x6c27(%rip), %xmm2     # 0xf060
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0xf8(%rbp), %xmm1
movsd -0xe8(%rbp), %xmm0
movsd -0xf0(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x140(%rbp)
movsd -0xe8(%rbp), %xmm0
movsd 0x6d90(%rip), %xmm1     # 0xf228
callq 0x20a0
movq -0x120(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x140(%rbp), %xmm0
movsd 0x6ba9(%rip), %xmm2     # 0xf060
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x108(%rbp)
addq $0x20, %rdi
movsd -0x100(%rbp), %xmm0
leaq -0x60(%rbp), %rsi
callq 0x2200
movq -0x118(%rbp), %rdi
addq $0x20, %rdi
movsd -0x108(%rbp), %xmm0
leaq -0x80(%rbp), %rsi
callq 0x2200
movq -0x120(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
movl $0x3, %ecx
movl $0x1, %r8d
callq 0x21f0
movq -0x118(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0xe0(%rbp), %rdx
movl $0x3, %ecx
movl $0x1, %r8d
callq 0x21f0
movsd 0x6b1c(%rip), %xmm0     # 0xf060
movsd %xmm0, -0xc8(%rbp)
movsd 0x6b0c(%rip), %xmm0     # 0xf060
movsd %xmm0, -0xa8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x2260
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x2400
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movl $0x1, %ecx
callq 0x2280
leaq -0xa0(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x20, %rsi
movl $0x3, %edx
movl $0x1, %ecx
callq 0x2280
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movq -0x8(%rbp), %rsi
addq $0x20, %rsi
callq 0x20f0
movq -0x20(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x22e0
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
ucomisd -0x110(%rbp), %xmm0
jbe 0x860a
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
jmp 0x861f
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
jmp 0x86ea
movq -0x120(%rbp), %rsi
leaq -0x40(%rbp), %rdi
addq $0x20, %rsi
leaq -0x60(%rbp), %rdx
callq 0x23b0
leaq -0x60(%rbp), %rdi
callq 0x2050
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movsd (%rax), %xmm1
movsd -0x110(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x866f
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
jmp 0x86e8
movq -0x120(%rbp), %rsi
movq -0x28(%rbp), %rax
movl $0x2, (%rax)
leaq -0x40(%rbp), %rdi
addq $0x20, %rsi
leaq -0x60(%rbp), %rdx
callq 0x23b0
movq -0x120(%rbp), %rsi
leaq -0x60(%rbp), %rdi
addq $0x20, %rsi
leaq -0x80(%rbp), %rdx
callq 0x23b0
leaq -0x80(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x20, %rsi
callq 0x20f0
movq -0x120(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movl $0x1, %ecx
callq 0x2280
movq -0x120(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x22e0
jmp 0x86ea
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopw %cs:(%rax,%rax)