// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/linear_system.c
// Function: SolveFactorizedLinearSystem
static int SolveFactorizedLinearSystem(const int n, Real L[restrict][n], Real U[restrict][n],
        Real x[], Real b[], const int permute[restrict])
{
    /*
     * Rearrange the elements of right hand side vector according to
     * permutations applied. Rearranged vector can be saved to the
     * solution vector, interchange values needs to be applied since
     * the right hand side vector and solution vector may occupy the
     * same storage space.
     */
    Real temp = 0.0; /* auxiliary variable */
    for (int row = 0; row < n; ++row) {
        temp = b[row];
        x[row] = b[permute[row]];
        b[permute[row]] = temp;
    }
    /*
     * Forward substitution.
     * Note that the lower triangle L has unit diagonal.
     */
    for (int row = 0; row < n; ++row) {
        for (int col = 0; col < row; ++col) {
            x[row] = x[row] - L[row][col] * x[col];
        }
    }
    /*
     * Bach substitution.
     */
    for (int row = n - 1; row >= 0; --row) {
        for (int col = row + 1; col < n; ++col) {
            x[row] = x[row] - U[row][col] * x[col];
        }
        x[row] = x[row] / U[row][row];
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl -0x4(%rbp), %eax
movq %rax, -0x60(%rbp)
movl -0x4(%rbp), %eax
movq %rax, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1c359
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1c2f8
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1c3fc
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x1c3ec
movq -0x60(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x10(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x44(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x44(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1c373
jmp 0x1c3ee
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1c360
movl -0x4(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jl 0x1c4d9
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1c491
movq -0x58(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x4c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1c418
movq -0x58(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x48(%rbp), %rcx
divsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x48(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x1c405
xorl %eax, %eax
popq %rbp
retq
nopl (%rax)