From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18435 invoked by alias); 7 Jan 2007 19:12:22 -0000 Received: (qmail 18424 invoked by uid 22791); 7 Jan 2007 19:12:19 -0000 X-Spam-Check-By: sourceware.org Received: from nf-out-0910.google.com (HELO nf-out-0910.google.com) (64.233.182.190) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 07 Jan 2007 19:12:15 +0000 Received: by nf-out-0910.google.com with SMTP id a25so878094nfc for ; Sun, 07 Jan 2007 11:12:12 -0800 (PST) Received: by 10.82.111.8 with SMTP id j8mr2495515buc.1168197132335; Sun, 07 Jan 2007 11:12:12 -0800 (PST) Received: by 10.82.150.13 with HTTP; Sun, 7 Jan 2007 11:12:12 -0800 (PST) Message-ID: <84fc9c000701071112l487e1120vefb4083d60ec771a@mail.gmail.com> Date: Sun, 07 Jan 2007 19:12:00 -0000 From: "Richard Guenther" To: "Gcc Patch List" Subject: [PATCH][RFC] Rework int_const_binop, fix PR30318, VRP not creating anti-ranges for overflowing +/- MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_72618_2104195.1168197132241" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-01/txt/msg00517.txt.bz2 ------=_Part_72618_2104195.1168197132241 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 2827 This addresses PR30318 that is about VRP not creating anti-ranges out of overflowing PLUS/MINUS_EXPR. Fixing this PR can possibly make removing undefined signed overflow assumptions from VRP less harmful. In order to do so this patch enhances certain parts of VRP to handle anti-ranges better and canonicalizes certain anti-ranges back to ranges. In the quest to tackle this PR I have started to re-work int_const_binop to get rid of the vrp_int_const_binop wrapper in VRP. What this patch does is expose the new proposed interface under a different name and not touch the old one (to keep patch size down). The new interface get's rid of the nearly unused "notrunc" argument (and so always force_fits_type), adds a type argument and a second output, a boolean whether the operation overflowed (regardless of definedness or undefinedness). This avoids creating a new node just to set the overflow flag and also allows tracking overflow for unsigned types just as vrp_int_const_binop tried to do. A new force_fit_type_1 was added to allow tracking of unsigned overflow here. We can implement both old interfaces, int_const_binop and force_fit_type using the new helpers, but I didn't yet change those to keep the patch small. Suggestions for a better name for int_const_binop_1 welcome ;) Note that I will split out the fold-const.c parts into a separate patch if the general idea is ok - I just included them with the VRP patch to make the intended use visible. Bootstrapped and tested on x86_64-unknown-linux-gnu. Note this patch relies on wrapping types wrapping in two's complement way. I have no idea how for example Ada types with range [1, 11] is supposed to "wrap" -- with the patch we assume that adding 5 to a range [10,10] will result in [15, 15] as it wraps according to TYPE_PRECISION, not TYPE_MIN/MAX_VALUE. So this part of the VRP patch needs to be guarded appropriately - I'm just wondering about the Ada semantics here. Comments? Thanks, Richard. 2007-01-07 Richard Guenther PR tree-optimization/30318 * tree.h (int_const_binop_1): Export. * fold-const.c (force_fit_type_1): New static function. (int_const_binop_1): New function. * tree-vrp.c (set_value_range): Canonicalize anti-ranges to ranges where possible. (extract_range_from_assert): Merge anti-ranges if possible. (vrp_int_const_binop): Remove. (extract_range_from_binary_expr): Separate MIN_EXPR and MAX_EXPR cases, merge PLUS_EXPR and MINUS_EXPR cases. Handle cases where PLUS_EXPR and MINUS_EXPR create an anti-range. Replace uses of vrp_int_const_binop by int_const_binop_1. (compare_range_with_value): Handle anti-range with no valid value. * gcc.dg/tree-ssa/vrp31.c: New testcase. ------=_Part_72618_2104195.1168197132241 Content-Type: text/x-patch; name=fix-pr30318.diff; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: base64 X-Attachment-Id: f_ewntehtr Content-Disposition: attachment; filename="fix-pr30318.diff" Content-length: 36332 MjAwNy0wMS0wNyAgUmljaGFyZCBHdWVudGhlciAgPHJndWVudGhlckBzdXNl LmRlPgoKCVBSIHRyZWUtb3B0aW1pemF0aW9uLzMwMzE4CgkqIHRyZW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kgIT0gMDsKKyAgICAgICBoaWdoICY9IH4oKEhPU1RfV0lERV9JTlQpICgt MSkgPDwgKHByZWMgLSBIT1NUX0JJVFNfUEVSX1dJREVfSU5UKSk7CisgICAg IH0KKyAgIGVsc2UKKyAgICAgeworICAgICAgIG92ZXJmbG93ID0gaGlnaCAh PSAwOworICAgICAgIGhpZ2ggPSAwOworICAgICAgIGlmIChwcmVjIDwgSE9T VF9CSVRTX1BFUl9XSURFX0lOVCkKKyAgICAgICAgIHsKKyAJICBvdmVyZmxv dyB8PSAobG93ICYgKChIT1NUX1dJREVfSU5UKSAoLTEpIDw8IHByZWMpKSAh PSAwOworIAkgIGxvdyAmPSB+KChIT1NUX1dJREVfSU5UKSAoLTEpIDw8IHBy ZWMpOworIAl9CisgICAgIH0KKyAKKyAgIGlmICghc2lnbl9leHRlbmRlZF90 eXBlKQorICAgICAvKiBObyBzaWduIGV4dGVuc2lvbiAqLzsKKyAgIGVsc2Ug aWYgKHByZWMgPj0gMiAqIEhPU1RfQklUU19QRVJfV0lERV9JTlQpCisgICAg IC8qIENvcnJlY3Qgd2lkdGggYWxyZWFkeS4gICovOworICAgZWxzZSBpZiAo cHJlYyA+IEhPU1RfQklUU19QRVJfV0lERV9JTlQpCisgICAgIHsKKyAgICAg ICAvKiBTaWduIGV4dGVuZCB0b3AgaGFsZj8gKi8KKyAgICAgICBpZiAoaGln aCAmICgodW5zaWduZWQgSE9TVF9XSURFX0lOVCkxCisgCQkgIDw8IChwcmVj IC0gSE9TVF9CSVRTX1BFUl9XSURFX0lOVCAtIDEpKSkKKyAJaGlnaCB8PSAo SE9TVF9XSURFX0lOVCkgKC0xKSA8PCAocHJlYyAtIEhPU1RfQklUU19QRVJf V0lERV9JTlQpOworICAgICB9CisgICBlbHNlIGlmIChwcmVjID09IEhPU1Rf QklUU19QRVJfV0lERV9JTlQpCisgICAgIHsKKyAgICAgICBpZiAoKEhPU1Rf V0lERV9JTlQpbG93IDwgMCkKKyAJaGlnaCA9IC0xOwor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J REVfSU5UIGludDFsLCBpbnQybDsKKyAgIEhPU1RfV0lERV9JTlQgaW50MWgs IGludDJoOworICAgdW5zaWduZWQgSE9TVF9XSURFX0lOVCBsb3c7CisgICBI T1NUX1dJREVfSU5UIGhpOworICAgdW5zaWduZWQgSE9TVF9XSURFX0lOVCBn YXJiYWdlbDsKKyAgIEhPU1RfV0lERV9JTlQgZ2FyYmFnZWg7CisgICBpbnQg dW5zID0gVFlQRV9VTlNJR05FRCAodHlwZSk7CisgICB0cmVlIHQ7CisgICBp bnQgb3ZlcmZsb3cgPSAwOworIAorICAgaW50MWwgPSBUUkVFX0lOVF9DU1Rf TE9XIChhcmcxKTsKKyAgIGludDFoID0gVFJFRV9JTlRfQ1NUX0hJR0ggKGFy ZzEpOworICAgaW50MmwgPSBUUkVFX0lOVF9DU1RfTE9XIChhcmcyKTsKKyAg IGludDJoID0gVFJFRV9JTlRfQ1NUX0hJR0ggKGFyZzIpOworIAorICAgc3dp dGNoIChjb2RlKQorICAgICB7CisgICAgIGNhc2UgQklUX0lPUl9FWFBSOgor ICAgICAgIGxvdyA9IGludDFsIHwgaW50MmwsIGhpID0gaW50MWggfCBpbnQy aDsKKyAgICAgICBicmVhazsKKyAKKyAgICAgY2FzZSBCSVRfWE9SX0VYUFI6 CisgICAgICAgbG93ID0gaW50MWwgXiBpbnQybCwgaGkgPSBpbnQxaCBeIGlu dDJoOworICAgICAgIGJyZWFrOworIAorICAgICBjYXNlIEJJVF9BTkRfRVhQ UjoKKyAgICAgICBsb3cgPSBpbnQxbCAmIGludDJsLCBoaSA9IGludDFoICYg aW50Mmg7CisgICAgICAgYnJlYWs7CisgCisgICAgIGNhc2UgUlNISUZUX0VY UFI6CisgICAgICAgaW50MmwgPSAtaW50Mmw7CisgICAgIGNhc2UgTFNISUZU X0VYUFI6CisgICAgICAgLyogSXQncyB1bmNsZWFyIGZyb20gdGhlIEMgc3Rh bmRhcmQgd2hldGhlciBzaGlmdHMgY2FuIG92ZXJmbG93LgorIAkgVGhlIGZv bGxvd2luZyBjb2RlIGlnbm9yZXMgb3ZlcmZsb3c7IHBlcmhhcHMgYSBDIHN0 YW5kYXJkCisgCSBpbnRlcnByZXRhdGlvbiBydWxpbmcgaXMgbmVlZGVkLiAg Ki8KKyAgICAgICBsc2hpZnRfZG91YmxlIChpbnQxbCwgaW50MWgsIGludDJs LCBUWVBFX1BSRUNJU0lPTiAodHlwZSksCisgCQkgICAgICZsb3csICZoaSwg IXVucyk7CisgICAgICAgYnJlYWs7CisgCisgICAgIGNhc2UgUlJPVEFURV9F WFBSOgorICAgICAgIGludDJsID0gLSBpbnQybDsKKyAgICAgY2FzZSBMUk9U QVRFX0VYUFI6CisgICAgICAgbHJvdGF0ZV9kb3VibGUgKGludDFsLCBpbnQx aCwgaW50MmwsIFRZUEVfUFJFQ0lTSU9OICh0eXBlKSwKKyAJCSAgICAgICZs b3csICZoaSk7CisgICAgICAgYnJlYWs7CisgCisgICAgIGNhc2UgUExVU19F WFBSOgorICAgICAgIG92ZXJmbG93ID0gYWRkX2RvdWJsZSAoaW50MWwsIGlu dDFoLCBpbnQybCwgaW50MmgsICZsb3csICZoaSk7CisgICAgICAgYnJlYWs7 CisgCisgICAgIGNhc2UgTUlOVVNfRVhQUjoKKyAgICAgICBuZWdfZG91Ymxl IChpbnQybCwgaW50MmgsICZsb3csICZoaSk7CisgICAgICAgYWRkX2RvdWJs ZSAoaW50MWwsIGludDFoLCBsb3csIGhpLCAmbG93LCAmaGkpOworICAgICAg IG92ZXJmbG93ID0gT1ZFUkZMT1dfU1VNX1NJR04gKGhpLCBpbnQyaCwgaW50 MWgpOworICAgICAgIGJyZWFrOworIAorICAgICBjYXNlIE1VTFRfRVhQUjoK KyAgICAgICBvdmVyZmxvdyA9IG11bF9kb3VibGUgKGludDFsLCBpbnQxaCwg aW50MmwsIGludDJoLCAmbG93LCAmaGkpOworICAgICAgIGJyZWFrOworIAor ICAgICBjYXNlIFRSVU5DX0RJVl9FWFBSOgorICAgICBjYXNlIEZMT09SX0RJ Vl9FWFBSOiBjYXNlIENFSUxfRElWX0VYUFI6CisgICAgIGNhc2UgRVhBQ1Rf RElWX0VYUFI6CisgICAgICAgLyogVGhpcyBpcyBhIHNob3J0Y3V0IGZvciBh IGNvbW1vbiBzcGVjaWFsIGNhc2UuICAqLworICAgICAgIGlmIChpbnQyaCA9 PSAwICYmIChIT1NUX1dJREVfSU5UKSBpbnQybCA+IDAKKyAJICAmJiAhIFRS RUVfQ09OU1RBTlRfT1ZFUkZMT1cgKGFyZzEpCisgCSAgJiYgISBUUkVFX0NP TlNUQU5UX09WRVJGTE9XIChhcmcyKQorIAkgICYmIGludDFoID09IDAgJiYg KEhPU1RfV0lERV9JTlQpIGludDFsID49IDApCisgCXsKKyAJICBpZiAoY29k ZSA9PSBDRUlMX0RJVl9FWFBSKQorIAkgICAgaW50MWwgKz0gaW50MmwgLSAx OworIAorIAkgIGxvdyA9IGludDFsIC8gaW50MmwsIGhpID0gMDsKKyAJICBi cmVhazsKKyAJfQorIAorICAgICAgIC8qIC4uLiBmYWxsIHRocm91Z2ggLi4u ICAqLworIAorICAgICBjYXNlIFJPVU5EX0RJVl9FWFBSOgorICAgICAgIGlm IChpbnQyaCA9PSAwICYmIGludDJsID09IDApCisgCXJldHVybiBOVUxMX1RS RUU7CisgICAgICAgaWYgKGludDJoID09IDAgJiYgaW50MmwgPT0gMSkKKyAJ eworIAkgIGxvdyA9IGludDFsLCBoaSA9IGludDFoOworIAkgIGJyZWFrOwor IAl9CisgICAgICAgaWYgKGludDFsID09IGludDJsICYmIGludDFoID09IGlu dDJoCisgCSAgJiYgISAoaW50MWwgPT0gMCAmJiBpbnQxaCA9PSAwKSkKKyAJ eworIAkgIGxvdyA9IDEsIGhpID0gMDsKKyAJICBicmVhazsKKyAJfQorICAg ICAgIG92ZXJmbG93ID0gZGl2X2FuZF9yb3VuZF9kb3VibGUgKGNvZGUsIHVu cywgaW50MWwsIGludDFoLCBpbnQybCwgaW50MmgsCisgCQkJCSAgICAgICAm bG93LCAmaGksICZnYXJiYWdlbCwgJmdhcmJhZ2VoKTsKKyAgICAgICBicmVh azsKKyAKKyAgICAgY2FzZSBUUlVOQ19NT0RfRVhQUjoKKyAgICAgY2FzZSBG TE9PUl9NT0RfRVhQUjogY2FzZSBDRUlMX01PRF9FWFBSOgorICAgICAgIC8q IFRoaXMgaXMgYSBzaG9ydGN1dCBmb3IgYSBjb21tb24gc3BlY2lhbCBjYXNl LiAgKi8KKyAgICAgICBpZiAoaW50MmggPT0gMCAmJiAoSE9TVF9XSURFX0lO VCkgaW50MmwgPiAwCisgCSAgJiYgISBUUkVFX0NPTlNUQU5UX09WRVJGTE9X IChhcmcxKQorIAkgICYmICEgVFJFRV9DT05TVEFOVF9PVkVSRkxPVyAoYXJn MikKKyAJICAmJiBpbnQxaCA9PSAwICYmIChIT1NUX1dJREVfSU5UKSBpbnQx bCA+PSAwKQorIAl7CisgCSAgaWYgKGNvZGUgPT0gQ0VJTF9NT0RfRVhQUikK KyAJICAgIGludDFsICs9IGludDJsIC0gMTsKKyAJICBsb3cgPSBpbnQxbCAl IGludDJsLCBoaSA9IDA7CisgCSAgYnJlYWs7CisgCX0KKyAKKyAgICAgICAv KiAuLi4gZmFsbCB0aHJvdWdoIC4uLiAgKi8KKyAKKyAgICAgY2FzZSBST1VO RF9NT0RfRVhQUjoKKyAgICAgICBpZiAoaW50MmggPT0gMCAmJiBpbnQybCA9 PSAwKQorIAlyZXR1cm4gTlVMTF9UUkVFOworICAgICAgIG92ZXJmbG93ID0g ZGl2X2FuZF9yb3VuZF9kb3VibGUgKGNvZGUsIHVucywKKyAJCQkJICAgICAg IGludDFsLCBpbnQxaCwgaW50MmwsIGludDJoLAorIAkJCQkgICAgICAgJmdh cmJhZ2VsLCAmZ2FyYmFnZWgsICZsb3csICZoaSk7CisgICAgICAgYnJlYWs7 CisgCisgICAgIGNhc2UgTUlOX0VYUFI6CisgICAgIGNhc2UgTUFYX0VYUFI6 CisgICAgICAgaWYgKHVucykKKyAJbG93ID0gKCgodW5zaWduZWQgSE9TVF9X SURFX0lOVCkgaW50MWgKKyAJCTwgKHVuc2lnbmVkIEhPU1RfV0lERV9JTlQp IGludDJoKQorIAkgICAgICAgfHwgKCgodW5zaWduZWQgSE9TVF9XSURFX0lO VCkgaW50MWgKKyAJCSAgICA9PSAodW5zaWduZWQgSE9TVF9XSURFX0lOVCkg aW50MmgpCisgCQkgICAmJiBpbnQxbCA8IGludDJsKSk7CisgICAgICAgZWxz ZQorIAlsb3cgPSAoaW50MWggPCBpbnQyaAorIAkgICAgICAgfHwgKGludDFo ID09IGludDJoICYmIGludDFsIDwgaW50MmwpKTsKKyAKKyAgICAgICBpZiAo bG93ID09IChjb2RlID09IE1JTl9FWFBSKSkKKyAJbG93ID0gaW50MWwsIGhp ID0gaW50MWg7CisgICAgICAgZWxzZQorIAlsb3cgPSBpbnQybCwgaGkgPSBp bnQyaDsKKyAgICAgICBicmVhazsKKyAKKyAgICAgZGVmYXVsdDoKKyAgICAg ICByZXR1cm4gTlVMTF9UUkVFOworICAgICB9CisgCisgICBpZiAob3ZlcmZs b3dfcCkKKyAgICAgKm92ZXJmbG93X3AgPSBvdmVyZmxvdzsKKyAKKyAgIHQg PSBmb3JjZV9maXRfdHlwZV8xICh0eXBlLCBsb3csIGhpLCBvdmVyZmxvd19w KTsKKyAKKyAgIHJldHVybiB0OworIH0KKyAKICAvKiBDb21iaW5lIHR3byBp bnRlZ2VyIGNvbnN0YW50cyBBUkcxIGFuZCBBUkcyIHVuZGVyIG9wZXJhdGlv biBDT0RFCiAgICAgdG8gcHJvZHVjZSBhIG5ldyBjb25zdGFudC4gIFJldHVy biBOVUxMX1RSRUUgaWYgd2UgZG9uJ3Qga25vdyBob3cKICAgICB0byBldmFs dWF0ZSBDT0RFIGF0IGNvbXBpbGUtdGltZS4KSW5kZXg6IHRlc3RzdWl0ZS9n Y2MuZGcvdHJlZS1zc2EvdnJwMzEuYwo9PT09PT09PT09PT09PT09PT09PT09 PT09P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uc2lnbmVkKV9fSU5UX01BWF9fICsg MQorIHZvaWQgdGVzdDIodW5zaWduZWQgaW50IGkpCisgeworICAgUkFOR0Uo aSwgVUlOVF9NQVggLSAweDQsIFVJTlRfTUFYIC0gMHgxKTsKKyAgIENIRUNL X0FOVElfUkFOR0UoaSArIDB4MiwgMHgxLCBVSU5UX01BWCAtIDB4Myk7Cisg fQorIHZvaWQgdGVzdDModW5zaWduZWQgaW50IGkpCisgeworICAgUkFOR0Uo aSwgVUlOVF9NQVggLSAweDQsIFVJTlRfTUFYIC0gMHgxKTsKKyAgIENIRUNL X1JBTkdFKGkgKyAweDUsIDB4MCwgMHgzKTsKKyB9Cisgdm9pZCB0ZXN0NCh1 bnNpZ25lZCBpbnQgaSkKKyB7CisgICBSQU5HRShpLCAyLCA0KTsKKyAgIENI RUNLX0FOVElfUkFOR0UoaSAtIDQsIDEsIFVJTlRfTUFYIC0gMik7CisgfQor IHZvaWQgdGVzdDUodW5zaWduZWQgaW50IGkpCisgeworICAgUkFOR0UoaSwg MiwgNCk7CisgICBDSEVDS19SQU5HRShpIC0gOCwgVUlOVF9NQVggLSA1LCBV SU5UX01BWCAtIDMpOworIH0KKyAKKyBpbnQgbWFpbigpCisgeworIH0KKyAK SW5kZXg6IHRyZWUtdnJwLmMKPT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQoqKiog dHJlZS12cnAuYwkocmV2aXNpb24gMTIwNTQ3KQotLS0gdHJlZS12cnAuYwko d29ya2luZyBjb3B5KQoqKioqKioqKioqKioqKiogc2V0X3ZhbHVlX3Jhbmdl ICh2YWx1ZV9yYW5nZV90ICp2ciwgZW51bQoqKiogMTY4LDE3MyAqKioqCi0t LSAxNjgsMTk4IC0tLS0KICAgICAgZ2NjX2Fzc2VydCAoZXF1aXYgPT0gTlVM TCB8fCBiaXRtYXBfZW1wdHlfcCAoZXF1aXYpKTsKICAjZW5kaWYKICAKKyAg IC8qI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ID0gKHZyMC5tYXggIT0gdnIwLm1pbikKISAJICAgICAgID8gdnJwX2ludF9j b25zdF9iaW5vcCAoY29kZSwgdnIwLm1heCwgdnIxLm1pbikKICAJICAgICAg IDogTlVMTF9UUkVFOwogIAohICAgICAgIHZhbFszXSA9ICh2cjAubWluICE9 IHZyMC5tYXggJiYgdnIxLm1pbiAhPSB2cjEubWF4KQohIAkgICAgICAgPyB2 cnBfaW50X2NvbnN0X2Jpbm9wIChjb2RlLCB2cjAubWF4LCB2cjEubWF4KQog IAkgICAgICAgOiBOVUxMX1RSRUU7CiAgCiAgICAgICAgLyogU2V0IE1JTiB0 byB0aGUgbWluaW11bSBvZiBWQUxbaV0gYW5kIE1BWCB0byB0aGUgbWF4aW11 bQogIAkgb2YgVkFMW2ldLiAgKi8KICAgICAgICBtaW4gPSB2YWxbMF07CiAg ICAgICAgbWF4ID0gdmFsWzBdOwogICAgICAgIGZvciAoaSA9IDE7IGkgPCA0 OyBpKyspCiAgCXsKLSAJICBpZiAoIWlzX2dpbXBsZV9taW5faW52YXJpYW50 IChtaW4pIHx8IFRSRUVfT1ZFUkZMT1cgKG1pbikKLSAJICAgICAgfHwgIWlz X2dpbXBsZV9taW5faW52YXJpYW50IChtYXgpIHx8IFRSRUVfT1ZFUkZMT1cg KG1heCkpCi0gCSAgICBicmVhazsKLSAKICAJICBpZiAodmFsW2ldKQogIAkg ICAgewotIAkgICAgICBpZiAoIWlzX2dpbXBsZV9taW5faW52YXJpYW50ICh2 YWxbaV0pIHx8IFRSRUVfT1ZFUkZMT1cgKHZhbFtpXSkpCi0gCQl7Ci0gCQkg IC8qIElmIHdlIGZvdW5kIGFuIG92ZXJmbG93ZWQgdmFsdWUsIHNldCBNSU4g YW5kIE1BWAotIAkJICAgICB0byBpdCBzbyB0aGF0IHdlIHNldCB0aGUgcmVz dWx0aW5nIHJhbmdlIHRvCi0gCQkgICAgIFZBUllJTkcuICAqLwotIAkJICBt aW4gPSBtYXggPSB2YWxbaV07Ci0gCQkgIGJyZWFrOwotIAkJfQotIAogIAkg ICAgICBpZiAoY29tcGFyZV92YWx1ZXMgKHZhbFtpXSwgbWluKSA9PSAtMSkK ICAJCW1pbiA9IHZhbFtpXTsKICAKLS0tIDE1NDEsMTU3OSAtLS0tCiAgCX0K ICAKICAgICAgICAvKiBDb21wdXRlIHRoZSA0IGNyb3NzIG9wZXJhdGlvbnMu ICAqLwohICAgICAgIHZhbFswXSA9IGludF9jb25zdF9iaW5vcF8xIChjb2Rl LCBUUkVFX1RZUEUgKHZyMC5taW4pLAohIAkJCQkgIHZyMC5taW4sIHZyMS5t aW4sICZvdmZsKTsKICAKISAgICAgICB2YWxbMV0gPSAodnIxLm1heCAhPSB2 cjEubWluICYmICFvdmZsKQohIAkgICAgICAgPyBpbnRfY29uc3RfYmlub3Bf MSAoY29kZSwgVFJFRV9UWVBFICh2cjAubWluKSwKISAJCQkJICAgIHZyMC5t aW4sIHZyMS5tYXgsICZvdmZsKQogIAkgICAgICAgOiBOVUxMX1RSRUU7CiAg CiEgICAgICAgdmFsWzJdID0gKHZyMC5tYXggIT0gdnIwLm1pbiAmJiAhb3Zm bCkKISAJICAgICAgID8gaW50X2NvbnN0X2Jpbm9wXzEgKGNvZGUsIFRSRUVf VFlQRSAodnIwLm1heCksCiEgCQkJCSAgICB2cjAubWF4LCB2cjEubWluLCAm b3ZmbCkKICAJICAgICAgIDogTlVMTF9UUkVFOwogIAohICAgICAgIHZhbFsz XSA9ICh2cjAubWluICE9IHZyMC5tYXggJiYgdnIxLm1pbiAhPSB2cjEubWF4 ICYmICFvdmZsKQohIAkgICAgICAgPyBpbnRfY29uc3RfYmlub3BfMSAoY29k ZSwgVFJFRV9UWVBFICh2cjAubWF4KSwKISAJCQkJICAgIHZyMC5tYXgsIHZy MS5tYXgsICZvdmZsKQogIAkgICAgICAgOiBOVUxMX1RSRUU7CiAgCisgICAg ICAgLyogSWYgYW55IG92ZXJmbG93IG9jY3VyZWQgZHJvcCB0byB2YXJ5aW5n Li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