// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %r8, %rbx
movq %rcx, %r15
movl %edx, -0x30(%rbp)
movl %edi, %r12d
movl %edi, %r13d
movq %rsp, %rdx
leaq 0xf(,%r13,4), %rax
andq $-0x10, %rax
subq %rax, %rdx
movq %rdx, %rsp
movq %rsp, %r14
leaq 0xf(,%r13,8), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movq %rsi, -0x38(%rbp)
movq %rdx, -0x50(%rbp)
callq 0x13c25
movl -0x30(%rbp), %eax
testl %eax, %eax
jle 0x13c14
movl %eax, %eax
movq %rax, -0x58(%rbp)
leaq (,%rax,8), %rcx
leaq (,%r13,8), %rdx
leaq (%r14,%r13,8), %rax
movq %rax, -0x48(%rbp)
movq %r13, %rsi
imulq %r13, %rsi
movq -0x38(%rbp), %rax
leaq (%rax,%rsi,8), %rax
movq %rax, -0x40(%rbp)
movq %rdx, %r8
xorq $-0x8, %r8
xorl %r9d, %r9d
movq %r15, -0x30(%rbp)
testl %r12d, %r12d
jle 0x13ae9
movq %rbx, %rsi
xorl %r10d, %r10d
movsd (%rsi), %xmm0
movsd %xmm0, (%r14,%r10,8)
incq %r10
addq %rcx, %rsi
cmpq %r10, %r13
jne 0x13ad4
movq %rbx, %rax
testl %r12d, %r12d
jle 0x13bd8
xorl %esi, %esi
movq -0x50(%rbp), %rdi
movsd (%r14,%rsi,8), %xmm0
movslq (%rdi,%rsi,4), %r10
movsd (%r14,%r10,8), %xmm1
movsd %xmm1, (%r14,%rsi,8)
movsd %xmm0, (%r14,%r10,8)
incq %rsi
cmpq %rsi, %r13
jne 0x13afb
testl %r12d, %r12d
jle 0x13bd8
movq -0x38(%rbp), %r10
xorl %r11d, %r11d
testq %r11, %r11
je 0x13b5a
movsd (%r14,%r11,8), %xmm0
xorl %esi, %esi
movsd (%r10,%rsi,8), %xmm1
mulsd (%r14,%rsi,8), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, (%r14,%r11,8)
incq %rsi
cmpq %rsi, %r11
jne 0x13b3c
incq %r11
addq %rdx, %r10
cmpq %r13, %r11
jne 0x13b2f
movq -0x40(%rbp), %r10
movq -0x48(%rbp), %r11
movq %r13, %r15
testl %r12d, %r12d
jle 0x13bd8
leaq -0x1(%r15), %rbx
cmpq %r13, %r15
jge 0x13ba8
movsd (%r14,%rbx,8), %xmm0
xorl %esi, %esi
movsd (%r10,%rsi,8), %xmm1
mulsd (%r11,%rsi,8), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, (%r14,%rbx,8)
incq %rsi
leal (%rsi,%r15), %edi
cmpl %r12d, %edi
jl 0x13b86
movsd (%r14,%rbx,8), %xmm0
movq %rbx, %rsi
imulq %r13, %rsi
movq -0x38(%rbp), %rdi
leaq (%rdi,%rsi,8), %rsi
divsd (%rsi,%rbx,8), %xmm0
movsd %xmm0, (%r14,%rbx,8)
addq $-0x8, %r11
addq %r8, %r10
cmpq $0x1, %r15
movq %rbx, %r15
jg 0x13b75
testl %r12d, %r12d
movq -0x30(%rbp), %r15
jle 0x13bfc
movq %r15, %rsi
xorl %r10d, %r10d
movsd (%r14,%r10,8), %xmm0
movsd %xmm0, (%rsi)
incq %r10
addq %rcx, %rsi
cmpq %r10, %r13
jne 0x13be7
incq %r9
movq %rax, %rbx
addq $0x8, %rbx
addq $0x8, %r15
cmpq -0x58(%rbp), %r9
jne 0x13ac5
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq