// File: /workspace/github_c_makefile_star2_O3/Alessandro-Barbieri[P]SpaceLib/src/SPACELI4.c
// Function: invA
int invA(real alpha, real beta, int sig, int i, int j, int k, MAT3 Ai)
{
	int l;
	real sa,ca,sb,cb;     /* sine and cosine of two Euler/Cardan angles */

	sa = (real) sin(alpha); ca = (real) cos(alpha);
	sb = (real) sin(beta);  cb = (real) cos(beta);

	if ( ((i!=k) && (cb==0.)) || ((i==k) && (sb==0.)) ) /* singularity */
		return (NOTOK);
	if (i!=k)	      /* Cardan convention */
	{
		Ai[X][i]=1.; Ai[X][j]=sa*sb/cb;     Ai[X][k]=(-sig)*ca*sb/cb;
		Ai[Y][i]=0.; Ai[Y][j]=ca;           Ai[Y][k]=sig*sa;
		Ai[Z][i]=0.; Ai[Z][j]=(-sig)*sa/cb; Ai[Z][k]=ca/cb;
	}
	else	              /* Euler convention */
	{
		l=3-i-j;

		Ai[X][i]=1.; Ai[X][j]=-sa*cb/sb;    Ai[X][l]=sig*ca*cb/sb;
		Ai[Y][i]=0.; Ai[Y][j]=ca;           Ai[Y][l]=sig*sa;
		Ai[Z][i]=0.; Ai[Z][j]=sa/sb;	    Ai[Z][l]=(-sig)*ca/sb;
	}
	return(OK);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %r8, %rbx
movl %ecx, %r15d
movl %edx, %r14d
movl %esi, %r12d
movl %edi, %ebp
movsd %xmm1, 0x18(%rsp)
movsd %xmm0, 0x8(%rsp)
callq 0x2370
movaps %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x2140
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x2370
movsd %xmm0, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x2140
xorl %eax, %eax
cmpl %r15d, %r12d
je 0x5859
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5859
jnp 0x59b1
cmpl %r15d, %r12d
movsd 0x8(%rsp), %xmm6
jne 0x5874
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm6
jne 0x5874
jnp 0x59b1
cmpl %r15d, %r12d
je 0x590c
movslq %r12d, %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rbx,%rax,8)
movapd 0x20(%rsp), %xmm5
movapd %xmm5, %xmm1
mulsd %xmm6, %xmm1
divsd %xmm0, %xmm1
movslq %r14d, %rcx
movsd %xmm1, (%rbx,%rcx,8)
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
negl %ebp
cvtsi2sd %ebp, %xmm2
movsd 0x10(%rsp), %xmm4
movapd %xmm4, %xmm3
mulsd %xmm2, %xmm3
mulsd %xmm6, %xmm3
divsd %xmm0, %xmm3
movslq %r15d, %rdx
movsd %xmm3, (%rbx,%rdx,8)
xorl %esi, %esi
movq %rsi, 0x18(%rbx,%rax,8)
movsd %xmm4, 0x18(%rbx,%rcx,8)
mulsd %xmm5, %xmm1
movsd %xmm1, 0x18(%rbx,%rdx,8)
movq %rsi, 0x30(%rbx,%rax,8)
mulsd %xmm2, %xmm5
divsd %xmm0, %xmm5
movsd %xmm5, 0x30(%rbx,%rcx,8)
divsd %xmm0, %xmm4
movsd %xmm4, 0x30(%rbx,%rdx,8)
jmp 0x59ac
movl $0x3, %ecx
subl %r12d, %ecx
subl %r14d, %ecx
movslq %r12d, %rax
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movq %rdx, (%rbx,%rax,8)
movapd 0x46f0(%rip), %xmm1     # 0xa020
movapd 0x20(%rsp), %xmm4
xorpd %xmm4, %xmm1
mulsd %xmm0, %xmm1
divsd %xmm6, %xmm1
movslq %r14d, %rdx
movsd %xmm1, (%rbx,%rdx,8)
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0x10(%rsp), %xmm3
movapd %xmm3, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
divsd %xmm6, %xmm2
movslq %ecx, %rcx
movsd %xmm2, (%rbx,%rcx,8)
xorl %esi, %esi
movq %rsi, 0x18(%rbx,%rax,8)
movsd %xmm3, 0x18(%rbx,%rdx,8)
mulsd %xmm4, %xmm1
movsd %xmm1, 0x18(%rbx,%rcx,8)
movq %rsi, 0x30(%rbx,%rax,8)
divsd %xmm6, %xmm4
movsd %xmm4, 0x30(%rbx,%rdx,8)
negl %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
mulsd %xmm3, %xmm0
divsd %xmm6, %xmm0
movsd %xmm0, 0x30(%rbx,%rcx,8)
movl $0x1, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq