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sIGxvZ2ZhYzI7CQkvKiBsb2cgZmFjaWxpdHkgZm9yIGJvdGggc2VydmVycy4gLTEgPSBkaXNhYmxlZCAqLworICAgIGludCB0b19sb2c7CQkJCS8qIHRoaW5ncyB0byBiZSBsb2dnZWQgKExXXyopICovCiAgICAgc3RydWN0IHRpbWV2YWwgc3RvcF90aW1lOwkJLyogZGF0ZSB0byBzdG9wIGxpc3RlbmluZywgd2hlbiBzdG9wcGluZyAhPSAwICovCiAgICAgaW50IG5iX3JlcWFkZCwgbmJfcnNwYWRkOwogICAgIHN0cnVjdCBoZHJfZXhwICpyZXFfZXhwOwkJLyogcmVndWxhciBleHByZXNzaW9ucyBmb3IgcmVxdWVzdCBoZWFkZXJzICovCkBAIC00MjQsMTIgKzQ1NywyOCBAQAogCiAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwogCi1pbnQgY2ZnX21heGNvbm4gPSAyMDAwOwkJLyogIyBvZiBzaW11bHRhbmVvdXMgY29ubmVjdGlvbnMsICgtbikgKi8KIGludCBjZmdfbWF4cGNvbm4gPSAyMDAwOwkvKiAjIG9mIHNpbXVsdGFuZW91cyBjb25uZWN0aW9ucyBwZXIgcHJveHkgKC1OKSAqLwotaW50IGNmZ19tYXhzb2NrID0gMDsJCS8qIG1heCAjIG9mIHNvY2tldHMgKi8KIGNoYXIgKmNmZ19jZmdmaWxlID0gTlVMTDsJLyogY29uZmlndXJhdGlvbiBmaWxlICovCiBjaGFyICpwcm9nbmFtZSA9IE5VTEw7CQkvKiBwcm9ncmFtIG5hbWUgKi8KIGludCAgcGlkOwkJCS8qIGN1cnJlbnQgcHJvY2VzcyBpZCAqLworCisvKiBnbG9iYWwgb3B0aW9ucyAqLworc3RhdGljIHN0cnVjdCB7CisgICAgaW50IHVpZDsKKyAgICBpbnQgZ2lkOworICAgIGludCBuYnByb2M7CisgICAgaW50IG1heGNvbm47CisgICAgaW50IG1heHNvY2s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