// File: /workspace/github_c_makefile_star2_O0/Alessandro-Barbieri[P]SpaceLib/src/LINEAR2.c
// Function: solve
int solve(MAT A, real *b, real *x, int dim)
{
	int solution=1;
	real *H;
	int *ivet;
	int vpr=-1;
	int irank;
	real arm;
	int i,j;

	H = (real *) calloc(dim*(dim+solution),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+solution)+j) = *(A+i*dim+j);

	for(i=0;i<dim;i++)	    /* copies right hand vector b into H */
		H[i*(dim+solution)+dim] = b[i];

	linear(H,dim,dim+solution,dim,dim,solution,ivet,&irank,&arm,&vpr);

	for(i=0;i<dim;i++)          /* finds solution x reordering matrix H */
		x[ivet[i]] = H[i*(dim+solution)+dim];

	free(H); free(ivet);

	return irank;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x68, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl $0x1, -0x28(%rbp)
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movl -0x24(%rbp), %eax
movl -0x24(%rbp), %ecx
addl -0x28(%rbp), %ecx
imull %ecx, %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x2160
movq %rax, -0x30(%rbp)
movslq -0x24(%rbp), %rdi
movl $0x4, %esi
callq 0x2160
movq %rax, -0x38(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x398c
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x397f
movq -0x10(%rbp), %rax
movl -0x4c(%rbp), %ecx
imull -0x24(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl -0x24(%rbp), %edx
addl -0x28(%rbp), %edx
imull %edx, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x392b
jmp 0x3981
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x391c
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x39ce
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl -0x24(%rbp), %edx
addl -0x28(%rbp), %edx
imull %edx, %ecx
addl -0x24(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x3993
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x24(%rbp), %edx
addl -0x28(%rbp), %edx
movl -0x24(%rbp), %ecx
movl -0x24(%rbp), %r8d
movl -0x28(%rbp), %r9d
movq -0x38(%rbp), %rbx
leaq -0x40(%rbp), %r11
leaq -0x48(%rbp), %r10
leaq -0x3c(%rbp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x21e0
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x3a58
movq -0x30(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl -0x24(%rbp), %edx
addl -0x28(%rbp), %edx
imull %edx, %ecx
addl -0x24(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x3a15
movq -0x30(%rbp), %rdi
callq 0x2040
movq -0x38(%rbp), %rdi
callq 0x2040
movl -0x40(%rbp), %eax
addq $0x68, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)