// File: /workspace/github_cpp_makefile_star2_O1/syzcch[P]FEC_C_version/./fec_rs.h
// Function: rscode::encoding()
void encoding()
    {
        int cols,rows;
        int factor=0,*factors;
        int *vdm,tmp;
        int z=rsNum,n=0;
        unsigned int fl=(num-1);
        int i=0,j=0;
        char *block;
        char **buffer;
        int l=0;
        int numx=num;

        if(allNum != num + rsNum)
        {
            printf("the addition of data disk num and checksum disk num should equal to allNum \n");
            exit(1);
        }

        n=num;
        cols=n;
        rows=z+n;
        factors = (int *) malloc(sizeof(int)*n);
        block=(char *) malloc(sizeof(char)*stripe_unit_size);
        buffer = (char **) malloc(sizeof(char *)*n);
        for (int i = 0; i < n; i++)
        {
            buffer[i] = (char *) malloc(stripe_unit_size);
            memset(buffer[i], 0, stripe_unit_size);
        }

        for(int i=0; i<n; i++)
        {
            for(int l=0; l<stripe_unit_size; l++)
            {
                buffer[i][l]=rs[i][l];
            }
        }

        for (int i = 0; i < n; i++)
        {
            factors[i] = 1;
        }

        vdm = gf_make_dispersal_matrix(rows, cols);

        for (int i = cols ; i< rows; i++)
        {
            memset(block, 0, stripe_unit_size);
            for (int j = 0; j < cols; j++)
            {
                tmp = vdm[i*cols+j];
                if (0 != tmp)
                {
                    factor = gf_single_divide(tmp, factors[j]);
                    factors[j] = tmp;
                    gf_mult_region(buffer[j], stripe_unit_size, factor);
                    gf_add_parity(buffer[j], block, stripe_unit_size);// do parity check
                }
            }

            memcpy(rs[numx],block,stripe_unit_size);
            numx++;
        }

        for(int i=0; i<num; i++)
        {
            if(buffer[i] == NULL)
            {
                printf(" already free ** \n ");
                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
movl 0x24(%rdi), %eax
movslq 0x8(%rdi), %r13
movq %rax, -0x30(%rbp)
addl %r13d, %eax
movl %eax, -0x38(%rbp)
cmpl %eax, 0x1c(%rdi)
jne 0x1692
movq %rdi, %rbx
leaq (,%r13,4), %rdi
movq %rdi, -0x60(%rbp)
callq 0x10d0
movq %rax, -0x48(%rbp)
movslq 0x20(%rbx), %r15
movq %r15, %rdi
callq 0x10d0
movq %rax, -0x40(%rbp)
leaq (,%r13,8), %rdi
callq 0x10d0
movq %rax, %r12
testl %r13d, %r13d
jle 0x14fa
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x10d0
movq %rax, (%r12,%r14,8)
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1050
incq %r14
cmpq %r14, %r13
jne 0x14d9
testl %r13d, %r13d
jle 0x1531
xorl %eax, %eax
cmpl $0x0, 0x20(%rbx)
jle 0x1529
movq (%r12,%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 0x150d
incq %rax
cmpq %r13, %rax
jne 0x1501
movq %r12, -0x50(%rbp)
testl %r13d, %r13d
movq -0x48(%rbp), %rcx
jle 0x154f
xorl %eax, %eax
movl $0x1, (%rcx,%rax,4)
incq %rax
cmpq %rax, %r13
jne 0x1540
movq %rbx, %rdi
movl -0x38(%rbp), %r14d
movl %r14d, %esi
movl %r13d, %edx
callq 0x1bda
cmpl %r14d, %r13d
movq -0x40(%rbp), %r14
jge 0x162f
movq -0x30(%rbp), %rcx
addl %r13d, %ecx
movq %rcx, -0x30(%rbp)
movl %r13d, %ecx
movq %rcx, -0x38(%rbp)
movq %r13, %rcx
imulq %r13, %rcx
leaq (%rax,%rcx,4), %r12
movq %r13, %r15
movq %r13, -0x58(%rbp)
movq %r15, -0x68(%rbp)
movslq 0x20(%rbx), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x1050
testl %r13d, %r13d
jle 0x1602
xorl %r13d, %r13d
movl (%r12,%r13,4), %r15d
testl %r15d, %r15d
je 0x15f9
movq -0x48(%rbp), %r14
movl (%r14,%r13,4), %edx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1e62
movl %r15d, (%r14,%r13,4)
movq -0x40(%rbp), %r14
movq -0x50(%rbp), %rcx
movq (%rcx,%r13,8), %r15
movl 0x20(%rbx), %edx
movq %rbx, %rdi
movq %r15, %rsi
movl %eax, %ecx
callq 0x1eae
movl 0x20(%rbx), %ecx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1f30
incq %r13
cmpq %r13, -0x38(%rbp)
jne 0x15ac
movq 0x10(%rbx), %rax
movq -0x68(%rbp), %r15
movq (%rax,%r15,8), %rdi
movslq 0x20(%rbx), %rdx
movq %r14, %rsi
callq 0x1070
incq %r15
addq -0x60(%rbp), %r12
cmpl %r15d, -0x30(%rbp)
movq -0x58(%rbp), %r13
jne 0x1592
cmpl $0x0, 0x8(%rbx)
movq -0x50(%rbp), %r12
je 0x1668
leaq 0x19fa(%rip), %r15      # 0x303a
xorl %r14d, %r14d
movq (%r12,%r14,8), %rdi
testq %rdi, %rdi
je 0x1653
callq 0x10b0
jmp 0x165d
movq %r15, %rdi
xorl %eax, %eax
callq 0x1040
incq %r14
movl 0x8(%rbx), %eax
cmpq %rax, %r14
jb 0x1643
testq %r12, %r12
je 0x1683
movq %r12, %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
leaq 0x1b80(%rip), %rdi      # 0x3219
callq 0x1100
movl $0x1, %edi
callq 0x10c0