function res = ChangeCheck2MReg(Zc,Layer,path,filename)
%ChangeCheck2MReg:将算法给出的校验结果按照测试代码的输出进行拆分、排序
%   Layer:      层索引,BG1校验过程为前4层,Layer = 1:4
%   Zc:         LDPC提升值,仅支持Zc = 8n
%   path:       文件路径
%   filename:   文件名
    ACodeBlockIndex = [1	2	3	5	6	7	12	13	15	18	20	24	26];
    BCodeBlockIndex = [4	8	9	10	11	14	16	17	19	21	22	23	25];
    CBIndex{1} = [1     2     3     4     6     7    10    11    12    13    14    16    17    19    20    21    22    23    24];
    CBIndex{2} = [1     3     4     5     6     8     9    10    12    13    15    16    17    18    20    22    23    24    25];
    CBIndex{3} = [1     2     3     5     6     7     8     9    10    11    14    15    16    18    19    20    21    25    26];
    CBIndex{4} = [1     2     4     5     7     8     9    11    12    13    14    15    17    18    19    21    22    23    26];
    res = 0;
    if mod(Zc,8)
        res = -1;
        fprintf('illegal Zc(%d).\n',Zc);
        return;
    end    
    CBByteLen = Zc/8;
    Data = u32DataFromFile(path,filename);
    Data = Int32ToInt8(Data);
    DotIndex = find(filename == '.');
    Afilename_mreg = [filename(1:DotIndex-1) '_Amreg' filename(DotIndex:end)];
    Bfilename_mreg = [filename(1:DotIndex-1) '_Bmreg' filename(DotIndex:end)];
    
    Afid = fopen([path Afilename_mreg],'w');
    if -1 == Afid
        fprintf('write %s filled.\n',Afilename_mreg);
        res = -1;
        return;
    end
    Bfid = fopen([path Bfilename_mreg],'w');
    if -1 == Afid
        fprintf('write %s filled.\n',Afilename_mreg);
        res = -1;
        return;
    end
    
    Data = Data(1:CBByteLen*19);
    Data = reshape(Data,CBByteLen,19);
    tmpZero = zeros(64-CBByteLen,19);
    Data = [Data;tmpZero];
    AIndex = find(ismember(CBIndex{Layer},ACodeBlockIndex)~=0);
    BIndex = find(ismember(CBIndex{Layer},BCodeBlockIndex)~=0);
    AData = Data(:,AIndex);
    BData = Data(:,BIndex);
    AData = reshape(AData,1,[]);
    BData = reshape(BData,1,[]);
    AData = Int8ToInt32(AData);
    BData = Int8ToInt32(BData);
    fprintf(Afid,'0x%08x\n',AData);
    fprintf(Bfid,'0x%08x\n',BData);
    fclose(Afid);fclose(Bfid);    
end

