// File: /workspace/github_c_makefile_star2_O3/Alessandro-Barbieri[P]SpaceLib/src/LINEAR2.c
// Function: minvers
int minvers(MAT A, MAT Ai, int dim)
{

	real *H;                /* matrix where A and I must be copied */
	int *ivet;              /* vector filled with reordering info. */
	int vpr = -1;
	int irank;
	real arm;
	int i,j;

	H = (real *) calloc (2*dim*dim,sizeof(real));
	ivet = (int *) calloc (dim,sizeof(int));

	for (i=0;i<dim;i++)     /* copies matrix A into matrix H */
		for (j=0;j<dim;j++)
			H[i*dim*2+j] = *(A+i*dim+j);
	for (i=0;i<dim;i++)     /* copies identity matrix I into matrix H */
		for (j=dim;j<2*dim;j++)
			if (i!=(j-dim))
				H[i*dim*2+j] = 0;
			else
				H[i*dim*2+j] = 1;
	linear(H,dim,2*dim,dim,dim,dim,ivet,&irank,&arm,&vpr);
	for (j=dim;j<2*dim;j++) /* extracts solution x reordering matrix H */
		for (i=0;i<dim;i++)
			*(Ai+ivet[i]*dim+j-dim) = *(H+i*2*dim+j);

	free (H); free (ivet);

	return irank;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, 0x38(%rsp)
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
leal (%rbx,%rbx), %ebp
movl %ebp, %eax
imull %edx, %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x2180
movq %rax, %r13
movslq %ebx, %r12
movl $0x4, %esi
movq %r12, %rdi
callq 0x2180
movq %rax, 0x28(%rsp)
movl %ebx, %r15d
testl %r12d, %r12d
movq %r13, 0x8(%rsp)
jle 0x384a
movq %r14, 0x20(%rsp)
leaq (,%r15,8), %rax
movq %rax, 0x30(%rsp)
xorl %r14d, %r14d
movq %rbx, 0x18(%rsp)
movq %r15, %rbx
xorl %r13d, %r13d
movl %r13d, %eax
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax,8), %rsi
movl %r14d, %eax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %rdi
movq 0x30(%rsp), %rdx
callq 0x2200
addl 0x18(%rsp), %r13d
addl %ebp, %r14d
decq %rbx
jne 0x3719
movq 0x18(%rsp), %rbx
testl %ebx, %ebx
movq 0x20(%rsp), %r14
movq 0x8(%rsp), %r13
jle 0x384a
movl %ebp, %ecx
subq %r12, %rcx
leaq 0x1(%rcx), %rax
andq $-0x2, %rax
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq 0x8(,%r12,8), %rcx
addq %r13, %rcx
xorl %edx, %edx
movdqa 0x68a2(%rip), %xmm1     # 0xa030
movdqa 0x68aa(%rip), %xmm2     # 0xa040
pxor %xmm2, %xmm0
movq 0x6926(%rip), %xmm3     # 0xa0c8
pcmpeqd %xmm4, %xmm4
xorl %esi, %esi
cmpl %ebx, %ebp
jle 0x383c
movslq %edx, %rdi
leaq (%rcx,%rdi,8), %rdi
leaq -0x1(%rsi), %r8
xorl %r9d, %r9d
movq %r9, %xmm5
pshufd $0x44, %xmm5, %xmm5     # xmm5 = xmm5[0,1,0,1]
por %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %r10d
notl %r10d
testb $0x1, %r10b
je 0x3810
movdqa %xmm3, %xmm6
cmpq %r9, %rsi
je 0x3809
pxor %xmm6, %xmm6
movq %xmm6, -0x8(%rdi,%r9,8)
pxor %xmm4, %xmm5
pextrw $0x4, %xmm5, %r10d
testb $0x1, %r10b
je 0x3833
movdqa %xmm3, %xmm5
cmpq %r9, %r8
je 0x382d
pxor %xmm5, %xmm5
movq %xmm5, (%rdi,%r9,8)
addq $0x2, %r9
cmpq %r9, %rax
jne 0x37be
incq %rsi
addl %ebp, %edx
cmpq %r15, %rsi
jne 0x37a8
leaq 0x14(%rsp), %rax
leaq 0x40(%rsp), %r10
leaq 0x10(%rsp), %r11
movq %r13, %rdi
movl %ebx, %esi
movl %ebp, %edx
movl %ebx, %ecx
movl %ebx, %r8d
movl %ebx, %r9d
pushq %rax
pushq %r10
pushq %r11
movq %r14, %r13
movq 0x40(%rsp), %r14
pushq %r14
callq 0x21f0
movq %r14, %r10
movq 0x28(%rsp), %rdi
addq $0x20, %rsp
cmpl %ebx, %ebp
jle 0x38e0
leaq (,%r12,8), %rax
subq %rax, %r13
movslq %ebp, %rax
movq %r12, %rcx
testl %ebx, %ebx
jle 0x38d8
leaq (%rdi,%rcx,8), %rdx
leaq (,%rcx,8), %rsi
addq %r13, %rsi
xorl %r14d, %r14d
xorl %r8d, %r8d
movslq %r14d, %r14
movq (%rdx,%r14,8), %xmm0
movslq (%r10,%r8,4), %r9
imulq %r12, %r9
movq %xmm0, (%rsi,%r9,8)
incq %r8
addl %ebp, %r14d
cmpq %r8, %r15
jne 0x38b6
incq %rcx
cmpq %rax, %rcx
jne 0x389d
movq %r10, %rbx
callq 0x2040
movq %rbx, %rdi
callq 0x2040
movl 0x10(%rsp), %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop