// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, %rbx
movl 0x1c(%rdi), %r15d
leaq (,%r15,8), %rdi
callq 0x10d0
movq %rax, %r13
testq %r15, %r15
je 0x16fe
movslq 0x20(%rbx), %r14
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x10d0
movq %rax, (%r13,%r12,8)
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x1050
incq %r12
cmpq %r12, %r15
jne 0x16dc
movq %r13, -0x38(%rbp)
movslq 0x24(%rbx), %r12
movslq 0x8(%rbx), %r15
addq %r15, %r12
movq %rbx, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x1bda
movq %rax, -0x58(%rbp)
leaq (,%r12,4), %r14
movq %r14, %rdi
callq 0x10d0
movq %rax, -0x48(%rbp)
movq %r14, %rdi
callq 0x10d0
movq %rax, -0x40(%rbp)
movq %r14, %rdi
callq 0x10d0
movq %rax, -0x50(%rbp)
movq %r12, -0x30(%rbp)
shlq $0x3, %r12
movq %r12, %rdi
callq 0x10d0
movq %rax, %r13
movl 0x24(%rbx), %eax
movq %r15, -0x60(%rbp)
addl %r15d, %eax
jle 0x1796
movslq 0x20(%rbx), %r15
movl %eax, %r14d
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x10d0
movq %rax, (%r13,%r12,8)
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1050
incq %r12
cmpq %r12, %r14
jne 0x1774
movl 0x24(%rbx), %eax
addl 0x8(%rbx), %eax
movq -0x60(%rbp), %r15
movq -0x50(%rbp), %r9
je 0x17e2
xorl %eax, %eax
cmpl $0x0, 0x20(%rbx)
jle 0x17d4
movq -0x38(%rbp), %rcx
movq (%rcx,%rax,8), %rcx
xorl %edx, %edx
movq 0x10(%rbx), %rsi
movq (%rsi,%rax,8), %rsi
movb (%rsi,%rdx), %sil
movb %sil, (%rcx,%rdx)
incq %rdx
movslq 0x20(%rbx), %rsi
cmpq %rsi, %rdx
jl 0x17b8
incq %rax
movl 0x24(%rbx), %ecx
addl 0x8(%rbx), %ecx
cmpq %rcx, %rax
jb 0x17a8
movq -0x30(%rbp), %rdx
testl %edx, %edx
setle %al
testl %r15d, %r15d
setle %cl
orb %al, %cl
movl %edx, %r14d
jne 0x1852
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x28(%rbx), %rdx
cmpl $0x1, (%rdx,%rax,4)
jne 0x1810
movl $0xffffffff, (%r9,%rax,4) # imm = 0xFFFFFFFF
jmp 0x1845
leal 0x1(%rcx), %edx
movl %ecx, (%r9,%rax,4)
cmpl $0x0, 0x20(%rbx)
jle 0x1843
movq -0x38(%rbp), %rsi
movq (%rsi,%rax,8), %rsi
movslq %ecx, %rcx
movq (%r13,%rcx,8), %rcx
xorl %edi, %edi
movb (%rsi,%rdi), %r8b
movb %r8b, (%rcx,%rdi)
incq %rdi
movslq 0x20(%rbx), %r8
cmpq %r8, %rdi
jl 0x182f
movl %edx, %ecx
incq %rax
cmpq %r14, %rax
jae 0x1852
cmpl %r15d, %ecx
jl 0x17fc
testl %r15d, %r15d
movq %r13, -0x68(%rbp)
jle 0x187d
xorl %eax, %eax
xorl %esi, %esi
movq -0x38(%rbp), %r13
movq -0x40(%rbp), %r12
xorl %ecx, %ecx
cmpl $-0x1, (%r9,%rax,4)
sete %cl
addl %ecx, %esi
incq %rax
cmpq %rax, %r15
jne 0x1867
jmp 0x1887
xorl %esi, %esi
movq -0x38(%rbp), %r13
movq -0x40(%rbp), %r12
leaq 0x188c(%rip), %rdi      # 0x311a
xorl %eax, %eax
callq 0x1040
movslq 0x20(%rbx), %rdi
callq 0x10d0
movq -0x50(%rbp), %rsi
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x30(%rbp)
movq -0x48(%rbp), %rdx
jle 0x18c6
xorl %eax, %eax
xorl %ecx, %ecx
cmpl $-0x1, (%rsi,%rax,4)
setne %cl
movl %ecx, (%rdx,%rax,4)
incq %rax
cmpq %rax, %r14
jne 0x18b2
movq %rbx, %rdi
movq -0x58(%rbp), %rsi
movq -0x30(%rbp), %rcx
movl %r15d, %r8d
callq 0x2206
movq -0x50(%rbp), %rdx
movq (%rax), %rsi
movq 0x8(%rax), %rdi
testl %r15d, %r15d
jle 0x1903
xorl %eax, %eax
cmpl $-0x1, (%rdx,%rax,4)
jne 0x18fb
movslq (%rdi,%rax,4), %rcx
movl (%rdx,%rcx,4), %ecx
movl %ecx, (%rdx,%rax,4)
incq %rax
cmpq %rax, %r15
jne 0x18eb
movq %rdi, -0x48(%rbp)
movq %rbx, %rdi
movl %r15d, %edx
callq 0x240c
cmpl $0x0, -0x30(%rbp)
jle 0x192a
xorl %ecx, %ecx
movl $0x1, (%r12,%rcx,4)
incq %rcx
cmpq %rcx, %r14
jne 0x191a
testl %r15d, %r15d
movq -0x40(%rbp), %r14
movq -0x48(%rbp), %rcx
jle 0x1a03
leaq (,%r15,4), %rdx
xorl %esi, %esi
movq %rdx, -0x70(%rbp)
cmpl %r15d, (%rcx,%rsi,4)
jl 0x19f4
movq %rsi, -0x58(%rbp)
movslq 0x20(%rbx), %rdx
movq %r14, %rdi
xorl %esi, %esi
movq %rax, -0x30(%rbp)
callq 0x1050
xorl %r13d, %r13d
movq -0x50(%rbp), %r15
movq -0x30(%rbp), %rax
movl (%rax,%r13,4), %r14d
movl (%r12,%r13,4), %edx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1e62
movl %r14d, (%r12,%r13,4)
movslq (%r15,%r13,4), %rcx
movq -0x68(%rbp), %rdx
movq (%rdx,%rcx,8), %r14
movl 0x20(%rbx), %edx
movq %rbx, %rdi
movq %r14, %rsi
movl %eax, %ecx
callq 0x1eae
movl 0x20(%rbx), %ecx
movq %rbx, %rdi
movq %r14, %rsi
movq -0x40(%rbp), %r14
movq %r14, %rdx
callq 0x1f30
incq %r13
cmpq %r13, -0x60(%rbp)
jne 0x1970
movq 0x10(%rbx), %rax
movq -0x58(%rbp), %r15
movq (%rax,%r15,8), %rdi
movslq 0x20(%rbx), %rdx
movq %r14, %rsi
callq 0x1070
movq %r15, %rsi
movq -0x38(%rbp), %r13
movq -0x60(%rbp), %r15
movq -0x48(%rbp), %rcx
movq -0x30(%rbp), %rax
movq -0x70(%rbp), %rdx
incq %rsi
addq %rdx, %rax
cmpq %r15, %rsi
jne 0x1949
movl 0x24(%rbx), %eax
addl 0x8(%rbx), %eax
movq -0x68(%rbp), %r15
je 0x1a2f
xorl %r14d, %r14d
movq (%r13,%r14,8), %rdi
testq %rdi, %rdi
je 0x1a21
callq 0x10b0
incq %r14
movl 0x24(%rbx), %eax
addl 0x8(%rbx), %eax
cmpq %rax, %r14
jb 0x1a12
testq %r13, %r13
je 0x1a3c
movq %r13, %rdi
callq 0x10b0
movl 0x24(%rbx), %eax
addl 0x8(%rbx), %eax
je 0x1a63
xorl %r14d, %r14d
movq (%r15,%r14,8), %rdi
testq %rdi, %rdi
je 0x1a55
callq 0x10b0
incq %r14
movl 0x24(%rbx), %eax
addl 0x8(%rbx), %eax
cmpq %rax, %r14
jb 0x1a47
testq %r15, %r15
je 0x1a7e
movq %r15, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop