// File: /workspace/github_cpp_makefile_star2_O3/syzcch[P]FEC_C_version/./fec_rs.h
// Function: rscode::gf_invert_matrix(int*, int)
int *gf_invert_matrix(int *mat, int rows)
    {
        int *inv;
        int *copy;
        int cols, i, j, k, x, rs2;
        int row_start, tmp, inverse;

        cols = rows;

        inv = (int *) malloc(sizeof(int)*rows*cols);
        if (inv == NULL)
        {
            printf("gf_invert_matrix - inv");
        }
        copy = (int *) malloc(sizeof(int)*rows*cols);
        if (copy == NULL)
        {
            printf("gf_invert_matrix - copy");
        }

        k = 0;
        for (i = 0; i < rows; i++)
        {
            for (j = 0; j < cols; j++)
            {
                inv[k] = (i == j) ? 1 : 0;
                copy[k] = mat[k];
                k++;
            }
        }

        /* First -- convert into upper triangular */
        for (i = 0; i < cols; i++)
        {
            row_start = cols*i;

            /* Swap rows if we ave a zero i,i element.  If we can't swap, then the
            matrix was not invertible */

            if (copy[row_start+i] == 0)
            {
                for (j = i+1; j < rows && copy[cols*j+i] == 0; j++) ;
                if (j == rows)
                {
                    printf( "gf_invert_matrix: Matrix not invertible!!\n");
                    exit(1);
                }
                rs2 = j*cols;
                for (k = 0; k < cols; k++)
                {
                    tmp = copy[row_start+k];
                    copy[row_start+k] = copy[rs2+k];
                    copy[rs2+k] = tmp;
                    tmp = inv[row_start+k];
                    inv[row_start+k] = inv[rs2+k];
                    inv[rs2+k] = tmp;
                }
            }

            /* Multiply the row by 1/element i,i */
            tmp = copy[row_start+i];
            if (tmp != 1)
            {
                inverse = gf_single_divide(1, tmp);
                for (j = 0; j < cols; j++)
                {
                    copy[row_start+j] = gf_single_multiply(copy[row_start+j], inverse);
                    inv[row_start+j] = gf_single_multiply(inv[row_start+j], inverse);
                }
                /* pic(inv, copy, rows, "Divided through"); */
            }

            /* Now for each j>i, add A_ji*Ai to Aj */
            k = row_start+i;
            for (j = i+1; j != cols; j++)
            {
                k += cols;
                if (copy[k] != 0)
                {
                    if (copy[k] == 1)
                    {
                        rs2 = cols*j;
                        for (x = 0; x < cols; x++)
                        {
                            copy[rs2+x] ^= copy[row_start+x];
                            inv[rs2+x] ^= inv[row_start+x];
                        }
                    }
                    else
                    {
                        tmp = copy[k];
                        rs2 = cols*j;
                        for (x = 0; x < cols; x++)
                        {
                            copy[rs2+x] ^= gf_single_multiply(tmp, copy[row_start+x]);
                            inv[rs2+x] ^= gf_single_multiply(tmp, inv[row_start+x]);
                        }
                    }
                }
            }
            /* pic(inv, copy, rows, "Eliminated rows"); */
        }

        /* Now the matrix is upper triangular.  Start at the top and multiply down */

        for (i = rows-1; i >= 0; i--)
        {
            row_start = i*cols;
            for (j = 0; j < i; j++)
            {
                rs2 = j*cols;
                if (0 != copy[rs2+i])
                {
                    tmp = copy[rs2+i];
                    copy[rs2+i] = 0;
                    for (k = 0; k < cols; k++)
                    {
                        inv[rs2+k] ^= gf_single_multiply(tmp, inv[row_start+k]);
                    }
                }
            }
            /* pic(inv, copy, rows, "One Column"); */
        }
        free(copy);
        return inv;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, -0x30(%rbp)
movq %rdi, %rbx
movq %rdx, -0x58(%rbp)
movslq %edx, %r14
movq %r14, -0x60(%rbp)
imulq %r14, %r14
shlq $0x2, %r14
movq %r14, %rdi
callq 0x10e0
movq %rax, %r15
testq %rax, %rax
jne 0x2492
leaq 0xd3b(%rip), %rdi       # 0x31c6
xorl %eax, %eax
callq 0x1040
movq %rbx, -0x90(%rbp)
movq %r14, %rdi
callq 0x10e0
movq %rax, %r12
testq %rax, %rax
jne 0x24b7
leaq 0xd2d(%rip), %rdi       # 0x31dd
xorl %eax, %eax
callq 0x1040
movq -0x58(%rbp), %rax
testl %eax, %eax
jle 0x2917
movl %eax, %eax
movq %rax, -0x50(%rbp)
leaq (,%rax,4), %r13
xorl %ebx, %ebx
xorl %r14d, %r14d
movslq %r14d, %r14
leaq (%r12,%r14,4), %rdi
movq -0x30(%rbp), %rax
leaq (%rax,%r14,4), %rsi
movq %r13, %rdx
callq 0x1080
movq -0x58(%rbp), %r8
xorl %eax, %eax
xorl %ecx, %ecx
cmpl %eax, %ebx
sete %cl
movl %ecx, (%r15,%r14,4)
incq %r14
incl %eax
cmpl %eax, %r8d
jne 0x24f3
incl %ebx
cmpl %r8d, %ebx
jne 0x24d6
testl %r8d, %r8d
movq -0x50(%rbp), %r10
jle 0x2917
leal -0x1(%r8), %eax
movq %rax, -0x68(%rbp)
leal 0x1(%r8), %eax
movl %eax, -0x94(%rbp)
movq -0x60(%rbp), %rax
leaq (,%rax,4), %r11
leaq (%r12,%rax,4), %r13
leaq 0x4(,%rax,4), %rax
movq %rax, -0xe8(%rbp)
leaq (,%r10,4), %rax
movq %rax, -0xe0(%rbp)
leaq (%r15,%r10,4), %rax
movq %rax, -0xb8(%rbp)
leaq (%r12,%r10,4), %rax
movq %rax, -0xb0(%rbp)
movl $0x1, %eax
movq %rax, -0xa8(%rbp)
xorl %r9d, %r9d
movq %r15, %rcx
movq %r12, %rdx
movq $0x0, -0x38(%rbp)
xorl %eax, %eax
movq %r15, -0xa0(%rbp)
movq %r12, -0x70(%rbp)
movq %r11, -0xd8(%rbp)
movq %rax, -0x40(%rbp)
movq %rdx, -0xc0(%rbp)
movq %rcx, -0xd0(%rbp)
movq -0x40(%rbp), %rax
imull %r8d, %eax
movslq %eax, %rdx
movq -0x40(%rbp), %rax
leaq (%r12,%rax,4), %rcx
movl (%rcx,%rdx,4), %ebx
testl %ebx, %ebx
movq -0x90(%rbp), %r14
movq %r9, -0xc8(%rbp)
jne 0x2662
movq %rdx, -0x30(%rbp)
movq %r13, %rdi
movl %r9d, %edx
movq -0x68(%rbp), %rsi
movq -0xd0(%rbp), %rbx
cmpq %rsi, %rax
je 0x2934
decq %rsi
addl %r8d, %edx
cmpl $0x0, (%rdi)
leaq (%rdi,%r11), %rdi
je 0x25f6
incl %esi
cmpl %eax, %esi
je 0x2934
movslq %edx, %rsi
leaq (%r12,%rsi,4), %rdx
leaq (%r15,%rsi,4), %rsi
xorl %edi, %edi
movq -0xc0(%rbp), %rax
movl (%rax,%rdi,4), %r8d
movl (%rdx,%rdi,4), %r9d
movl %r9d, (%rax,%rdi,4)
movl %r8d, (%rdx,%rdi,4)
movl (%rbx,%rdi,4), %r8d
movl (%rsi,%rdi,4), %r9d
movl %r9d, (%rbx,%rdi,4)
movl %r8d, (%rsi,%rdi,4)
incq %rdi
cmpq %rdi, %r10
jne 0x262c
movq -0x30(%rbp), %rax
movl (%rcx,%rax,4), %ebx
movq -0xc8(%rbp), %r9
movq %r13, -0xf0(%rbp)
movl %r9d, %eax
leaq (%r15,%rax,4), %rdx
leaq (%r12,%rax,4), %r12
cmpl $0x1, %ebx
movq %rdx, -0x30(%rbp)
je 0x26ee
movq %r14, %rdi
callq 0x213e
testl %ebx, %ebx
je 0x26ae
movslq 0x2a54(%rip), %rax      # 0x50e4
movslq %ebx, %rcx
leaq 0x2a46(%rip), %rdx      # 0x50e0
movslq (%rdx,%rcx,4), %rcx
subq %rcx, %rax
movq 0x2a30(%rip), %rcx      # 0x50d8
movl (%rcx,%rax,4), %r13d
jmp 0x26b4
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %ebx, %ebx
movl (%r12,%rbx,4), %esi
movq %r14, %rdi
movl %r13d, %edx
callq 0x20f8
movl %eax, (%r12,%rbx,4)
movq -0x30(%rbp), %rax
movl (%rax,%rbx,4), %esi
movq %r14, %rdi
movl %r13d, %edx
callq 0x20f8
movq -0x30(%rbp), %rdx
movq -0x50(%rbp), %r10
movl %eax, (%rdx,%rbx,4)
incq %rbx
cmpq %rbx, %r10
jne 0x26b6
movq -0x38(%rbp), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
incq %rax
movq %rax, -0x40(%rbp)
cmpq %r10, %rax
je 0x27d7
movq %r12, %rbx
movq -0xb0(%rbp), %r15
movq -0xb8(%rbp), %rdi
movq -0xa8(%rbp), %rcx
movq -0x38(%rbp), %r8
movq %rcx, -0x80(%rbp)
addq %r10, %r8
movq -0x70(%rbp), %rax
movq %r8, -0x78(%rbp)
movl (%rax,%r8,4), %eax
testl %eax, %eax
je 0x27b6
cmpl $0x1, %eax
jne 0x275d
xorl %eax, %eax
movl (%rbx,%rax,4), %ecx
xorl %ecx, (%r15,%rax,4)
movl (%rdx,%rax,4), %ecx
xorl %ecx, (%rdi,%rax,4)
incq %rax
cmpq %rax, %r10
jne 0x2746
jmp 0x27b6
movl %eax, -0x88(%rbp)
xorl %r14d, %r14d
movq %rdi, -0x48(%rbp)
movl (%rbx,%r14,4), %edx
movq -0x90(%rbp), %r12
movq %r12, %rdi
movl -0x88(%rbp), %r13d
movl %r13d, %esi
callq 0x20f8
xorl %eax, (%r15,%r14,4)
movq -0x30(%rbp), %rax
movl (%rax,%r14,4), %edx
movq %r12, %rdi
movl %r13d, %esi
callq 0x20f8
movq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x50(%rbp), %r10
xorl %eax, (%rdi,%r14,4)
incq %r14
cmpq %r14, %r10
jne 0x276a
movq -0x80(%rbp), %rcx
incq %rcx
movq -0xe0(%rbp), %rax
addq %rax, %rdi
addq %rax, %r15
cmpq %r10, %rcx
movq -0x78(%rbp), %r8
jne 0x2728
movq -0x38(%rbp), %rax
addl -0x94(%rbp), %eax
movq %rax, -0x38(%rbp)
incq -0xa8(%rbp)
movq -0x58(%rbp), %r8
movq -0xc8(%rbp), %r9
addl %r8d, %r9d
movq -0xf0(%rbp), %r13
addq -0xe8(%rbp), %r13
movq -0xd8(%rbp), %r11
movq -0xc0(%rbp), %rdx
addq %r11, %rdx
movq -0xd0(%rbp), %rcx
addq %r11, %rcx
movq -0xe0(%rbp), %rax
addq %rax, -0xb8(%rbp)
addq %rax, -0xb0(%rbp)
movq -0x40(%rbp), %rax
cmpq %r10, %rax
movq -0xa0(%rbp), %r15
movq -0x70(%rbp), %r12
jne 0x25a3
testl %r8d, %r8d
jle 0x2917
movq -0x60(%rbp), %rcx
leaq -0x1(%rcx), %rax
imulq %rcx, %rax
leaq (%r15,%rax,4), %rbx
negq %r11
movq %r11, -0x78(%rbp)
cmpq $0x2, %rcx
jl 0x2917
movq %rcx, -0x88(%rbp)
leaq -0x1(%rcx), %rax
movq %rax, -0x80(%rbp)
leaq (%r12,%rax,4), %rax
movq %rax, -0x48(%rbp)
movq %r15, %r13
xorl %eax, %eax
movq %rax, -0x30(%rbp)
imulq -0x60(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rcx,%rax,4), %r12d
testl %r12d, %r12d
movq -0x90(%rbp), %r15
je 0x28de
movq -0x48(%rbp), %rcx
movl $0x0, (%rcx,%rax,4)
xorl %r14d, %r14d
movl (%rbx,%r14,4), %edx
movq %r15, %rdi
movl %r12d, %esi
callq 0x20f8
xorl %eax, (%r13,%r14,4)
incq %r14
cmpq %r14, -0x50(%rbp)
jne 0x28c1
movq -0x30(%rbp), %rax
incq %rax
addq -0xd8(%rbp), %r13
cmpq -0x68(%rbp), %rax
jne 0x2896
decq -0x68(%rbp)
addq -0x78(%rbp), %rbx
cmpq $0x2, -0x88(%rbp)
movq -0x80(%rbp), %rcx
movq -0xa0(%rbp), %r15
movq -0x70(%rbp), %r12
jge 0x2870
movq %r12, %rdi
callq 0x10c0
movq %r15, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9b9(%rip), %rdi       # 0x32f4
callq 0x1110
movl $0x1, %edi
callq 0x10d0