// File: 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
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdx
movq %rdx, -0x80(%rbp)
movl $0x0, -0x14(%rbp)
movl 0x24(%rdx), %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl 0x8(%rdx), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x54(%rbp)
movl 0x8(%rdx), %eax
movl %eax, -0x58(%rbp)
movl 0x1c(%rdx), %eax
movl 0x8(%rdx), %ecx
addl 0x24(%rdx), %ecx
cmpl %ecx, %eax
je 0x2774
leaq 0x28d7(%rip), %rdi      # 0x503a
movb $0x0, %al
callq 0x2040
movl $0x1, %edi
callq 0x2170
movq -0x80(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x10(%rbp)
movslq -0x34(%rbp), %rdi
shlq $0x2, %rdi
callq 0x2190
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, -0x20(%rbp)
movslq 0x20(%rax), %rdi
shlq $0x0, %rdi
callq 0x2190
movq %rax, -0x48(%rbp)
movslq -0x34(%rbp), %rdi
shlq $0x3, %rdi
callq 0x2190
movq %rax, -0x50(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x2818
movq -0x80(%rbp), %rax
movslq 0x20(%rax), %rdi
callq 0x2190
movq %rax, %rsi
movq -0x80(%rbp), %rax
movq -0x50(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq -0x50(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq 0x20(%rax), %rdx
xorl %esi, %esi
callq 0x2090
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x27ce
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x287c
movl $0x0, -0x64(%rbp)
movq -0x80(%rbp), %rcx
movl -0x64(%rbp), %eax
cmpl 0x20(%rcx), %eax
jge 0x286f
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x64(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x50(%rbp), %rax
movslq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x64(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x282e
jmp 0x2871
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x281f
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x28a5
movq -0x20(%rbp), %rax
movslq -0x68(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x2883
movq -0x80(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0xc(%rbp), %edx
callq 0x35a0
movq %rax, -0x28(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x29b1
movq -0x80(%rbp), %rax
movq -0x48(%rbp), %rdi
movslq 0x20(%rax), %rdx
xorl %esi, %esi
callq 0x2090
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x297d
movq -0x28(%rbp), %rax
movl -0x6c(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x70(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
cmpl -0x2c(%rbp), %eax
je 0x296d
movq -0x80(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x20(%rbp), %rax
movslq -0x70(%rbp), %rcx
movl (%rax,%rcx,4), %edx
callq 0x3840
movq -0x80(%rbp), %rdi
movl %eax, -0x14(%rbp)
movl -0x2c(%rbp), %edx
movq -0x20(%rbp), %rax
movslq -0x70(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movl 0x20(%rdi), %edx
movl -0x14(%rbp), %ecx
callq 0x38c0
movq -0x80(%rbp), %rdi
movq -0x50(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x48(%rbp), %rdx
movl 0x20(%rdi), %ecx
callq 0x3990
jmp 0x296f
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x28e4
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x58(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movq -0x48(%rbp), %rsi
movslq 0x20(%rax), %rdx
callq 0x20d0
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x28be
movl $0x0, -0x74(%rbp)
movq -0x80(%rbp), %rcx
movl -0x74(%rbp), %eax
cmpl 0x8(%rcx), %eax
jae 0x29ff
movq -0x50(%rbp), %rax
movslq -0x74(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x29e3
leaq 0x26ad(%rip), %rdi      # 0x5087
movb $0x0, %al
callq 0x2040
jmp 0x29f4
movq -0x50(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2160
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x29b8
cmpq $0x0, -0x50(%rbp)
je 0x2a0f
movq -0x50(%rbp), %rdi
callq 0x2160
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)