// File: /workspace/github_cpp_makefile_star2_O3/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
movslq 0x8(%rdi), %r12
movl 0x1c(%rdi), %ecx
movl 0x24(%rdi), %eax
addl %r12d, %eax
movl %ecx, -0x34(%rbp)
cmpl %eax, %ecx
jne 0x16a9
movq %rdi, %rbx
leaq (,%r12,4), %rdi
movq %rdi, -0x58(%rbp)
callq 0x10e0
movq %rax, -0x48(%rbp)
movl 0x20(%rbx), %r14d
movslq %r14d, %r13
movq %r13, %rdi
callq 0x10e0
movq %rax, -0x50(%rbp)
leaq (,%r12,8), %rdi
callq 0x10e0
testl %r12d, %r12d
movq %rax, -0x30(%rbp)
jle 0x1567
movq %r13, %r15
movq %r12, %r13
xorl %r12d, %r12d
movl $0x1, %edi
movq %r15, %rsi
callq 0x1060
movq -0x30(%rbp), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
cmpq %r12, %r13
jne 0x14f3
testl %r13d, %r13d
movq %r13, %r12
movq -0x48(%rbp), %rdi
movq -0x30(%rbp), %r15
jle 0x1567
xorl %eax, %eax
testl %r14d, %r14d
jle 0x1549
movq (%r15,%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), %r14
cmpq %r14, %rdx
jl 0x152d
incq %rax
cmpq %r12, %rax
jne 0x1522
testl %r12d, %r12d
jle 0x1567
xorl %eax, %eax
movl $0x1, (%rdi,%rax,4)
incq %rax
cmpq %rax, %r12
jne 0x1558
movq %rbx, %rdi
movl -0x34(%rbp), %r14d
movl %r14d, %esi
movl %r12d, %edx
callq 0x1c04
movq %r12, -0x40(%rbp)
cmpl %r14d, %r12d
movq -0x50(%rbp), %r14
jge 0x1640
movq -0x40(%rbp), %r13
movl %r13d, %ecx
movq %rcx, -0x68(%rbp)
movq %r13, %rcx
imulq %r13, %rcx
leaq (%rax,%rcx,4), %r12
movslq 0x20(%rbx), %r15
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1050
cmpl $0x0, -0x40(%rbp)
jle 0x161c
movq %r13, -0x60(%rbp)
xorl %r13d, %r13d
movl (%r12,%r13,4), %r15d
testl %r15d, %r15d
je 0x160b
movq -0x48(%rbp), %r14
movl (%r14,%r13,4), %edx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1ea0
movl %r15d, (%r14,%r13,4)
movq -0x50(%rbp), %r14
movq -0x30(%rbp), %rcx
movq (%rcx,%r13,8), %r15
movl 0x20(%rbx), %edx
movq %rbx, %rdi
movq %r15, %rsi
movl %eax, %ecx
callq 0x1eec
movl 0x20(%rbx), %ecx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1f6e
incq %r13
cmpq %r13, -0x68(%rbp)
jne 0x15be
movslq 0x20(%rbx), %r15
movq -0x60(%rbp), %r13
movq 0x10(%rbx), %rax
movq (%rax,%r13,8), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1080
incq %r13
addq -0x58(%rbp), %r12
cmpl %r13d, -0x34(%rbp)
jne 0x15a0
cmpl $0x0, 0x8(%rbx)
je 0x167b
leaq 0x19ed(%rip), %r15      # 0x303a
xorl %r14d, %r14d
movq -0x30(%rbp), %r12
movq (%r12,%r14,8), %rdi
testq %rdi, %rdi
je 0x1664
callq 0x10c0
jmp 0x166e
movq %r15, %rdi
xorl %eax, %eax
callq 0x1040
incq %r14
movl 0x8(%rbx), %eax
cmpq %rax, %r14
jb 0x1654
jmp 0x1684
movq -0x30(%rbp), %r12
testq %r12, %r12
je 0x169a
movq %r12, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b69(%rip), %rdi      # 0x3219
callq 0x1110
movl $0x1, %edi
callq 0x10d0
nop