// File: 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
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl $0x0, -0x94(%rbp)
movl $0x0, -0x98(%rbp)
movl $0x0, -0x9c(%rbp)
movl 0x1c(%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2190
movq %rax, -0x80(%rbp)
movl $0x0, -0xa0(%rbp)
movq -0xe0(%rbp), %rcx
movl -0xa0(%rbp), %eax
cmpl 0x1c(%rcx), %eax
jae 0x2ada
movq -0xe0(%rbp), %rax
movslq 0x20(%rax), %rdi
callq 0x2190
movq %rax, %rsi
movq -0xe0(%rbp), %rax
movq -0x80(%rbp), %rcx
movslq -0xa0(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq -0x80(%rbp), %rcx
movslq -0xa0(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq 0x20(%rax), %rdx
xorl %esi, %esi
callq 0x2090
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x2a74
movq -0xe0(%rbp), %rdi
movl 0x24(%rdi), %eax
movl %eax, -0x24(%rbp)
movl 0x8(%rdi), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %edx
callq 0x35a0
movq %rax, -0x10(%rbp)
movslq -0x1c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x2190
movq %rax, -0x38(%rbp)
movslq -0x1c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x2190
movq %rax, -0x40(%rbp)
movslq -0x1c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x2190
movq %rax, -0x48(%rbp)
movl -0x28(%rbp), %eax
addl -0x24(%rbp), %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x2190
movq %rax, -0x50(%rbp)
movl $0x0, -0xa4(%rbp)
movq -0xe0(%rbp), %rdx
movl -0xa4(%rbp), %eax
movl -0x28(%rbp), %ecx
addl 0x24(%rdx), %ecx
cmpl %ecx, %eax
jge 0x2bc9
movq -0xe0(%rbp), %rax
movslq 0x20(%rax), %rdi
callq 0x2190
movq %rax, %rsi
movq -0xe0(%rbp), %rax
movq -0x50(%rbp), %rcx
movslq -0xa4(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq -0x50(%rbp), %rcx
movslq -0xa4(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq 0x20(%rax), %rdx
xorl %esi, %esi
callq 0x2090
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x2b5e
movl $0x0, -0xa8(%rbp)
movq -0xe0(%rbp), %rdx
movl -0xa8(%rbp), %eax
movl 0x8(%rdx), %ecx
addl 0x24(%rdx), %ecx
cmpl %ecx, %eax
jae 0x2c66
movl $0x0, -0xac(%rbp)
movq -0xe0(%rbp), %rcx
movl -0xac(%rbp), %eax
cmpl 0x20(%rcx), %eax
jge 0x2c50
movq -0xe0(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0xa8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0xac(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x80(%rbp), %rax
movslq -0xa8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0xac(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x2bf4
jmp 0x2c52
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x2bd3
movl $0x0, -0x8c(%rbp)
movl $0x0, -0xb0(%rbp)
movl -0xb0(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0xe1(%rbp)
jge 0x2c9f
movl -0x8c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setl %al
movb %al, -0xe1(%rbp)
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0x2cae
jmp 0x2d7f
movq -0xe0(%rbp), %rax
movq 0x28(%rax), %rcx
movslq -0xb0(%rbp), %rdx
movl $0x1, %eax
cmpl (%rcx,%rdx,4), %eax
jne 0x2ce1
movq -0x48(%rbp), %rax
movslq -0xb0(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x2d69
movl -0x8c(%rbp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
movq -0x48(%rbp), %rax
movslq -0xb0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl $0x0, -0xb4(%rbp)
movq -0xe0(%rbp), %rcx
movl -0xb4(%rbp), %eax
cmpl 0x20(%rcx), %eax
jge 0x2d67
movq -0x80(%rbp), %rax
movslq -0xb0(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0xb4(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq -0xb0(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movq (%rax,%rcx,8), %rax
movslq -0xb4(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x2d0a
jmp 0x2d69
jmp 0x2d6b
movl -0xb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0x2c7a
movl $0x0, -0x8c(%rbp)
movl $0x0, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x2dd1
movq -0x48(%rbp), %rax
movslq -0xb8(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x2dbe
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x2dc0
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0x2d93
movl -0x8c(%rbp), %esi
leaq 0x2439(%rip), %rdi      # 0x5217
movb $0x0, %al
callq 0x2040
movq -0xe0(%rbp), %rax
movslq 0x20(%rax), %rdi
shlq $0x0, %rdi
callq 0x2190
movq %rax, -0x58(%rbp)
movl $0x0, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x2e48
movq -0x48(%rbp), %rax
movslq -0xbc(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
setne %al
andb $0x1, %al
movzbl %al, %edx
movq -0x38(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x2e07
movq -0xe0(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
callq 0x3f40
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x2edb
movq -0x48(%rbp), %rax
movslq -0xc0(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x2ec8
movq -0x48(%rbp), %rax
movq -0x60(%rbp), %rcx
movslq -0xc0(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
movq -0x48(%rbp), %rax
movslq -0xc0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x2eca
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x2e88
movq -0xe0(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x20(%rbp), %edx
callq 0x4200
movq %rax, -0x70(%rbp)
movl $0x0, -0xc4(%rbp)
movl $0x0, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x2f34
movq -0x40(%rbp), %rax
movslq -0xc8(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0x2f06
movl $0x0, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x3081
movq -0x60(%rbp), %rax
movslq -0xcc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x20(%rbp), %eax
jl 0x306b
movq -0xe0(%rbp), %rax
movq -0x58(%rbp), %rdi
movslq 0x20(%rax), %rdx
xorl %esi, %esi
callq 0x2090
movl $0x0, -0xd0(%rbp)
movl -0xd0(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x3048
movq -0xe0(%rbp), %rdi
movq -0x70(%rbp), %rax
movl -0xcc(%rbp), %ecx
imull -0x20(%rbp), %ecx
addl -0xd0(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %esi
movq -0x40(%rbp), %rax
movslq -0xd0(%rbp), %rcx
movl (%rax,%rcx,4), %edx
callq 0x3840
movq -0xe0(%rbp), %rdi
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %edx
movq -0x40(%rbp), %rax
movslq -0xd0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq -0xd0(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq (%rax,%rcx,8), %rsi
movl 0x20(%rdi), %edx
movl -0x30(%rbp), %ecx
callq 0x38c0
movq -0xe0(%rbp), %rdi
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq -0xd0(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x58(%rbp), %rdx
movl 0x20(%rdi), %ecx
callq 0x3990
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x2f84
movq -0xe0(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0xcc(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movq -0x58(%rbp), %rsi
movslq 0x20(%rax), %rdx
callq 0x20d0
jmp 0x306d
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x2f3e
movl $0x0, -0xd4(%rbp)
movq -0xe0(%rbp), %rdx
movl -0xd4(%rbp), %eax
movl 0x8(%rdx), %ecx
addl 0x24(%rdx), %ecx
cmpl %ecx, %eax
jae 0x30db
movq -0x80(%rbp), %rax
movslq -0xd4(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x30b6
jmp 0x30ca
movq -0x80(%rbp), %rax
movslq -0xd4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2160
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x308b
cmpq $0x0, -0x80(%rbp)
je 0x30eb
movq -0x80(%rbp), %rdi
callq 0x2160
movl $0x0, -0xd8(%rbp)
movq -0xe0(%rbp), %rdx
movl -0xd8(%rbp), %eax
movl 0x8(%rdx), %ecx
addl 0x24(%rdx), %ecx
cmpl %ecx, %eax
jae 0x3145
movq -0x50(%rbp), %rax
movslq -0xd8(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x3120
jmp 0x3134
movq -0x50(%rbp), %rax
movslq -0xd8(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2160
movl -0xd8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd8(%rbp)
jmp 0x30f5
cmpq $0x0, -0x50(%rbp)
je 0x3155
movq -0x50(%rbp), %rdi
callq 0x2160
addq $0xf0, %rsp
popq %rbp
retq
nop