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kJfQU1JR0FfRUNTX09OTFkKIyAgZGVmaW5lIElTX0VDUyAoMSkKI2VuZGlmCgojaWYgIWRlZmluZWQoQ09ORklHX0ZCX0FNSUdBX0FHQSkKIyAgZGVmaW5lIElTX0FHQSAoMCkKI2VsaWYgZGVmaW5lZChDT05GSUdfRkJfQU1JR0FfT0NTKSB8fCBkZWZpbmVkKENPTkZJR19GQl9BTUlHQV9FQ1MpCiMgIGRlZmluZSBJU19BR0EgKGNoaXBzZXQgPT0gVEFHX0FHQSkKI2Vsc2UKIyAgZGVmaW5lIENPTkZJR19GQl9BTUlHQV9BR0FfT05MWQojICBkZWZpbmUgSVNfQUdBICgxKQojZW5kaWYKCiNpZmRlZiBERUJVRwojICBkZWZpbmUgRFBSSU5USyhmbXQsIGFyZ3MuLi4pCXByaW50ayhLRVJOX0RFQlVHICIlczogIiBmbXQsIF9fRlVOQ1RJT05fXyAsICMjIGFyZ3MpCiNlbHNlCiMgIGRlZmluZSBEUFJJTlRLKGZtdCwgYXJncy4uLikKI2VuZGlmCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoKCiAgIEdlbmVyaWMgdmlkZW8gdGltaW5ncwogICAtLS0tLS0tLS0tLS0tLS0tLS0tLS0KCiAgIFRpbWluZ3MgdXNlZCBieSB0aGUgZnJhbWUgYnVmZmVyIGludGVyZmFjZToKCiAgICstLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tKy0tLS0tLS0rCiAgIHwgICAgICAgICAgfCAgICAgICAgICAgICAgICBeICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgfCAgICAgICAgICAgICAgICB8dXBwZXJfbWFyZ2luICAgICAgICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgfCAgICAgICAgICAgICAgICClICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICB8CiAgICstLS0tLS0tLS0tIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMtLS0tLS0tLS0tKy0tLS0tLS0rCiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICBeICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICBsZWZ0ICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgIHJpZ2h0ICAgfCBoc3luYyB8CiAgIHwgIG1hcmdpbiAgIyAgICAgICAgICAgICAgICB8ICAgICAgIHhyZXMgICAgICAgICAgICAgICAgICMgIG1hcmdpbiAgfCAgbGVuICB8CiAgIHw8LS0tLS0tLS0+IzwtLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tPiM8LS0tLS0tLS0+fDwtLS0tLT58CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8eXJlcyAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgIyAgICAgICAgICAgICAgICClICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgfCAgICAgICB8CiAgICstLS0tLS0tLS0tIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMtLS0tLS0tLS0tKy0tLS0tLS0rCiAgIHwgICAgICAgICAgfCAgICAgICAgICAgICAgICBeICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgfCAgICAgICAgICAgICAgICB8bG93ZXJfbWFyZ2luICAgICAgICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgfCAgICAgICAgICAgICAgICClICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICB8CiAgICstLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tKy0tLS0tLS0rCiAgIHwgICAgICAgICAgfCAgICAgICAgICAgICAgICBeICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgfCAgICAgICAgICAgICAgICB8dnN5bmNfbGVuICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICB8CiAgIHwgICAgICAgICAgfCAgICAgICAgICAgICAgICClICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICB8CiAgICstLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tKy0tLS0tLS0rCgoKICAgQW1pZ2EgdmlkZW8gdGltaW5ncwogICAtLS0tLS0tLS0tLS0tLS0tLS0tCgogICBUaGUgQW1pZ2EgbmF0aXZlIGNoaXBzZXRzIHVzZXMgYW5vdGhlciB0aW1pbmcgc2NoZW1lOgoKICAgICAgLSBoc3N0cnQ6ICAgU3RhcnQgb2YgaG9yaXpvbnRhbCBzeW5jaHJvbml6YXRpb24gcHVsc2UKICAgICAgLSBoc3N0b3A6ICAgRW5kIG9mIGhvcml6b250YWwgc3luY2hyb25pemF0aW9uIHB1bHNlCiAgIC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