// File: /workspace/github_cpp_makefile_star2_O3/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 0x10e0
movq %rax, %r13
testq %r15, %r15
je 0x170e
movslq 0x20(%rbx), %r14
xorl %r12d, %r12d
movl $0x1, %edi
movq %r14, %rsi
callq 0x1060
movq %rax, (%r13,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0x16f4
movq %r13, -0x70(%rbp)
movslq 0x24(%rbx), %r12
movslq 0x8(%rbx), %r15
addq %r15, %r12
movq %rbx, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x1c04
movq %rax, -0x60(%rbp)
leaq (,%r12,4), %r14
movq %r14, %rdi
callq 0x10e0
movq %rax, -0x40(%rbp)
movq %r14, %rdi
callq 0x10e0
movq %rax, -0x38(%rbp)
movq %r14, %rdi
callq 0x10e0
movq %rax, -0x48(%rbp)
movq %r12, -0x30(%rbp)
leaq (,%r12,8), %rdi
callq 0x10e0
movq %rax, %r14
movl 0x24(%rbx), %eax
movq %rax, -0x58(%rbp)
movq %r15, -0x68(%rbp)
addl %r15d, %eax
jle 0x17a2
movslq 0x20(%rbx), %r15
movl %eax, %r12d
xorl %r13d, %r13d
movl $0x1, %edi
movq %r15, %rsi
callq 0x1060
movq %rax, (%r14,%r13,8)
incq %r13
cmpq %r13, %r12
jne 0x1789
movq %r14, -0x50(%rbp)
movl 0x8(%rbx), %edx
movq -0x58(%rbp), %rdi
movl %edi, %eax
addl %edx, %eax
movq -0x70(%rbp), %r13
movq -0x68(%rbp), %r15
movq -0x48(%rbp), %r9
movq -0x30(%rbp), %r10
je 0x17fe
movl 0x20(%rbx), %ecx
xorl %eax, %eax
testl %ecx, %ecx
jle 0x17f3
movq (%r13,%rax,8), %rdx
xorl %esi, %esi
movq 0x10(%rbx), %rcx
movq (%rcx,%rax,8), %rcx
movb (%rcx,%rsi), %cl
movb %cl, (%rdx,%rsi)
incq %rsi
movslq 0x20(%rbx), %rcx
cmpq %rcx, %rsi
jl 0x17d3
movl 0x8(%rbx), %edx
movl 0x24(%rbx), %edi
incq %rax
leal (%rdi,%rdx), %esi
cmpq %rsi, %rax
jb 0x17c8
testl %r10d, %r10d
setle %al
testl %r15d, %r15d
setle %cl
orb %al, %cl
jne 0x1868
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x28(%rbx), %rdx
cmpl $0x1, (%rdx,%rax,4)
jne 0x1826
movl $0xffffffff, (%r9,%rax,4) # imm = 0xFFFFFFFF
jmp 0x185b
leal 0x1(%rcx), %edx
movl %ecx, (%r9,%rax,4)
cmpl $0x0, 0x20(%rbx)
jle 0x1859
movq (%r13,%rax,8), %rsi
movslq %ecx, %rcx
movq -0x50(%rbp), %rdi
movq (%rdi,%rcx,8), %rcx
xorl %edi, %edi
movb (%rsi,%rdi), %r8b
movb %r8b, (%rcx,%rdi)
incq %rdi
movslq 0x20(%rbx), %r8
cmpq %r8, %rdi
jl 0x1845
movl %edx, %ecx
incq %rax
cmpq %r10, %rax
jge 0x1868
cmpl %r15d, %ecx
jl 0x1812
testl %r15d, %r15d
jle 0x188b
xorl %eax, %eax
xorl %esi, %esi
movq -0x38(%rbp), %r12
xorl %ecx, %ecx
cmpl $-0x1, (%r9,%rax,4)
sete %cl
addl %ecx, %esi
incq %rax
cmpq %rax, %r15
jne 0x1875
jmp 0x1891
xorl %esi, %esi
movq -0x38(%rbp), %r12
leaq 0x1882(%rip), %rdi      # 0x311a
xorl %eax, %eax
callq 0x1040
movslq 0x20(%rbx), %rdi
callq 0x10e0
movq -0x48(%rbp), %rdi
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rcx
movl %ecx, %r14d
testl %ecx, %ecx
movq -0x40(%rbp), %rdx
jle 0x18d6
xorl %eax, %eax
xorl %esi, %esi
cmpl $-0x1, (%rdi,%rax,4)
setne %sil
movl %esi, (%rdx,%rax,4)
incq %rax
cmpq %rax, %r14
jne 0x18c1
movq %rbx, %rdi
movq -0x60(%rbp), %rsi
movl %r15d, %r8d
callq 0x224e
movq -0x48(%rbp), %rdx
movq (%rax), %rsi
movq 0x8(%rax), %rdi
testl %r15d, %r15d
jle 0x190f
xorl %eax, %eax
cmpl $-0x1, (%rdx,%rax,4)
jne 0x1907
movslq (%rdi,%rax,4), %rcx
movl (%rdx,%rcx,4), %ecx
movl %ecx, (%rdx,%rax,4)
incq %rax
cmpq %rax, %r15
jne 0x18f7
movq %rdi, -0x40(%rbp)
movq %rbx, %rdi
movl %r15d, %edx
callq 0x2446
cmpl $0x0, -0x30(%rbp)
jle 0x1936
xorl %ecx, %ecx
movl $0x1, (%r12,%rcx,4)
incq %rcx
cmpq %rcx, %r14
jne 0x1926
testl %r15d, %r15d
movq -0x38(%rbp), %r14
movq -0x40(%rbp), %rcx
jle 0x1a0f
leaq (,%r15,4), %rdx
xorl %esi, %esi
movq %rdx, -0x58(%rbp)
cmpl %r15d, (%rcx,%rsi,4)
jl 0x1a00
movq %rsi, -0x60(%rbp)
movslq 0x20(%rbx), %rdx
movq %r14, %rdi
xorl %esi, %esi
movq %rax, -0x30(%rbp)
callq 0x1050
xorl %r13d, %r13d
movq -0x48(%rbp), %r15
movq -0x30(%rbp), %rax
movl (%rax,%r13,4), %r14d
movl (%r12,%r13,4), %edx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1ea0
movl %r14d, (%r12,%r13,4)
movslq (%r15,%r13,4), %rcx
movq -0x50(%rbp), %rdx
movq (%rdx,%rcx,8), %r14
movl 0x20(%rbx), %edx
movq %rbx, %rdi
movq %r14, %rsi
movl %eax, %ecx
callq 0x1eec
movl 0x20(%rbx), %ecx
movq %rbx, %rdi
movq %r14, %rsi
movq -0x38(%rbp), %r14
movq %r14, %rdx
callq 0x1f6e
incq %r13
cmpq %r13, -0x68(%rbp)
jne 0x197c
movslq 0x20(%rbx), %rdx
movq 0x10(%rbx), %rax
movq -0x60(%rbp), %r15
movq (%rax,%r15,8), %rdi
movq %r14, %rsi
callq 0x1080
movq %r15, %rsi
movq -0x70(%rbp), %r13
movq -0x68(%rbp), %r15
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rdx
incq %rsi
addq %rdx, %rax
cmpq %r15, %rsi
jne 0x1955
movl 0x8(%rbx), %r14d
movl 0x24(%rbx), %r15d
movl %r15d, %eax
addl %r14d, %eax
jne 0x1a26
testq %r13, %r13
jne 0x1a4c
jmp 0x1a54
xorl %r12d, %r12d
movq (%r13,%r12,8), %rdi
testq %rdi, %rdi
je 0x1a40
callq 0x10c0
movl 0x8(%rbx), %r14d
movl 0x24(%rbx), %r15d
incq %r12
leal (%r15,%r14), %eax
cmpq %rax, %r12
jb 0x1a29
movq %r13, %rdi
callq 0x10c0
movl %r15d, %eax
addl %r14d, %eax
jne 0x1a74
movq -0x50(%rbp), %r13
testq %r13, %r13
jne 0x1a9e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
movq -0x50(%rbp), %r13
movq (%r13,%r12,8), %rdi
testq %rdi, %rdi
je 0x1a92
callq 0x10c0
movl 0x8(%rbx), %r14d
movl 0x24(%rbx), %r15d
incq %r12
leal (%r15,%r14), %eax
cmpq %rax, %r12
jb 0x1a7b
movq %r13, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0