// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/linear_system.c
// Function: LUFactorization
static int LUFactorization(const int n, Real A[restrict][n], int permute[restrict])
{
    const Real epsilon = 1.0e-15; /* a small number for singularity check */
    const Real zero = 0.0;
    const Real one = 1.0;
    Real temp = 0.0; /* auxiliary variable */
    Real maximum = 0.0; /* store the maximum value in column */
    Real scale[n]; /* stores the implicit scaling of each row with variable length array */
    int rowMax = 0; /* record the row number of current pivot element */
    int sign = 1; /* used for determine the sign of determinant after pivoting */
    /*
     * Loop over rows to get the implicit scaling information.
     */
    for (int row = 0; row < n; ++row) {
        maximum = zero;
        for (int col = 0; col < n; ++col) {
            temp = fabs(A[row][col]);
            if (temp > maximum) {
                maximum = temp;
            }
        }
        if (zero == maximum) {
            ShowError("singular matrix in LU factorization...");
        }
        scale[row] = one / maximum; /* save the scaling */
    }
    /*
     * Do LU factorization with partial pivoting.
     */
    for (int loop = 0; loop < n; ++loop) {
        maximum = zero; /* initialize for the search of largest pivot element */
        rowMax = loop; /* initialize the pivot position to current row */
        for (int row = loop; row < n; ++row) { /* search pivot element for current loop */
            temp = scale[row] * fabs(A[row][loop]);
            if (temp > maximum) {
                maximum = temp;
                rowMax = row;
            }
        }
        if (loop != rowMax) { /* interchange rows if required */
            for (int col = 0; col < n; ++col) {
                temp = A[rowMax][col];
                A[rowMax][col] = A[loop][col];
                A[loop][col] = temp;
            }
            sign = -sign; /* change the parity of sign */
            scale[rowMax] = scale[loop]; /* replace the scale factor */
        }
        permute[loop] = rowMax; /* record the permutation */
        if (zero == A[loop][loop]) { /* substitute zero pivot element with epsilon */
            A[loop][loop] = epsilon;
        }
        for (int row = loop + 1; row < n; ++row) {
            A[row][loop] = A[row][loop] / A[loop][loop]; /* divide column element with pivot element */
            for (int col = loop + 1; col < n; ++col) { /* reduce remaining submatrix */
                A[row][col] = A[row][col] - A[row][loop] * A[loop][col];
            }
        }
    }
    return sign;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl -0x4(%rbp), %eax
movq %rax, -0x88(%rbp)
movabsq $0x3cd203af9ee75616, %rax # imm = 0x3CD203AF9EE75616
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x4(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x48(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x80(%rbp)
movq %rcx, %rsp
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x1, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1bf9b
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1bf59
movq -0x88(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x5c(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x8643(%rip), %xmm1     # 0x24570
pand %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
ucomisd -0x40(%rbp), %xmm0
jbe 0x1bf4c
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x1bf4e
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1befb
xorps %xmm0, %xmm0
ucomisd -0x40(%rbp), %xmm0
jne 0x1bf73
jp 0x1bf73
leaq 0xd184(%rip), %rdi      # 0x290f0
movb $0x0, %al
callq 0xbbd0
movq -0x80(%rbp), %rax
movsd 0xb791(%rip), %xmm0     # 0x27710
divsd -0x40(%rbp), %xmm0
movslq -0x5c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1bee0
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1c2af
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1c037
movq -0x88(%rbp), %rdx
movq -0x80(%rbp), %rax
movslq -0x68(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movslq -0x68(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x64(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movaps 0x856f(%rip), %xmm2     # 0x24570
pand %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
ucomisd -0x40(%rbp), %xmm0
jbe 0x1c02a
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x1c02c
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x1bfc2
movl -0x64(%rbp), %eax
cmpl -0x54(%rbp), %eax
je 0x1c103
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1c0e5
movq -0x88(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x54(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x6c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x64(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x6c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movslq -0x54(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x6c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x38(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x64(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x6c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1c04a
movq -0x80(%rbp), %rax
xorl %ecx, %ecx
subl -0x58(%rbp), %ecx
movl %ecx, -0x58(%rbp)
movslq -0x64(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movslq -0x54(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x88(%rbp), %rdx
movl -0x54(%rbp), %esi
movq -0x18(%rbp), %rax
movslq -0x64(%rbp), %rcx
movl %esi, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x64(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x64(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
jne 0x1c166
jp 0x1c166
movq -0x88(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x64(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x64(%rbp), %rcx
movsd 0xcf87(%rip), %xmm0     # 0x290e8
movsd %xmm0, (%rax,%rcx,8)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1c29f
movq -0x88(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x70(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x64(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movslq -0x64(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x64(%rbp), %rcx
divsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movslq -0x70(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x64(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x1c28f
movq -0x88(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x70(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x74(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x10(%rbp), %rax
movslq -0x70(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x64(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movslq -0x64(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x74(%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 -0x10(%rbp), %rax
movslq -0x70(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x74(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1c1df
jmp 0x1c291
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x1c16f
jmp 0x1c2a1
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x1bfa2
movl -0x58(%rbp), %eax
movq -0x48(%rbp), %rcx
movq %rcx, %rsp
movq %rbp, %rsp
popq %rbp
retq
nop