// File: /workspace/github_cpp_makefile_star2_O1/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 $0xb8, %rsp
movl %edx, %r13d
movq %rsi, -0x30(%rbp)
movq %rdi, -0x88(%rbp)
movslq %edx, %r15
imulq %r15, %r15
shlq $0x2, %r15
movq %r15, %rdi
callq 0x10d0
movq %rax, -0x40(%rbp)
testq %rax, %rax
jne 0x2458
leaq 0xd75(%rip), %rdi       # 0x31c6
xorl %eax, %eax
callq 0x1040
movq %r15, %rdi
callq 0x10d0
movq %rax, -0x38(%rbp)
testq %rax, %rax
jne 0x2477
leaq 0xd6d(%rip), %rdi       # 0x31dd
xorl %eax, %eax
callq 0x1040
movl %r13d, %eax
movq %rax, -0x78(%rbp)
testl %r13d, %r13d
jle 0x24db
movq -0x78(%rbp), %rax
leaq (,%rax,4), %r15
xorl %ebx, %ebx
xorl %r14d, %r14d
movslq %r14d, %r12
movq -0x38(%rbp), %rax
leaq (%rax,%r12,4), %rdi
movq -0x30(%rbp), %rax
leaq (%rax,%r12,4), %rsi
movq %r15, %rdx
callq 0x1070
movq -0x40(%rbp), %rax
leaq (%rax,%r12,4), %rcx
xorl %eax, %eax
xorl %edx, %edx
movl %ebx, %esi
addl %eax, %esi
sete %dl
movl %edx, (%rcx)
addq $0x4, %rcx
decl %eax
movl %r13d, %edx
addl %eax, %edx
jne 0x24b9
subl %eax, %r14d
incl %ebx
cmpl %r13d, %ebx
jne 0x2494
testl %r13d, %r13d
movq -0x78(%rbp), %r12
jle 0x27ef
leal -0x1(%r13), %r10d
leal 0x1(%r13), %eax
movl %eax, -0x8c(%rbp)
negq %r10
leaq (,%r12,4), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rcx
leaq (%rcx,%r12,4), %rdx
leaq 0x4(,%r12,4), %rax
movq %rax, -0xb0(%rbp)
movq -0x40(%rbp), %rax
leaq (%rax,%r12,4), %rsi
movq %rsi, -0xa0(%rbp)
movl $0x1, %esi
movq %rsi, -0x98(%rbp)
xorl %r11d, %r11d
movq %rax, %rbx
movq %rcx, %r14
movq %rdx, -0xa8(%rbp)
movq %rdx, %r15
movq $0x0, -0x48(%rbp)
xorl %edx, %edx
movq %r13, -0x70(%rbp)
movl %edx, %eax
imull %r13d, %eax
cltq
movq -0x38(%rbp), %rcx
movq %rdx, -0x68(%rbp)
leaq (%rcx,%rdx,4), %rcx
cmpl $0x0, (%rcx,%rax,4)
jne 0x25e1
movq %r15, %rsi
xorl %edx, %edx
cmpq %rdx, %r10
je 0x2594
decq %rdx
cmpl $0x0, (%rsi)
movq -0x58(%rbp), %rdi
leaq (%rsi,%rdi), %rsi
je 0x2577
movq -0x68(%rbp), %rsi
subl %edx, %esi
jmp 0x2597
movl %r13d, %esi
cmpl %r13d, %esi
je 0x28eb
imull %r13d, %esi
movslq %esi, %rsi
movq -0x38(%rbp), %rdx
leaq (%rdx,%rsi,4), %rdx
movq -0x40(%rbp), %rdi
leaq (%rdi,%rsi,4), %rsi
xorl %edi, %edi
movl (%r14,%rdi,4), %r8d
movl (%rdx,%rdi,4), %r9d
movl %r9d, (%r14,%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, %r12
jne 0x25b9
movq %r15, -0xb8(%rbp)
movq %r14, -0xc0(%rbp)
movq %rbx, -0xc8(%rbp)
movq %r10, -0xd8(%rbp)
movq %r11, -0xd0(%rbp)
movl %r11d, %edx
movq -0x40(%rbp), %rsi
leaq (%rsi,%rdx,4), %rdi
movq -0x38(%rbp), %rsi
leaq (%rsi,%rdx,4), %rdx
movslq (%rcx,%rax,4), %rbx
cmpq $0x1, %rbx
movq -0x88(%rbp), %r13
movq %rdi, -0x50(%rbp)
movq %rdx, -0x30(%rbp)
je 0x26a9
movq %r13, %rdi
callq 0x20fa
testl %ebx, %ebx
je 0x265e
movslq 0x2a91(%rip), %rax      # 0x50d4
leaq 0x2a86(%rip), %rcx      # 0x50d0
movslq (%rcx,%rbx,4), %rcx
subq %rcx, %rax
movq 0x2a70(%rip), %rcx      # 0x50c8
movl (%rcx,%rax,4), %r15d
jmp 0x2664
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movq -0x30(%rbp), %rdx
movl (%rdx,%r14,4), %esi
movq %r13, %rdi
movl %r15d, %edx
callq 0x20b4
movq -0x30(%rbp), %rcx
movl %eax, (%rcx,%r14,4)
movq -0x50(%rbp), %rax
movl (%rax,%r14,4), %esi
movq %r13, %rdi
movl %r15d, %edx
callq 0x20b4
movq -0x30(%rbp), %rdx
movq -0x50(%rbp), %rdi
movl %eax, (%rdi,%r14,4)
incq %r14
cmpq %r14, %r12
jne 0x266b
movq -0x48(%rbp), %rax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq -0x68(%rbp), %rax
incq %rax
movq %rax, -0x68(%rbp)
cmpq %r12, %rax
je 0x2781
movq -0xa8(%rbp), %r14
movq -0xa0(%rbp), %r13
movq -0x98(%rbp), %rcx
movq -0x48(%rbp), %rsi
movq %rcx, -0x80(%rbp)
addq %r12, %rsi
movq -0x38(%rbp), %rax
movq %rsi, -0x60(%rbp)
movl (%rax,%rsi,4), %r15d
testl %r15d, %r15d
je 0x2763
cmpl $0x1, %r15d
jne 0x2719
xorl %eax, %eax
movl (%rdx,%rax,4), %ecx
xorl %ecx, (%r14,%rax,4)
movl (%rdi,%rax,4), %ecx
xorl %ecx, (%r13,%rax,4)
incq %rax
cmpq %rax, %r12
jne 0x2700
jmp 0x2763
xorl %ebx, %ebx
movq -0x30(%rbp), %rax
movl (%rax,%rbx,4), %edx
movq -0x88(%rbp), %r12
movq %r12, %rdi
movl %r15d, %esi
callq 0x20b4
xorl %eax, (%r14,%rbx,4)
movq -0x50(%rbp), %rax
movl (%rax,%rbx,4), %edx
movq %r12, %rdi
movq -0x78(%rbp), %r12
movl %r15d, %esi
callq 0x20b4
movq -0x30(%rbp), %rdx
movq -0x50(%rbp), %rdi
xorl %eax, (%r13,%rbx,4)
incq %rbx
cmpq %rbx, %r12
jne 0x271b
movq -0x80(%rbp), %rcx
incq %rcx
movq -0x58(%rbp), %rax
addq %rax, %r13
addq %rax, %r14
cmpq %r12, %rcx
movq -0x60(%rbp), %rsi
jne 0x26e0
movq -0x48(%rbp), %rax
addl -0x8c(%rbp), %eax
movq %rax, -0x48(%rbp)
incq -0x98(%rbp)
movq -0xd8(%rbp), %r10
incq %r10
movq -0xb8(%rbp), %r15
addq -0xb0(%rbp), %r15
movq -0x58(%rbp), %rax
movq -0xc0(%rbp), %r14
addq %rax, %r14
movq -0xc8(%rbp), %rbx
addq %rax, %rbx
movq -0x70(%rbp), %r13
movq -0xd0(%rbp), %r11
addl %r13d, %r11d
addq %rax, -0xa0(%rbp)
addq %rax, -0xa8(%rbp)
movq -0x68(%rbp), %rdx
cmpq %r12, %rdx
jne 0x2558
testl %r13d, %r13d
jle 0x28cc
decl %r13d
leaq (,%r12,4), %rdx
leaq -0x1(%r12), %rax
imulq %r12, %rax
movq -0x40(%rbp), %rcx
leaq (%rcx,%rax,4), %rcx
movq %rdx, -0x80(%rbp)
negq %rdx
movq %rdx, -0x48(%rbp)
movq %r12, -0x60(%rbp)
movq -0x88(%rbp), %r15
movq %r13, -0x70(%rbp)
movq -0x60(%rbp), %rdx
leaq -0x1(%rdx), %rax
movq %rax, -0x60(%rbp)
movq %rdx, -0x58(%rbp)
cmpq $0x2, %rdx
jl 0x28b6
movq -0x38(%rbp), %rax
movq -0x60(%rbp), %rdx
leaq (%rax,%rdx,4), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %r14
xorl %eax, %eax
movq %rax, -0x30(%rbp)
imulq %r12, %rax
movq -0x50(%rbp), %rdx
movl (%rdx,%rax,4), %ebx
testl %ebx, %ebx
movq %r12, %r8
je 0x28a2
movq -0x50(%rbp), %rdx
movl $0x0, (%rdx,%rax,4)
xorl %r12d, %r12d
movl (%rcx,%r12,4), %edx
movq %r15, %rdi
movl %ebx, %esi
movq %rcx, %r13
callq 0x20b4
movq -0x78(%rbp), %r8
movq %r13, %rcx
xorl %eax, (%r14,%r12,4)
incq %r12
cmpq %r12, %r8
jne 0x287e
movq -0x30(%rbp), %rax
incq %rax
addq -0x80(%rbp), %r14
cmpq -0x70(%rbp), %rax
movq %r8, %r12
jne 0x285a
movq -0x70(%rbp), %r13
decq %r13
addq -0x48(%rbp), %rcx
cmpq $0x2, -0x58(%rbp)
jge 0x282a
movq -0x38(%rbp), %rdi
callq 0x10b0
movq -0x40(%rbp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa02(%rip), %rdi       # 0x32f4
callq 0x1100
movl $0x1, %edi
callq 0x10c0