// File: /workspace/github_c_makefile_star2_O2/mohuangrui[P]ArtraCFD/linear_system.c
// Function: SolveLinearSystem
int SolveLinearSystem(const int n, Real A[restrict][n], const int m,
        Real X[restrict][m], Real B[restrict][m])
{
    int permute[n]; /* record the permutation information */
    Real rhs[n]; /* transfer data into column vector */
    LUFactorization(n, A, permute);
    for (int col = 0; col < m; ++col) { /* solve column by column */
        for (int row = 0; row < n; ++row) {
            rhs[row] = B[row][col]; /* obtain each right hand side vector */
        }
        SolveFactorizedLinearSystem(n, A, A, rhs, rhs, permute);
        for (int row = 0; row < n; ++row) { /* save solution vector */
            X[row][col] = rhs[row];
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r14
movq %rcx, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq %rsi, -0x40(%rbp)
movl %edi, %r13d
movl %edx, %ebx
movl %edi, %r15d
movq %rsp, %rdx
leaq 0xf(,%r15,4), %rax
andq $-0x10, %rax
subq %rax, %rdx
movq %rdx, %rsp
movq %rsp, %r12
leaq 0xf(,%r15,8), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movq %rdx, -0x60(%rbp)
callq 0x128d8
movq -0x38(%rbp), %rax
xorl %edi, %edi
testl %r13d, %r13d
movl $0x0, %ecx
cmovgl %r13d, %ecx
movq -0x30(%rbp), %rdx
testl %edx, %edx
cmovlel %edi, %edx
movq %rdx, -0x30(%rbp)
shlq $0x3, %rbx
leaq (,%r15,8), %r8
leaq (%r12,%r15,8), %rdx
movq %rdx, -0x50(%rbp)
movq %r15, %rdx
movq %r15, %rsi
imulq %r15, %rsi
movq -0x40(%rbp), %r9
movq %r9, %r15
leaq (%r9,%rsi,8), %rsi
movq %rsi, -0x48(%rbp)
movq %r8, -0x58(%rbp)
xorq $-0x8, %r8
cmpq -0x30(%rbp), %rdi
je 0x128c7
movq %rdi, -0x68(%rbp)
movq %r14, %rsi
xorl %edi, %edi
movq -0x60(%rbp), %r9
cmpq %rdi, %rcx
je 0x127bd
movsd (%rsi), %xmm0
movsd %xmm0, (%r12,%rdi,8)
incq %rdi
addq %rbx, %rsi
jmp 0x127a6
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x127e5
movsd (%r12,%rsi,8), %xmm0
movslq (%r9,%rsi,4), %rdi
movsd (%r12,%rdi,8), %xmm1
movsd %xmm1, (%r12,%rsi,8)
movsd %xmm0, (%r12,%rdi,8)
incq %rsi
jmp 0x127bf
movq %rax, -0x38(%rbp)
movq %r15, %r9
xorl %r10d, %r10d
movq -0x58(%rbp), %rax
cmpq %rcx, %r10
je 0x12828
xorl %esi, %esi
cmpq %rsi, %r10
je 0x12820
movsd (%r9,%rsi,8), %xmm0
mulsd (%r12,%rsi,8), %xmm0
movsd (%r12,%r10,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r12,%r10,8)
incq %rsi
jmp 0x127fa
incq %r10
addq %rax, %r9
jmp 0x127f3
movq %r14, -0x70(%rbp)
movq -0x48(%rbp), %r9
movq -0x50(%rbp), %r10
movq %rdx, %r14
testl %r14d, %r14d
jle 0x1288f
leaq -0x1(%r14), %r11
movq %r11, %rsi
imulq %rdx, %rsi
leaq (%r15,%rsi,8), %rsi
movsd (%r12,%r11,8), %xmm0
xorl %edi, %edi
leal (%r14,%rdi), %eax
cmpl %r13d, %eax
jge 0x12877
movsd (%r9,%rdi,8), %xmm1
mulsd (%r10,%rdi,8), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, (%r12,%r11,8)
incq %rdi
jmp 0x12853
divsd (%rsi,%r11,8), %xmm0
movsd %xmm0, (%r12,%r11,8)
addq $-0x8, %r10
addq %r8, %r9
movq %r11, %r14
jmp 0x12837
movq -0x38(%rbp), %rax
movq %rax, %rsi
xorl %edi, %edi
movq -0x70(%rbp), %r14
cmpq %rdi, %rcx
je 0x128b3
movsd (%r12,%rdi,8), %xmm0
movsd %xmm0, (%rsi)
incq %rdi
addq %rbx, %rsi
jmp 0x1289c
movq -0x68(%rbp), %rdi
incq %rdi
addq $0x8, %r14
addq $0x8, %rax
jmp 0x1278f
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq