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AgICAgICAgICAgICAgCVNFVFBPUlQoRE1BQ05UUkwwLCBFTkRNQSk7CiAgICAgICAgICAgICAgICAgICAgICAgIAl9CgkKICAgICAgICAgICAgICAgICAgICAgICAgCWlmKGRhdGFfY291bnQgPiAxKSB7CgkJCQkJRFBSSU5USyhkZWJ1Z19kYXRhaSwgREVCVUdfTEVBRCAiMTZiaXQoJWQpXG4iLCBDTURJTkZPKENVUlJFTlRfU0MpLCBkYXRhX2NvdW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJZGF0YV9jb3VudCA+Pj0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJaW5zdyhEQVRBUE9SVCwgQ1VSUkVOVF9TQy0+U0NwLnB0ciwgZGF0YV9jb3VudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCUNVUlJFTlRfU0MtPlNDcC5wdHIgICAgICAgICAgICs9IDIgKiBkYXRhX2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAlDVVJSRU5UX1NDLT5TQ3AudGhpc19yZXNpZHVhbCAtPSAyICogZGF0YV9jb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJREFUQV9MRU4gICAgICAgICAgICAgICAgICAgICAgKz0gMiAqIGRhdGFfY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIAl9CgkKICAgICAgICAgICAgICAgICAgICAgICAgCWlmKENVUlJFTlRfU0MtPlNDcC50aGlzX3Jlc2lkdWFsPT0wICYmIENVUlJFTlRfU0MtPlNDcC5idWZmZXJzX3Jlc2lkdWFsPjApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAkJLyogYWR2YW5jZSB0byBuZXh0IGJ1ZmZlciAqLwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCQlDVVJSRU5UX1NDLT5TQ3AuYnVmZmVyc19yZXNpZHVhbC0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCQlDVVJ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aW50cyksIGludHMpOwoKCWlmKHNldHVwX2NvdW50Pj1BUlJBWV9TSVpFKHNldHVwKSkgewoJCXByaW50ayhLRVJOX0VSUiAiYWhhMTUyeDogeW91IGNhbiBvbmx5IGNvbmZpZ3VyZSB1cCB0byB0d28gY29udHJvbGxlcnNcbiIpOwoJCXJldHVybiAxOwoJfQoKCXNldHVwW3NldHVwX2NvdW50XS5jb25mICAgICAgICA9IHN0cjsKCXNldHVwW3NldHVwX2NvdW50XS5pb19wb3J0ICAgICA9IGludHNbMF0gPj0gMSA/IGludHNbMV0gOiAweDM0MDsKCXNldHVwW3NldHVwX2NvdW50XS5pcnEgICAgICAgICA9IGludHNbMF0gPj0gMiA/IGludHNbMl0gOiAxMTsKCXNldHVwW3NldHVwX2NvdW50XS5zY3NpaWQgICAgICA9IGludHNbMF0gPj0gMyA/IGludHNbM10gOiA3OwoJc2V0dXBbc2V0dXBfY291bnRdLnJlY29ubmVjdCAgID0gaW50c1swXSA+PSA0ID8gaW50c1s0XSA6IDE7CglzZXR1cFtzZXR1cF9jb3VudF0ucGFyaXR5ICAgICAgPSBpbnRzWzBdID49IDUgPyBpbnRzWzVdIDogMTsKCXNldHVwW3NldHVwX2NvdW50XS5zeW5jaHJvbm91cyA9IGludHNbMF0gPj0gNiA/IGludHNbNl0gOiAxOwoJc2V0dXBbc2V0dXBfY291bnRdLmRlbGF5ICAgICAgID0gaW50c1swXSA+PSA3ID8gaW50c1s3XSA6IERFTEFZX0RFRkFVTFQ7CglzZXR1cFtzZXR1cF9jb3VudF0uZXh0X3RyYW5zICAgPSBpbnRzWzBdID49IDggPyBpbnRzWzhdIDogMDsKI2lmIGRlZmluZWQoQUhBMTUyWF9ERUJVRykKCXNldHVwW3NldHVwX2NvdW50XS5kZWJ1ZyAgICAgICA9IGludHNbMF0gPj0gOSA/IGludHNbOV0gOiBERUJVR19ERUZBVUxUOwoJaWYgKGludHNbMF0gPiA5KSB7CgkJcHJpbnRrKEtFUk5fTk9USUNFICJhaGEx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