// File: /workspace/github_c_makefile_star2_O3/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, %r15
movl %edx, -0x30(%rbp)
movq %rsi, -0x38(%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, %rbx
leaq 0xf(,%r13,8), %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq %rdx, -0x58(%rbp)
callq 0x1386c
movl -0x30(%rbp), %ecx
movq -0x38(%rbp), %rax
testl %ecx, %ecx
jle 0x1385b
movl %ecx, %r9d
leaq (,%r9,8), %rcx
leaq (,%r13,8), %rdx
leaq (%rbx,%r13,8), %rsi
movq %rsi, -0x48(%rbp)
movq %r13, %rsi
imulq %r13, %rsi
leaq (%rax,%rsi,8), %rsi
movq %rsi, -0x40(%rbp)
movq %rdx, %r8
xorq $-0x8, %r8
xorl %r10d, %r10d
movq %r9, -0x50(%rbp)
testl %r12d, %r12d
jle 0x13847
movq %r14, %rsi
xorl %edi, %edi
movsd (%rsi), %xmm0
movsd %xmm0, (%rbx,%rdi,8)
incq %rdi
addq %rcx, %rsi
cmpq %rdi, %r13
jne 0x13718
testl %r12d, %r12d
jle 0x13847
movq %r10, -0x60(%rbp)
xorl %esi, %esi
movq -0x58(%rbp), %r9
movsd (%rbx,%rsi,8), %xmm0
movslq (%r9,%rsi,4), %rdi
movsd (%rbx,%rdi,8), %xmm1
movsd %xmm1, (%rbx,%rsi,8)
movsd %xmm0, (%rbx,%rdi,8)
incq %rsi
cmpq %rsi, %r13
jne 0x1373f
movq %r15, -0x68(%rbp)
movq %r14, -0x30(%rbp)
movq %rax, %r10
xorl %esi, %esi
testq %rsi, %rsi
je 0x13794
movsd (%rbx,%rsi,8), %xmm0
xorl %edi, %edi
movsd (%r10,%rdi,8), %xmm1
mulsd (%rbx,%rdi,8), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, (%rbx,%rsi,8)
incq %rdi
cmpq %rdi, %rsi
jne 0x13778
incq %rsi
addq %rdx, %r10
cmpq %r13, %rsi
jne 0x1376c
movq -0x40(%rbp), %r10
movq -0x48(%rbp), %r11
movq %r13, %r15
leaq -0x1(%r15), %r14
cmpq %r13, %r15
jge 0x137ec
movq %rax, %r9
movq %r14, %rsi
imulq %r13, %rsi
movsd (%rbx,%r14,8), %xmm0
xorl %edi, %edi
movsd (%r10,%rdi,8), %xmm1
mulsd (%r11,%rdi,8), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, (%rbx,%r14,8)
incq %rdi
leal (%rdi,%r15), %eax
cmpl %r12d, %eax
jl 0x137c5
movq %r9, %rax
jmp 0x137f9
movsd (%rbx,%r14,8), %xmm0
movq %r14, %rsi
imulq %r13, %rsi
leaq (%rax,%rsi,8), %rsi
divsd (%rsi,%r14,8), %xmm0
movsd %xmm0, (%rbx,%r14,8)
addq $-0x8, %r11
addq %r8, %r10
cmpq $0x1, %r15
movq %r14, %r15
jg 0x137aa
testl %r12d, %r12d
movq -0x30(%rbp), %r14
movq -0x68(%rbp), %r15
movq -0x50(%rbp), %r9
movq -0x60(%rbp), %r10
jle 0x13847
movq %r15, %rsi
xorl %edi, %edi
movsd (%rbx,%rdi,8), %xmm0
movsd %xmm0, (%rsi)
incq %rdi
addq %rcx, %rsi
cmpq %rdi, %r13
jne 0x13833
incq %r10
addq $0x8, %r14
addq $0x8, %r15
cmpq %r9, %r10
jne 0x1370a
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq