// File: /workspace/github_cpp_makefile_star2_O2/syzcch[P]FEC_C_version/./fec_rs.h
// Function: rscode::decoding()
void decoding()
    {
        int *vdm;
        Condensed_Matrix *cm;
        int rows,cols;
        int m,n,tmp,factor;
        int *exists,*factors,*map;
        char **buffer,*block;
        int *id,*mat,*inv,k;
        char **buff;
        int index,i,j,ret;
        int xx=0;
        int js=0;
        int l=0;

        buff=(char **) malloc(sizeof(char *)*allNum);
        for (int i = 0; i < (allNum); i++)
        {
            buff[i] = (char *) malloc(stripe_unit_size);
            memset(buff[i],0,stripe_unit_size);
        }

        m=rsNum;
        n=num;
        cols=n;
        rows=m+n;
        vdm = gf_make_dispersal_matrix(rows, cols);
        exists = (int *) malloc(sizeof(int) * rows);

        factors = (int *) malloc(sizeof(int) * rows);

        map = (int *) malloc(sizeof(int) * rows);
        buffer = (char **) malloc(sizeof(char *)*(n+m));
        for (int i = 0; i < (n+rsNum); i++)
        {
            buffer[i] = (char *) malloc(stripe_unit_size);
            memset(buffer[i],0,stripe_unit_size);
        }

        for(int j=0; j<(num+rsNum); j++)
        {
            for(int i=0; i<stripe_unit_size; i++)
            {
                buff[j][i] = rs[j][i];
            }
        }

        j=0;
        for (int i = 0; i <rows && j <cols; i++)
        {
            if (1 == inthis[i])
            {
                map[i]=-1;
            }
            else
            {
                map[i] = j++;
                for(int l=0; l<stripe_unit_size; l++)
                {
                    buffer[map[i]][l]=buff[i][l];
                }
            }
        }

        j = 0;
        for (int i = 0; i < cols; i++)
        {
            if (map[i] == -1)
            {
                j++;  //map == -1 means data loss or data corruption
            }
        }

        printf("Blocks to decode: %d\n", j);
        block = (char *) malloc(sizeof(char)*stripe_unit_size);
        for (int i = 0; i < rows; i++)
        {
            exists[i] = (map[i] != -1);
        }
        cm = gf_condense_dispersal_matrix(vdm, exists, rows, cols);
        mat = cm->condensed_matrix;
        id = cm->row_identities;
        for (int i = 0; i < cols; i++)
        {
            if (map[i] == -1)
            {
                map[i] = map[id[i]];
            }
        }

        inv = gf_invert_matrix(mat, cols);
        int hh=0;
        for(int i = 0; i < rows; i++)
        {
            factors[i] = 1;
        }

        for (int i = 0; i < cols ; i++)
        {
            if (id[i] >= cols)
            {
                memset(block, 0, stripe_unit_size);
                for (int j = 0; j < cols; j++)
                {
                    tmp = inv[i*cols+j];
                    factor = gf_single_divide(tmp, factors[j]);

                    factors[j] = tmp;
                    gf_mult_region(buffer[map[j]], stripe_unit_size, factor);

                    gf_add_parity(buffer[map[j]], block, stripe_unit_size);
                }

                memcpy(rs[i],block,stripe_unit_size);
            }

        }

        for(int i=0; i<(num+rsNum); i++)
        {
            if(buff[i]==NULL)
            {
                continue;
            }
            free(buff[i]);
        }
        if(buff!=NULL) free(buff);

        for(int i=0; i<(num+rsNum); i++)
        {
            if(buffer[i]==NULL)
            {
                continue;
            }
            free(buffer[i]);
        }
        if(buffer!=NULL)
        {
            free(buffer);
        }

    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movl 0x1c(%rdi), %r14d
leaq (,%r14,8), %rdi
callq 0x10f0
movq %rax, -0x50(%rbp)
movslq 0x20(%rbx), %r15
xorl %r13d, %r13d
pushq $0x1
popq %r12
cmpq %r13, %r14
je 0x16af
movq %r12, %rdi
movq %r15, %rsi
callq 0x1070
movq -0x50(%rbp), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
jmp 0x1692
movslq 0x24(%rbx), %r12
movl 0x8(%rbx), %r14d
movslq %r14d, %rdx
addq %rdx, %r12
movq %rbx, %rdi
movl %r12d, %esi
movq %rdx, -0x68(%rbp)
callq 0x1ba4
movq %rax, -0x78(%rbp)
leaq (,%r12,4), %r15
movq %r15, %rdi
callq 0x10f0
movq %rax, -0x48(%rbp)
movq %r15, %rdi
callq 0x10f0
movq %rax, -0x80(%rbp)
movq %r15, %rdi
callq 0x10f0
movq %rax, -0x30(%rbp)
movq %r12, -0x58(%rbp)
leaq (,%r12,8), %rdi
callq 0x10f0
movq %rax, -0x40(%rbp)
movl 0x20(%rbx), %r13d
movl 0x24(%rbx), %r12d
movq %r14, -0x70(%rbp)
addl %r12d, %r14d
movslq %r13d, %rax
movq %rax, -0x38(%rbp)
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
cmpq %r15, %r14
je 0x174f
pushq $0x1
popq %rdi
movq -0x38(%rbp), %rsi
callq 0x1070
movq -0x40(%rbp), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
jmp 0x1731
xorl %eax, %eax
movq -0x50(%rbp), %r9
movq -0x70(%rbp), %r10
movq -0x58(%rbp), %r15
addl 0x8(%rbx), %r12d
cmpq %r12, %rax
jae 0x1794
xorl %ecx, %ecx
movslq %r13d, %rdx
cmpq %rdx, %rcx
jge 0x178b
movq 0x10(%rbx), %rdx
movq (%rdx,%rax,8), %rdx
movb (%rdx,%rcx), %dl
movq (%r9,%rax,8), %rsi
movb %dl, (%rsi,%rcx)
incq %rcx
movl 0x20(%rbx), %r13d
jmp 0x1768
incq %rax
movl 0x24(%rbx), %r12d
jmp 0x175d
xorl %eax, %eax
xorl %ecx, %ecx
cmpq %r15, %rax
jge 0x17ee
cmpl %r10d, %ecx
jge 0x17ee
movq 0x28(%rbx), %rdx
cmpl $0x1, (%rdx,%rax,4)
jne 0x17b6
movq -0x30(%rbp), %rdx
orl $-0x1, (%rdx,%rax,4)
jmp 0x17e9
movq -0x30(%rbp), %rdx
movl %ecx, (%rdx,%rax,4)
movslq %ecx, %rdx
xorl %esi, %esi
movslq %r13d, %rdi
cmpq %rdi, %rsi
jge 0x17e7
movq (%r9,%rax,8), %rdi
movb (%rdi,%rsi), %dil
movq -0x40(%rbp), %r8
movq (%r8,%rdx,8), %r8
movb %dil, (%r8,%rsi)
incq %rsi
movl 0x20(%rbx), %r13d
jmp 0x17c2
incl %ecx
incq %rax
jmp 0x1798
xorl %eax, %eax
testl %r10d, %r10d
movl $0x0, %edi
cmovgl %r10d, %edi
xorl %esi, %esi
movq -0x30(%rbp), %rdx
cmpq %rax, %rdi
je 0x1817
xorl %ecx, %ecx
cmpl $-0x1, (%rdx,%rax,4)
sete %cl
addl %ecx, %esi
incq %rax
jmp 0x1802
movq %rdi, -0x60(%rbp)
leaq 0x18f8(%rip), %rdi      # 0x311a
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x1040
movslq 0x20(%rbx), %rdi
callq 0x10f0
movq %rax, -0x38(%rbp)
testl %r15d, %r15d
movl $0x0, %r12d
cmovgl %r15d, %r12d
movq -0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
cmpq %r14, %r12
je 0x1866
xorl %eax, %eax
cmpl $-0x1, (%rcx,%r14,4)
setne %al
movl %eax, (%rdx,%r14,4)
incq %r14
jmp 0x184e
movq %rbx, %rdi
movq -0x78(%rbp), %rsi
movl %r15d, %ecx
movq -0x70(%rbp), %r14
movl %r14d, %r8d
callq 0x21c6
movq (%rax), %rsi
movq 0x8(%rax), %r8
xorl %eax, %eax
movq -0x60(%rbp), %rdi
movq -0x30(%rbp), %rdx
cmpq %rax, %rdi
je 0x18ab
movq -0x30(%rbp), %rcx
cmpl $-0x1, (%rcx,%rax,4)
jne 0x18a6
movslq (%r8,%rax,4), %rcx
movl (%rdx,%rcx,4), %ecx
movl %ecx, (%rdx,%rax,4)
incq %rax
jmp 0x188d
movq %r8, -0x48(%rbp)
movq %rbx, %rdi
movl %r14d, %edx
callq 0x238e
movq %rax, -0x58(%rbp)
xorl %eax, %eax
movq -0x68(%rbp), %rcx
movq -0x80(%rbp), %rdx
cmpq %rax, %r12
je 0x18d9
movl $0x1, (%rdx,%rax,4)
incq %rax
jmp 0x18c8
movl %r14d, %r12d
shlq $0x2, %rcx
xorl %esi, %esi
movq -0x60(%rbp), %rax
movq -0x48(%rbp), %rdx
movq %rcx, -0x68(%rbp)
movq -0x80(%rbp), %r15
cmpq %rax, %rsi
je 0x19aa
cmpl %r14d, (%rdx,%rsi,4)
jl 0x199e
movq %rsi, -0x78(%rbp)
movslq 0x20(%rbx), %rdx
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1060
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x1972
movq -0x58(%rbp), %rax
movl (%rax,%r14,4), %r13d
movl (%r15,%r14,4), %edx
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1dc0
movl %r13d, (%r15,%r14,4)
movq -0x30(%rbp), %rcx
movslq (%rcx,%r14,4), %rcx
movq -0x40(%rbp), %rdx
movq (%rdx,%rcx,8), %r13
movl 0x20(%rbx), %edx
movq %rbx, %rdi
movq %r13, %rsi
movl %eax, %ecx
callq 0x1e0a
movl 0x20(%rbx), %ecx
movq %rbx, %rdi
movq %r13, %rsi
movq -0x38(%rbp), %rdx
callq 0x1e8c
incq %r14
jmp 0x191b
movq 0x10(%rbx), %rax
movq -0x78(%rbp), %r14
movq (%rax,%r14,8), %rdi
movslq 0x20(%rbx), %rdx
movq -0x38(%rbp), %rsi
callq 0x1090
movq %r14, %rsi
movq -0x70(%rbp), %r14
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %rax
movq -0x48(%rbp), %rdx
incq %rsi
addq %rcx, -0x58(%rbp)
jmp 0x18f2
xorl %r12d, %r12d
movl 0x8(%rbx), %r15d
movl 0x24(%rbx), %r14d
leal (%r14,%r15), %eax
cmpq %rax, %r12
jae 0x19d0
movq -0x50(%rbp), %rax
movq (%rax,%r12,8), %rdi
callq 0x10d0
incq %r12
jmp 0x19ad
movq -0x50(%rbp), %rdi
callq 0x10d0
xorl %r12d, %r12d
addl %r15d, %r14d
cmpq %r14, %r12
jae 0x19fe
movq -0x40(%rbp), %rax
movq (%rax,%r12,8), %rdi
callq 0x10d0
incq %r12
movl 0x8(%rbx), %r15d
movl 0x24(%rbx), %r14d
jmp 0x19dc
movq -0x40(%rbp), %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10d0
nop