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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAqIEluaXQgVXRpbGl0aWVzCQkJCQkJCSoKICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgogKiBTb21lIG9mIHRoaXMgY29kZSBzaG91bGQgYmUgbW92ZWQgaW50byB0aGUgY29yZSBmdW5jdGlvbnMsCiAqIG9yIGRyb3BwZWQgY29tcGxldGVseSwKICogYnV0IGxldCdzIGdldCBpdCB3b3JraW5nIChhZ2FpbikgZmlyc3QuLi4KICovCnN0YXRpYyB2b2lkIHN5c2NhbGxzX2luaXQgKHZvaWQpCnsKCXN5c2NhbGxfdGJsW1NZU0NBTExfTUFMTE9DXSA9ICh2b2lkICopIG1hbGxvYzsKCXN5c2NhbGxfdGJsW1NZU0NBTExfRlJFRV0gPSAodm9pZCAqKSBmcmVlOwoKCXN5c2NhbGxfdGJsW1NZU0NBTExfSU5TVEFMTF9IRExSXSA9ICh2b2lkICopIGlycV9pbnN0YWxsX2hhbmRsZXI7CglzeXNjYWxsX3RibFtTWVNDQUxMX0ZSRUVfSERMUl0gPSAodm9pZCAqKSBpcnFfZnJlZV9oYW5kbGVyOwoKfQoKc3RhdGljIGludCBpbml0X2JhdWRyYXRlICh2b2lkKQp7CglERUNMQVJFX0dMT0JBTF9EQVRBX1BUUjsKCgl1Y2hhciB0bXBbNjRdOwkvKiBsb25nIGVub3VnaCBmb3IgZW52aXJvbm1lbnQgdmFyaWFibGVzICovCglpbnQgaSA9IGdldGVudl9yICgiYmF1ZHJhdGUiLCB0bXAsIHNpemVvZiAodG1wKSk7CgoJZ2QtPmJhdWRyYXRlID0gKGkgPiAwKQoJCQk/IChpbnQpIHNpbXBsZV9zdHJ0b3VsICh0bXAsIE5VTEwsIDEwKQoJCQk6IENPTkZJR19CQVVEUkFURTsKCglyZXR1cm4gKDApOwp9Cgpz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