aframe-ar.js 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509
  1. ((function(){"use strict";var ARController=(function(width,height,camera){var id;var w=width,h=height;this.orientation="landscape";this.listeners={};if(typeof width!=="number"){var image=width;camera=height;w=image.videoWidth||image.width;h=image.videoHeight||image.height;this.image=image}this.defaultMarkerWidth=1;this.patternMarkers={};this.barcodeMarkers={};this.transform_mat=new Float32Array(16);this.canvas=document.createElement("canvas");this.canvas.width=w;this.canvas.height=h;this.ctx=this.canvas.getContext("2d");this.videoWidth=w;this.videoHeight=h;if(typeof camera==="string"){var self=this;this.cameraParam=new ARCameraParam(camera,(function(){self._initialize()}),(function(err){console.error("ARController: Failed to load ARCameraParam",err)}))}else{this.cameraParam=camera;this._initialize()}});ARController.prototype.dispose=(function(){artoolkit.teardown(this.id);for(var t in this){this[t]=null}});ARController.prototype.process=(function(image){this.detectMarker(image);var markerNum=this.getMarkerNum();var k,o;for(k in this.patternMarkers){o=this.patternMarkers[k];o.inPrevious=o.inCurrent;o.inCurrent=false}for(k in this.barcodeMarkers){o=this.barcodeMarkers[k];o.inPrevious=o.inCurrent;o.inCurrent=false}for(var i=0;i<markerNum;i++){var markerInfo=this.getMarker(i);var markerType=artoolkit.UNKNOWN_MARKER;var visible=this.trackPatternMarkerId(-1);if(markerInfo.idPatt>-1&&(markerInfo.id===markerInfo.idPatt||markerInfo.idMatrix===-1)){visible=this.trackPatternMarkerId(markerInfo.idPatt);markerType=artoolkit.PATTERN_MARKER;if(markerInfo.dir!==markerInfo.dirPatt){this.setMarkerInfoDir(i,markerInfo.dirPatt)}}else if(markerInfo.idMatrix>-1){visible=this.trackBarcodeMarkerId(markerInfo.idMatrix);markerType=artoolkit.BARCODE_MARKER;if(markerInfo.dir!==markerInfo.dirMatrix){this.setMarkerInfoDir(i,markerInfo.dirMatrix)}}if(markerType!==artoolkit.UNKNOWN_MARKER&&visible.inPrevious){this.getTransMatSquareCont(i,visible.markerWidth,visible.matrix,visible.matrix)}else{this.getTransMatSquare(i,visible.markerWidth,visible.matrix)}visible.inCurrent=true;this.transMatToGLMat(visible.matrix,this.transform_mat);this.dispatchEvent({name:"getMarker",target:this,data:{index:i,type:markerType,marker:markerInfo,matrix:this.transform_mat}})}var multiMarkerCount=this.getMultiMarkerCount();for(var i=0;i<multiMarkerCount;i++){var subMarkerCount=this.getMultiMarkerPatternCount(i);var visible=false;artoolkit.getTransMatMultiSquareRobust(this.id,i);this.transMatToGLMat(this.marker_transform_mat,this.transform_mat);for(var j=0;j<subMarkerCount;j++){var multiEachMarkerInfo=this.getMultiEachMarker(i,j);if(multiEachMarkerInfo.visible>=0){visible=true;this.dispatchEvent({name:"getMultiMarker",target:this,data:{multiMarkerId:i,matrix:this.transform_mat}});break}}if(visible){for(var j=0;j<subMarkerCount;j++){var multiEachMarkerInfo=this.getMultiEachMarker(i,j);this.transMatToGLMat(this.marker_transform_mat,this.transform_mat);this.dispatchEvent({name:"getMultiMarkerSub",target:this,data:{multiMarkerId:i,markerIndex:j,marker:multiEachMarkerInfo,matrix:this.transform_mat}})}}}if(this._bwpointer){this.debugDraw()}});ARController.prototype.trackPatternMarkerId=(function(id,markerWidth){var obj=this.patternMarkers[id];if(!obj){this.patternMarkers[id]=obj={inPrevious:false,inCurrent:false,matrix:new Float32Array(12),markerWidth:markerWidth||this.defaultMarkerWidth}}if(markerWidth){obj.markerWidth=markerWidth}return obj});ARController.prototype.trackBarcodeMarkerId=(function(id,markerWidth){var obj=this.barcodeMarkers[id];if(!obj){this.barcodeMarkers[id]=obj={inPrevious:false,inCurrent:false,matrix:new Float32Array(12),markerWidth:markerWidth||this.defaultMarkerWidth}}if(markerWidth){obj.markerWidth=markerWidth}return obj});ARController.prototype.getMultiMarkerCount=(function(){return artoolkit.getMultiMarkerCount(this.id)});ARController.prototype.getMultiMarkerPatternCount=(function(multiMarkerId){return artoolkit.getMultiMarkerNum(this.id,multiMarkerId)});ARController.prototype.addEventListener=(function(name,callback){if(!this.listeners[name]){this.listeners[name]=[]}this.listeners[name].push(callback)});ARController.prototype.removeEventListener=(function(name,callback){if(this.listeners[name]){var index=this.listeners[name].indexOf(callback);if(index>-1){this.listeners[name].splice(index,1)}}});ARController.prototype.dispatchEvent=(function(event){var listeners=this.listeners[event.name];if(listeners){for(var i=0;i<listeners.length;i++){listeners[i].call(this,event)}}});ARController.prototype.debugSetup=(function(){document.body.appendChild(this.canvas);this.setDebugMode(1);this._bwpointer=this.getProcessingImage()});ARController.prototype.loadMarker=(function(markerURL,onSuccess,onError){return artoolkit.addMarker(this.id,markerURL,onSuccess,onError)});ARController.prototype.loadMultiMarker=(function(markerURL,onSuccess,onError){return artoolkit.addMultiMarker(this.id,markerURL,onSuccess,onError)});ARController.prototype.getTransMatSquare=(function(markerIndex,markerWidth,dst){artoolkit.getTransMatSquare(this.id,markerIndex,markerWidth);dst.set(this.marker_transform_mat);return dst});ARController.prototype.getTransMatSquareCont=(function(markerIndex,markerWidth,previousMarkerTransform,dst){this.marker_transform_mat.set(previousMarkerTransform);artoolkit.getTransMatSquareCont(this.id,markerIndex,markerWidth);dst.set(this.marker_transform_mat);return dst});ARController.prototype.getTransMatMultiSquare=(function(multiMarkerId,dst){artoolkit.getTransMatMultiSquare(this.id,multiMarkerId);dst.set(this.marker_transform_mat);return dst});ARController.prototype.getTransMatMultiSquareRobust=(function(multiMarkerId,dst){artoolkit.getTransMatMultiSquare(this.id,multiMarkerId);dst.set(this.marker_transform_mat);return dst});ARController.prototype.transMatToGLMat=(function(transMat,glMat,scale){glMat[0+0*4]=transMat[0];glMat[0+1*4]=transMat[1];glMat[0+2*4]=transMat[2];glMat[0+3*4]=transMat[3];glMat[1+0*4]=transMat[4];glMat[1+1*4]=transMat[5];glMat[1+2*4]=transMat[6];glMat[1+3*4]=transMat[7];glMat[2+0*4]=transMat[8];glMat[2+1*4]=transMat[9];glMat[2+2*4]=transMat[10];glMat[2+3*4]=transMat[11];glMat[3+0*4]=0;glMat[3+1*4]=0;glMat[3+2*4]=0;glMat[3+3*4]=1;if(scale!=undefined&&scale!==0){glMat[12]*=scale;glMat[13]*=scale;glMat[14]*=scale}return glMat});ARController.prototype.detectMarker=(function(image){if(this._copyImageToHeap(image)){return artoolkit.detectMarker(this.id)}return-99});ARController.prototype.getMarkerNum=(function(){return artoolkit.getMarkerNum(this.id)});ARController.prototype.getMarker=(function(markerIndex){if(0===artoolkit.getMarker(this.id,markerIndex)){return artoolkit.markerInfo}});ARController.prototype.setMarkerInfoVertex=(function(markerIndex,vertexData){for(var i=0;i<vertexData.length;i++){this.marker_transform_mat[i*2+0]=vertexData[i][0];this.marker_transform_mat[i*2+1]=vertexData[i][1]}return artoolkit.setMarkerInfoVertex(this.id,markerIndex)});ARController.prototype.cloneMarkerInfo=(function(markerInfo){return JSON.parse(JSON.stringify(markerInfo))});ARController.prototype.getMultiEachMarker=(function(multiMarkerId,markerIndex){if(0===artoolkit.getMultiEachMarker(this.id,multiMarkerId,markerIndex)){return artoolkit.multiEachMarkerInfo}});ARController.prototype.getTransformationMatrix=(function(){return this.transform_mat});ARController.prototype.getCameraMatrix=(function(){return this.camera_mat});ARController.prototype.getMarkerTransformationMatrix=(function(){return this.marker_transform_mat});ARController.prototype.setDebugMode=(function(mode){return artoolkit.setDebugMode(this.id,mode)});ARController.prototype.getDebugMode=(function(){return artoolkit.getDebugMode(this.id)});ARController.prototype.getProcessingImage=(function(){return artoolkit.getProcessingImage(this.id)});ARController.prototype.setLogLevel=(function(mode){return artoolkit.setLogLevel(mode)});ARController.prototype.getLogLevel=(function(){return artoolkit.getLogLevel()});ARController.prototype.setMarkerInfoDir=(function(markerIndex,dir){return artoolkit.setMarkerInfoDir(this.id,markerIndex,dir)});ARController.prototype.setProjectionNearPlane=(function(value){return artoolkit.setProjectionNearPlane(this.id,value)});ARController.prototype.getProjectionNearPlane=(function(){return artoolkit.getProjectionNearPlane(this.id)});ARController.prototype.setProjectionFarPlane=(function(value){return artoolkit.setProjectionFarPlane(this.id,value)});ARController.prototype.getProjectionFarPlane=(function(){return artoolkit.getProjectionFarPlane(this.id)});ARController.prototype.setThresholdMode=(function(mode){return artoolkit.setThresholdMode(this.id,mode)});ARController.prototype.getThresholdMode=(function(){return artoolkit.getThresholdMode(this.id)});ARController.prototype.setThreshold=(function(threshold){return artoolkit.setThreshold(this.id,threshold)});ARController.prototype.getThreshold=(function(){return artoolkit.getThreshold(this.id)});ARController.prototype.setPatternDetectionMode=(function(value){return artoolkit.setPatternDetectionMode(this.id,value)});ARController.prototype.getPatternDetectionMode=(function(){return artoolkit.getPatternDetectionMode(this.id)});ARController.prototype.setMatrixCodeType=(function(value){return artoolkit.setMatrixCodeType(this.id,value)});ARController.prototype.getMatrixCodeType=(function(){return artoolkit.getMatrixCodeType(this.id)});ARController.prototype.setLabelingMode=(function(value){return artoolkit.setLabelingMode(this.id,value)});ARController.prototype.getLabelingMode=(function(){return artoolkit.getLabelingMode(this.id)});ARController.prototype.setPattRatio=(function(value){return artoolkit.setPattRatio(this.id,value)});ARController.prototype.getPattRatio=(function(){return artoolkit.getPattRatio(this.id)});ARController.prototype.setImageProcMode=(function(value){return artoolkit.setImageProcMode(this.id,value)});ARController.prototype.getImageProcMode=(function(){return artoolkit.getImageProcMode(this.id)});ARController.prototype.debugDraw=(function(){var debugBuffer=new Uint8ClampedArray(Module.HEAPU8.buffer,this._bwpointer,this.framesize);var id=new ImageData(debugBuffer,this.canvas.width,this.canvas.height);this.ctx.putImageData(id,0,0);var marker_num=this.getMarkerNum();for(var i=0;i<marker_num;i++){this._debugMarker(this.getMarker(i))}});ARController.prototype._initialize=(function(){this.id=artoolkit.setup(this.canvas.width,this.canvas.height,this.cameraParam.id);var params=artoolkit.frameMalloc;this.framepointer=params.framepointer;this.framesize=params.framesize;this.dataHeap=new Uint8Array(Module.HEAPU8.buffer,this.framepointer,this.framesize);this.camera_mat=new Float64Array(Module.HEAPU8.buffer,params.camera,16);this.marker_transform_mat=new Float64Array(Module.HEAPU8.buffer,params.transform,12);this.setProjectionNearPlane(.1);this.setProjectionFarPlane(1e3);var self=this;setTimeout((function(){if(self.onload){self.onload()}self.dispatchEvent({name:"load",target:self})}),1)});ARController.prototype._copyImageToHeap=(function(image){if(!image){image=this.image}this.ctx.save();if(this.orientation==="portrait"){this.ctx.translate(this.canvas.width,0);this.ctx.rotate(Math.PI/2);this.ctx.drawImage(image,0,0,this.canvas.height,this.canvas.width)}else{this.ctx.drawImage(image,0,0,this.canvas.width,this.canvas.height)}this.ctx.restore();var imageData=this.ctx.getImageData(0,0,this.canvas.width,this.canvas.height);var data=imageData.data;if(this.dataHeap){this.dataHeap.set(data);return true}return false});ARController.prototype._debugMarker=(function(marker){var vertex,pos;vertex=marker.vertex;var ctx=this.ctx;ctx.strokeStyle="red";ctx.beginPath();ctx.moveTo(vertex[0][0],vertex[0][1]);ctx.lineTo(vertex[1][0],vertex[1][1]);ctx.stroke();ctx.beginPath();ctx.moveTo(vertex[2][0],vertex[2][1]);ctx.lineTo(vertex[3][0],vertex[3][1]);ctx.stroke();ctx.strokeStyle="green";ctx.beginPath();ctx.lineTo(vertex[1][0],vertex[1][1]);ctx.lineTo(vertex[2][0],vertex[2][1]);ctx.stroke();ctx.beginPath();ctx.moveTo(vertex[3][0],vertex[3][1]);ctx.lineTo(vertex[0][0],vertex[0][1]);ctx.stroke();pos=marker.pos;ctx.beginPath();ctx.arc(pos[0],pos[1],8,0,Math.PI*2);ctx.fillStyle="red";ctx.fill()});ARController.getUserMedia=(function(configuration){var facing=configuration.facingMode||"environment";var onSuccess=configuration.onSuccess;var onError=configuration.onError||(function(err){console.error("ARController.getUserMedia",err)});var video=document.createElement("video");var initProgress=(function(){if(this.videoWidth!==0){onSuccess(video)}});var readyToPlay=false;var eventNames=["touchstart","touchend","touchmove","touchcancel","click","mousedown","mouseup","mousemove","keydown","keyup","keypress","scroll"];var play=(function(ev){if(readyToPlay){video.play();if(!video.paused){eventNames.forEach((function(eventName){window.removeEventListener(eventName,play,true)}))}}});eventNames.forEach((function(eventName){window.addEventListener(eventName,play,true)}));var success=(function(stream){video.addEventListener("loadedmetadata",initProgress,false);video.src=window.URL.createObjectURL(stream);readyToPlay=true;play()});var constraints={};var mediaDevicesConstraints={};if(configuration.width){mediaDevicesConstraints.width=configuration.width;if(typeof configuration.width==="object"){if(configuration.width.max){constraints.maxWidth=configuration.width.max}if(configuration.width.min){constraints.minWidth=configuration.width.max}}else{constraints.maxWidth=configuration.width}}if(configuration.height){mediaDevicesConstraints.height=configuration.height;if(typeof configuration.height==="object"){if(configuration.height.max){constraints.maxHeight=configuration.height.max}if(configuration.height.min){constraints.minHeight=configuration.height.max}}else{constraints.maxHeight=configuration.height}}mediaDevicesConstraints.facingMode=facing;navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;var hdConstraints={audio:false,video:{mandatory:constraints}};if(false){if(navigator.mediaDevices){navigator.mediaDevices.getUserMedia({audio:false,video:mediaDevicesConstraints}).then(success,onError)}else{MediaStreamTrack.getSources((function(sources){var facingDir=mediaDevicesConstraints.facingMode;if(facing&&facing.exact){facingDir=facing.exact}for(var i=0;i<sources.length;i++){if(sources[i].kind==="video"&&sources[i].facing===facingDir){hdConstraints.video.mandatory.sourceId=sources[i].id;break}}if(facing&&facing.exact&&!hdConstraints.video.mandatory.sourceId){onError("Failed to get camera facing the wanted direction")}else{if(navigator.getUserMedia){navigator.getUserMedia(hdConstraints,success,onError)}else{onError("navigator.getUserMedia is not supported on your browser")}}}))}}else{if(navigator.getUserMedia){navigator.getUserMedia(hdConstraints,success,onError)}else{onError("navigator.getUserMedia is not supported on your browser")}}return video});ARController.getUserMediaARController=(function(configuration){var obj={};for(var i in configuration){obj[i]=configuration[i]}var onSuccess=configuration.onSuccess;var cameraParamURL=configuration.cameraParam;obj.onSuccess=(function(){new ARCameraParam(cameraParamURL,(function(){var arCameraParam=this;var maxSize=configuration.maxARVideoSize||Math.max(video.videoWidth,video.videoHeight);var f=maxSize/Math.max(video.videoWidth,video.videoHeight);var w=f*video.videoWidth;var h=f*video.videoHeight;if(video.videoWidth<video.videoHeight){var tmp=w;w=h;h=tmp}var arController=new ARController(w,h,arCameraParam);arController.image=video;if(video.videoWidth<video.videoHeight){arController.orientation="portrait";arController.videoWidth=video.videoHeight;arController.videoHeight=video.videoWidth}else{arController.orientation="landscape";arController.videoWidth=video.videoWidth;arController.videoHeight=video.videoHeight}onSuccess(arController,arCameraParam)}),(function(err){console.error("ARController: Failed to load ARCameraParam",err)}))});var video=this.getUserMedia(obj);return video});var ARCameraParam=(function(src,onload,onerror){this.id=-1;this._src="";this.complete=false;this.onload=onload;this.onerror=onerror;if(src){this.load(src)}});ARCameraParam.prototype.load=(function(src){if(this._src!==""){throw"ARCameraParam: Trying to load camera parameters twice."}this._src=src;if(src){var self=this;artoolkit.loadCamera(src,(function(id){self.id=id;self.complete=true;self.onload()}),(function(err){self.onerror(err)}))}});Object.defineProperty(ARCameraParam.prototype,"src",{set:(function(src){this.load(src)}),get:(function(){return this._src})});ARCameraParam.prototype.dispose=(function(){if(this.id!==-1){artoolkit.deleteCamera(this.id)}this.id=-1;this._src="";this.complete=false});var artoolkit={UNKNOWN_MARKER:-1,PATTERN_MARKER:0,BARCODE_MARKER:1,loadCamera:loadCamera,addMarker:addMarker,addMultiMarker:addMultiMarker};var FUNCTIONS=["setup","teardown","setLogLevel","getLogLevel","setDebugMode","getDebugMode","getProcessingImage","setMarkerInfoDir","setMarkerInfoVertex","getTransMatSquare","getTransMatSquareCont","getTransMatMultiSquare","getTransMatMultiSquareRobust","getMultiMarkerNum","getMultiMarkerCount","detectMarker","getMarkerNum","getMarker","getMultiEachMarker","setProjectionNearPlane","getProjectionNearPlane","setProjectionFarPlane","getProjectionFarPlane","setThresholdMode","getThresholdMode","setThreshold","getThreshold","setPatternDetectionMode","getPatternDetectionMode","setMatrixCodeType","getMatrixCodeType","setLabelingMode","getLabelingMode","setPattRatio","getPattRatio","setImageProcMode","getImageProcMode"];function runWhenLoaded(){FUNCTIONS.forEach((function(n){artoolkit[n]=Module[n]}));for(var m in Module){if(m.match(/^AR/))artoolkit[m]=Module[m]}}var marker_count=0;function addMarker(arId,url,callback){var filename="/marker_"+marker_count++;ajax(url,filename,(function(){var id=Module._addMarker(arId,filename);if(callback)callback(id)}))}function bytesToString(array){return String.fromCharCode.apply(String,array)}function parseMultiFile(bytes){var str=bytesToString(bytes);var lines=str.split("\n");var files=[];var state=0;var markers=0;lines.forEach((function(line){line=line.trim();if(!line||line.startsWith("#"))return;switch(state){case 0:markers=+line;state=1;return;case 1:if(!line.match(/^\d+$/)){files.push(line)};case 2:case 3:case 4:state++;return;case 5:state=1;return}}));return files}var multi_marker_count=0;function addMultiMarker(arId,url,callback){var filename="/multi_marker_"+multi_marker_count++;ajax(url,filename,(function(bytes){var files=parseMultiFile(bytes);function ok(){var markerID=Module._addMultiMarker(arId,filename);var markerNum=Module.getMultiMarkerNum(arId,markerID);if(callback)callback(markerID,markerNum)}if(!files.length)return ok();var path=url.split("/").slice(0,-1).join("/");files=files.map((function(file){return[path+"/"+file,file]}));ajaxDependencies(files,ok)}))}var camera_count=0;function loadCamera(url,callback){var filename="/camera_param_"+camera_count++;var writeCallback=(function(){var id=Module._loadCamera(filename);if(callback)callback(id)});if(typeof url==="object"){writeByteArrayToFS(filename,url,writeCallback)}else if(url.indexOf("\n")>-1){writeStringToFS(filename,url,writeCallback)}else{ajax(url,filename,writeCallback)}}function writeStringToFS(target,string,callback){var byteArray=new Uint8Array(string.length);for(var i=0;i<byteArray.length;i++){byteArray[i]=string.charCodeAt(i)&255}writeByteArrayToFS(target,byteArray,callback)}function writeByteArrayToFS(target,byteArray,callback){FS.writeFile(target,byteArray,{encoding:"binary"});callback(byteArray)}function ajax(url,target,callback){var oReq=new XMLHttpRequest;oReq.open("GET",url,true);oReq.responseType="arraybuffer";oReq.onload=(function(oEvent){var arrayBuffer=oReq.response;var byteArray=new Uint8Array(arrayBuffer);writeByteArrayToFS(target,byteArray,callback)});oReq.send()}function ajaxDependencies(files,callback){var next=files.pop();if(next){ajax(next[0],next[1],(function(){ajaxDependencies(files,callback)}))}else{callback()}}window.artoolkit=artoolkit;window.ARController=ARController;window.ARCameraParam=ARCameraParam;if(window.Module){runWhenLoaded()}else{window.Module={onRuntimeInitialized:(function(){runWhenLoaded()})}}}))();var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);if(!ret&&filename!=nodePath["resolve"](filename)){filename=path.join(__dirname,"..","src",filename);ret=nodeFS["readFileSync"](filename)}if(ret&&!binary)ret=ret.toString();return ret};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};Module["load"]=function load(f){globalEval(read(f))};if(!Module["thisProgram"]){if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available (jsc?)"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.log(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=(function(title){document.title=title})}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}var Runtime={setTempRet0:(function(value){tempRet0=value}),getTempRet0:(function(){return tempRet0}),stackSave:(function(){return STACKTOP}),stackRestore:(function(stackTop){STACKTOP=stackTop}),getNativeTypeSize:(function(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return Runtime.QUANTUM_SIZE}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}),getNativeFieldSize:(function(type){return Math.max(Runtime.getNativeTypeSize(type),Runtime.QUANTUM_SIZE)}),STACK_ALIGN:16,prepVararg:(function(ptr,type){if(type==="double"||type==="i64"){if(ptr&7){assert((ptr&7)===4);ptr+=4}}else{assert((ptr&3)===0)}return ptr}),getAlignSize:(function(type,size,vararg){if(!vararg&&(type=="i64"||type=="double"))return 8;if(!type)return Math.min(size,8);return Math.min(size||(type?Runtime.getNativeFieldSize(type):0),Runtime.QUANTUM_SIZE)}),dynCall:(function(sig,ptr,args){if(args&&args.length){if(!args.splice)args=Array.prototype.slice.call(args);args.splice(0,0,ptr);return Module["dynCall_"+sig].apply(null,args)}else{return Module["dynCall_"+sig].call(null,ptr)}}),functionPointers:[],addFunction:(function(func){for(var i=0;i<Runtime.functionPointers.length;i++){if(!Runtime.functionPointers[i]){Runtime.functionPointers[i]=func;return 2*(1+i)}}throw"Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS."}),removeFunction:(function(index){Runtime.functionPointers[(index-2)/2]=null}),warnOnce:(function(text){if(!Runtime.warnOnce.shown)Runtime.warnOnce.shown={};if(!Runtime.warnOnce.shown[text]){Runtime.warnOnce.shown[text]=1;Module.printErr(text)}}),funcWrappers:{},getFuncWrapper:(function(func,sig){assert(sig);if(!Runtime.funcWrappers[sig]){Runtime.funcWrappers[sig]={}}var sigCache=Runtime.funcWrappers[sig];if(!sigCache[func]){sigCache[func]=function dynCall_wrapper(){return Runtime.dynCall(sig,func,arguments)}}return sigCache[func]}),getCompilerSetting:(function(name){throw"You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work"}),stackAlloc:(function(size){var ret=STACKTOP;STACKTOP=STACKTOP+size|0;STACKTOP=STACKTOP+15&-16;return ret}),staticAlloc:(function(size){var ret=STATICTOP;STATICTOP=STATICTOP+size|0;STATICTOP=STATICTOP+15&-16;return ret}),dynamicAlloc:(function(size){var ret=DYNAMICTOP;DYNAMICTOP=DYNAMICTOP+size|0;DYNAMICTOP=DYNAMICTOP+15&-16;if(DYNAMICTOP>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){DYNAMICTOP=ret;return 0}}return ret}),alignMemory:(function(size,quantum){var ret=size=Math.ceil(size/(quantum?quantum:16))*(quantum?quantum:16);return ret}),makeBigInt:(function(low,high,unsigned){var ret=unsigned?+(low>>>0)+ +(high>>>0)*+4294967296:+(low>>>0)+ +(high|0)*+4294967296;return ret}),GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};Module["Runtime"]=Runtime;var __THREW__=0;var ABORT=false;var EXITSTATUS=0;var undef=0;var tempValue,tempInt,tempBigInt,tempInt2,tempBigInt2,tempPair,tempBigIntI,tempBigIntR,tempBigIntS,tempBigIntP,tempBigIntD,tempDouble,tempFloat;var tempI64,tempI64b;var tempRet0,tempRet1,tempRet2,tempRet3,tempRet4,tempRet5,tempRet6,tempRet7,tempRet8,tempRet9;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}var globalScope=this;function getCFunc(ident){var func=Module["_"+ident];if(!func){try{func=eval("_"+ident)}catch(e){}}assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)");return func}var cwrap,ccall;((function(){var JSfuncs={"stackSave":(function(){Runtime.stackSave()}),"stackRestore":(function(){Runtime.stackRestore()}),"arrayToC":(function(arr){var ret=Runtime.stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=Runtime.stackAlloc((str.length<<2)+1);writeStringToMemory(str,ret)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};ccall=function ccallFunc(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=Runtime.stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func.apply(null,cArgs);if(returnType==="string")ret=Pointer_stringify(ret);if(stack!==0){if(opts&&opts.async){EmterpreterAsync.asyncFinalizers.push((function(){Runtime.stackRestore(stack)}));return}Runtime.stackRestore(stack)}return ret};var sourceRegex=/^function\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;function parseJSFunc(jsfunc){var parsed=jsfunc.toString().match(sourceRegex).slice(1);return{arguments:parsed[0],body:parsed[1],returnValue:parsed[2]}}var JSsource={};for(var fun in JSfuncs){if(JSfuncs.hasOwnProperty(fun)){JSsource[fun]=parseJSFunc(JSfuncs[fun])}}cwrap=function cwrap(ident,returnType,argTypes){argTypes=argTypes||[];var cfunc=getCFunc(ident);var numericArgs=argTypes.every((function(type){return type==="number"}));var numericRet=returnType!=="string";if(numericRet&&numericArgs){return cfunc}var argNames=argTypes.map((function(x,i){return"$"+i}));var funcstr="(function("+argNames.join(",")+") {";var nargs=argTypes.length;if(!numericArgs){funcstr+="var stack = "+JSsource["stackSave"].body+";";for(var i=0;i<nargs;i++){var arg=argNames[i],type=argTypes[i];if(type==="number")continue;var convertCode=JSsource[type+"ToC"];funcstr+="var "+convertCode.arguments+" = "+arg+";";funcstr+=convertCode.body+";";funcstr+=arg+"="+convertCode.returnValue+";"}}var cfuncname=parseJSFunc((function(){return cfunc})).returnValue;funcstr+="var ret = "+cfuncname+"("+argNames.join(",")+");";if(!numericRet){var strgfy=parseJSFunc((function(){return Pointer_stringify})).returnValue;funcstr+="ret = "+strgfy+"(ret);"}if(!numericArgs){funcstr+=JSsource["stackRestore"].body.replace("()","(stack)")+";"}funcstr+="return ret})";return eval(funcstr)}}))();Module["ccall"]=ccall;Module["cwrap"]=cwrap;function setValue(ptr,value,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}Module["setValue"]=setValue;function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for setValue: "+type)}return null}Module["getValue"]=getValue;var ALLOC_NORMAL=0;var ALLOC_STACK=1;var ALLOC_STATIC=2;var ALLOC_DYNAMIC=3;var ALLOC_NONE=4;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;Module["ALLOC_STACK"]=ALLOC_STACK;Module["ALLOC_STATIC"]=ALLOC_STATIC;Module["ALLOC_DYNAMIC"]=ALLOC_DYNAMIC;Module["ALLOC_NONE"]=ALLOC_NONE;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[_malloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var ptr=ret,stop;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr<stop;ptr+=4){HEAP32[ptr>>2]=0}stop=ret+size;while(ptr<stop){HEAP8[ptr++>>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i<size){var curr=slab[i];if(typeof curr==="function"){curr=Runtime.getFunctionIndex(curr)}type=singleType||types[i];if(type===0){i++;continue}if(type=="i64")type="i32";setValue(ret+i,curr,type);if(previousType!==type){typeSize=Runtime.getNativeTypeSize(type);previousType=type}i+=typeSize}return ret}Module["allocate"]=allocate;function getMemory(size){if(!staticSealed)return Runtime.staticAlloc(size);if(typeof _sbrk!=="undefined"&&!_sbrk.called||!runtimeInitialized)return Runtime.dynamicAlloc(size);return _malloc(size)}Module["getMemory"]=getMemory;function Pointer_stringify(ptr,length){if(length===0||!ptr)return"";var hasUtf=0;var t;var i=0;while(1){t=HEAPU8[ptr+i>>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return Module["UTF8ToString"](ptr)}Module["Pointer_stringify"]=Pointer_stringify;function AsciiToString(ptr){var str="";while(1){var ch=HEAP8[ptr++>>0];if(!ch)return str;str+=String.fromCharCode(ch)}}Module["AsciiToString"]=AsciiToString;function stringToAscii(str,outPtr){return writeAsciiToMemory(str,outPtr,false)}Module["stringToAscii"]=stringToAscii;function UTF8ArrayToString(u8Array,idx){var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}Module["UTF8ArrayToString"]=UTF8ArrayToString;function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}Module["UTF8ToString"]=UTF8ToString;function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}Module["stringToUTF8Array"]=stringToUTF8Array;function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}Module["stringToUTF8"]=stringToUTF8;function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}Module["lengthBytesUTF8"]=lengthBytesUTF8;function UTF16ToString(ptr){var i=0;var str="";while(1){var codeUnit=HEAP16[ptr+i*2>>1];if(codeUnit==0)return str;++i;str+=String.fromCharCode(codeUnit)}}Module["UTF16ToString"]=UTF16ToString;function stringToUTF16(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite<str.length*2?maxBytesToWrite/2:str.length;for(var i=0;i<numCharsToWrite;++i){var codeUnit=str.charCodeAt(i);HEAP16[outPtr>>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr}Module["stringToUTF16"]=stringToUTF16;function lengthBytesUTF16(str){return str.length*2}Module["lengthBytesUTF16"]=lengthBytesUTF16;function UTF32ToString(ptr){var i=0;var str="";while(1){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)return str;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else{str+=String.fromCharCode(utf32)}}}Module["UTF32ToString"]=UTF32ToString;function stringToUTF32(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i<str.length;++i){var codeUnit=str.charCodeAt(i);if(codeUnit>=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr}Module["stringToUTF32"]=stringToUTF32;function lengthBytesUTF32(str){var len=0;for(var i=0;i<str.length;++i){var codeUnit=str.charCodeAt(i);if(codeUnit>=55296&&codeUnit<=57343)++i;len+=4}return len}Module["lengthBytesUTF32"]=lengthBytesUTF32;function demangle(func){var hasLibcxxabi=!!Module["___cxa_demangle"];if(hasLibcxxabi){try{var buf=_malloc(func.length);writeStringToMemory(func.substr(1),buf);var status=_malloc(4);var ret=Module["___cxa_demangle"](buf,0,0,status);if(getValue(status,"i32")===0&&ret){return Pointer_stringify(ret)}}catch(e){}finally{if(buf)_free(buf);if(status)_free(status);if(ret)_free(ret)}}var i=3;var basicTypes={"v":"void","b":"bool","c":"char","s":"short","i":"int","l":"long","f":"float","d":"double","w":"wchar_t","a":"signed char","h":"unsigned char","t":"unsigned short","j":"unsigned int","m":"unsigned long","x":"long long","y":"unsigned long long","z":"..."};var subs=[];var first=true;function dump(x){if(x)Module.print(x);Module.print(func);var pre="";for(var a=0;a<i;a++)pre+=" ";Module.print(pre+"^")}function parseNested(){i++;if(func[i]==="K")i++;var parts=[];while(func[i]!=="E"){if(func[i]==="S"){i++;var next=func.indexOf("_",i);var num=func.substring(i,next)||0;parts.push(subs[num]||"?");i=next+1;continue}if(func[i]==="C"){parts.push(parts[parts.length-1]);i+=2;continue}var size=parseInt(func.substr(i));var pre=size.toString().length;if(!size||!pre){i--;break}var curr=func.substr(i+pre,size);parts.push(curr);subs.push(curr);i+=pre+size}i++;return parts}function parse(rawList,limit,allowVoid){limit=limit||Infinity;var ret="",list=[];function flushList(){return"("+list.join(", ")+")"}var name;if(func[i]==="N"){name=parseNested().join("::");limit--;if(limit===0)return rawList?[name]:name}else{if(func[i]==="K"||first&&func[i]==="L")i++;var size=parseInt(func.substr(i));if(size){var pre=size.toString().length;name=func.substr(i+pre,size);i+=pre+size}}first=false;if(func[i]==="I"){i++;var iList=parse(true);var iRet=parse(true,1,true);ret+=iRet[0]+" "+name+"<"+iList.join(", ")+">"}else{ret=name}paramLoop:while(i<func.length&&limit-->0){var c=func[i++];if(c in basicTypes){list.push(basicTypes[c])}else{switch(c){case"P":list.push(parse(true,1,true)[0]+"*");break;case"R":list.push(parse(true,1,true)[0]+"&");break;case"L":{i++;var end=func.indexOf("E",i);var size=end-i;list.push(func.substr(i,size));i+=size+2;break};case"A":{var size=parseInt(func.substr(i));i+=size.toString().length;if(func[i]!=="_")throw"?";i++;list.push(parse(true,1,true)[0]+" ["+size+"]");break};case"E":break paramLoop;default:ret+="?"+c;break paramLoop}}}if(!allowVoid&&list.length===1&&list[0]==="void")list=[];if(rawList){if(ret){list.push(ret+"?")}return list}else{return ret+flushList()}}var parsed=func;try{if(func=="Object._main"||func=="_main"){return"main()"}if(typeof func==="number")func=Pointer_stringify(func);if(func[0]!=="_")return func;if(func[1]!=="_")return func;if(func[2]!=="Z")return func;switch(func[3]){case"n":return"operator new()";case"d":return"operator delete()"}parsed=parse()}catch(e){parsed+="?"}if(parsed.indexOf("?")>=0&&!hasLibcxxabi){Runtime.warnOnce("warning: a problem occurred in builtin C++ name demangling; build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling")}return parsed}function demangleAll(text){return text.replace(/__Z[\w\d_]+/g,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function stackTrace(){return demangleAll(jsStackTrace())}Module["stackTrace"]=stackTrace;var PAGE_SIZE=4096;function alignMemoryPage(x){if(x%4096>0){x+=4096-x%4096}return x}var HEAP;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var STATIC_BASE=0,STATICTOP=0,staticSealed=false;var STACK_BASE=0,STACKTOP=0,STACK_MAX=0;var DYNAMIC_BASE=0,DYNAMICTOP=0;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}function enlargeMemory(){abortOnCannotGrowMemory()}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||268435456;var totalMemory=64*1024;while(totalMemory<TOTAL_MEMORY||totalMemory<2*TOTAL_STACK){if(totalMemory<16*1024*1024){totalMemory*=2}else{totalMemory+=16*1024*1024}}if(totalMemory!==TOTAL_MEMORY){TOTAL_MEMORY=totalMemory}assert(typeof Int32Array!=="undefined"&&typeof Float64Array!=="undefined"&&!!(new Int32Array(1))["subarray"]&&!!(new Int32Array(1))["set"],"JS engine does not provide full typed array support");var buffer;buffer=new ArrayBuffer(TOTAL_MEMORY);HEAP8=new Int8Array(buffer);HEAP16=new Int16Array(buffer);HEAP32=new Int32Array(buffer);HEAPU8=new Uint8Array(buffer);HEAPU16=new Uint16Array(buffer);HEAPU32=new Uint32Array(buffer);HEAPF32=new Float32Array(buffer);HEAPF64=new Float64Array(buffer);HEAP32[0]=255;assert(HEAPU8[0]===255&&HEAPU8[3]===0,"Typed arrays 2 must be run on a little-endian system");Module["HEAP"]=HEAP;Module["buffer"]=buffer;Module["HEAP8"]=HEAP8;Module["HEAP16"]=HEAP16;Module["HEAP32"]=HEAP32;Module["HEAPU8"]=HEAPU8;Module["HEAPU16"]=HEAPU16;Module["HEAPU32"]=HEAPU32;Module["HEAPF32"]=HEAPF32;Module["HEAPF64"]=HEAPF64;function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Runtime.dynCall("v",func)}else{Runtime.dynCall("vi",func,[callback.arg])}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}Module["addOnPreRun"]=addOnPreRun;function addOnInit(cb){__ATINIT__.unshift(cb)}Module["addOnInit"]=addOnInit;function addOnPreMain(cb){__ATMAIN__.unshift(cb)}Module["addOnPreMain"]=addOnPreMain;function addOnExit(cb){__ATEXIT__.unshift(cb)}Module["addOnExit"]=addOnExit;function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}Module["addOnPostRun"]=addOnPostRun;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}Module["intArrayFromString"]=intArrayFromString;function intArrayToString(array){var ret=[];for(var i=0;i<array.length;i++){var chr=array[i];if(chr>255){chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}Module["intArrayToString"]=intArrayToString;function writeStringToMemory(string,buffer,dontAddNull){var array=intArrayFromString(string,dontAddNull);var i=0;while(i<array.length){var chr=array[i];HEAP8[buffer+i>>0]=chr;i=i+1}}Module["writeStringToMemory"]=writeStringToMemory;function writeArrayToMemory(array,buffer){for(var i=0;i<array.length;i++){HEAP8[buffer++>>0]=array[i]}}Module["writeArrayToMemory"]=writeArrayToMemory;function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i<str.length;++i){HEAP8[buffer++>>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}Module["writeAsciiToMemory"]=writeAsciiToMemory;function unSign(value,bits,ignore){if(value>=0){return value}return bits<=32?2*Math.abs(1<<bits-1)+value:Math.pow(2,bits)+value}function reSign(value,bits,ignore){if(value<=0){return value}var half=bits<=32?Math.abs(1<<bits-1):Math.pow(2,bits-1);if(value>=half&&(bits<=32||value>half)){value=-2*half+value}return value}if(!Math["imul"]||Math["imul"](4294967295,5)!==-5)Math["imul"]=function imul(a,b){var ah=a>>>16;var al=a&65535;var bh=b>>>16;var bl=b&65535;return al*bl+(ah*bl+al*bh<<16)|0};Math.imul=Math["imul"];if(!Math["clz32"])Math["clz32"]=(function(x){x=x>>>0;for(var i=0;i<32;i++){if(x&1<<31-i)return i}return 32});Math.clz32=Math["clz32"];var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_min=Math.min;var Math_clz32=Math.clz32;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}Module["addRunDependency"]=addRunDependency;function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["removeRunDependency"]=removeRunDependency;Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var ASM_CONSTS=[(function($0,$1,$2,$3){{if(!artoolkit["multiEachMarkerInfo"]){artoolkit["multiEachMarkerInfo"]={}}var multiEachMarker=artoolkit["multiEachMarkerInfo"];multiEachMarker["visible"]=$0;multiEachMarker["pattId"]=$1;multiEachMarker["pattType"]=$2;multiEachMarker["width"]=$3}}),(function($0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32){{var $a=arguments;var i=12;if(!artoolkit["markerInfo"]){artoolkit["markerInfo"]={pos:[0,0],line:[[0,0,0],[0,0,0],[0,0,0],[0,0,0]],vertex:[[0,0],[0,0],[0,0],[0,0]]}}var markerInfo=artoolkit["markerInfo"];markerInfo["area"]=$0;markerInfo["id"]=$1;markerInfo["idPatt"]=$2;markerInfo["idMatrix"]=$3;markerInfo["dir"]=$4;markerInfo["dirPatt"]=$5;markerInfo["dirMatrix"]=$6;markerInfo["cf"]=$7;markerInfo["cfPatt"]=$8;markerInfo["cfMatrix"]=$9;markerInfo["pos"][0]=$10;markerInfo["pos"][1]=$11;markerInfo["line"][0][0]=$a[i++];markerInfo["line"][0][1]=$a[i++];markerInfo["line"][0][2]=$a[i++];markerInfo["line"][1][0]=$a[i++];markerInfo["line"][1][1]=$a[i++];markerInfo["line"][1][2]=$a[i++];markerInfo["line"][2][0]=$a[i++];markerInfo["line"][2][1]=$a[i++];markerInfo["line"][2][2]=$a[i++];markerInfo["line"][3][0]=$a[i++];markerInfo["line"][3][1]=$a[i++];markerInfo["line"][3][2]=$a[i++];markerInfo["vertex"][0][0]=$a[i++];markerInfo["vertex"][0][1]=$a[i++];markerInfo["vertex"][1][0]=$a[i++];markerInfo["vertex"][1][1]=$a[i++];markerInfo["vertex"][2][0]=$a[i++];markerInfo["vertex"][2][1]=$a[i++];markerInfo["vertex"][3][0]=$a[i++];markerInfo["vertex"][3][1]=$a[i++];markerInfo["errorCorrected"]=$a[i++]}}),(function($0,$1,$2,$3,$4){{if(!artoolkit["frameMalloc"]){artoolkit["frameMalloc"]={}}var frameMalloc=artoolkit["frameMalloc"];frameMalloc["framepointer"]=$1;frameMalloc["framesize"]=$2;frameMalloc["camera"]=$3;frameMalloc["transform"]=$4}})];function _emscripten_asm_const_33(code,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32){return ASM_CONSTS[code](a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32)}function _emscripten_asm_const_4(code,a0,a1,a2,a3){return ASM_CONSTS[code](a0,a1,a2,a3)}function _emscripten_asm_const_5(code,a0,a1,a2,a3,a4){return ASM_CONSTS[code](a0,a1,a2,a3,a4)}STATIC_BASE=8;STATICTOP=STATIC_BASE+16496;__ATINIT__.push({func:(function(){__GLOBAL__sub_I_ARToolKitJS_cpp()})},{func:(function(){__GLOBAL__sub_I_bind_cpp()})});allocate([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,9,0,0,53,42,0,0,0,0,0,0,1,0,0,0,128,1,0,0,0,0,0,0,228,8,0,0,116,42,0,0,52,9,0,0,136,47,0,0,0,0,0,0,1,0,0,0,128,1,0,0,0,0,0,0,52,9,0,0,73,47,0,0,0,0,0,0,1,0,0,0,128,1,0,0,0,0,0,0,228,8,0,0,54,47,0,0,228,8,0,0,23,47,0,0,228,8,0,0,62,46,0,0,228,8,0,0,31,46,0,0,228,8,0,0,0,46,0,0,228,8,0,0,225,45,0,0,228,8,0,0,194,45,0,0,228,8,0,0,93,46,0,0,228,8,0,0,124,46,0,0,228,8,0,0,155,46,0,0,228,8,0,0,186,46,0,0,228,8,0,0,217,46,0,0,228,8,0,0,248,46,0,0,12,9,0,0,199,47,0,0,48,2,0,0,0,0,0,0,228,8,0,0,212,47,0,0,228,8,0,0,225,47,0,0,12,9,0,0,238,47,0,0,56,2,0,0,0,0,0,0,12,9,0,0,15,48,0,0,64,2,0,0,0,0,0,0,12,9,0,0,49,48,0,0,64,2,0,0,0,0,0,0,200,8,0,0,89,48,0,0,200,8,0,0,91,48,0,0,200,8,0,0,93,48,0,0,200,8,0,0,95,48,0,0,200,8,0,0,97,48,0,0,200,8,0,0,99,48,0,0,200,8,0,0,101,48,0,0,200,8,0,0,103,48,0,0,200,8,0,0,105,48,0,0,200,8,0,0,107,48,0,0,200,8,0,0,109,48,0,0,200,8,0,0,111,48,0,0,200,8,0,0,113,48,0,0,12,9,0,0,115,48,0,0,80,2,0,0,0,0,0,0,12,9,0,0,152,48,0,0,80,2,0,0,0,0,0,0,255,15,0,0,6,16,0,0,18,16,0,0,28,16,0,0,255,255,255,255,255,255,255,255,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,1,0,0,0,2,0,0,0,4,0,0,0,8,0,0,0,3,0,0,0,6,0,0,0,12,0,0,0,11,0,0,0,5,0,0,0,10,0,0,0,7,0,0,0,14,0,0,0,15,0,0,0,13,0,0,0,9,0,0,0,1,0,0,0,2,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,32,0,0,0,64,0,0,0,3,0,0,0,6,0,0,0,12,0,0,0,24,0,0,0,48,0,0,0,96,0,0,0,67,0,0,0,5,0,0,0,10,0,0,0,20,0,0,0,40,0,0,0,80,0,0,0,35,0,0,0,70,0,0,0,15,0,0,0,30,0,0,0,60,0,0,0,120,0,0,0,115,0,0,0,101,0,0,0,73,0,0,0,17,0,0,0,34,0,0,0,68,0,0,0,11,0,0,0,22,0,0,0,44,0,0,0,88,0,0,0,51,0,0,0,102,0,0,0,79,0,0,0,29,0,0,0,58,0,0,0,116,0,0,0,107,0,0,0,85,0,0,0,41,0,0,0,82,0,0,0,39,0,0,0,78,0,0,0,31,0,0,0,62,0,0,0,124,0,0,0,123,0,0,0,117,0,0,0,105,0,0,0,81,0,0,0,33,0,0,0,66,0,0,0,7,0,0,0,14,0,0,0,28,0,0,0,56,0,0,0,112,0,0,0,99,0,0,0,69,0,0,0,9,0,0,0,18,0,0,0,36,0,0,0,72,0,0,0,19,0,0,0,38,0,0,0,76,0,0,0,27,0,0,0,54,0,0,0,108,0,0,0,91,0,0,0,53,0,0,0,106,0,0,0,87,0,0,0,45,0,0,0,90,0,0,0,55,0,0,0,110,0,0,0,95,0,0,0,61,0,0,0,122,0,0,0,119,0,0,0,109,0,0,0,89,0,0,0,49,0,0,0,98,0,0,0,71,0,0,0,13,0,0,0,26,0,0,0,52,0,0,0,104,0,0,0,83,0,0,0,37,0,0,0,74,0,0,0,23,0,0,0,46,0,0,0,92,0,0,0,59,0,0,0,118,0,0,0,111,0,0,0,93,0,0,0,57,0,0,0,114,0,0,0,103,0,0,0,77,0,0,0,25,0,0,0,50,0,0,0,100,0,0,0,75,0,0,0,21,0,0,0,42,0,0,0,84,0,0,0,43,0,0,0,86,0,0,0,47,0,0,0,94,0,0,0,63,0,0,0,126,0,0,0,127,0,0,0,125,0,0,0,121,0,0,0,113,0,0,0,97,0,0,0,65,0,0,0,255,255,255,255,0,0,0,0,1,0,0,0,4,0,0,0,2,0,0,0,8,0,0,0,5,0,0,0,10,0,0,0,3,0,0,0,14,0,0,0,9,0,0,0,7,0,0,0,6,0,0,0,13,0,0,0,11,0,0,0,12,0,0,0,255,255,255,255,0,0,0,0,1,0,0,0,7,0,0,0,2,0,0,0,14,0,0,0,8,0,0,0,56,0,0,0,3,0,0,0,63,0,0,0,15,0,0,0,31,0,0,0,9,0,0,0,90,0,0,0,57,0,0,0,21,0,0,0,4,0,0,0,28,0,0,0,64,0,0,0,67,0,0,0,16,0,0,0,112,0,0,0,32,0,0,0,97,0,0,0,10,0,0,0,108,0,0,0,91,0,0,0,70,0,0,0,58,0,0,0,38,0,0,0,22,0,0,0,47,0,0,0,5,0,0,0,54,0,0,0,29,0,0,0,19,0,0,0,65,0,0,0,95,0,0,0,68,0,0,0,45,0,0,0,17,0,0,0,43,0,0,0,113,0,0,0,115,0,0,0,33,0,0,0,77,0,0,0,98,0,0,0,117,0,0,0,11,0,0,0,87,0,0,0,109,0,0,0,35,0,0,0,92,0,0,0,74,0,0,0,71,0,0,0,79,0,0,0,59,0,0,0,104,0,0,0,39,0,0,0,100,0,0,0,23,0,0,0,82,0,0,0,48,0,0,0,119,0,0,0,6,0,0,0,126,0,0,0,55,0,0,0,13,0,0,0,30,0,0,0,62,0,0,0,20,0,0,0,89,0,0,0,66,0,0,0,27,0,0,0,96,0,0,0,111,0,0,0,69,0,0,0,107,0,0,0,46,0,0,0,37,0,0,0,18,0,0,0,53,0,0,0,44,0,0,0,94,0,0,0,114,0,0,0,42,0,0,0,116,0,0,0,76,0,0,0,34,0,0,0,86,0,0,0,78,0,0,0,73,0,0,0,99,0,0,0,103,0,0,0,118,0,0,0,81,0,0,0,12,0,0,0,125,0,0,0,88,0,0,0,61,0,0,0,110,0,0,0,26,0,0,0,36,0,0,0,106,0,0,0,93,0,0,0,52,0,0,0,75,0,0,0,41,0,0,0,72,0,0,0,85,0,0,0,80,0,0,0,102,0,0,0,60,0,0,0,124,0,0,0,105,0,0,0,25,0,0,0,40,0,0,0,51,0,0,0,101,0,0,0,84,0,0,0,24,0,0,0,123,0,0,0,83,0,0,0,50,0,0,0,49,0,0,0,122,0,0,0,120,0,0,0,121,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,136,0,0,0,5,0,0,0,144,0,0,0,6,0,0,0,152,0,0,0,9,0,0,0,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,253,255,255,255,254,255,255,255,0,0,0,0,112,2,0,0,168,2,0,0,200,2,0,0,112,2,0,0,168,2,0,0,168,2,0,0,208,2,0,0,168,2,0,0,112,2,0,0,168,2,0,0,208,2,0,0,168,2,0,0,112,2,0,0,168,2,0,0,168,2,0,0,104,1,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,104,1,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,0,0,0,0,32,2,0,0,1,0,0,0,2,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,96,2,0,0,3,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,1,0,0,0,0,0,0,0,80,2,0,0,3,0,0,0,7,0,0,0,5,0,0,0,6,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,216,2,0,0,3,0,0,0,8,0,0,0,5,0,0,0,6,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,232,2,0,0,3,0,0,0,9,0,0,0,5,0,0,0,6,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,192,3,0,0,192,4,0,0,192,5,0,0,192,6,0,0,192,7,0,0,192,8,0,0,192,9,0,0,192,10,0,0,192,11,0,0,192,12,0,0,192,13,0,0,192,14,0,0,192,15,0,0,192,16,0,0,192,17,0,0,192,18,0,0,192,19,0,0,192,20,0,0,192,21,0,0,192,22,0,0,192,23,0,0,192,24,0,0,192,25,0,0,192,26,0,0,192,27,0,0,192,28,0,0,192,29,0,0,192,30,0,0,192,31,0,0,192,0,0,0,179,1,0,0,195,2,0,0,195,3,0,0,195,4,0,0,195,5,0,0,195,6,0,0,195,7,0,0,195,8,0,0,195,9,0,0,195,10,0,0,195,11,0,0,195,12,0,0,195,13,0,0,211,14,0,0,195,15,0,0,195,0,0,12,187,1,0,12,195,2,0,12,195,3,0,12,195,4,0,12,211,240,10,0,0,96,11,0,0,0,0,0,0,10,0,0,0,100,0,0,0,232,3,0,0,16,39,0,0,160,134,1,0,64,66,15,0,128,150,152,0,0,225,245,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,5,0,0,0,81,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,5,0,0,0,73,58,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,5,0,0,0,7,0,0,0,11,0,0,0,13,0,0,0,17,0,0,0,19,0,0,0,23,0,0,0,29,0,0,0,31,0,0,0,37,0,0,0,41,0,0,0,43,0,0,0,47,0,0,0,53,0,0,0,59,0,0,0,61,0,0,0,67,0,0,0,71,0,0,0,73,0,0,0,79,0,0,0,83,0,0,0,89,0,0,0,97,0,0,0,101,0,0,0,103,0,0,0,107,0,0,0,109,0,0,0,113,0,0,0,127,0,0,0,131,0,0,0,137,0,0,0,139,0,0,0,149,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,167,0,0,0,173,0,0,0,179,0,0,0,181,0,0,0,191,0,0,0,193,0,0,0,197,0,0,0,199,0,0,0,211,0,0,0,1,0,0,0,11,0,0,0,13,0,0,0,17,0,0,0,19,0,0,0,23,0,0,0,29,0,0,0,31,0,0,0,37,0,0,0,41,0,0,0,43,0,0,0,47,0,0,0,53,0,0,0,59,0,0,0,61,0,0,0,67,0,0,0,71,0,0,0,73,0,0,0,79,0,0,0,83,0,0,0,89,0,0,0,97,0,0,0,101,0,0,0,103,0,0,0,107,0,0,0,109,0,0,0,113,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,137,0,0,0,139,0,0,0,143,0,0,0,149,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,167,0,0,0,169,0,0,0,173,0,0,0,179,0,0,0,181,0,0,0,187,0,0,0,191,0,0,0,193,0,0,0,197,0,0,0,199,0,0,0,209,0,0,0,69,114,114,111,114,58,32,108,97,98,101,108,105,110,103,32,119,111,114,107,32,111,118,101,114,102,108,111,119,46,10,0,69,114,114,111,114,58,32,85,110,115,117,112,112,111,114,116,101,100,32,112,105,120,101,108,32,102,111,114,109,97,116,32,40,37,100,41,32,114,101,113,117,101,115,116,101,100,46,10,0,85,110,107,110,111,119,110,32,111,114,32,117,110,115,117,112,112,111,114,116,101,100,32,108,97,98,101,108,105,110,103,32,116,104,114,101,115,104,111,108,100,32,109,111,100,101,32,114,101,113,117,101,115,116,101,100,46,32,83,101,116,32,116,111,32,109,97,110,117,97,108,46,10,0,76,97,98,101,108,105,110,103,32,116,104,114,101,115,104,111,108,100,32,109,111,100,101,32,115,101,116,32,116,111,32,37,115,46,10,0,77,65,78,85,65,76,0,65,85,84,79,95,77,69,68,73,65,78,0,65,85,84,79,95,79,84,83,85,0,65,85,84,79,95,65,68,65,80,84,73,86,69,65,85,84,79,95,66,82,65,67,75,69,84,73,78,71,0,65,117,116,111,32,116,104,114,101,115,104,111,108,100,32,40,98,114,97,99,107,101,116,41,32,109,97,114,107,101,114,32,99,111,117,110,116,115,32,45,91,37,51,100,58,32,37,51,100,93,32,91,37,51,100,58,32,37,51,100,93,32,91,37,51,100,58,32,37,51,100,93,43,46,10,0,65,117,116,111,32,116,104,114,101,115,104,111,108,100,32,40,98,114,97,99,107,101,116,41,32,97,100,106,117,115,116,101,100,32,116,104,114,101,115,104,111,108,100,32,116,111,32,37,100,46,10,0,109,101,100,105,97,110,0,79,116,115,117,0,65,117,116,111,32,116,104,114,101,115,104,111,108,100,32,40,37,115,41,32,97,100,106,117,115,116,101,100,32,116,104,114,101,115,104,111,108,100,32,116,111,32,37,100,46,10,0,63,63,63,32,49,10,0,63,63,63,32,50,10,0,63,63,63,32,51,10,0,69,114,114,111,114,58,32,85,110,115,117,112,112,111,114,116,101,100,32,112,105,120,101,108,32,102,111,114,109,97,116,32,112,97,115,115,101,100,32,116,111,32,97,114,73,109,97,103,101,80,114,111,99,72,105,115,116,40,41,46,10,0,0,0,0,1,0,1,1,1,0,2,4,255,255,5,3,1,0,2,255,6,7,255,3,1,2,2,3,2,3,2,3,3,0,255,4,6,7,5,255,1,4,5,4,4,5,5,4,5,7,6,6,6,7,7,7,6,255,2,4,6,7,5,3,255,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,255,255,3,255,5,6,255,255,9,10,255,12,255,255,15,255,17,18,255,20,255,255,23,24,255,255,27,255,29,30,255,255,1,2,255,4,255,255,7,8,255,255,11,255,13,14,255,16,255,255,19,255,21,22,255,255,25,26,255,28,255,255,31,69,114,114,111,114,58,32,117,110,115,117,112,112,111,114,116,101,100,32,112,105,120,101,108,32,102,111,114,109,97,116,46,10,0,69,114,114,111,114,58,32,78,85,76,76,32,112,97,116,116,72,97,110,100,108,101,46,10,0,69,114,114,111,114,58,32,99,97,110,39,116,32,108,111,97,100,32,112,97,116,116,101,114,110,32,102,114,111,109,32,78,85,76,76,32,98,117,102,102,101,114,46,10,0,69,114,114,111,114,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,46,10,0,32,9,10,13,0,80,97,116,116,101,114,110,32,68,97,116,97,32,114,101,97,100,32,101,114,114,111,114,33,33,10,0,69,114,114,111,114,32,111,112,101,110,105,110,103,32,112,97,116,116,101,114,110,32,102,105,108,101,32,39,37,115,39,32,102,111,114,32,114,101,97,100,105,110,103,46,10,0,69,114,114,111,114,32,114,101,97,100,105,110,103,32,112,97,116,116,101,114,110,32,102,105,108,101,32,39,37,115,39,46,10,0,114,98,0,69,114,114,111,114,32,40,37,100,41,58,32,117,110,97,98,108,101,32,116,111,32,111,112,101,110,32,99,97,109,101,114,97,32,112,97,114,97,109,101,116,101,114,115,32,102,105,108,101,32,34,37,115,34,32,102,111,114,32,114,101,97,100,105,110,103,46,10,0,69,114,114,111,114,32,40,37,100,41,58,32,117,110,97,98,108,101,32,116,111,32,100,101,116,101,114,109,105,110,101,32,102,105,108,101,32,108,101,110,103,116,104,46,0,69,114,114,111,114,58,32,115,117,112,112,108,105,101,100,32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,97,112,112,101,97,114,32,116,111,32,98,101,32,97,110,32,65,82,84,111,111,108,75,105,116,32,99,97,109,101,114,97,32,112,97,114,97,109,101,116,101,114,32,102,105,108,101,46,10,0,69,114,114,111,114,32,40,37,100,41,58,32,117,110,97,98,108,101,32,116,111,32,114,101,97,100,32,102,114,111,109,32,102,105,108,101,46,0,69,114,114,111,114,58,32,105,99,112,71,101,116,74,95,85,95,88,99,0,69,114,114,111,114,58,32,109,97,108,108,111,99,10,0,69,114,114,111,114,32,49,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,50,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,51,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,52,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,53,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,54,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,55,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,114,0,69,114,114,111,114,58,32,117,110,97,98,108,101,32,116,111,32,111,112,101,110,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,46,10,0,37,115,37,115,10,0,0,37,100,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,70,105,114,115,116,32,108,105,110,101,32,109,117,115,116,32,98,101,32,110,117,109,98,101,114,32,111,102,32,109,97,114,107,101,114,32,99,111,110,102,105,103,115,32,116,111,32,114,101,97,100,46,10,0,79,117,116,32,111,102,32,109,101,109,111,114,121,33,33,10,0,37,108,108,117,37,99,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,112,97,116,116,101,114,110,32,39,37,115,39,32,115,112,101,99,105,102,105,101,100,32,105,110,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,117,114,97,116,105,111,110,32,119,104,105,108,101,32,105,110,32,98,97,114,99,111,100,101,45,111,110,108,121,32,109,111,100,101,46,10,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,85,110,97,98,108,101,32,116,111,32,100,101,116,101,114,109,105,110,101,32,100,105,114,101,99,116,111,114,121,32,110,97,109,101,46,10,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,85,110,97,98,108,101,32,116,111,32,108,111,97,100,32,112,97,116,116,101,114,110,32,39,37,115,39,46,10,0,37,108,102,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,44,32,109,97,114,107,101,114,32,100,101,102,105,110,105,116,105,111,110,32,37,51,100,58,32,70,105,114,115,116,32,108,105,110,101,32,109,117,115,116,32,98,101,32,112,97,116,116,101,114,110,32,119,105,100,116,104,46,10,0,37,108,102,32,37,108,102,32,37,108,102,32,37,108,102,0,37,102,32,37,102,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,44,32,109,97,114,107,101,114,32,100,101,102,105,110,105,116,105,111,110,32,37,51,100,58,32,76,105,110,101,115,32,50,32,45,32,52,32,109,117,115,116,32,98,101,32,109,97,114,107,101,114,32,116,114,97,110,115,102,111,114,109,46,10,0,97,114,103,108,67,97,109,101,114,97,70,114,117,115,116,117,109,40,41,58,32,97,114,80,97,114,97,109,68,101,99,111,109,112,77,97,116,40,41,32,105,110,100,105,99,97,116,101,100,32,112,97,114,97,109,101,116,101,114,32,101,114,114,111,114,46,10,0,108,111,97,100,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,32,108,111,97,100,105,110,103,32,112,97,114,97,109,101,116,101,114,32,102,105,108,101,32,37,115,32,102,111,114,32,99,97,109,101,114,97,46,10,0,42,42,42,32,67,97,109,101,114,97,32,80,97,114,97,109,101,116,101,114,32,114,101,115,105,122,101,100,32,102,114,111,109,32,37,100,44,32,37,100,46,32,42,42,42,10,0,115,101,116,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,58,32,97,114,80,97,114,97,109,76,84,67,114,101,97,116,101,46,10,0,115,101,116,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,58,32,97,114,67,114,101,97,116,101,72,97,110,100,108,101,46,10,0,115,101,116,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,32,99,114,101,97,116,105,110,103,32,51,68,32,104,97,110,100,108,101,0,108,111,97,100,77,97,114,107,101,114,40,41,58,32,69,114,114,111,114,32,108,111,97,100,105,110,103,32,112,97,116,116,101,114,110,32,102,105,108,101,32,37,115,46,10,0,65,82,84,111,111,108,75,105,116,74,83,40,41,58,32,85,110,97,98,108,101,32,116,111,32,115,101,116,32,117,112,32,65,82,32,109,97,114,107,101,114,46,10,0,99,111,110,102,105,103,32,100,97,116,97,32,108,111,97,100,32,101,114,114,111,114,32,33,33,10,0,65,82,84,111,111,108,75,105,116,74,83,40,41,58,32,85,110,97,98,108,101,32,116,111,32,115,101,116,32,117,112,32,65,82,32,109,117,108,116,105,109,97,114,107,101,114,46,10,0,80,97,116,116,101,114,110,32,100,101,116,101,99,116,105,111,110,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,46,10,0,80,97,116,116,101,114,110,32,114,97,116,105,111,32,115,105,122,101,32,115,101,116,32,116,111,32,37,102,46,10,0,76,97,98,101,108,105,110,103,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,10,0,84,104,114,101,115,104,111,108,100,32,115,101,116,32,116,111,32,37,100,10,0,84,104,114,101,115,104,111,108,100,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,10,0,111,110,46,0,111,102,102,46,0,68,101,98,117,103,32,109,111,100,101,32,115,101,116,32,116,111,32,37,115,10,0,73,109,97,103,101,32,112,114,111,99,46,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,46,10,0,123,32,105,102,32,40,33,97,114,116,111,111,108,107,105,116,91,34,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,73,110,102,111,34,93,41,32,123,32,97,114,116,111,111,108,107,105,116,91,34,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,73,110,102,111,34,93,32,61,32,40,123,125,41,59,32,125,32,118,97,114,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,32,61,32,97,114,116,111,111,108,107,105,116,91,34,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,73,110,102,111,34,93,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,118,105,115,105,98,108,101,39,93,32,61,32,36,48,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,112,97,116,116,73,100,39,93,32,61,32,36,49,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,112,97,116,116,84,121,112,101,39,93,32,61,32,36,50,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,119,105,100,116,104,39,93,32,61,32,36,51,59,32,125,0,123,32,118,97,114,32,36,97,32,61,32,97,114,103,117,109,101,110,116,115,59,32,118,97,114,32,105,32,61,32,49,50,59,32,105,102,32,40,33,97,114,116,111,111,108,107,105,116,91,34,109,97,114,107,101,114,73,110,102,111,34,93,41,32,123,32,97,114,116,111,111,108,107,105,116,91,34,109,97,114,107,101,114,73,110,102,111,34,93,32,61,32,40,123,32,112,111,115,58,32,91,48,44,48,93,44,32,108,105,110,101,58,32,91,91,48,44,48,44,48,93,44,32,91,48,44,48,44,48,93,44,32,91,48,44,48,44,48,93,44,32,91,48,44,48,44,48,93,93,44,32,118,101,114,116,101,120,58,32,91,91,48,44,48,93,44,32,91,48,44,48,93,44,32,91,48,44,48,93,44,32,91,48,44,48,93,93,32,125,41,59,32,125,32,118,97,114,32,109,97,114,107,101,114,73,110,102,111,32,61,32,97,114,116,111,111,108,107,105,116,91,34,109,97,114,107,101,114,73,110,102,111,34,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,97,114,101,97,34,93,32,61,32,36,48,59,32,109,97,114,107,101,114,73,110,102,111,91,34,105,100,34,93,32,61,32,36,49,59,32,109,97,114,107,101,114,73,110,102,111,91,34,105,100,80,97,116,116,34,93,32,61,32,36,50,59,32,109,97,114,107,101,114,73,110,102,111,91,34,105,100,77,97,116,114,105,120,34,93,32,61,32,36,51,59,32,109,97,114,107,101,114,73,110,102,111,91,34,100,105,114,34,93,32,61,32,36,52,59,32,109,97,114,107,101,114,73,110,102,111,91,34,100,105,114,80,97,116,116,34,93,32,61,32,36,53,59,32,109,97,114,107,101,114,73,110,102,111,91,34,100,105,114,77,97,116,114,105,120,34,93,32,61,32,36,54,59,32,109,97,114,107,101,114,73,110,102,111,91,34,99,102,34,93,32,61,32,36,55,59,32,109,97,114,107,101,114,73,110,102,111,91,34,99,102,80,97,116,116,34,93,32,61,32,36,56,59,32,109,97,114,107,101,114,73,110,102,111,91,34,99,102,77,97,116,114,105,120,34,93,32,61,32,36,57,59,32,109,97,114,107,101,114,73,110,102,111,91,34,112,111,115,34,93,91,48,93,32,61,32,36,49,48,59,32,109,97,114,107,101,114,73,110,102,111,91,34,112,111,115,34,93,91,49,93,32,61,32,36,49,49,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,48,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,48,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,48,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,49,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,49,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,49,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,50,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,50,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,50,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,51,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,51,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,51,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,48,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,48,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,49,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,49,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,50,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,50,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,51,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,51,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,101,114,114,111,114,67,111,114,114,101,99,116,101,100,34,93,32,61,32,36,97,91,105,43,43,93,59,32,125,0,115,101,116,117,112,40,41,58,32,69,114,114,111,114,58,32,97,114,80,97,116,116,67,114,101,97,116,101,72,97,110,100,108,101,46,10,0,65,108,108,111,99,97,116,101,100,32,118,105,100,101,111,70,114,97,109,101,83,105,122,101,32,37,100,10,0,123,32,105,102,32,40,33,97,114,116,111,111,108,107,105,116,91,34,102,114,97,109,101,77,97,108,108,111,99,34,93,41,32,123,32,97,114,116,111,111,108,107,105,116,91,34,102,114,97,109,101,77,97,108,108,111,99,34,93,32,61,32,40,123,125,41,59,32,125,32,118,97,114,32,102,114,97,109,101,77,97,108,108,111,99,32,61,32,97,114,116,111,111,108,107,105,116,91,34,102,114,97,109,101,77,97,108,108,111,99,34,93,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,102,114,97,109,101,112,111,105,110,116,101,114,34,93,32,61,32,36,49,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,102,114,97,109,101,115,105,122,101,34,93,32,61,32,36,50,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,99,97,109,101,114,97,34,93,32,61,32,36,51,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,116,114,97,110,115,102,111,114,109,34,93,32,61,32,36,52,59,32,125,0,115,101,116,117,112,0,116,101,97,114,100,111,119,110,0,95,97,100,100,77,97,114,107,101,114,0,95,97,100,100,77,117,108,116,105,77,97,114,107,101,114,0,103,101,116,77,117,108,116,105,77,97,114,107,101,114,78,117,109,0,103,101,116,77,117,108,116,105,77,97,114,107,101,114,67,111,117,110,116,0,95,108,111,97,100,67,97,109,101,114,97,0,115,101,116,77,97,114,107,101,114,73,110,102,111,68,105,114,0,115,101,116,77,97,114,107,101,114,73,110,102,111,86,101,114,116,101,120,0,103,101,116,84,114,97,110,115,77,97,116,83,113,117,97,114,101,0,103,101,116,84,114,97,110,115,77,97,116,83,113,117,97,114,101,67,111,110,116,0,103,101,116,84,114,97,110,115,77,97,116,77,117,108,116,105,83,113,117,97,114,101,0,103,101,116,84,114,97,110,115,77,97,116,77,117,108,116,105,83,113,117,97,114,101,82,111,98,117,115,116,0,100,101,116,101,99,116,77,97,114,107,101,114,0,103,101,116,77,97,114,107,101,114,78,117,109,0,103,101,116,77,117,108,116,105,69,97,99,104,77,97,114,107,101,114,0,103,101,116,77,97,114,107,101,114,0,115,101,116,68,101,98,117,103,77,111,100,101,0,103,101,116,68,101,98,117,103,77,111,100,101,0,103,101,116,80,114,111,99,101,115,115,105,110,103,73,109,97,103,101,0,115,101,116,76,111,103,76,101,118,101,108,0,103,101,116,76,111,103,76,101,118,101,108,0,115,101,116,80,114,111,106,101,99,116,105,111,110,78,101,97,114,80,108,97,110,101,0,103,101,116,80,114,111,106,101,99,116,105,111,110,78,101,97,114,80,108,97,110,101,0,115,101,116,80,114,111,106,101,99,116,105,111,110,70,97,114,80,108,97,110,101,0,103,101,116,80,114,111,106,101,99,116,105,111,110,70,97,114,80,108,97,110,101,0,115,101,116,84,104,114,101,115,104,111,108,100,77,111,100,101,0,103,101,116,84,104,114,101,115,104,111,108,100,77,111,100,101,0,115,101,116,84,104,114,101,115,104,111,108,100,0,103,101,116,84,104,114,101,115,104,111,108,100,0,115,101,116,80,97,116,116,101,114,110,68,101,116,101,99,116,105,111,110,77,111,100,101,0,103,101,116,80,97,116,116,101,114,110,68,101,116,101,99,116,105,111,110,77,111,100,101,0,115,101,116,80,97,116,116,82,97,116,105,111,0,103,101,116,80,97,116,116,82,97,116,105,111,0,115,101,116,77,97,116,114,105,120,67,111,100,101,84,121,112,101,0,103,101,116,77,97,116,114,105,120,67,111,100,101,84,121,112,101,0,115,101,116,76,97,98,101,108,105,110,103,77,111,100,101,0,103,101,116,76,97,98,101,108,105,110,103,77,111,100,101,0,115,101,116,73,109,97,103,101,80,114,111,99,77,111,100,101,0,103,101,116,73,109,97,103,101,80,114,111,99,77,111,100,101,0,69,82,82,79,82,95,65,82,67,79,78,84,82,79,76,76,69,82,95,78,79,84,95,70,79,85,78,68,0,69,82,82,79,82,95,77,85,76,84,73,77,65,82,75,69,82,95,78,79,84,95,70,79,85,78,68,0,69,82,82,79,82,95,77,65,82,75,69,82,95,73,78,68,69,88,95,79,85,84,95,79,70,95,66,79,85,78,68,83,0,65,82,95,68,69,66,85,71,95,68,73,83,65,66,76,69,0,65,82,95,68,69,66,85,71,95,69,78,65,66,76,69,0,65,82,95,68,69,70,65,85,76,84,95,68,69,66,85,71,95,77,79,68,69,0,65,82,95,76,65,66,69,76,73,78,71,95,87,72,73,84,69,95,82,69,71,73,79,78,0,65,82,95,76,65,66,69,76,73,78,71,95,66,76,65,67,75,95,82,69,71,73,79,78,0,65,82,95,68,69,70,65,85,76,84,95,76,65,66,69,76,73,78,71,95,77,79,68,69,0,65,82,95,68,69,70,65,85,76,84,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,0,65,82,95,73,77,65,71,69,95,80,82,79,67,95,70,82,65,77,69,95,73,77,65,71,69,0,65,82,95,73,77,65,71,69,95,80,82,79,67,95,70,73,69,76,68,95,73,77,65,71,69,0,65,82,95,68,69,70,65,85,76,84,95,73,77,65,71,69,95,80,82,79,67,95,77,79,68,69,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,67,79,76,79,82,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,77,79,78,79,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,68,69,84,69,67,84,73,79,78,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,67,79,76,79,82,95,65,78,68,95,77,65,84,82,73,88,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,77,79,78,79,95,65,78,68,95,77,65,84,82,73,88,0,65,82,95,68,69,70,65,85,76,84,95,80,65,84,84,69,82,78,95,68,69,84,69,67,84,73,79,78,95,77,79,68,69,0,65,82,95,85,83,69,95,84,82,65,67,75,73,78,71,95,72,73,83,84,79,82,89,0,65,82,95,78,79,85,83,69,95,84,82,65,67,75,73,78,71,95,72,73,83,84,79,82,89,0,65,82,95,85,83,69,95,84,82,65,67,75,73,78,71,95,72,73,83,84,79,82,89,95,86,50,0,65,82,95,68,69,70,65,85,76,84,95,77,65,82,75,69,82,95,69,88,84,82,65,67,84,73,79,78,95,77,79,68,69,0,65,82,95,77,65,88,95,76,79,79,80,95,67,79,85,78,84,0,65,82,95,76,79,79,80,95,66,82,69,65,75,95,84,72,82,69,83,72,0,65,82,95,76,79,71,95,76,69,86,69,76,95,68,69,66,85,71,0,65,82,95,76,79,71,95,76,69,86,69,76,95,73,78,70,79,0,65,82,95,76,79,71,95,76,69,86,69,76,95,87,65,82,78,0,65,82,95,76,79,71,95,76,69,86,69,76,95,69,82,82,79,82,0,65,82,95,76,79,71,95,76,69,86,69,76,95,82,69,76,95,73,78,70,79,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,51,120,51,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,51,120,51,95,72,65,77,77,73,78,71,54,51,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,51,120,51,95,80,65,82,73,84,89,54,53,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,52,120,52,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,52,120,52,95,66,67,72,95,49,51,95,57,95,51,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,52,120,52,95,66,67,72,95,49,51,95,53,95,53,0,65,82,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,77,65,78,85,65,76,0,65,82,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,65,85,84,79,95,77,69,68,73,65,78,0,65,82,95,76,65],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE);allocate([66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,65,85,84,79,95,79,84,83,85,0,65,82,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,65,85,84,79,95,65,68,65,80,84,73,86,69,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,78,79,78,69,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,80,65,84,84,69,82,78,95,69,88,84,82,65,67,84,73,79,78,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,71,69,78,69,82,73,67,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,67,79,78,84,82,65,83,84,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,66,65,82,67,79,68,69,95,78,79,84,95,70,79,85,78,68,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,66,65,82,67,79,68,69,95,69,68,67,95,70,65,73,76,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,67,79,78,70,73,68,69,78,67,69,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,80,79,83,69,95,69,82,82,79,82,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,80,79,83,69,95,69,82,82,79,82,95,77,85,76,84,73,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,72,69,85,82,73,83,84,73,67,95,84,82,79,85,66,76,69,83,79,77,69,95,77,65,84,82,73,88,95,67,79,68,69,83,0,118,105,105,102,0,118,105,105,105,0,100,105,105,0,118,105,105,100,0,105,105,0,118,105,105,0,105,105,105,0,78,83,116,51,95,95,49,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,99,69,69,69,69,0,78,83,116,51,95,95,49,50,49,95,95,98,97,115,105,99,95,115,116,114,105,110,103,95,99,111,109,109,111,110,73,76,98,49,69,69,69,0,105,105,105,105,0,105,105,105,105,105,0,118,111,105,100,0,98,111,111,108,0,99,104,97,114,0,115,105,103,110,101,100,32,99,104,97,114,0,117,110,115,105,103,110,101,100,32,99,104,97,114,0,115,104,111,114,116,0,117,110,115,105,103,110,101,100,32,115,104,111,114,116,0,105,110,116,0,117,110,115,105,103,110,101,100,32,105,110,116,0,108,111,110,103,0,117,110,115,105,103,110,101,100,32,108,111,110,103,0,102,108,111,97,116,0,100,111,117,98,108,101,0,115,116,100,58,58,115,116,114,105,110,103,0,115,116,100,58,58,98,97,115,105,99,95,115,116,114,105,110,103,60,117,110,115,105,103,110,101,100,32,99,104,97,114,62,0,115,116,100,58,58,119,115,116,114,105,110,103,0,101,109,115,99,114,105,112,116,101,110,58,58,118,97,108,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,99,104,97,114,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,115,105,103,110,101,100,32,99,104,97,114,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,99,104,97,114,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,115,104,111,114,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,115,104,111,114,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,105,110,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,108,111,110,103,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,108,111,110,103,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,56,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,105,110,116,56,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,49,54,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,105,110,116,49,54,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,51,50,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,105,110,116,51,50,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,102,108,111,97,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,100,111,117,98,108,101,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,108,111,110,103,32,100,111,117,98,108,101,62,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,101,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,100,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,102,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,109,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,108,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,106,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,105,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,116,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,115,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,104,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,97,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,99,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,0,78,83,116,51,95,95,49,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,119,69,69,69,69,0,78,83,116,51,95,95,49,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,104,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,104,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,104,69,69,69,69,0,83,116,57,98,97,100,95,97,108,108,111,99,0,83,116,57,101,120,99,101,112,116,105,111,110,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,51,95,95,102,117,110,100,97,109,101,110,116,97,108,95,116,121,112,101,95,105,110,102,111,69,0,118,0,98,0,99,0,104,0,97,0,115,0,116,0,105,0,106,0,108,0,109,0,102,0,100,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,49,95,95,118,109,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,33,34,118,101,99,116,111,114,32,108,101,110,103,116,104,95,101,114,114,111,114,34,0,47,85,115,101,114,115,47,106,101,114,111,109,101,101,116,105,101,110,110,101,47,119,111,114,107,47,101,109,115,100,107,95,112,111,114,116,97,98,108,101,47,101,109,115,99,114,105,112,116,101,110,47,49,46,51,53,46,48,47,115,121,115,116,101,109,47,105,110,99,108,117,100,101,47,108,105,98,99,120,120,47,118,101,99,116,111,114,0,95,95,116,104,114,111,119,95,108,101,110,103,116,104,95,101,114,114,111,114,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,33,34,98,97,115,105,99,95,115,116,114,105,110,103,32,108,101,110,103,116,104,95,101,114,114,111,114,34,0,47,85,115,101,114,115,47,106,101,114,111,109,101,101,116,105,101,110,110,101,47,119,111,114,107,47,101,109,115,100,107,95,112,111,114,116,97,98,108,101,47,101,109,115,99,114,105,112,116,101,110,47,49,46,51,53,46,48,47,115,121,115,116,101,109,47,105,110,99,108,117,100,101,47,108,105,98,99,120,120,47,115,116,114,105,110,103,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,105,110,102,105,110,105,116,121,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,255,255,255,255,255,255,255,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,255,255,255,255,255,255,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,1,2,4,7,3,6,5,0,114,119,97],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE+10240);allocate([17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,46,0],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE+15945);var tempDoublePtr=Runtime.alignMemory(allocate(12,"i8",ALLOC_STATIC),8);assert(tempDoublePtr%8==0);function copyTempFloat(ptr){HEAP8[tempDoublePtr]=HEAP8[ptr];HEAP8[tempDoublePtr+1]=HEAP8[ptr+1];HEAP8[tempDoublePtr+2]=HEAP8[ptr+2];HEAP8[tempDoublePtr+3]=HEAP8[ptr+3]}function copyTempDouble(ptr){HEAP8[tempDoublePtr]=HEAP8[ptr];HEAP8[tempDoublePtr+1]=HEAP8[ptr+1];HEAP8[tempDoublePtr+2]=HEAP8[ptr+2];HEAP8[tempDoublePtr+3]=HEAP8[ptr+3];HEAP8[tempDoublePtr+4]=HEAP8[ptr+4];HEAP8[tempDoublePtr+5]=HEAP8[ptr+5];HEAP8[tempDoublePtr+6]=HEAP8[ptr+6];HEAP8[tempDoublePtr+7]=HEAP8[ptr+7]}function _atexit(func,arg){__ATEXIT__.unshift({func:func,arg:arg})}function ___cxa_atexit(){return _atexit.apply(null,arguments)}Module["_i64Subtract"]=_i64Subtract;function ___assert_fail(condition,filename,line,func){ABORT=true;throw"Assertion failed: "+Pointer_stringify(condition)+", at: "+[filename?Pointer_stringify(filename):"unknown filename",line,func?Pointer_stringify(func):"unknown function"]+" at "+stackTrace()}function embind_init_charCodes(){var codes=new Array(256);for(var i=0;i<256;++i){codes[i]=String.fromCharCode(i)}embind_charCodes=codes}var embind_charCodes=undefined;function readLatin1String(ptr){var ret="";var c=ptr;while(HEAPU8[c]){ret+=embind_charCodes[HEAPU8[c++]]}return ret}var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var char_0=48;var char_9=57;function makeLegalFunctionName(name){if(undefined===name){return"_unknown"}name=name.replace(/[^a-zA-Z0-9_]/g,"$");var f=name.charCodeAt(0);if(f>=char_0&&f<=char_9){return"_"+name}else{return name}}function createNamedFunction(name,body){name=makeLegalFunctionName(name);return(new Function("body","return function "+name+"() {\n"+' "use strict";'+" return body.apply(this, arguments);\n"+"};\n"))(body)}function extendError(baseErrorType,errorName){var errorClass=createNamedFunction(errorName,(function(message){this.name=errorName;this.message=message;var stack=(new Error(message)).stack;if(stack!==undefined){this.stack=this.toString()+"\n"+stack.replace(/^Error(:[^\n]*)?\n/,"")}}));errorClass.prototype=Object.create(baseErrorType.prototype);errorClass.prototype.constructor=errorClass;errorClass.prototype.toString=(function(){if(this.message===undefined){return this.name}else{return this.name+": "+this.message}});return errorClass}var BindingError=undefined;function throwBindingError(message){throw new BindingError(message)}var InternalError=undefined;function throwInternalError(message){throw new InternalError(message)}function whenDependentTypesAreResolved(myTypes,dependentTypes,getTypeConverters){myTypes.forEach((function(type){typeDependencies[type]=dependentTypes}));function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i<myTypes.length;++i){registerType(myTypes[i],myTypeConverters[i])}}var typeConverters=new Array(dependentTypes.length);var unregisteredTypes=[];var registered=0;dependentTypes.forEach((function(dt,i){if(registeredTypes.hasOwnProperty(dt)){typeConverters[i]=registeredTypes[dt]}else{unregisteredTypes.push(dt);if(!awaitingDependencies.hasOwnProperty(dt)){awaitingDependencies[dt]=[]}awaitingDependencies[dt].push((function(){typeConverters[i]=registeredTypes[dt];++registered;if(registered===unregisteredTypes.length){onComplete(typeConverters)}}))}}));if(0===unregisteredTypes.length){onComplete(typeConverters)}}function registerType(rawType,registeredInstance,options){options=options||{};if(!("argPackAdvance"in registeredInstance)){throw new TypeError("registerType registeredInstance requires argPackAdvance")}var name=registeredInstance.name;if(!rawType){throwBindingError('type "'+name+'" must have a positive integer typeid pointer')}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError("Cannot register type '"+name+"' twice")}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach((function(cb){cb()}))}}function __embind_register_void(rawType,name){name=readLatin1String(name);registerType(rawType,{isVoid:true,name:name,"argPackAdvance":0,"fromWireType":(function(){return undefined}),"toWireType":(function(destructors,o){return undefined})})}function __ZSt18uncaught_exceptionv(){return!!__ZSt18uncaught_exceptionv.uncaught_exception}var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:(function(adjusted){if(!adjusted||EXCEPTIONS.infos[adjusted])return adjusted;for(var ptr in EXCEPTIONS.infos){var info=EXCEPTIONS.infos[ptr];if(info.adjusted===adjusted){return ptr}}return adjusted}),addRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount++}),decRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];assert(info.refcount>0);info.refcount--;if(info.refcount===0){if(info.destructor){Runtime.dynCall("vi",info.destructor,[ptr])}delete EXCEPTIONS.infos[ptr];___cxa_free_exception(ptr)}}),clearRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount=0})};function ___resumeException(ptr){if(!EXCEPTIONS.last){EXCEPTIONS.last=ptr}EXCEPTIONS.clearRef(EXCEPTIONS.deAdjust(ptr));throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var thrown=EXCEPTIONS.last;if(!thrown){return(asm["setTempRet0"](0),0)|0}var info=EXCEPTIONS.infos[thrown];var throwntype=info.type;if(!throwntype){return(asm["setTempRet0"](0),thrown)|0}var typeArray=Array.prototype.slice.call(arguments);var pointer=Module["___cxa_is_pointer_type"](throwntype);if(!___cxa_find_matching_catch.buffer)___cxa_find_matching_catch.buffer=_malloc(4);HEAP32[___cxa_find_matching_catch.buffer>>2]=thrown;thrown=___cxa_find_matching_catch.buffer;for(var i=0;i<typeArray.length;i++){if(typeArray[i]&&Module["___cxa_can_catch"](typeArray[i],throwntype,thrown)){thrown=HEAP32[thrown>>2];info.adjusted=thrown;return(asm["setTempRet0"](typeArray[i]),thrown)|0}}thrown=HEAP32[thrown>>2];return(asm["setTempRet0"](throwntype),thrown)|0}function ___cxa_throw(ptr,type,destructor){EXCEPTIONS.infos[ptr]={ptr:ptr,adjusted:ptr,type:type,destructor:destructor,refcount:0};EXCEPTIONS.last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exception=1}else{__ZSt18uncaught_exceptionv.uncaught_exception++}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}Module["_memset"]=_memset;var _BDtoILow=true;function getShiftFromSize(size){switch(size){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+size)}}function __embind_register_bool(rawType,name,size,trueValue,falseValue){var shift=getShiftFromSize(size);name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":(function(wt){return!!wt}),"toWireType":(function(destructors,o){return o?trueValue:falseValue}),"argPackAdvance":8,"readValueFromPointer":(function(pointer){var heap;if(size===1){heap=HEAP8}else if(size===2){heap=HEAP16}else if(size===4){heap=HEAP32}else{throw new TypeError("Unknown boolean type size: "+name)}return this["fromWireType"](heap[pointer>>shift])}),destructorFunction:null})}Module["_bitshift64Shl"]=_bitshift64Shl;function _abort(){Module["abort"]()}function _free(){}Module["_free"]=_free;function _malloc(bytes){var ptr=Runtime.dynamicAlloc(bytes+8);return ptr+8&4294967288}Module["_malloc"]=_malloc;function simpleReadValueFromPointer(pointer){return this["fromWireType"](HEAPU32[pointer>>2])}function __embind_register_std_string(rawType,name){name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":(function(value){var length=HEAPU32[value>>2];var a=new Array(length);for(var i=0;i<length;++i){a[i]=String.fromCharCode(HEAPU8[value+4+i])}_free(value);return a.join("")}),"toWireType":(function(destructors,value){if(value instanceof ArrayBuffer){value=new Uint8Array(value)}function getTAElement(ta,index){return ta[index]}function getStringElement(string,index){return string.charCodeAt(index)}var getElement;if(value instanceof Uint8Array){getElement=getTAElement}else if(value instanceof Int8Array){getElement=getTAElement}else if(typeof value==="string"){getElement=getStringElement}else{throwBindingError("Cannot pass non-string to std::string")}var length=value.length;var ptr=_malloc(4+length);HEAPU32[ptr>>2]=length;for(var i=0;i<length;++i){var charCode=getElement(value,i);if(charCode>255){_free(ptr);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+4+i]=charCode}if(destructors!==null){destructors.push(_free,ptr)}return ptr}),"argPackAdvance":8,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:(function(ptr){_free(ptr)})})}function __embind_register_std_wstring(rawType,charSize,name){name=readLatin1String(name);var getHeap,shift;if(charSize===2){getHeap=(function(){return HEAPU16});shift=1}else if(charSize===4){getHeap=(function(){return HEAPU32});shift=2}registerType(rawType,{name:name,"fromWireType":(function(value){var HEAP=getHeap();var length=HEAPU32[value>>2];var a=new Array(length);var start=value+4>>shift;for(var i=0;i<length;++i){a[i]=String.fromCharCode(HEAP[start+i])}_free(value);return a.join("")}),"toWireType":(function(destructors,value){var HEAP=getHeap();var length=value.length;var ptr=_malloc(4+length*charSize);HEAPU32[ptr>>2]=length;var start=ptr+4>>shift;for(var i=0;i<length;++i){HEAP[start+i]=value.charCodeAt(i)}if(destructors!==null){destructors.push(_free,ptr)}return ptr}),"argPackAdvance":8,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:(function(ptr){_free(ptr)})})}function ___lock(){}function ___unlock(){}var _emscripten_asm_const_int=true;Module["_i64Add"]=_i64Add;var _fabs=Math_abs;var _sqrt=Math_sqrt;function _embind_repr(v){if(v===null){return"null"}var t=typeof v;if(t==="object"||t==="array"||t==="function"){return v.toString()}else{return""+v}}function integerReadValueFromPointer(name,shift,signed){switch(shift){case 0:return signed?function readS8FromPointer(pointer){return HEAP8[pointer]}:function readU8FromPointer(pointer){return HEAPU8[pointer]};case 1:return signed?function readS16FromPointer(pointer){return HEAP16[pointer>>1]}:function readU16FromPointer(pointer){return HEAPU16[pointer>>1]};case 2:return signed?function readS32FromPointer(pointer){return HEAP32[pointer>>2]}:function readU32FromPointer(pointer){return HEAPU32[pointer>>2]};default:throw new TypeError("Unknown integer type: "+name)}}function __embind_register_integer(primitiveType,name,size,minRange,maxRange){name=readLatin1String(name);if(maxRange===-1){maxRange=4294967295}var shift=getShiftFromSize(size);var fromWireType=(function(value){return value});if(minRange===0){var bitshift=32-8*size;fromWireType=(function(value){return value<<bitshift>>>bitshift})}registerType(primitiveType,{name:name,"fromWireType":fromWireType,"toWireType":(function(destructors,value){if(typeof value!=="number"&&typeof value!=="boolean"){throw new TypeError('Cannot convert "'+_embind_repr(value)+'" to '+this.name)}if(value<minRange||value>maxRange){throw new TypeError('Passing a number "'+_embind_repr(value)+'" from JS side to C/C++ side to an argument of type "'+name+'", which is outside the valid range ['+minRange+", "+maxRange+"]!")}return value|0}),"argPackAdvance":8,"readValueFromPointer":integerReadValueFromPointer(name,shift,minRange!==0),destructorFunction:null})}var emval_free_list=[];var emval_handle_array=[{},{value:undefined},{value:null},{value:true},{value:false}];function __emval_decref(handle){if(handle>4&&0===--emval_handle_array[handle].refcount){emval_handle_array[handle]=undefined;emval_free_list.push(handle)}}function count_emval_handles(){var count=0;for(var i=5;i<emval_handle_array.length;++i){if(emval_handle_array[i]!==undefined){++count}}return count}function get_first_emval(){for(var i=5;i<emval_handle_array.length;++i){if(emval_handle_array[i]!==undefined){return emval_handle_array[i]}}return null}function init_emval(){Module["count_emval_handles"]=count_emval_handles;Module["get_first_emval"]=get_first_emval}function __emval_register(value){switch(value){case undefined:{return 1};case null:{return 2};case true:{return 3};case false:{return 4};default:{var handle=emval_free_list.length?emval_free_list.pop():emval_handle_array.length;emval_handle_array[handle]={refcount:1,value:value};return handle}}}function __embind_register_emval(rawType,name){name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":(function(handle){var rv=emval_handle_array[handle].value;__emval_decref(handle);return rv}),"toWireType":(function(destructors,value){return __emval_register(value)}),"argPackAdvance":8,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:null})}function ___cxa_allocate_exception(size){return _malloc(size)}var _sin=Math_sin;function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};function _sysconf(name){switch(name){case 30:return PAGE_SIZE;case 85:return totalMemory/PAGE_SIZE;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:{if(typeof navigator==="object")return navigator["hardwareConcurrency"]||1;return 1}}___setErrNo(ERRNO_CODES.EINVAL);return-1}Module["_bitshift64Lshr"]=_bitshift64Lshr;function __exit(status){Module["exit"](status)}function _exit(status){__exit(status)}var _llvm_ctlz_i32=true;function floatReadValueFromPointer(name,shift){switch(shift){case 2:return(function(pointer){return this["fromWireType"](HEAPF32[pointer>>2])});case 3:return(function(pointer){return this["fromWireType"](HEAPF64[pointer>>3])});default:throw new TypeError("Unknown float type: "+name)}}function __embind_register_float(rawType,name,size){var shift=getShiftFromSize(size);name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":(function(value){return value}),"toWireType":(function(destructors,value){if(typeof value!=="number"&&typeof value!=="boolean"){throw new TypeError('Cannot convert "'+_embind_repr(value)+'" to '+this.name)}return value}),"argPackAdvance":8,"readValueFromPointer":floatReadValueFromPointer(name,shift),destructorFunction:null})}var _BDtoIHigh=true;function _pthread_cleanup_push(routine,arg){__ATEXIT__.push((function(){Runtime.dynCall("vi",routine,[arg])}));_pthread_cleanup_push.level=__ATEXIT__.length}function new_(constructor,argumentList){if(!(constructor instanceof Function)){throw new TypeError("new_ called with constructor type "+typeof constructor+" which is not a function")}var dummy=createNamedFunction(constructor.name||"unknownFunctionName",(function(){}));dummy.prototype=constructor.prototype;var obj=new dummy;var r=constructor.apply(obj,argumentList);return r instanceof Object?r:obj}function runDestructors(destructors){while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}}function craftInvokerFunction(humanName,argTypes,classType,cppInvokerFunc,cppTargetFunc){var argCount=argTypes.length;if(argCount<2){throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!")}var isClassMethodFunc=argTypes[1]!==null&&classType!==null;var argsList="";var argsListWired="";for(var i=0;i<argCount-2;++i){argsList+=(i!==0?", ":"")+"arg"+i;argsListWired+=(i!==0?", ":"")+"arg"+i+"Wired"}var invokerFnBody="return function "+makeLegalFunctionName(humanName)+"("+argsList+") {\n"+"if (arguments.length !== "+(argCount-2)+") {\n"+"throwBindingError('function "+humanName+" called with ' + arguments.length + ' arguments, expected "+(argCount-2)+" args!');\n"+"}\n";var needsDestructorStack=false;for(var i=1;i<argTypes.length;++i){if(argTypes[i]!==null&&argTypes[i].destructorFunction===undefined){needsDestructorStack=true;break}}if(needsDestructorStack){invokerFnBody+="var destructors = [];\n"}var dtorStack=needsDestructorStack?"destructors":"null";var args1=["throwBindingError","invoker","fn","runDestructors","retType","classParam"];var args2=[throwBindingError,cppInvokerFunc,cppTargetFunc,runDestructors,argTypes[0],argTypes[1]];if(isClassMethodFunc){invokerFnBody+="var thisWired = classParam.toWireType("+dtorStack+", this);\n"}for(var i=0;i<argCount-2;++i){invokerFnBody+="var arg"+i+"Wired = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n";args1.push("argType"+i);args2.push(argTypes[i+2])}if(isClassMethodFunc){argsListWired="thisWired"+(argsListWired.length>0?", ":"")+argsListWired}var returns=argTypes[0].name!=="void";invokerFnBody+=(returns?"var rv = ":"")+"invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";if(needsDestructorStack){invokerFnBody+="runDestructors(destructors);\n"}else{for(var i=isClassMethodFunc?1:2;i<argTypes.length;++i){var paramName=i===1?"thisWired":"arg"+(i-2)+"Wired";if(argTypes[i].destructorFunction!==null){invokerFnBody+=paramName+"_dtor("+paramName+"); // "+argTypes[i].name+"\n";args1.push(paramName+"_dtor");args2.push(argTypes[i].destructorFunction)}}}if(returns){invokerFnBody+="var ret = retType.fromWireType(rv);\n"+"return ret;\n"}else{}invokerFnBody+="}\n";args1.push(invokerFnBody);var invokerFunction=new_(Function,args1).apply(null,args2);return invokerFunction}function ensureOverloadTable(proto,methodName,humanName){if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=(function(){if(!proto[methodName].overloadTable.hasOwnProperty(arguments.length)){throwBindingError("Function '"+humanName+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+proto[methodName].overloadTable+")!")}return proto[methodName].overloadTable[arguments.length].apply(this,arguments)});proto[methodName].overloadTable=[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}}function exposePublicSymbol(name,value,numArguments){if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments]){throwBindingError("Cannot register public name '"+name+"' twice")}ensureOverloadTable(Module,name,name);if(Module.hasOwnProperty(numArguments)){throwBindingError("Cannot register multiple overloads of a function with the same number of arguments ("+numArguments+")!")}Module[name].overloadTable[numArguments]=value}else{Module[name]=value;if(undefined!==numArguments){Module[name].numArguments=numArguments}}}function heap32VectorToArray(count,firstElement){var array=[];for(var i=0;i<count;i++){array.push(HEAP32[(firstElement>>2)+i])}return array}function replacePublicSymbol(name,value,numArguments){if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistant public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value}}function requireFunction(signature,rawFunction){signature=readLatin1String(signature);function makeDynCaller(dynCall){var args=[];for(var i=1;i<signature.length;++i){args.push("a"+i)}var name="dynCall_"+signature+"_"+rawFunction;var body="return function "+name+"("+args.join(", ")+") {\n";body+=" return dynCall(rawFunction"+(args.length?", ":"")+args.join(", ")+");\n";body+="};\n";return(new Function("dynCall","rawFunction",body))(dynCall,rawFunction)}var fp;if(Module["FUNCTION_TABLE_"+signature]!==undefined){fp=Module["FUNCTION_TABLE_"+signature][rawFunction]}else if(typeof FUNCTION_TABLE!=="undefined"){fp=FUNCTION_TABLE[rawFunction]}else{var dc=asm["dynCall_"+signature];if(dc===undefined){dc=asm["dynCall_"+signature.replace(/f/g,"d")];if(dc===undefined){throwBindingError("No dynCall invoker for signature: "+signature)}}fp=makeDynCaller(dc)}if(typeof fp!=="function"){throwBindingError("unknown function pointer with signature "+signature+": "+rawFunction)}return fp}var UnboundTypeError=undefined;function getTypeName(type){var ptr=___getTypeName(type);var rv=readLatin1String(ptr);_free(ptr);return rv}function throwUnboundTypeError(message,types){var unboundTypes=[];var seen={};function visit(type){if(seen[type]){return}if(registeredTypes[type]){return}if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(message+": "+unboundTypes.map(getTypeName).join([", "]))}function __embind_register_function(name,argCount,rawArgTypesAddr,signature,rawInvoker,fn){var argTypes=heap32VectorToArray(argCount,rawArgTypesAddr);name=readLatin1String(name);rawInvoker=requireFunction(signature,rawInvoker);exposePublicSymbol(name,(function(){throwUnboundTypeError("Cannot call "+name+" due to unbound types",argTypes)}),argCount-1);whenDependentTypesAreResolved([],argTypes,(function(argTypes){var invokerArgsArray=[argTypes[0],null].concat(argTypes.slice(1));replacePublicSymbol(name,craftInvokerFunction(name,invokerArgsArray,null,rawInvoker,fn),argCount-1);return[]}))}function __embind_register_constant(name,type,value){name=readLatin1String(name);whenDependentTypesAreResolved([],[type],(function(type){type=type[0];Module[name]=type["fromWireType"](value);return[]}))}function _pthread_cleanup_pop(){assert(_pthread_cleanup_push.level==__ATEXIT__.length,"cannot pop if something else added meanwhile!");__ATEXIT__.pop();_pthread_cleanup_push.level=__ATEXIT__.length}var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};var PATH={splitPath:(function(filename){var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)}),normalizeArray:(function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}),normalize:(function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter((function(p){return!!p})),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path}),dirname:(function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir}),basename:(function(path){if(path==="/")return"/";var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)}),extname:(function(path){return PATH.splitPath(path)[3]}),join:(function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))}),join2:(function(l,r){return PATH.normalize(l+"/"+r)}),resolve:(function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter((function(p){return!!p})),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."}),relative:(function(from,to){from=PATH.resolve(from).substr(1);to=PATH.resolve(to).substr(1);function trim(arr){var start=0;for(;start<arr.length;start++){if(arr[start]!=="")break}var end=arr.length-1;for(;end>=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i<length;i++){if(fromParts[i]!==toParts[i]){samePartsLength=i;break}}var outputParts=[];for(var i=samePartsLength;i<fromParts.length;i++){outputParts.push("..")}outputParts=outputParts.concat(toParts.slice(samePartsLength));return outputParts.join("/")})};var TTY={ttys:[],init:(function(){}),shutdown:(function(){}),register:(function(dev,ops){TTY.ttys[dev]={input:[],output:[],ops:ops};FS.registerDevice(dev,TTY.stream_ops)}),stream_ops:{open:(function(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(ERRNO_CODES.ENODEV)}stream.tty=tty;stream.seekable=false}),close:(function(stream){stream.tty.ops.flush(stream.tty)}),flush:(function(stream){stream.tty.ops.flush(stream.tty)}),read:(function(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(ERRNO_CODES.ENXIO)}var bytesRead=0;for(var i=0;i<length;i++){var result;try{result=stream.tty.ops.get_char(stream.tty)}catch(e){throw new FS.ErrnoError(ERRNO_CODES.EIO)}if(result===undefined&&bytesRead===0){throw new FS.ErrnoError(ERRNO_CODES.EAGAIN)}if(result===null||result===undefined)break;bytesRead++;buffer[offset+i]=result}if(bytesRead){stream.node.timestamp=Date.now()}return bytesRead}),write:(function(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.put_char){throw new FS.ErrnoError(ERRNO_CODES.ENXIO)}for(var i=0;i<length;i++){try{stream.tty.ops.put_char(stream.tty,buffer[offset+i])}catch(e){throw new FS.ErrnoError(ERRNO_CODES.EIO)}}if(length){stream.node.timestamp=Date.now()}return i})},default_tty_ops:{get_char:(function(tty){if(!tty.input.length){var result=null;if(ENVIRONMENT_IS_NODE){var BUFSIZE=256;var buf=new Buffer(BUFSIZE);var bytesRead=0;var fd=process.stdin.fd;var usingDevice=false;try{fd=fs.openSync("/dev/stdin","r");usingDevice=true}catch(e){}bytesRead=fs.readSync(fd,buf,0,BUFSIZE,null);if(usingDevice){fs.closeSync(fd)}if(bytesRead>0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()}),put_char:(function(tty,val){if(val===null||val===10){Module["print"](UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}}),flush:(function(tty){if(tty.output&&tty.output.length>0){Module["print"](UTF8ArrayToString(tty.output,0));tty.output=[]}})},default_tty1_ops:{put_char:(function(tty,val){if(val===null||val===10){Module["printErr"](UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}}),flush:(function(tty){if(tty.output&&tty.output.length>0){Module["printErr"](UTF8ArrayToString(tty.output,0));tty.output=[]}})}};var MEMFS={ops_table:null,mount:(function(mount){return MEMFS.createNode(null,"/",16384|511,0)}),createNode:(function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node}return node}),getFileDataAsRegularArray:(function(node){if(node.contents&&node.contents.subarray){var arr=[];for(var i=0;i<node.usedBytes;++i)arr.push(node.contents[i]);return arr}return node.contents}),getFileDataAsTypedArray:(function(node){if(!node.contents)return new Uint8Array;if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)}),expandFileStorage:(function(node,newCapacity){if(node.contents&&node.contents.subarray&&newCapacity>node.contents.length){node.contents=MEMFS.getFileDataAsRegularArray(node);node.usedBytes=node.contents.length}if(!node.contents||node.contents.subarray){var prevCapacity=node.contents?node.contents.buffer.byteLength:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity<CAPACITY_DOUBLING_MAX?2:1.125)|0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0);return}if(!node.contents&&newCapacity>0)node.contents=[];while(node.contents.length<newCapacity)node.contents.push(0)}),resizeFileStorage:(function(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0;return}if(!node.contents||node.contents.subarray){var oldContents=node.contents;node.contents=new Uint8Array(new ArrayBuffer(newSize));if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize;return}if(!node.contents)node.contents=[];if(node.contents.length>newSize)node.contents.length=newSize;else while(node.contents.length<newSize)node.contents.push(0);node.usedBytes=newSize}),node_ops:{getattr:(function(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.timestamp);attr.mtime=new Date(node.timestamp);attr.ctime=new Date(node.timestamp);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr}),setattr:(function(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}}),lookup:(function(parent,name){throw FS.genericErrors[ERRNO_CODES.ENOENT]}),mknod:(function(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)}),rename:(function(old_node,new_dir,new_name){if(FS.isDir(old_node.mode)){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){for(var i in new_node.contents){throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY)}}}delete old_node.parent.contents[old_node.name];old_node.name=new_name;new_dir.contents[new_name]=old_node;old_node.parent=new_dir}),unlink:(function(parent,name){delete parent.contents[name]}),rmdir:(function(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY)}delete parent.contents[name]}),readdir:(function(node){var entries=[".",".."];for(var key in node.contents){if(!node.contents.hasOwnProperty(key)){continue}entries.push(key)}return entries}),symlink:(function(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node}),readlink:(function(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return node.link})},stream_ops:{read:(function(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);assert(size>=0);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i<size;i++)buffer[offset+i]=contents[position+i]}return size}),write:(function(stream,buffer,offset,length,position,canOwn){if(!length)return 0;var node=stream.node;node.timestamp=Date.now();if(buffer.subarray&&(!node.contents||node.contents.subarray)){if(canOwn){node.contents=buffer.subarray(offset,offset+length);node.usedBytes=length;return length}else if(node.usedBytes===0&&position===0){node.contents=new Uint8Array(buffer.subarray(offset,offset+length));node.usedBytes=length;return length}else if(position+length<=node.usedBytes){node.contents.set(buffer.subarray(offset,offset+length),position);return length}}MEMFS.expandFileStorage(node,position+length);if(node.contents.subarray&&buffer.subarray)node.contents.set(buffer.subarray(offset,offset+length),position);else{for(var i=0;i<length;i++){node.contents[position+i]=buffer[offset+i]}}node.usedBytes=Math.max(node.usedBytes,position+length);return length}),llseek:(function(stream,offset,whence){var position=offset;if(whence===1){position+=stream.position}else if(whence===2){if(FS.isFile(stream.node.mode)){position+=stream.node.usedBytes}}if(position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return position}),allocate:(function(stream,offset,length){MEMFS.expandFileStorage(stream.node,offset+length);stream.node.usedBytes=Math.max(stream.node.usedBytes,offset+length)}),mmap:(function(stream,buffer,offset,length,position,prot,flags){if(!FS.isFile(stream.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENODEV)}var ptr;var allocated;var contents=stream.node.contents;if(!(flags&2)&&(contents.buffer===buffer||contents.buffer===buffer.buffer)){allocated=false;ptr=contents.byteOffset}else{if(position>0||position+length<stream.node.usedBytes){if(contents.subarray){contents=contents.subarray(position,position+length)}else{contents=Array.prototype.slice.call(contents,position,position+length)}}allocated=true;ptr=_malloc(length);if(!ptr){throw new FS.ErrnoError(ERRNO_CODES.ENOMEM)}buffer.set(contents,ptr)}return{ptr:ptr,allocated:allocated}}),msync:(function(stream,buffer,offset,length,mmapFlags){if(!FS.isFile(stream.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENODEV)}if(mmapFlags&2){return 0}var bytesWritten=MEMFS.stream_ops.write(stream,buffer,0,length,offset,false);return 0})}};var IDBFS={dbs:{},indexedDB:(function(){if(typeof indexedDB!=="undefined")return indexedDB;var ret=null;if(typeof window==="object")ret=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB;assert(ret,"IDBFS used, but indexedDB not supported");return ret}),DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:(function(mount){return MEMFS.mount.apply(null,arguments)}),syncfs:(function(mount,populate,callback){IDBFS.getLocalSet(mount,(function(err,local){if(err)return callback(err);IDBFS.getRemoteSet(mount,(function(err,remote){if(err)return callback(err);var src=populate?remote:local;var dst=populate?local:remote;IDBFS.reconcile(src,dst,callback)}))}))}),getDB:(function(name,callback){var db=IDBFS.dbs[name];if(db){return callback(null,db)}var req;try{req=IDBFS.indexedDB().open(name,IDBFS.DB_VERSION)}catch(e){return callback(e)}req.onupgradeneeded=(function(e){var db=e.target.result;var transaction=e.target.transaction;var fileStore;if(db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)){fileStore=transaction.objectStore(IDBFS.DB_STORE_NAME)}else{fileStore=db.createObjectStore(IDBFS.DB_STORE_NAME)}if(!fileStore.indexNames.contains("timestamp")){fileStore.createIndex("timestamp","timestamp",{unique:false})}});req.onsuccess=(function(){db=req.result;IDBFS.dbs[name]=db;callback(null,db)});req.onerror=(function(e){callback(this.error);e.preventDefault()})}),getLocalSet:(function(mount,callback){var entries={};function isRealDir(p){return p!=="."&&p!==".."}function toAbsolute(root){return(function(p){return PATH.join2(root,p)})}var check=FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));while(check.length){var path=check.pop();var stat;try{stat=FS.stat(path)}catch(e){return callback(e)}if(FS.isDir(stat.mode)){check.push.apply(check,FS.readdir(path).filter(isRealDir).map(toAbsolute(path)))}entries[path]={timestamp:stat.mtime}}return callback(null,{type:"local",entries:entries})}),getRemoteSet:(function(mount,callback){var entries={};IDBFS.getDB(mount.mountpoint,(function(err,db){if(err)return callback(err);var transaction=db.transaction([IDBFS.DB_STORE_NAME],"readonly");transaction.onerror=(function(e){callback(this.error);e.preventDefault()});var store=transaction.objectStore(IDBFS.DB_STORE_NAME);var index=store.index("timestamp");index.openKeyCursor().onsuccess=(function(event){var cursor=event.target.result;if(!cursor){return callback(null,{type:"remote",db:db,entries:entries})}entries[cursor.primaryKey]={timestamp:cursor.key};cursor.continue()})}))}),loadLocalEntry:(function(path,callback){var stat,node;try{var lookup=FS.lookupPath(path);node=lookup.node;stat=FS.stat(path)}catch(e){return callback(e)}if(FS.isDir(stat.mode)){return callback(null,{timestamp:stat.mtime,mode:stat.mode})}else if(FS.isFile(stat.mode)){node.contents=MEMFS.getFileDataAsTypedArray(node);return callback(null,{timestamp:stat.mtime,mode:stat.mode,contents:node.contents})}else{return callback(new Error("node type not supported"))}}),storeLocalEntry:(function(path,entry,callback){try{if(FS.isDir(entry.mode)){FS.mkdir(path,entry.mode)}else if(FS.isFile(entry.mode)){FS.writeFile(path,entry.contents,{encoding:"binary",canOwn:true})}else{return callback(new Error("node type not supported"))}FS.chmod(path,entry.mode);FS.utime(path,entry.timestamp,entry.timestamp)}catch(e){return callback(e)}callback(null)}),removeLocalEntry:(function(path,callback){try{var lookup=FS.lookupPath(path);var stat=FS.stat(path);if(FS.isDir(stat.mode)){FS.rmdir(path)}else if(FS.isFile(stat.mode)){FS.unlink(path)}}catch(e){return callback(e)}callback(null)}),loadRemoteEntry:(function(store,path,callback){var req=store.get(path);req.onsuccess=(function(event){callback(null,event.target.result)});req.onerror=(function(e){callback(this.error);e.preventDefault()})}),storeRemoteEntry:(function(store,path,entry,callback){var req=store.put(entry,path);req.onsuccess=(function(){callback(null)});req.onerror=(function(e){callback(this.error);e.preventDefault()})}),removeRemoteEntry:(function(store,path,callback){var req=store.delete(path);req.onsuccess=(function(){callback(null)});req.onerror=(function(e){callback(this.error);e.preventDefault()})}),reconcile:(function(src,dst,callback){var total=0;var create=[];Object.keys(src.entries).forEach((function(key){var e=src.entries[key];var e2=dst.entries[key];if(!e2||e.timestamp>e2.timestamp){create.push(key);total++}}));var remove=[];Object.keys(dst.entries).forEach((function(key){var e=dst.entries[key];var e2=src.entries[key];if(!e2){remove.push(key);total++}}));if(!total){return callback(null)}var errored=false;var completed=0;var db=src.type==="remote"?src.db:dst.db;var transaction=db.transaction([IDBFS.DB_STORE_NAME],"readwrite");var store=transaction.objectStore(IDBFS.DB_STORE_NAME);function done(err){if(err){if(!done.errored){done.errored=true;return callback(err)}return}if(++completed>=total){return callback(null)}}transaction.onerror=(function(e){done(this.error);e.preventDefault()});create.sort().forEach((function(path){if(dst.type==="local"){IDBFS.loadRemoteEntry(store,path,(function(err,entry){if(err)return done(err);IDBFS.storeLocalEntry(path,entry,done)}))}else{IDBFS.loadLocalEntry(path,(function(err,entry){if(err)return done(err);IDBFS.storeRemoteEntry(store,path,entry,done)}))}}));remove.sort().reverse().forEach((function(path){if(dst.type==="local"){IDBFS.removeLocalEntry(path,done)}else{IDBFS.removeRemoteEntry(store,path,done)}}))})};var NODEFS={isWindows:false,staticInit:(function(){NODEFS.isWindows=!!process.platform.match(/^win/)}),mount:(function(mount){assert(ENVIRONMENT_IS_NODE);return NODEFS.createNode(null,"/",NODEFS.getMode(mount.opts.root),0)}),createNode:(function(parent,name,mode,dev){if(!FS.isDir(mode)&&!FS.isFile(mode)&&!FS.isLink(mode)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node=FS.createNode(parent,name,mode);node.node_ops=NODEFS.node_ops;node.stream_ops=NODEFS.stream_ops;return node}),getMode:(function(path){var stat;try{stat=fs.lstatSync(path);if(NODEFS.isWindows){stat.mode=stat.mode|(stat.mode&146)>>1}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}return stat.mode}),realPath:(function(node){var parts=[];while(node.parent!==node){parts.push(node.name);node=node.parent}parts.push(node.mount.opts.root);parts.reverse();return PATH.join.apply(null,parts)}),flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:(function(flags){flags&=~32768;if(flags in NODEFS.flagsToPermissionStringMap){return NODEFS.flagsToPermissionStringMap[flags]}else{throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}}),node_ops:{getattr:(function(node){var path=NODEFS.realPath(node);var stat;try{stat=fs.lstatSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}if(NODEFS.isWindows&&!stat.blksize){stat.blksize=4096}if(NODEFS.isWindows&&!stat.blocks){stat.blocks=(stat.size+stat.blksize-1)/stat.blksize|0}return{dev:stat.dev,ino:stat.ino,mode:stat.mode,nlink:stat.nlink,uid:stat.uid,gid:stat.gid,rdev:stat.rdev,size:stat.size,atime:stat.atime,mtime:stat.mtime,ctime:stat.ctime,blksize:stat.blksize,blocks:stat.blocks}}),setattr:(function(node,attr){var path=NODEFS.realPath(node);try{if(attr.mode!==undefined){fs.chmodSync(path,attr.mode);node.mode=attr.mode}if(attr.timestamp!==undefined){var date=new Date(attr.timestamp);fs.utimesSync(path,date,date)}if(attr.size!==undefined){fs.truncateSync(path,attr.size)}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),lookup:(function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);var mode=NODEFS.getMode(path);return NODEFS.createNode(parent,name,mode)}),mknod:(function(parent,name,mode,dev){var node=NODEFS.createNode(parent,name,mode,dev);var path=NODEFS.realPath(node);try{if(FS.isDir(node.mode)){fs.mkdirSync(path,node.mode)}else{fs.writeFileSync(path,"",{mode:node.mode})}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}return node}),rename:(function(oldNode,newDir,newName){var oldPath=NODEFS.realPath(oldNode);var newPath=PATH.join2(NODEFS.realPath(newDir),newName);try{fs.renameSync(oldPath,newPath)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),unlink:(function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);try{fs.unlinkSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),rmdir:(function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);try{fs.rmdirSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),readdir:(function(node){var path=NODEFS.realPath(node);try{return fs.readdirSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),symlink:(function(parent,newName,oldPath){var newPath=PATH.join2(NODEFS.realPath(parent),newName);try{fs.symlinkSync(oldPath,newPath)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),readlink:(function(node){var path=NODEFS.realPath(node);try{path=fs.readlinkSync(path);path=NODEJS_PATH.relative(NODEJS_PATH.resolve(node.mount.opts.root),path);return path}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}})},stream_ops:{open:(function(stream){var path=NODEFS.realPath(stream.node);try{if(FS.isFile(stream.node.mode)){stream.nfd=fs.openSync(path,NODEFS.flagsToPermissionString(stream.flags))}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),close:(function(stream){try{if(FS.isFile(stream.node.mode)&&stream.nfd){fs.closeSync(stream.nfd)}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),read:(function(stream,buffer,offset,length,position){if(length===0)return 0;var nbuffer=new Buffer(length);var res;try{res=fs.readSync(stream.nfd,nbuffer,0,length,position)}catch(e){throw new FS.ErrnoError(ERRNO_CODES[e.code])}if(res>0){for(var i=0;i<res;i++){buffer[offset+i]=nbuffer[i]}}return res}),write:(function(stream,buffer,offset,length,position){var nbuffer=new Buffer(buffer.subarray(offset,offset+length));var res;try{res=fs.writeSync(stream.nfd,nbuffer,0,length,position)}catch(e){throw new FS.ErrnoError(ERRNO_CODES[e.code])}return res}),llseek:(function(stream,offset,whence){var position=offset;if(whence===1){position+=stream.position}else if(whence===2){if(FS.isFile(stream.node.mode)){try{var stat=fs.fstatSync(stream.nfd);position+=stat.size}catch(e){throw new FS.ErrnoError(ERRNO_CODES[e.code])}}}if(position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return position})}};var WORKERFS={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount:(function(mount){assert(ENVIRONMENT_IS_WORKER);if(!WORKERFS.reader)WORKERFS.reader=new FileReaderSync;var root=WORKERFS.createNode(null,"/",WORKERFS.DIR_MODE,0);var createdParents={};function ensureParent(path){var parts=path.split("/");var parent=root;for(var i=0;i<parts.length-1;i++){var curr=parts.slice(0,i+1).join("/");if(!createdParents[curr]){createdParents[curr]=WORKERFS.createNode(parent,curr,WORKERFS.DIR_MODE,0)}parent=createdParents[curr]}return parent}function base(path){var parts=path.split("/");return parts[parts.length-1]}Array.prototype.forEach.call(mount.opts["files"]||[],(function(file){WORKERFS.createNode(ensureParent(file.name),base(file.name),WORKERFS.FILE_MODE,0,file,file.lastModifiedDate)}));(mount.opts["blobs"]||[]).forEach((function(obj){WORKERFS.createNode(ensureParent(obj["name"]),base(obj["name"]),WORKERFS.FILE_MODE,0,obj["data"])}));(mount.opts["packages"]||[]).forEach((function(pack){pack["metadata"].files.forEach((function(file){var name=file.filename.substr(1);WORKERFS.createNode(ensureParent(name),base(name),WORKERFS.FILE_MODE,0,pack["blob"].slice(file.start,file.end))}))}));return root}),createNode:(function(parent,name,mode,dev,contents,mtime){var node=FS.createNode(parent,name,mode);node.mode=mode;node.node_ops=WORKERFS.node_ops;node.stream_ops=WORKERFS.stream_ops;node.timestamp=(mtime||new Date).getTime();assert(WORKERFS.FILE_MODE!==WORKERFS.DIR_MODE);if(mode===WORKERFS.FILE_MODE){node.size=contents.size;node.contents=contents}else{node.size=4096;node.contents={}}if(parent){parent.contents[name]=node}return node}),node_ops:{getattr:(function(node){return{dev:1,ino:undefined,mode:node.mode,nlink:1,uid:0,gid:0,rdev:undefined,size:node.size,atime:new Date(node.timestamp),mtime:new Date(node.timestamp),ctime:new Date(node.timestamp),blksize:4096,blocks:Math.ceil(node.size/4096)}}),setattr:(function(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}}),lookup:(function(parent,name){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}),mknod:(function(parent,name,mode,dev){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}),rename:(function(oldNode,newDir,newName){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}),unlink:(function(parent,name){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}),rmdir:(function(parent,name){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}),readdir:(function(node){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}),symlink:(function(parent,newName,oldPath){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}),readlink:(function(node){throw new FS.ErrnoError(ERRNO_CODES.EPERM)})},stream_ops:{read:(function(stream,buffer,offset,length,position){if(position>=stream.node.size)return 0;var chunk=stream.node.contents.slice(position,position+length);var ab=WORKERFS.reader.readAsArrayBuffer(chunk);buffer.set(new Uint8Array(ab),offset);return chunk.size}),write:(function(stream,buffer,offset,length,position){throw new FS.ErrnoError(ERRNO_CODES.EIO)}),llseek:(function(stream,offset,whence){var position=offset;if(whence===1){position+=stream.position}else if(whence===2){if(FS.isFile(stream.node.mode)){position+=stream.node.size}}if(position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return position})}};var _stdin=allocate(1,"i32*",ALLOC_STATIC);var _stdout=allocate(1,"i32*",ALLOC_STATIC);var _stderr=allocate(1,"i32*",ALLOC_STATIC);var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,handleFSError:(function(e){if(!(e instanceof FS.ErrnoError))throw e+" : "+stackTrace();return ___setErrNo(e.errno)}),lookupPath:(function(path,opts){path=PATH.resolve(FS.cwd(),path);opts=opts||{};if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};for(var key in defaults){if(opts[key]===undefined){opts[key]=defaults[key]}}if(opts.recurse_count>8){throw new FS.ErrnoError(ERRNO_CODES.ELOOP)}var parts=PATH.normalizeArray(path.split("/").filter((function(p){return!!p})),false);var current=FS.root;var current_path="/";for(var i=0;i<parts.length;i++){var islast=i===parts.length-1;if(islast&&opts.parent){break}current=FS.lookupNode(current,parts[i]);current_path=PATH.join2(current_path,parts[i]);if(FS.isMountpoint(current)){if(!islast||islast&&opts.follow_mount){current=current.mounted.root}}if(!islast||opts.follow){var count=0;while(FS.isLink(current.mode)){var link=FS.readlink(current_path);current_path=PATH.resolve(PATH.dirname(current_path),link);var lookup=FS.lookupPath(current_path,{recurse_count:opts.recurse_count});current=lookup.node;if(count++>40){throw new FS.ErrnoError(ERRNO_CODES.ELOOP)}}}}return{path:current_path,node:current}}),getPath:(function(node){var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}}),hashName:(function(parentid,name){var hash=0;for(var i=0;i<name.length;i++){hash=(hash<<5)-hash+name.charCodeAt(i)|0}return(parentid+hash>>>0)%FS.nameTable.length}),hashAddNode:(function(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node}),hashRemoveNode:(function(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}}),lookupNode:(function(parent,name){var err=FS.mayLookup(parent);if(err){throw new FS.ErrnoError(err,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)}),createNode:(function(parent,name,mode,rdev){if(!FS.FSNode){FS.FSNode=(function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev});FS.FSNode.prototype={};var readMode=292|73;var writeMode=146;Object.defineProperties(FS.FSNode.prototype,{read:{get:(function(){return(this.mode&readMode)===readMode}),set:(function(val){val?this.mode|=readMode:this.mode&=~readMode})},write:{get:(function(){return(this.mode&writeMode)===writeMode}),set:(function(val){val?this.mode|=writeMode:this.mode&=~writeMode})},isFolder:{get:(function(){return FS.isDir(this.mode)})},isDevice:{get:(function(){return FS.isChrdev(this.mode)})}})}var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node}),destroyNode:(function(node){FS.hashRemoveNode(node)}),isRoot:(function(node){return node===node.parent}),isMountpoint:(function(node){return!!node.mounted}),isFile:(function(mode){return(mode&61440)===32768}),isDir:(function(mode){return(mode&61440)===16384}),isLink:(function(mode){return(mode&61440)===40960}),isChrdev:(function(mode){return(mode&61440)===8192}),isBlkdev:(function(mode){return(mode&61440)===24576}),isFIFO:(function(mode){return(mode&61440)===4096}),isSocket:(function(mode){return(mode&49152)===49152}),flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:(function(str){var flags=FS.flagModes[str];if(typeof flags==="undefined"){throw new Error("Unknown file open mode: "+str)}return flags}),flagsToPermissionString:(function(flag){var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms}),nodePermissions:(function(node,perms){if(FS.ignorePermissions){return 0}if(perms.indexOf("r")!==-1&&!(node.mode&292)){return ERRNO_CODES.EACCES}else if(perms.indexOf("w")!==-1&&!(node.mode&146)){return ERRNO_CODES.EACCES}else if(perms.indexOf("x")!==-1&&!(node.mode&73)){return ERRNO_CODES.EACCES}return 0}),mayLookup:(function(dir){var err=FS.nodePermissions(dir,"x");if(err)return err;if(!dir.node_ops.lookup)return ERRNO_CODES.EACCES;return 0}),mayCreate:(function(dir,name){try{var node=FS.lookupNode(dir,name);return ERRNO_CODES.EEXIST}catch(e){}return FS.nodePermissions(dir,"wx")}),mayDelete:(function(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var err=FS.nodePermissions(dir,"wx");if(err){return err}if(isdir){if(!FS.isDir(node.mode)){return ERRNO_CODES.ENOTDIR}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return ERRNO_CODES.EBUSY}}else{if(FS.isDir(node.mode)){return ERRNO_CODES.EISDIR}}return 0}),mayOpen:(function(node,flags){if(!node){return ERRNO_CODES.ENOENT}if(FS.isLink(node.mode)){return ERRNO_CODES.ELOOP}else if(FS.isDir(node.mode)){if((flags&2097155)!==0||flags&512){return ERRNO_CODES.EISDIR}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))}),MAX_OPEN_FDS:4096,nextfd:(function(fd_start,fd_end){fd_start=fd_start||0;fd_end=fd_end||FS.MAX_OPEN_FDS;for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(ERRNO_CODES.EMFILE)}),getStream:(function(fd){return FS.streams[fd]}),createStream:(function(stream,fd_start,fd_end){if(!FS.FSStream){FS.FSStream=(function(){});FS.FSStream.prototype={};Object.defineProperties(FS.FSStream.prototype,{object:{get:(function(){return this.node}),set:(function(val){this.node=val})},isRead:{get:(function(){return(this.flags&2097155)!==1})},isWrite:{get:(function(){return(this.flags&2097155)!==0})},isAppend:{get:(function(){return this.flags&1024})}})}var newStream=new FS.FSStream;for(var p in stream){newStream[p]=stream[p]}stream=newStream;var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream}),closeStream:(function(fd){FS.streams[fd]=null}),chrdev_stream_ops:{open:(function(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}}),llseek:(function(){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)})},major:(function(dev){return dev>>8}),minor:(function(dev){return dev&255}),makedev:(function(ma,mi){return ma<<8|mi}),registerDevice:(function(dev,ops){FS.devices[dev]={stream_ops:ops}}),getDevice:(function(dev){return FS.devices[dev]}),getMounts:(function(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts}),syncfs:(function(populate,callback){if(typeof populate==="function"){callback=populate;populate=false}var mounts=FS.getMounts(FS.root.mount);var completed=0;function done(err){if(err){if(!done.errored){done.errored=true;return callback(err)}return}if(++completed>=mounts.length){callback(null)}}mounts.forEach((function(mount){if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)}))}),mount:(function(type,opts,mountpoint){var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot}),unmount:(function(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach((function(hash){var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.indexOf(current.mount)!==-1){FS.destroyNode(current)}current=next}}));node.mounted=null;var idx=node.mount.mounts.indexOf(mount);assert(idx!==-1);node.mount.mounts.splice(idx,1)}),lookup:(function(parent,name){return parent.node_ops.lookup(parent,name)}),mknod:(function(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var err=FS.mayCreate(parent,name);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return parent.node_ops.mknod(parent,name,mode,dev)}),create:(function(path,mode){mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)}),mkdir:(function(path,mode){mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)}),mkdev:(function(path,mode,dev){if(typeof dev==="undefined"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)}),symlink:(function(oldpath,newpath){if(!PATH.resolve(oldpath)){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}var newname=PATH.basename(newpath);var err=FS.mayCreate(parent,newname);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return parent.node_ops.symlink(parent,newname,oldpath)}),rename:(function(old_path,new_path){var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;try{lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node}catch(e){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(!old_dir||!new_dir)throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(ERRNO_CODES.EXDEV)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH.relative(old_path,new_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}relative=PATH.relative(new_path,old_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var err=FS.mayDelete(old_dir,old_name,isdir);if(err){throw new FS.ErrnoError(err)}err=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(err){throw new FS.ErrnoError(err)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(new_dir!==old_dir){err=FS.nodePermissions(old_dir,"w");if(err){throw new FS.ErrnoError(err)}}try{if(FS.trackingDelegate["willMovePath"]){FS.trackingDelegate["willMovePath"](old_path,new_path)}}catch(e){console.log("FS.trackingDelegate['willMovePath']('"+old_path+"', '"+new_path+"') threw an exception: "+e.message)}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name)}catch(e){throw e}finally{FS.hashAddNode(old_node)}try{if(FS.trackingDelegate["onMovePath"])FS.trackingDelegate["onMovePath"](old_path,new_path)}catch(e){console.log("FS.trackingDelegate['onMovePath']('"+old_path+"', '"+new_path+"') threw an exception: "+e.message)}}),rmdir:(function(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var err=FS.mayDelete(parent,name,true);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}try{if(FS.trackingDelegate["willDeletePath"]){FS.trackingDelegate["willDeletePath"](path)}}catch(e){console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: "+e.message)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node);try{if(FS.trackingDelegate["onDeletePath"])FS.trackingDelegate["onDeletePath"](path)}catch(e){console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: "+e.message)}}),readdir:(function(path){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node.node_ops.readdir){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}return node.node_ops.readdir(node)}),unlink:(function(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var err=FS.mayDelete(parent,name,false);if(err){if(err===ERRNO_CODES.EISDIR)err=ERRNO_CODES.EPERM;throw new FS.ErrnoError(err)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}try{if(FS.trackingDelegate["willDeletePath"]){FS.trackingDelegate["willDeletePath"](path)}}catch(e){console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: "+e.message)}parent.node_ops.unlink(parent,name);FS.destroyNode(node);try{if(FS.trackingDelegate["onDeletePath"])FS.trackingDelegate["onDeletePath"](path)}catch(e){console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: "+e.message)}}),readlink:(function(path){var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}if(!link.node_ops.readlink){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return PATH.resolve(FS.getPath(link.parent),link.node_ops.readlink(link))}),stat:(function(path,dontFollow){var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;if(!node){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}if(!node.node_ops.getattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return node.node_ops.getattr(node)}),lstat:(function(path){return FS.stat(path,true)}),chmod:(function(path,mode,dontFollow){var node;if(typeof path==="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}node.node_ops.setattr(node,{mode:mode&4095|node.mode&~4095,timestamp:Date.now()})}),lchmod:(function(path,mode){FS.chmod(path,mode,true)}),fchmod:(function(fd,mode){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}FS.chmod(stream.node,mode)}),chown:(function(path,uid,gid,dontFollow){var node;if(typeof path==="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}node.node_ops.setattr(node,{timestamp:Date.now()})}),lchown:(function(path,uid,gid){FS.chown(path,uid,gid,true)}),fchown:(function(fd,uid,gid){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}FS.chown(stream.node,uid,gid)}),truncate:(function(path,len){if(len<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node;if(typeof path==="string"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EISDIR)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var err=FS.nodePermissions(node,"w");if(err){throw new FS.ErrnoError(err)}node.node_ops.setattr(node,{size:len,timestamp:Date.now()})}),ftruncate:(function(fd,len){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}FS.truncate(stream.node,len)}),utime:(function(path,atime,mtime){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;node.node_ops.setattr(node,{timestamp:Math.max(atime,mtime)})}),open:(function(path,flags,mode,fd_start,fd_end){if(path===""){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}flags=typeof flags==="string"?FS.modeStringToFlags(flags):flags;mode=typeof mode==="undefined"?438:mode;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;if(typeof path==="object"){node=path}else{path=PATH.normalize(path);try{var lookup=FS.lookupPath(path,{follow:!(flags&131072)});node=lookup.node}catch(e){}}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(ERRNO_CODES.EEXIST)}}else{node=FS.mknod(path,mode,0);created=true}}if(!node){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}if(!created){var err=FS.mayOpen(node,flags);if(err){throw new FS.ErrnoError(err)}}if(flags&512){FS.truncate(node,0)}flags&=~(128|512);var stream=FS.createStream({node:node,path:FS.getPath(node),flags:flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false},fd_start,fd_end);if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(Module["logReadFiles"]&&!(flags&1)){if(!FS.readFiles)FS.readFiles={};if(!(path in FS.readFiles)){FS.readFiles[path]=1;Module["printErr"]("read file: "+path)}}try{if(FS.trackingDelegate["onOpenFile"]){var trackingFlags=0;if((flags&2097155)!==1){trackingFlags|=FS.tracking.openFlags.READ}if((flags&2097155)!==0){trackingFlags|=FS.tracking.openFlags.WRITE}FS.trackingDelegate["onOpenFile"](path,trackingFlags)}}catch(e){console.log("FS.trackingDelegate['onOpenFile']('"+path+"', flags) threw an exception: "+e.message)}return stream}),close:(function(stream){if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}}),llseek:(function(stream,offset,whence){if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position}),read:(function(stream,buffer,offset,length,position){if(length<0||position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EISDIR)}if(!stream.stream_ops.read){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var seeking=true;if(typeof position==="undefined"){position=stream.position;seeking=false}else if(!stream.seekable){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead}),write:(function(stream,buffer,offset,length,position,canOwn){if(length<0||position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EISDIR)}if(!stream.stream_ops.write){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if(stream.flags&1024){FS.llseek(stream,0,2)}var seeking=true;if(typeof position==="undefined"){position=stream.position;seeking=false}else if(!stream.seekable){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;try{if(stream.path&&FS.trackingDelegate["onWriteToFile"])FS.trackingDelegate["onWriteToFile"](stream.path)}catch(e){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+e.message)}return bytesWritten}),allocate:(function(stream,offset,length){if(offset<0||length<=0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if(!FS.isFile(stream.node.mode)&&!FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENODEV)}if(!stream.stream_ops.allocate){throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP)}stream.stream_ops.allocate(stream,offset,length)}),mmap:(function(stream,buffer,offset,length,position,prot,flags){if((stream.flags&2097155)===1){throw new FS.ErrnoError(ERRNO_CODES.EACCES)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(ERRNO_CODES.ENODEV)}return stream.stream_ops.mmap(stream,buffer,offset,length,position,prot,flags)}),msync:(function(stream,buffer,offset,length,mmapFlags){if(!stream||!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)}),munmap:(function(stream){return 0}),ioctl:(function(stream,cmd,arg){if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(ERRNO_CODES.ENOTTY)}return stream.stream_ops.ioctl(stream,cmd,arg)}),readFile:(function(path,opts){opts=opts||{};opts.flags=opts.flags||"r";opts.encoding=opts.encoding||"binary";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var ret;var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding==="utf8"){ret=UTF8ArrayToString(buf,0)}else if(opts.encoding==="binary"){ret=buf}FS.close(stream);return ret}),writeFile:(function(path,data,opts){opts=opts||{};opts.flags=opts.flags||"w";opts.encoding=opts.encoding||"utf8";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var stream=FS.open(path,opts.flags,opts.mode);if(opts.encoding==="utf8"){var buf=new Uint8Array(lengthBytesUTF8(data)+1);var actualNumBytes=stringToUTF8Array(data,buf,0,buf.length);FS.write(stream,buf,0,actualNumBytes,0,opts.canOwn)}else if(opts.encoding==="binary"){FS.write(stream,data,0,data.length,0,opts.canOwn)}FS.close(stream)}),cwd:(function(){return FS.currentPath}),chdir:(function(path){var lookup=FS.lookupPath(path,{follow:true});if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}var err=FS.nodePermissions(lookup.node,"x");if(err){throw new FS.ErrnoError(err)}FS.currentPath=lookup.path}),createDefaultDirectories:(function(){FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")}),createDefaultDevices:(function(){FS.mkdir("/dev");FS.registerDevice(FS.makedev(1,3),{read:(function(){return 0}),write:(function(stream,buffer,offset,length,pos){return length})});FS.mkdev("/dev/null",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev("/dev/tty",FS.makedev(5,0));FS.mkdev("/dev/tty1",FS.makedev(6,0));var random_device;if(typeof crypto!=="undefined"){var randomBuffer=new Uint8Array(1);random_device=(function(){crypto.getRandomValues(randomBuffer);return randomBuffer[0]})}else if(ENVIRONMENT_IS_NODE){random_device=(function(){return require("crypto").randomBytes(1)[0]})}else{random_device=(function(){return Math.random()*256|0})}FS.createDevice("/dev","random",random_device);FS.createDevice("/dev","urandom",random_device);FS.mkdir("/dev/shm");FS.mkdir("/dev/shm/tmp")}),createSpecialDirectories:(function(){FS.mkdir("/proc");FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd");FS.mount({mount:(function(){var node=FS.createNode("/proc/self","fd",16384|511,73);node.node_ops={lookup:(function(parent,name){var fd=+name;var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(ERRNO_CODES.EBADF);var ret={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:(function(){return stream.path})}};ret.parent=ret;return ret})};return node})},{},"/proc/self/fd")}),createStandardStreams:(function(){if(Module["stdin"]){FS.createDevice("/dev","stdin",Module["stdin"])}else{FS.symlink("/dev/tty","/dev/stdin")}if(Module["stdout"]){FS.createDevice("/dev","stdout",null,Module["stdout"])}else{FS.symlink("/dev/tty","/dev/stdout")}if(Module["stderr"]){FS.createDevice("/dev","stderr",null,Module["stderr"])}else{FS.symlink("/dev/tty1","/dev/stderr")}var stdin=FS.open("/dev/stdin","r");assert(stdin.fd===0,"invalid handle for stdin ("+stdin.fd+")");var stdout=FS.open("/dev/stdout","w");assert(stdout.fd===1,"invalid handle for stdout ("+stdout.fd+")");var stderr=FS.open("/dev/stderr","w");assert(stderr.fd===2,"invalid handle for stderr ("+stderr.fd+")")}),ensureErrnoError:(function(){if(FS.ErrnoError)return;FS.ErrnoError=function ErrnoError(errno,node){this.node=node;this.setErrno=(function(errno){this.errno=errno;for(var key in ERRNO_CODES){if(ERRNO_CODES[key]===errno){this.code=key;break}}});this.setErrno(errno);this.message=ERRNO_MESSAGES[errno]};FS.ErrnoError.prototype=new Error;FS.ErrnoError.prototype.constructor=FS.ErrnoError;[ERRNO_CODES.ENOENT].forEach((function(code){FS.genericErrors[code]=new FS.ErrnoError(code);FS.genericErrors[code].stack="<generic error, no stack>"}))}),staticInit:(function(){FS.ensureErrnoError();FS.nameTable=new Array(4096);FS.mount(MEMFS,{},"/");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories();FS.filesystems={"MEMFS":MEMFS,"IDBFS":IDBFS,"NODEFS":NODEFS,"WORKERFS":WORKERFS}}),init:(function(input,output,error){assert(!FS.init.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)");FS.init.initialized=true;FS.ensureErrnoError();Module["stdin"]=input||Module["stdin"];Module["stdout"]=output||Module["stdout"];Module["stderr"]=error||Module["stderr"];FS.createStandardStreams()}),quit:(function(){FS.init.initialized=false;var fflush=Module["_fflush"];if(fflush)fflush(0);for(var i=0;i<FS.streams.length;i++){var stream=FS.streams[i];if(!stream){continue}FS.close(stream)}}),getMode:(function(canRead,canWrite){var mode=0;if(canRead)mode|=292|73;if(canWrite)mode|=146;return mode}),joinPath:(function(parts,forceRelative){var path=PATH.join.apply(null,parts);if(forceRelative&&path[0]=="/")path=path.substr(1);return path}),absolutePath:(function(relative,base){return PATH.resolve(base,relative)}),standardizePath:(function(path){return PATH.normalize(path)}),findObject:(function(path,dontResolveLastLink){var ret=FS.analyzePath(path,dontResolveLastLink);if(ret.exists){return ret.object}else{___setErrNo(ret.error);return null}}),analyzePath:(function(path,dontResolveLastLink){try{var lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});path=lookup.path}catch(e){}var ret={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var lookup=FS.lookupPath(path,{parent:true});ret.parentExists=true;ret.parentPath=lookup.path;ret.parentObject=lookup.node;ret.name=PATH.basename(path);lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});ret.exists=true;ret.path=lookup.path;ret.object=lookup.node;ret.name=lookup.node.name;ret.isRoot=lookup.path==="/"}catch(e){ret.error=e.errno}return ret}),createFolder:(function(parent,name,canRead,canWrite){var path=PATH.join2(typeof parent==="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(canRead,canWrite);return FS.mkdir(path,mode)}),createPath:(function(parent,path,canRead,canWrite){parent=typeof parent==="string"?parent:FS.getPath(parent);var parts=path.split("/").reverse();while(parts.length){var part=parts.pop();if(!part)continue;var current=PATH.join2(parent,part);try{FS.mkdir(current)}catch(e){}parent=current}return current}),createFile:(function(parent,name,properties,canRead,canWrite){var path=PATH.join2(typeof parent==="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(canRead,canWrite);return FS.create(path,mode)}),createDataFile:(function(parent,name,data,canRead,canWrite,canOwn){var path=name?PATH.join2(typeof parent==="string"?parent:FS.getPath(parent),name):parent;var mode=FS.getMode(canRead,canWrite);var node=FS.create(path,mode);if(data){if(typeof data==="string"){var arr=new Array(data.length);for(var i=0,len=data.length;i<len;++i)arr[i]=data.charCodeAt(i);data=arr}FS.chmod(node,mode|146);var stream=FS.open(node,"w");FS.write(stream,data,0,data.length,0,canOwn);FS.close(stream);FS.chmod(node,mode)}return node}),createDevice:(function(parent,name,input,output){var path=PATH.join2(typeof parent==="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(!!input,!!output);if(!FS.createDevice.major)FS.createDevice.major=64;var dev=FS.makedev(FS.createDevice.major++,0);FS.registerDevice(dev,{open:(function(stream){stream.seekable=false}),close:(function(stream){if(output&&output.buffer&&output.buffer.length){output(10)}}),read:(function(stream,buffer,offset,length,pos){var bytesRead=0;for(var i=0;i<length;i++){var result;try{result=input()}catch(e){throw new FS.ErrnoError(ERRNO_CODES.EIO)}if(result===undefined&&bytesRead===0){throw new FS.ErrnoError(ERRNO_CODES.EAGAIN)}if(result===null||result===undefined)break;bytesRead++;buffer[offset+i]=result}if(bytesRead){stream.node.timestamp=Date.now()}return bytesRead}),write:(function(stream,buffer,offset,length,pos){for(var i=0;i<length;i++){try{output(buffer[offset+i])}catch(e){throw new FS.ErrnoError(ERRNO_CODES.EIO)}}if(length){stream.node.timestamp=Date.now()}return i})});return FS.mkdev(path,mode,dev)}),createLink:(function(parent,name,target,canRead,canWrite){var path=PATH.join2(typeof parent==="string"?parent:FS.getPath(parent),name);return FS.symlink(target,path)}),forceLoadFile:(function(obj){if(obj.isDevice||obj.isFolder||obj.link||obj.contents)return true;var success=true;if(typeof XMLHttpRequest!=="undefined"){throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.")}else if(Module["read"]){try{obj.contents=intArrayFromString(Module["read"](obj.url),true);obj.usedBytes=obj.contents.length}catch(e){success=false}}else{throw new Error("Cannot load without read() or XMLHttpRequest.")}if(!success)___setErrNo(ERRNO_CODES.EIO);return success}),createLazyFile:(function(parent,name,url,canRead,canWrite){function LazyUint8Array(){this.lengthKnown=false;this.chunks=[]}LazyUint8Array.prototype.get=function LazyUint8Array_get(idx){if(idx>this.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(function(from,to){if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);if(typeof Uint8Array!="undefined")xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}else{return intArrayFromString(xhr.responseText||"",true)}});var lazyArray=this;lazyArray.setDataGetter((function(chunkNum){var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]==="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]==="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]}));this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!=="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperty(lazyArray,"length",{get:(function(){if(!this.lengthKnown){this.cacheLength()}return this._length})});Object.defineProperty(lazyArray,"chunkSize",{get:(function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize})});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperty(node,"usedBytes",{get:(function(){return this.contents.length})});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach((function(key){var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){if(!FS.forceLoadFile(node)){throw new FS.ErrnoError(ERRNO_CODES.EIO)}return fn.apply(null,arguments)}}));stream_ops.read=function stream_ops_read(stream,buffer,offset,length,position){if(!FS.forceLoadFile(node)){throw new FS.ErrnoError(ERRNO_CODES.EIO)}var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);assert(size>=0);if(contents.slice){for(var i=0;i<size;i++){buffer[offset+i]=contents[position+i]}}else{for(var i=0;i<size;i++){buffer[offset+i]=contents.get(position+i)}}return size};node.stream_ops=stream_ops;return node}),createPreloadedFile:(function(parent,name,url,canRead,canWrite,onload,onerror,dontCreateFile,canOwn,preFinish){Browser.init();var fullname=name?PATH.resolve(PATH.join2(parent,name)):parent;var dep=getUniqueRunDependency("cp "+fullname);function processData(byteArray){function finish(byteArray){if(preFinish)preFinish();if(!dontCreateFile){FS.createDataFile(parent,name,byteArray,canRead,canWrite,canOwn)}if(onload)onload();removeRunDependency(dep)}var handled=false;Module["preloadPlugins"].forEach((function(plugin){if(handled)return;if(plugin["canHandle"](fullname)){plugin["handle"](byteArray,fullname,finish,(function(){if(onerror)onerror();removeRunDependency(dep)}));handled=true}}));if(!handled)finish(byteArray)}addRunDependency(dep);if(typeof url=="string"){Browser.asyncLoad(url,(function(byteArray){processData(byteArray)}),onerror)}else{processData(url)}}),indexedDB:(function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB}),DB_NAME:(function(){return"EM_FS_"+window.location.pathname}),DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(function(paths,onload,onerror){onload=onload||(function(){});onerror=onerror||(function(){});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=function openRequest_onupgradeneeded(){console.log("creating db");var db=openRequest.result;db.createObjectStore(FS.DB_STORE_NAME)};openRequest.onsuccess=function openRequest_onsuccess(){var db=openRequest.result;var transaction=db.transaction([FS.DB_STORE_NAME],"readwrite");var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach((function(path){var putRequest=files.put(FS.analyzePath(path).object.contents,path);putRequest.onsuccess=function putRequest_onsuccess(){ok++;if(ok+fail==total)finish()};putRequest.onerror=function putRequest_onerror(){fail++;if(ok+fail==total)finish()}}));transaction.onerror=onerror};openRequest.onerror=onerror}),loadFilesFromDB:(function(paths,onload,onerror){onload=onload||(function(){});onerror=onerror||(function(){});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=onerror;openRequest.onsuccess=function openRequest_onsuccess(){var db=openRequest.result;try{var transaction=db.transaction([FS.DB_STORE_NAME],"readonly")}catch(e){onerror(e);return}var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach((function(path){var getRequest=files.get(path);getRequest.onsuccess=function getRequest_onsuccess(){if(FS.analyzePath(path).exists){FS.unlink(path)}FS.createDataFile(PATH.dirname(path),PATH.basename(path),getRequest.result,true,true,true);ok++;if(ok+fail==total)finish()};getRequest.onerror=function getRequest_onerror(){fail++;if(ok+fail==total)finish()}}));transaction.onerror=onerror};openRequest.onerror=onerror})};var SYSCALLS={DEFAULT_POLLMASK:5,mappings:{},umask:511,calculateAt:(function(dirfd,path){if(path[0]!=="/"){var dir;if(dirfd===-100){dir=FS.cwd()}else{var dirstream=FS.getStream(dirfd);if(!dirstream)throw new FS.ErrnoError(ERRNO_CODES.EBADF);dir=dirstream.path}path=PATH.join2(dir,path)}return path}),doStat:(function(func,path,buf){try{var stat=func(path)}catch(e){if(e&&e.node&&PATH.normalize(path)!==PATH.normalize(FS.getPath(e.node))){return-ERRNO_CODES.ENOTDIR}throw e}HEAP32[buf>>2]=stat.dev;HEAP32[buf+4>>2]=0;HEAP32[buf+8>>2]=stat.ino;HEAP32[buf+12>>2]=stat.mode;HEAP32[buf+16>>2]=stat.nlink;HEAP32[buf+20>>2]=stat.uid;HEAP32[buf+24>>2]=stat.gid;HEAP32[buf+28>>2]=stat.rdev;HEAP32[buf+32>>2]=0;HEAP32[buf+36>>2]=stat.size;HEAP32[buf+40>>2]=4096;HEAP32[buf+44>>2]=stat.blocks;HEAP32[buf+48>>2]=stat.atime.getTime()/1e3|0;HEAP32[buf+52>>2]=0;HEAP32[buf+56>>2]=stat.mtime.getTime()/1e3|0;HEAP32[buf+60>>2]=0;HEAP32[buf+64>>2]=stat.ctime.getTime()/1e3|0;HEAP32[buf+68>>2]=0;HEAP32[buf+72>>2]=stat.ino;return 0}),doMsync:(function(addr,stream,len,flags){var buffer=new Uint8Array(HEAPU8.subarray(addr,addr+len));FS.msync(stream,buffer,0,len,flags)}),doMkdir:(function(path,mode){path=PATH.normalize(path);if(path[path.length-1]==="/")path=path.substr(0,path.length-1);FS.mkdir(path,mode,0);return 0}),doMknod:(function(path,mode,dev){switch(mode&61440){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-ERRNO_CODES.EINVAL}FS.mknod(path,mode,dev);return 0}),doReadlink:(function(path,buf,bufsize){if(bufsize<=0)return-ERRNO_CODES.EINVAL;var ret=FS.readlink(path);ret=ret.slice(0,Math.max(0,bufsize));writeStringToMemory(ret,buf,true);return ret.length}),doAccess:(function(path,amode){if(amode&~7){return-ERRNO_CODES.EINVAL}var node;var lookup=FS.lookupPath(path,{follow:true});node=lookup.node;var perms="";if(amode&4)perms+="r";if(amode&2)perms+="w";if(amode&1)perms+="x";if(perms&&FS.nodePermissions(node,perms)){return-ERRNO_CODES.EACCES}return 0}),doDup:(function(path,flags,suggestFD){var suggest=FS.getStream(suggestFD);if(suggest)FS.close(suggest);return FS.open(path,flags,0,suggestFD,suggestFD).fd}),doReadv:(function(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i<iovcnt;i++){var ptr=HEAP32[iov+i*8>>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr<len)break}return ret}),doWritev:(function(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i<iovcnt;i++){var ptr=HEAP32[iov+i*8>>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr}return ret}),varargs:0,get:(function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret}),getStr:(function(){var ret=Pointer_stringify(SYSCALLS.get());return ret}),getStreamFromFD:(function(){var stream=FS.getStream(SYSCALLS.get());if(!stream)throw new FS.ErrnoError(ERRNO_CODES.EBADF);return stream}),getSocketFromFD:(function(){var socket=SOCKFS.getSocket(SYSCALLS.get());if(!socket)throw new FS.ErrnoError(ERRNO_CODES.EBADF);return socket}),getSocketAddress:(function(allowNull){var addrp=SYSCALLS.get(),addrlen=SYSCALLS.get();if(allowNull&&addrp===0)return null;var info=__read_sockaddr(addrp,addrlen);if(info.errno)throw new FS.ErrnoError(info.errno);info.addr=DNS.lookup_addr(info.addr)||info.addr;return info}),get64:(function(){var low=SYSCALLS.get(),high=SYSCALLS.get();if(low>=0)assert(high===0);else assert(high===-1);return low}),getZero:(function(){assert(SYSCALLS.get()===0)})};function ___syscall5(which,varargs){SYSCALLS.varargs=varargs;try{var pathname=SYSCALLS.getStr(),flags=SYSCALLS.get(),mode=SYSCALLS.get();var stream=FS.open(pathname,flags,mode);return stream.fd}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest);return dest}Module["_memcpy"]=_memcpy;function ___syscall6(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD();FS.close(stream);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}var _cos=Math_cos;function _sbrk(bytes){var self=_sbrk;if(!self.called){DYNAMICTOP=alignMemoryPage(DYNAMICTOP);self.called=true;assert(Runtime.dynamicAlloc);self.alloc=Runtime.dynamicAlloc;Runtime.dynamicAlloc=(function(){abort("cannot dynamically allocate, sbrk now has control")})}var ret=DYNAMICTOP;if(bytes!=0){var success=self.alloc(bytes);if(!success)return-1>>>0}return ret}var _BItoD=true;function ___syscall54(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),op=SYSCALLS.get();switch(op){case 21505:{if(!stream.tty)return-ERRNO_CODES.ENOTTY;return 0};case 21506:{if(!stream.tty)return-ERRNO_CODES.ENOTTY;return 0};case 21519:{if(!stream.tty)return-ERRNO_CODES.ENOTTY;var argp=SYSCALLS.get();HEAP32[argp>>2]=0;return 0};case 21520:{if(!stream.tty)return-ERRNO_CODES.ENOTTY;return-ERRNO_CODES.EINVAL};case 21531:{var argp=SYSCALLS.get();return FS.ioctl(stream,op,argp)};default:abort("bad ioctl syscall "+op)}}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}var _ceilf=Math_ceil;function __embind_register_memory_view(rawType,dataTypeIndex,name){var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){handle=handle>>2;var heap=HEAPU32;var size=heap[handle];var data=heap[handle+1];return new TA(heap["buffer"],data,size)}name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":decodeMemoryView,"argPackAdvance":8,"readValueFromPointer":decodeMemoryView},{ignoreDuplicateRegistrations:true})}function _time(ptr){var ret=Date.now()/1e3|0;if(ptr){HEAP32[ptr>>2]=ret}return ret}function _pthread_self(){return 0}function ___syscall140(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),offset_high=SYSCALLS.get(),offset_low=SYSCALLS.get(),result=SYSCALLS.get(),whence=SYSCALLS.get();var offset=offset_low;assert(offset_high===0);FS.llseek(stream,offset,whence);HEAP32[result>>2]=stream.position;if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall146(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();return SYSCALLS.doWritev(stream,iov,iovcnt)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall221(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),cmd=SYSCALLS.get();switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-ERRNO_CODES.EINVAL}var newStream;newStream=FS.open(stream.path,stream.flags,0,arg);return newStream.fd};case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0};case 12:case 12:{var arg=SYSCALLS.get();var offset=0;HEAP16[arg+offset>>1]=2;return 0};case 13:case 14:case 13:case 14:return 0;case 16:case 8:return-ERRNO_CODES.EINVAL;case 9:___setErrNo(ERRNO_CODES.EINVAL);return-1;default:{return-ERRNO_CODES.EINVAL}}}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall145(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();return SYSCALLS.doReadv(stream,iov,iovcnt)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}var ___dso_handle=allocate(1,"i32*",ALLOC_STATIC);embind_init_charCodes();BindingError=Module["BindingError"]=extendError(Error,"BindingError");InternalError=Module["InternalError"]=extendError(Error,"InternalError");init_emval();UnboundTypeError=Module["UnboundTypeError"]=extendError(Error,"UnboundTypeError");FS.staticInit();__ATINIT__.unshift((function(){if(!Module["noFSInit"]&&!FS.init.initialized)FS.init()}));__ATMAIN__.push((function(){FS.ignorePermissions=false}));__ATEXIT__.push((function(){FS.quit()}));Module["FS_createFolder"]=FS.createFolder;Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createLink"]=FS.createLink;Module["FS_createDevice"]=FS.createDevice;Module["FS_unlink"]=FS.unlink;__ATINIT__.unshift((function(){TTY.init()}));__ATEXIT__.push((function(){TTY.shutdown()}));if(ENVIRONMENT_IS_NODE){var fs=require("fs");var NODEJS_PATH=require("path");NODEFS.staticInit()}STACK_BASE=STACKTOP=Runtime.alignMemory(STATICTOP);staticSealed=true;STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=DYNAMICTOP=Runtime.alignMemory(STACK_MAX);assert(DYNAMIC_BASE<TOTAL_MEMORY,"TOTAL_MEMORY not big enough for stack");var cttz_i8=allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],"i8",ALLOC_DYNAMIC);function invoke_iiii(index,a1,a2,a3){try{return Module["dynCall_iiii"](index,a1,a2,a3)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){try{Module["dynCall_viiiii"](index,a1,a2,a3,a4,a5)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_dii(index,a1,a2){try{return Module["dynCall_dii"](index,a1,a2)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_vid(index,a1,a2){try{Module["dynCall_vid"](index,a1,a2)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_di(index,a1){try{return Module["dynCall_di"](index,a1)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_i(index){try{return Module["dynCall_i"](index)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_vi(index,a1){try{Module["dynCall_vi"](index,a1)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_vii(index,a1,a2){try{Module["dynCall_vii"](index,a1,a2)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_ii(index,a1){try{return Module["dynCall_ii"](index,a1)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_viii(index,a1,a2,a3){try{Module["dynCall_viii"](index,a1,a2,a3)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_v(index){try{Module["dynCall_v"](index)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_viid(index,a1,a2,a3){try{Module["dynCall_viid"](index,a1,a2,a3)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){try{return Module["dynCall_iiiii"](index,a1,a2,a3,a4)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){try{Module["dynCall_viiiiii"](index,a1,a2,a3,a4,a5,a6)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_iii(index,a1,a2){try{return Module["dynCall_iii"](index,a1,a2)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}function invoke_viiii(index,a1,a2,a3,a4){try{Module["dynCall_viiii"](index,a1,a2,a3,a4)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;asm["setThrew"](1,0)}}Module.asmGlobalArg={"Math":Math,"Int8Array":Int8Array,"Int16Array":Int16Array,"Int32Array":Int32Array,"Uint8Array":Uint8Array,"Uint16Array":Uint16Array,"Uint32Array":Uint32Array,"Float32Array":Float32Array,"Float64Array":Float64Array,"NaN":NaN,"Infinity":Infinity};Module.asmLibraryArg={"abort":abort,"assert":assert,"invoke_iiii":invoke_iiii,"invoke_viiiii":invoke_viiiii,"invoke_dii":invoke_dii,"invoke_vid":invoke_vid,"invoke_di":invoke_di,"invoke_i":invoke_i,"invoke_vi":invoke_vi,"invoke_vii":invoke_vii,"invoke_ii":invoke_ii,"invoke_viii":invoke_viii,"invoke_v":invoke_v,"invoke_viid":invoke_viid,"invoke_iiiii":invoke_iiiii,"invoke_viiiiii":invoke_viiiiii,"invoke_iii":invoke_iii,"invoke_viiii":invoke_viiii,"_fabs":_fabs,"___syscall221":___syscall221,"_sin":_sin,"floatReadValueFromPointer":floatReadValueFromPointer,"simpleReadValueFromPointer":simpleReadValueFromPointer,"integerReadValueFromPointer":integerReadValueFromPointer,"__embind_register_memory_view":__embind_register_memory_view,"throwInternalError":throwInternalError,"get_first_emval":get_first_emval,"_abort":_abort,"count_emval_handles":count_emval_handles,"_pthread_cleanup_push":_pthread_cleanup_push,"__embind_register_integer":__embind_register_integer,"extendError":extendError,"___assert_fail":___assert_fail,"init_emval":init_emval,"__embind_register_void":__embind_register_void,"___cxa_find_matching_catch":___cxa_find_matching_catch,"_ceilf":_ceilf,"getShiftFromSize":getShiftFromSize,"__embind_register_function":__embind_register_function,"embind_init_charCodes":embind_init_charCodes,"_emscripten_asm_const_33":_emscripten_asm_const_33,"throwBindingError":throwBindingError,"___setErrNo":___setErrNo,"__emval_register":__emval_register,"_sbrk":_sbrk,"readLatin1String":readLatin1String,"___cxa_allocate_exception":___cxa_allocate_exception,"_emscripten_memcpy_big":_emscripten_memcpy_big,"__embind_register_bool":__embind_register_bool,"___resumeException":___resumeException,"__ZSt18uncaught_exceptionv":__ZSt18uncaught_exceptionv,"_sysconf":_sysconf,"_embind_repr":_embind_repr,"__embind_register_std_wstring":__embind_register_std_wstring,"createNamedFunction":createNamedFunction,"__embind_register_emval":__embind_register_emval,"_cos":_cos,"throwUnboundTypeError":throwUnboundTypeError,"_pthread_self":_pthread_self,"craftInvokerFunction":craftInvokerFunction,"__emval_decref":__emval_decref,"_sqrt":_sqrt,"__embind_register_float":__embind_register_float,"makeLegalFunctionName":makeLegalFunctionName,"___syscall54":___syscall54,"___unlock":___unlock,"heap32VectorToArray":heap32VectorToArray,"_pthread_cleanup_pop":_pthread_cleanup_pop,"whenDependentTypesAreResolved":whenDependentTypesAreResolved,"_exit":_exit,"__embind_register_std_string":__embind_register_std_string,"new_":new_,"___cxa_atexit":___cxa_atexit,"registerType":registerType,"___cxa_throw":___cxa_throw,"__exit":__exit,"___lock":___lock,"___syscall6":___syscall6,"___syscall5":___syscall5,"ensureOverloadTable":ensureOverloadTable,"__embind_register_constant":__embind_register_constant,"_time":_time,"requireFunction":requireFunction,"runDestructors":runDestructors,"getTypeName":getTypeName,"_atexit":_atexit,"___syscall140":___syscall140,"exposePublicSymbol":exposePublicSymbol,"_emscripten_asm_const_5":_emscripten_asm_const_5,"_emscripten_asm_const_4":_emscripten_asm_const_4,"replacePublicSymbol":replacePublicSymbol,"___syscall145":___syscall145,"___syscall146":___syscall146,"STACKTOP":STACKTOP,"STACK_MAX":STACK_MAX,"tempDoublePtr":tempDoublePtr,"ABORT":ABORT,"cttz_i8":cttz_i8,"___dso_handle":___dso_handle};// EMSCRIPTEN_START_ASM
  2. var asm=(function(global,env,buffer) {
  3. "use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.tempDoublePtr|0;var l=env.ABORT|0;var m=env.cttz_i8|0;var n=env.___dso_handle|0;var o=0;var p=0;var q=0;var r=0;var s=global.NaN,t=global.Infinity;var u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0.0;var D=0;var E=0;var F=0;var G=0;var H=0;var I=0;var J=0;var K=0;var L=0;var M=0;var N=global.Math.floor;var O=global.Math.abs;var P=global.Math.sqrt;var Q=global.Math.pow;var R=global.Math.cos;var S=global.Math.sin;var T=global.Math.tan;var U=global.Math.acos;var V=global.Math.asin;var W=global.Math.atan;var X=global.Math.atan2;var Y=global.Math.exp;var Z=global.Math.log;var _=global.Math.ceil;var $=global.Math.imul;var aa=global.Math.min;var ba=global.Math.clz32;var ca=env.abort;var da=env.assert;var ea=env.invoke_iiii;var fa=env.invoke_viiiii;var ga=env.invoke_dii;var ha=env.invoke_vid;var ia=env.invoke_di;var ja=env.invoke_i;var ka=env.invoke_vi;var la=env.invoke_vii;var ma=env.invoke_ii;var na=env.invoke_viii;var oa=env.invoke_v;var pa=env.invoke_viid;var qa=env.invoke_iiiii;var ra=env.invoke_viiiiii;var sa=env.invoke_iii;var ta=env.invoke_viiii;var ua=env._fabs;var va=env.___syscall221;var wa=env._sin;var xa=env.floatReadValueFromPointer;var ya=env.simpleReadValueFromPointer;var za=env.integerReadValueFromPointer;var Aa=env.__embind_register_memory_view;var Ba=env.throwInternalError;var Ca=env.get_first_emval;var Da=env._abort;var Ea=env.count_emval_handles;var Fa=env._pthread_cleanup_push;var Ga=env.__embind_register_integer;var Ha=env.extendError;var Ia=env.___assert_fail;var Ja=env.init_emval;var Ka=env.__embind_register_void;var La=env.___cxa_find_matching_catch;var Ma=env._ceilf;var Na=env.getShiftFromSize;var Oa=env.__embind_register_function;var Pa=env.embind_init_charCodes;var Qa=env._emscripten_asm_const_33;var Ra=env.throwBindingError;var Sa=env.___setErrNo;var Ta=env.__emval_register;var Ua=env._sbrk;var Va=env.readLatin1String;var Wa=env.___cxa_allocate_exception;var Xa=env._emscripten_memcpy_big;var Ya=env.__embind_register_bool;var Za=env.___resumeException;var _a=env.__ZSt18uncaught_exceptionv;var $a=env._sysconf;var ab=env._embind_repr;var bb=env.__embind_register_std_wstring;var cb=env.createNamedFunction;var db=env.__embind_register_emval;var eb=env._cos;var fb=env.throwUnboundTypeError;var gb=env._pthread_self;var hb=env.craftInvokerFunction;var ib=env.__emval_decref;var jb=env._sqrt;var kb=env.__embind_register_float;var lb=env.makeLegalFunctionName;var mb=env.___syscall54;var nb=env.___unlock;var ob=env.heap32VectorToArray;var pb=env._pthread_cleanup_pop;var qb=env.whenDependentTypesAreResolved;var rb=env._exit;var sb=env.__embind_register_std_string;var tb=env.new_;var ub=env.___cxa_atexit;var vb=env.registerType;var wb=env.___cxa_throw;var xb=env.__exit;var yb=env.___lock;var zb=env.___syscall6;var Ab=env.___syscall5;var Bb=env.ensureOverloadTable;var Cb=env.__embind_register_constant;var Db=env._time;var Eb=env.requireFunction;var Fb=env.runDestructors;var Gb=env.getTypeName;var Hb=env._atexit;var Ib=env.___syscall140;var Jb=env.exposePublicSymbol;var Kb=env._emscripten_asm_const_5;var Lb=env._emscripten_asm_const_4;var Mb=env.replacePublicSymbol;var Nb=env.___syscall145;var Ob=env.___syscall146;var Pb=0.0;
  4. // EMSCRIPTEN_START_FUNCS
  5. function dd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}z=D+-1|0;if((g|0)>1){l=0;m=o;n=o+(z<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{m=m+(D<<1)|0;n=n+(D<<1)|0}}}n=k+1179664|0;m=D+1|0;w=0-D|0;u=1-D|0;v=~D;t=f+4|0;a:do if((A|0)>1){x=(z|0)>1;l=(c[k+4>>2]|0)+m|0;y=1;g=e+((f<<1)+2)|0;e=o+(m<<1)|0;m=0;b:while(1){if(x){s=1;r=g;q=m;while(1){do if((d[r>>0]|0|0)>(j|0)){b[e>>1]=0;a[l>>0]=0;m=q}else{a[l>>0]=-1;m=b[e+(w<<1)>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}f=b[e+(u<<1)>>1]|0;o=f<<16>>16;m=b[e+(v<<1)>>1]|0;p=m<<16>>16;g=m<<16>>16>0;if(f<<16>>16<=0){if(g){b[e>>1]=m;m=p*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-3<<2)|0;if((c[g>>2]|0)<(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=b[e+-2>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(s|0)){m=q;break}c[m>>2]=s;m=q;break}else{m=q+1|0;if((q|0)>32767)break b;b[e>>1]=m;c[k+1179664+(q<<2)>>2]=m<<16>>16;q=q*7|0;c[k+1310736+(q<<2)>>2]=1;c[k+1310736+(q+1<<2)>>2]=s;c[k+1310736+(q+2<<2)>>2]=y;c[k+1310736+(q+3<<2)>>2]=s;c[k+1310736+(q+4<<2)>>2]=s;c[k+1310736+(q+5<<2)>>2]=y;c[k+1310736+(q+6<<2)>>2]=y;break}}if(g){m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+(p+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}g=b[e+-2>>1]|0;if(g<<16>>16<=0){b[e>>1]=f;m=o*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-4<<2)|0;if((c[g>>2]|0)>(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+((g<<16>>16)+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+y;m=q}while(0);s=s+1|0;g=r+2|0;e=e+2|0;l=l+1|0;if((s|0)>=(z|0))break;else{r=g;q=m}}}y=y+1|0;if((y|0)>=(A|0)){o=m;C=52;break a}else{l=l+2|0;g=g+t|0;e=e+4|0}}Me(3,3904,B);l=-1}else{o=0;C=52}while(0);if((C|0)==52){e=k+12|0;if((o|0)<1)m=1;else{g=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(g|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((g|0)<(o|0)){g=g+1|0;n=n+4|0}else break}}f=k+8|0;l=m+-1|0;c[f>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[f>>2]|0))}if((o|0)>0){e=0;do{n=(c[k+1179664+(e<<2)>>2]|0)+-1|0;g=e*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(g<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(g+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(g+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(g+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(g+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(g+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(g+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;e=e+1|0}while((e|0)<(o|0))}if((c[f>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[f>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function ed(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}z=D+-1|0;if((g|0)>1){l=0;m=o;n=o+(z<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{m=m+(D<<1)|0;n=n+(D<<1)|0}}}n=k+1179664|0;m=D+1|0;w=0-D|0;u=1-D|0;v=~D;t=(f<<1)+8|0;a:do if((A|0)>1){x=(z|0)>1;l=(c[k+4>>2]|0)+m|0;y=1;g=e+((f<<2)+4)|0;e=o+(m<<1)|0;m=0;b:while(1){if(x){s=1;r=g;q=m;while(1){do if((d[r+1>>0]|0|0)>(j|0)){b[e>>1]=0;a[l>>0]=0;m=q}else{a[l>>0]=-1;m=b[e+(w<<1)>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}f=b[e+(u<<1)>>1]|0;o=f<<16>>16;m=b[e+(v<<1)>>1]|0;p=m<<16>>16;g=m<<16>>16>0;if(f<<16>>16<=0){if(g){b[e>>1]=m;m=p*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-3<<2)|0;if((c[g>>2]|0)<(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=b[e+-2>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(s|0)){m=q;break}c[m>>2]=s;m=q;break}else{m=q+1|0;if((q|0)>32767)break b;b[e>>1]=m;c[k+1179664+(q<<2)>>2]=m<<16>>16;q=q*7|0;c[k+1310736+(q<<2)>>2]=1;c[k+1310736+(q+1<<2)>>2]=s;c[k+1310736+(q+2<<2)>>2]=y;c[k+1310736+(q+3<<2)>>2]=s;c[k+1310736+(q+4<<2)>>2]=s;c[k+1310736+(q+5<<2)>>2]=y;c[k+1310736+(q+6<<2)>>2]=y;break}}if(g){m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+(p+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}g=b[e+-2>>1]|0;if(g<<16>>16<=0){b[e>>1]=f;m=o*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-4<<2)|0;if((c[g>>2]|0)>(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+((g<<16>>16)+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+y;m=q}while(0);s=s+1|0;g=r+4|0;e=e+2|0;l=l+1|0;if((s|0)>=(z|0))break;else{r=g;q=m}}}y=y+1|0;if((y|0)>=(A|0)){o=m;C=52;break a}else{l=l+2|0;g=g+t|0;e=e+4|0}}Me(3,3904,B);l=-1}else{o=0;C=52}while(0);if((C|0)==52){e=k+12|0;if((o|0)<1)m=1;else{g=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(g|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((g|0)<(o|0)){g=g+1|0;n=n+4|0}else break}}f=k+8|0;l=m+-1|0;c[f>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[f>>2]|0))}if((o|0)>0){e=0;do{n=(c[k+1179664+(e<<2)>>2]|0)+-1|0;g=e*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(g<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(g+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(g+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(g+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(g+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(g+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(g+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;e=e+1|0}while((e|0)<(o|0))}if((c[f>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[f>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function fd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}z=D+-1|0;if((g|0)>1){l=0;m=o;n=o+(z<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{m=m+(D<<1)|0;n=n+(D<<1)|0}}}n=k+1179664|0;m=D+1|0;w=0-D|0;u=1-D|0;v=~D;t=(f<<1)+8|0;a:do if((A|0)>1){x=(z|0)>1;l=(c[k+4>>2]|0)+m|0;y=1;g=e+((f<<2)+4)|0;e=o+(m<<1)|0;m=0;b:while(1){if(x){s=1;r=g;q=m;while(1){do if((d[r>>0]|0|0)>(j|0)){b[e>>1]=0;a[l>>0]=0;m=q}else{a[l>>0]=-1;m=b[e+(w<<1)>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}f=b[e+(u<<1)>>1]|0;o=f<<16>>16;m=b[e+(v<<1)>>1]|0;p=m<<16>>16;g=m<<16>>16>0;if(f<<16>>16<=0){if(g){b[e>>1]=m;m=p*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-3<<2)|0;if((c[g>>2]|0)<(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=b[e+-2>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(s|0)){m=q;break}c[m>>2]=s;m=q;break}else{m=q+1|0;if((q|0)>32767)break b;b[e>>1]=m;c[k+1179664+(q<<2)>>2]=m<<16>>16;q=q*7|0;c[k+1310736+(q<<2)>>2]=1;c[k+1310736+(q+1<<2)>>2]=s;c[k+1310736+(q+2<<2)>>2]=y;c[k+1310736+(q+3<<2)>>2]=s;c[k+1310736+(q+4<<2)>>2]=s;c[k+1310736+(q+5<<2)>>2]=y;c[k+1310736+(q+6<<2)>>2]=y;break}}if(g){m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+(p+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}g=b[e+-2>>1]|0;if(g<<16>>16<=0){b[e>>1]=f;m=o*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-4<<2)|0;if((c[g>>2]|0)>(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+((g<<16>>16)+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+y;m=q}while(0);s=s+1|0;g=r+4|0;e=e+2|0;l=l+1|0;if((s|0)>=(z|0))break;else{r=g;q=m}}}y=y+1|0;if((y|0)>=(A|0)){o=m;C=52;break a}else{l=l+2|0;g=g+t|0;e=e+4|0}}Me(3,3904,B);l=-1}else{o=0;C=52}while(0);if((C|0)==52){e=k+12|0;if((o|0)<1)m=1;else{g=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(g|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((g|0)<(o|0)){g=g+1|0;n=n+4|0}else break}}f=k+8|0;l=m+-1|0;c[f>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[f>>2]|0))}if((o|0)>0){e=0;do{n=(c[k+1179664+(e<<2)>>2]|0)+-1|0;g=e*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(g<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(g+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(g+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(g+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(g+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(g+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(g+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;e=e+1|0}while((e|0)<(o|0))}if((c[f>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[f>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function gd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l*3|0)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){do if(((d[s+1>>0]|0)+(d[s>>0]|0)+(d[s+2>>0]|0)|0)>(A|0)){b[e>>1]=0;a[l>>0]=0;j=r}else{a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}while(0);t=t+1|0;n=s+3|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+6|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function hd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<1)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){p=d[s>>0]|0;q=d[s+1>>0]|0;do if(((p&248)+10+(p<<5&224)+(q>>>3&28)+(q<<3&248)|0)>(A|0)){b[e>>1]=0;a[l>>0]=0;j=r}else{a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function id(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<2)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){do if(((d[s+1>>0]|0)+(d[s>>0]|0)+(d[s+2>>0]|0)|0)>(A|0)){b[e>>1]=0;a[l>>0]=0;j=r}else{a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}while(0);t=t+1|0;n=s+4|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+8|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function jd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<1)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){q=d[s>>0]|0;do if(((q&240)+24+(q<<4&240)+((d[s+1>>0]|0)&240)|0)>(A|0)){b[e>>1]=0;a[l>>0]=0;j=r}else{a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function kd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<1)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){p=d[s>>0]|0;q=d[s+1>>0]|0;do if(((p&248)+12+(p<<5&224)+(q>>>3&24)+(q<<2&248)|0)>(A|0)){b[e>>1]=0;a[l>>0]=0;j=r}else{a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function ld(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<2)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){do if(((d[s+2>>0]|0)+(d[s+1>>0]|0)+(d[s+3>>0]|0)|0)>(A|0)){b[e>>1]=0;a[l>>0]=0;j=r}else{a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}while(0);t=t+1|0;n=s+4|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+8|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function md(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+l|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t>>0]|0|0)>(j|0)){b[o>>1]=0;a[l>>0]=0;m=s}else{a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}while(0);u=u+1|0;e=t+1|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+2|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function nd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+(l<<1)|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t+1>>0]|0|0)>(j|0)){b[o>>1]=0;a[l>>0]=0;m=s}else{a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}while(0);u=u+1|0;e=t+2|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+4|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function od(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+(l<<1)|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t>>0]|0|0)>(j|0)){b[o>>1]=0;a[l>>0]=0;m=s}else{a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}while(0);u=u+1|0;e=t+2|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+4|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function pd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;m=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;l=(c[k+4>>2]|0)+m|0;z=1;e=e+m|0;o=o+(m<<1)|0;j=j+m|0;m=0;b:while(1){if(y){u=1;t=e;s=m;while(1){do if((d[t>>0]|0)>(d[j>>0]|0)){b[o>>1]=0;a[l>>0]=0;m=s}else{a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}while(0);u=u+1|0;e=t+1|0;j=j+1|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}z=z+1|0;if((z|0)>=(B|0)){p=m;D=52;break a}else{l=l+2|0;e=e+2|0;o=o+4|0;j=j+2|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((p|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(p|0)){e=e+1|0;n=n+4|0}else break}}j=k+8|0;l=m+-1|0;c[j>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[j>>2]|0))}if((p|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(p|0))}if((c[j>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[j>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function qd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f*3|0)+12|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f*6|0)+6)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){do if(((d[q+1>>0]|0)+(d[q>>0]|0)+(d[q+2>>0]|0)|0)>(y|0)){a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}else{b[g>>1]=0;a[l>>0]=0;j=p}while(0);r=r+1|0;n=q+6|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function rd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<1)+8|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<2)+4)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){f=d[q>>0]|0;o=d[q+1>>0]|0;do if(((f&248)+10+(f<<5&224)+(o>>>3&28)+(o<<3&248)|0)>(y|0)){a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}else{b[g>>1]=0;a[l>>0]=0;j=p}while(0);r=r+1|0;n=q+4|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function sd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<2)+16|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<3)+8)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){do if(((d[q+1>>0]|0)+(d[q>>0]|0)+(d[q+2>>0]|0)|0)>(y|0)){a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}else{b[g>>1]=0;a[l>>0]=0;j=p}while(0);r=r+1|0;n=q+8|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function td(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<1)+8|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<2)+4)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){o=d[q>>0]|0;do if(((o&240)+24+(o<<4&240)+((d[q+1>>0]|0)&240)|0)>(y|0)){a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}else{b[g>>1]=0;a[l>>0]=0;j=p}while(0);r=r+1|0;n=q+4|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function ud(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<1)+8|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<2)+4)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){f=d[q>>0]|0;o=d[q+1>>0]|0;do if(((f&248)+12+(f<<5&224)+(o>>>3&24)+(o<<2&248)|0)>(y|0)){a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}else{b[g>>1]=0;a[l>>0]=0;j=p}while(0);r=r+1|0;n=q+4|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function vd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<2)+16|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<3)+8)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){do if(((d[q+2>>0]|0)+(d[q+1>>0]|0)+(d[q+3>>0]|0)|0)>(y|0)){a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}else{b[g>>1]=0;a[l>>0]=0;j=p}while(0);r=r+1|0;n=q+8|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function wd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}z=D+-1|0;if((g|0)>1){l=0;m=o;n=o+(z<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{m=m+(D<<1)|0;n=n+(D<<1)|0}}}n=k+1179664|0;m=D+1|0;w=0-D|0;u=1-D|0;v=~D;t=f+4|0;a:do if((A|0)>1){x=(z|0)>1;l=(c[k+4>>2]|0)+m|0;y=1;g=e+((f<<1)+2)|0;e=o+(m<<1)|0;m=0;b:while(1){if(x){s=1;r=g;q=m;while(1){do if((d[r>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[e+(w<<1)>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}f=b[e+(u<<1)>>1]|0;o=f<<16>>16;m=b[e+(v<<1)>>1]|0;p=m<<16>>16;g=m<<16>>16>0;if(f<<16>>16<=0){if(g){b[e>>1]=m;m=p*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-3<<2)|0;if((c[g>>2]|0)<(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=b[e+-2>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(s|0)){m=q;break}c[m>>2]=s;m=q;break}else{m=q+1|0;if((q|0)>32767)break b;b[e>>1]=m;c[k+1179664+(q<<2)>>2]=m<<16>>16;q=q*7|0;c[k+1310736+(q<<2)>>2]=1;c[k+1310736+(q+1<<2)>>2]=s;c[k+1310736+(q+2<<2)>>2]=y;c[k+1310736+(q+3<<2)>>2]=s;c[k+1310736+(q+4<<2)>>2]=s;c[k+1310736+(q+5<<2)>>2]=y;c[k+1310736+(q+6<<2)>>2]=y;break}}if(g){m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+(p+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}g=b[e+-2>>1]|0;if(g<<16>>16<=0){b[e>>1]=f;m=o*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-4<<2)|0;if((c[g>>2]|0)>(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+((g<<16>>16)+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+y;m=q}else{b[e>>1]=0;a[l>>0]=0;m=q}while(0);s=s+1|0;g=r+2|0;e=e+2|0;l=l+1|0;if((s|0)>=(z|0))break;else{r=g;q=m}}}y=y+1|0;if((y|0)>=(A|0)){o=m;C=52;break a}else{l=l+2|0;g=g+t|0;e=e+4|0}}Me(3,3904,B);l=-1}else{o=0;C=52}while(0);if((C|0)==52){e=k+12|0;if((o|0)<1)m=1;else{g=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(g|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((g|0)<(o|0)){g=g+1|0;n=n+4|0}else break}}f=k+8|0;l=m+-1|0;c[f>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[f>>2]|0))}if((o|0)>0){e=0;do{n=(c[k+1179664+(e<<2)>>2]|0)+-1|0;g=e*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(g<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(g+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(g+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(g+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(g+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(g+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(g+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;e=e+1|0}while((e|0)<(o|0))}if((c[f>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[f>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function xd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}z=D+-1|0;if((g|0)>1){l=0;m=o;n=o+(z<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{m=m+(D<<1)|0;n=n+(D<<1)|0}}}n=k+1179664|0;m=D+1|0;w=0-D|0;u=1-D|0;v=~D;t=(f<<1)+8|0;a:do if((A|0)>1){x=(z|0)>1;l=(c[k+4>>2]|0)+m|0;y=1;g=e+((f<<2)+4)|0;e=o+(m<<1)|0;m=0;b:while(1){if(x){s=1;r=g;q=m;while(1){do if((d[r+1>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[e+(w<<1)>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}f=b[e+(u<<1)>>1]|0;o=f<<16>>16;m=b[e+(v<<1)>>1]|0;p=m<<16>>16;g=m<<16>>16>0;if(f<<16>>16<=0){if(g){b[e>>1]=m;m=p*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-3<<2)|0;if((c[g>>2]|0)<(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=b[e+-2>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(s|0)){m=q;break}c[m>>2]=s;m=q;break}else{m=q+1|0;if((q|0)>32767)break b;b[e>>1]=m;c[k+1179664+(q<<2)>>2]=m<<16>>16;q=q*7|0;c[k+1310736+(q<<2)>>2]=1;c[k+1310736+(q+1<<2)>>2]=s;c[k+1310736+(q+2<<2)>>2]=y;c[k+1310736+(q+3<<2)>>2]=s;c[k+1310736+(q+4<<2)>>2]=s;c[k+1310736+(q+5<<2)>>2]=y;c[k+1310736+(q+6<<2)>>2]=y;break}}if(g){m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+(p+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}g=b[e+-2>>1]|0;if(g<<16>>16<=0){b[e>>1]=f;m=o*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-4<<2)|0;if((c[g>>2]|0)>(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+((g<<16>>16)+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+y;m=q}else{b[e>>1]=0;a[l>>0]=0;m=q}while(0);s=s+1|0;g=r+4|0;e=e+2|0;l=l+1|0;if((s|0)>=(z|0))break;else{r=g;q=m}}}y=y+1|0;if((y|0)>=(A|0)){o=m;C=52;break a}else{l=l+2|0;g=g+t|0;e=e+4|0}}Me(3,3904,B);l=-1}else{o=0;C=52}while(0);if((C|0)==52){e=k+12|0;if((o|0)<1)m=1;else{g=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(g|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((g|0)<(o|0)){g=g+1|0;n=n+4|0}else break}}f=k+8|0;l=m+-1|0;c[f>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[f>>2]|0))}if((o|0)>0){e=0;do{n=(c[k+1179664+(e<<2)>>2]|0)+-1|0;g=e*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(g<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(g+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(g+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(g+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(g+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(g+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(g+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;e=e+1|0}while((e|0)<(o|0))}if((c[f>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[f>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function yd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}z=D+-1|0;if((g|0)>1){l=0;m=o;n=o+(z<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{m=m+(D<<1)|0;n=n+(D<<1)|0}}}n=k+1179664|0;m=D+1|0;w=0-D|0;u=1-D|0;v=~D;t=(f<<1)+8|0;a:do if((A|0)>1){x=(z|0)>1;l=(c[k+4>>2]|0)+m|0;y=1;g=e+((f<<2)+4)|0;e=o+(m<<1)|0;m=0;b:while(1){if(x){s=1;r=g;q=m;while(1){do if((d[r>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[e+(w<<1)>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}f=b[e+(u<<1)>>1]|0;o=f<<16>>16;m=b[e+(v<<1)>>1]|0;p=m<<16>>16;g=m<<16>>16>0;if(f<<16>>16<=0){if(g){b[e>>1]=m;m=p*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-3<<2)|0;if((c[g>>2]|0)<(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=b[e+-2>>1]|0;if(m<<16>>16>0){b[e>>1]=m;m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(s|0)){m=q;break}c[m>>2]=s;m=q;break}else{m=q+1|0;if((q|0)>32767)break b;b[e>>1]=m;c[k+1179664+(q<<2)>>2]=m<<16>>16;q=q*7|0;c[k+1310736+(q<<2)>>2]=1;c[k+1310736+(q+1<<2)>>2]=s;c[k+1310736+(q+2<<2)>>2]=y;c[k+1310736+(q+3<<2)>>2]=s;c[k+1310736+(q+4<<2)>>2]=s;c[k+1310736+(q+5<<2)>>2]=y;c[k+1310736+(q+6<<2)>>2]=y;break}}if(g){m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+(p+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=k+1310736+(m+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+y;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}g=b[e+-2>>1]|0;if(g<<16>>16<=0){b[e>>1]=f;m=o*7|0;g=k+1310736+(m+-7<<2)|0;c[g>>2]=(c[g>>2]|0)+1;g=k+1310736+(m+-6<<2)|0;c[g>>2]=(c[g>>2]|0)+s;g=k+1310736+(m+-5<<2)|0;c[g>>2]=(c[g>>2]|0)+y;g=k+1310736+(m+-4<<2)|0;if((c[g>>2]|0)>(s|0))c[g>>2]=s;c[k+1310736+(m+-1<<2)>>2]=y;m=q;break}m=c[k+1179664+(o+-1<<2)>>2]|0;o=c[k+1179664+((g<<16>>16)+-1<<2)>>2]|0;if((m|0)>(o|0)){b[e>>1]=o;if((q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(m|0))c[f>>2]=o;g=g+1|0;if((g|0)>=(q|0)){m=o;break}else f=f+4|0}}else m=o}else{b[e>>1]=m;if((m|0)<(o|0)&(q|0)>0){g=0;f=n;while(1){if((c[f>>2]|0)==(o|0))c[f>>2]=m;g=g+1|0;if((g|0)>=(q|0))break;else f=f+4|0}}}m=(m<<16>>16)*7|0;p=k+1310736+(m+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=k+1310736+(m+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+y;m=q}else{b[e>>1]=0;a[l>>0]=0;m=q}while(0);s=s+1|0;g=r+4|0;e=e+2|0;l=l+1|0;if((s|0)>=(z|0))break;else{r=g;q=m}}}y=y+1|0;if((y|0)>=(A|0)){o=m;C=52;break a}else{l=l+2|0;g=g+t|0;e=e+4|0}}Me(3,3904,B);l=-1}else{o=0;C=52}while(0);if((C|0)==52){e=k+12|0;if((o|0)<1)m=1;else{g=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(g|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((g|0)<(o|0)){g=g+1|0;n=n+4|0}else break}}f=k+8|0;l=m+-1|0;c[f>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[f>>2]|0))}if((o|0)>0){e=0;do{n=(c[k+1179664+(e<<2)>>2]|0)+-1|0;g=e*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(g<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(g+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(g+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(g+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(g+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(g+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(g+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;e=e+1|0}while((e|0)<(o|0))}if((c[f>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[f>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}
  6. function ec(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+15&-16;return b|0}function fc(){return i|0}function gc(a){a=a|0;i=a}function hc(a,b){a=a|0;b=b|0;i=a;j=b}function ic(a,b){a=a|0;b=b|0;if(!o){o=a;p=b}}function jc(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0]}function kc(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0];a[k+4>>0]=a[b+4>>0];a[k+5>>0]=a[b+5>>0];a[k+6>>0]=a[b+6>>0];a[k+7>>0]=a[b+7>>0]}function lc(a){a=a|0;D=a}function mc(){return D|0}function nc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e*3|0)+12|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e*6|0)+6)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){do if(((d[g+1>>0]|0)+(d[g>>0]|0)+(d[g+2>>0]|0)|0)>(w|0)){b[o>>1]=0;k=n}else{k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}while(0);p=p+1|0;g=g+6|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function oc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<1)+8|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<2)+4)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){a=d[g>>0]|0;e=d[g+1>>0]|0;do if(((a&248)+10+(a<<5&224)+(e>>>3&28)+(e<<3&248)|0)>(w|0)){b[o>>1]=0;k=n}else{k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}while(0);p=p+1|0;g=g+4|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function pc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<2)+16|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<3)+8)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){do if(((d[g+1>>0]|0)+(d[g>>0]|0)+(d[g+2>>0]|0)|0)>(w|0)){b[o>>1]=0;k=n}else{k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}while(0);p=p+1|0;g=g+8|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function qc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<1)+8|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<2)+4)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){e=d[g>>0]|0;do if(((e&240)+24+(e<<4&240)+((d[g+1>>0]|0)&240)|0)>(w|0)){b[o>>1]=0;k=n}else{k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}while(0);p=p+1|0;g=g+4|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function rc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<1)+8|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<2)+4)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){a=d[g>>0]|0;e=d[g+1>>0]|0;do if(((a&248)+12+(a<<5&224)+(e>>>3&24)+(e<<2&248)|0)>(w|0)){b[o>>1]=0;k=n}else{k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}while(0);p=p+1|0;g=g+4|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function sc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<2)+16|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<3)+8)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){do if(((d[g+2>>0]|0)+(d[g+1>>0]|0)+(d[g+3>>0]|0)|0)>(w|0)){b[o>>1]=0;k=n}else{k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}while(0);p=p+1|0;g=g+8|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function tc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}x=B+-1|0;if((f|0)>1){k=0;l=n;m=n+(x<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{l=l+(B<<1)|0;m=m+(B<<1)|0}}}m=j+1179664|0;u=0-B|0;s=1-B|0;t=~B;r=e+4|0;a:do if((y|0)>1){v=(x|0)>1;w=1;l=a+((e<<1)+2)|0;f=n+(B+1<<1)|0;k=0;b:while(1){if(v){q=1;p=f;o=k;while(1){do if((d[l>>0]|0|0)>(g|0)){b[p>>1]=0;k=o}else{k=b[p+(u<<1)>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}a=b[p+(s<<1)>>1]|0;e=a<<16>>16;k=b[p+(t<<1)>>1]|0;n=k<<16>>16;f=k<<16>>16>0;if(a<<16>>16<=0){if(f){b[p>>1]=k;k=n*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-3<<2)|0;if((c[f>>2]|0)<(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=b[p+-2>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(q|0)){k=o;break}c[k>>2]=q;k=o;break}else{k=o+1|0;if((o|0)>32767)break b;b[p>>1]=k;c[j+1179664+(o<<2)>>2]=k<<16>>16;o=o*7|0;c[j+1310736+(o<<2)>>2]=1;c[j+1310736+(o+1<<2)>>2]=q;c[j+1310736+(o+2<<2)>>2]=w;c[j+1310736+(o+3<<2)>>2]=q;c[j+1310736+(o+4<<2)>>2]=q;c[j+1310736+(o+5<<2)>>2]=w;c[j+1310736+(o+6<<2)>>2]=w;break}}if(f){k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+(n+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}f=b[p+-2>>1]|0;if(f<<16>>16<=0){b[p>>1]=a;k=e*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-4<<2)|0;if((c[f>>2]|0)>(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+((f<<16>>16)+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=o}while(0);q=q+1|0;l=l+2|0;f=p+2|0;if((q|0)>=(x|0))break;else{p=f;o=k}}}w=w+1|0;if((w|0)>=(y|0)){n=k;A=52;break a}else{l=l+r|0;f=f+4|0}}Me(3,3904,z);k=-1}else{n=0;A=52}while(0);if((A|0)==52){a=j+12|0;if((n|0)<1)l=1;else{f=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(f|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((f|0)<(n|0)){f=f+1|0;m=m+4|0}else break}}e=j+8|0;k=l+-1|0;c[e>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[e>>2]|0))}if((n|0)>0){a=0;do{m=(c[j+1179664+(a<<2)>>2]|0)+-1|0;f=a*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(f<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(f+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(f+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(f+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(f+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(f+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(f+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;a=a+1|0}while((a|0)<(n|0))}if((c[e>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[e>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function uc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}x=B+-1|0;if((f|0)>1){k=0;l=n;m=n+(x<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{l=l+(B<<1)|0;m=m+(B<<1)|0}}}m=j+1179664|0;u=0-B|0;s=1-B|0;t=~B;r=(e<<1)+8|0;a:do if((y|0)>1){v=(x|0)>1;w=1;l=a+((e<<2)+4)|0;f=n+(B+1<<1)|0;k=0;b:while(1){if(v){q=1;p=f;o=k;while(1){do if((d[l+1>>0]|0|0)>(g|0)){b[p>>1]=0;k=o}else{k=b[p+(u<<1)>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}a=b[p+(s<<1)>>1]|0;e=a<<16>>16;k=b[p+(t<<1)>>1]|0;n=k<<16>>16;f=k<<16>>16>0;if(a<<16>>16<=0){if(f){b[p>>1]=k;k=n*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-3<<2)|0;if((c[f>>2]|0)<(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=b[p+-2>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(q|0)){k=o;break}c[k>>2]=q;k=o;break}else{k=o+1|0;if((o|0)>32767)break b;b[p>>1]=k;c[j+1179664+(o<<2)>>2]=k<<16>>16;o=o*7|0;c[j+1310736+(o<<2)>>2]=1;c[j+1310736+(o+1<<2)>>2]=q;c[j+1310736+(o+2<<2)>>2]=w;c[j+1310736+(o+3<<2)>>2]=q;c[j+1310736+(o+4<<2)>>2]=q;c[j+1310736+(o+5<<2)>>2]=w;c[j+1310736+(o+6<<2)>>2]=w;break}}if(f){k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+(n+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}f=b[p+-2>>1]|0;if(f<<16>>16<=0){b[p>>1]=a;k=e*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-4<<2)|0;if((c[f>>2]|0)>(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+((f<<16>>16)+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=o}while(0);q=q+1|0;l=l+4|0;f=p+2|0;if((q|0)>=(x|0))break;else{p=f;o=k}}}w=w+1|0;if((w|0)>=(y|0)){n=k;A=52;break a}else{l=l+r|0;f=f+4|0}}Me(3,3904,z);k=-1}else{n=0;A=52}while(0);if((A|0)==52){a=j+12|0;if((n|0)<1)l=1;else{f=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(f|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((f|0)<(n|0)){f=f+1|0;m=m+4|0}else break}}e=j+8|0;k=l+-1|0;c[e>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[e>>2]|0))}if((n|0)>0){a=0;do{m=(c[j+1179664+(a<<2)>>2]|0)+-1|0;f=a*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(f<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(f+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(f+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(f+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(f+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(f+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(f+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;a=a+1|0}while((a|0)<(n|0))}if((c[e>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[e>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function vc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}x=B+-1|0;if((f|0)>1){k=0;l=n;m=n+(x<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{l=l+(B<<1)|0;m=m+(B<<1)|0}}}m=j+1179664|0;u=0-B|0;s=1-B|0;t=~B;r=(e<<1)+8|0;a:do if((y|0)>1){v=(x|0)>1;w=1;l=a+((e<<2)+4)|0;f=n+(B+1<<1)|0;k=0;b:while(1){if(v){q=1;p=f;o=k;while(1){do if((d[l>>0]|0|0)>(g|0)){b[p>>1]=0;k=o}else{k=b[p+(u<<1)>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}a=b[p+(s<<1)>>1]|0;e=a<<16>>16;k=b[p+(t<<1)>>1]|0;n=k<<16>>16;f=k<<16>>16>0;if(a<<16>>16<=0){if(f){b[p>>1]=k;k=n*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-3<<2)|0;if((c[f>>2]|0)<(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=b[p+-2>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(q|0)){k=o;break}c[k>>2]=q;k=o;break}else{k=o+1|0;if((o|0)>32767)break b;b[p>>1]=k;c[j+1179664+(o<<2)>>2]=k<<16>>16;o=o*7|0;c[j+1310736+(o<<2)>>2]=1;c[j+1310736+(o+1<<2)>>2]=q;c[j+1310736+(o+2<<2)>>2]=w;c[j+1310736+(o+3<<2)>>2]=q;c[j+1310736+(o+4<<2)>>2]=q;c[j+1310736+(o+5<<2)>>2]=w;c[j+1310736+(o+6<<2)>>2]=w;break}}if(f){k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+(n+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}f=b[p+-2>>1]|0;if(f<<16>>16<=0){b[p>>1]=a;k=e*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-4<<2)|0;if((c[f>>2]|0)>(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+((f<<16>>16)+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=o}while(0);q=q+1|0;l=l+4|0;f=p+2|0;if((q|0)>=(x|0))break;else{p=f;o=k}}}w=w+1|0;if((w|0)>=(y|0)){n=k;A=52;break a}else{l=l+r|0;f=f+4|0}}Me(3,3904,z);k=-1}else{n=0;A=52}while(0);if((A|0)==52){a=j+12|0;if((n|0)<1)l=1;else{f=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(f|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((f|0)<(n|0)){f=f+1|0;m=m+4|0}else break}}e=j+8|0;k=l+-1|0;c[e>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[e>>2]|0))}if((n|0)>0){a=0;do{m=(c[j+1179664+(a<<2)>>2]|0)+-1|0;f=a*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(f<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(f+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(f+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(f+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(f+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(f+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(f+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;a=a+1|0}while((a|0)<(n|0))}if((c[e>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[e>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function wc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k*3|0)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){do if(((d[g+1>>0]|0)+(d[g>>0]|0)+(d[g+2>>0]|0)|0)>(y|0)){b[q>>1]=0;k=p}else{k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}while(0);r=r+1|0;g=g+3|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+6|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function xc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<1)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){n=d[g>>0]|0;o=d[g+1>>0]|0;do if(((n&248)+10+(n<<5&224)+(o>>>3&28)+(o<<3&248)|0)>(y|0)){b[q>>1]=0;k=p}else{k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}while(0);r=r+1|0;g=g+2|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+4|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function yc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<2)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){do if(((d[g+1>>0]|0)+(d[g>>0]|0)+(d[g+2>>0]|0)|0)>(y|0)){b[q>>1]=0;k=p}else{k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}while(0);r=r+1|0;g=g+4|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+8|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function zc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<1)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){o=d[g>>0]|0;do if(((o&240)+24+(o<<4&240)+((d[g+1>>0]|0)&240)|0)>(y|0)){b[q>>1]=0;k=p}else{k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}while(0);r=r+1|0;g=g+2|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+4|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Ac(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<1)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){n=d[g>>0]|0;o=d[g+1>>0]|0;do if(((n&248)+12+(n<<5&224)+(o>>>3&24)+(o<<2&248)|0)>(y|0)){b[q>>1]=0;k=p}else{k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}while(0);r=r+1|0;g=g+2|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+4|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Bc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<2)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){do if(((d[g+2>>0]|0)+(d[g+1>>0]|0)+(d[g+3>>0]|0)|0)>(y|0)){b[q>>1]=0;k=p}else{k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}while(0);r=r+1|0;g=g+4|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+8|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Cc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=e+-1|0;if((f|0)>0){k=0;l=n;m=n+(y<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{l=l+(e<<1)|0;m=m+(e<<1)|0}}}m=j+1179664|0;k=e+1|0;v=0-e|0;t=1-e|0;u=~e;a:do if((z|0)>1){w=(y|0)>1;x=1;l=a+k|0;a=n+(k<<1)|0;k=0;b:while(1){if(w){s=1;r=a;q=k;while(1){do if((d[l>>0]|0|0)>(g|0)){b[r>>1]=0;k=q}else{k=b[r+(v<<1)>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}n=b[r+(t<<1)>>1]|0;o=n<<16>>16;k=b[r+(u<<1)>>1]|0;p=k<<16>>16;a=k<<16>>16>0;if(n<<16>>16<=0){if(a){b[r>>1]=k;k=p*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-3<<2)|0;if((c[a>>2]|0)<(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(s|0)){k=q;break}c[k>>2]=s;k=q;break}else{k=q+1|0;if((q|0)>32767)break b;b[r>>1]=k;c[j+1179664+(q<<2)>>2]=k<<16>>16;q=q*7|0;c[j+1310736+(q<<2)>>2]=1;c[j+1310736+(q+1<<2)>>2]=s;c[j+1310736+(q+2<<2)>>2]=x;c[j+1310736+(q+3<<2)>>2]=s;c[j+1310736+(q+4<<2)>>2]=s;c[j+1310736+(q+5<<2)>>2]=x;c[j+1310736+(q+6<<2)>>2]=x;break}}if(a){k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+(p+-1<<2)>>2]|0;if((k|0)>(o|0)){b[r>>1]=o;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}else{b[r>>1]=k;if((k|0)<(o|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16<=0){b[r>>1]=n;k=o*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-4<<2)|0;if((c[a>>2]|0)>(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}o=c[j+1179664+(o+-1<<2)>>2]|0;k=c[j+1179664+((k<<16>>16)+-1<<2)>>2]|0;if((o|0)>(k|0)){b[r>>1]=k;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}else{b[r>>1]=o;if((o|0)<(k|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+x;k=q}while(0);s=s+1|0;l=l+1|0;a=r+2|0;if((s|0)>=(y|0))break;else{r=a;q=k}}}x=x+1|0;if((x|0)>=(z|0)){p=k;B=52;break a}else{l=l+2|0;a=a+4|0}}Me(3,3904,A);k=-1}else{p=0;B=52}while(0);if((B|0)==52){n=j+12|0;if((p|0)<1)l=1;else{a=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(a|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((a|0)<(p|0)){a=a+1|0;m=m+4|0}else break}}o=j+8|0;k=l+-1|0;c[o>>2]=k;if(k){ek(n|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[o>>2]|0))}if((p|0)>0){n=0;do{m=(c[j+1179664+(n<<2)>>2]|0)+-1|0;a=n*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(a<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(a+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(a+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(a+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(a+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(a+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(a+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;n=n+1|0}while((n|0)<(p|0))}if((c[o>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[o>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Dc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=e+-1|0;if((f|0)>0){k=0;l=n;m=n+(y<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{l=l+(e<<1)|0;m=m+(e<<1)|0}}}m=j+1179664|0;k=e+1|0;v=0-e|0;t=1-e|0;u=~e;a:do if((z|0)>1){w=(y|0)>1;x=1;l=a+(k<<1)|0;a=n+(k<<1)|0;k=0;b:while(1){if(w){s=1;r=a;q=k;while(1){do if((d[l+1>>0]|0|0)>(g|0)){b[r>>1]=0;k=q}else{k=b[r+(v<<1)>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}n=b[r+(t<<1)>>1]|0;o=n<<16>>16;k=b[r+(u<<1)>>1]|0;p=k<<16>>16;a=k<<16>>16>0;if(n<<16>>16<=0){if(a){b[r>>1]=k;k=p*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-3<<2)|0;if((c[a>>2]|0)<(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(s|0)){k=q;break}c[k>>2]=s;k=q;break}else{k=q+1|0;if((q|0)>32767)break b;b[r>>1]=k;c[j+1179664+(q<<2)>>2]=k<<16>>16;q=q*7|0;c[j+1310736+(q<<2)>>2]=1;c[j+1310736+(q+1<<2)>>2]=s;c[j+1310736+(q+2<<2)>>2]=x;c[j+1310736+(q+3<<2)>>2]=s;c[j+1310736+(q+4<<2)>>2]=s;c[j+1310736+(q+5<<2)>>2]=x;c[j+1310736+(q+6<<2)>>2]=x;break}}if(a){k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+(p+-1<<2)>>2]|0;if((k|0)>(o|0)){b[r>>1]=o;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}else{b[r>>1]=k;if((k|0)<(o|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}a=b[r+-2>>1]|0;if(a<<16>>16<=0){b[r>>1]=n;k=o*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-4<<2)|0;if((c[a>>2]|0)>(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+((a<<16>>16)+-1<<2)>>2]|0;if((k|0)>(o|0)){b[r>>1]=o;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}else{b[r>>1]=k;if((k|0)<(o|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+x;k=q}while(0);s=s+1|0;l=l+2|0;a=r+2|0;if((s|0)>=(y|0))break;else{r=a;q=k}}}x=x+1|0;if((x|0)>=(z|0)){p=k;B=52;break a}else{l=l+4|0;a=a+4|0}}Me(3,3904,A);k=-1}else{p=0;B=52}while(0);if((B|0)==52){n=j+12|0;if((p|0)<1)l=1;else{a=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(a|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((a|0)<(p|0)){a=a+1|0;m=m+4|0}else break}}o=j+8|0;k=l+-1|0;c[o>>2]=k;if(k){ek(n|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[o>>2]|0))}if((p|0)>0){n=0;do{m=(c[j+1179664+(n<<2)>>2]|0)+-1|0;a=n*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(a<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(a+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(a+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(a+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(a+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(a+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(a+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;n=n+1|0}while((n|0)<(p|0))}if((c[o>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[o>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Ec(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=e+-1|0;if((f|0)>0){k=0;l=n;m=n+(y<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{l=l+(e<<1)|0;m=m+(e<<1)|0}}}m=j+1179664|0;k=e+1|0;v=0-e|0;t=1-e|0;u=~e;a:do if((z|0)>1){w=(y|0)>1;x=1;l=a+(k<<1)|0;a=n+(k<<1)|0;k=0;b:while(1){if(w){s=1;r=a;q=k;while(1){do if((d[l>>0]|0|0)>(g|0)){b[r>>1]=0;k=q}else{k=b[r+(v<<1)>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}n=b[r+(t<<1)>>1]|0;o=n<<16>>16;k=b[r+(u<<1)>>1]|0;p=k<<16>>16;a=k<<16>>16>0;if(n<<16>>16<=0){if(a){b[r>>1]=k;k=p*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-3<<2)|0;if((c[a>>2]|0)<(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(s|0)){k=q;break}c[k>>2]=s;k=q;break}else{k=q+1|0;if((q|0)>32767)break b;b[r>>1]=k;c[j+1179664+(q<<2)>>2]=k<<16>>16;q=q*7|0;c[j+1310736+(q<<2)>>2]=1;c[j+1310736+(q+1<<2)>>2]=s;c[j+1310736+(q+2<<2)>>2]=x;c[j+1310736+(q+3<<2)>>2]=s;c[j+1310736+(q+4<<2)>>2]=s;c[j+1310736+(q+5<<2)>>2]=x;c[j+1310736+(q+6<<2)>>2]=x;break}}if(a){k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+(p+-1<<2)>>2]|0;if((k|0)>(o|0)){b[r>>1]=o;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}else{b[r>>1]=k;if((k|0)<(o|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16<=0){b[r>>1]=n;k=o*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-4<<2)|0;if((c[a>>2]|0)>(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}o=c[j+1179664+(o+-1<<2)>>2]|0;k=c[j+1179664+((k<<16>>16)+-1<<2)>>2]|0;if((o|0)>(k|0)){b[r>>1]=k;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}else{b[r>>1]=o;if((o|0)<(k|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+x;k=q}while(0);s=s+1|0;l=l+2|0;a=r+2|0;if((s|0)>=(y|0))break;else{r=a;q=k}}}x=x+1|0;if((x|0)>=(z|0)){p=k;B=52;break a}else{l=l+4|0;a=a+4|0}}Me(3,3904,A);k=-1}else{p=0;B=52}while(0);if((B|0)==52){n=j+12|0;if((p|0)<1)l=1;else{a=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(a|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((a|0)<(p|0)){a=a+1|0;m=m+4|0}else break}}o=j+8|0;k=l+-1|0;c[o>>2]=k;if(k){ek(n|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[o>>2]|0))}if((p|0)>0){n=0;do{m=(c[j+1179664+(n<<2)>>2]|0)+-1|0;a=n*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(a<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(a+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(a+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(a+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(a+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(a+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(a+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;n=n+1|0}while((n|0)<(p|0))}if((c[o>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[o>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Fc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=e+-1|0;if((f|0)>0){k=0;l=n;m=n+(y<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{l=l+(e<<1)|0;m=m+(e<<1)|0}}}m=j+1179664|0;k=e+1|0;v=0-e|0;t=1-e|0;u=~e;a:do if((z|0)>1){w=(y|0)>1;x=1;l=a+k|0;a=n+(k<<1)|0;n=g+k|0;k=0;b:while(1){if(w){s=1;r=l;q=k;while(1){do if((d[r>>0]|0)>(d[n>>0]|0)){b[a>>1]=0;k=q}else{k=b[a+(v<<1)>>1]|0;if(k<<16>>16>0){b[a>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}g=b[a+(t<<1)>>1]|0;o=g<<16>>16;k=b[a+(u<<1)>>1]|0;p=k<<16>>16;l=k<<16>>16>0;if(g<<16>>16<=0){if(l){b[a>>1]=k;k=p*7|0;l=j+1310736+(k+-7<<2)|0;c[l>>2]=(c[l>>2]|0)+1;l=j+1310736+(k+-6<<2)|0;c[l>>2]=(c[l>>2]|0)+s;l=j+1310736+(k+-5<<2)|0;c[l>>2]=(c[l>>2]|0)+x;l=j+1310736+(k+-3<<2)|0;if((c[l>>2]|0)<(s|0))c[l>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[a+-2>>1]|0;if(k<<16>>16>0){b[a>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(s|0)){k=q;break}c[k>>2]=s;k=q;break}else{k=q+1|0;if((q|0)>32767)break b;b[a>>1]=k;c[j+1179664+(q<<2)>>2]=k<<16>>16;q=q*7|0;c[j+1310736+(q<<2)>>2]=1;c[j+1310736+(q+1<<2)>>2]=s;c[j+1310736+(q+2<<2)>>2]=x;c[j+1310736+(q+3<<2)>>2]=s;c[j+1310736+(q+4<<2)>>2]=s;c[j+1310736+(q+5<<2)>>2]=x;c[j+1310736+(q+6<<2)>>2]=x;break}}if(l){k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+(p+-1<<2)>>2]|0;if((k|0)>(o|0)){b[a>>1]=o;if((q|0)>0){l=0;g=m;while(1){if((c[g>>2]|0)==(k|0))c[g>>2]=o;l=l+1|0;if((l|0)>=(q|0)){k=o;break}else g=g+4|0}}else k=o}else{b[a>>1]=k;if((k|0)<(o|0)&(q|0)>0){l=0;g=m;while(1){if((c[g>>2]|0)==(o|0))c[g>>2]=k;l=l+1|0;if((l|0)>=(q|0))break;else g=g+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[a+-2>>1]|0;if(k<<16>>16<=0){b[a>>1]=g;k=o*7|0;l=j+1310736+(k+-7<<2)|0;c[l>>2]=(c[l>>2]|0)+1;l=j+1310736+(k+-6<<2)|0;c[l>>2]=(c[l>>2]|0)+s;l=j+1310736+(k+-5<<2)|0;c[l>>2]=(c[l>>2]|0)+x;l=j+1310736+(k+-4<<2)|0;if((c[l>>2]|0)>(s|0))c[l>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}o=c[j+1179664+(o+-1<<2)>>2]|0;k=c[j+1179664+((k<<16>>16)+-1<<2)>>2]|0;if((o|0)>(k|0)){b[a>>1]=k;if((q|0)>0){l=0;g=m;while(1){if((c[g>>2]|0)==(o|0))c[g>>2]=k;l=l+1|0;if((l|0)>=(q|0))break;else g=g+4|0}}}else{b[a>>1]=o;if((o|0)<(k|0)&(q|0)>0){l=0;g=m;while(1){if((c[g>>2]|0)==(k|0))c[g>>2]=o;l=l+1|0;if((l|0)>=(q|0)){k=o;break}else g=g+4|0}}else k=o}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+x;k=q}while(0);s=s+1|0;l=r+1|0;n=n+1|0;a=a+2|0;if((s|0)>=(y|0))break;else{r=l;q=k}}}x=x+1|0;if((x|0)>=(z|0)){o=k;B=52;break a}else{l=l+2|0;a=a+4|0;n=n+2|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){n=j+12|0;if((o|0)<1)l=1;else{a=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(a|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((a|0)<(o|0)){a=a+1|0;m=m+4|0}else break}}g=j+8|0;k=l+-1|0;c[g>>2]=k;if(k){ek(n|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[g>>2]|0))}if((o|0)>0){n=0;do{m=(c[j+1179664+(n<<2)>>2]|0)+-1|0;a=n*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(a<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(a+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(a+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(a+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(a+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(a+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(a+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;n=n+1|0}while((n|0)<(o|0))}if((c[g>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[g>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Gc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e*3|0)+12|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e*6|0)+6)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){do if(((d[g+1>>0]|0)+(d[g>>0]|0)+(d[g+2>>0]|0)|0)>(w|0)){k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}else{b[o>>1]=0;k=n}while(0);p=p+1|0;g=g+6|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function Hc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<1)+8|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<2)+4)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){a=d[g>>0]|0;e=d[g+1>>0]|0;do if(((a&248)+10+(a<<5&224)+(e>>>3&28)+(e<<3&248)|0)>(w|0)){k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}else{b[o>>1]=0;k=n}while(0);p=p+1|0;g=g+4|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function Ic(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<2)+16|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<3)+8)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){do if(((d[g+1>>0]|0)+(d[g>>0]|0)+(d[g+2>>0]|0)|0)>(w|0)){k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}else{b[o>>1]=0;k=n}while(0);p=p+1|0;g=g+8|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}
  7. function Jc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<1)+8|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<2)+4)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){e=d[g>>0]|0;do if(((e&240)+24+(e<<4&240)+((d[g+1>>0]|0)&240)|0)>(w|0)){k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}else{b[o>>1]=0;k=n}while(0);p=p+1|0;g=g+4|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function Kc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<1)+8|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<2)+4)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){a=d[g>>0]|0;e=d[g+1>>0]|0;do if(((a&248)+12+(a<<5&224)+(e>>>3&24)+(e<<2&248)|0)>(w|0)){k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}else{b[o>>1]=0;k=n}while(0);p=p+1|0;g=g+4|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function Lc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}w=g*3|0;x=B+-1|0;if((f|0)>1){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{g=g+(B<<1)|0;l=l+(B<<1)|0}}}l=j+1179664|0;t=0-B|0;r=1-B|0;s=~B;q=(e<<2)+16|0;a:do if((y|0)>1){u=(x|0)>1;v=1;g=a+((e<<3)+8)|0;m=n+(B+1<<1)|0;k=0;b:while(1){if(u){p=1;o=m;n=k;while(1){do if(((d[g+2>>0]|0)+(d[g+1>>0]|0)+(d[g+3>>0]|0)|0)>(w|0)){k=b[o+(t<<1)>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}f=b[o+(r<<1)>>1]|0;a=f<<16>>16;k=b[o+(s<<1)>>1]|0;e=k<<16>>16;m=k<<16>>16>0;if(f<<16>>16<=0){if(m){b[o>>1]=k;k=e*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=b[o+-2>>1]|0;if(k<<16>>16>0){b[o>>1]=k;k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(p|0)){k=n;break}c[k>>2]=p;k=n;break}else{k=n+1|0;if((n|0)>32767)break b;b[o>>1]=k;c[j+1179664+(n<<2)>>2]=k<<16>>16;n=n*7|0;c[j+1310736+(n<<2)>>2]=1;c[j+1310736+(n+1<<2)>>2]=p;c[j+1310736+(n+2<<2)>>2]=v;c[j+1310736+(n+3<<2)>>2]=p;c[j+1310736+(n+4<<2)>>2]=p;c[j+1310736+(n+5<<2)>>2]=v;c[j+1310736+(n+6<<2)>>2]=v;break}}if(m){k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+(e+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;e=j+1310736+(k+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+v;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}m=b[o+-2>>1]|0;if(m<<16>>16<=0){b[o>>1]=f;k=a*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+p;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+v;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(p|0))c[m>>2]=p;c[j+1310736+(k+-1<<2)>>2]=v;k=n;break}k=c[j+1179664+(a+-1<<2)>>2]|0;a=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(a|0)){b[o>>1]=a;if((n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(k|0))c[f>>2]=a;m=m+1|0;if((m|0)>=(n|0)){k=a;break}else f=f+4|0}}else k=a}else{b[o>>1]=k;if((k|0)<(a|0)&(n|0)>0){m=0;f=l;while(1){if((c[f>>2]|0)==(a|0))c[f>>2]=k;m=m+1|0;if((m|0)>=(n|0))break;else f=f+4|0}}}k=(k<<16>>16)*7|0;e=j+1310736+(k+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=j+1310736+(k+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+p;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+v;k=n}else{b[o>>1]=0;k=n}while(0);p=p+1|0;g=g+8|0;m=o+2|0;if((p|0)>=(x|0))break;else{o=m;n=k}}}v=v+1|0;if((v|0)>=(y|0)){e=k;A=52;break a}else{g=g+q|0;m=m+4|0}}Me(3,3904,z);k=-1}else{e=0;A=52}while(0);if((A|0)==52){f=j+12|0;if((e|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(e|0)){m=m+1|0;l=l+4|0}else break}}a=j+8|0;k=g+-1|0;c[a>>2]=k;if(k){ek(f|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[a>>2]|0))}if((e|0)>0){f=0;do{l=(c[j+1179664+(f<<2)>>2]|0)+-1|0;m=f*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;f=f+1|0}while((f|0)<(e|0))}if((c[a>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[a>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function Mc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}x=B+-1|0;if((f|0)>1){k=0;l=n;m=n+(x<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{l=l+(B<<1)|0;m=m+(B<<1)|0}}}m=j+1179664|0;u=0-B|0;s=1-B|0;t=~B;r=e+4|0;a:do if((y|0)>1){v=(x|0)>1;w=1;l=a+((e<<1)+2)|0;f=n+(B+1<<1)|0;k=0;b:while(1){if(v){q=1;p=f;o=k;while(1){do if((d[l>>0]|0|0)>(g|0)){k=b[p+(u<<1)>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}a=b[p+(s<<1)>>1]|0;e=a<<16>>16;k=b[p+(t<<1)>>1]|0;n=k<<16>>16;f=k<<16>>16>0;if(a<<16>>16<=0){if(f){b[p>>1]=k;k=n*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-3<<2)|0;if((c[f>>2]|0)<(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=b[p+-2>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(q|0)){k=o;break}c[k>>2]=q;k=o;break}else{k=o+1|0;if((o|0)>32767)break b;b[p>>1]=k;c[j+1179664+(o<<2)>>2]=k<<16>>16;o=o*7|0;c[j+1310736+(o<<2)>>2]=1;c[j+1310736+(o+1<<2)>>2]=q;c[j+1310736+(o+2<<2)>>2]=w;c[j+1310736+(o+3<<2)>>2]=q;c[j+1310736+(o+4<<2)>>2]=q;c[j+1310736+(o+5<<2)>>2]=w;c[j+1310736+(o+6<<2)>>2]=w;break}}if(f){k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+(n+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}f=b[p+-2>>1]|0;if(f<<16>>16<=0){b[p>>1]=a;k=e*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-4<<2)|0;if((c[f>>2]|0)>(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+((f<<16>>16)+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=o}else{b[p>>1]=0;k=o}while(0);q=q+1|0;l=l+2|0;f=p+2|0;if((q|0)>=(x|0))break;else{p=f;o=k}}}w=w+1|0;if((w|0)>=(y|0)){n=k;A=52;break a}else{l=l+r|0;f=f+4|0}}Me(3,3904,z);k=-1}else{n=0;A=52}while(0);if((A|0)==52){a=j+12|0;if((n|0)<1)l=1;else{f=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(f|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((f|0)<(n|0)){f=f+1|0;m=m+4|0}else break}}e=j+8|0;k=l+-1|0;c[e>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[e>>2]|0))}if((n|0)>0){a=0;do{m=(c[j+1179664+(a<<2)>>2]|0)+-1|0;f=a*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(f<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(f+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(f+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(f+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(f+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(f+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(f+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;a=a+1|0}while((a|0)<(n|0))}if((c[e>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[e>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function Nc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}x=B+-1|0;if((f|0)>1){k=0;l=n;m=n+(x<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{l=l+(B<<1)|0;m=m+(B<<1)|0}}}m=j+1179664|0;u=0-B|0;s=1-B|0;t=~B;r=(e<<1)+8|0;a:do if((y|0)>1){v=(x|0)>1;w=1;l=a+((e<<2)+4)|0;f=n+(B+1<<1)|0;k=0;b:while(1){if(v){q=1;p=f;o=k;while(1){do if((d[l+1>>0]|0|0)>(g|0)){k=b[p+(u<<1)>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}a=b[p+(s<<1)>>1]|0;e=a<<16>>16;k=b[p+(t<<1)>>1]|0;n=k<<16>>16;f=k<<16>>16>0;if(a<<16>>16<=0){if(f){b[p>>1]=k;k=n*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-3<<2)|0;if((c[f>>2]|0)<(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=b[p+-2>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(q|0)){k=o;break}c[k>>2]=q;k=o;break}else{k=o+1|0;if((o|0)>32767)break b;b[p>>1]=k;c[j+1179664+(o<<2)>>2]=k<<16>>16;o=o*7|0;c[j+1310736+(o<<2)>>2]=1;c[j+1310736+(o+1<<2)>>2]=q;c[j+1310736+(o+2<<2)>>2]=w;c[j+1310736+(o+3<<2)>>2]=q;c[j+1310736+(o+4<<2)>>2]=q;c[j+1310736+(o+5<<2)>>2]=w;c[j+1310736+(o+6<<2)>>2]=w;break}}if(f){k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+(n+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}f=b[p+-2>>1]|0;if(f<<16>>16<=0){b[p>>1]=a;k=e*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-4<<2)|0;if((c[f>>2]|0)>(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+((f<<16>>16)+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=o}else{b[p>>1]=0;k=o}while(0);q=q+1|0;l=l+4|0;f=p+2|0;if((q|0)>=(x|0))break;else{p=f;o=k}}}w=w+1|0;if((w|0)>=(y|0)){n=k;A=52;break a}else{l=l+r|0;f=f+4|0}}Me(3,3904,z);k=-1}else{n=0;A=52}while(0);if((A|0)==52){a=j+12|0;if((n|0)<1)l=1;else{f=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(f|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((f|0)<(n|0)){f=f+1|0;m=m+4|0}else break}}e=j+8|0;k=l+-1|0;c[e>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[e>>2]|0))}if((n|0)>0){a=0;do{m=(c[j+1179664+(a<<2)>>2]|0)+-1|0;f=a*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(f<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(f+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(f+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(f+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(f+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(f+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(f+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;a=a+1|0}while((a|0)<(n|0))}if((c[e>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[e>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function Oc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;D=i;i=i+16|0;z=D;B=(e|0)/2|0;C=(f|0)/2|0;n=c[j>>2]|0;y=C+-1|0;if((e|0)>1){k=0;l=n;m=n+(($(y,B)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(B|0))break;else{l=l+2|0;m=m+2|0}}}x=B+-1|0;if((f|0)>1){k=0;l=n;m=n+(x<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(C|0))break;else{l=l+(B<<1)|0;m=m+(B<<1)|0}}}m=j+1179664|0;u=0-B|0;s=1-B|0;t=~B;r=(e<<1)+8|0;a:do if((y|0)>1){v=(x|0)>1;w=1;l=a+((e<<2)+4)|0;f=n+(B+1<<1)|0;k=0;b:while(1){if(v){q=1;p=f;o=k;while(1){do if((d[l>>0]|0|0)>(g|0)){k=b[p+(u<<1)>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}a=b[p+(s<<1)>>1]|0;e=a<<16>>16;k=b[p+(t<<1)>>1]|0;n=k<<16>>16;f=k<<16>>16>0;if(a<<16>>16<=0){if(f){b[p>>1]=k;k=n*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-3<<2)|0;if((c[f>>2]|0)<(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=b[p+-2>>1]|0;if(k<<16>>16>0){b[p>>1]=k;k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(q|0)){k=o;break}c[k>>2]=q;k=o;break}else{k=o+1|0;if((o|0)>32767)break b;b[p>>1]=k;c[j+1179664+(o<<2)>>2]=k<<16>>16;o=o*7|0;c[j+1310736+(o<<2)>>2]=1;c[j+1310736+(o+1<<2)>>2]=q;c[j+1310736+(o+2<<2)>>2]=w;c[j+1310736+(o+3<<2)>>2]=q;c[j+1310736+(o+4<<2)>>2]=q;c[j+1310736+(o+5<<2)>>2]=w;c[j+1310736+(o+6<<2)>>2]=w;break}}if(f){k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+(n+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;n=j+1310736+(k+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}f=b[p+-2>>1]|0;if(f<<16>>16<=0){b[p>>1]=a;k=e*7|0;f=j+1310736+(k+-7<<2)|0;c[f>>2]=(c[f>>2]|0)+1;f=j+1310736+(k+-6<<2)|0;c[f>>2]=(c[f>>2]|0)+q;f=j+1310736+(k+-5<<2)|0;c[f>>2]=(c[f>>2]|0)+w;f=j+1310736+(k+-4<<2)|0;if((c[f>>2]|0)>(q|0))c[f>>2]=q;c[j+1310736+(k+-1<<2)>>2]=w;k=o;break}k=c[j+1179664+(e+-1<<2)>>2]|0;e=c[j+1179664+((f<<16>>16)+-1<<2)>>2]|0;if((k|0)>(e|0)){b[p>>1]=e;if((o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=e;f=f+1|0;if((f|0)>=(o|0)){k=e;break}else a=a+4|0}}else k=e}else{b[p>>1]=k;if((k|0)<(e|0)&(o|0)>0){f=0;a=m;while(1){if((c[a>>2]|0)==(e|0))c[a>>2]=k;f=f+1|0;if((f|0)>=(o|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;n=j+1310736+(k+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=j+1310736+(k+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+q;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=o}else{b[p>>1]=0;k=o}while(0);q=q+1|0;l=l+4|0;f=p+2|0;if((q|0)>=(x|0))break;else{p=f;o=k}}}w=w+1|0;if((w|0)>=(y|0)){n=k;A=52;break a}else{l=l+r|0;f=f+4|0}}Me(3,3904,z);k=-1}else{n=0;A=52}while(0);if((A|0)==52){a=j+12|0;if((n|0)<1)l=1;else{f=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(f|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((f|0)<(n|0)){f=f+1|0;m=m+4|0}else break}}e=j+8|0;k=l+-1|0;c[e>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{A=k<<2;c[j+131084+(A<<2)>>2]=B;c[j+131084+((A|1)<<2)>>2]=0;c[j+131084+((A|2)<<2)>>2]=C;c[j+131084+((A|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[e>>2]|0))}if((n|0)>0){a=0;do{m=(c[j+1179664+(a<<2)>>2]|0)+-1|0;f=a*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(f<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(f+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(f+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(f+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(f+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(f+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(f+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;a=a+1|0}while((a|0)<(n|0))}if((c[e>>2]|0)>0){k=0;do{B=j+12+(k<<2)|0;C=k<<1;A=j+655376+(C<<3)|0;h[A>>3]=+h[A>>3]/+(c[B>>2]|0);C=j+655376+((C|1)<<3)|0;h[C>>3]=+h[C>>3]/+(c[B>>2]|0);k=k+1|0}while((k|0)<(c[e>>2]|0));k=0}else k=0}else k=0}i=D;return k|0}function Pc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k*3|0)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){do if(((d[g+1>>0]|0)+(d[g>>0]|0)+(d[g+2>>0]|0)|0)>(y|0)){k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}else{b[q>>1]=0;k=p}while(0);r=r+1|0;g=g+3|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+6|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Qc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<1)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){n=d[g>>0]|0;o=d[g+1>>0]|0;do if(((n&248)+10+(n<<5&224)+(o>>>3&28)+(o<<3&248)|0)>(y|0)){k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}else{b[q>>1]=0;k=p}while(0);r=r+1|0;g=g+2|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+4|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Rc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<2)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){do if(((d[g+1>>0]|0)+(d[g>>0]|0)+(d[g+2>>0]|0)|0)>(y|0)){k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}else{b[q>>1]=0;k=p}while(0);r=r+1|0;g=g+4|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+8|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Sc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<1)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){o=d[g>>0]|0;do if(((o&240)+24+(o<<4&240)+((d[g+1>>0]|0)&240)|0)>(y|0)){k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}else{b[q>>1]=0;k=p}while(0);r=r+1|0;g=g+2|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+4|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Tc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<1)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){n=d[g>>0]|0;o=d[g+1>>0]|0;do if(((n&248)+12+(n<<5&224)+(o>>>3&24)+(o<<2&248)|0)>(y|0)){k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}else{b[q>>1]=0;k=p}while(0);r=r+1|0;g=g+2|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+4|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Uc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=g*3|0;x=e+-1|0;if((f|0)>0){k=0;g=n;l=n+(x<<1)|0;while(1){b[l>>1]=0;b[g>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{g=g+(e<<1)|0;l=l+(e<<1)|0}}}l=j+1179664|0;k=e+1|0;u=0-e|0;s=1-e|0;t=~e;a:do if((z|0)>1){v=(x|0)>1;w=1;g=a+(k<<2)|0;m=n+(k<<1)|0;k=0;b:while(1){if(v){r=1;q=m;p=k;while(1){do if(((d[g+2>>0]|0)+(d[g+1>>0]|0)+(d[g+3>>0]|0)|0)>(y|0)){k=b[q+(u<<1)>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}a=b[q+(s<<1)>>1]|0;n=a<<16>>16;k=b[q+(t<<1)>>1]|0;o=k<<16>>16;m=k<<16>>16>0;if(a<<16>>16<=0){if(m){b[q>>1]=k;k=o*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-3<<2)|0;if((c[m>>2]|0)<(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=b[q+-2>>1]|0;if(k<<16>>16>0){b[q>>1]=k;k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(r|0)){k=p;break}c[k>>2]=r;k=p;break}else{k=p+1|0;if((p|0)>32767)break b;b[q>>1]=k;c[j+1179664+(p<<2)>>2]=k<<16>>16;p=p*7|0;c[j+1310736+(p<<2)>>2]=1;c[j+1310736+(p+1<<2)>>2]=r;c[j+1310736+(p+2<<2)>>2]=w;c[j+1310736+(p+3<<2)>>2]=r;c[j+1310736+(p+4<<2)>>2]=r;c[j+1310736+(p+5<<2)>>2]=w;c[j+1310736+(p+6<<2)>>2]=w;break}}if(m){k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+(o+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=j+1310736+(k+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+w;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}m=b[q+-2>>1]|0;if(m<<16>>16<=0){b[q>>1]=a;k=n*7|0;m=j+1310736+(k+-7<<2)|0;c[m>>2]=(c[m>>2]|0)+1;m=j+1310736+(k+-6<<2)|0;c[m>>2]=(c[m>>2]|0)+r;m=j+1310736+(k+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+w;m=j+1310736+(k+-4<<2)|0;if((c[m>>2]|0)>(r|0))c[m>>2]=r;c[j+1310736+(k+-1<<2)>>2]=w;k=p;break}k=c[j+1179664+(n+-1<<2)>>2]|0;n=c[j+1179664+((m<<16>>16)+-1<<2)>>2]|0;if((k|0)>(n|0)){b[q>>1]=n;if((p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(k|0))c[a>>2]=n;m=m+1|0;if((m|0)>=(p|0)){k=n;break}else a=a+4|0}}else k=n}else{b[q>>1]=k;if((k|0)<(n|0)&(p|0)>0){m=0;a=l;while(1){if((c[a>>2]|0)==(n|0))c[a>>2]=k;m=m+1|0;if((m|0)>=(p|0))break;else a=a+4|0}}}k=(k<<16>>16)*7|0;o=j+1310736+(k+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=j+1310736+(k+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+w;k=p}else{b[q>>1]=0;k=p}while(0);r=r+1|0;g=g+4|0;m=q+2|0;if((r|0)>=(x|0))break;else{q=m;p=k}}}w=w+1|0;if((w|0)>=(z|0)){o=k;B=52;break a}else{g=g+8|0;m=m+4|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){a=j+12|0;if((o|0)<1)g=1;else{m=1;g=1;while(1){k=c[l>>2]|0;if((k|0)==(m|0)){k=g;g=g+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[l>>2]=k;if((m|0)<(o|0)){m=m+1|0;l=l+4|0}else break}}n=j+8|0;k=g+-1|0;c[n>>2]=k;if(k){ek(a|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((g|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[n>>2]|0))}if((o|0)>0){a=0;do{l=(c[j+1179664+(a<<2)>>2]|0)+-1|0;m=a*7|0;k=j+12+(l<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(m<<2)>>2]|0);k=l<<1;g=j+655376+(k<<3)|0;h[g>>3]=+h[g>>3]+ +(c[j+1310736+(m+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(m+2<<2)>>2]|0);l=l<<2;k=j+131084+(l<<2)|0;g=c[j+1310736+(m+3<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;k=j+131084+((l|1)<<2)|0;g=c[j+1310736+(m+4<<2)>>2]|0;if((c[k>>2]|0)<(g|0))c[k>>2]=g;k=j+131084+((l|2)<<2)|0;g=c[j+1310736+(m+5<<2)>>2]|0;if((c[k>>2]|0)>(g|0))c[k>>2]=g;g=j+131084+((l|3)<<2)|0;k=c[j+1310736+(m+6<<2)>>2]|0;if((c[g>>2]|0)<(k|0))c[g>>2]=k;a=a+1|0}while((a|0)<(o|0))}if((c[n>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[n>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Vc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=e+-1|0;if((f|0)>0){k=0;l=n;m=n+(y<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{l=l+(e<<1)|0;m=m+(e<<1)|0}}}m=j+1179664|0;k=e+1|0;v=0-e|0;t=1-e|0;u=~e;a:do if((z|0)>1){w=(y|0)>1;x=1;l=a+k|0;a=n+(k<<1)|0;k=0;b:while(1){if(w){s=1;r=a;q=k;while(1){do if((d[l>>0]|0|0)>(g|0)){k=b[r+(v<<1)>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}n=b[r+(t<<1)>>1]|0;o=n<<16>>16;k=b[r+(u<<1)>>1]|0;p=k<<16>>16;a=k<<16>>16>0;if(n<<16>>16<=0){if(a){b[r>>1]=k;k=p*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-3<<2)|0;if((c[a>>2]|0)<(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(s|0)){k=q;break}c[k>>2]=s;k=q;break}else{k=q+1|0;if((q|0)>32767)break b;b[r>>1]=k;c[j+1179664+(q<<2)>>2]=k<<16>>16;q=q*7|0;c[j+1310736+(q<<2)>>2]=1;c[j+1310736+(q+1<<2)>>2]=s;c[j+1310736+(q+2<<2)>>2]=x;c[j+1310736+(q+3<<2)>>2]=s;c[j+1310736+(q+4<<2)>>2]=s;c[j+1310736+(q+5<<2)>>2]=x;c[j+1310736+(q+6<<2)>>2]=x;break}}if(a){k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+(p+-1<<2)>>2]|0;if((k|0)>(o|0)){b[r>>1]=o;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}else{b[r>>1]=k;if((k|0)<(o|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16<=0){b[r>>1]=n;k=o*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-4<<2)|0;if((c[a>>2]|0)>(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}o=c[j+1179664+(o+-1<<2)>>2]|0;k=c[j+1179664+((k<<16>>16)+-1<<2)>>2]|0;if((o|0)>(k|0)){b[r>>1]=k;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}else{b[r>>1]=o;if((o|0)<(k|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+x;k=q}else{b[r>>1]=0;k=q}while(0);s=s+1|0;l=l+1|0;a=r+2|0;if((s|0)>=(y|0))break;else{r=a;q=k}}}x=x+1|0;if((x|0)>=(z|0)){p=k;B=52;break a}else{l=l+2|0;a=a+4|0}}Me(3,3904,A);k=-1}else{p=0;B=52}while(0);if((B|0)==52){n=j+12|0;if((p|0)<1)l=1;else{a=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(a|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((a|0)<(p|0)){a=a+1|0;m=m+4|0}else break}}o=j+8|0;k=l+-1|0;c[o>>2]=k;if(k){ek(n|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[o>>2]|0))}if((p|0)>0){n=0;do{m=(c[j+1179664+(n<<2)>>2]|0)+-1|0;a=n*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(a<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(a+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(a+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(a+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(a+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(a+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(a+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;n=n+1|0}while((n|0)<(p|0))}if((c[o>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[o>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Wc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=e+-1|0;if((f|0)>0){k=0;l=n;m=n+(y<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{l=l+(e<<1)|0;m=m+(e<<1)|0}}}m=j+1179664|0;k=e+1|0;v=0-e|0;t=1-e|0;u=~e;a:do if((z|0)>1){w=(y|0)>1;x=1;l=a+(k<<1)|0;a=n+(k<<1)|0;k=0;b:while(1){if(w){s=1;r=a;q=k;while(1){do if((d[l+1>>0]|0|0)>(g|0)){k=b[r+(v<<1)>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}n=b[r+(t<<1)>>1]|0;o=n<<16>>16;k=b[r+(u<<1)>>1]|0;p=k<<16>>16;a=k<<16>>16>0;if(n<<16>>16<=0){if(a){b[r>>1]=k;k=p*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-3<<2)|0;if((c[a>>2]|0)<(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(s|0)){k=q;break}c[k>>2]=s;k=q;break}else{k=q+1|0;if((q|0)>32767)break b;b[r>>1]=k;c[j+1179664+(q<<2)>>2]=k<<16>>16;q=q*7|0;c[j+1310736+(q<<2)>>2]=1;c[j+1310736+(q+1<<2)>>2]=s;c[j+1310736+(q+2<<2)>>2]=x;c[j+1310736+(q+3<<2)>>2]=s;c[j+1310736+(q+4<<2)>>2]=s;c[j+1310736+(q+5<<2)>>2]=x;c[j+1310736+(q+6<<2)>>2]=x;break}}if(a){k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+(p+-1<<2)>>2]|0;if((k|0)>(o|0)){b[r>>1]=o;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}else{b[r>>1]=k;if((k|0)<(o|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}a=b[r+-2>>1]|0;if(a<<16>>16<=0){b[r>>1]=n;k=o*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-4<<2)|0;if((c[a>>2]|0)>(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+((a<<16>>16)+-1<<2)>>2]|0;if((k|0)>(o|0)){b[r>>1]=o;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}else{b[r>>1]=k;if((k|0)<(o|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+x;k=q}else{b[r>>1]=0;k=q}while(0);s=s+1|0;l=l+2|0;a=r+2|0;if((s|0)>=(y|0))break;else{r=a;q=k}}}x=x+1|0;if((x|0)>=(z|0)){p=k;B=52;break a}else{l=l+4|0;a=a+4|0}}Me(3,3904,A);k=-1}else{p=0;B=52}while(0);if((B|0)==52){n=j+12|0;if((p|0)<1)l=1;else{a=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(a|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((a|0)<(p|0)){a=a+1|0;m=m+4|0}else break}}o=j+8|0;k=l+-1|0;c[o>>2]=k;if(k){ek(n|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[o>>2]|0))}if((p|0)>0){n=0;do{m=(c[j+1179664+(n<<2)>>2]|0)+-1|0;a=n*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(a<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(a+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(a+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(a+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(a+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(a+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(a+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;n=n+1|0}while((n|0)<(p|0))}if((c[o>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[o>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Xc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=e+-1|0;if((f|0)>0){k=0;l=n;m=n+(y<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{l=l+(e<<1)|0;m=m+(e<<1)|0}}}m=j+1179664|0;k=e+1|0;v=0-e|0;t=1-e|0;u=~e;a:do if((z|0)>1){w=(y|0)>1;x=1;l=a+(k<<1)|0;a=n+(k<<1)|0;k=0;b:while(1){if(w){s=1;r=a;q=k;while(1){do if((d[l>>0]|0|0)>(g|0)){k=b[r+(v<<1)>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}n=b[r+(t<<1)>>1]|0;o=n<<16>>16;k=b[r+(u<<1)>>1]|0;p=k<<16>>16;a=k<<16>>16>0;if(n<<16>>16<=0){if(a){b[r>>1]=k;k=p*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-3<<2)|0;if((c[a>>2]|0)<(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16>0){b[r>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(s|0)){k=q;break}c[k>>2]=s;k=q;break}else{k=q+1|0;if((q|0)>32767)break b;b[r>>1]=k;c[j+1179664+(q<<2)>>2]=k<<16>>16;q=q*7|0;c[j+1310736+(q<<2)>>2]=1;c[j+1310736+(q+1<<2)>>2]=s;c[j+1310736+(q+2<<2)>>2]=x;c[j+1310736+(q+3<<2)>>2]=s;c[j+1310736+(q+4<<2)>>2]=s;c[j+1310736+(q+5<<2)>>2]=x;c[j+1310736+(q+6<<2)>>2]=x;break}}if(a){k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+(p+-1<<2)>>2]|0;if((k|0)>(o|0)){b[r>>1]=o;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}else{b[r>>1]=k;if((k|0)<(o|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[r+-2>>1]|0;if(k<<16>>16<=0){b[r>>1]=n;k=o*7|0;a=j+1310736+(k+-7<<2)|0;c[a>>2]=(c[a>>2]|0)+1;a=j+1310736+(k+-6<<2)|0;c[a>>2]=(c[a>>2]|0)+s;a=j+1310736+(k+-5<<2)|0;c[a>>2]=(c[a>>2]|0)+x;a=j+1310736+(k+-4<<2)|0;if((c[a>>2]|0)>(s|0))c[a>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}o=c[j+1179664+(o+-1<<2)>>2]|0;k=c[j+1179664+((k<<16>>16)+-1<<2)>>2]|0;if((o|0)>(k|0)){b[r>>1]=k;if((q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(o|0))c[n>>2]=k;a=a+1|0;if((a|0)>=(q|0))break;else n=n+4|0}}}else{b[r>>1]=o;if((o|0)<(k|0)&(q|0)>0){a=0;n=m;while(1){if((c[n>>2]|0)==(k|0))c[n>>2]=o;a=a+1|0;if((a|0)>=(q|0)){k=o;break}else n=n+4|0}}else k=o}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+x;k=q}else{b[r>>1]=0;k=q}while(0);s=s+1|0;l=l+2|0;a=r+2|0;if((s|0)>=(y|0))break;else{r=a;q=k}}}x=x+1|0;if((x|0)>=(z|0)){p=k;B=52;break a}else{l=l+4|0;a=a+4|0}}Me(3,3904,A);k=-1}else{p=0;B=52}while(0);if((B|0)==52){n=j+12|0;if((p|0)<1)l=1;else{a=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(a|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((a|0)<(p|0)){a=a+1|0;m=m+4|0}else break}}o=j+8|0;k=l+-1|0;c[o>>2]=k;if(k){ek(n|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[o>>2]|0))}if((p|0)>0){n=0;do{m=(c[j+1179664+(n<<2)>>2]|0)+-1|0;a=n*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(a<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(a+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(a+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(a+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(a+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(a+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(a+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;n=n+1|0}while((n|0)<(p|0))}if((c[o>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[o>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Yc(a,e,f,g,j){a=a|0;e=e|0;f=f|0;g=g|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+16|0;A=C;n=c[j>>2]|0;z=f+-1|0;if((e|0)>0){k=0;l=n;m=n+(($(z,e)|0)<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(e|0))break;else{l=l+2|0;m=m+2|0}}}y=e+-1|0;if((f|0)>0){k=0;l=n;m=n+(y<<1)|0;while(1){b[m>>1]=0;b[l>>1]=0;k=k+1|0;if((k|0)>=(f|0))break;else{l=l+(e<<1)|0;m=m+(e<<1)|0}}}m=j+1179664|0;k=e+1|0;v=0-e|0;t=1-e|0;u=~e;a:do if((z|0)>1){w=(y|0)>1;x=1;l=a+k|0;a=n+(k<<1)|0;n=g+k|0;k=0;b:while(1){if(w){s=1;r=l;q=k;while(1){do if((d[r>>0]|0)>(d[n>>0]|0)){k=b[a+(v<<1)>>1]|0;if(k<<16>>16>0){b[a>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}g=b[a+(t<<1)>>1]|0;o=g<<16>>16;k=b[a+(u<<1)>>1]|0;p=k<<16>>16;l=k<<16>>16>0;if(g<<16>>16<=0){if(l){b[a>>1]=k;k=p*7|0;l=j+1310736+(k+-7<<2)|0;c[l>>2]=(c[l>>2]|0)+1;l=j+1310736+(k+-6<<2)|0;c[l>>2]=(c[l>>2]|0)+s;l=j+1310736+(k+-5<<2)|0;c[l>>2]=(c[l>>2]|0)+x;l=j+1310736+(k+-3<<2)|0;if((c[l>>2]|0)<(s|0))c[l>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[a+-2>>1]|0;if(k<<16>>16>0){b[a>>1]=k;k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;k=j+1310736+(k+-3<<2)|0;if((c[k>>2]|0)>=(s|0)){k=q;break}c[k>>2]=s;k=q;break}else{k=q+1|0;if((q|0)>32767)break b;b[a>>1]=k;c[j+1179664+(q<<2)>>2]=k<<16>>16;q=q*7|0;c[j+1310736+(q<<2)>>2]=1;c[j+1310736+(q+1<<2)>>2]=s;c[j+1310736+(q+2<<2)>>2]=x;c[j+1310736+(q+3<<2)>>2]=s;c[j+1310736+(q+4<<2)>>2]=s;c[j+1310736+(q+5<<2)>>2]=x;c[j+1310736+(q+6<<2)>>2]=x;break}}if(l){k=c[j+1179664+(o+-1<<2)>>2]|0;o=c[j+1179664+(p+-1<<2)>>2]|0;if((k|0)>(o|0)){b[a>>1]=o;if((q|0)>0){l=0;g=m;while(1){if((c[g>>2]|0)==(k|0))c[g>>2]=o;l=l+1|0;if((l|0)>=(q|0)){k=o;break}else g=g+4|0}}else k=o}else{b[a>>1]=k;if((k|0)<(o|0)&(q|0)>0){l=0;g=m;while(1){if((c[g>>2]|0)==(o|0))c[g>>2]=k;l=l+1|0;if((l|0)>=(q|0))break;else g=g+4|0}}}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;p=j+1310736+(k+-5<<2)|0;c[p>>2]=(c[p>>2]|0)+x;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}k=b[a+-2>>1]|0;if(k<<16>>16<=0){b[a>>1]=g;k=o*7|0;l=j+1310736+(k+-7<<2)|0;c[l>>2]=(c[l>>2]|0)+1;l=j+1310736+(k+-6<<2)|0;c[l>>2]=(c[l>>2]|0)+s;l=j+1310736+(k+-5<<2)|0;c[l>>2]=(c[l>>2]|0)+x;l=j+1310736+(k+-4<<2)|0;if((c[l>>2]|0)>(s|0))c[l>>2]=s;c[j+1310736+(k+-1<<2)>>2]=x;k=q;break}o=c[j+1179664+(o+-1<<2)>>2]|0;k=c[j+1179664+((k<<16>>16)+-1<<2)>>2]|0;if((o|0)>(k|0)){b[a>>1]=k;if((q|0)>0){l=0;g=m;while(1){if((c[g>>2]|0)==(o|0))c[g>>2]=k;l=l+1|0;if((l|0)>=(q|0))break;else g=g+4|0}}}else{b[a>>1]=o;if((o|0)<(k|0)&(q|0)>0){l=0;g=m;while(1){if((c[g>>2]|0)==(k|0))c[g>>2]=o;l=l+1|0;if((l|0)>=(q|0)){k=o;break}else g=g+4|0}}else k=o}k=(k<<16>>16)*7|0;p=j+1310736+(k+-7<<2)|0;c[p>>2]=(c[p>>2]|0)+1;p=j+1310736+(k+-6<<2)|0;c[p>>2]=(c[p>>2]|0)+s;k=j+1310736+(k+-5<<2)|0;c[k>>2]=(c[k>>2]|0)+x;k=q}else{b[a>>1]=0;k=q}while(0);s=s+1|0;l=r+1|0;n=n+1|0;a=a+2|0;if((s|0)>=(y|0))break;else{r=l;q=k}}}x=x+1|0;if((x|0)>=(z|0)){o=k;B=52;break a}else{l=l+2|0;a=a+4|0;n=n+2|0}}Me(3,3904,A);k=-1}else{o=0;B=52}while(0);if((B|0)==52){n=j+12|0;if((o|0)<1)l=1;else{a=1;l=1;while(1){k=c[m>>2]|0;if((k|0)==(a|0)){k=l;l=l+1|0}else k=c[j+1179664+(k+-1<<2)>>2]|0;c[m>>2]=k;if((a|0)<(o|0)){a=a+1|0;m=m+4|0}else break}}g=j+8|0;k=l+-1|0;c[g>>2]=k;if(k){ek(n|0,0,k<<2|0)|0;ek(j+655376|0,0,k<<4|0)|0;if((l|0)>1){k=0;do{B=k<<2;c[j+131084+(B<<2)>>2]=e;c[j+131084+((B|1)<<2)>>2]=0;c[j+131084+((B|2)<<2)>>2]=f;c[j+131084+((B|3)<<2)>>2]=0;k=k+1|0}while((k|0)<(c[g>>2]|0))}if((o|0)>0){n=0;do{m=(c[j+1179664+(n<<2)>>2]|0)+-1|0;a=n*7|0;k=j+12+(m<<2)|0;c[k>>2]=(c[k>>2]|0)+(c[j+1310736+(a<<2)>>2]|0);k=m<<1;l=j+655376+(k<<3)|0;h[l>>3]=+h[l>>3]+ +(c[j+1310736+(a+1<<2)>>2]|0);k=j+655376+((k|1)<<3)|0;h[k>>3]=+h[k>>3]+ +(c[j+1310736+(a+2<<2)>>2]|0);m=m<<2;k=j+131084+(m<<2)|0;l=c[j+1310736+(a+3<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;k=j+131084+((m|1)<<2)|0;l=c[j+1310736+(a+4<<2)>>2]|0;if((c[k>>2]|0)<(l|0))c[k>>2]=l;k=j+131084+((m|2)<<2)|0;l=c[j+1310736+(a+5<<2)>>2]|0;if((c[k>>2]|0)>(l|0))c[k>>2]=l;l=j+131084+((m|3)<<2)|0;k=c[j+1310736+(a+6<<2)>>2]|0;if((c[l>>2]|0)<(k|0))c[l>>2]=k;n=n+1|0}while((n|0)<(o|0))}if((c[g>>2]|0)>0){k=0;do{e=j+12+(k<<2)|0;f=k<<1;B=j+655376+(f<<3)|0;h[B>>3]=+h[B>>3]/+(c[e>>2]|0);f=j+655376+((f|1)<<3)|0;h[f>>3]=+h[f>>3]/+(c[e>>2]|0);k=k+1|0}while((k|0)<(c[g>>2]|0));k=0}else k=0}else k=0}i=C;return k|0}function Zc(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f*3|0)+12|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f*6|0)+6)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){do if(((d[q+1>>0]|0)+(d[q>>0]|0)+(d[q+2>>0]|0)|0)>(y|0)){b[g>>1]=0;a[l>>0]=0;j=p}else{a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}while(0);r=r+1|0;n=q+6|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function _c(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<1)+8|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<2)+4)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){f=d[q>>0]|0;o=d[q+1>>0]|0;do if(((f&248)+10+(f<<5&224)+(o>>>3&28)+(o<<3&248)|0)>(y|0)){b[g>>1]=0;a[l>>0]=0;j=p}else{a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}while(0);r=r+1|0;n=q+4|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function $c(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<2)+16|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<3)+8)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){do if(((d[q+1>>0]|0)+(d[q>>0]|0)+(d[q+2>>0]|0)|0)>(y|0)){b[g>>1]=0;a[l>>0]=0;j=p}else{a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}while(0);r=r+1|0;n=q+8|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function ad(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<1)+8|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<2)+4)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){o=d[q>>0]|0;do if(((o&240)+24+(o<<4&240)+((d[q+1>>0]|0)&240)|0)>(y|0)){b[g>>1]=0;a[l>>0]=0;j=p}else{a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}while(0);r=r+1|0;n=q+4|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function bd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<1)+8|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<2)+4)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){f=d[q>>0]|0;o=d[q+1>>0]|0;do if(((f&248)+12+(f<<5&224)+(o>>>3&24)+(o<<2&248)|0)>(y|0)){b[g>>1]=0;a[l>>0]=0;j=p}else{a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}while(0);r=r+1|0;n=q+4|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}function cd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;B=F;D=(f|0)/2|0;E=(g|0)/2|0;o=c[k>>2]|0;A=E+-1|0;if((f|0)>1){l=0;m=o;n=o+(($(A,D)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(D|0))break;else{m=m+2|0;n=n+2|0}}}y=j*3|0;z=D+-1|0;if((g|0)>1){l=0;j=o;m=o+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(E|0))break;else{j=j+(D<<1)|0;m=m+(D<<1)|0}}}m=k+1179664|0;j=D+1|0;v=0-D|0;t=1-D|0;u=~D;s=(f<<2)+16|0;a:do if((A|0)>1){w=(z|0)>1;l=(c[k+4>>2]|0)+j|0;x=1;n=e+((f<<3)+8)|0;g=o+(j<<1)|0;j=0;b:while(1){if(w){r=1;q=n;p=j;while(1){do if(((d[q+2>>0]|0)+(d[q+1>>0]|0)+(d[q+3>>0]|0)|0)>(y|0)){b[g>>1]=0;a[l>>0]=0;j=p}else{a[l>>0]=-1;j=b[g+(v<<1)>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}e=b[g+(t<<1)>>1]|0;f=e<<16>>16;j=b[g+(u<<1)>>1]|0;o=j<<16>>16;n=j<<16>>16>0;if(e<<16>>16<=0){if(n){b[g>>1]=j;j=o*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=b[g+-2>>1]|0;if(j<<16>>16>0){b[g>>1]=j;j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(r|0)){j=p;break}c[j>>2]=r;j=p;break}else{j=p+1|0;if((p|0)>32767)break b;b[g>>1]=j;c[k+1179664+(p<<2)>>2]=j<<16>>16;p=p*7|0;c[k+1310736+(p<<2)>>2]=1;c[k+1310736+(p+1<<2)>>2]=r;c[k+1310736+(p+2<<2)>>2]=x;c[k+1310736+(p+3<<2)>>2]=r;c[k+1310736+(p+4<<2)>>2]=r;c[k+1310736+(p+5<<2)>>2]=x;c[k+1310736+(p+6<<2)>>2]=x;break}}if(n){j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+(o+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;o=k+1310736+(j+-5<<2)|0;c[o>>2]=(c[o>>2]|0)+x;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}n=b[g+-2>>1]|0;if(n<<16>>16<=0){b[g>>1]=e;j=f*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+r;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+x;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(r|0))c[n>>2]=r;c[k+1310736+(j+-1<<2)>>2]=x;j=p;break}j=c[k+1179664+(f+-1<<2)>>2]|0;f=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(f|0)){b[g>>1]=f;if((p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(j|0))c[e>>2]=f;n=n+1|0;if((n|0)>=(p|0)){j=f;break}else e=e+4|0}}else j=f}else{b[g>>1]=j;if((j|0)<(f|0)&(p|0)>0){n=0;e=m;while(1){if((c[e>>2]|0)==(f|0))c[e>>2]=j;n=n+1|0;if((n|0)>=(p|0))break;else e=e+4|0}}}j=(j<<16>>16)*7|0;o=k+1310736+(j+-7<<2)|0;c[o>>2]=(c[o>>2]|0)+1;o=k+1310736+(j+-6<<2)|0;c[o>>2]=(c[o>>2]|0)+r;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+x;j=p}while(0);r=r+1|0;n=q+8|0;g=g+2|0;l=l+1|0;if((r|0)>=(z|0))break;else{q=n;p=j}}}x=x+1|0;if((x|0)>=(A|0)){f=j;C=52;break a}else{l=l+2|0;n=n+s|0;g=g+4|0}}Me(3,3904,B);l=-1}else{f=0;C=52}while(0);if((C|0)==52){g=k+12|0;if((f|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(f|0)){n=n+1|0;m=m+4|0}else break}}e=k+8|0;l=j+-1|0;c[e>>2]=l;if(l){ek(g|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{C=l<<2;c[k+131084+(C<<2)>>2]=D;c[k+131084+((C|1)<<2)>>2]=0;c[k+131084+((C|2)<<2)>>2]=E;c[k+131084+((C|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[e>>2]|0))}if((f|0)>0){g=0;do{m=(c[k+1179664+(g<<2)>>2]|0)+-1|0;n=g*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;g=g+1|0}while((g|0)<(f|0))}if((c[e>>2]|0)>0){l=0;do{D=k+12+(l<<2)|0;E=l<<1;C=k+655376+(E<<3)|0;h[C>>3]=+h[C>>3]/+(c[D>>2]|0);E=k+655376+((E|1)<<3)|0;h[E>>3]=+h[E>>3]/+(c[D>>2]|0);l=l+1|0}while((l|0)<(c[e>>2]|0));l=0}else l=0}else l=0}i=F;return l|0}
  8. function sh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;if((b|0)!=1){if(b+-1&b)b=_j(b)|0}else b=2;f=c[a+4>>2]|0;if(b>>>0<=f>>>0){if(b>>>0<f>>>0){if(f>>>0>2)e=(f+-1&f|0)==0;else e=0;d=~~+_(+(+((c[a+12>>2]|0)>>>0)/+g[a+16>>2]))>>>0;if(e)d=1<<32-(ba(d+-1|0)|0);else d=_j(d)|0;b=b>>>0<d>>>0?d:b;if(b>>>0<f>>>0)th(a,b)}}else th(a,b);return}function th(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=a+4|0;a:do if(b){m=Kh(b<<2)|0;d=c[a>>2]|0;c[a>>2]=m;if(d)Lh(d);c[e>>2]=b;if(b){d=0;do{c[(c[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(b|0))}e=a+8|0;f=c[e>>2]|0;if(f){d=c[f+4>>2]|0;l=b+-1|0;m=(l&b|0)==0;if(m)h=d&l;else h=(d>>>0)%(b>>>0)|0;c[(c[a>>2]|0)+(h<<2)>>2]=e;d=c[f>>2]|0;if(d){g=f;e=f;while(1){k=e;b:while(1){while(1){e=c[d+4>>2]|0;if(m)j=e&l;else j=(e>>>0)%(b>>>0)|0;if((j|0)==(h|0)){e=d;break}e=(c[a>>2]|0)+(j<<2)|0;if(!(c[e>>2]|0)){h=j;f=d;break b}i=d+8|0;e=d;while(1){f=c[e>>2]|0;if(!f)break;if((c[i>>2]|0)==(c[f+8>>2]|0))e=f;else break}c[g>>2]=f;c[e>>2]=c[c[(c[a>>2]|0)+(j<<2)>>2]>>2];c[c[(c[a>>2]|0)+(j<<2)>>2]>>2]=d;d=c[k>>2]|0;if(!d)break a}d=c[e>>2]|0;if(!d)break a;else{g=e;k=e}}c[e>>2]=g;d=c[f>>2]|0;if(!d)break;else{g=f;e=f}}}}}else{d=c[a>>2]|0;c[a>>2]=0;if(d)Lh(d);c[e>>2]=0}while(0);return}function uh(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;g=i;i=i+32|0;h=g+16|0;f=g+4|0;j=g;d=c[d>>2]|0;e=c[d>>2]|0;c[j>>2]=d;c[h>>2]=c[j>>2];vh(f,b,h);d=c[f>>2]|0;c[f>>2]=0;if(d){if(a[f+8>>0]|0)Fg(d+264|0);Lh(d)}i=g;return e|0}function vh(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;o=c[e>>2]|0;l=c[d+4>>2]|0;e=c[o+4>>2]|0;m=l+-1|0;n=(m&l|0)==0;if(n)k=m&e;else k=(e>>>0)%(l>>>0)|0;g=(c[d>>2]|0)+(k<<2)|0;f=c[g>>2]|0;while(1){e=c[f>>2]|0;if((e|0)==(o|0)){j=f;break}else f=e}i=d+8|0;if((j|0)!=(i|0)){e=c[j+4>>2]|0;if(n)e=e&m;else e=(e>>>0)%(l>>>0)|0;if((e|0)==(k|0))g=o;else h=12}else h=12;do if((h|0)==12){e=c[o>>2]|0;if(e){e=c[e+4>>2]|0;if(n)e=e&m;else e=(e>>>0)%(l>>>0)|0;if((e|0)==(k|0)){g=o;break}}c[g>>2]=0;g=o}while(0);f=c[g>>2]|0;e=f;if(f){f=c[f+4>>2]|0;if(n)f=f&m;else f=(f>>>0)%(l>>>0)|0;if((f|0)!=(k|0)){c[(c[d>>2]|0)+(f<<2)>>2]=j;e=c[o>>2]|0}}c[j>>2]=e;c[g>>2]=0;d=d+12|0;c[d>>2]=(c[d>>2]|0)+-1;c[b>>2]=o;c[b+4>>2]=i;a[b+8>>0]=1;return}function wh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=Kh(408)|0;c[e+8>>2]=c[d>>2];ek(e+16|0,0,392)|0;h[e+248>>3]=.0001;h[e+256>>3]=1.0e3;d=e+264|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[a>>2]=e;a=a+4|0;c[a>>2]=b+8;c[a+4>>2]=257;return}function xh(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0.0,k=0.0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;m=c[e+8>>2]|0;s=e+4|0;c[s>>2]=m;r=d+4|0;l=c[r>>2]|0;q=(l|0)==0;a:do if(!q){n=l+-1|0;o=(n&l|0)==0;if(o)h=n&m;else h=(m>>>0)%(l>>>0)|0;f=c[(c[d>>2]|0)+(h<<2)>>2]|0;if(!f)p=12;else while(1){i=c[f>>2]|0;if(!i){p=12;break a}f=c[i+4>>2]|0;if(o)f=f&n;else f=(f>>>0)%(l>>>0)|0;if((f|0)!=(h|0)){p=12;break a}if((c[i+8>>2]|0)==(m|0)){f=0;e=i;break}else f=i}}else{h=0;p=12}while(0);if((p|0)==12){m=d+12|0;j=+(((c[m>>2]|0)+1|0)>>>0);k=+g[d+16>>2];do if(q|j>+(l>>>0)*k){if(l>>>0>2)f=(l+-1&l|0)==0;else f=0;i=(f&1|l<<1)^1;f=~~+_(+(j/k))>>>0;yh(d,i>>>0<f>>>0?f:i);i=c[r>>2]|0;f=c[s>>2]|0;h=i+-1|0;if(!(h&i)){l=i;h=h&f;break}else{l=i;h=(f>>>0)%(i>>>0)|0;break}}while(0);f=c[(c[d>>2]|0)+(h<<2)>>2]|0;if(!f){f=d+8|0;c[e>>2]=c[f>>2];c[f>>2]=e;c[(c[d>>2]|0)+(h<<2)>>2]=f;f=c[e>>2]|0;if(f){f=c[f+4>>2]|0;h=l+-1|0;if(!(h&l))f=f&h;else f=(f>>>0)%(l>>>0)|0;c[(c[d>>2]|0)+(f<<2)>>2]=e}}else{c[e>>2]=c[f>>2];c[f>>2]=e}c[m>>2]=(c[m>>2]|0)+1;f=1}c[b>>2]=e;a[b+4>>0]=f;return}function yh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;if((b|0)!=1){if(b+-1&b)b=_j(b)|0}else b=2;f=c[a+4>>2]|0;if(b>>>0<=f>>>0){if(b>>>0<f>>>0){if(f>>>0>2)e=(f+-1&f|0)==0;else e=0;d=~~+_(+(+((c[a+12>>2]|0)>>>0)/+g[a+16>>2]))>>>0;if(e)d=1<<32-(ba(d+-1|0)|0);else d=_j(d)|0;b=b>>>0<d>>>0?d:b;if(b>>>0<f>>>0)zh(a,b)}}else zh(a,b);return}function zh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=a+4|0;a:do if(b){m=Kh(b<<2)|0;d=c[a>>2]|0;c[a>>2]=m;if(d)Lh(d);c[e>>2]=b;if(b){d=0;do{c[(c[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(b|0))}e=a+8|0;f=c[e>>2]|0;if(f){d=c[f+4>>2]|0;l=b+-1|0;m=(l&b|0)==0;if(m)h=d&l;else h=(d>>>0)%(b>>>0)|0;c[(c[a>>2]|0)+(h<<2)>>2]=e;d=c[f>>2]|0;if(d){g=f;e=f;while(1){k=e;b:while(1){while(1){e=c[d+4>>2]|0;if(m)j=e&l;else j=(e>>>0)%(b>>>0)|0;if((j|0)==(h|0)){e=d;break}e=(c[a>>2]|0)+(j<<2)|0;if(!(c[e>>2]|0)){h=j;f=d;break b}i=d+8|0;e=d;while(1){f=c[e>>2]|0;if(!f)break;if((c[i>>2]|0)==(c[f+8>>2]|0))e=f;else break}c[g>>2]=f;c[e>>2]=c[c[(c[a>>2]|0)+(j<<2)>>2]>>2];c[c[(c[a>>2]|0)+(j<<2)>>2]>>2]=d;d=c[k>>2]|0;if(!d)break a}d=c[e>>2]|0;if(!d)break a;else{g=e;k=e}}c[e>>2]=g;d=c[f>>2]|0;if(!d)break;else{g=f;e=f}}}}}else{d=c[a>>2]|0;c[a>>2]=0;if(d)Lh(d);c[e>>2]=0}while(0);return}function Ah(a){a=a|0;return Aj(c[a+4>>2]|0)|0}function Bh(a){a=a|0;Ka(624,10917);Ya(632,10922,1,1,0);Ga(640,10927,1,-128,127);Ga(656,10932,1,-128,127);Ga(648,10944,1,0,255);Ga(664,10958,2,-32768,32767);Ga(672,10964,2,0,65535);Ga(680,10979,4,-2147483648,2147483647);Ga(688,10983,4,0,-1);Ga(696,10996,4,-2147483648,2147483647);Ga(704,11001,4,0,-1);kb(712,11015,4);kb(720,11021,8);sb(360,11028);sb(392,11040);bb(416,4,11073);db(440,11086);Aa(448,0,11102);Dh(11132);Eh(11169);Fh(11208);Gh(11239);Hh(11279);Ih(11308);Aa(456,4,11346);Aa(464,5,11376);Dh(11415);Eh(11447);Fh(11480);Gh(11513);Hh(11547);Ih(11580);Aa(472,6,11614);Aa(480,7,11645);Aa(488,7,11677);return}function Ch(){Bh(0);return}function Dh(a){a=a|0;Aa(536,0,a|0);return}function Eh(a){a=a|0;Aa(528,1,a|0);return}function Fh(a){a=a|0;Aa(520,2,a|0);return}function Gh(a){a=a|0;Aa(512,3,a|0);return}function Hh(a){a=a|0;Aa(504,4,a|0);return}function Ih(a){a=a|0;Aa(496,5,a|0);return}function Jh(a){a=a|0;Ia(12478,12501,303,12589)}function Kh(a){a=a|0;var b=0;b=(a|0)==0?1:a;a=Uj(b)|0;a:do if(!a){while(1){a=Ph()|0;if(!a)break;_b[a&0]();a=Uj(b)|0;if(a)break a}b=Wa(4)|0;c[b>>2]=2224;wb(b|0,544,1)}while(0);return a|0}function Lh(a){a=a|0;Vj(a);return}function Mh(a){a=a|0;return}function Nh(a){a=a|0;Lh(a);return}function Oh(a){a=a|0;return 12610}function Ph(){var a=0;a=c[559]|0;c[559]=a+0;return a|0}function Qh(a){a=a|0;return}function Rh(a){a=a|0;return}function Sh(a){a=a|0;return}function Th(a){a=a|0;return}function Uh(a){a=a|0;return}function Vh(a){a=a|0;Lh(a);return}function Wh(a){a=a|0;Lh(a);return}function Xh(a){a=a|0;Lh(a);return}function Yh(a){a=a|0;Lh(a);return}function Zh(a,b,c){a=a|0;b=b|0;c=c|0;return (a|0)==(b|0)|0}function _h(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;h=i;i=i+64|0;g=h;if((a|0)!=(b|0))if((b|0)!=0?(f=ei(b,576,592,0)|0,(f|0)!=0):0){b=g;e=b+56|0;do{c[b>>2]=0;b=b+4|0}while((b|0)<(e|0));c[g>>2]=f;c[g+8>>2]=a;c[g+12>>2]=-1;c[g+48>>2]=1;dc[c[(c[f>>2]|0)+28>>2]&3](f,g,c[d>>2]|0,1);if((c[g+24>>2]|0)==1){c[d>>2]=c[g+16>>2];b=1}else b=0}else b=0;else b=1;i=h;return b|0}function $h(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0;b=d+16|0;g=c[b>>2]|0;do if(g){if((g|0)!=(e|0)){f=d+36|0;c[f>>2]=(c[f>>2]|0)+1;c[d+24>>2]=2;a[d+54>>0]=1;break}b=d+24|0;if((c[b>>2]|0)==2)c[b>>2]=f}else{c[b>>2]=e;c[d+24>>2]=f;c[d+36>>2]=1}while(0);return}function ai(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;if((a|0)==(c[b+8>>2]|0))$h(0,b,d,e);return}function bi(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;if((a|0)==(c[b+8>>2]|0))$h(0,b,d,e);else{a=c[a+8>>2]|0;dc[c[(c[a>>2]|0)+28>>2]&3](a,b,d,e)}return}function ci(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;g=c[a+4>>2]|0;f=g>>8;if(g&1)f=c[(c[d>>2]|0)+f>>2]|0;a=c[a>>2]|0;dc[c[(c[a>>2]|0)+28>>2]&3](a,b,d+f|0,(g&2|0)!=0?e:2);return}function di(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;a:do if((b|0)!=(c[d+8>>2]|0)){h=c[b+12>>2]|0;g=b+16+(h<<3)|0;ci(b+16|0,d,e,f);if((h|0)>1){h=d+54|0;b=b+24|0;do{ci(b,d,e,f);if(a[h>>0]|0)break a;b=b+8|0}while(b>>>0<g>>>0)}}else $h(0,d,e,f);while(0);return}function ei(d,e,f,g){d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+64|0;q=r;p=c[d>>2]|0;o=d+(c[p+-8>>2]|0)|0;p=c[p+-4>>2]|0;c[q>>2]=f;c[q+4>>2]=d;c[q+8>>2]=e;c[q+12>>2]=g;g=q+16|0;d=q+20|0;e=q+24|0;h=q+28|0;j=q+32|0;k=q+40|0;l=(p|0)==(f|0);m=g;n=m+36|0;do{c[m>>2]=0;m=m+4|0}while((m|0)<(n|0));b[g+36>>1]=0;a[g+38>>0]=0;a:do if(l){c[q+48>>2]=1;bc[c[(c[f>>2]|0)+20>>2]&3](f,q,o,o,1,0);g=(c[e>>2]|0)==1?o:0}else{Rb[c[(c[p>>2]|0)+24>>2]&3](p,q,o,1,0);switch(c[q+36>>2]|0){case 0:{g=(c[k>>2]|0)==1&(c[h>>2]|0)==1&(c[j>>2]|0)==1?c[d>>2]|0:0;break a}case 1:break;default:{g=0;break a}}if((c[e>>2]|0)!=1?!((c[k>>2]|0)==0&(c[h>>2]|0)==1&(c[j>>2]|0)==1):0){g=0;break}g=c[g>>2]|0}while(0);i=r;return g|0}function fi(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;a[d+53>>0]=1;do if((c[d+4>>2]|0)==(f|0)){a[d+52>>0]=1;f=d+16|0;b=c[f>>2]|0;if(!b){c[f>>2]=e;c[d+24>>2]=g;c[d+36>>2]=1;if(!((g|0)==1?(c[d+48>>2]|0)==1:0))break;a[d+54>>0]=1;break}if((b|0)!=(e|0)){g=d+36|0;c[g>>2]=(c[g>>2]|0)+1;a[d+54>>0]=1;break}b=d+24|0;f=c[b>>2]|0;if((f|0)==2){c[b>>2]=g;f=g}if((f|0)==1?(c[d+48>>2]|0)==1:0)a[d+54>>0]=1}while(0);return}function gi(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;a:do if((b|0)==(c[d+8>>2]|0)){if((c[d+4>>2]|0)==(e|0)?(h=d+28|0,(c[h>>2]|0)!=1):0)c[h>>2]=f}else{if((b|0)!=(c[d>>2]|0)){q=c[b+12>>2]|0;j=b+16+(q<<3)|0;ii(b+16|0,d,e,f,g);h=b+24|0;if((q|0)<=1)break;i=c[b+8>>2]|0;if((i&2|0)==0?(k=d+36|0,(c[k>>2]|0)!=1):0){if(!(i&1)){i=d+54|0;while(1){if(a[i>>0]|0)break a;if((c[k>>2]|0)==1)break a;ii(h,d,e,f,g);h=h+8|0;if(h>>>0>=j>>>0)break a}}i=d+24|0;b=d+54|0;while(1){if(a[b>>0]|0)break a;if((c[k>>2]|0)==1?(c[i>>2]|0)==1:0)break a;ii(h,d,e,f,g);h=h+8|0;if(h>>>0>=j>>>0)break a}}i=d+54|0;while(1){if(a[i>>0]|0)break a;ii(h,d,e,f,g);h=h+8|0;if(h>>>0>=j>>>0)break a}}if((c[d+16>>2]|0)!=(e|0)?(p=d+20|0,(c[p>>2]|0)!=(e|0)):0){c[d+32>>2]=f;m=d+44|0;if((c[m>>2]|0)==4)break;i=c[b+12>>2]|0;j=b+16+(i<<3)|0;k=d+52|0;f=d+53|0;n=d+54|0;l=b+8|0;o=d+24|0;b:do if((i|0)>0){i=0;h=0;b=b+16|0;while(1){a[k>>0]=0;a[f>>0]=0;hi(b,d,e,e,1,g);if(a[n>>0]|0){q=20;break b}do if(a[f>>0]|0){if(!(a[k>>0]|0))if(!(c[l>>2]&1)){h=1;q=20;break b}else{h=1;break}if((c[o>>2]|0)==1)break b;if(!(c[l>>2]&2))break b;else{i=1;h=1}}while(0);b=b+8|0;if(b>>>0>=j>>>0){q=20;break}}}else{i=0;h=0;q=20}while(0);do if((q|0)==20){if((!i?(c[p>>2]=e,e=d+40|0,c[e>>2]=(c[e>>2]|0)+1,(c[d+36>>2]|0)==1):0)?(c[o>>2]|0)==2:0){a[n>>0]=1;if(h)break}else q=24;if((q|0)==24?h:0)break;c[m>>2]=4;break a}while(0);c[m>>2]=3;break}if((f|0)==1)c[d+32>>2]=1}while(0);return}function hi(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;i=c[a+4>>2]|0;h=i>>8;if(i&1)h=c[(c[e>>2]|0)+h>>2]|0;a=c[a>>2]|0;bc[c[(c[a>>2]|0)+20>>2]&3](a,b,d,e+h|0,(i&2|0)!=0?f:2,g);return}function ii(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;h=c[a+4>>2]|0;g=h>>8;if(h&1)g=c[(c[d>>2]|0)+g>>2]|0;a=c[a>>2]|0;Rb[c[(c[a>>2]|0)+24>>2]&3](a,b,d+g|0,(h&2|0)!=0?e:2,f);return}function ji(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;a:do if((b|0)==(c[d+8>>2]|0)){if((c[d+4>>2]|0)==(e|0)?(h=d+28|0,(c[h>>2]|0)!=1):0)c[h>>2]=f}else{if((b|0)!=(c[d>>2]|0)){j=c[b+8>>2]|0;Rb[c[(c[j>>2]|0)+24>>2]&3](j,d,e,f,g);break}if((c[d+16>>2]|0)!=(e|0)?(i=d+20|0,(c[i>>2]|0)!=(e|0)):0){c[d+32>>2]=f;f=d+44|0;if((c[f>>2]|0)==4)break;h=d+52|0;a[h>>0]=0;k=d+53|0;a[k>>0]=0;b=c[b+8>>2]|0;bc[c[(c[b>>2]|0)+20>>2]&3](b,d,e,e,1,g);if(a[k>>0]|0){if(!(a[h>>0]|0)){h=1;j=13}}else{h=0;j=13}do if((j|0)==13){c[i>>2]=e;k=d+40|0;c[k>>2]=(c[k>>2]|0)+1;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==2:0){a[d+54>>0]=1;if(h)break}else j=16;if((j|0)==16?h:0)break;c[f>>2]=4;break a}while(0);c[f>>2]=3;break}if((f|0)==1)c[d+32>>2]=1}while(0);return}function ki(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;do if((b|0)==(c[d+8>>2]|0)){if((c[d+4>>2]|0)==(e|0)?(i=d+28|0,(c[i>>2]|0)!=1):0)c[i>>2]=f}else if((b|0)==(c[d>>2]|0)){if((c[d+16>>2]|0)!=(e|0)?(h=d+20|0,(c[h>>2]|0)!=(e|0)):0){c[d+32>>2]=f;c[h>>2]=e;g=d+40|0;c[g>>2]=(c[g>>2]|0)+1;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==2:0)a[d+54>>0]=1;c[d+44>>2]=4;break}if((f|0)==1)c[d+32>>2]=1}while(0);return}function li(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if((b|0)==(c[d+8>>2]|0))fi(0,d,e,f,g);else{m=d+52|0;n=a[m>>0]|0;o=d+53|0;p=a[o>>0]|0;l=c[b+12>>2]|0;i=b+16+(l<<3)|0;a[m>>0]=0;a[o>>0]=0;hi(b+16|0,d,e,f,g,h);a:do if((l|0)>1){j=d+24|0;k=b+8|0;l=d+54|0;b=b+24|0;do{if(a[l>>0]|0)break a;if(!(a[m>>0]|0)){if((a[o>>0]|0)!=0?(c[k>>2]&1|0)==0:0)break a}else{if((c[j>>2]|0)==1)break a;if(!(c[k>>2]&2))break a}a[m>>0]=0;a[o>>0]=0;hi(b,d,e,f,g,h);b=b+8|0}while(b>>>0<i>>>0)}while(0);a[m>>0]=n;a[o>>0]=p}return}function mi(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;if((a|0)==(c[b+8>>2]|0))fi(0,b,d,e,f);else{a=c[a+8>>2]|0;bc[c[(c[a>>2]|0)+20>>2]&3](a,b,d,e,f,g)}return}function ni(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;if((a|0)==(c[b+8>>2]|0))fi(0,b,d,e,f);return}function oi(a){a=a|0;Ia(12625,12654,1164,12589)}function pi(a){a=a|0;return ((a|0)==32|(a+-9|0)>>>0<5)&1|0}function qi(){var a=0;if(!(c[597]|0))a=2644;else a=c[(gb()|0)+60>>2]|0;return a|0}function ri(b){b=b|0;var c=0,e=0;c=0;while(1){if((d[12742+c>>0]|0)==(b|0)){e=2;break}c=c+1|0;if((c|0)==87){c=87;b=12830;e=5;break}}if((e|0)==2)if(!c)b=12830;else{b=12830;e=5}if((e|0)==5)while(1){e=b;while(1){b=e+1|0;if(!(a[e>>0]|0))break;else e=b}c=c+-1|0;if(!c)break;else e=5}return b|0}function si(b,e,f){b=b|0;e=e|0;f=f|0;var g=0.0,h=0,j=0.0,k=0,l=0,m=0.0,n=0,o=0,p=0,q=0.0,r=0.0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0.0;L=i;i=i+512|0;H=L;switch(e|0){case 0:{K=24;J=-149;A=4;break}case 1:{K=53;J=-1074;A=4;break}case 2:{K=53;J=-1074;A=4;break}default:g=0.0}a:do if((A|0)==4){E=b+4|0;C=b+100|0;do{e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0}else e=vi(b)|0}while((pi(e)|0)!=0);b:do switch(e|0){case 43:case 45:{h=1-(((e|0)==45&1)<<1)|0;e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0;I=h;break b}else{e=vi(b)|0;I=h;break b}}default:I=1}while(0);h=e;e=0;do{if((h|32|0)!=(a[14634+e>>0]|0))break;do if(e>>>0<7){h=c[E>>2]|0;if(h>>>0<(c[C>>2]|0)>>>0){c[E>>2]=h+1;h=d[h>>0]|0;break}else{h=vi(b)|0;break}}while(0);e=e+1|0}while(e>>>0<8);c:do switch(e|0){case 8:break;case 3:{A=23;break}default:{k=(f|0)!=0;if(k&e>>>0>3)if((e|0)==8)break c;else{A=23;break c}d:do if(!e){e=0;do{if((h|32|0)!=(a[16477+e>>0]|0))break d;do if(e>>>0<2){h=c[E>>2]|0;if(h>>>0<(c[C>>2]|0)>>>0){c[E>>2]=h+1;h=d[h>>0]|0;break}else{h=vi(b)|0;break}}while(0);e=e+1|0}while(e>>>0<3)}while(0);switch(e|0){case 3:{e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0}else e=vi(b)|0;if((e|0)==40)e=1;else{if(!(c[C>>2]|0)){g=s;break a}c[E>>2]=(c[E>>2]|0)+-1;g=s;break a}while(1){h=c[E>>2]|0;if(h>>>0<(c[C>>2]|0)>>>0){c[E>>2]=h+1;h=d[h>>0]|0}else h=vi(b)|0;if(!((h+-48|0)>>>0<10|(h+-65|0)>>>0<26)?!((h|0)==95|(h+-97|0)>>>0<26):0)break;e=e+1|0}if((h|0)==41){g=s;break a}h=(c[C>>2]|0)==0;if(!h)c[E>>2]=(c[E>>2]|0)+-1;if(!k){c[(qi()|0)>>2]=22;ui(b,0);g=0.0;break a}if(!e){g=s;break a}while(1){e=e+-1|0;if(!h)c[E>>2]=(c[E>>2]|0)+-1;if(!e){g=s;break a}}}case 0:{do if((h|0)==48){e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0}else e=vi(b)|0;if((e|32|0)!=120){if(!(c[C>>2]|0)){e=48;break}c[E>>2]=(c[E>>2]|0)+-1;e=48;break}e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0;k=0}else{e=vi(b)|0;k=0}e:while(1){switch(e|0){case 46:{A=74;break e}case 48:break;default:{y=0;l=0;x=0;h=0;n=k;o=0;w=0;m=1.0;k=0;g=0.0;break e}}e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0;k=1;continue}else{e=vi(b)|0;k=1;continue}}if((A|0)==74){e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0}else e=vi(b)|0;if((e|0)==48){k=0;h=0;do{e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0}else e=vi(b)|0;k=gk(k|0,h|0,-1,-1)|0;h=D}while((e|0)==48);y=0;l=0;x=k;n=1;o=1;w=0;m=1.0;k=0;g=0.0}else{y=0;l=0;x=0;h=0;n=k;o=1;w=0;m=1.0;k=0;g=0.0}}while(1){u=e+-48|0;p=e|32;if(u>>>0>=10){v=(e|0)==46;if(!(v|(p+-97|0)>>>0<6)){p=x;u=y;break}if(v)if(!o){v=l;h=y;u=y;o=1;p=w;j=m}else{p=x;u=y;e=46;break}else A=86}else A=86;if((A|0)==86){A=0;e=(e|0)>57?p+-87|0:u;do if(!((y|0)<0|(y|0)==0&l>>>0<8)){if((y|0)<0|(y|0)==0&l>>>0<14){r=m*.0625;p=w;j=r;g=g+r*+(e|0);break}if((w|0)!=0|(e|0)==0){p=w;j=m}else{p=1;j=m;g=g+m*.5}}else{p=w;j=m;k=e+(k<<4)|0}while(0);l=gk(l|0,y|0,1,0)|0;v=x;u=D;n=1}e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;y=u;x=v;e=d[e>>0]|0;w=p;m=j;continue}else{y=u;x=v;e=vi(b)|0;w=p;m=j;continue}}if(!n){e=(c[C>>2]|0)==0;if(!e)c[E>>2]=(c[E>>2]|0)+-1;if(f){if(!e?(z=c[E>>2]|0,c[E>>2]=z+-1,(o|0)!=0):0)c[E>>2]=z+-2}else ui(b,0);g=+(I|0)*0.0;break a}n=(o|0)==0;o=n?l:p;n=n?u:h;if((u|0)<0|(u|0)==0&l>>>0<8){h=u;do{k=k<<4;l=gk(l|0,h|0,1,0)|0;h=D}while((h|0)<0|(h|0)==0&l>>>0<8)}if((e|32|0)==112){h=Hj(b,f)|0;e=D;if((h|0)==0&(e|0)==-2147483648){if(!f){ui(b,0);g=0.0;break a}if(!(c[C>>2]|0)){h=0;e=0}else{c[E>>2]=(c[E>>2]|0)+-1;h=0;e=0}}}else if(!(c[C>>2]|0)){h=0;e=0}else{c[E>>2]=(c[E>>2]|0)+-1;h=0;e=0}H=fk(o|0,n|0,2)|0;H=gk(H|0,D|0,-32,-1)|0;e=gk(H|0,D|0,h|0,e|0)|0;h=D;if(!k){g=+(I|0)*0.0;break a}if((h|0)>0|(h|0)==0&e>>>0>(0-J|0)>>>0){c[(qi()|0)>>2]=34;g=+(I|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break a}H=J+-106|0;G=((H|0)<0)<<31>>31;if((h|0)<(G|0)|(h|0)==(G|0)&e>>>0<H>>>0){c[(qi()|0)>>2]=34;g=+(I|0)*2.2250738585072014e-308*2.2250738585072014e-308;break a}if((k|0)>-1){do{G=!(g>=.5);H=G&1|k<<1;k=H^1;g=g+(G?g:g+-1.0);e=gk(e|0,h|0,-1,-1)|0;h=D}while((H|0)>-1);l=e;m=g}else{l=e;m=g}e=dk(32,0,J|0,((J|0)<0)<<31>>31|0)|0;e=gk(l|0,h|0,e|0,D|0)|0;J=D;if(0>(J|0)|0==(J|0)&K>>>0>e>>>0)if((e|0)<0){e=0;A=127}else A=125;else{e=K;A=125}if((A|0)==125)if((e|0)<53)A=127;else{h=e;j=+(I|0);g=0.0}if((A|0)==127){g=+(I|0);h=e;j=g;g=+yi(+Di(1.0,84-e|0),g)}K=(k&1|0)==0&(m!=0.0&(h|0)<32);g=j*(K?0.0:m)+(g+j*+(((K&1)+k|0)>>>0))-g;if(!(g!=0.0))c[(qi()|0)>>2]=34;g=+Ei(g,l);break a}else e=h;while(0);F=J+K|0;G=0-F|0;k=0;f:while(1){switch(e|0){case 46:{A=138;break f}case 48:break;default:{h=0;p=0;o=0;break f}}e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0;k=1;continue}else{e=vi(b)|0;k=1;continue}}if((A|0)==138){e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0}else e=vi(b)|0;if((e|0)==48){h=0;e=0;while(1){h=gk(h|0,e|0,-1,-1)|0;k=D;e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0}else e=vi(b)|0;if((e|0)==48)e=k;else{p=k;k=1;o=1;break}}}else{h=0;p=0;o=1}}c[H>>2]=0;n=e+-48|0;l=(e|0)==46;g:do if(l|n>>>0<10){B=H+496|0;y=0;v=0;w=l;A=p;u=k;z=o;k=0;l=0;o=0;h:while(1){do if(w)if(!z){h=y;p=v;z=1}else{p=A;e=y;n=v;break h}else{w=gk(y|0,v|0,1,0)|0;v=D;x=(e|0)!=48;if((l|0)>=125){if(!x){p=A;y=w;break}c[B>>2]=c[B>>2]|1;p=A;y=w;break}p=H+(l<<2)|0;if(k)n=e+-48+((c[p>>2]|0)*10|0)|0;c[p>>2]=n;k=k+1|0;n=(k|0)==9;p=A;y=w;u=1;k=n?0:k;l=(n&1)+l|0;o=x?w:o}while(0);e=c[E>>2]|0;if(e>>>0<(c[C>>2]|0)>>>0){c[E>>2]=e+1;e=d[e>>0]|0}else e=vi(b)|0;n=e+-48|0;w=(e|0)==46;if(!(w|n>>>0<10)){n=z;A=161;break g}else A=p}u=(u|0)!=0;A=169}else{y=0;v=0;u=k;n=o;k=0;l=0;o=0;A=161}while(0);do if((A|0)==161){B=(n|0)==0;h=B?y:h;p=B?v:p;u=(u|0)!=0;if(!((e|32|0)==101&u))if((e|0)>-1){e=y;n=v;A=169;break}else{e=y;n=v;A=171;break}n=Hj(b,f)|0;e=D;if((n|0)==0&(e|0)==-2147483648){if(!f){ui(b,0);g=0.0;break}if(!(c[C>>2]|0)){n=0;e=0}else{c[E>>2]=(c[E>>2]|0)+-1;n=0;e=0}}h=gk(n|0,e|0,h|0,p|0)|0;u=y;p=D;n=v;A=173}while(0);if((A|0)==169)if(c[C>>2]|0){c[E>>2]=(c[E>>2]|0)+-1;if(u){u=e;A=173}else A=172}else A=171;if((A|0)==171)if(u){u=e;A=173}else A=172;do if((A|0)==172){c[(qi()|0)>>2]=22;ui(b,0);g=0.0}else if((A|0)==173){e=c[H>>2]|0;if(!e){g=+(I|0)*0.0;break}if(((n|0)<0|(n|0)==0&u>>>0<10)&((h|0)==(u|0)&(p|0)==(n|0))?K>>>0>30|(e>>>K|0)==0:0){g=+(I|0)*+(e>>>0);break}b=(J|0)/-2|0;E=((b|0)<0)<<31>>31;if((p|0)>(E|0)|(p|0)==(E|0)&h>>>0>b>>>0){c[(qi()|0)>>2]=34;g=+(I|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break}b=J+-106|0;E=((b|0)<0)<<31>>31;if((p|0)<(E|0)|(p|0)==(E|0)&h>>>0<b>>>0){c[(qi()|0)>>2]=34;g=+(I|0)*2.2250738585072014e-308*2.2250738585072014e-308;break}if(k){if((k|0)<9){n=H+(l<<2)|0;e=c[n>>2]|0;do{e=e*10|0;k=k+1|0}while((k|0)!=9);c[n>>2]=e}l=l+1|0}if((o|0)<9?(o|0)<=(h|0)&(h|0)<18:0){if((h|0)==9){g=+(I|0)*+((c[H>>2]|0)>>>0);break}if((h|0)<9){g=+(I|0)*+((c[H>>2]|0)>>>0)/+(c[2648+(8-h<<2)>>2]|0);break}b=K+27+($(h,-3)|0)|0;e=c[H>>2]|0;if((b|0)>30|(e>>>b|0)==0){g=+(I|0)*+(e>>>0)*+(c[2648+(h+-10<<2)>>2]|0);break}}e=(h|0)%9|0;if(!e){k=0;e=0}else{u=(h|0)>-1?e:e+9|0;n=c[2648+(8-u<<2)>>2]|0;if(l){o=1e9/(n|0)|0;k=0;e=0;p=0;do{C=H+(p<<2)|0;E=c[C>>2]|0;b=((E>>>0)/(n>>>0)|0)+e|0;c[C>>2]=b;e=$((E>>>0)%(n>>>0)|0,o)|0;b=(p|0)==(k|0)&(b|0)==0;p=p+1|0;h=b?h+-9|0:h;k=b?p&127:k}while((p|0)!=(l|0));if(e){c[H+(l<<2)>>2]=e;l=l+1|0}}else{k=0;l=0}e=0;h=9-u+h|0}i:while(1){v=(h|0)<18;w=(h|0)==18;x=H+(k<<2)|0;do{if(!v){if(!w)break i;if((c[x>>2]|0)>>>0>=9007199){h=18;break i}}n=0;o=l+127|0;while(1){u=o&127;p=H+(u<<2)|0;o=fk(c[p>>2]|0,0,29)|0;o=gk(o|0,D|0,n|0,0)|0;n=D;if(n>>>0>0|(n|0)==0&o>>>0>1e9){b=pk(o|0,n|0,1e9,0)|0;o=qk(o|0,n|0,1e9,0)|0;n=b}else n=0;c[p>>2]=o;b=(u|0)==(k|0);l=(u|0)!=(l+127&127|0)|b?l:(o|0)==0?u:l;if(b)break;else o=u+-1|0}e=e+-29|0}while((n|0)==0);k=k+127&127;if((k|0)==(l|0)){b=l+127&127;l=H+((l+126&127)<<2)|0;c[l>>2]=c[l>>2]|c[H+(b<<2)>>2];l=b}c[H+(k<<2)>>2]=n;h=h+9|0}j:while(1){y=l+1&127;x=H+((l+127&127)<<2)|0;while(1){v=(h|0)==18;w=(h|0)>27?9:1;u=v^1;while(1){o=k&127;p=(o|0)==(l|0);do if(!p){n=c[H+(o<<2)>>2]|0;if(n>>>0<9007199){A=219;break}if(n>>>0>9007199)break;n=k+1&127;if((n|0)==(l|0)){A=219;break}n=c[H+(n<<2)>>2]|0;if(n>>>0<254740991){A=219;break}if(!(n>>>0>254740991|u)){h=o;break j}}else A=219;while(0);if((A|0)==219?(A=0,v):0){A=220;break j}e=e+w|0;if((k|0)==(l|0))k=l;else break}u=(1<<w)+-1|0;v=1e9>>>w;o=k;n=0;p=k;while(1){E=H+(p<<2)|0;b=c[E>>2]|0;k=(b>>>w)+n|0;c[E>>2]=k;n=$(b&u,v)|0;k=(p|0)==(o|0)&(k|0)==0;p=p+1&127;h=k?h+-9|0:h;k=k?p:o;if((p|0)==(l|0))break;else o=k}if(!n)continue;if((y|0)!=(k|0))break;c[x>>2]=c[x>>2]|1}c[H+(l<<2)>>2]=n;l=y}if((A|0)==220)if(p){c[H+(y+-1<<2)>>2]=0;h=l;l=y}else h=o;g=+((c[H+(h<<2)>>2]|0)>>>0);h=k+1&127;if((h|0)==(l|0)){l=k+2&127;c[H+(l+-1<<2)>>2]=0}r=+(I|0);j=r*(g*1.0e9+ +((c[H+(h<<2)>>2]|0)>>>0));v=e+53|0;p=v-J|0;u=(p|0)<(K|0);h=u&1;o=u?((p|0)<0?0:p):K;if((o|0)<53){M=+yi(+Di(1.0,105-o|0),j);m=+Ai(j,+Di(1.0,53-o|0));q=M;g=m;m=M+(j-m)}else{q=0.0;g=0.0;m=j}n=k+2&127;do if((n|0)==(l|0))j=g;else{n=c[H+(n<<2)>>2]|0;do if(n>>>0>=5e8){if(n>>>0>5e8){g=r*.75+g;break}if((k+3&127|0)==(l|0)){g=r*.5+g;break}else{g=r*.75+g;break}}else{if((n|0)==0?(k+3&127|0)==(l|0):0)break;g=r*.25+g}while(0);if((53-o|0)<=1){j=g;break}if(+Ai(g,1.0)!=0.0){j=g;break}j=g+1.0}while(0);g=m+j-q;do if((v&2147483647|0)>(-2-F|0)){if(+O(+g)>=9007199254740992.0){h=u&(o|0)==(p|0)?0:h;e=e+1|0;g=g*.5}if((e+50|0)<=(G|0)?!(j!=0.0&(h|0)!=0):0)break;c[(qi()|0)>>2]=34}while(0);g=+Ei(g,e)}while(0);break a}default:{if(c[C>>2]|0)c[E>>2]=(c[E>>2]|0)+-1;c[(qi()|0)>>2]=22;ui(b,0);g=0.0;break a}}}}while(0);if((A|0)==23){h=(c[C>>2]|0)==0;if(!h)c[E>>2]=(c[E>>2]|0)+-1;if((f|0)!=0&e>>>0>3)do{if(!h)c[E>>2]=(c[E>>2]|0)+-1;e=e+-1|0}while(e>>>0>3)}g=+(I|0)*t}while(0);i=L;return +g}function ti(b,e,f,g,h){b=b|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;a:do if(e>>>0>36){c[(qi()|0)>>2]=22;h=0;g=0}else{r=b+4|0;q=b+100|0;do{i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=vi(b)|0}while((pi(i)|0)!=0);b:do switch(i|0){case 43:case 45:{j=((i|0)==45)<<31>>31;i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0;p=j;break b}else{i=vi(b)|0;p=j;break b}}default:p=0}while(0);j=(e|0)==0;do if((e&-17|0)==0&(i|0)==48){i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=vi(b)|0;if((i|32|0)!=120)if(j){e=8;n=46;break}else{n=32;break}e=c[r>>2]|0;if(e>>>0<(c[q>>2]|0)>>>0){c[r>>2]=e+1;i=d[e>>0]|0}else i=vi(b)|0;if((d[14643+(i+1)>>0]|0)>15){g=(c[q>>2]|0)==0;if(!g)c[r>>2]=(c[r>>2]|0)+-1;if(!f){ui(b,0);h=0;g=0;break a}if(g){h=0;g=0;break a}c[r>>2]=(c[r>>2]|0)+-1;h=0;g=0;break a}else{e=16;n=46}}else{e=j?10:e;if((d[14643+(i+1)>>0]|0)>>>0<e>>>0)n=32;else{if(c[q>>2]|0)c[r>>2]=(c[r>>2]|0)+-1;ui(b,0);c[(qi()|0)>>2]=22;h=0;g=0;break a}}while(0);if((n|0)==32)if((e|0)==10){e=i+-48|0;if(e>>>0<10){i=0;while(1){j=(i*10|0)+e|0;e=c[r>>2]|0;if(e>>>0<(c[q>>2]|0)>>>0){c[r>>2]=e+1;i=d[e>>0]|0}else i=vi(b)|0;e=i+-48|0;if(!(e>>>0<10&j>>>0<429496729)){e=j;break}else i=j}j=0}else{e=0;j=0}f=i+-48|0;if(f>>>0<10){while(1){k=ok(e|0,j|0,10,0)|0;l=D;m=((f|0)<0)<<31>>31;o=~m;if(l>>>0>o>>>0|(l|0)==(o|0)&k>>>0>~f>>>0){k=e;break}e=gk(k|0,l|0,f|0,m|0)|0;j=D;i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=vi(b)|0;f=i+-48|0;if(!(f>>>0<10&(j>>>0<429496729|(j|0)==429496729&e>>>0<2576980378))){k=e;break}}if(f>>>0>9){i=k;e=p}else{e=10;n=72}}else{i=e;e=p}}else n=46;c:do if((n|0)==46){if(!(e+-1&e)){n=a[14900+((e*23|0)>>>5&7)>>0]|0;j=a[14643+(i+1)>>0]|0;f=j&255;if(f>>>0<e>>>0){i=0;while(1){k=f|i<<n;i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=vi(b)|0;j=a[14643+(i+1)>>0]|0;f=j&255;if(!(k>>>0<134217728&f>>>0<e>>>0))break;else i=k}f=0}else{f=0;k=0}l=hk(-1,-1,n|0)|0;m=D;if((j&255)>>>0>=e>>>0|(f>>>0>m>>>0|(f|0)==(m|0)&k>>>0>l>>>0)){j=f;n=72;break}else i=f;while(1){k=fk(k|0,i|0,n|0)|0;f=D;k=j&255|k;i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=vi(b)|0;j=a[14643+(i+1)>>0]|0;if((j&255)>>>0>=e>>>0|(f>>>0>m>>>0|(f|0)==(m|0)&k>>>0>l>>>0)){j=f;n=72;break c}else i=f}}j=a[14643+(i+1)>>0]|0;f=j&255;if(f>>>0<e>>>0){i=0;while(1){k=f+($(i,e)|0)|0;i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=vi(b)|0;j=a[14643+(i+1)>>0]|0;f=j&255;if(!(k>>>0<119304647&f>>>0<e>>>0))break;else i=k}f=0}else{k=0;f=0}if((j&255)>>>0<e>>>0){n=pk(-1,-1,e|0,0)|0;o=D;m=f;while(1){if(m>>>0>o>>>0|(m|0)==(o|0)&k>>>0>n>>>0){j=m;n=72;break c}f=ok(k|0,m|0,e|0,0)|0;l=D;j=j&255;if(l>>>0>4294967295|(l|0)==-1&f>>>0>~j>>>0){j=m;n=72;break c}k=gk(j|0,0,f|0,l|0)|0;f=D;i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=vi(b)|0;j=a[14643+(i+1)>>0]|0;if((j&255)>>>0>=e>>>0){j=f;n=72;break}else m=f}}else{j=f;n=72}}while(0);if((n|0)==72)if((d[14643+(i+1)>>0]|0)>>>0<e>>>0){do{i=c[r>>2]|0;if(i>>>0<(c[q>>2]|0)>>>0){c[r>>2]=i+1;i=d[i>>0]|0}else i=vi(b)|0}while((d[14643+(i+1)>>0]|0)>>>0<e>>>0);c[(qi()|0)>>2]=34;j=h;i=g;e=(g&1|0)==0&0==0?p:0}else{i=k;e=p}if(c[q>>2]|0)c[r>>2]=(c[r>>2]|0)+-1;if(!(j>>>0<h>>>0|(j|0)==(h|0)&i>>>0<g>>>0)){if(!((g&1|0)!=0|0!=0|(e|0)!=0)){c[(qi()|0)>>2]=34;g=gk(g|0,h|0,-1,-1)|0;h=D;break}if(j>>>0>h>>>0|(j|0)==(h|0)&i>>>0>g>>>0){c[(qi()|0)>>2]=34;break}}g=((e|0)<0)<<31>>31;g=dk(i^e|0,j^g|0,e|0,g|0)|0;h=D}while(0);D=h;return g|0}function ui(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;c[a+104>>2]=b;d=c[a+4>>2]|0;e=c[a+8>>2]|0;f=e-d|0;c[a+108>>2]=f;if((b|0)!=0&(f|0)>(b|0))c[a+100>>2]=d+b;else c[a+100>>2]=e;return}function vi(b){b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0;f=b+104|0;i=c[f>>2]|0;if((i|0)!=0?(c[b+108>>2]|0)>=(i|0):0)j=4;else{e=Vi(b)|0;if((e|0)>=0){h=c[f>>2]|0;f=b+8|0;if(h){g=c[f>>2]|0;i=c[b+4>>2]|0;f=g;h=h-(c[b+108>>2]|0)+-1|0;if((f-i|0)>(h|0))c[b+100>>2]=i+h;else j=9}else{g=c[f>>2]|0;f=g;j=9}if((j|0)==9)c[b+100>>2]=f;f=c[b+4>>2]|0;if(g){b=b+108|0;c[b>>2]=g+1-f+(c[b>>2]|0)}f=f+-1|0;if((d[f>>0]|0|0)!=(e|0))a[f>>0]=e}else j=4}if((j|0)==4){c[b+100>>2]=0;e=-1}return e|0}function wi(a){a=a|0;if(a>>>0>4294963200){c[(qi()|0)>>2]=0-a;a=-1}return a|0}function xi(a,b){a=+a;b=+b;var d=0,e=0;h[k>>3]=a;e=c[k>>2]|0;d=c[k+4>>2]|0;h[k>>3]=b;d=c[k+4>>2]&-2147483648|d&2147483647;c[k>>2]=e;c[k+4>>2]=d;return +(+h[k>>3])}function yi(a,b){a=+a;b=+b;return +(+xi(a,b))}function zi(a,b){a=+a;b=+b;var d=0,e=0,f=0,g=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0;h[k>>3]=a;d=c[k>>2]|0;m=c[k+4>>2]|0;h[k>>3]=b;n=c[k>>2]|0;o=c[k+4>>2]|0;e=hk(d|0,m|0,52)|0;e=e&2047;j=hk(n|0,o|0,52)|0;j=j&2047;p=m&-2147483648;i=fk(n|0,o|0,1)|0;l=D;a:do if(!((i|0)==0&(l|0)==0)?(g=o&2147483647,!(g>>>0>2146435072|(g|0)==2146435072&n>>>0>0|(e|0)==2047)):0){f=fk(d|0,m|0,1)|0;g=D;if(!(g>>>0>l>>>0|(g|0)==(l|0)&f>>>0>i>>>0))return +((f|0)==(i|0)&(g|0)==(l|0)?a*0.0:a);if(!e){e=fk(d|0,m|0,12)|0;f=D;if((f|0)>-1|(f|0)==-1&e>>>0>4294967295){g=e;e=0;do{e=e+-1|0;g=fk(g|0,f|0,1)|0;f=D}while((f|0)>-1|(f|0)==-1&g>>>0>4294967295)}else e=0;d=fk(d|0,m|0,1-e|0)|0;f=D}else f=m&1048575|1048576;if(!j){g=fk(n|0,o|0,12)|0;i=D;if((i|0)>-1|(i|0)==-1&g>>>0>4294967295){j=0;do{j=j+-1|0;g=fk(g|0,i|0,1)|0;i=D}while((i|0)>-1|(i|0)==-1&g>>>0>4294967295)}else j=0;n=fk(n|0,o|0,1-j|0)|0;m=D}else m=o&1048575|1048576;l=dk(d|0,f|0,n|0,m|0)|0;i=D;g=(i|0)>-1|(i|0)==-1&l>>>0>4294967295;b:do if((e|0)>(j|0)){while(1){if(g)if((d|0)==(n|0)&(f|0)==(m|0))break;else{d=l;f=i}d=fk(d|0,f|0,1)|0;f=D;e=e+-1|0;l=dk(d|0,f|0,n|0,m|0)|0;i=D;g=(i|0)>-1|(i|0)==-1&l>>>0>4294967295;if((e|0)<=(j|0))break b}b=a*0.0;break a}while(0);if(g)if((d|0)==(n|0)&(f|0)==(m|0)){b=a*0.0;break}else{f=i;d=l}if(f>>>0<1048576|(f|0)==1048576&d>>>0<0)do{d=fk(d|0,f|0,1)|0;f=D;e=e+-1|0}while(f>>>0<1048576|(f|0)==1048576&d>>>0<0);if((e|0)>0){o=gk(d|0,f|0,0,-1048576)|0;d=D;e=fk(e|0,0,52)|0;d=d|D;e=o|e}else{e=hk(d|0,f|0,1-e|0)|0;d=D}c[k>>2]=e;c[k+4>>2]=d|p;b=+h[k>>3]}else q=3;while(0);if((q|0)==3){b=a*b;b=b/b}return +b}function Ai(a,b){a=+a;b=+b;return +(+zi(a,b))}function Bi(a,b){a=+a;b=b|0;var d=0,e=0,f=0;h[k>>3]=a;d=c[k>>2]|0;e=c[k+4>>2]|0;f=hk(d|0,e|0,52)|0;f=f&2047;switch(f|0){case 0:{if(a!=0.0){a=+Bi(a*18446744073709551616.0,b);d=(c[b>>2]|0)+-64|0}else d=0;c[b>>2]=d;break}case 2047:break;default:{c[b>>2]=f+-1022;c[k>>2]=d;c[k+4>>2]=e&-2146435073|1071644672;a=+h[k>>3]}}return +a}function Ci(a,b){a=+a;b=b|0;return +(+Bi(a,b))}function Di(a,b){a=+a;b=b|0;var d=0;if((b|0)>1023){a=a*8988465674311579538646525.0e283;d=b+-1023|0;if((d|0)>1023){d=b+-2046|0;d=(d|0)>1023?1023:d;a=a*8988465674311579538646525.0e283}}else if((b|0)<-1022){a=a*2.2250738585072014e-308;d=b+1022|0;if((d|0)<-1022){d=b+2044|0;d=(d|0)<-1022?-1022:d;a=a*2.2250738585072014e-308}}else d=b;d=fk(d+1023|0,0,52)|0;b=D;c[k>>2]=d;c[k+4>>2]=b;return +(a*+h[k>>3])}function Ei(a,b){a=+a;b=b|0;return +(+Di(a,b))}function Fi(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0;l=i;i=i+16|0;g=l;j=(f|0)==0?2680:f;f=c[j>>2]|0;a:do if(!d)if(!f)f=0;else k=15;else{h=(b|0)==0?g:b;if(!e)f=-2;else{if(!f){f=a[d>>0]|0;g=f&255;if(f<<24>>24>-1){c[h>>2]=g;f=f<<24>>24!=0&1;break}f=g+-194|0;if(f>>>0>50){k=15;break}f=c[2432+(f<<2)>>2]|0;g=e+-1|0;if(g){d=d+1|0;k=9}}else{g=e;k=9}b:do if((k|0)==9){b=a[d>>0]|0;m=(b&255)>>>3;if((m+-16|m+(f>>26))>>>0>7){k=15;break a}while(1){d=d+1|0;f=(b&255)+-128|f<<6;g=g+-1|0;if((f|0)>=0)break;if(!g)break b;b=a[d>>0]|0;if((b&-64)<<24>>24!=-128){k=15;break a}}c[j>>2]=0;c[h>>2]=f;f=e-g|0;break a}while(0);c[j>>2]=f;f=-2}}while(0);if((k|0)==15){c[j>>2]=0;c[(qi()|0)>>2]=84;f=-1}i=l;return f|0}function Gi(a){a=a|0;if(!a)a=1;else a=(c[a>>2]|0)==0;return a&1|0}function Hi(b,d,e){b=b|0;d=d|0;e=e|0;do if(b){if(d>>>0<128){a[b>>0]=d;b=1;break}if(d>>>0<2048){a[b>>0]=d>>>6|192;a[b+1>>0]=d&63|128;b=2;break}if(d>>>0<55296|(d&-8192|0)==57344){a[b>>0]=d>>>12|224;a[b+1>>0]=d>>>6&63|128;a[b+2>>0]=d&63|128;b=3;break}if((d+-65536|0)>>>0<1048576){a[b>>0]=d>>>18|240;a[b+1>>0]=d>>>12&63|128;a[b+2>>0]=d>>>6&63|128;a[b+3>>0]=d&63|128;b=4;break}else{c[(qi()|0)>>2]=84;b=-1;break}}else b=1;while(0);return b|0}function Ii(a,b){a=a|0;b=b|0;if(!a)a=0;else a=Hi(a,b,0)|0;return a|0}function Ji(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0;o=i;i=i+112|0;n=o+40|0;l=o+24|0;k=o+16|0;g=o;m=o+52|0;f=a[d>>0]|0;if(sj(14909,f<<24>>24,4)|0){e=Uj(1144)|0;if(!e)e=0;else{h=e;j=h+112|0;do{c[h>>2]=0;h=h+4|0}while((h|0)<(j|0));if(!(wj(d,43)|0))c[e>>2]=f<<24>>24==114?8:4;if(wj(d,101)|0){c[g>>2]=b;c[g+4>>2]=2;c[g+8>>2]=1;va(221,g|0)|0;f=a[d>>0]|0}if(f<<24>>24==97){c[k>>2]=b;c[k+4>>2]=3;f=va(221,k|0)|0;if(!(f&1024)){c[l>>2]=b;c[l+4>>2]=4;c[l+8>>2]=f|1024;va(221,l|0)|0}d=c[e>>2]|128;c[e>>2]=d}else d=c[e>>2]|0;c[e+60>>2]=b;c[e+44>>2]=e+120;c[e+48>>2]=1024;f=e+75|0;a[f>>0]=-1;if((d&8|0)==0?(c[n>>2]=b,c[n+4>>2]=21505,c[n+8>>2]=m,(mb(54,n|0)|0)==0):0)a[f>>0]=10;c[e+32>>2]=14;c[e+36>>2]=4;c[e+40>>2]=5;c[e+12>>2]=2;if(!(c[598]|0))c[e+76>>2]=-1;yb(2416);f=c[603]|0;c[e+56>>2]=f;if(f)c[f+52>>2]=e;c[603]=e;nb(2416)}}else{c[(qi()|0)>>2]=22;e=0}i=o;return e|0}function Ki(b){b=b|0;var c=0,d=0,e=0;d=(wj(b,43)|0)==0;c=a[b>>0]|0;d=d?c<<24>>24!=114&1:2;e=(wj(b,120)|0)==0;d=e?d:d|128;b=(wj(b,101)|0)==0;b=b?d:d|524288;b=c<<24>>24==114?b:b|64;b=c<<24>>24==119?b|512:b;return (c<<24>>24==97?b|1024:b)|0}function Li(a){a=a|0;return 0}function Mi(a){a=a|0;return}function Ni(a){a=a|0;var b=0,d=0;b=i;i=i+16|0;d=b;c[d>>2]=c[a+60>>2];a=wi(zb(6,d|0)|0)|0;i=b;return a|0}function Oi(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;m=i;i=i+48|0;h=m+16|0;g=m;f=m+32|0;c[f>>2]=d;j=f+4|0;l=b+48|0;n=c[l>>2]|0;c[j>>2]=e-((n|0)!=0&1);k=b+44|0;c[f+8>>2]=c[k>>2];c[f+12>>2]=n;if(!(c[597]|0)){c[h>>2]=c[b+60>>2];c[h+4>>2]=f;c[h+8>>2]=2;f=wi(Nb(145,h|0)|0)|0}else{Fa(13,b|0);c[g>>2]=c[b+60>>2];c[g+4>>2]=f;c[g+8>>2]=2;f=wi(Nb(145,g|0)|0)|0;pb(0)}if((f|0)>=1){j=c[j>>2]|0;if(f>>>0>j>>>0){h=c[k>>2]|0;g=b+4|0;c[g>>2]=h;c[b+8>>2]=h+(f-j);if(!(c[l>>2]|0))f=e;else{c[g>>2]=h+1;a[d+(e+-1)>>0]=a[h>>0]|0;f=e}}}else{c[b>>2]=c[b>>2]|f&48^16;c[b+8>>2]=0;c[b+4>>2]=0}i=m;return f|0}function Pi(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;f=i;i=i+32|0;g=f;e=f+20|0;c[g>>2]=c[a+60>>2];c[g+4>>2]=0;c[g+8>>2]=b;c[g+12>>2]=e;c[g+16>>2]=d;if((wi(Ib(140,g|0)|0)|0)<0){c[e>>2]=-1;a=-1}else a=c[e>>2]|0;i=f;return a|0}function Qi(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;q=i;i=i+48|0;n=q+16|0;m=q;e=q+32|0;o=a+28|0;f=c[o>>2]|0;c[e>>2]=f;p=a+20|0;f=(c[p>>2]|0)-f|0;c[e+4>>2]=f;c[e+8>>2]=b;c[e+12>>2]=d;k=a+60|0;l=a+44|0;b=2;f=f+d|0;while(1){if(!(c[597]|0)){c[n>>2]=c[k>>2];c[n+4>>2]=e;c[n+8>>2]=b;h=wi(Ob(146,n|0)|0)|0}else{Fa(14,a|0);c[m>>2]=c[k>>2];c[m+4>>2]=e;c[m+8>>2]=b;h=wi(Ob(146,m|0)|0)|0;pb(0)}if((f|0)==(h|0)){f=6;break}if((h|0)<0){f=8;break}f=f-h|0;g=c[e+4>>2]|0;if(h>>>0<=g>>>0)if((b|0)==2){c[o>>2]=(c[o>>2]|0)+h;j=g;b=2}else j=g;else{j=c[l>>2]|0;c[o>>2]=j;c[p>>2]=j;j=c[e+12>>2]|0;h=h-g|0;e=e+8|0;b=b+-1|0}c[e>>2]=(c[e>>2]|0)+h;c[e+4>>2]=j-h}if((f|0)==6){n=c[l>>2]|0;c[a+16>>2]=n+(c[a+48>>2]|0);a=n;c[o>>2]=a;c[p>>2]=a}else if((f|0)==8){c[a+16>>2]=0;c[o>>2]=0;c[p>>2]=0;c[a>>2]=c[a>>2]|32;if((b|0)==2)d=0;else d=d-(c[e+4>>2]|0)|0}i=q;return d|0}function Ri(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;g=i;i=i+80|0;f=g;c[b+36>>2]=4;if((c[b>>2]&64|0)==0?(c[f>>2]=c[b+60>>2],c[f+4>>2]=21505,c[f+8>>2]=g+12,(mb(54,f|0)|0)!=0):0)a[b+75>>0]=-1;f=Qi(b,d,e)|0;i=g;return f|0}function Si(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=a+84|0;g=c[e>>2]|0;h=d+256|0;f=sj(g,0,h)|0;f=(f|0)==0?h:f-g|0;d=f>>>0<d>>>0?f:d;ik(b|0,g|0,d|0)|0;c[a+4>>2]=g+d;b=g+f|0;c[a+8>>2]=b;c[e>>2]=b;return d|0}function Ti(b){b=b|0;var d=0,e=0;d=b+74|0;e=a[d>>0]|0;a[d>>0]=e+255|e;d=b+20|0;e=b+44|0;if((c[d>>2]|0)>>>0>(c[e>>2]|0)>>>0)Qb[c[b+36>>2]&15](b,0,0)|0;c[b+16>>2]=0;c[b+28>>2]=0;c[d>>2]=0;d=c[b>>2]|0;if(d&20)if(!(d&4))d=-1;else{c[b>>2]=d|32;d=-1}else{d=c[e>>2]|0;c[b+8>>2]=d;c[b+4>>2]=d;d=0}return d|0}function Ui(b){b=b|0;var d=0,e=0;d=b+74|0;e=a[d>>0]|0;a[d>>0]=e+255|e;d=c[b>>2]|0;if(!(d&8)){c[b+8>>2]=0;c[b+4>>2]=0;d=c[b+44>>2]|0;c[b+28>>2]=d;c[b+20>>2]=d;c[b+16>>2]=d+(c[b+48>>2]|0);d=0}else{c[b>>2]=d|32;d=-1}return d|0}function Vi(a){a=a|0;var b=0,e=0;e=i;i=i+16|0;b=e;if((c[a+8>>2]|0)==0?(Ti(a)|0)!=0:0)b=-1;else if((Qb[c[a+32>>2]&15](a,b,1)|0)==1)b=d[b>>0]|0;else b=-1;i=e;return b|0}function Wi(a){a=a|0;var b=0,d=0,e=0;e=(c[a>>2]&1|0)!=0;if(!e){yb(2416);d=c[a+52>>2]|0;b=a+56|0;if(d)c[d+56>>2]=c[b>>2];b=c[b>>2]|0;if(b)c[b+52>>2]=d;if((c[603]|0)==(a|0))c[603]=b;nb(2416)}b=Yi(a)|0;b=Yb[c[a+12>>2]&31](a)|0|b;d=c[a+92>>2]|0;if(d)Vj(d);if(!e)Vj(a);return b|0}function Xi(a){a=a|0;var b=0;if((c[a+76>>2]|0)>-1){b=(Li(a)|0)==0;a=(c[a>>2]|0)>>>5&1}else a=(c[a>>2]|0)>>>5&1;return a|0}function Yi(a){a=a|0;var b=0,d=0;do if(a){if((c[a+76>>2]|0)<=-1){b=Kj(a)|0;break}d=(Li(a)|0)==0;b=Kj(a)|0;if(!d)Mi(a)}else{if(!(c[660]|0))b=0;else b=Yi(c[660]|0)|0;yb(2416);a=c[603]|0;if(a)do{if((c[a+76>>2]|0)>-1)d=Li(a)|0;else d=0;if((c[a+20>>2]|0)>>>0>(c[a+28>>2]|0)>>>0)b=Kj(a)|0|b;if(d)Mi(a);a=c[a+56>>2]|0}while((a|0)!=0);nb(2416)}while(0);return b|0}function Zi(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;if((c[f+76>>2]|0)>-1)o=Li(f)|0;else o=0;g=e+-1|0;if((e|0)<2){p=f+74|0;n=a[p>>0]|0;a[p>>0]=n+255|n;if(o)Mi(f);if(!g)a[b>>0]=0;else b=0}else{a:do if(g){m=f+4|0;n=f+8|0;h=b;while(1){i=c[m>>2]|0;q=i;k=(c[n>>2]|0)-q|0;j=sj(i,10,k)|0;r=(j|0)==0;j=r?k:1-q+j|0;q=j>>>0<g>>>0;j=q?j:g;ik(h|0,i|0,j|0)|0;i=c[m>>2]|0;k=i+j|0;c[m>>2]=k;e=h+j|0;l=g-j|0;if(!(r&q)){p=18;break a}if(k>>>0<(c[n>>2]|0)>>>0){j=j+1|0;c[m>>2]=i+j;i=d[k>>0]|0}else{g=Vi(f)|0;if((g|0)<0)break;j=j+1|0;i=g}g=l+-1|0;h=h+j|0;a[e>>0]=i;if(!((g|0)!=0&(i&255|0)!=10)){e=h;p=18;break a}}if((e|0)!=(b|0)?(c[f>>2]&16|0)!=0:0)p=18;else b=0}else{e=b;p=18}while(0);if((p|0)==18)if(!b)b=0;else a[e>>0]=0;if(o)Mi(f)}return b|0}function _i(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=i;i=i+32|0;f=g+16|0;e=g;if(sj(14909,a[d>>0]|0,4)|0){h=Ki(d)|0|32768;c[e>>2]=b;c[e+4>>2]=h;c[e+8>>2]=438;e=wi(Ab(5,e|0)|0)|0;if((e|0)>=0){b=Ji(e,d)|0;if(!b){c[f>>2]=e;zb(6,f|0)|0;b=0}}else b=0}else{c[(qi()|0)>>2]=22;b=0}i=g;return b|0}function $i(a,b){a=a|0;b=b|0;return (ij(a,Bj(a)|0,1,b)|0)+-1|0}function aj(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0;j=$(e,d)|0;if((c[f+76>>2]|0)>-1)k=Li(f)|0;else k=0;g=f+74|0;h=a[g>>0]|0;a[g>>0]=h+255|h;g=f+4|0;h=c[g>>2]|0;i=(c[f+8>>2]|0)-h|0;if((i|0)>0){i=i>>>0<j>>>0?i:j;ik(b|0,h|0,i|0)|0;c[g>>2]=h+i;b=b+i|0;g=j-i|0}else g=j;a:do if(!g)l=13;else{i=f+32|0;h=g;while(1){if(Ti(f)|0){e=h;break}g=Qb[c[i>>2]&15](f,b,h)|0;if((g+1|0)>>>0<2){e=h;break}if((h|0)==(g|0)){l=13;break a}else{b=b+g|0;h=h-g|0}}if(k)Mi(f);e=((j-e|0)>>>0)/(d>>>0)|0}while(0);if((l|0)==13)if(k)Mi(f);return e|0}function bj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;if((d|0)==1)b=b-(c[a+8>>2]|0)+(c[a+4>>2]|0)|0;f=a+20|0;e=a+28|0;if((c[f>>2]|0)>>>0>(c[e>>2]|0)>>>0?(Qb[c[a+36>>2]&15](a,0,0)|0,(c[f>>2]|0)==0):0)b=-1;else{c[a+16>>2]=0;c[e>>2]=0;c[f>>2]=0;if((Qb[c[a+40>>2]&15](a,b,d)|0)<0)b=-1;else{c[a+8>>2]=0;c[a+4>>2]=0;c[a>>2]=c[a>>2]&-17;b=0}}return b|0}function cj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;if((c[a+76>>2]|0)>-1){e=(Li(a)|0)==0;b=bj(a,b,d)|0;if(!e)Mi(a)}else b=bj(a,b,d)|0;return b|0}function dj(a,b,c){a=a|0;b=b|0;c=c|0;return cj(a,b,c)|0}function ej(a){a=a|0;var b=0;if(!(c[a>>2]&128))b=1;else b=(c[a+20>>2]|0)>>>0>(c[a+28>>2]|0)>>>0?2:1;b=Qb[c[a+40>>2]&15](a,0,b)|0;if((b|0)>=0)b=b-(c[a+8>>2]|0)+(c[a+4>>2]|0)+(c[a+20>>2]|0)-(c[a+28>>2]|0)|0;return b|0}function fj(a){a=a|0;var b=0;if((c[a+76>>2]|0)>-1){b=(Li(a)|0)==0;a=ej(a)|0}else a=ej(a)|0;return a|0}function gj(a){a=a|0;return fj(a)|0}function hj(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=e+16|0;g=c[f>>2]|0;if(!g)if(!(Ui(e)|0)){g=c[f>>2]|0;h=4}else f=0;else h=4;a:do if((h|0)==4){i=e+20|0;h=c[i>>2]|0;if((g-h|0)>>>0<d>>>0){f=Qb[c[e+36>>2]&15](e,b,d)|0;break}b:do if((a[e+75>>0]|0)>-1){f=d;while(1){if(!f){g=h;f=0;break b}g=f+-1|0;if((a[b+g>>0]|0)==10)break;else f=g}if((Qb[c[e+36>>2]&15](e,b,f)|0)>>>0<f>>>0)break a;d=d-f|0;b=b+f|0;g=c[i>>2]|0}else{g=h;f=0}while(0);ik(g|0,b|0,d|0)|0;c[i>>2]=(c[i>>2]|0)+d;f=f+d|0}while(0);return f|0}function ij(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=$(d,b)|0;if((c[e+76>>2]|0)>-1){g=(Li(e)|0)==0;a=hj(a,f,e)|0;if(!g)Mi(e)}else a=hj(a,f,e)|0;if((a|0)!=(f|0))d=(a>>>0)/(b>>>0)|0;return d|0}function jj(a){a=a|0;var b=0;if((c[a+76>>2]|0)>-1){b=(Li(a)|0)==0;bj(a,0,0)|0;c[a>>2]=c[a>>2]&-33;if(!b)Mi(a)}else{bj(a,0,0)|0;c[a>>2]=c[a>>2]&-33}return}function kj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=i;i=i+16|0;f=e;c[f>>2]=d;d=pj(a,b,f)|0;i=e;return d|0}function lj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;j=i;i=i+16|0;e=j;f=Uj(240)|0;do if(f){c[e>>2]=c[d>>2];e=oj(f,240,b,e)|0;if(e>>>0<240){b=Xj(f,e+1|0)|0;c[a>>2]=(b|0)!=0?b:f;break}Vj(f);if((e|0)>=0?(h=e+1|0,g=Uj(h)|0,c[a>>2]=g,(g|0)!=0):0)e=oj(g,h,b,d)|0;else e=-1}else e=-1;while(0);i=j;return e|0}function mj(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=i;i=i+224|0;o=s+80|0;r=s+96|0;q=s;p=s+136|0;f=r;g=f+40|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(g|0));c[o>>2]=c[e>>2];if((Lj(0,d,o,q,r)|0)<0)e=-1;else{if((c[b+76>>2]|0)>-1)m=Li(b)|0;else m=0;e=c[b>>2]|0;n=e&32;if((a[b+74>>0]|0)<1)c[b>>2]=e&-33;e=b+48|0;if(!(c[e>>2]|0)){g=b+44|0;h=c[g>>2]|0;c[g>>2]=p;j=b+28|0;c[j>>2]=p;k=b+20|0;c[k>>2]=p;c[e>>2]=80;l=b+16|0;c[l>>2]=p+80;f=Lj(b,d,o,q,r)|0;if(h){Qb[c[b+36>>2]&15](b,0,0)|0;f=(c[k>>2]|0)==0?-1:f;c[g>>2]=h;c[e>>2]=0;c[l>>2]=0;c[j>>2]=0;c[k>>2]=0}}else f=Lj(b,d,o,q,r)|0;e=c[b>>2]|0;c[b>>2]=e|n;if(m)Mi(b);e=(e&32|0)==0?f:-1}i=s;return e|0}function nj(e,f,j){e=e|0;f=f|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0;P=i;i=i+304|0;H=P+16|0;J=P+8|0;I=P+33|0;K=P;y=P+32|0;if((c[e+76>>2]|0)>-1)O=Li(e)|0;else O=0;k=a[f>>0]|0;a:do if(k<<24>>24){L=e+4|0;M=e+100|0;G=e+108|0;z=e+8|0;A=I+10|0;B=I+33|0;C=J+4|0;E=I+46|0;F=I+94|0;m=k;k=0;n=f;s=0;l=0;f=0;b:while(1){c:do if(!(pi(m&255)|0)){m=(a[n>>0]|0)==37;d:do if(m){q=n+1|0;o=a[q>>0]|0;e:do switch(o<<24>>24){case 37:break d;case 42:{x=0;o=n+2|0;break}default:{o=(o&255)+-48|0;if(o>>>0<10?(a[n+2>>0]|0)==36:0){c[H>>2]=c[j>>2];while(1){x=(c[H>>2]|0)+(4-1)&~(4-1);m=c[x>>2]|0;c[H>>2]=x+4;if(o>>>0>1)o=o+-1|0;else break}x=m;o=n+3|0;break e}o=(c[j>>2]|0)+(4-1)&~(4-1);x=c[o>>2]|0;c[j>>2]=o+4;o=q}}while(0);m=a[o>>0]|0;n=m&255;if((n+-48|0)>>>0<10){m=0;while(1){q=(m*10|0)+-48+n|0;o=o+1|0;m=a[o>>0]|0;n=m&255;if((n+-48|0)>>>0>=10)break;else m=q}}else q=0;if(m<<24>>24==109){o=o+1|0;r=a[o>>0]|0;m=(x|0)!=0&1;l=0;f=0}else{r=m;m=0}n=o+1|0;switch(r&255|0){case 104:{w=(a[n>>0]|0)==104;n=w?o+2|0:n;o=w?-2:-1;break}case 108:{w=(a[n>>0]|0)==108;n=w?o+2|0:n;o=w?3:1;break}case 106:{o=3;break}case 116:case 122:{o=1;break}case 76:{o=2;break}case 110:case 112:case 67:case 83:case 91:case 99:case 115:case 88:case 71:case 70:case 69:case 65:case 103:case 102:case 101:case 97:case 120:case 117:case 111:case 105:case 100:{n=o;o=0;break}default:{N=152;break b}}r=d[n>>0]|0;t=(r&47|0)==3;r=t?r|32:r;t=t?1:o;switch(r|0){case 99:{w=s;v=(q|0)<1?1:q;break}case 91:{w=s;v=q;break}case 110:{if(!x){o=s;break c}switch(t|0){case -2:{a[x>>0]=s;o=s;break c}case -1:{b[x>>1]=s;o=s;break c}case 0:{c[x>>2]=s;o=s;break c}case 1:{c[x>>2]=s;o=s;break c}case 3:{o=x;c[o>>2]=s;c[o+4>>2]=((s|0)<0)<<31>>31;o=s;break c}default:{o=s;break c}}}default:{ui(e,0);do{o=c[L>>2]|0;if(o>>>0<(c[M>>2]|0)>>>0){c[L>>2]=o+1;o=d[o>>0]|0}else o=vi(e)|0}while((pi(o)|0)!=0);o=c[L>>2]|0;if(c[M>>2]|0){o=o+-1|0;c[L>>2]=o}w=(c[G>>2]|0)+s+o-(c[z>>2]|0)|0;v=q}}ui(e,v);o=c[L>>2]|0;q=c[M>>2]|0;if(o>>>0<q>>>0)c[L>>2]=o+1;else{if((vi(e)|0)<0){N=152;break b}q=c[M>>2]|0}if(q)c[L>>2]=(c[L>>2]|0)+-1;f:do switch(r|0){case 91:case 99:case 115:{u=(r|0)==99;g:do if((r&239|0)==99){ek(I|0,-1,257)|0;a[I>>0]=0;if((r|0)==115){a[B>>0]=0;a[A>>0]=0;a[A+1>>0]=0;a[A+2>>0]=0;a[A+3>>0]=0;a[A+4>>0]=0}}else{Q=n+1|0;s=(a[Q>>0]|0)==94;o=s&1;r=s?Q:n;n=s?n+2|0:Q;ek(I|0,s&1|0,257)|0;a[I>>0]=0;switch(a[n>>0]|0){case 45:{s=(o^1)&255;a[E>>0]=s;n=r+2|0;break}case 93:{s=(o^1)&255;a[F>>0]=s;n=r+2|0;break}default:s=(o^1)&255}while(1){o=a[n>>0]|0;h:do switch(o<<24>>24){case 0:{N=152;break b}case 93:break g;case 45:{r=n+1|0;o=a[r>>0]|0;switch(o<<24>>24){case 93:case 0:{o=45;break h}default:{}}n=a[n+-1>>0]|0;if((n&255)<(o&255)){n=n&255;do{n=n+1|0;a[I+n>>0]=s;o=a[r>>0]|0}while((n|0)<(o&255|0));n=r}else n=r;break}default:{}}while(0);a[I+((o&255)+1)>>0]=s;n=n+1|0}}while(0);r=u?v+1|0:31;s=(t|0)==1;t=(m|0)!=0;i:do if(s){if(t){f=Uj(r<<2)|0;if(!f){l=0;N=152;break b}}else f=x;c[J>>2]=0;c[C>>2]=0;l=0;j:while(1){q=(f|0)==0;do{k:while(1){o=c[L>>2]|0;if(o>>>0<(c[M>>2]|0)>>>0){c[L>>2]=o+1;o=d[o>>0]|0}else o=vi(e)|0;if(!(a[I+(o+1)>>0]|0))break j;a[y>>0]=o;switch(Fi(K,y,1,J)|0){case -1:{l=0;N=152;break b}case -2:break;default:break k}}if(!q){c[f+(l<<2)>>2]=c[K>>2];l=l+1|0}}while(!(t&(l|0)==(r|0)));l=r<<1|1;o=Xj(f,l<<2)|0;if(!o){l=0;N=152;break b}Q=r;r=l;f=o;l=Q}if(!(Gi(J)|0)){l=0;N=152;break b}else{q=l;l=0}}else{if(t){l=Uj(r)|0;if(!l){l=0;f=0;N=152;break b}else o=0;while(1){do{f=c[L>>2]|0;if(f>>>0<(c[M>>2]|0)>>>0){c[L>>2]=f+1;f=d[f>>0]|0}else f=vi(e)|0;if(!(a[I+(f+1)>>0]|0)){q=o;f=0;break i}a[l+o>>0]=f;o=o+1|0}while((o|0)!=(r|0));f=r<<1|1;o=Xj(l,f)|0;if(!o){f=0;N=152;break b}else{Q=r;r=f;l=o;o=Q}}}if(!x){l=q;while(1){f=c[L>>2]|0;if(f>>>0<l>>>0){c[L>>2]=f+1;f=d[f>>0]|0}else f=vi(e)|0;if(!(a[I+(f+1)>>0]|0)){q=0;l=0;f=0;break i}l=c[M>>2]|0}}else{l=0;while(1){f=c[L>>2]|0;if(f>>>0<q>>>0){c[L>>2]=f+1;f=d[f>>0]|0}else f=vi(e)|0;if(!(a[I+(f+1)>>0]|0)){q=l;l=x;f=0;break i}a[x+l>>0]=f;q=c[M>>2]|0;l=l+1|0}}}while(0);o=c[L>>2]|0;if(c[M>>2]|0){o=o+-1|0;c[L>>2]=o}o=o-(c[z>>2]|0)+(c[G>>2]|0)|0;if(!o)break b;if(!((o|0)==(v|0)|u^1))break b;do if(t)if(s){c[x>>2]=f;break}else{c[x>>2]=l;break}while(0);if(!u){if(f)c[f+(q<<2)>>2]=0;if(!l){l=0;break f}a[l+q>>0]=0}break}case 120:case 88:case 112:{o=16;N=134;break}case 111:{o=8;N=134;break}case 117:case 100:{o=10;N=134;break}case 105:{o=0;N=134;break}case 71:case 103:case 70:case 102:case 69:case 101:case 65:case 97:{p=+si(e,t,0);if((c[G>>2]|0)==((c[z>>2]|0)-(c[L>>2]|0)|0))break b;if(x)switch(t|0){case 0:{g[x>>2]=p;break f}case 1:{h[x>>3]=p;break f}case 2:{h[x>>3]=p;break f}default:break f}break}default:{}}while(0);l:do if((N|0)==134){N=0;o=ti(e,o,0,-1,-1)|0;if((c[G>>2]|0)==((c[z>>2]|0)-(c[L>>2]|0)|0))break b;if((x|0)!=0&(r|0)==112){c[x>>2]=o;break}if(x)switch(t|0){case -2:{a[x>>0]=o;break l}case -1:{b[x>>1]=o;break l}case 0:{c[x>>2]=o;break l}case 1:{c[x>>2]=o;break l}case 3:{Q=x;c[Q>>2]=o;c[Q+4>>2]=D;break l}default:break l}}while(0);k=((x|0)!=0&1)+k|0;o=(c[G>>2]|0)+w+(c[L>>2]|0)-(c[z>>2]|0)|0;break c}while(0);n=n+(m&1)|0;ui(e,0);m=c[L>>2]|0;if(m>>>0<(c[M>>2]|0)>>>0){c[L>>2]=m+1;m=d[m>>0]|0}else m=vi(e)|0;if((m|0)!=(d[n>>0]|0)){N=21;break b}o=s+1|0}else{while(1){m=n+1|0;if(!(pi(d[m>>0]|0)|0))break;else n=m}ui(e,0);do{m=c[L>>2]|0;if(m>>>0<(c[M>>2]|0)>>>0){c[L>>2]=m+1;m=d[m>>0]|0}else m=vi(e)|0}while((pi(m)|0)!=0);m=c[L>>2]|0;if(c[M>>2]|0){m=m+-1|0;c[L>>2]=m}o=(c[G>>2]|0)+s+m-(c[z>>2]|0)|0}while(0);n=n+1|0;m=a[n>>0]|0;if(!(m<<24>>24))break a;else s=o}if((N|0)==21){if(c[M>>2]|0)c[L>>2]=(c[L>>2]|0)+-1;if((k|0)!=0|(m|0)>-1)break;else{k=0;N=153}}else if((N|0)==152)if(!k){k=m;N=153}if((N|0)==153){m=k;k=-1}if(m){Vj(l);Vj(f)}}else k=0;while(0);if(O)Mi(e);i=P;return k|0}function oj(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0;n=i;i=i+128|0;g=n+112|0;m=n;h=m;j=2684;k=h+112|0;do{c[h>>2]=c[j>>2];h=h+4|0;j=j+4|0}while((h|0)<(k|0));if((d+-1|0)>>>0>2147483646)if(!d){d=1;l=4}else{c[(qi()|0)>>2]=75;d=-1}else{g=b;l=4}if((l|0)==4){l=-2-g|0;l=d>>>0>l>>>0?l:d;c[m+48>>2]=l;b=m+20|0;c[b>>2]=g;c[m+44>>2]=g;d=g+l|0;g=m+16|0;c[g>>2]=d;c[m+28>>2]=d;d=mj(m,e,f)|0;if(l){e=c[b>>2]|0;a[e+(((e|0)==(c[g>>2]|0))<<31>>31)>>0]=0}}i=n;return d|0}function pj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=i;i=i+112|0;e=g;f=e;h=f+112|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(h|0));c[e+32>>2]=15;c[e+44>>2]=a;c[e+76>>2]=-1;c[e+84>>2]=a;h=nj(e,b,d)|0;i=g;return h|0}function qj(b){b=b|0;var c=0,d=0,e=0,f=0;while(1){c=b+1|0;if(!(pi(a[b>>0]|0)|0))break;else b=c}d=a[b>>0]|0;switch(d<<24>>24|0){case 45:{e=1;f=5;break}case 43:{e=0;f=5;break}default:e=0}if((f|0)==5){b=c;d=a[c>>0]|0}c=(d<<24>>24)+-48|0;if(c>>>0<10){d=b;b=0;do{d=d+1|0;b=(b*10|0)-c|0;c=(a[d>>0]|0)+-48|0}while(c>>>0<10)}else b=0;return ((e|0)!=0?b:0-b|0)|0}function rj(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+208|0;o=r+8|0;p=r;f=$(d,b)|0;n=p;c[n>>2]=1;c[n+4>>2]=0;if(f){j=f-d|0;c[o+4>>2]=d;c[o>>2]=d;g=d;b=d;h=2;while(1){b=b+d+g|0;c[o+(h<<2)>>2]=b;if(b>>>0<f>>>0){n=g;g=b;h=h+1|0;b=n}else break}n=0-d|0;k=a+j|0;m=p+4|0;if((j|0)>0){j=k;f=1;h=1;while(1){do if((f&3|0)==3){Nj(a,d,e,h,o);l=c[m>>2]|0;b=l<<30|(c[p>>2]|0)>>>2;c[p>>2]=b;c[m>>2]=l>>>2;h=h+2|0}else{b=h+-1|0;if((c[o+(b<<2)>>2]|0)>>>0<(j-a|0)>>>0)Nj(a,d,e,h,o);else Oj(a,d,e,p,h,0,o);if((h|0)==1){b=c[p>>2]|0;c[m>>2]=b>>>31|c[m>>2]<<1;b=b<<1;c[p>>2]=b;h=0;break}if(b>>>0>31){f=c[p>>2]|0;c[m>>2]=f;c[p>>2]=0;b=h+-33|0;g=0}else{f=c[m>>2]|0;g=c[p>>2]|0}c[m>>2]=g>>>(32-b|0)|f<<b;b=g<<b;c[p>>2]=b;h=1}while(0);f=b|1;c[p>>2]=f;b=a+d|0;if(b>>>0>=k>>>0){f=b;break}else a=b}}else{f=a;h=1}Oj(f,d,e,p,h,0,o);l=p+4|0;b=c[p>>2]|0;if(!((h|0)==1&(b|0)==1&(c[l>>2]|0)==0)){g=f;while(1){if((h|0)<2){f=b+-1|0;do if(f){if(!(f&1)){j=f;f=0;do{f=f+1|0;j=j>>>1}while((j&1|0)==0);if(!f)q=24}else q=24;if((q|0)==24){q=0;k=c[m>>2]|0;if(!k){f=64;q=30;break}if(!(k&1)){j=k;f=0}else{a=0;j=k;f=0;break}while(1){a=f+1|0;j=j>>>1;if(j&1){j=a;break}else f=a}if(!j){a=0;j=k;f=0;break}else f=f+33|0}if(f>>>0>31)q=30;else{a=f;j=c[m>>2]|0}}else{f=32;q=30}while(0);if((q|0)==30){q=0;b=c[m>>2]|0;c[p>>2]=b;c[m>>2]=0;a=f+-32|0;j=0}c[p>>2]=j<<32-a|b>>>a;c[m>>2]=j>>>a;g=g+n|0;f=f+h|0}else{a=b>>>30;k=a|c[m>>2]<<2;f=h+-2|0;c[p>>2]=(b<<1&2147483646|a<<31)^3;c[m>>2]=k>>>1;Oj(g+(0-((c[o+(f<<2)>>2]|0)+d))|0,d,e,p,h+-1|0,1,o);k=c[p>>2]|0;c[m>>2]=k>>>31|c[m>>2]<<1;c[p>>2]=k<<1|1;g=g+n|0;Oj(g,d,e,p,f,1,o)}b=c[p>>2]|0;if((f|0)==1&(b|0)==1&(c[l>>2]|0)==0)break;else h=f}}}i=r;return}function sj(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;h=d&255;f=(e|0)!=0;a:do if(f&(b&3|0)!=0){g=d&255;while(1){if((a[b>>0]|0)==g<<24>>24){i=6;break a}b=b+1|0;e=e+-1|0;f=(e|0)!=0;if(!(f&(b&3|0)!=0)){i=5;break}}}else i=5;while(0);if((i|0)==5)if(f)i=6;else e=0;b:do if((i|0)==6){g=d&255;if((a[b>>0]|0)!=g<<24>>24){f=$(h,16843009)|0;c:do if(e>>>0>3)while(1){h=c[b>>2]^f;if((h&-2139062144^-2139062144)&h+-16843009)break;b=b+4|0;e=e+-4|0;if(e>>>0<=3){i=11;break c}}else i=11;while(0);if((i|0)==11)if(!e){e=0;break}while(1){if((a[b>>0]|0)==g<<24>>24)break b;b=b+1|0;e=e+-1|0;if(!e){e=0;break}}}}while(0);return ((e|0)!=0?b:0)|0}function tj(b,c,d){b=b|0;c=c|0;d=d|0;var e=0;e=c&255;do{if(!d){c=0;break}d=d+-1|0;c=b+d|0}while((a[c>>0]|0)!=e<<24>>24);return c|0}function uj(b,d){b=b|0;d=d|0;var e=0,f=0;e=d;a:do if(!((e^b)&3)){if(e&3)do{e=a[d>>0]|0;a[b>>0]=e;if(!(e<<24>>24))break a;d=d+1|0;b=b+1|0}while((d&3|0)!=0);e=c[d>>2]|0;if(!((e&-2139062144^-2139062144)&e+-16843009)){f=b;while(1){d=d+4|0;b=f+4|0;c[f>>2]=e;e=c[d>>2]|0;if((e&-2139062144^-2139062144)&e+-16843009)break;else f=b}}f=8}else f=8;while(0);if((f|0)==8){f=a[d>>0]|0;a[b>>0]=f;if(f<<24>>24)do{d=d+1|0;b=b+1|0;f=a[d>>0]|0;a[b>>0]=f}while(f<<24>>24!=0)}return b|0}function vj(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;g=d;do if(!((g^b)&3)){f=(e|0)!=0;a:do if(f&(g&3|0)!=0)while(1){g=a[d>>0]|0;a[b>>0]=g;if(!(g<<24>>24))break a;e=e+-1|0;d=d+1|0;b=b+1|0;f=(e|0)!=0;if(!(f&(d&3|0)!=0)){h=5;break}}else h=5;while(0);if((h|0)==5)if(!f){e=0;break}if(a[d>>0]|0){b:do if(e>>>0>3)do{f=c[d>>2]|0;if((f&-2139062144^-2139062144)&f+-16843009)break b;c[b>>2]=f;e=e+-4|0;d=d+4|0;b=b+4|0}while(e>>>0>3);while(0);h=11}}else h=11;while(0);c:do if((h|0)==11)if(!e)e=0;else while(1){h=a[d>>0]|0;a[b>>0]=h;if(!(h<<24>>24))break c;e=e+-1|0;b=b+1|0;if(!e){e=0;break}else d=d+1|0}while(0);ek(b|0,0,e|0)|0;return b|0}function wj(b,c){b=b|0;c=c|0;b=xj(b,c)|0;return ((a[b>>0]|0)==(c&255)<<24>>24?b:0)|0}function xj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;f=d&255;a:do if(!f)b=b+(Bj(b)|0)|0;else{if(b&3){e=d&255;do{g=a[b>>0]|0;if(g<<24>>24==0?1:g<<24>>24==e<<24>>24)break a;b=b+1|0}while((b&3|0)!=0)}f=$(f,16843009)|0;e=c[b>>2]|0;b:do if(!((e&-2139062144^-2139062144)&e+-16843009))do{g=e^f;if((g&-2139062144^-2139062144)&g+-16843009)break b;b=b+4|0;e=c[b>>2]|0}while(((e&-2139062144^-2139062144)&e+-16843009|0)==0);while(0);e=d&255;while(1){g=a[b>>0]|0;if(g<<24>>24==0?1:g<<24>>24==e<<24>>24)break;else b=b+1|0}}while(0);return b|0}function yj(a,b){a=a|0;b=b|0;uj(a,b)|0;return a|0}function zj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=i;i=i+32|0;f=g;e=a[d>>0]|0;if(e<<24>>24!=0?(a[d+1>>0]|0)!=0:0){c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[f+20>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;do{h=f+(((e&255)>>>5&255)<<2)|0;c[h>>2]=c[h>>2]|1<<(e&31);d=d+1|0;e=a[d>>0]|0}while(e<<24>>24!=0);d=a[b>>0]|0;a:do if(!(d<<24>>24))e=b;else{e=b;do{if(c[f+(((d&255)>>>5&255)<<2)>>2]&1<<(d&31))break a;e=e+1|0;d=a[e>>0]|0}while(d<<24>>24!=0)}while(0);e=e-b|0}else e=(xj(b,e<<24>>24)|0)-b|0;i=g;return e|0}function Aj(a){a=a|0;var b=0,c=0;c=(Bj(a)|0)+1|0;b=Uj(c)|0;if(!b)b=0;else ik(b|0,a|0,c|0)|0;return b|0}function Bj(b){b=b|0;var d=0,e=0,f=0;f=b;a:do if(!(f&3))e=4;else{d=b;b=f;while(1){if(!(a[d>>0]|0))break a;d=d+1|0;b=d;if(!(b&3)){b=d;e=4;break}}}while(0);if((e|0)==4){while(1){d=c[b>>2]|0;if(!((d&-2139062144^-2139062144)&d+-16843009))b=b+4|0;else break}if((d&255)<<24>>24)do b=b+1|0;while((a[b>>0]|0)!=0)}return b-f|0}function Cj(b,c,d){b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0;e=b+(Bj(b)|0)|0;a:do if(d)while(1){f=a[c>>0]|0;if(!(f<<24>>24))break a;d=d+-1|0;g=e+1|0;a[e>>0]=f;if(!d){e=g;break}else{c=c+1|0;e=g}}while(0);a[e>>0]=0;return b|0}function Dj(a,b,c){a=a|0;b=b|0;c=c|0;vj(a,b,c)|0;return a|0}function Ej(a,b){a=a|0;b=b|0;return tj(a,b,(Bj(a)|0)+1|0)|0}function Fj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;h=i;i=i+32|0;g=h;c[g>>2]=0;c[g+4>>2]=0;c[g+8>>2]=0;c[g+12>>2]=0;c[g+16>>2]=0;c[g+20>>2]=0;c[g+24>>2]=0;c[g+28>>2]=0;f=a[d>>0]|0;do if(!(f<<24>>24))d=0;else{if(!(a[d+1>>0]|0)){d=b;while(1)if((a[d>>0]|0)==f<<24>>24)d=d+1|0;else break;d=d-b|0;break}else{e=d;d=f}do{f=g+(((d&255)>>>5&255)<<2)|0;c[f>>2]=c[f>>2]|1<<(d&31);e=e+1|0;d=a[e>>0]|0}while(d<<24>>24!=0);e=a[b>>0]|0;a:do if(!(e<<24>>24))d=b;else{d=b;do{if(!(c[g+(((e&255)>>>5&255)<<2)>>2]&1<<(e&31)))break a;d=d+1|0;e=a[d>>0]|0}while(e<<24>>24!=0)}while(0);d=d-b|0}while(0);i=h;return d|0}function Gj(b,d){b=b|0;d=d|0;var e=0,f=0;if(!b){b=c[699]|0;if(!b)b=0;else{f=b;e=3}}else{f=b;e=3}do if((e|0)==3){e=Fj(f,d)|0;b=f+e|0;if(!(a[b>>0]|0)){c[699]=0;b=0;break}e=(zj(b,d)|0)+e|0;d=f+e|0;c[699]=d;if(!(a[d>>0]|0)){c[699]=0;break}else{c[699]=f+(e+1);a[d>>0]=0;break}}while(0);return b|0}function Hj(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0;i=a+4|0;e=c[i>>2]|0;j=a+100|0;if(e>>>0<(c[j>>2]|0)>>>0){c[i>>2]=e+1;e=d[e>>0]|0}else e=vi(a)|0;switch(e|0){case 43:case 45:{f=(e|0)==45&1;e=c[i>>2]|0;if(e>>>0<(c[j>>2]|0)>>>0){c[i>>2]=e+1;e=d[e>>0]|0}else e=vi(a)|0;if((b|0)!=0&(e+-48|0)>>>0>9?(c[j>>2]|0)!=0:0){c[i>>2]=(c[i>>2]|0)+-1;h=f}else h=f;break}default:h=0}if((e+-48|0)>>>0>9)if(!(c[j>>2]|0)){f=-2147483648;e=0}else{c[i>>2]=(c[i>>2]|0)+-1;f=-2147483648;e=0}else{f=0;do{f=e+-48+(f*10|0)|0;e=c[i>>2]|0;if(e>>>0<(c[j>>2]|0)>>>0){c[i>>2]=e+1;e=d[e>>0]|0}else e=vi(a)|0}while((e+-48|0)>>>0<10&(f|0)<214748364);b=((f|0)<0)<<31>>31;if((e+-48|0)>>>0<10){do{b=ok(f|0,b|0,10,0)|0;f=D;e=gk(e|0,((e|0)<0)<<31>>31|0,-48,-1)|0;f=gk(e|0,D|0,b|0,f|0)|0;b=D;e=c[i>>2]|0;if(e>>>0<(c[j>>2]|0)>>>0){c[i>>2]=e+1;e=d[e>>0]|0}else e=vi(a)|0}while((e+-48|0)>>>0<10&((b|0)<21474836|(b|0)==21474836&f>>>0<2061584302));g=f}else g=f;if((e+-48|0)>>>0<10)do{e=c[i>>2]|0;if(e>>>0<(c[j>>2]|0)>>>0){c[i>>2]=e+1;e=d[e>>0]|0}else e=vi(a)|0}while((e+-48|0)>>>0<10);if(c[j>>2]|0)c[i>>2]=(c[i>>2]|0)+-1;a=(h|0)!=0;e=dk(0,0,g|0,b|0)|0;f=a?D:b;e=a?e:g}D=f;return e|0}function Ij(a){a=a|0;if(!(c[a+68>>2]|0))Mi(a);return}function Jj(a){a=a|0;if(!(c[a+68>>2]|0))Mi(a);return}function Kj(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=a+20|0;g=a+28|0;if((c[b>>2]|0)>>>0>(c[g>>2]|0)>>>0?(Qb[c[a+36>>2]&15](a,0,0)|0,(c[b>>2]|0)==0):0)b=-1;else{h=a+4|0;d=c[h>>2]|0;e=a+8|0;f=c[e>>2]|0;if(d>>>0<f>>>0)Qb[c[a+40>>2]&15](a,d-f|0,1)|0;c[a+16>>2]=0;c[g>>2]=0;c[b>>2]=0;c[e>>2]=0;c[h>>2]=0;b=0}return b|0}function Lj(e,f,g,j,l){e=e|0;f=f|0;g=g|0;j=j|0;l=l|0;var m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0;ha=i;i=i+624|0;ca=ha+24|0;ea=ha+16|0;da=ha+588|0;Y=ha+576|0;ba=ha;V=ha+536|0;ga=ha+8|0;fa=ha+528|0;M=(e|0)!=0;N=V+40|0;U=N;V=V+39|0;W=ga+4|0;X=Y+12|0;Y=Y+11|0;Z=da;_=X;aa=_-Z|0;O=-2-Z|0;P=_+2|0;Q=ca+288|0;R=da+9|0;S=R;T=da+8|0;m=0;w=f;n=0;f=0;a:while(1){do if((m|0)>-1)if((n|0)>(2147483647-m|0)){c[(qi()|0)>>2]=75;m=-1;break}else{m=n+m|0;break}while(0);n=a[w>>0]|0;if(!(n<<24>>24)){L=245;break}else o=w;b:while(1){switch(n<<24>>24){case 37:{n=o;L=9;break b}case 0:{n=o;break b}default:{}}K=o+1|0;n=a[K>>0]|0;o=K}c:do if((L|0)==9)while(1){L=0;if((a[n+1>>0]|0)!=37)break c;o=o+1|0;n=n+2|0;if((a[n>>0]|0)==37)L=9;else break}while(0);y=o-w|0;if(M?(c[e>>2]&32|0)==0:0)hj(w,y,e)|0;if((o|0)!=(w|0)){w=n;n=y;continue}r=n+1|0;o=a[r>>0]|0;p=(o<<24>>24)+-48|0;if(p>>>0<10){K=(a[n+2>>0]|0)==36;r=K?n+3|0:r;o=a[r>>0]|0;u=K?p:-1;f=K?1:f}else u=-1;n=o<<24>>24;d:do if((n&-32|0)==32){p=0;while(1){if(!(1<<n+-32&75913)){s=p;n=r;break d}p=1<<(o<<24>>24)+-32|p;r=r+1|0;o=a[r>>0]|0;n=o<<24>>24;if((n&-32|0)!=32){s=p;n=r;break}}}else{s=0;n=r}while(0);do if(o<<24>>24==42){p=n+1|0;o=(a[p>>0]|0)+-48|0;if(o>>>0<10?(a[n+2>>0]|0)==36:0){c[l+(o<<2)>>2]=10;f=1;n=n+3|0;o=c[j+((a[p>>0]|0)+-48<<3)>>2]|0}else{if(f){m=-1;break a}if(!M){x=s;n=p;f=0;K=0;break}f=(c[g>>2]|0)+(4-1)&~(4-1);o=c[f>>2]|0;c[g>>2]=f+4;f=0;n=p}if((o|0)<0){x=s|8192;K=0-o|0}else{x=s;K=o}}else{p=(o<<24>>24)+-48|0;if(p>>>0<10){o=0;do{o=(o*10|0)+p|0;n=n+1|0;p=(a[n>>0]|0)+-48|0}while(p>>>0<10);if((o|0)<0){m=-1;break a}else{x=s;K=o}}else{x=s;K=0}}while(0);e:do if((a[n>>0]|0)==46){p=n+1|0;o=a[p>>0]|0;if(o<<24>>24!=42){r=(o<<24>>24)+-48|0;if(r>>>0<10){n=p;o=0}else{n=p;r=0;break}while(1){o=(o*10|0)+r|0;n=n+1|0;r=(a[n>>0]|0)+-48|0;if(r>>>0>=10){r=o;break e}}}p=n+2|0;o=(a[p>>0]|0)+-48|0;if(o>>>0<10?(a[n+3>>0]|0)==36:0){c[l+(o<<2)>>2]=10;n=n+4|0;r=c[j+((a[p>>0]|0)+-48<<3)>>2]|0;break}if(f){m=-1;break a}if(M){n=(c[g>>2]|0)+(4-1)&~(4-1);r=c[n>>2]|0;c[g>>2]=n+4;n=p}else{n=p;r=0}}else r=-1;while(0);t=0;while(1){o=(a[n>>0]|0)+-65|0;if(o>>>0>57){m=-1;break a}p=n+1|0;o=a[15953+(t*58|0)+o>>0]|0;s=o&255;if((s+-1|0)>>>0<8){n=p;t=s}else{J=p;break}}if(!(o<<24>>24)){m=-1;break}p=(u|0)>-1;do if(o<<24>>24==19)if(p){m=-1;break a}else L=52;else{if(p){c[l+(u<<2)>>2]=s;H=j+(u<<3)|0;I=c[H+4>>2]|0;L=ba;c[L>>2]=c[H>>2];c[L+4>>2]=I;L=52;break}if(!M){m=0;break a}Rj(ba,s,g)}while(0);if((L|0)==52?(L=0,!M):0){w=J;n=y;continue}u=a[n>>0]|0;u=(t|0)!=0&(u&15|0)==3?u&-33:u;p=x&-65537;I=(x&8192|0)==0?x:p;f:do switch(u|0){case 110:switch(t|0){case 0:{c[c[ba>>2]>>2]=m;w=J;n=y;continue a}case 1:{c[c[ba>>2]>>2]=m;w=J;n=y;continue a}case 2:{w=c[ba>>2]|0;c[w>>2]=m;c[w+4>>2]=((m|0)<0)<<31>>31;w=J;n=y;continue a}case 3:{b[c[ba>>2]>>1]=m;w=J;n=y;continue a}case 4:{a[c[ba>>2]>>0]=m;w=J;n=y;continue a}case 6:{c[c[ba>>2]>>2]=m;w=J;n=y;continue a}case 7:{w=c[ba>>2]|0;c[w>>2]=m;c[w+4>>2]=((m|0)<0)<<31>>31;w=J;n=y;continue a}default:{w=J;n=y;continue a}}case 112:{t=I|8;r=r>>>0>8?r:8;u=120;L=64;break}case 88:case 120:{t=I;L=64;break}case 111:{p=ba;o=c[p>>2]|0;p=c[p+4>>2]|0;if((o|0)==0&(p|0)==0)n=N;else{n=N;do{n=n+-1|0;a[n>>0]=o&7|48;o=hk(o|0,p|0,3)|0;p=D}while(!((o|0)==0&(p|0)==0))}if(!(I&8)){o=I;t=0;s=16433;L=77}else{t=U-n+1|0;o=I;r=(r|0)<(t|0)?t:r;t=0;s=16433;L=77}break}case 105:case 100:{o=ba;n=c[o>>2]|0;o=c[o+4>>2]|0;if((o|0)<0){n=dk(0,0,n|0,o|0)|0;o=D;p=ba;c[p>>2]=n;c[p+4>>2]=o;p=1;s=16433;L=76;break f}if(!(I&2048)){s=I&1;p=s;s=(s|0)==0?16433:16435;L=76}else{p=1;s=16434;L=76}break}case 117:{o=ba;n=c[o>>2]|0;o=c[o+4>>2]|0;p=0;s=16433;L=76;break}case 99:{a[V>>0]=c[ba>>2];w=V;o=1;t=0;u=16433;n=N;break}case 109:{n=ri(c[(qi()|0)>>2]|0)|0;L=82;break}case 115:{n=c[ba>>2]|0;n=(n|0)!=0?n:16443;L=82;break}case 67:{c[ga>>2]=c[ba>>2];c[W>>2]=0;c[ba>>2]=ga;r=-1;L=86;break}case 83:{if(!r){Tj(e,32,K,0,I);n=0;L=98}else L=86;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{q=+h[ba>>3];c[ea>>2]=0;h[k>>3]=q;if((c[k+4>>2]|0)>=0)if(!(I&2048)){H=I&1;G=H;H=(H|0)==0?16451:16456}else{G=1;H=16453}else{q=-q;G=1;H=16450}h[k>>3]=q;F=c[k+4>>2]&2146435072;do if(F>>>0<2146435072|(F|0)==2146435072&0<0){v=+Ci(q,ea)*2.0;o=v!=0.0;if(o)c[ea>>2]=(c[ea>>2]|0)+-1;C=u|32;if((C|0)==97){w=u&32;y=(w|0)==0?H:H+9|0;x=G|2;n=12-r|0;do if(!(r>>>0>11|(n|0)==0)){q=8.0;do{n=n+-1|0;q=q*16.0}while((n|0)!=0);if((a[y>>0]|0)==45){q=-(q+(-v-q));break}else{q=v+q-q;break}}else q=v;while(0);o=c[ea>>2]|0;n=(o|0)<0?0-o|0:o;n=Sj(n,((n|0)<0)<<31>>31,X)|0;if((n|0)==(X|0)){a[Y>>0]=48;n=Y}a[n+-1>>0]=(o>>31&2)+43;t=n+-2|0;a[t>>0]=u+15;s=(r|0)<1;p=(I&8|0)==0;o=da;while(1){H=~~q;n=o+1|0;a[o>>0]=d[16417+H>>0]|w;q=(q-+(H|0))*16.0;do if((n-Z|0)==1){if(p&(s&q==0.0))break;a[n>>0]=46;n=o+2|0}while(0);if(!(q!=0.0))break;else o=n}r=(r|0)!=0&(O+n|0)<(r|0)?P+r-t|0:aa-t+n|0;p=r+x|0;Tj(e,32,K,p,I);if(!(c[e>>2]&32))hj(y,x,e)|0;Tj(e,48,K,p,I^65536);n=n-Z|0;if(!(c[e>>2]&32))hj(da,n,e)|0;o=_-t|0;Tj(e,48,r-(n+o)|0,0,0);if(!(c[e>>2]&32))hj(t,o,e)|0;Tj(e,32,K,p,I^8192);n=(p|0)<(K|0)?K:p;break}n=(r|0)<0?6:r;if(o){o=(c[ea>>2]|0)+-28|0;c[ea>>2]=o;q=v*268435456.0}else{q=v;o=c[ea>>2]|0}F=(o|0)<0?ca:Q;E=F;o=F;do{B=~~q>>>0;c[o>>2]=B;o=o+4|0;q=(q-+(B>>>0))*1.0e9}while(q!=0.0);p=o;o=c[ea>>2]|0;if((o|0)>0){s=F;while(1){t=(o|0)>29?29:o;r=p+-4|0;do if(r>>>0<s>>>0)r=s;else{o=0;do{B=fk(c[r>>2]|0,0,t|0)|0;B=gk(B|0,D|0,o|0,0)|0;o=D;A=qk(B|0,o|0,1e9,0)|0;c[r>>2]=A;o=pk(B|0,o|0,1e9,0)|0;r=r+-4|0}while(r>>>0>=s>>>0);if(!o){r=s;break}r=s+-4|0;c[r>>2]=o}while(0);while(1){if(p>>>0<=r>>>0)break;o=p+-4|0;if(!(c[o>>2]|0))p=o;else break}o=(c[ea>>2]|0)-t|0;c[ea>>2]=o;if((o|0)>0)s=r;else break}}else r=F;if((o|0)<0){y=((n+25|0)/9|0)+1|0;z=(C|0)==102;w=r;while(1){x=0-o|0;x=(x|0)>9?9:x;do if(w>>>0<p>>>0){o=(1<<x)+-1|0;s=1e9>>>x;r=0;t=w;do{B=c[t>>2]|0;c[t>>2]=(B>>>x)+r;r=$(B&o,s)|0;t=t+4|0}while(t>>>0<p>>>0);o=(c[w>>2]|0)==0?w+4|0:w;if(!r){r=o;break}c[p>>2]=r;r=o;p=p+4|0}else r=(c[w>>2]|0)==0?w+4|0:w;while(0);o=z?F:r;p=(p-o>>2|0)>(y|0)?o+(y<<2)|0:p;o=(c[ea>>2]|0)+x|0;c[ea>>2]=o;if((o|0)>=0){w=r;break}else w=r}}else w=r;do if(w>>>0<p>>>0){o=(E-w>>2)*9|0;s=c[w>>2]|0;if(s>>>0<10)break;else r=10;do{r=r*10|0;o=o+1|0}while(s>>>0>=r>>>0)}else o=0;while(0);A=(C|0)==103;B=(n|0)!=0;r=n-((C|0)!=102?o:0)+((B&A)<<31>>31)|0;if((r|0)<(((p-E>>2)*9|0)+-9|0)){t=r+9216|0;z=(t|0)/9|0;r=F+(z+-1023<<2)|0;t=((t|0)%9|0)+1|0;if((t|0)<9){s=10;do{s=s*10|0;t=t+1|0}while((t|0)!=9)}else s=10;x=c[r>>2]|0;y=(x>>>0)%(s>>>0)|0;if((y|0)==0?(F+(z+-1022<<2)|0)==(p|0):0)s=w;else L=163;do if((L|0)==163){L=0;v=(((x>>>0)/(s>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;t=(s|0)/2|0;do if(y>>>0<t>>>0)q=.5;else{if((y|0)==(t|0)?(F+(z+-1022<<2)|0)==(p|0):0){q=1.0;break}q=1.5}while(0);do if(G){if((a[H>>0]|0)!=45)break;v=-v;q=-q}while(0);t=x-y|0;c[r>>2]=t;if(!(v+q!=v)){s=w;break}C=t+s|0;c[r>>2]=C;if(C>>>0>999999999){o=w;while(1){s=r+-4|0;c[r>>2]=0;if(s>>>0<o>>>0){o=o+-4|0;c[o>>2]=0}C=(c[s>>2]|0)+1|0;c[s>>2]=C;if(C>>>0>999999999)r=s;else{w=o;r=s;break}}}o=(E-w>>2)*9|0;t=c[w>>2]|0;if(t>>>0<10){s=w;break}else s=10;do{s=s*10|0;o=o+1|0}while(t>>>0>=s>>>0);s=w}while(0);C=r+4|0;w=s;p=p>>>0>C>>>0?C:p}y=0-o|0;while(1){if(p>>>0<=w>>>0){z=0;C=p;break}r=p+-4|0;if(!(c[r>>2]|0))p=r;else{z=1;C=p;break}}do if(A){n=(B&1^1)+n|0;if((n|0)>(o|0)&(o|0)>-5){u=u+-1|0;n=n+-1-o|0}else{u=u+-2|0;n=n+-1|0}p=I&8;if(p)break;do if(z){p=c[C+-4>>2]|0;if(!p){r=9;break}if(!((p>>>0)%10|0)){s=10;r=0}else{r=0;break}do{s=s*10|0;r=r+1|0}while(((p>>>0)%(s>>>0)|0|0)==0)}else r=9;while(0);p=((C-E>>2)*9|0)+-9|0;if((u|32|0)==102){p=p-r|0;p=(p|0)<0?0:p;n=(n|0)<(p|0)?n:p;p=0;break}else{p=p+o-r|0;p=(p|0)<0?0:p;n=(n|0)<(p|0)?n:p;p=0;break}}else p=I&8;while(0);x=n|p;s=(x|0)!=0&1;t=(u|32|0)==102;if(t){o=(o|0)>0?o:0;u=0}else{r=(o|0)<0?y:o;r=Sj(r,((r|0)<0)<<31>>31,X)|0;if((_-r|0)<2)do{r=r+-1|0;a[r>>0]=48}while((_-r|0)<2);a[r+-1>>0]=(o>>31&2)+43;E=r+-2|0;a[E>>0]=u;o=_-E|0;u=E}y=G+1+n+s+o|0;Tj(e,32,K,y,I);if(!(c[e>>2]&32))hj(H,G,e)|0;Tj(e,48,K,y,I^65536);do if(t){r=w>>>0>F>>>0?F:w;o=r;do{p=Sj(c[o>>2]|0,0,R)|0;do if((o|0)==(r|0)){if((p|0)!=(R|0))break;a[T>>0]=48;p=T}else{if(p>>>0<=da>>>0)break;do{p=p+-1|0;a[p>>0]=48}while(p>>>0>da>>>0)}while(0);if(!(c[e>>2]&32))hj(p,S-p|0,e)|0;o=o+4|0}while(o>>>0<=F>>>0);do if(x){if(c[e>>2]&32)break;hj(16485,1,e)|0}while(0);if((n|0)>0&o>>>0<C>>>0){p=o;while(1){o=Sj(c[p>>2]|0,0,R)|0;if(o>>>0>da>>>0)do{o=o+-1|0;a[o>>0]=48}while(o>>>0>da>>>0);if(!(c[e>>2]&32))hj(o,(n|0)>9?9:n,e)|0;p=p+4|0;o=n+-9|0;if(!((n|0)>9&p>>>0<C>>>0)){n=o;break}else n=o}}Tj(e,48,n+9|0,9,0)}else{t=z?C:w+4|0;if((n|0)>-1){s=(p|0)==0;r=w;do{o=Sj(c[r>>2]|0,0,R)|0;if((o|0)==(R|0)){a[T>>0]=48;o=T}do if((r|0)==(w|0)){p=o+1|0;if(!(c[e>>2]&32))hj(o,1,e)|0;if(s&(n|0)<1){o=p;break}if(c[e>>2]&32){o=p;break}hj(16485,1,e)|0;o=p}else{if(o>>>0<=da>>>0)break;do{o=o+-1|0;a[o>>0]=48}while(o>>>0>da>>>0)}while(0);p=S-o|0;if(!(c[e>>2]&32))hj(o,(n|0)>(p|0)?p:n,e)|0;n=n-p|0;r=r+4|0}while(r>>>0<t>>>0&(n|0)>-1)}Tj(e,48,n+18|0,18,0);if(c[e>>2]&32)break;hj(u,_-u|0,e)|0}while(0);Tj(e,32,K,y,I^8192);n=(y|0)<(K|0)?K:y}else{t=(u&32|0)!=0;s=q!=q|0.0!=0.0;o=s?0:G;r=o+3|0;Tj(e,32,K,r,p);n=c[e>>2]|0;if(!(n&32)){hj(H,o,e)|0;n=c[e>>2]|0}if(!(n&32))hj(s?(t?16477:16481):t?16469:16473,3,e)|0;Tj(e,32,K,r,I^8192);n=(r|0)<(K|0)?K:r}while(0);w=J;continue a}default:{p=I;o=r;t=0;u=16433;n=N}}while(0);g:do if((L|0)==64){p=ba;o=c[p>>2]|0;p=c[p+4>>2]|0;s=u&32;if(!((o|0)==0&(p|0)==0)){n=N;do{n=n+-1|0;a[n>>0]=d[16417+(o&15)>>0]|s;o=hk(o|0,p|0,4)|0;p=D}while(!((o|0)==0&(p|0)==0));L=ba;if((t&8|0)==0|(c[L>>2]|0)==0&(c[L+4>>2]|0)==0){o=t;t=0;s=16433;L=77}else{o=t;t=2;s=16433+(u>>4)|0;L=77}}else{n=N;o=t;t=0;s=16433;L=77}}else if((L|0)==76){n=Sj(n,o,N)|0;o=I;t=p;L=77}else if((L|0)==82){L=0;I=sj(n,0,r)|0;H=(I|0)==0;w=n;o=H?r:I-n|0;t=0;u=16433;n=H?n+r|0:I}else if((L|0)==86){L=0;o=0;n=0;s=c[ba>>2]|0;while(1){p=c[s>>2]|0;if(!p)break;n=Ii(fa,p)|0;if((n|0)<0|n>>>0>(r-o|0)>>>0)break;o=n+o|0;if(r>>>0>o>>>0)s=s+4|0;else break}if((n|0)<0){m=-1;break a}Tj(e,32,K,o,I);if(!o){n=0;L=98}else{p=0;r=c[ba>>2]|0;while(1){n=c[r>>2]|0;if(!n){n=o;L=98;break g}n=Ii(fa,n)|0;p=n+p|0;if((p|0)>(o|0)){n=o;L=98;break g}if(!(c[e>>2]&32))hj(fa,n,e)|0;if(p>>>0>=o>>>0){n=o;L=98;break}else r=r+4|0}}}while(0);if((L|0)==98){L=0;Tj(e,32,K,n,I^8192);w=J;n=(K|0)>(n|0)?K:n;continue}if((L|0)==77){L=0;p=(r|0)>-1?o&-65537:o;o=ba;o=(c[o>>2]|0)!=0|(c[o+4>>2]|0)!=0;if((r|0)!=0|o){o=(o&1^1)+(U-n)|0;w=n;o=(r|0)>(o|0)?r:o;u=s;n=N}else{w=N;o=0;u=s;n=N}}s=n-w|0;o=(o|0)<(s|0)?s:o;r=t+o|0;n=(K|0)<(r|0)?r:K;Tj(e,32,n,r,p);if(!(c[e>>2]&32))hj(u,t,e)|0;Tj(e,48,n,r,p^65536);Tj(e,48,o,s,0);if(!(c[e>>2]&32))hj(w,s,e)|0;Tj(e,32,n,r,p^8192);w=J}h:do if((L|0)==245)if(!e)if(f){m=1;while(1){f=c[l+(m<<2)>>2]|0;if(!f)break;Rj(j+(m<<3)|0,f,g);m=m+1|0;if((m|0)>=10){m=1;break h}}if((m|0)<10)while(1){if(c[l+(m<<2)>>2]|0){m=-1;break h}m=m+1|0;if((m|0)>=10){m=1;break}}else m=1}else m=0;while(0);i=ha;return m|0}function Mj(a,b,c){a=a|0;b=b|0;c=c|0;return Si(a,b,c)|0}function Nj(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+240|0;o=p;c[o>>2]=a;a:do if((e|0)>1){n=0-b|0;g=e;h=a;k=a;l=1;while(1){a=h+n|0;m=g+-2|0;j=h+(0-((c[f+(m<<2)>>2]|0)+b))|0;if((cc[d&15](k,j)|0)>-1?(cc[d&15](k,a)|0)>-1:0){e=l;break a}e=l+1|0;h=o+(l<<2)|0;if((cc[d&15](j,a)|0)>-1){c[h>>2]=j;a=j;g=g+-1|0}else{c[h>>2]=a;g=m}if((g|0)<=1)break a;h=a;k=c[o>>2]|0;l=e}}else e=1;while(0);Pj(b,o,e);i=p;return}function Oj(a,b,d,e,f,g,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+240|0;p=r;k=c[e>>2]|0;e=c[e+4>>2]|0;c[p>>2]=a;o=0-b|0;a:do if((e|0)!=0|(k|0)!=1?(j=a+(0-(c[h+(f<<2)>>2]|0))|0,(cc[d&15](j,a)|0)>=1):0){g=(g|0)==0;n=j;l=k;m=e;j=1;while(1){if(g&(f|0)>1){e=c[h+(f+-2<<2)>>2]|0;if((cc[d&15](a+o|0,n)|0)>-1){g=f;e=j;q=20;break a}if((cc[d&15](a+(0-(e+b))|0,n)|0)>-1){g=f;e=j;q=20;break a}}e=j+1|0;c[p+(j<<2)>>2]=n;g=l+-1|0;do if(g){if(!(g&1)){a=g;g=0;do{g=g+1|0;a=a>>>1}while((a&1|0)==0);if(!g)q=11}else q=11;if((q|0)==11){q=0;if(!m){g=64;q=16;break}if(!(m&1)){a=m;g=0}else{k=0;a=l;j=m;g=0;break}while(1){j=g+1|0;a=a>>>1;if(a&1){a=j;break}else g=j}if(!a){k=0;a=l;j=m;g=0;break}else g=g+33|0}if(g>>>0>31)q=16;else{k=g;a=l;j=m}}else{g=32;q=16}while(0);if((q|0)==16){q=0;k=g+-32|0;a=m;j=0}l=j<<32-k|a>>>k;m=j>>>k;g=g+f|0;if(!((m|0)!=0|(l|0)!=1)){a=n;q=20;break a}a=n+(0-(c[h+(g<<2)>>2]|0))|0;if((cc[d&15](a,c[p>>2]|0)|0)<1){a=n;f=g;g=0;q=19;break}else{k=n;f=g;g=1;n=a;j=e;a=k}}}else{e=1;q=19}while(0);if((q|0)==19?(g|0)==0:0){g=f;q=20}if((q|0)==20){Pj(b,p,e);Nj(a,b,d,g,h)}i=r;return}function Pj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;h=i;i=i+256|0;e=h;a:do if((d|0)>=2?(g=b+(d<<2)|0,c[g>>2]=e,(a|0)!=0):0)while(1){f=a>>>0>256?256:a;ik(e|0,c[b>>2]|0,f|0)|0;e=0;do{j=b+(e<<2)|0;e=e+1|0;ik(c[j>>2]|0,c[b+(e<<2)>>2]|0,f|0)|0;c[j>>2]=(c[j>>2]|0)+f}while((e|0)!=(d|0));if((a|0)==(f|0))break a;a=a-f|0;e=c[g>>2]|0}while(0);i=h;return}function Qj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=a+20|0;f=c[e>>2]|0;a=(c[a+16>>2]|0)-f|0;a=a>>>0>d>>>0?d:a;ik(f|0,b|0,a|0)|0;c[e>>2]=(c[e>>2]|0)+a;return d|0}function Rj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{e=(c[d>>2]|0)+(4-1)&~(4-1);b=c[e>>2]|0;c[d>>2]=e+4;c[a>>2]=b;break a}case 10:{e=(c[d>>2]|0)+(4-1)&~(4-1);b=c[e>>2]|0;c[d>>2]=e+4;e=a;c[e>>2]=b;c[e+4>>2]=((b|0)<0)<<31>>31;break a}case 11:{e=(c[d>>2]|0)+(4-1)&~(4-1);b=c[e>>2]|0;c[d>>2]=e+4;e=a;c[e>>2]=b;c[e+4>>2]=0;break a}case 12:{e=(c[d>>2]|0)+(8-1)&~(8-1);b=e;f=c[b>>2]|0;b=c[b+4>>2]|0;c[d>>2]=e+8;e=a;c[e>>2]=f;c[e+4>>2]=b;break a}case 13:{f=(c[d>>2]|0)+(4-1)&~(4-1);e=c[f>>2]|0;c[d>>2]=f+4;e=(e&65535)<<16>>16;f=a;c[f>>2]=e;c[f+4>>2]=((e|0)<0)<<31>>31;break a}case 14:{f=(c[d>>2]|0)+(4-1)&~(4-1);e=c[f>>2]|0;c[d>>2]=f+4;f=a;c[f>>2]=e&65535;c[f+4>>2]=0;break a}case 15:{f=(c[d>>2]|0)+(4-1)&~(4-1);e=c[f>>2]|0;c[d>>2]=f+4;e=(e&255)<<24>>24;f=a;c[f>>2]=e;c[f+4>>2]=((e|0)<0)<<31>>31;break a}case 16:{f=(c[d>>2]|0)+(4-1)&~(4-1);e=c[f>>2]|0;c[d>>2]=f+4;f=a;c[f>>2]=e&255;c[f+4>>2]=0;break a}case 17:{f=(c[d>>2]|0)+(8-1)&~(8-1);g=+h[f>>3];c[d>>2]=f+8;h[a>>3]=g;break a}case 18:{f=(c[d>>2]|0)+(8-1)&~(8-1);g=+h[f>>3];c[d>>2]=f+8;h[a>>3]=g;break a}default:break a}while(0);while(0);return}function Sj(b,c,d){b=b|0;c=c|0;d=d|0;var e=0;if(c>>>0>0|(c|0)==0&b>>>0>4294967295)while(1){e=qk(b|0,c|0,10,0)|0;d=d+-1|0;a[d>>0]=e|48;e=pk(b|0,c|0,10,0)|0;if(c>>>0>9|(c|0)==9&b>>>0>4294967295){b=e;c=D}else{b=e;break}}if(b)while(1){d=d+-1|0;a[d>>0]=(b>>>0)%10|0|48;if(b>>>0<10)break;else b=(b>>>0)/10|0}return d|0}function Tj(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0;j=i;i=i+256|0;h=j;do if((d|0)>(e|0)&(f&73728|0)==0){f=d-e|0;ek(h|0,b|0,(f>>>0>256?256:f)|0)|0;b=c[a>>2]|0;g=(b&32|0)==0;if(f>>>0>255){e=d-e|0;do{if(g){hj(h,256,a)|0;b=c[a>>2]|0}f=f+-256|0;g=(b&32|0)==0}while(f>>>0>255);if(g)f=e&255;else break}else if(!g)break;hj(h,f,a)|0}while(0);i=j;return}function Uj(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;do if(a>>>0<245){o=a>>>0<11?16:a+11&-8;a=o>>>3;i=c[756]|0;d=i>>>a;if(d&3){a=(d&1^1)+a|0;e=a<<1;d=3064+(e<<2)|0;e=3064+(e+2<<2)|0;f=c[e>>2]|0;g=f+8|0;h=c[g>>2]|0;do if((d|0)!=(h|0)){if(h>>>0<(c[760]|0)>>>0)Da();b=h+12|0;if((c[b>>2]|0)==(f|0)){c[b>>2]=d;c[e>>2]=h;break}else Da()}else c[756]=i&~(1<<a);while(0);M=a<<3;c[f+4>>2]=M|3;M=f+(M|4)|0;c[M>>2]=c[M>>2]|1;M=g;return M|0}h=c[758]|0;if(o>>>0>h>>>0){if(d){e=2<<a;e=d<<a&(e|0-e);e=(e&0-e)+-1|0;j=e>>>12&16;e=e>>>j;f=e>>>5&8;e=e>>>f;g=e>>>2&4;e=e>>>g;d=e>>>1&2;e=e>>>d;a=e>>>1&1;a=(f|j|g|d|a)+(e>>>a)|0;e=a<<1;d=3064+(e<<2)|0;e=3064+(e+2<<2)|0;g=c[e>>2]|0;j=g+8|0;f=c[j>>2]|0;do if((d|0)!=(f|0)){if(f>>>0<(c[760]|0)>>>0)Da();b=f+12|0;if((c[b>>2]|0)==(g|0)){c[b>>2]=d;c[e>>2]=f;k=c[758]|0;break}else Da()}else{c[756]=i&~(1<<a);k=h}while(0);M=a<<3;h=M-o|0;c[g+4>>2]=o|3;i=g+o|0;c[g+(o|4)>>2]=h|1;c[g+M>>2]=h;if(k){f=c[761]|0;d=k>>>3;b=d<<1;e=3064+(b<<2)|0;a=c[756]|0;d=1<<d;if(a&d){a=3064+(b+2<<2)|0;b=c[a>>2]|0;if(b>>>0<(c[760]|0)>>>0)Da();else{l=a;m=b}}else{c[756]=a|d;l=3064+(b+2<<2)|0;m=e}c[l>>2]=f;c[m+12>>2]=f;c[f+8>>2]=m;c[f+12>>2]=e}c[758]=h;c[761]=i;M=j;return M|0}a=c[757]|0;if(a){d=(a&0-a)+-1|0;L=d>>>12&16;d=d>>>L;K=d>>>5&8;d=d>>>K;M=d>>>2&4;d=d>>>M;a=d>>>1&2;d=d>>>a;e=d>>>1&1;e=c[3328+((K|L|M|a|e)+(d>>>e)<<2)>>2]|0;d=(c[e+4>>2]&-8)-o|0;a=e;while(1){b=c[a+16>>2]|0;if(!b){b=c[a+20>>2]|0;if(!b){j=d;break}}a=(c[b+4>>2]&-8)-o|0;M=a>>>0<d>>>0;d=M?a:d;a=b;e=M?b:e}g=c[760]|0;if(e>>>0<g>>>0)Da();i=e+o|0;if(e>>>0>=i>>>0)Da();h=c[e+24>>2]|0;d=c[e+12>>2]|0;do if((d|0)==(e|0)){a=e+20|0;b=c[a>>2]|0;if(!b){a=e+16|0;b=c[a>>2]|0;if(!b){n=0;break}}while(1){d=b+20|0;f=c[d>>2]|0;if(f){b=f;a=d;continue}d=b+16|0;f=c[d>>2]|0;if(!f)break;else{b=f;a=d}}if(a>>>0<g>>>0)Da();else{c[a>>2]=0;n=b;break}}else{f=c[e+8>>2]|0;if(f>>>0<g>>>0)Da();b=f+12|0;if((c[b>>2]|0)!=(e|0))Da();a=d+8|0;if((c[a>>2]|0)==(e|0)){c[b>>2]=d;c[a>>2]=f;n=d;break}else Da()}while(0);do if(h){b=c[e+28>>2]|0;a=3328+(b<<2)|0;if((e|0)==(c[a>>2]|0)){c[a>>2]=n;if(!n){c[757]=c[757]&~(1<<b);break}}else{if(h>>>0<(c[760]|0)>>>0)Da();b=h+16|0;if((c[b>>2]|0)==(e|0))c[b>>2]=n;else c[h+20>>2]=n;if(!n)break}a=c[760]|0;if(n>>>0<a>>>0)Da();c[n+24>>2]=h;b=c[e+16>>2]|0;do if(b)if(b>>>0<a>>>0)Da();else{c[n+16>>2]=b;c[b+24>>2]=n;break}while(0);b=c[e+20>>2]|0;if(b)if(b>>>0<(c[760]|0)>>>0)Da();else{c[n+20>>2]=b;c[b+24>>2]=n;break}}while(0);if(j>>>0<16){M=j+o|0;c[e+4>>2]=M|3;M=e+(M+4)|0;c[M>>2]=c[M>>2]|1}else{c[e+4>>2]=o|3;c[e+(o|4)>>2]=j|1;c[e+(j+o)>>2]=j;b=c[758]|0;if(b){g=c[761]|0;d=b>>>3;b=d<<1;f=3064+(b<<2)|0;a=c[756]|0;d=1<<d;if(a&d){b=3064+(b+2<<2)|0;a=c[b>>2]|0;if(a>>>0<(c[760]|0)>>>0)Da();else{p=b;q=a}}else{c[756]=a|d;p=3064+(b+2<<2)|0;q=f}c[p>>2]=g;c[q+12>>2]=g;c[g+8>>2]=q;c[g+12>>2]=f}c[758]=j;c[761]=i}M=e+8|0;return M|0}else q=o}else q=o}else if(a>>>0<=4294967231){a=a+11|0;m=a&-8;l=c[757]|0;if(l){d=0-m|0;a=a>>>8;if(a)if(m>>>0>16777215)k=31;else{q=(a+1048320|0)>>>16&8;v=a<<q;p=(v+520192|0)>>>16&4;v=v<<p;k=(v+245760|0)>>>16&2;k=14-(p|q|k)+(v<<k>>>15)|0;k=m>>>(k+7|0)&1|k<<1}else k=0;a=c[3328+(k<<2)>>2]|0;a:do if(!a){f=0;a=0;v=86}else{h=d;f=0;i=m<<((k|0)==31?0:25-(k>>>1)|0);j=a;a=0;while(1){g=c[j+4>>2]&-8;d=g-m|0;if(d>>>0<h>>>0)if((g|0)==(m|0)){g=j;a=j;v=90;break a}else a=j;else d=h;v=c[j+20>>2]|0;j=c[j+16+(i>>>31<<2)>>2]|0;f=(v|0)==0|(v|0)==(j|0)?f:v;if(!j){v=86;break}else{h=d;i=i<<1}}}while(0);if((v|0)==86){if((f|0)==0&(a|0)==0){a=2<<k;a=l&(a|0-a);if(!a){q=m;break}a=(a&0-a)+-1|0;n=a>>>12&16;a=a>>>n;l=a>>>5&8;a=a>>>l;p=a>>>2&4;a=a>>>p;q=a>>>1&2;a=a>>>q;f=a>>>1&1;f=c[3328+((l|n|p|q|f)+(a>>>f)<<2)>>2]|0;a=0}if(!f){i=d;j=a}else{g=f;v=90}}if((v|0)==90)while(1){v=0;q=(c[g+4>>2]&-8)-m|0;f=q>>>0<d>>>0;d=f?q:d;a=f?g:a;f=c[g+16>>2]|0;if(f){g=f;v=90;continue}g=c[g+20>>2]|0;if(!g){i=d;j=a;break}else v=90}if((j|0)!=0?i>>>0<((c[758]|0)-m|0)>>>0:0){f=c[760]|0;if(j>>>0<f>>>0)Da();h=j+m|0;if(j>>>0>=h>>>0)Da();g=c[j+24>>2]|0;d=c[j+12>>2]|0;do if((d|0)==(j|0)){a=j+20|0;b=c[a>>2]|0;if(!b){a=j+16|0;b=c[a>>2]|0;if(!b){o=0;break}}while(1){d=b+20|0;e=c[d>>2]|0;if(e){b=e;a=d;continue}d=b+16|0;e=c[d>>2]|0;if(!e)break;else{b=e;a=d}}if(a>>>0<f>>>0)Da();else{c[a>>2]=0;o=b;break}}else{e=c[j+8>>2]|0;if(e>>>0<f>>>0)Da();b=e+12|0;if((c[b>>2]|0)!=(j|0))Da();a=d+8|0;if((c[a>>2]|0)==(j|0)){c[b>>2]=d;c[a>>2]=e;o=d;break}else Da()}while(0);do if(g){b=c[j+28>>2]|0;a=3328+(b<<2)|0;if((j|0)==(c[a>>2]|0)){c[a>>2]=o;if(!o){c[757]=c[757]&~(1<<b);break}}else{if(g>>>0<(c[760]|0)>>>0)Da();b=g+16|0;if((c[b>>2]|0)==(j|0))c[b>>2]=o;else c[g+20>>2]=o;if(!o)break}a=c[760]|0;if(o>>>0<a>>>0)Da();c[o+24>>2]=g;b=c[j+16>>2]|0;do if(b)if(b>>>0<a>>>0)Da();else{c[o+16>>2]=b;c[b+24>>2]=o;break}while(0);b=c[j+20>>2]|0;if(b)if(b>>>0<(c[760]|0)>>>0)Da();else{c[o+20>>2]=b;c[b+24>>2]=o;break}}while(0);b:do if(i>>>0>=16){c[j+4>>2]=m|3;c[j+(m|4)>>2]=i|1;c[j+(i+m)>>2]=i;b=i>>>3;if(i>>>0<256){a=b<<1;e=3064+(a<<2)|0;d=c[756]|0;b=1<<b;if(d&b){b=3064+(a+2<<2)|0;a=c[b>>2]|0;if(a>>>0<(c[760]|0)>>>0)Da();else{s=b;t=a}}else{c[756]=d|b;s=3064+(a+2<<2)|0;t=e}c[s>>2]=h;c[t+12>>2]=h;c[j+(m+8)>>2]=t;c[j+(m+12)>>2]=e;break}b=i>>>8;if(b)if(i>>>0>16777215)e=31;else{L=(b+1048320|0)>>>16&8;M=b<<L;K=(M+520192|0)>>>16&4;M=M<<K;e=(M+245760|0)>>>16&2;e=14-(K|L|e)+(M<<e>>>15)|0;e=i>>>(e+7|0)&1|e<<1}else e=0;b=3328+(e<<2)|0;c[j+(m+28)>>2]=e;c[j+(m+20)>>2]=0;c[j+(m+16)>>2]=0;a=c[757]|0;d=1<<e;if(!(a&d)){c[757]=a|d;c[b>>2]=h;c[j+(m+24)>>2]=b;c[j+(m+12)>>2]=h;c[j+(m+8)>>2]=h;break}b=c[b>>2]|0;c:do if((c[b+4>>2]&-8|0)!=(i|0)){e=i<<((e|0)==31?0:25-(e>>>1)|0);while(1){a=b+16+(e>>>31<<2)|0;d=c[a>>2]|0;if(!d)break;if((c[d+4>>2]&-8|0)==(i|0)){y=d;break c}else{e=e<<1;b=d}}if(a>>>0<(c[760]|0)>>>0)Da();else{c[a>>2]=h;c[j+(m+24)>>2]=b;c[j+(m+12)>>2]=h;c[j+(m+8)>>2]=h;break b}}else y=b;while(0);b=y+8|0;a=c[b>>2]|0;M=c[760]|0;if(a>>>0>=M>>>0&y>>>0>=M>>>0){c[a+12>>2]=h;c[b>>2]=h;c[j+(m+8)>>2]=a;c[j+(m+12)>>2]=y;c[j+(m+24)>>2]=0;break}else Da()}else{M=i+m|0;c[j+4>>2]=M|3;M=j+(M+4)|0;c[M>>2]=c[M>>2]|1}while(0);M=j+8|0;return M|0}else q=m}else q=m}else q=-1;while(0);d=c[758]|0;if(d>>>0>=q>>>0){b=d-q|0;a=c[761]|0;if(b>>>0>15){c[761]=a+q;c[758]=b;c[a+(q+4)>>2]=b|1;c[a+d>>2]=b;c[a+4>>2]=q|3}else{c[758]=0;c[761]=0;c[a+4>>2]=d|3;M=a+(d+4)|0;c[M>>2]=c[M>>2]|1}M=a+8|0;return M|0}a=c[759]|0;if(a>>>0>q>>>0){L=a-q|0;c[759]=L;M=c[762]|0;c[762]=M+q;c[M+(q+4)>>2]=L|1;c[M+4>>2]=q|3;M=M+8|0;return M|0}do if(!(c[874]|0)){a=$a(30)|0;if(!(a+-1&a)){c[876]=a;c[875]=a;c[877]=-1;c[878]=-1;c[879]=0;c[867]=0;c[874]=(Db(0)|0)&-16^1431655768;break}else Da()}while(0);j=q+48|0;i=c[876]|0;k=q+47|0;h=i+k|0;i=0-i|0;l=h&i;if(l>>>0<=q>>>0){M=0;return M|0}a=c[866]|0;if((a|0)!=0?(t=c[864]|0,y=t+l|0,y>>>0<=t>>>0|y>>>0>a>>>0):0){M=0;return M|0}d:do if(!(c[867]&4)){a=c[762]|0;e:do if(a){f=3472;while(1){d=c[f>>2]|0;if(d>>>0<=a>>>0?(r=f+4|0,(d+(c[r>>2]|0)|0)>>>0>a>>>0):0){g=f;a=r;break}f=c[f+8>>2]|0;if(!f){v=174;break e}}d=h-(c[759]|0)&i;if(d>>>0<2147483647){f=Ua(d|0)|0;y=(f|0)==((c[g>>2]|0)+(c[a>>2]|0)|0);a=y?d:0;if(y){if((f|0)!=(-1|0)){w=f;p=a;v=194;break d}}else v=184}else a=0}else v=174;while(0);do if((v|0)==174){g=Ua(0)|0;if((g|0)!=(-1|0)){a=g;d=c[875]|0;f=d+-1|0;if(!(f&a))d=l;else d=l-a+(f+a&0-d)|0;a=c[864]|0;f=a+d|0;if(d>>>0>q>>>0&d>>>0<2147483647){y=c[866]|0;if((y|0)!=0?f>>>0<=a>>>0|f>>>0>y>>>0:0){a=0;break}f=Ua(d|0)|0;y=(f|0)==(g|0);a=y?d:0;if(y){w=g;p=a;v=194;break d}else v=184}else a=0}else a=0}while(0);f:do if((v|0)==184){g=0-d|0;do if(j>>>0>d>>>0&(d>>>0<2147483647&(f|0)!=(-1|0))?(u=c[876]|0,u=k-d+u&0-u,u>>>0<2147483647):0)if((Ua(u|0)|0)==(-1|0)){Ua(g|0)|0;break f}else{d=u+d|0;break}while(0);if((f|0)!=(-1|0)){w=f;p=d;v=194;break d}}while(0);c[867]=c[867]|4;v=191}else{a=0;v=191}while(0);if((((v|0)==191?l>>>0<2147483647:0)?(w=Ua(l|0)|0,x=Ua(0)|0,w>>>0<x>>>0&((w|0)!=(-1|0)&(x|0)!=(-1|0))):0)?(z=x-w|0,A=z>>>0>(q+40|0)>>>0,A):0){p=A?z:a;v=194}if((v|0)==194){a=(c[864]|0)+p|0;c[864]=a;if(a>>>0>(c[865]|0)>>>0)c[865]=a;h=c[762]|0;g:do if(h){g=3472;do{a=c[g>>2]|0;d=g+4|0;f=c[d>>2]|0;if((w|0)==(a+f|0)){B=a;C=d;D=f;E=g;v=204;break}g=c[g+8>>2]|0}while((g|0)!=0);if(((v|0)==204?(c[E+12>>2]&8|0)==0:0)?h>>>0<w>>>0&h>>>0>=B>>>0:0){c[C>>2]=D+p;M=(c[759]|0)+p|0;L=h+8|0;L=(L&7|0)==0?0:0-L&7;K=M-L|0;c[762]=h+L;c[759]=K;c[h+(L+4)>>2]=K|1;c[h+(M+4)>>2]=40;c[763]=c[878];break}a=c[760]|0;if(w>>>0<a>>>0){c[760]=w;a=w}d=w+p|0;g=3472;while(1){if((c[g>>2]|0)==(d|0)){f=g;d=g;v=212;break}g=c[g+8>>2]|0;if(!g){d=3472;break}}if((v|0)==212)if(!(c[d+12>>2]&8)){c[f>>2]=w;n=d+4|0;c[n>>2]=(c[n>>2]|0)+p;n=w+8|0;n=(n&7|0)==0?0:0-n&7;k=w+(p+8)|0;k=(k&7|0)==0?0:0-k&7;b=w+(k+p)|0;m=n+q|0;o=w+m|0;l=b-(w+n)-q|0;c[w+(n+4)>>2]=q|3;h:do if((b|0)!=(h|0)){if((b|0)==(c[761]|0)){M=(c[758]|0)+l|0;c[758]=M;c[761]=o;c[w+(m+4)>>2]=M|1;c[w+(M+m)>>2]=M;break}i=p+4|0;d=c[w+(i+k)>>2]|0;if((d&3|0)==1){j=d&-8;g=d>>>3;i:do if(d>>>0>=256){h=c[w+((k|24)+p)>>2]|0;e=c[w+(p+12+k)>>2]|0;do if((e|0)==(b|0)){f=k|16;e=w+(i+f)|0;d=c[e>>2]|0;if(!d){e=w+(f+p)|0;d=c[e>>2]|0;if(!d){J=0;break}}while(1){f=d+20|0;g=c[f>>2]|0;if(g){d=g;e=f;continue}f=d+16|0;g=c[f>>2]|0;if(!g)break;else{d=g;e=f}}if(e>>>0<a>>>0)Da();else{c[e>>2]=0;J=d;break}}else{f=c[w+((k|8)+p)>>2]|0;if(f>>>0<a>>>0)Da();a=f+12|0;if((c[a>>2]|0)!=(b|0))Da();d=e+8|0;if((c[d>>2]|0)==(b|0)){c[a>>2]=e;c[d>>2]=f;J=e;break}else Da()}while(0);if(!h)break;a=c[w+(p+28+k)>>2]|0;d=3328+(a<<2)|0;do if((b|0)!=(c[d>>2]|0)){if(h>>>0<(c[760]|0)>>>0)Da();a=h+16|0;if((c[a>>2]|0)==(b|0))c[a>>2]=J;else c[h+20>>2]=J;if(!J)break i}else{c[d>>2]=J;if(J)break;c[757]=c[757]&~(1<<a);break i}while(0);d=c[760]|0;if(J>>>0<d>>>0)Da();c[J+24>>2]=h;b=k|16;a=c[w+(b+p)>>2]|0;do if(a)if(a>>>0<d>>>0)Da();else{c[J+16>>2]=a;c[a+24>>2]=J;break}while(0);b=c[w+(i+b)>>2]|0;if(!b)break;if(b>>>0<(c[760]|0)>>>0)Da();else{c[J+20>>2]=b;c[b+24>>2]=J;break}}else{e=c[w+((k|8)+p)>>2]|0;f=c[w+(p+12+k)>>2]|0;d=3064+(g<<1<<2)|0;do if((e|0)!=(d|0)){if(e>>>0<a>>>0)Da();if((c[e+12>>2]|0)==(b|0))break;Da()}while(0);if((f|0)==(e|0)){c[756]=c[756]&~(1<<g);break}do if((f|0)==(d|0))F=f+8|0;else{if(f>>>0<a>>>0)Da();a=f+8|0;if((c[a>>2]|0)==(b|0)){F=a;break}Da()}while(0);c[e+12>>2]=f;c[F>>2]=e}while(0);b=w+((j|k)+p)|0;f=j+l|0}else f=l;b=b+4|0;c[b>>2]=c[b>>2]&-2;c[w+(m+4)>>2]=f|1;c[w+(f+m)>>2]=f;b=f>>>3;if(f>>>0<256){a=b<<1;e=3064+(a<<2)|0;d=c[756]|0;b=1<<b;do if(!(d&b)){c[756]=d|b;K=3064+(a+2<<2)|0;L=e}else{b=3064+(a+2<<2)|0;a=c[b>>2]|0;if(a>>>0>=(c[760]|0)>>>0){K=b;L=a;break}Da()}while(0);c[K>>2]=o;c[L+12>>2]=o;c[w+(m+8)>>2]=L;c[w+(m+12)>>2]=e;break}b=f>>>8;do if(!b)e=0;else{if(f>>>0>16777215){e=31;break}K=(b+1048320|0)>>>16&8;L=b<<K;J=(L+520192|0)>>>16&4;L=L<<J;e=(L+245760|0)>>>16&2;e=14-(J|K|e)+(L<<e>>>15)|0;e=f>>>(e+7|0)&1|e<<1}while(0);b=3328+(e<<2)|0;c[w+(m+28)>>2]=e;c[w+(m+20)>>2]=0;c[w+(m+16)>>2]=0;a=c[757]|0;d=1<<e;if(!(a&d)){c[757]=a|d;c[b>>2]=o;c[w+(m+24)>>2]=b;c[w+(m+12)>>2]=o;c[w+(m+8)>>2]=o;break}b=c[b>>2]|0;j:do if((c[b+4>>2]&-8|0)!=(f|0)){e=f<<((e|0)==31?0:25-(e>>>1)|0);while(1){a=b+16+(e>>>31<<2)|0;d=c[a>>2]|0;if(!d)break;if((c[d+4>>2]&-8|0)==(f|0)){M=d;break j}else{e=e<<1;b=d}}if(a>>>0<(c[760]|0)>>>0)Da();else{c[a>>2]=o;c[w+(m+24)>>2]=b;c[w+(m+12)>>2]=o;c[w+(m+8)>>2]=o;break h}}else M=b;while(0);b=M+8|0;a=c[b>>2]|0;L=c[760]|0;if(a>>>0>=L>>>0&M>>>0>=L>>>0){c[a+12>>2]=o;c[b>>2]=o;c[w+(m+8)>>2]=a;c[w+(m+12)>>2]=M;c[w+(m+24)>>2]=0;break}else Da()}else{M=(c[759]|0)+l|0;c[759]=M;c[762]=o;c[w+(m+4)>>2]=M|1}while(0);M=w+(n|8)|0;return M|0}else d=3472;while(1){a=c[d>>2]|0;if(a>>>0<=h>>>0?(b=c[d+4>>2]|0,e=a+b|0,e>>>0>h>>>0):0)break;d=c[d+8>>2]|0}f=a+(b+-39)|0;a=a+(b+-47+((f&7|0)==0?0:0-f&7))|0;f=h+16|0;a=a>>>0<f>>>0?h:a;b=a+8|0;d=w+8|0;d=(d&7|0)==0?0:0-d&7;M=p+-40-d|0;c[762]=w+d;c[759]=M;c[w+(d+4)>>2]=M|1;c[w+(p+-36)>>2]=40;c[763]=c[878];d=a+4|0;c[d>>2]=27;c[b>>2]=c[868];c[b+4>>2]=c[869];c[b+8>>2]=c[870];c[b+12>>2]=c[871];c[868]=w;c[869]=p;c[871]=0;c[870]=b;b=a+28|0;c[b>>2]=7;if((a+32|0)>>>0<e>>>0)do{M=b;b=b+4|0;c[b>>2]=7}while((M+8|0)>>>0<e>>>0);if((a|0)!=(h|0)){g=a-h|0;c[d>>2]=c[d>>2]&-2;c[h+4>>2]=g|1;c[a>>2]=g;b=g>>>3;if(g>>>0<256){a=b<<1;e=3064+(a<<2)|0;d=c[756]|0;b=1<<b;if(d&b){b=3064+(a+2<<2)|0;a=c[b>>2]|0;if(a>>>0<(c[760]|0)>>>0)Da();else{G=b;H=a}}else{c[756]=d|b;G=3064+(a+2<<2)|0;H=e}c[G>>2]=h;c[H+12>>2]=h;c[h+8>>2]=H;c[h+12>>2]=e;break}b=g>>>8;if(b)if(g>>>0>16777215)e=31;else{L=(b+1048320|0)>>>16&8;M=b<<L;K=(M+520192|0)>>>16&4;M=M<<K;e=(M+245760|0)>>>16&2;e=14-(K|L|e)+(M<<e>>>15)|0;e=g>>>(e+7|0)&1|e<<1}else e=0;d=3328+(e<<2)|0;c[h+28>>2]=e;c[h+20>>2]=0;c[f>>2]=0;b=c[757]|0;a=1<<e;if(!(b&a)){c[757]=b|a;c[d>>2]=h;c[h+24>>2]=d;c[h+12>>2]=h;c[h+8>>2]=h;break}b=c[d>>2]|0;k:do if((c[b+4>>2]&-8|0)!=(g|0)){e=g<<((e|0)==31?0:25-(e>>>1)|0);while(1){a=b+16+(e>>>31<<2)|0;d=c[a>>2]|0;if(!d)break;if((c[d+4>>2]&-8|0)==(g|0)){I=d;break k}else{e=e<<1;b=d}}if(a>>>0<(c[760]|0)>>>0)Da();else{c[a>>2]=h;c[h+24>>2]=b;c[h+12>>2]=h;c[h+8>>2]=h;break g}}else I=b;while(0);b=I+8|0;a=c[b>>2]|0;M=c[760]|0;if(a>>>0>=M>>>0&I>>>0>=M>>>0){c[a+12>>2]=h;c[b>>2]=h;c[h+8>>2]=a;c[h+12>>2]=I;c[h+24>>2]=0;break}else Da()}}else{M=c[760]|0;if((M|0)==0|w>>>0<M>>>0)c[760]=w;c[868]=w;c[869]=p;c[871]=0;c[765]=c[874];c[764]=-1;b=0;do{M=b<<1;L=3064+(M<<2)|0;c[3064+(M+3<<2)>>2]=L;c[3064+(M+2<<2)>>2]=L;b=b+1|0}while((b|0)!=32);M=w+8|0;M=(M&7|0)==0?0:0-M&7;L=p+-40-M|0;c[762]=w+M;c[759]=L;c[w+(M+4)>>2]=L|1;c[w+(p+-36)>>2]=40;c[763]=c[878]}while(0);b=c[759]|0;if(b>>>0>q>>>0){L=b-q|0;c[759]=L;M=c[762]|0;c[762]=M+q;c[M+(q+4)>>2]=L|1;c[M+4>>2]=q|3;M=M+8|0;return M|0}}c[(qi()|0)>>2]=12;M=0;return M|0}function Vj(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;if(!a)return;b=a+-8|0;i=c[760]|0;if(b>>>0<i>>>0)Da();d=c[a+-4>>2]|0;e=d&3;if((e|0)==1)Da();o=d&-8;q=a+(o+-8)|0;do if(!(d&1)){b=c[b>>2]|0;if(!e)return;j=-8-b|0;l=a+j|0;m=b+o|0;if(l>>>0<i>>>0)Da();if((l|0)==(c[761]|0)){b=a+(o+-4)|0;d=c[b>>2]|0;if((d&3|0)!=3){u=l;g=m;break}c[758]=m;c[b>>2]=d&-2;c[a+(j+4)>>2]=m|1;c[q>>2]=m;return}f=b>>>3;if(b>>>0<256){e=c[a+(j+8)>>2]|0;d=c[a+(j+12)>>2]|0;b=3064+(f<<1<<2)|0;if((e|0)!=(b|0)){if(e>>>0<i>>>0)Da();if((c[e+12>>2]|0)!=(l|0))Da()}if((d|0)==(e|0)){c[756]=c[756]&~(1<<f);u=l;g=m;break}if((d|0)!=(b|0)){if(d>>>0<i>>>0)Da();b=d+8|0;if((c[b>>2]|0)==(l|0))h=b;else Da()}else h=d+8|0;c[e+12>>2]=d;c[h>>2]=e;u=l;g=m;break}h=c[a+(j+24)>>2]|0;e=c[a+(j+12)>>2]|0;do if((e|0)==(l|0)){d=a+(j+20)|0;b=c[d>>2]|0;if(!b){d=a+(j+16)|0;b=c[d>>2]|0;if(!b){k=0;break}}while(1){e=b+20|0;f=c[e>>2]|0;if(f){b=f;d=e;continue}e=b+16|0;f=c[e>>2]|0;if(!f)break;else{b=f;d=e}}if(d>>>0<i>>>0)Da();else{c[d>>2]=0;k=b;break}}else{f=c[a+(j+8)>>2]|0;if(f>>>0<i>>>0)Da();b=f+12|0;if((c[b>>2]|0)!=(l|0))Da();d=e+8|0;if((c[d>>2]|0)==(l|0)){c[b>>2]=e;c[d>>2]=f;k=e;break}else Da()}while(0);if(h){b=c[a+(j+28)>>2]|0;d=3328+(b<<2)|0;if((l|0)==(c[d>>2]|0)){c[d>>2]=k;if(!k){c[757]=c[757]&~(1<<b);u=l;g=m;break}}else{if(h>>>0<(c[760]|0)>>>0)Da();b=h+16|0;if((c[b>>2]|0)==(l|0))c[b>>2]=k;else c[h+20>>2]=k;if(!k){u=l;g=m;break}}d=c[760]|0;if(k>>>0<d>>>0)Da();c[k+24>>2]=h;b=c[a+(j+16)>>2]|0;do if(b)if(b>>>0<d>>>0)Da();else{c[k+16>>2]=b;c[b+24>>2]=k;break}while(0);b=c[a+(j+20)>>2]|0;if(b)if(b>>>0<(c[760]|0)>>>0)Da();else{c[k+20>>2]=b;c[b+24>>2]=k;u=l;g=m;break}else{u=l;g=m}}else{u=l;g=m}}else{u=b;g=o}while(0);if(u>>>0>=q>>>0)Da();b=a+(o+-4)|0;d=c[b>>2]|0;if(!(d&1))Da();if(!(d&2)){if((q|0)==(c[762]|0)){t=(c[759]|0)+g|0;c[759]=t;c[762]=u;c[u+4>>2]=t|1;if((u|0)!=(c[761]|0))return;c[761]=0;c[758]=0;return}if((q|0)==(c[761]|0)){t=(c[758]|0)+g|0;c[758]=t;c[761]=u;c[u+4>>2]=t|1;c[u+t>>2]=t;return}g=(d&-8)+g|0;f=d>>>3;do if(d>>>0>=256){h=c[a+(o+16)>>2]|0;b=c[a+(o|4)>>2]|0;do if((b|0)==(q|0)){d=a+(o+12)|0;b=c[d>>2]|0;if(!b){d=a+(o+8)|0;b=c[d>>2]|0;if(!b){p=0;break}}while(1){e=b+20|0;f=c[e>>2]|0;if(f){b=f;d=e;continue}e=b+16|0;f=c[e>>2]|0;if(!f)break;else{b=f;d=e}}if(d>>>0<(c[760]|0)>>>0)Da();else{c[d>>2]=0;p=b;break}}else{d=c[a+o>>2]|0;if(d>>>0<(c[760]|0)>>>0)Da();e=d+12|0;if((c[e>>2]|0)!=(q|0))Da();f=b+8|0;if((c[f>>2]|0)==(q|0)){c[e>>2]=b;c[f>>2]=d;p=b;break}else Da()}while(0);if(h){b=c[a+(o+20)>>2]|0;d=3328+(b<<2)|0;if((q|0)==(c[d>>2]|0)){c[d>>2]=p;if(!p){c[757]=c[757]&~(1<<b);break}}else{if(h>>>0<(c[760]|0)>>>0)Da();b=h+16|0;if((c[b>>2]|0)==(q|0))c[b>>2]=p;else c[h+20>>2]=p;if(!p)break}d=c[760]|0;if(p>>>0<d>>>0)Da();c[p+24>>2]=h;b=c[a+(o+8)>>2]|0;do if(b)if(b>>>0<d>>>0)Da();else{c[p+16>>2]=b;c[b+24>>2]=p;break}while(0);b=c[a+(o+12)>>2]|0;if(b)if(b>>>0<(c[760]|0)>>>0)Da();else{c[p+20>>2]=b;c[b+24>>2]=p;break}}}else{e=c[a+o>>2]|0;d=c[a+(o|4)>>2]|0;b=3064+(f<<1<<2)|0;if((e|0)!=(b|0)){if(e>>>0<(c[760]|0)>>>0)Da();if((c[e+12>>2]|0)!=(q|0))Da()}if((d|0)==(e|0)){c[756]=c[756]&~(1<<f);break}if((d|0)!=(b|0)){if(d>>>0<(c[760]|0)>>>0)Da();b=d+8|0;if((c[b>>2]|0)==(q|0))n=b;else Da()}else n=d+8|0;c[e+12>>2]=d;c[n>>2]=e}while(0);c[u+4>>2]=g|1;c[u+g>>2]=g;if((u|0)==(c[761]|0)){c[758]=g;return}}else{c[b>>2]=d&-2;c[u+4>>2]=g|1;c[u+g>>2]=g}b=g>>>3;if(g>>>0<256){d=b<<1;f=3064+(d<<2)|0;e=c[756]|0;b=1<<b;if(e&b){b=3064+(d+2<<2)|0;d=c[b>>2]|0;if(d>>>0<(c[760]|0)>>>0)Da();else{r=b;s=d}}else{c[756]=e|b;r=3064+(d+2<<2)|0;s=f}c[r>>2]=u;c[s+12>>2]=u;c[u+8>>2]=s;c[u+12>>2]=f;return}b=g>>>8;if(b)if(g>>>0>16777215)f=31;else{r=(b+1048320|0)>>>16&8;s=b<<r;q=(s+520192|0)>>>16&4;s=s<<q;f=(s+245760|0)>>>16&2;f=14-(q|r|f)+(s<<f>>>15)|0;f=g>>>(f+7|0)&1|f<<1}else f=0;b=3328+(f<<2)|0;c[u+28>>2]=f;c[u+20>>2]=0;c[u+16>>2]=0;d=c[757]|0;e=1<<f;a:do if(d&e){b=c[b>>2]|0;b:do if((c[b+4>>2]&-8|0)!=(g|0)){f=g<<((f|0)==31?0:25-(f>>>1)|0);while(1){d=b+16+(f>>>31<<2)|0;e=c[d>>2]|0;if(!e)break;if((c[e+4>>2]&-8|0)==(g|0)){t=e;break b}else{f=f<<1;b=e}}if(d>>>0<(c[760]|0)>>>0)Da();else{c[d>>2]=u;c[u+24>>2]=b;c[u+12>>2]=u;c[u+8>>2]=u;break a}}else t=b;while(0);b=t+8|0;d=c[b>>2]|0;s=c[760]|0;if(d>>>0>=s>>>0&t>>>0>=s>>>0){c[d+12>>2]=u;c[b>>2]=u;c[u+8>>2]=d;c[u+12>>2]=t;c[u+24>>2]=0;break}else Da()}else{c[757]=d|e;c[b>>2]=u;c[u+24>>2]=b;c[u+12>>2]=u;c[u+8>>2]=u}while(0);u=(c[764]|0)+-1|0;c[764]=u;if(!u)b=3480;else return;while(1){b=c[b>>2]|0;if(!b)break;else b=b+8|0}c[764]=-1;return}function Wj(a,b){a=a|0;b=b|0;var d=0;if(a){d=$(b,a)|0;if((b|a)>>>0>65535)d=((d>>>0)/(a>>>0)|0|0)==(b|0)?d:-1}else d=0;b=Uj(d)|0;if(!b)return b|0;if(!(c[b+-4>>2]&3))return b|0;ek(b|0,0,d|0)|0;return b|0}function Xj(a,b){a=a|0;b=b|0;var d=0,e=0;if(!a){a=Uj(b)|0;return a|0}if(b>>>0>4294967231){c[(qi()|0)>>2]=12;a=0;return a|0}d=Yj(a+-8|0,b>>>0<11?16:b+11&-8)|0;if(d){a=d+8|0;return a|0}d=Uj(b)|0;if(!d){a=0;return a|0}e=c[a+-4>>2]|0;e=(e&-8)-((e&3|0)==0?8:4)|0;ik(d|0,a|0,(e>>>0<b>>>0?e:b)|0)|0;Vj(a);a=d;return a|0}function Yj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;o=a+4|0;p=c[o>>2]|0;j=p&-8;l=a+j|0;i=c[760]|0;d=p&3;if(!((d|0)!=1&a>>>0>=i>>>0&a>>>0<l>>>0))Da();e=a+(j|4)|0;f=c[e>>2]|0;if(!(f&1))Da();if(!d){if(b>>>0<256){a=0;return a|0}if(j>>>0>=(b+4|0)>>>0?(j-b|0)>>>0<=c[876]<<1>>>0:0)return a|0;a=0;return a|0}if(j>>>0>=b>>>0){d=j-b|0;if(d>>>0<=15)return a|0;c[o>>2]=p&1|b|2;c[a+(b+4)>>2]=d|3;c[e>>2]=c[e>>2]|1;Zj(a+b|0,d);return a|0}if((l|0)==(c[762]|0)){d=(c[759]|0)+j|0;if(d>>>0<=b>>>0){a=0;return a|0}n=d-b|0;c[o>>2]=p&1|b|2;c[a+(b+4)>>2]=n|1;c[762]=a+b;c[759]=n;return a|0}if((l|0)==(c[761]|0)){e=(c[758]|0)+j|0;if(e>>>0<b>>>0){a=0;return a|0}d=e-b|0;if(d>>>0>15){c[o>>2]=p&1|b|2;c[a+(b+4)>>2]=d|1;c[a+e>>2]=d;e=a+(e+4)|0;c[e>>2]=c[e>>2]&-2;e=a+b|0}else{c[o>>2]=p&1|e|2;e=a+(e+4)|0;c[e>>2]=c[e>>2]|1;e=0;d=0}c[758]=d;c[761]=e;return a|0}if(f&2){a=0;return a|0}m=(f&-8)+j|0;if(m>>>0<b>>>0){a=0;return a|0}n=m-b|0;g=f>>>3;do if(f>>>0>=256){h=c[a+(j+24)>>2]|0;g=c[a+(j+12)>>2]|0;do if((g|0)==(l|0)){e=a+(j+20)|0;d=c[e>>2]|0;if(!d){e=a+(j+16)|0;d=c[e>>2]|0;if(!d){k=0;break}}while(1){f=d+20|0;g=c[f>>2]|0;if(g){d=g;e=f;continue}f=d+16|0;g=c[f>>2]|0;if(!g)break;else{d=g;e=f}}if(e>>>0<i>>>0)Da();else{c[e>>2]=0;k=d;break}}else{f=c[a+(j+8)>>2]|0;if(f>>>0<i>>>0)Da();d=f+12|0;if((c[d>>2]|0)!=(l|0))Da();e=g+8|0;if((c[e>>2]|0)==(l|0)){c[d>>2]=g;c[e>>2]=f;k=g;break}else Da()}while(0);if(h){d=c[a+(j+28)>>2]|0;e=3328+(d<<2)|0;if((l|0)==(c[e>>2]|0)){c[e>>2]=k;if(!k){c[757]=c[757]&~(1<<d);break}}else{if(h>>>0<(c[760]|0)>>>0)Da();d=h+16|0;if((c[d>>2]|0)==(l|0))c[d>>2]=k;else c[h+20>>2]=k;if(!k)break}e=c[760]|0;if(k>>>0<e>>>0)Da();c[k+24>>2]=h;d=c[a+(j+16)>>2]|0;do if(d)if(d>>>0<e>>>0)Da();else{c[k+16>>2]=d;c[d+24>>2]=k;break}while(0);d=c[a+(j+20)>>2]|0;if(d)if(d>>>0<(c[760]|0)>>>0)Da();else{c[k+20>>2]=d;c[d+24>>2]=k;break}}}else{f=c[a+(j+8)>>2]|0;e=c[a+(j+12)>>2]|0;d=3064+(g<<1<<2)|0;if((f|0)!=(d|0)){if(f>>>0<i>>>0)Da();if((c[f+12>>2]|0)!=(l|0))Da()}if((e|0)==(f|0)){c[756]=c[756]&~(1<<g);break}if((e|0)!=(d|0)){if(e>>>0<i>>>0)Da();d=e+8|0;if((c[d>>2]|0)==(l|0))h=d;else Da()}else h=e+8|0;c[f+12>>2]=e;c[h>>2]=f}while(0);if(n>>>0<16){c[o>>2]=m|p&1|2;b=a+(m|4)|0;c[b>>2]=c[b>>2]|1;return a|0}else{c[o>>2]=p&1|b|2;c[a+(b+4)>>2]=n|3;p=a+(m|4)|0;c[p>>2]=c[p>>2]|1;Zj(a+b|0,n);return a|0}return 0}function Zj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;q=a+b|0;d=c[a+4>>2]|0;do if(!(d&1)){k=c[a>>2]|0;if(!(d&3))return;n=a+(0-k)|0;m=k+b|0;j=c[760]|0;if(n>>>0<j>>>0)Da();if((n|0)==(c[761]|0)){e=a+(b+4)|0;d=c[e>>2]|0;if((d&3|0)!=3){t=n;h=m;break}c[758]=m;c[e>>2]=d&-2;c[a+(4-k)>>2]=m|1;c[q>>2]=m;return}g=k>>>3;if(k>>>0<256){f=c[a+(8-k)>>2]|0;e=c[a+(12-k)>>2]|0;d=3064+(g<<1<<2)|0;if((f|0)!=(d|0)){if(f>>>0<j>>>0)Da();if((c[f+12>>2]|0)!=(n|0))Da()}if((e|0)==(f|0)){c[756]=c[756]&~(1<<g);t=n;h=m;break}if((e|0)!=(d|0)){if(e>>>0<j>>>0)Da();d=e+8|0;if((c[d>>2]|0)==(n|0))i=d;else Da()}else i=e+8|0;c[f+12>>2]=e;c[i>>2]=f;t=n;h=m;break}i=c[a+(24-k)>>2]|0;f=c[a+(12-k)>>2]|0;do if((f|0)==(n|0)){f=16-k|0;e=a+(f+4)|0;d=c[e>>2]|0;if(!d){e=a+f|0;d=c[e>>2]|0;if(!d){l=0;break}}while(1){f=d+20|0;g=c[f>>2]|0;if(g){d=g;e=f;continue}f=d+16|0;g=c[f>>2]|0;if(!g)break;else{d=g;e=f}}if(e>>>0<j>>>0)Da();else{c[e>>2]=0;l=d;break}}else{g=c[a+(8-k)>>2]|0;if(g>>>0<j>>>0)Da();d=g+12|0;if((c[d>>2]|0)!=(n|0))Da();e=f+8|0;if((c[e>>2]|0)==(n|0)){c[d>>2]=f;c[e>>2]=g;l=f;break}else Da()}while(0);if(i){d=c[a+(28-k)>>2]|0;e=3328+(d<<2)|0;if((n|0)==(c[e>>2]|0)){c[e>>2]=l;if(!l){c[757]=c[757]&~(1<<d);t=n;h=m;break}}else{if(i>>>0<(c[760]|0)>>>0)Da();d=i+16|0;if((c[d>>2]|0)==(n|0))c[d>>2]=l;else c[i+20>>2]=l;if(!l){t=n;h=m;break}}f=c[760]|0;if(l>>>0<f>>>0)Da();c[l+24>>2]=i;d=16-k|0;e=c[a+d>>2]|0;do if(e)if(e>>>0<f>>>0)Da();else{c[l+16>>2]=e;c[e+24>>2]=l;break}while(0);d=c[a+(d+4)>>2]|0;if(d)if(d>>>0<(c[760]|0)>>>0)Da();else{c[l+20>>2]=d;c[d+24>>2]=l;t=n;h=m;break}else{t=n;h=m}}else{t=n;h=m}}else{t=a;h=b}while(0);j=c[760]|0;if(q>>>0<j>>>0)Da();d=a+(b+4)|0;e=c[d>>2]|0;if(!(e&2)){if((q|0)==(c[762]|0)){s=(c[759]|0)+h|0;c[759]=s;c[762]=t;c[t+4>>2]=s|1;if((t|0)!=(c[761]|0))return;c[761]=0;c[758]=0;return}if((q|0)==(c[761]|0)){s=(c[758]|0)+h|0;c[758]=s;c[761]=t;c[t+4>>2]=s|1;c[t+s>>2]=s;return}h=(e&-8)+h|0;g=e>>>3;do if(e>>>0>=256){i=c[a+(b+24)>>2]|0;f=c[a+(b+12)>>2]|0;do if((f|0)==(q|0)){e=a+(b+20)|0;d=c[e>>2]|0;if(!d){e=a+(b+16)|0;d=c[e>>2]|0;if(!d){p=0;break}}while(1){f=d+20|0;g=c[f>>2]|0;if(g){d=g;e=f;continue}f=d+16|0;g=c[f>>2]|0;if(!g)break;else{d=g;e=f}}if(e>>>0<j>>>0)Da();else{c[e>>2]=0;p=d;break}}else{g=c[a+(b+8)>>2]|0;if(g>>>0<j>>>0)Da();d=g+12|0;if((c[d>>2]|0)!=(q|0))Da();e=f+8|0;if((c[e>>2]|0)==(q|0)){c[d>>2]=f;c[e>>2]=g;p=f;break}else Da()}while(0);if(i){d=c[a+(b+28)>>2]|0;e=3328+(d<<2)|0;if((q|0)==(c[e>>2]|0)){c[e>>2]=p;if(!p){c[757]=c[757]&~(1<<d);break}}else{if(i>>>0<(c[760]|0)>>>0)Da();d=i+16|0;if((c[d>>2]|0)==(q|0))c[d>>2]=p;else c[i+20>>2]=p;if(!p)break}e=c[760]|0;if(p>>>0<e>>>0)Da();c[p+24>>2]=i;d=c[a+(b+16)>>2]|0;do if(d)if(d>>>0<e>>>0)Da();else{c[p+16>>2]=d;c[d+24>>2]=p;break}while(0);d=c[a+(b+20)>>2]|0;if(d)if(d>>>0<(c[760]|0)>>>0)Da();else{c[p+20>>2]=d;c[d+24>>2]=p;break}}}else{f=c[a+(b+8)>>2]|0;e=c[a+(b+12)>>2]|0;d=3064+(g<<1<<2)|0;if((f|0)!=(d|0)){if(f>>>0<j>>>0)Da();if((c[f+12>>2]|0)!=(q|0))Da()}if((e|0)==(f|0)){c[756]=c[756]&~(1<<g);break}if((e|0)!=(d|0)){if(e>>>0<j>>>0)Da();d=e+8|0;if((c[d>>2]|0)==(q|0))o=d;else Da()}else o=e+8|0;c[f+12>>2]=e;c[o>>2]=f}while(0);c[t+4>>2]=h|1;c[t+h>>2]=h;if((t|0)==(c[761]|0)){c[758]=h;return}}else{c[d>>2]=e&-2;c[t+4>>2]=h|1;c[t+h>>2]=h}d=h>>>3;if(h>>>0<256){e=d<<1;g=3064+(e<<2)|0;f=c[756]|0;d=1<<d;if(f&d){d=3064+(e+2<<2)|0;e=c[d>>2]|0;if(e>>>0<(c[760]|0)>>>0)Da();else{r=d;s=e}}else{c[756]=f|d;r=3064+(e+2<<2)|0;s=g}c[r>>2]=t;c[s+12>>2]=t;c[t+8>>2]=s;c[t+12>>2]=g;return}d=h>>>8;if(d)if(h>>>0>16777215)g=31;else{r=(d+1048320|0)>>>16&8;s=d<<r;q=(s+520192|0)>>>16&4;s=s<<q;g=(s+245760|0)>>>16&2;g=14-(q|r|g)+(s<<g>>>15)|0;g=h>>>(g+7|0)&1|g<<1}else g=0;d=3328+(g<<2)|0;c[t+28>>2]=g;c[t+20>>2]=0;c[t+16>>2]=0;e=c[757]|0;f=1<<g;if(!(e&f)){c[757]=e|f;c[d>>2]=t;c[t+24>>2]=d;c[t+12>>2]=t;c[t+8>>2]=t;return}d=c[d>>2]|0;a:do if((c[d+4>>2]&-8|0)!=(h|0)){g=h<<((g|0)==31?0:25-(g>>>1)|0);while(1){e=d+16+(g>>>31<<2)|0;f=c[e>>2]|0;if(!f)break;if((c[f+4>>2]&-8|0)==(h|0)){d=f;break a}else{g=g<<1;d=f}}if(e>>>0<(c[760]|0)>>>0)Da();c[e>>2]=t;c[t+24>>2]=d;c[t+12>>2]=t;c[t+8>>2]=t;return}while(0);e=d+8|0;f=c[e>>2]|0;s=c[760]|0;if(!(f>>>0>=s>>>0&d>>>0>=s>>>0))Da();c[f+12>>2]=t;c[e>>2]=t;c[t+8>>2]=f;c[t+12>>2]=d;c[t+24>>2]=0;return}
  9. function Ee(b,e,f,j,k,l,m,n,o,p,q,r){b=b|0;e=e|0;f=f|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=+q;r=r|0;var s=0,t=0,u=0.0,v=0.0,w=0,x=0,y=0.0,z=0.0,A=0.0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0.0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0,Z=0;T=i;i=i+240|0;x=T+224|0;w=T+216|0;C=T+208|0;B=T+200|0;s=T+136|0;N=T+72|0;P=T;Q=T+232|0;R=T+228|0;h[s>>3]=100.0;h[s+8>>3]=100.0;h[s+16>>3]=110.0;h[s+24>>3]=100.0;h[s+32>>3]=110.0;h[s+40>>3]=110.0;h[s+48>>3]=100.0;h[s+56>>3]=110.0;h[N>>3]=+h[p>>3];h[N+8>>3]=+h[p+8>>3];h[N+16>>3]=+h[p+16>>3];h[N+24>>3]=+h[p+24>>3];h[N+32>>3]=+h[p+32>>3];h[N+40>>3]=+h[p+40>>3];h[N+48>>3]=+h[p+48>>3];h[N+56>>3]=+h[p+56>>3];He(s,N,P);A=+h[N>>3];V=+h[N+16>>3];y=A-V;J=+h[N+8>>3];U=+h[N+24>>3];u=J-U;s=~~(y*y+u*u);u=+h[N+32>>3];y=+h[N+48>>3];X=u-y;v=+h[N+40>>3];z=+h[N+56>>3];W=v-z;N=~~(X*X+W*W);u=V-u;v=U-v;t=~~(u*u+v*v);A=y-A;J=z-J;O=~~(A*A+J*J);s=~~(+(((N|0)>(s|0)?N:s)|0)*q*q);t=~~(+(((O|0)>(t|0)?O:t)|0)*q*q);if(!b){p=f;while(1)if((p|0)<(j|0)&($(p,p)|0)<(s|0))p=p<<1;else break;s=f;while(1)if((s|0)<(j|0)&($(s,s)|0)<(t|0))s=s<<1;else break}else{p=f;while(1)if((p|0)<(j|0)&($(p<<2,p)|0)<(s|0))p=p<<1;else break;s=f;while(1)if((s|0)<(j|0)&($(s<<2,s)|0)<(t|0))s=s<<1;else break}O=(p|0)>(j|0)?j:p;M=(s|0)>(j|0)?j:s;L=(O|0)/(f|0)|0;K=(M|0)/(f|0)|0;u=(1.0-q)*.5*10.0;J=q*10.0;N=$(f,f)|0;a:do if(!e){I=N*3|0;p=Wj(I,4)|0;if(!p){Me(3,5472,B);rb(1)}do switch(n|0){case 0:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){t=(($(t,l)|0)+s|0)*3|0;b=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;s=p+(b<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t+2)>>0]|0);s=p+(b+1<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t+1)>>0]|0);b=p+(b+2<<2)|0;c[b>>2]=(c[b>>2]|0)+(d[k+t>>0]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 1:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){t=(($(t,l)|0)+s|0)*3|0;b=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;s=p+(b<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+t>>0]|0);s=p+(b+1<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t+1)>>0]|0);b=p+(b+2<<2)|0;c[b>>2]=(c[b>>2]|0)+(d[k+(t+2)>>0]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 2:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){t=($(t,l)|0)+s<<2;b=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;s=p+(b<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t|2)>>0]|0);s=p+(b+1<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t|1)>>0]|0);b=p+(b+2<<2)|0;c[b>>2]=(c[b>>2]|0)+(d[k+t>>0]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 3:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){t=($(t,l)|0)+s<<2;b=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;s=p+(b<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+t>>0]|0);s=p+(b+1<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t|1)>>0]|0);b=p+(b+2<<2)|0;c[b>>2]=(c[b>>2]|0)+(d[k+(t|2)>>0]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 4:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){t=($(t,l)|0)+s<<2;b=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;s=p+(b<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t|1)>>0]|0);s=p+(b+1<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t|2)>>0]|0);b=p+(b+2<<2)|0;c[b>>2]=(c[b>>2]|0)+(d[k+(t|3)>>0]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 5:case 12:case 13:case 14:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){t=d[k+(($(t,l)|0)+s)>>0]|0;b=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;s=p+(b<<2)|0;c[s>>2]=(c[s>>2]|0)+t;s=p+(b+1<<2)|0;c[s>>2]=(c[s>>2]|0)+t;b=p+(b+2<<2)|0;c[b>>2]=(c[b>>2]|0)+t}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 6:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){t=($(t,l)|0)+s<<2;b=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;s=p+(b<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t|3)>>0]|0);s=p+(b+1<<2)|0;c[s>>2]=(c[s>>2]|0)+(d[k+(t|2)>>0]|0);b=p+(b+2<<2)|0;c[b>>2]=(c[b>>2]|0)+(d[k+(t|1)>>0]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 7:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Z=$(t,l)|0;Y=(s&65534)+Z<<1;V=+((d[k+Y>>0]|0)+-128|0);X=+((d[k+(Y+2)>>0]|0)+-128|0);W=+((d[k+(Z+s<<1|1)>>0]|0)+-16|0)*298.0820007324219;Z=~~(V*516.4110107421875+W)>>8;Y=~~(W-V*100.29100036621094-X*208.1199951171875)>>8;t=~~(W+X*408.5830078125)>>8;Z=(Z|0)>0?Z:0;b=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;s=p+(b<<2)|0;c[s>>2]=((Z|0)<255?Z:255)+(c[s>>2]|0);Y=(Y|0)>0?Y:0;s=p+(b+1<<2)|0;c[s>>2]=((Y|0)<255?Y:255)+(c[s>>2]|0);t=(t|0)>0?t:0;b=p+(b+2<<2)|0;c[b>>2]=((t|0)<255?t:255)+(c[b>>2]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 8:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){t=$(t,l)|0;Y=(s&65534)+t<<1;V=+((d[k+(Y|1)>>0]|0)+-128|0);X=+((d[k+(Y+3)>>0]|0)+-128|0);W=+((d[k+(t+s<<1)>>0]|0)+-16|0)*298.0820007324219;s=~~(W+V*516.4110107421875)>>8;t=~~(W-V*100.29100036621094-X*208.1199951171875)>>8;Y=~~(W+X*408.5830078125)>>8;s=(s|0)>0?s:0;Z=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;b=p+(Z<<2)|0;c[b>>2]=((s|0)<255?s:255)+(c[b>>2]|0);t=(t|0)>0?t:0;b=p+(Z+1<<2)|0;c[b>>2]=((t|0)<255?t:255)+(c[b>>2]|0);Y=(Y|0)>0?Y:0;Z=p+(Z+2<<2)|0;c[Z>>2]=((Y|0)<255?Y:255)+(c[Z>>2]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 9:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=($(t,l)|0)+s<<1;t=d[k+(Y|1)>>0]|0;Z=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;b=p+(Z<<2)|0;c[b>>2]=(t<<3&248|4)+(c[b>>2]|0);Y=d[k+Y>>0]|0;b=p+(Z+1<<2)|0;c[b>>2]=(Y<<5&224|t>>>3&28|2)+(c[b>>2]|0);Z=p+(Z+2<<2)|0;c[Z>>2]=(Y&248|4)+(c[Z>>2]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 10:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=($(t,l)|0)+s<<1;t=d[k+(Y|1)>>0]|0;Z=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;b=p+(Z<<2)|0;c[b>>2]=(t<<2&248|4)+(c[b>>2]|0);Y=d[k+Y>>0]|0;b=p+(Z+1<<2)|0;c[b>>2]=(Y<<5&224|t>>>3&24|4)+(c[b>>2]|0);Z=p+(Z+2<<2)|0;c[Z>>2]=(Y&248|4)+(c[Z>>2]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}case 11:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=($(t,l)|0)+s<<1;Z=(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)|0)*3|0;b=p+(Z<<2)|0;c[b>>2]=(c[b>>2]|0)+((d[k+(Y|1)>>0]|0)&240|8);Y=d[k+Y>>0]|0;b=p+(Z+1<<2)|0;c[b>>2]=(Y<<4&240|8)+(c[b>>2]|0);Z=p+(Z+2<<2)|0;c[Z>>2]=(Y&240|8)+(c[Z>>2]|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}break}default:{Me(3,4615,C);S=278;break a}}while(0);t=$(K,L)|0;if(N){s=0;do{a[r+s>>0]=((c[p+(s<<2)>>2]|0)>>>0)/(t>>>0)|0;s=s+1|0}while((s|0)<(I|0))}Vj(p);p=0}else{p=Wj(N,4)|0;if(!p){Me(3,5472,w);rb(1)}b:do if(n>>>0<2){y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)>0){e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=(($(t,l)|0)+s|0)*3|0;Z=p+(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)<<2)|0;c[Z>>2]=(c[Z>>2]|0)+((((d[k+(Y+1)>>0]|0)+(d[k+Y>>0]|0)+(d[k+(Y+2)>>0]|0)|0)>>>0)/3|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0))}}else{if((n&-2|0)==2){y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)<=0)break;e=(O|0)>0;x=0;while(1){v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=($(t,l)|0)+s<<2;Z=p+(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)<<2)|0;c[Z>>2]=(c[Z>>2]|0)+((((d[k+(Y|1)>>0]|0)+(d[k+Y>>0]|0)+(d[k+(Y|2)>>0]|0)|0)>>>0)/3|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0;if((x|0)>=(M|0))break b}}if((n&-3|0)==4){y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)<=0)break;e=(O|0)>0;x=0;while(1){v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=($(t,l)|0)+s<<2;Z=p+(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)<<2)|0;c[Z>>2]=(c[Z>>2]|0)+((((d[k+(Y|2)>>0]|0)+(d[k+(Y|1)>>0]|0)+(d[k+(Y|3)>>0]|0)|0)>>>0)/3|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0;if((x|0)>=(M|0))break b}}switch(n|0){case 5:case 12:case 13:case 14:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)<=0)break b;e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=d[k+(($(t,l)|0)+s)>>0]|0;Z=p+(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)<<2)|0;c[Z>>2]=(c[Z>>2]|0)+Y}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0));break}case 7:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)<=0)break b;e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=d[k+(($(t,l)|0)+s<<1|1)>>0]|0;Z=p+(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)<<2)|0;c[Z>>2]=(c[Z>>2]|0)+Y}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0));break}case 8:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)<=0)break b;e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=d[k+(($(t,l)|0)+s<<1)>>0]|0;Z=p+(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)<<2)|0;c[Z>>2]=(c[Z>>2]|0)+Y}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0));break}case 9:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)<=0)break b;e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=($(t,l)|0)+s<<1;I=d[k+Y>>0]|0;Y=d[k+(Y|1)>>0]|0;Z=p+(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)<<2)|0;c[Z>>2]=(c[Z>>2]|0)+((((Y<<3&248|4)+(I&248|4)+(I<<5&224|Y>>>3&28|2)|0)>>>0)/3|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0));break}case 10:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)<=0)break b;e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=($(t,l)|0)+s<<1;I=d[k+Y>>0]|0;Y=d[k+(Y|1)>>0]|0;Z=p+(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)<<2)|0;c[Z>>2]=(c[Z>>2]|0)+((((Y<<2&248|4)+(I&248|4)+(I<<5&224|Y>>>3&24|4)|0)>>>0)/3|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0));break}case 11:{y=u+100.0;z=+(M|0);A=+(O|0);B=P+48|0;C=P+56|0;n=P+64|0;D=P+8|0;E=P+16|0;F=P+24|0;G=P+32|0;H=P+40|0;j=(b|0)==1;if((M|0)<=0)break b;e=(O|0)>0;x=0;do{v=y+J*(+(x|0)+.5)/z;if(e){w=0;do{u=y+J*(+(w|0)+.5)/A;q=+h[n>>3]+(+h[B>>3]*u+v*+h[C>>3]);if(q==0.0){S=278;break a}X=(+h[E>>3]+(u*+h[P>>3]+v*+h[D>>3]))/q;g[Q>>2]=X;u=(+h[H>>3]+(u*+h[F>>3]+v*+h[G>>3]))/q;g[R>>2]=u;lf(o,X,u,Q,R)|0;u=+g[Q>>2];if(j){s=((~~(u+1.0)|0)/2|0)<<1;t=((~~(+g[R>>2]+1.0)|0)/2|0)<<1}else{s=~~(u+.5);t=~~(+g[R>>2]+.5)}if((s|0)>-1?(t|0)<(m|0)&((t|0)>-1&(s|0)<(l|0)):0){Y=($(t,l)|0)+s<<1;I=d[k+Y>>0]|0;Z=p+(($((x|0)/(K|0)|0,f)|0)+((w|0)/(L|0)|0)<<2)|0;c[Z>>2]=(c[Z>>2]|0)+((((I<<4&240|8)+(I&240|8)+((d[k+(Y|1)>>0]|0)&240|8)|0)>>>0)/3|0)}w=w+1|0}while((w|0)<(O|0))}x=x+1|0}while((x|0)<(M|0));break}default:{Me(3,4615,x);S=278;break a}}}while(0);s=$(K,L)|0;if(N){t=0;do{a[r+t>>0]=((c[p+(t<<2)>>2]|0)>>>0)/(s>>>0)|0;t=t+1|0}while((t|0)<(N|0))}Vj(p);p=0}while(0);if((S|0)==278){Vj(p);p=-1}i=T;return p|0}function Fe(b,e,f,g,j,k,l){b=b|0;e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;v=i;i=i+32|0;p=v+24|0;o=v+8|0;u=v;a:do if((e+-3|0)>>>0>5){c[f>>2]=-1;c[g>>2]=0;h[j>>3]=-1.0;m=-1}else{c[o>>2]=0;t=e+-1|0;c[o+4>>2]=$(t,e)|0;r=$(e,e)|0;c[o+8>>2]=r+-1;c[o+12>>2]=t;n=a[b+(c[o>>2]|0)>>0]|0;m=(n&255)>0?n:0;n=(n&255)<255?n:-1;s=a[b+(c[o+4>>2]|0)>>0]|0;m=(s&255)>(m&255)?s:m;n=(s&255)<(n&255)?s:n;s=a[b+(c[o+8>>2]|0)>>0]|0;m=(s&255)>(m&255)?s:m;n=(s&255)<(n&255)?s:n;s=a[b+(c[o+12>>2]|0)>>0]|0;m=((s&255)>(m&255)?s:m)&255;n=((s&255)<(n&255)?s:n)&255;if((m-n|0)<30){c[f>>2]=-1;c[g>>2]=0;h[j>>3]=-1.0;m=-2;break}q=(m+n|0)>>>1;a[p>>0]=(d[b+(c[o>>2]|0)>>0]|0)>>>0<q>>>0&1;a[p+1>>0]=(d[b+(c[o+4>>2]|0)>>0]|0)>>>0<q>>>0&1;a[p+2>>0]=(d[b+(c[o+8>>2]|0)>>0]|0)>>>0<q>>>0&1;a[p+3>>0]=(d[b+(c[o+12>>2]|0)>>0]|0)>>>0<q>>>0&1;n=0;while(1){m=n+1|0;if(((a[p+n>>0]|0)==1?(a[p+((m|0)%4|0)>>0]|0)==1:0)?(a[p+((n+2|0)%4|0)>>0]|0)==0:0){m=n;n=10;break}if((m|0)<4)n=m;else{n=12;break}}if((n|0)==10)c[g>>2]=m;else if((n|0)==12?(m|0)==4:0){c[f>>2]=-1;c[g>>2]=0;h[j>>3]=-1.0;m=-3;break}if(!r)s=255;else{m=255;n=0;do{s=b+n|0;p=d[s>>0]|0;o=p-q|0;o=(o|0)<0?0-o|0:o;m=(o|0)<(m|0)?o:m;a[s>>0]=p>>>0<q>>>0&1;n=n+1|0}while((n|0)<(r|0));s=m}switch(c[g>>2]|0){case 0:{if((e|0)>0){r=(e|0)==0;n=0;m=0;g=0;do{p=(g|0)==(t|0);q=$(g,e)|0;if(!r){o=0;do{if((o|g|0)!=0?!(p&((o|0)==0|(o|0)==(t|0))):0){n=fk(n|0,m|0,1)|0;n=(a[b+(o+q)>>0]|0)!=0|n;m=D}o=o+1|0}while((o|0)!=(e|0))}g=g+1|0}while((g|0)<(e|0))}else{n=0;m=0}break}case 1:{if((e|0)>0){r=(e|0)>0;n=0;m=0;g=0;do{p=(g|0)==0;q=(g|0)==(t|0);if(r){o=t;while(1){w=(o|0)==(t|0);if(!(p&w)?!(q&(w|(o|0)==0)):0){n=fk(n|0,m|0,1)|0;n=(a[b+(($(o,e)|0)+g)>>0]|0)!=0|n;m=D}if((o|0)>0)o=o+-1|0;else break}}g=g+1|0}while((g|0)<(e|0))}else{n=0;m=0}break}case 2:{if((e|0)>0){r=(e|0)>0;n=0;m=0;g=t;while(1){q=(g|0)==(t|0)|(g|0)==0;p=$(g,e)|0;if(r){o=t;while(1){if(!(q&(o|0)==(t|0)|(o|g|0)==0)){n=fk(n|0,m|0,1)|0;n=(a[b+(o+p)>>0]|0)!=0|n;m=D}if((o|0)>0)o=o+-1|0;else break}}if((g|0)>0)g=g+-1|0;else break}}else{n=0;m=0}break}case 3:{if((e|0)>0){r=(e|0)>0;n=0;m=0;g=t;while(1){p=(g|0)==(t|0);q=(g|0)==0;if(r){o=0;do{if(!(p&(o|0)==0|(o|g|0)==0|q&(o|0)==(t|0))){n=fk(n|0,m|0,1)|0;n=(a[b+(($(o,e)|0)+g)>>0]|0)!=0|n;m=D}o=o+1|0}while((o|0)<(e|0))}if((g|0)>0)g=g+-1|0;else break}}else{n=0;m=0}break}default:{n=0;m=0}}h[j>>3]=(s|0)>30?1.0:+(s|0)/30.0;switch(k|0){case 259:{w=a[4551+n>>0]|0;k=w<<24>>24;l=u;c[l>>2]=k;c[l+4>>2]=((k|0)<0)<<31>>31;if(w<<24>>24<0){c[f>>2]=-1;h[j>>3]=-1.0;m=-4;break a}break}case 515:{m=a[4423+n>>0]|0;k=m<<24>>24;w=u;c[w>>2]=k;c[w+4>>2]=((k|0)<0)<<31>>31;if(l)c[l>>2]=d[4487+n>>0];if(m<<24>>24<0){c[f>>2]=-1;h[j>>3]=-1.0;m=-4;break a}break}case 772:case 1028:{m=Ie(k,n,m,0,u)|0;if((m|0)<0){c[f>>2]=-1;h[j>>3]=-1.0;m=-4;break a}if((l|0)!=0&(m|0)>0)c[l>>2]=m;break}default:{w=u;c[w>>2]=n;c[w+4>>2]=m}}c[f>>2]=c[u>>2];m=0}while(0);i=v;return m|0}function Ge(a,b,e,f,g,j,k){a=a|0;b=b|0;e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0,D=0.0;C=i;i=i+16|0;l=C+8|0;n=C;a:do if(!a){c[g>>2]=0;c[j>>2]=0;h[k>>3]=-1.0;b=-1}else switch(b|0){case 0:{o=$(f,f)|0;z=o*3|0;A=Uj(o*12|0)|0;if(!A){Me(3,5472,n);rb(1)}if(!o)b=0;else{b=0;l=0;do{b=((d[e+l>>0]|0)^255)+b|0;l=l+1|0}while((l|0)<(z|0))}l=(b|0)/(z|0)|0;if(!o)m=0.0;else{n=0;b=0;do{x=((d[e+n>>0]|0)^255)-l|0;c[A+(n<<2)>>2]=x;b=($(x,x)|0)+b|0;n=n+1|0}while((n|0)<(z|0));m=+(b|0)}y=+P(+m);if(y/(+(f|0)*1.7320508)<15.0){c[g>>2]=0;c[j>>2]=0;h[k>>3]=-1.0;Vj(A);b=-2;break a}v=c[a>>2]|0;w=a+12|0;x=a+16|0;if((v|0)>0){u=c[a+8>>2]|0;s=(o|0)==0;n=-1;t=0;m=0.0;l=-1;b=-1;do{b:while(1){n=n+1|0;switch(c[u+(n<<2)>>2]|0){case 0:break;case 2:break b;default:{B=17;break b}}}if((B|0)==17){B=0;p=n<<2;q=c[x>>2]|0;r=0;do{a=r+p|0;if(s)o=0;else{e=c[(c[w>>2]|0)+(a<<2)>>2]|0;f=0;o=0;do{o=($(c[e+(f<<2)>>2]|0,c[A+(f<<2)>>2]|0)|0)+o|0;f=f+1|0}while((f|0)<(z|0))}D=+(o|0)/+h[q+(a<<3)>>3]/y;a=D>m;l=a?r:l;b=a?n:b;m=a?D:m;r=r+1|0}while((r|0)!=4)}t=t+1|0}while((t|0)<(v|0))}else{m=0.0;l=-1;b=-1}c[j>>2]=l;c[g>>2]=b;h[k>>3]=m;Vj(A);b=0;break a}case 1:{z=$(f,f)|0;A=Uj(z<<2)|0;if(!A){Me(3,5472,l);rb(1)}if(!z)b=0;else{b=0;l=0;do{b=((d[e+l>>0]|0)^255)+b|0;l=l+1|0}while((l|0)<(z|0))}l=(b|0)/(z|0)|0;if(!z)m=0.0;else{n=0;b=0;do{x=((d[e+n>>0]|0)^255)-l|0;c[A+(n<<2)>>2]=x;b=($(x,x)|0)+b|0;n=n+1|0}while((n|0)<(z|0));m=+(b|0)}y=+P(+m);if(y/+(f|0)<15.0){c[g>>2]=0;c[j>>2]=0;h[k>>3]=-1.0;Vj(A);b=-2;break a}v=c[a>>2]|0;w=a+20|0;x=a+24|0;if((v|0)>0){s=c[a+8>>2]|0;t=(z|0)==0;n=-1;u=0;m=0.0;l=-1;b=-1;do{c:while(1){n=n+1|0;switch(c[s+(n<<2)>>2]|0){case 0:break;case 2:break c;default:{B=37;break c}}}if((B|0)==37){B=0;p=n<<2;q=c[x>>2]|0;r=0;do{a=r+p|0;if(t)o=0;else{e=c[(c[w>>2]|0)+(a<<2)>>2]|0;f=0;o=0;do{o=($(c[e+(f<<2)>>2]|0,c[A+(f<<2)>>2]|0)|0)+o|0;f=f+1|0}while((f|0)<(z|0))}D=+(o|0)/+h[q+(a<<3)>>3]/y;a=D>m;l=a?r:l;b=a?n:b;m=a?D:m;r=r+1|0}while((r|0)!=4)}u=u+1|0}while((u|0)<(v|0))}else{m=0.0;l=-1;b=-1}c[j>>2]=l;c[g>>2]=b;h[k>>3]=m;Vj(A);b=0;break a}default:{b=-1;break a}}while(0);i=C;return b|0}function He(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=Re(8,8)|0;f=Re(8,1)|0;g=Re(8,1)|0;i=c[e>>2]|0;j=c[f>>2]|0;k=0;do{p=a+(k<<4)|0;l=k<<4;h[i+(l<<3)>>3]=+h[p>>3];o=a+(k<<4)+8|0;h[i+((l|1)<<3)>>3]=+h[o>>3];h[i+((l|2)<<3)>>3]=1.0;h[i+((l|3)<<3)>>3]=0.0;h[i+((l|4)<<3)>>3]=0.0;h[i+((l|5)<<3)>>3]=0.0;n=b+(k<<4)|0;h[i+((l|6)<<3)>>3]=-(+h[p>>3]*+h[n>>3]);h[i+((l|7)<<3)>>3]=-(+h[o>>3]*+h[n>>3]);h[i+((l|8)<<3)>>3]=0.0;h[i+((l|9)<<3)>>3]=0.0;h[i+((l|10)<<3)>>3]=0.0;h[i+((l|11)<<3)>>3]=+h[p>>3];h[i+((l|12)<<3)>>3]=+h[o>>3];h[i+((l|13)<<3)>>3]=1.0;m=b+(k<<4)+8|0;h[i+((l|14)<<3)>>3]=-(+h[p>>3]*+h[m>>3]);h[i+((l|15)<<3)>>3]=-(+h[o>>3]*+h[m>>3]);l=k<<1;h[j+(l<<3)>>3]=+h[n>>3];h[j+((l|1)<<3)>>3]=+h[m>>3];k=k+1|0}while((k|0)!=4);_e(e)|0;Xe(g,e,f)|0;p=c[g>>2]|0;h[d>>3]=+h[p>>3];h[d+8>>3]=+h[p+8>>3];h[d+16>>3]=+h[p+16>>3];p=c[g>>2]|0;h[d+24>>3]=+h[p+24>>3];h[d+32>>3]=+h[p+32>>3];h[d+40>>3]=+h[p+40>>3];p=c[g>>2]|0;h[d+48>>3]=+h[p+48>>3];h[d+56>>3]=+h[p+56>>3];h[d+64>>3]=1.0;We(e)|0;We(f)|0;We(g)|0;return}function Ie(b,e,f,g,h){b=b|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0;I=i;i=i+2320|0;k=I+2304|0;y=I+864|0;u=I+784|0;H=I+704|0;w=I+624|0;v=I+548|0;G=I+40|0;E=I;switch(b|0){case 772:{g=9;j=1;l=3;break}case 1028:{g=5;j=2;l=3;break}case 2830:{A=900;s=1472;C=64;F=120;z=127;B=g;j=9;l=6;break}default:f=-1}if((l|0)==3){b=0;while(1){a[k+b>>0]=e&1;e=hk(e|0,f|0,1)|0;b=b+1|0;if((b|0)==13)break;else f=D}A=840;s=1408;C=g;F=13;z=15;B=k;l=6}do if((l|0)==6){r=j<<1;k=1;f=0;while(1){g=v+(k<<2)|0;c[g>>2]=0;b=0;e=0;do{if(a[B+e>>0]|0){b=b^c[A+((($(e,k)|0)%(z|0)|0)<<2)>>2];c[g>>2]=b}e=e+1|0}while((e|0)<(F|0));f=(b|0)==0?f:1;c[g>>2]=c[s+(b<<2)>>2];if((k|0)<(r|0))k=k+1|0;else break}x=(f|0)!=0;if(x){c[u>>2]=0;f=c[v+4>>2]|0;c[u+4>>2]=f;c[y>>2]=0;c[y+72>>2]=1;if((r|0)>1){b=1;do{c[y+(b<<2)>>2]=-1;c[y+72+(b<<2)>>2]=0;b=b+1|0}while((b|0)<(r|0))}c[H>>2]=0;c[H+4>>2]=0;c[w>>2]=-1;c[w+4>>2]=0;p=0;q=0;while(1){g=q;q=q+1|0;o=u+(q<<2)|0;if((f|0)==-1){k=g+2|0;c[H+(k<<2)>>2]=p;if((p|0)<0)n=p;else{f=0;while(1){o=y+(q*72|0)+(f<<2)|0;n=c[o>>2]|0;c[y+(k*72|0)+(f<<2)>>2]=n;c[o>>2]=c[s+(n<<2)>>2];if((f|0)<(p|0))f=f+1|0;else{n=p;break}}}}else{b=g;while(1){f=(b|0)>0;if(f&(c[u+(b<<2)>>2]|0)==-1)b=b+-1|0;else break}if(f){e=b;do{f=e;e=e+-1|0;if((c[u+(e<<2)>>2]|0)!=-1)b=(c[w+(b<<2)>>2]|0)<(c[w+(e<<2)>>2]|0)?e:b}while((f|0)>1)}e=H+(b<<2)|0;m=q-b|0;n=m+(c[e>>2]|0)|0;k=g+2|0;n=(p|0)>(n|0)?p:n;c[H+(k<<2)>>2]=n;f=0;do{c[y+(k*72|0)+(f<<2)>>2]=0;f=f+1|0}while((f|0)<(r|0));f=c[e>>2]|0;e=u+(b<<2)|0;if((f|0)>=0){l=0;while(1){g=c[y+(b*72|0)+(l<<2)>>2]|0;if((g|0)!=-1)c[y+(k*72|0)+(m+l<<2)>>2]=c[A+(((g+z+(c[o>>2]|0)-(c[e>>2]|0)|0)%(z|0)|0)<<2)>>2];if((l|0)<(f|0))l=l+1|0;else break}}if((p|0)>=0){f=0;while(1){o=y+(q*72|0)+(f<<2)|0;m=c[o>>2]|0;l=y+(k*72|0)+(f<<2)|0;c[l>>2]=c[l>>2]^m;c[o>>2]=c[s+(m<<2)>>2];if((f|0)<(p|0))f=f+1|0;else break}}}c[w+(k<<2)>>2]=q-n;if((q|0)>=(r|0))break;f=c[v+(k<<2)>>2]|0;if((f|0)==-1)f=0;else f=c[A+(f<<2)>>2]|0;g=u+(k<<2)|0;c[g>>2]=f;if((n|0)>=1){e=1;while(1){b=c[v+(k-e<<2)>>2]|0;if((b|0)!=-1?(t=c[y+(k*72|0)+(e<<2)>>2]|0,(t|0)!=0):0){f=f^c[A+((((c[s+(t<<2)>>2]|0)+b|0)%(z|0)|0)<<2)>>2];c[g>>2]=f}if((e|0)<(n|0))e=e+1|0;else break}}f=c[s+(f<<2)>>2]|0;c[g>>2]=f;if((n|0)>(j|0))break;else p=n}if((n|0)>(j|0)){f=-1;break}if((n|0)>=0){f=0;while(1){w=y+(k*72|0)+(f<<2)|0;c[w>>2]=c[s+(c[w>>2]<<2)>>2];if((f|0)<(n|0))f=f+1|0;else break}}if((n|0)>=1){f=1;while(1){c[E+(f<<2)>>2]=c[y+(k*72|0)+(f<<2)>>2];if((f|0)<(n|0))f=f+1|0;else break}}l=(n|0)<1;f=0;m=1;do{if(l)b=1;else{j=1;b=1;while(1){e=E+(j<<2)|0;g=c[e>>2]|0;if((g|0)!=-1){y=(g+j|0)%(z|0)|0;c[e>>2]=y;b=c[A+(y<<2)>>2]^b}if((j|0)<(n|0))j=j+1|0;else break}}if(!b){c[G+(f<<2)>>2]=z-m;f=f+1|0}m=m+1|0}while((z|0)>=(m|0));if((f|0)!=(n|0)){f=-1;break}if((n|0)>0){f=0;do{E=B+(c[G+(f<<2)>>2]|0)|0;a[E>>0]=d[E>>0]^1;f=f+1|0}while((f|0)<(n|0))}}else k=0;b=h;c[b>>2]=0;c[b+4>>2]=0;b=1;e=0;g=0;j=0;f=F-C|0;while(1){G=ok(d[B+f>>0]|0,0,b|0,e|0)|0;g=gk(G|0,D|0,g|0,j|0)|0;j=D;G=h;c[G>>2]=g;c[G+4>>2]=j;b=fk(b|0,e|0,1)|0;f=f+1|0;if((f|0)>=(F|0))break;else e=D}if(x)f=c[H+(k<<2)>>2]|0;else f=0}while(0);i=I;return f|0}function Je(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0;A=i;i=i+32|0;z=A+24|0;g=A+16|0;d=A+8|0;do if(a){if(!b){Me(3,4674,d);d=-1;break}y=a+8|0;f=c[a+4>>2]|0;a:do if((f|0)>0){e=c[y>>2]|0;d=0;do{if(!(c[e+(d<<2)>>2]|0))break a;d=d+1|0}while((d|0)<(f|0))}else d=0;while(0);if((d|0)!=(f|0)){x=Aj(b)|0;if(!x){Me(3,4719,g);d=-1;break}r=a+28|0;s=d<<2;t=a+12|0;u=a+20|0;v=a+16|0;w=a+24|0;f=Gj(x,4742)|0;e=0;b:while(1){q=e+s|0;p=0;b=0;do{n=(p|0)==0;o=(p|0)==2;g=c[r>>2]|0;if((g|0)>0){m=0;do{if((g|0)>0){l=0;do{if(!f){e=17;break b}g=qj(f)|0;f=Gj(0,4742)|0;g=255-g|0;k=((($(c[r>>2]|0,m)|0)+l|0)*3|0)+p|0;c[(c[(c[t>>2]|0)+(q<<2)>>2]|0)+(k<<2)>>2]=g;k=($(c[r>>2]|0,m)|0)+l|0;j=c[(c[u>>2]|0)+(q<<2)>>2]|0;k=j+(k<<2)|0;if(!n){c[k>>2]=(c[k>>2]|0)+g;if(o){k=j+(($(c[r>>2]|0,m)|0)+l<<2)|0;c[k>>2]=(c[k>>2]|0)/3|0}}else c[k>>2]=g;b=g+b|0;l=l+1|0;g=c[r>>2]|0}while((l|0)<(g|0))}m=m+1|0}while((m|0)<(g|0))}p=p+1|0}while((p|0)<3);g=c[r>>2]|0;l=(b|0)/($(g*3|0,g)|0)|0;if(($(g*3|0,g)|0)>0){j=c[(c[t>>2]|0)+(q<<2)>>2]|0;k=0;b=0;do{p=j+(k<<2)|0;g=(c[p>>2]|0)-l|0;c[p>>2]=g;b=($(g,g)|0)+b|0;k=k+1|0;g=c[r>>2]|0}while((k|0)<($(g*3|0,g)|0))}else b=0;B=+P(+(+(b|0)));h[(c[v>>2]|0)+(q<<3)>>3]=B==0.0?1.0e-07:B;if(!($(g,g)|0))b=0;else{g=c[(c[u>>2]|0)+(q<<2)>>2]|0;j=0;b=0;do{o=g+(j<<2)|0;p=(c[o>>2]|0)-l|0;c[o>>2]=p;b=($(p,p)|0)+b|0;j=j+1|0;p=c[r>>2]|0}while((j|0)<($(p,p)|0))}B=+P(+(+(b|0)));h[(c[w>>2]|0)+(q<<3)>>3]=B==0.0?1.0e-07:B;e=e+1|0;if((e|0)>=4){e=32;break}}if((e|0)==17){Me(3,4747,z);Vj(x);d=-1;break}else if((e|0)==32){Vj(x);c[(c[y>>2]|0)+(d<<2)>>2]=1;c[a>>2]=(c[a>>2]|0)+1;break}}else d=-1}else{Me(3,4649,A);d=-1}while(0);i=A;return d|0}function Ke(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0;k=i;i=i+32|0;j=k+16|0;h=k+8|0;e=k;g=_i(d,4854)|0;do if(g){dj(g,0,2)|0;e=gj(g)|0;dj(g,0,0)|0;f=Uj(e+1|0)|0;if(!f){Me(3,5472,h);Wi(g)|0;e=-1;break}h=aj(f,e,1,g)|0;Wi(g)|0;if(!h){c[j>>2]=d;Me(3,4820,j);Vj(f);e=-1;break}else{a[f+e>>0]=0;e=Je(b,f)|0;Vj(f);break}}else{c[e>>2]=d;Me(3,4774,e);e=-1}while(0);i=k;return e|0}function Le(a,b){a=a|0;b=b|0;b=(c[a+8>>2]|0)+(b<<2)|0;if(!(c[b>>2]|0))b=-1;else{c[b>>2]=0;c[a>>2]=(c[a>>2]|0)+-1;b=1}return b|0}function Me(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0;j=i;i=i+32|0;h=j+16|0;f=j;c[h>>2]=0;if(((d|0)!=0&(c[496]|0)<=(b|0)?(a[d>>0]|0)!=0:0)?(c[f>>2]=e,g=lj(h,d,f)|0,(g|0)>-1):0){f=c[497]|0;do if(f){if(!(c[498]|0)){Wb[f&15](c[h>>2]|0);break}e=gb()|0;b=c[500]|0;if((e|0)==(c[499]|0)){if((b|0)>0){Wb[f&15](c[502]|0);c[500]=0;f=c[497]|0}Wb[f&15](c[h>>2]|0);break}f=c[501]|0;if((b|0)<(f|0)){d=(c[502]|0)+b|0;if((g|0)<(-3-b+f|0)){yj(d,c[h>>2]|0)|0;c[500]=(c[500]|0)+g;break}else{a[d>>0]=46;a[d+1>>0]=46;a[d+2>>0]=46;a[d+3>>0]=0;c[500]=c[501];break}}}else $i(c[h>>2]|0,c[659]|0)|0;while(0);Vj(c[h>>2]|0)}i=j;return}function Ne(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,i=0;i=0;do{d=a+(i<<5)|0;e=a+(i<<5)+8|0;f=a+(i<<5)+16|0;g=0;do{h[c+(i<<5)+(g<<3)>>3]=+h[d>>3]*+h[b+(g<<3)>>3]+ +h[e>>3]*+h[b+32+(g<<3)>>3]+ +h[f>>3]*+h[b+64+(g<<3)>>3];g=g+1|0}while((g|0)!=4);g=c+(i<<5)+24|0;h[g>>3]=+h[a+(i<<5)+24>>3]+ +h[g>>3];i=i+1|0}while((i|0)!=3);return 0}function Oe(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0;j=Re(4,4)|0;d=c[j>>2]|0;e=c[j>>2]|0;f=c[j>>2]|0;g=c[j>>2]|0;i=0;do{k=i<<2;h[d+(k<<3)>>3]=+h[a+(i<<5)>>3];h[e+(1+k<<3)>>3]=+h[a+(i<<5)+8>>3];h[f+(2+k<<3)>>3]=+h[a+(i<<5)+16>>3];h[g+(3+k<<3)>>3]=+h[a+(i<<5)+24>>3];i=i+1|0}while((i|0)!=3);d=c[j>>2]|0;e=d+96|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[e+20>>2]=0;h[d+120>>3]=1.0;_e(j)|0;d=c[j>>2]|0;e=c[j>>2]|0;f=c[j>>2]|0;g=c[j>>2]|0;i=0;do{k=i<<2;h[b+(i<<5)>>3]=+h[d+(k<<3)>>3];h[b+(i<<5)+8>>3]=+h[e+(1+k<<3)>>3];h[b+(i<<5)+16>>3]=+h[f+(2+k<<3)>>3];h[b+(i<<5)+24>>3]=+h[g+(3+k<<3)>>3];i=i+1|0}while((i|0)!=3);We(j)|0;return 0}function Pe(a){a=a|0;switch(a|0){case 1:case 0:{a=3;break}case 6:case 4:case 3:case 2:{a=4;break}case 14:case 13:case 12:case 5:{a=1;break}case 11:case 10:case 9:case 8:case 7:{a=2;break}default:a=0}return a|0}function Qe(b,c,d,e){b=b|0;c=c|0;d=d|0;e=e|0;var f=0;do if((b|0)!=0&(c|0)!=0&(d|0)!=0){f=Ej(c,47)|0;if(!f){a[b>>0]=0;break}f=f+((e|0)!=0&1)-c|0;if((f+1|0)>>>0<=d>>>0){Dj(b,c,f)|0;a[b+f>>0]=0}else b=0}else b=0;while(0);return b|0}function Re(a,b){a=a|0;b=b|0;var d=0,e=0;d=Uj(12)|0;do if(d){e=Uj($(a<<3,b)|0)|0;c[d>>2]=e;if(!e){Vj(d);d=0;break}else{c[d+4>>2]=a;c[d+8>>2]=b;break}}else d=0;while(0);return d|0}function Se(a){a=a|0;var b=0;b=Re(c[a+4>>2]|0,c[a+8>>2]|0)|0;if(b){if((Ve(b,a)|0)<0){We(b)|0;b=0}}else b=0;return b|0}function Te(a,b){a=a|0;b=b|0;var d=0;d=Re(c[a+4>>2]|0,c[b+8>>2]|0)|0;if(d){if((Xe(d,a,b)|0)<0){We(d)|0;d=0}}else d=0;return d|0}function Ue(a){a=a|0;var b=0;b=Re(c[a+8>>2]|0,c[a+4>>2]|0)|0;if(b){if(($e(b,a)|0)<0){We(b)|0;b=0}}else b=0;return b|0}function Ve(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0;d=c[a+4>>2]|0;if((d|0)==(c[b+4>>2]|0)?(j=c[a+8>>2]|0,(j|0)==(c[b+8>>2]|0)):0)if((d|0)>0){e=(j|0)>0;l=0;do{f=$(j,l)|0;if(e){g=c[b>>2]|0;i=c[a>>2]|0;k=0;do{m=f+k|0;h[i+(m<<3)>>3]=+h[g+(m<<3)>>3];k=k+1|0}while((k|0)<(j|0))}l=l+1|0}while((l|0)<(d|0));d=0}else d=0;else d=-1;return d|0}function We(a){a=a|0;if(a){Vj(c[a>>2]|0);Vj(a)}return 0}function Xe(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;n=c[b+8>>2]|0;if(((n|0)==(c[d+4>>2]|0)?(r=c[a+4>>2]|0,(r|0)==(c[b+4>>2]|0)):0)?(o=c[a+8>>2]|0,(o|0)==(c[d+8>>2]|0)):0){s=(o|0)>0?o:0;if((r|0)>0){p=(o|0)>0;q=(n|0)>0;k=c[a>>2]|0;m=0;while(1){a=$(n,m)|0;if(p){f=0;l=k;while(1){h[l>>3]=0.0;if(q){e=0.0;g=0;i=(c[b>>2]|0)+(a<<3)|0;j=(c[d>>2]|0)+(f<<3)|0;while(1){e=e+ +h[i>>3]*+h[j>>3];h[l>>3]=e;g=g+1|0;if((g|0)>=(n|0))break;else{i=i+8|0;j=j+(o<<3)|0}}}f=f+1|0;if((f|0)>=(o|0))break;else l=l+8|0}}m=m+1|0;if((m|0)>=(r|0)){a=0;break}else k=k+(s<<3)|0}}else a=0}else a=-1;return a|0}function Ye(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0.0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0,t=0,u=0;q=c[a+4>>2]|0;s=c[a+8>>2]|0;f=(q|0)<(s|0)?q:s;a:do if(((((!((q|0)<2|(s|0)<2)?(c[b+8>>2]|0)==(s|0):0)?(c[b+4>>2]|0)==(f|0):0)?(t=d+4|0,(c[t>>2]|0)==(f|0)):0)?(g=e+4|0,(c[g>>2]|0)==(s|0)):0)?(u=Se(a)|0,(u|0)!=0):0){r=+P(+(+(q|0)));o=c[u+4>>2]|0;p=c[u+8>>2]|0;if(!((o|0)<1|(p|0)<1)?(c[g>>2]|0)==(p|0):0){if(p){f=c[e>>2]|0;a=0;do{h[f+(a<<3)>>3]=0.0;a=a+1|0}while((a|0)!=(p|0))}n=c[u>>2]|0;if(o){f=(p|0)==0;a=0;j=n;while(1){if(!f){g=0;k=j;l=c[e>>2]|0;while(1){h[l>>3]=+h[k>>3]+ +h[l>>3];g=g+1|0;if((g|0)==(p|0))break;else{k=k+8|0;l=l+8|0}}}a=a+1|0;if((a|0)==(o|0))break;else j=j+(p<<3)|0}}i=+(o|0);if(p){f=c[e>>2]|0;a=0;do{m=f+(a<<3)|0;h[m>>3]=+h[m>>3]/i;a=a+1|0}while((a|0)!=(p|0))}l=(p|0)>0?p:0;if((o|0)>0){f=(p|0)>0;a=0;j=n;while(1){if(f){g=0;k=j;m=c[e>>2]|0;while(1){h[k>>3]=+h[k>>3]-+h[m>>3];g=g+1|0;if((g|0)>=(p|0))break;else{k=k+8|0;m=m+8|0}}}a=a+1|0;if((a|0)>=(o|0))break;else j=j+(l<<3)|0}}f=$(s,q)|0;if((f|0)>0){a=0;do{e=n+(a<<3)|0;h[e>>3]=+h[e>>3]/r;a=a+1|0}while((a|0)<(f|0))}f=Ze(u,b,d)|0;We(u)|0;j=c[t>>2]|0;if((j|0)>0){a=c[d>>2]|0;g=0;i=0.0;do{i=i+ +h[a+(g<<3)>>3];g=g+1|0}while((g|0)<(j|0))}else i=0.0;if((j|0)<=0)break;a=c[d>>2]|0;g=0;while(1){d=a+(g<<3)|0;h[d>>3]=+h[d>>3]/i;g=g+1|0;if((g|0)>=(j|0))break a}}We(u)|0;f=-1}else f=-1;while(0);return f|0}function Ze(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,j=0,k=0.0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0.0,v=0.0,w=0,x=0.0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,Q=0,R=0,S=0,T=0,U=0,V=0.0,W=0.0,X=0.0,Y=0,Z=0;U=i;i=i+16|0;w=U;F=a+4|0;I=c[F>>2]|0;J=a+8|0;K=c[J>>2]|0;S=(K|0)<(I|0)?K:I;a:do if(((!((I|0)<2|(K|0)<2)?(R=b+8|0,(c[R>>2]|0)==(K|0)):0)?(L=b+4|0,(c[L>>2]|0)==(S|0)):0)?(M=d+4|0,(c[M>>2]|0)==(S|0)):0){T=Re(S,S)|0;N=T+4|0;if((c[N>>2]|0)==(S|0)?(Q=T+8|0,(c[Q>>2]|0)==(S|0)):0){G=(I|0)<(K|0);s=c[F>>2]|0;t=c[J>>2]|0;if(G){if((S|0)!=(s|0)){We(T)|0;e=-1;break}g=c[T>>2]|0;if((S|0)>0){m=(S|0)==0;j=(t|0)>0;n=0;r=g;while(1){l=$(n,t)|0;if(!m){p=0;s=r;while(1){if((p|0)>=(n|0)){e=c[a>>2]|0;h[s>>3]=0.0;if(j){k=0.0;o=e+(l<<3)|0;e=e+(($(p,t)|0)<<3)|0;f=0;while(1){k=k+ +h[o>>3]*+h[e>>3];h[s>>3]=k;f=f+1|0;if((f|0)>=(t|0))break;else{o=o+8|0;e=e+8|0}}}}else h[s>>3]=+h[g+(($(p,S)|0)+n<<3)>>3];p=p+1|0;if((p|0)==(S|0))break;else s=s+8|0}}n=n+1|0;if((n|0)>=(S|0))break;else r=r+(S<<3)|0}}}else{if((S|0)!=(t|0)){We(T)|0;e=-1;break}g=c[T>>2]|0;if((S|0)>0){l=(S|0)==0;j=(s|0)>0;m=0;p=g;while(1){if(!l){o=0;r=p;while(1){if((o|0)>=(m|0)){e=c[a>>2]|0;h[r>>3]=0.0;if(j){k=0.0;n=e+(m<<3)|0;e=e+(o<<3)|0;f=0;while(1){k=k+ +h[n>>3]*+h[e>>3];h[r>>3]=k;f=f+1|0;if((f|0)>=(s|0))break;else{n=n+(S<<3)|0;e=e+(S<<3)|0}}}}else h[r>>3]=+h[g+(($(o,S)|0)+m<<3)>>3];o=o+1|0;if((o|0)==(S|0))break;else r=r+8|0}}m=m+1|0;if((m|0)>=(S|0))break;else p=p+(S<<3)|0}}}do if(((S|0)>=2?(c[M>>2]|0)==(S|0):0)?(H=nf(S)|0,(H|0)!=0):0){E=S+-1|0;c[w+4>>2]=E;c[w>>2]=(c[H>>2]|0)+8;if((rf(T,d,w)|0)<0){of(H)|0;break}B=c[H>>2]|0;h[B>>3]=0.0;if((E|0)>0){C=(S|0)==0;D=E;do{f=D;while(1){if((f|0)<=0)break;v=+O(+(+h[B+(f<<3)>>3]));e=f+-1|0;A=c[d>>2]|0;x=+O(+(+h[A+(e<<3)>>3]));if(v>(x+ +O(+(+h[A+(f<<3)>>3])))*1.0e-06)f=e;else break}y=D;D=D+-1|0;b:do if((f|0)!=(y|0)){o=B+(y<<3)|0;p=B+(f+1<<3)|0;r=(f|0)<(y|0);z=0;do{if((z|0)>99)break b;z=z+1|0;s=c[d>>2]|0;t=s+(D<<3)|0;w=s+(y<<3)|0;k=+h[w>>3];q=(+h[t>>3]-k)*.5;u=+h[o>>3];u=u*u;v=+P(+(u+q*q));if(r){A=f;q=+h[s+(f<<3)>>3]-k+u/(q+(q<0.0?-v:v));u=+h[p>>3];while(1){k=+O(+q);do if(!(k>=+O(+u))){v=-q/u;x=1.0/+P(+(v*v+1.0));v=v*x}else{if(!(k>1.0e-16)){v=1.0;x=0.0;break}k=-u/q;x=1.0/+P(+(k*k+1.0));v=x;x=k*x}while(0);j=s+(A<<3)|0;X=+h[j>>3];n=A;A=A+1|0;l=s+(A<<3)|0;W=+h[l>>3];k=X-W;m=B+(A<<3)|0;V=x*(x*k+v*2.0*+h[m>>3]);h[j>>3]=X-V;h[l>>3]=W+V;if((n|0)>(f|0)){l=B+(n<<3)|0;h[l>>3]=v*+h[l>>3]-u*x}X=+h[m>>3];h[m>>3]=X+x*(v*k-x*2.0*X);j=$(n,S)|0;l=$(A,S)|0;if(C)k=u;else{e=c[T>>2]|0;g=0;do{Z=e+(g+j<<3)|0;q=+h[Z>>3];Y=e+(g+l<<3)|0;k=+h[Y>>3];h[Z>>3]=v*q-x*k;h[Y>>3]=x*q+v*k;g=g+1|0}while((g|0)!=(S|0))}if((n|0)<(D|0)){q=+h[m>>3];Z=B+(n+2<<3)|0;k=+h[Z>>3];h[Z>>3]=v*k;k=-(x*k)}if((A|0)>=(y|0))break;else u=k}}W=+O(+(+h[o>>3]));X=+O(+(+h[t>>3]))}while(W>(X+ +O(+(+h[w>>3])))*1.0e-06)}while(0)}while((y|0)>1)}if(E){l=c[d>>2]|0;m=c[T>>2]|0;n=(S|0)==0;o=0;do{g=l+(o<<3)|0;q=+h[g>>3];j=o;o=o+1|0;if((o|0)<(S|0)){e=j;f=o;k=q;do{X=+h[l+(f<<3)>>3];Z=X>k;k=Z?X:k;e=Z?f:e;f=f+1|0}while((f|0)<(S|0))}else{e=j;k=q}h[l+(e<<3)>>3]=q;h[g>>3]=k;if(!n){g=0;f=m+(($(e,S)|0)<<3)|0;e=m+(($(j,S)|0)<<3)|0;while(1){X=+h[f>>3];h[f>>3]=+h[e>>3];h[e>>3]=X;g=g+1|0;if((g|0)==(S|0))break;else{f=f+8|0;e=e+8|0}}}}while((o|0)!=(E|0))}of(H)|0;c:do if(!G){g=c[b>>2]|0;p=(I|0)>(K|0)?K:I;d:do if((S|0)>0){m=c[d>>2]|0;n=(p|0)==0;e=0;o=c[T>>2]|0;do{if(+h[m+(e<<3)>>3]<1.0e-16)break d;if(!n){f=0;j=o;l=g;while(1){h[l>>3]=+h[j>>3];f=f+1|0;if((f|0)==(p|0))break;else{j=j+8|0;l=l+8|0}}}o=o+(p<<3)|0;g=g+(p<<3)|0;e=e+1|0}while((e|0)<(S|0))}else e=0;while(0);n=(p|0)>0?p:0;if((e|0)<(S|0)){l=c[d>>2]|0;m=(S|0)>0;while(1){h[l+(e<<3)>>3]=0.0;if(m){f=0;j=g;while(1){h[j>>3]=0.0;f=f+1|0;if((f|0)>=(S|0))break;else j=j+8|0}}e=e+1|0;if((e|0)>=(S|0))break;else g=g+(n<<3)|0}}}else{w=c[F>>2]|0;t=c[J>>2]|0;do if(!((w|0)<1|(t|0)<1)){if((c[N>>2]|0)!=(w|0))break;if((c[Q>>2]|0)!=(w|0))break;if((c[L>>2]|0)!=(w|0))break;if((c[R>>2]|0)!=(t|0))break;if((c[M>>2]|0)!=(w|0))break;f=c[b>>2]|0;e:do if((w|0)>0){p=c[d>>2]|0;s=(t|0)==0;r=(w|0)==0;e=0;do{k=+h[p+(e<<3)>>3];if(k<1.0e-16)break e;q=1.0/+P(+(+O(+k)));m=$(e,w)|0;if(!s){n=0;o=f;while(1){if(r)k=0.0;else{g=0;j=(c[T>>2]|0)+(m<<3)|0;l=(c[a>>2]|0)+(n<<3)|0;k=0.0;while(1){k=k+ +h[j>>3]*+h[l>>3];g=g+1|0;if((g|0)==(w|0))break;else{j=j+8|0;l=l+(t<<3)|0}}}h[o>>3]=q*k;n=n+1|0;if((n|0)==(t|0))break;else o=o+8|0}}f=f+(t<<3)|0;e=e+1|0}while((e|0)<(w|0))}else e=0;while(0);n=(t|0)>0?t:0;if((e|0)>=(w|0))break c;l=c[d>>2]|0;m=(t|0)>0;g=f;while(1){h[l+(e<<3)>>3]=0.0;if(m){f=0;j=g;while(1){h[j>>3]=0.0;f=f+1|0;if((f|0)>=(t|0))break;else j=j+8|0}}e=e+1|0;if((e|0)>=(w|0))break c;else g=g+(n<<3)|0}}while(0);We(T)|0;e=-1;break a}while(0);We(T)|0;e=0;break a}while(0);We(T)|0;e=-1;break}We(T)|0;e=-1}else e=-1;while(0);i=U;return e|0}function _e(a){a=a|0;var b=0,d=0,e=0,f=0.0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0;v=i;i=i+2e3|0;u=v;b=c[a>>2]|0;t=c[a+4>>2]|0;a:do if((t|0)<=500){switch(t|0){case 0:{b=0;break a}case 1:{h[b>>3]=1.0/+h[b>>3];break a}default:{}}if((t|0)>0){a=0;do{c[u+(a<<2)>>2]=a;a=a+1|0}while((a|0)<(t|0))}s=b+(t+-1<<3)|0;if((t|0)>0){m=(t|0)==0;p=(t|0)==1;o=(t|0)==0;n=(t|0)==1;q=s;a=0;r=0;while(1){l=b+(($(r,t)|0)<<3)|0;if((r|0)<(t|0)){e=r;f=0.0;d=l;while(1){w=+O(+(+h[d>>3]));k=f<w;a=k?e:a;f=k?w:f;e=e+1|0;if((e|0)>=(t|0))break;else d=d+(t<<3)|0}}else f=0.0;if(f<=1.0e-10){b=0;break a}g=u+(a<<2)|0;j=c[g>>2]|0;k=u+(r<<2)|0;c[g>>2]=c[k>>2];c[k>>2]=j;if(!m){d=0;e=b+(($(a,t)|0)<<3)|0;g=l;while(1){w=+h[e>>3];h[e>>3]=+h[g>>3];h[g>>3]=w;d=d+1|0;if((d|0)==(t|0))break;else{e=e+8|0;g=g+8|0}}}f=+h[l>>3];if(!p){d=1;e=l;do{k=e;e=e+8|0;h[k>>3]=+h[e>>3]/f;d=d+1|0}while((d|0)!=(t|0))}h[q>>3]=1.0/f;if(!o){g=0;j=s;while(1){if((g|0)!=(r|0)){d=b+(($(g,t)|0)<<3)|0;f=+h[d>>3];if(!n){k=1;e=l;while(1){x=d;d=d+8|0;h[x>>3]=+h[d>>3]-f*+h[e>>3];k=k+1|0;if((k|0)==(t|0))break;else e=e+8|0}}h[j>>3]=-(f*+h[q>>3])}g=g+1|0;if((g|0)==(t|0))break;else j=j+(t<<3)|0}}r=r+1|0;if((r|0)>=(t|0))break;else q=q+(t<<3)|0}}if((t|0)>0){g=(t|0)>0;j=0;do{a=u+(j<<2)|0;b:do if((j|0)<(t|0)){d=j;do{if((c[a>>2]|0)==(j|0))break b;d=d+1|0;a=u+(d<<2)|0}while((d|0)<(t|0))}else d=j;while(0);c[a>>2]=c[u+(j<<2)>>2];if(g){e=0;a=b+(d<<3)|0;d=b+(j<<3)|0;while(1){w=+h[a>>3];h[a>>3]=+h[d>>3];h[d>>3]=w;e=e+1|0;if((e|0)>=(t|0))break;else{a=a+(t<<3)|0;d=d+(t<<3)|0}}}j=j+1|0}while((j|0)<(t|0))}}else b=0;while(0);i=v;return ((b|0)==0)<<31>>31|0}function $e(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,i=0,j=0,k=0,l=0;i=c[a+4>>2]|0;if((i|0)==(c[b+8>>2]|0)?(k=c[a+8>>2]|0,(k|0)==(c[b+4>>2]|0)):0){l=(k|0)>0?k:0;if((i|0)>0){j=(k|0)>0;e=c[a>>2]|0;g=0;while(1){if(j){a=0;d=(c[b>>2]|0)+(g<<3)|0;f=e;while(1){h[f>>3]=+h[d>>3];a=a+1|0;if((a|0)>=(k|0))break;else{d=d+(i<<3)|0;f=f+8|0}}}g=g+1|0;if((g|0)>=(i|0)){a=0;break}else e=e+(l<<3)|0}}else a=0}else a=-1;return a|0}function af(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,i=0;f=+(b|0)/+(c[a>>2]|0);g=+(d|0)/+(c[a+4>>2]|0);c[e>>2]=b;c[e+4>>2]=d;b=0;do{h[e+8+(b<<3)>>3]=f*+h[a+8+(b<<3)>>3];h[e+40+(b<<3)>>3]=g*+h[a+40+(b<<3)>>3];h[e+72+(b<<3)>>3]=+h[a+72+(b<<3)>>3];b=b+1|0}while((b|0)!=4);b=c[a+176>>2]|0;switch(b|0){case 4:{h[e+104>>3]=+h[a+104>>3];h[e+112>>3]=+h[a+112>>3];h[e+120>>3]=+h[a+120>>3];h[e+128>>3]=+h[a+128>>3];h[e+136>>3]=f*+h[a+136>>3];h[e+144>>3]=g*+h[a+144>>3];h[e+152>>3]=f*+h[a+152>>3];h[e+160>>3]=g*+h[a+160>>3];h[e+168>>3]=+h[a+168>>3];i=8;break}case 3:{h[e+104>>3]=f*+h[a+104>>3];h[e+112>>3]=g*+h[a+112>>3];h[e+120>>3]=+h[a+120>>3];h[e+128>>3]=+h[a+128>>3];h[e+136>>3]=+h[a+136>>3]/(f*g);h[e+144>>3]=+h[a+144>>3]/(g*(f*f*g));i=8;break}case 2:{h[e+104>>3]=f*+h[a+104>>3];h[e+112>>3]=g*+h[a+112>>3];h[e+120>>3]=+h[a+120>>3];h[e+128>>3]=+h[a+128>>3]/(f*g);h[e+136>>3]=+h[a+136>>3]/(g*(f*f*g));i=8;break}case 1:{h[e+104>>3]=f*+h[a+104>>3];h[e+112>>3]=g*+h[a+112>>3];h[e+120>>3]=+h[a+120>>3];h[e+128>>3]=+h[a+128>>3]/(f*g);i=8;break}default:b=-1}if((i|0)==8){c[e+176>>2]=b;b=0}return b|0}function bf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0.0,j=0,k=0.0,l=0,m=0,n=0,o=0.0,p=0.0,q=0,r=0,s=0.0,t=0,u=0,v=0,w=0,x=0.0;f=i;i=i+96|0;e=f;if(!(+h[a+88>>3]>=0.0)){d=0;do{h[e+(d<<5)>>3]=-+h[a+(d<<5)>>3];h[e+(d<<5)+8>>3]=-+h[a+(d<<5)+8>>3];h[e+(d<<5)+16>>3]=-+h[a+(d<<5)+16>>3];h[e+(d<<5)+24>>3]=-+h[a+(d<<5)+24>>3];d=d+1|0}while((d|0)!=3)}else{d=0;do{h[e+(d<<5)>>3]=+h[a+(d<<5)>>3];h[e+(d<<5)+8>>3]=+h[a+(d<<5)+8>>3];h[e+(d<<5)+16>>3]=+h[a+(d<<5)+16>>3];h[e+(d<<5)+24>>3]=+h[a+(d<<5)+24>>3];d=d+1|0}while((d|0)!=3)}h[b>>3]=0.0;h[b+8>>3]=0.0;h[b+16>>3]=0.0;h[b+24>>3]=0.0;h[b+32>>3]=0.0;h[b+40>>3]=0.0;h[b+48>>3]=0.0;h[b+56>>3]=0.0;h[b+64>>3]=0.0;h[b+72>>3]=0.0;h[b+80>>3]=0.0;h[b+88>>3]=0.0;g=+h[e+64>>3];o=+h[e+72>>3];p=+h[e+80>>3];x=+P(+(g*g+o*o+p*p));a=b+80|0;h[a>>3]=x;x=g/x;v=c+64|0;h[v>>3]=x;o=o/+h[a>>3];t=c+72|0;h[t>>3]=o;p=p/+h[a>>3];q=c+80|0;h[q>>3]=p;n=c+88|0;h[n>>3]=+h[e+88>>3]/+h[a>>3];g=+h[e+32>>3];k=+h[e+40>>3];s=+h[e+48>>3];p=x*g+o*k+p*s;m=b+48|0;h[m>>3]=p;g=g-p*+h[v>>3];k=k-p*+h[t>>3];p=s-p*+h[q>>3];s=+P(+(g*g+k*k+p*p));l=b+40|0;h[l>>3]=s;w=c+32|0;h[w>>3]=g/s;u=c+40|0;h[u>>3]=k/+h[l>>3];r=c+48|0;h[r>>3]=p/+h[l>>3];p=+h[e>>3];k=+h[e+8>>3];s=+h[e+16>>3];g=+h[v>>3]*p+ +h[t>>3]*k+ +h[q>>3]*s;d=b+16|0;h[d>>3]=g;o=+h[w>>3]*p+ +h[u>>3]*k+ +h[r>>3]*s;j=b+8|0;h[j>>3]=o;p=p-o*+h[w>>3]-g*+h[v>>3];k=k-o*+h[u>>3]-g*+h[t>>3];g=s-o*+h[r>>3]-g*+h[q>>3];o=+P(+(p*p+k*k+g*g));h[b>>3]=o;h[c>>3]=p/o;h[c+8>>3]=k/+h[b>>3];h[c+16>>3]=g/+h[b>>3];g=+h[n>>3];k=(+h[e+56>>3]-+h[m>>3]*g)/+h[l>>3];h[c+56>>3]=k;h[c+24>>3]=(+h[e+24>>3]-k*+h[j>>3]-+h[d>>3]*g)/+h[b>>3];d=0;do{w=b+(d<<5)|0;h[w>>3]=+h[w>>3]/+h[a>>3];w=b+(d<<5)+8|0;h[w>>3]=+h[w>>3]/+h[a>>3];w=b+(d<<5)+16|0;h[w>>3]=+h[w>>3]/+h[a>>3];d=d+1|0}while((d|0)!=3);i=f;return 0}function cf(a,b,c,d,e,f){a=a|0;b=+b;c=+c;d=d|0;e=e|0;f=f|0;var g=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0;switch(f|0){case 4:{q=+h[a>>3];r=+h[a+8>>3];s=+h[a+16>>3];t=+h[a+24>>3];y=+h[a+32>>3];v=+h[a+40>>3];w=+h[a+48>>3];x=+h[a+56>>3];u=+h[a+64>>3];p=(b-w)/y;j=(c-x)/v;c=p*p;i=j*j;k=s*2.0;l=t*6.0;m=t*2.0;n=s*6.0;a:do if(i!=0.0|c!=0.0){f=1;g=p;b=j;while(1){C=i+c;B=q*C+1.0+C*(r*C);z=c*3.0;A=i*z;g=g-(t*(C+c*2.0)+(b*(k*g)+g*B)-p)/(l*g+(k*b+(q*(i+z)+1.0+r*(i*i+(c*(c*5.0)+A)))));z=m*g;b=b-(s*(i*2.0+C)+b*B+b*z-j)/(n*b+(q*(c+i*3.0)+1.0+r*(i*(i*5.0)+(c*c+A)))+z);if((f|0)==4)break a;c=g*g;i=b*b;if(!(i!=0.0|c!=0.0)){g=0.0;b=0.0;break}else f=f+1|0}}else{g=0.0;b=0.0}while(0);h[d>>3]=w+y*g/u;h[e>>3]=x+v*b/u;f=0;break}case 3:{p=+h[a>>3];g=(b-p)/+h[a+24>>3];o=a+8|0;b=c-+h[o>>3];j=+h[a+32>>3]/1.0e8;k=+h[a+40>>3]/1.0e8/1.0e5;c=g*g+b*b;l=+P(+c);m=j*3.0;n=k*5.0;b:do if(l!=0.0){f=1;i=l;while(1){C=i-(i*(1.0-j*c-c*(k*c))-l)/(1.0-m*c-c*(n*c));g=g*C/i;b=b*C/i;if((f|0)==3)break b;c=g*g+b*b;i=+P(+c);if(!(i!=0.0)){g=0.0;b=0.0;break}else f=f+1|0}}else{g=0.0;b=0.0}while(0);f=a+16|0;h[d>>3]=g/+h[f>>3]+p;h[e>>3]=b/+h[f>>3]+ +h[o>>3];f=0;break}case 2:{p=+h[a>>3];g=b-p;o=a+8|0;b=c-+h[o>>3];j=+h[a+24>>3]/1.0e8;k=+h[a+32>>3]/1.0e8/1.0e5;c=g*g+b*b;l=+P(+c);m=j*3.0;n=k*5.0;c:do if(l!=0.0){f=1;i=l;while(1){C=i-(i*(1.0-j*c-c*(k*c))-l)/(1.0-m*c-c*(n*c));g=g*C/i;b=b*C/i;if((f|0)==3)break c;c=g*g+b*b;i=+P(+c);if(!(i!=0.0)){g=0.0;b=0.0;break}else f=f+1|0}}else{g=0.0;b=0.0}while(0);f=a+16|0;h[d>>3]=g/+h[f>>3]+p;h[e>>3]=b/+h[f>>3]+ +h[o>>3];f=0;break}case 1:{m=+h[a>>3];g=b-m;o=a+8|0;b=c-+h[o>>3];j=+h[a+24>>3]/1.0e8;c=g*g+b*b;k=+P(+c);l=j*3.0;d:do if(k!=0.0){f=1;i=k;while(1){C=i-(i*(1.0-j*c)-k)/(1.0-l*c);g=g*C/i;b=b*C/i;if((f|0)==3)break d;c=g*g+b*b;i=+P(+c);if(!(i!=0.0)){g=0.0;b=0.0;break}else f=f+1|0}}else{g=0.0;b=0.0}while(0);f=a+16|0;h[d>>3]=g/+h[f>>3]+m;h[e>>3]=b/+h[f>>3]+ +h[o>>3];f=0;break}default:f=-1}return f|0}function df(a,b,c,d,e,f){a=a|0;b=+b;c=+c;d=d|0;e=e|0;f=f|0;var g=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0;switch(f|0){case 4:{j=+h[a+16>>3];k=+h[a+24>>3];n=+h[a+32>>3];l=+h[a+40>>3];o=+h[a+48>>3];m=+h[a+56>>3];i=+h[a+64>>3];b=(b-o)*i/n;i=(c-m)*i/l;g=b*b+i*i;c=+h[a>>3]*g+1.0+g*(+h[a+8>>3]*g);h[d>>3]=o+n*(k*(b*(b*2.0)+g)+(j*2.0*b*i+b*c));h[e>>3]=m+l*(k*2.0*b*i+(j*(g+i*(i*2.0))+i*c));f=0;break}case 3:{i=+h[a>>3];o=+h[a+16>>3];g=(b-i)*o;f=a+8|0;b=o*(c-+h[f>>3]);if(g==0.0&b==0.0){h[d>>3]=i;b=+h[f>>3]}else{o=g*g+b*b;o=1.0-o*(+h[a+32>>3]/1.0e8)-o*(o*(+h[a+40>>3]/1.0e8/1.0e5));h[d>>3]=i+ +h[a+24>>3]*(g*o);b=+h[f>>3]+b*o}h[e>>3]=b;f=0;break}case 2:{i=+h[a>>3];o=+h[a+16>>3];g=(b-i)*o;f=a+8|0;b=o*(c-+h[f>>3]);if(g==0.0&b==0.0){h[d>>3]=i;b=+h[f>>3]}else{o=g*g+b*b;o=1.0-o*(+h[a+24>>3]/1.0e8)-o*(o*(+h[a+32>>3]/1.0e8/1.0e5));h[d>>3]=i+g*o;b=+h[f>>3]+b*o}h[e>>3]=b;f=0;break}case 1:{i=+h[a>>3];o=+h[a+16>>3];g=(b-i)*o;f=a+8|0;b=o*(c-+h[f>>3]);if(g==0.0&b==0.0){h[d>>3]=i;b=+h[f>>3]}else{o=1.0-(g*g+b*b)*(+h[a+24>>3]/1.0e8);h[d>>3]=i+g*o;b=+h[f>>3]+b*o}h[e>>3]=b;f=0;break}default:f=-1}return f|0}function ef(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0;s=i;i=i+256|0;n=s+232|0;m=s+224|0;l=s+216|0;k=s+208|0;j=s+200|0;g=s+192|0;f=s+184|0;p=s+240|0;q=s;do if((a|0)!=0&(b|0)>0&(d|0)!=0){r=_i(a,4854)|0;if(!r){r=qi()|0;c[f>>2]=c[r>>2];c[f+4>>2]=a;Me(3,4857,f);a=ri(c[r>>2]|0)|0;c[g>>2]=5367;c[g+4>>2]=a;Me(3,5361,g);a=-1;break}dj(r,0,2)|0;a:do if(!(Xi(r)|0)){g=gj(r)|0;jj(r);a=0;do{if((a|0)>=4){o=9;break}f=c[2012+(a<<3)+4>>2]|0;a=a+1|0}while(((g|0)%(f|0)|0|0)!=0);do if((o|0)==9)if((a|0)==4){Me(3,4971,l);a=-1;break a}else{f=c[2012+(0<<3)+4>>2]|0;a=0;break}while(0);if((aj(q,f,1,r)|0)!=1){a=qi()|0;c[m>>2]=c[a>>2];Me(3,5051,m);a=ri(c[a>>2]|0)|0;c[n>>2]=5367;c[n+4>>2]=a;Me(3,5361,n);a=-1;break}l=q+176|0;c[l>>2]=a;ff(q);m=(a|0)==1;n=q+120|0;if(m){t=+h[n>>3];k=q+128|0;h[n>>3]=+h[k>>3];h[k>>3]=t}else k=q+128|0;ik(d|0,q|0,184)|0;c[p>>2]=e;f=d+176|0;if((b|0)>1){j=1;while(1){e=(c[p>>2]|0)+(4-1)&~(4-1);g=c[e>>2]|0;c[p>>2]=e+4;c[g+176>>2]=c[f>>2];if((aj(q,c[2012+((c[f>>2]|0)+-1<<3)+4>>2]|0,1,r)|0)!=1){a=-1;break a}c[l>>2]=a;ff(q);if(m){t=+h[n>>3];h[n>>3]=+h[k>>3];h[k>>3]=t}ik(g|0,q|0,184)|0;j=j+1|0;if((j|0)>=(b|0)){a=0;break}}}else a=0}else{a=qi()|0;c[j>>2]=c[a>>2];Me(3,4926,j);a=ri(c[a>>2]|0)|0;c[k>>2]=5367;c[k+4>>2]=a;Me(3,5361,k);a=-1}while(0);Wi(r)|0}else a=-1;while(0);i=s;return a|0}function ff(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;g=i;i=i+192|0;f=g;hf(a,f);hf(a+4|0,f+4|0);b=0;do{gf(a+8+(b<<5)|0,f+8+(b<<5)|0);gf(a+8+(b<<5)+8|0,f+8+(b<<5)+8|0);gf(a+8+(b<<5)+16|0,f+8+(b<<5)+16|0);gf(a+8+(b<<5)+24|0,f+8+(b<<5)+24|0);b=b+1|0}while((b|0)!=3);d=a+176|0;e=0;do{gf(a+104+(e<<3)|0,f+104+(e<<3)|0);e=e+1|0;b=c[d>>2]|0}while((e|0)<(c[2012+(b+-1<<3)>>2]|0));c[f+176>>2]=b;ik(a|0,f|0,184)|0;i=g;return}function gf(b,c){b=b|0;c=c|0;a[c>>0]=a[b+7>>0]|0;a[c+1>>0]=a[b+6>>0]|0;a[c+2>>0]=a[b+5>>0]|0;a[c+3>>0]=a[b+4>>0]|0;a[c+4>>0]=a[b+3>>0]|0;a[c+5>>0]=a[b+2>>0]|0;a[c+6>>0]=a[b+1>>0]|0;a[c+7>>0]=a[b>>0]|0;return}function hf(b,c){b=b|0;c=c|0;a[c>>0]=a[b+3>>0]|0;a[c+1>>0]=a[b+2>>0]|0;a[c+2>>0]=a[b+1>>0]|0;a[c+3>>0]=a[b>>0]|0;return}function jf(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0;x=i;i=i+64|0;t=x+24|0;u=x+16|0;v=x+8|0;w=x;q=Uj(208)|0;if(!q){Me(3,5472,x+32|0);rb(1)}ik(q|0,a|0,184)|0;s=b<<1;r=(c[a>>2]|0)+s|0;c[q+192>>2]=r;s=(c[a+4>>2]|0)+s|0;c[q+196>>2]=s;c[q+200>>2]=b;c[q+204>>2]=b;d=$(r<<3,s)|0;e=Uj(d)|0;c[q+184>>2]=e;if(!e){Me(3,5472,x+40|0);rb(1)}d=Uj(d)|0;c[q+188>>2]=d;if(!d){Me(3,5472,x+48|0);rb(1)}p=a+104|0;m=c[a+176>>2]|0;n=(r|0)>0?r<<1:0;if((s|0)>0){o=(r|0)>0;l=0;while(1){f=+(l-b|0);if(o){a=0;j=e;k=d;while(1){y=+(a-b|0);df(p,y,f,v,w,m)|0;g[j>>2]=+h[v>>3];g[j+4>>2]=+h[w>>3];cf(p,y,f,t,u,m)|0;g[k>>2]=+h[t>>3];g[k+4>>2]=+h[u>>3];a=a+1|0;if((a|0)>=(r|0))break;else{j=j+8|0;k=k+8|0}}}d=d+(n<<2)|0;l=l+1|0;if((l|0)>=(s|0))break;else e=e+(n<<2)|0}}i=x;return q|0}function kf(a){a=a|0;var b=0;if((a|0)!=0?(b=c[a>>2]|0,(b|0)!=0):0){Vj(c[b+184>>2]|0);Vj(c[(c[a>>2]|0)+188>>2]|0);Vj(c[a>>2]|0);c[a>>2]=0;b=0}else b=-1;return b|0}function lf(a,b,d,e,f){a=a|0;b=+b;d=+d;e=e|0;f=f|0;var g=0,h=0,i=0;h=(c[a+16>>2]|0)+~~(b+.5)|0;g=(c[a+20>>2]|0)+~~(d+.5)|0;if(((h|0)>=0?(i=c[a+8>>2]|0,!((g|0)<0|(h|0)>=(i|0))):0)?(g|0)<(c[a+12>>2]|0):0){a=c[a>>2]|0;g=($(i,g)|0)+h<<1;c[e>>2]=c[a+(g<<2)>>2];c[f>>2]=c[a+((g|1)<<2)>>2];g=0}else g=-1;return g|0}function mf(a,b,d,e,f){a=a|0;b=+b;d=+d;e=e|0;f=f|0;var g=0,h=0,i=0;h=(c[a+16>>2]|0)+~~(b+.5)|0;g=(c[a+20>>2]|0)+~~(d+.5)|0;if(((h|0)>=0?(i=c[a+8>>2]|0,!((g|0)<0|(h|0)>=(i|0))):0)?(g|0)<(c[a+12>>2]|0):0){a=c[a+4>>2]|0;g=($(i,g)|0)+h<<1;c[e>>2]=c[a+(g<<2)>>2];c[f>>2]=c[a+((g|1)<<2)>>2];g=0}else g=-1;return g|0}function nf(a){a=a|0;var b=0,d=0;b=Uj(8)|0;do if(b){d=Uj(a<<3)|0;c[b>>2]=d;if(!d){Vj(b);b=0;break}else{c[b+4>>2]=a;break}}else b=0;while(0);return b|0}function of(a){a=a|0;Vj(c[a>>2]|0);Vj(a);return 0}function pf(a){a=a|0;var b=0.0,d=0,e=0.0,f=0,g=0;b=+P(+(+qf(a,a)));if(b!=0.0){f=c[a>>2]|0;e=+h[f>>3];b=e<0.0?-b:b;e=e+b;h[f>>3]=e;e=1.0/+P(+(e*b));a=c[a+4>>2]|0;if((a|0)>0){d=0;do{g=f+(d<<3)|0;h[g>>3]=e*+h[g>>3];d=d+1|0}while((d|0)<(a|0))}}return +-b}function qf(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0;f=c[a+4>>2]|0;if((f|0)!=(c[b+4>>2]|0))rb(0);if((f|0)>0){e=c[a>>2]|0;a=c[b>>2]|0;b=0;d=0.0;do{d=d+ +h[e+(b<<3)>>3]*+h[a+(b<<3)>>3];b=b+1|0}while((b|0)<(f|0))}else d=0.0;return +d}function rf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,j=0.0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E+8|0;D=E;w=c[a+8>>2]|0;if(((w|0)==(c[a+4>>2]|0)?(w|0)==(c[b+4>>2]|0):0)?(w|0)==((c[d+4>>2]|0)+1|0):0){z=w+-2|0;A=C+4|0;B=D+4|0;if((w|0)>2){s=w+-1|0;t=0;do{o=$(t,w)|0;p=c[a>>2]|0;h[(c[b>>2]|0)+(t<<3)>>3]=+h[p+(o+t<<3)>>3];k=w-t+-1|0;c[A>>2]=k;u=t;t=t+1|0;l=p+(o+t<<3)|0;c[C>>2]=l;r=+pf(C);h[(c[d>>2]|0)+(u<<3)>>3]=r;if(!(r==0.0)){if((t|0)<(w|0)){m=c[b>>2]|0;n=t;do{if((t|0)<(n|0)){e=c[a>>2]|0;f=t;j=0.0;do{r=+h[e+(($(f,w)|0)+n<<3)>>3];j=j+r*+h[p+(f+o<<3)>>3];f=f+1|0}while((f|0)<(n|0))}else j=0.0;e=$(n,w)|0;if((n|0)<(w|0)){f=c[a>>2]|0;g=n;do{j=j+ +h[f+(g+e<<3)>>3]*+h[p+(g+o<<3)>>3];g=g+1|0}while((g|0)<(w|0))}h[m+(n<<3)>>3]=j;n=n+1|0}while((n|0)<(w|0))}c[B>>2]=k;c[A>>2]=k;c[C>>2]=l;c[D>>2]=(c[b>>2]|0)+(t<<3);j=+qf(C,D)*.5;if((s|0)>(u|0)){e=c[b>>2]|0;k=s;do{q=+h[p+(k+o<<3)>>3];f=e+(k<<3)|0;r=+h[f>>3]-j*q;h[f>>3]=r;f=$(k,w)|0;if((k|0)<(w|0)){g=c[a>>2]|0;l=k;do{n=g+(l+f<<3)|0;h[n>>3]=+h[n>>3]-(q*+h[e+(l<<3)>>3]+r*+h[p+(l+o<<3)>>3]);l=l+1|0}while((l|0)<(w|0))}k=k+-1|0}while((k|0)>(u|0))}}}while((t|0)<(z|0))}if((w|0)<=1){if((w|0)>0){f=0;g=c[a>>2]|0;e=c[b>>2]|0;v=27}}else{v=$(z,w)|0;g=c[a>>2]|0;e=c[b>>2]|0;h[e+(z<<3)>>3]=+h[g+(v+z<<3)>>3];f=w+-1|0;h[(c[d>>2]|0)+(z<<3)>>3]=+h[g+(f+v<<3)>>3];v=27}if((v|0)==27)h[e+(f<<3)>>3]=+h[g+(($(f,w)|0)+f<<3)>>3];if((w|0)>0){m=(w|0)>0;p=w;do{d=p;p=p+-1|0;n=$(p,w)|0;o=c[a>>2]|0;if((d|0)<=(z|0)?(x=w-p+-1|0,y=o+(n+d<<3)|0,(d|0)<(w|0)):0){e=(d|0)<(w|0);k=d;do{c[B>>2]=x;c[A>>2]=x;c[C>>2]=y;f=$(k,w)|0;c[D>>2]=(c[a>>2]|0)+(f+d<<3);j=+qf(C,D);if(e){g=c[a>>2]|0;l=d;do{v=g+(l+f<<3)|0;h[v>>3]=+h[v>>3]-j*+h[o+(l+n<<3)>>3];l=l+1|0}while((l|0)<(w|0))}k=k+1|0}while((k|0)<(w|0))}if(m){e=0;do{h[o+(e+n<<3)>>3]=0.0;e=e+1|0}while((e|0)<(w|0))}h[o+(n+p<<3)>>3]=1.0}while((d|0)>1);e=0}else e=0}else e=-1;i=E;return e|0}function sf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,g=0.0,i=0.0;f=+h[c>>3];g=+h[c+8>>3];e=+h[c+16>>3];d=+h[b+88>>3]+(f*+h[b+64>>3]+g*+h[b+72>>3]+e*+h[b+80>>3]);if(d==0.0)c=-1;else{i=+h[b+56>>3]+(f*+h[b+32>>3]+g*+h[b+40>>3]+e*+h[b+48>>3]);h[a>>3]=(+h[b+24>>3]+(f*+h[b>>3]+g*+h[b+8>>3]+e*+h[b+16>>3]))/d;h[a+8>>3]=i/d;c=0}return c|0}function tf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,g=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0;B=i;i=i+1072|0;y=B+1056|0;x=B+768|0;w=B+192|0;A=B+48|0;z=B;K=+h[d>>3];F=+h[e>>3];s=K*F;J=+h[d+8>>3];t=e+8|0;E=+h[t>>3];v=J*E;j=+h[d+16>>3];G=+h[e+16>>3];l=j*G;m=+h[d+24>>3];I=+h[d+32>>3];H=+h[d+40>>3];n=E*H;k=+h[d+48>>3];o=G*k;p=+h[d+56>>3];D=+h[d+64>>3];C=+h[d+72>>3];q=E*C;f=+h[d+80>>3];r=G*f;g=+h[d+88>>3];h[x>>3]=s;h[x+8>>3]=K*E;h[x+16>>3]=K*G;h[x+24>>3]=F*J;h[x+32>>3]=v;h[x+40>>3]=G*J;h[x+48>>3]=F*j;h[x+56>>3]=E*j;h[x+64>>3]=l;h[x+72>>3]=K;h[x+80>>3]=J;h[x+88>>3]=j;j=F*I;h[x+96>>3]=j;h[x+104>>3]=E*I;h[x+112>>3]=G*I;h[x+120>>3]=F*H;h[x+128>>3]=n;h[x+136>>3]=G*H;h[x+144>>3]=F*k;h[x+152>>3]=E*k;h[x+160>>3]=o;h[x+168>>3]=I;h[x+176>>3]=H;h[x+184>>3]=k;k=D*F;h[x+192>>3]=k;h[x+200>>3]=E*D;h[x+208>>3]=G*D;h[x+216>>3]=F*C;E=+h[t>>3];h[x+224>>3]=C*E;h[x+232>>3]=G*C;h[x+240>>3]=F*f;h[x+248>>3]=E*f;h[x+256>>3]=r;h[x+264>>3]=D;h[x+272>>3]=C;h[x+280>>3]=f;e=w+64|0;d=w;t=d+64|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(t|0));h[e>>3]=-1.0;e=w+72|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[e+20>>2]=0;c[e+24>>2]=0;c[e+28>>2]=0;h[w+104>>3]=1.0;e=w+160|0;d=w+112|0;t=d+48|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(t|0));h[e>>3]=1.0;e=w+240|0;d=w+168|0;t=d+72|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(t|0));h[e>>3]=-1.0;e=w+296|0;d=w+248|0;t=d+48|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(t|0));h[e>>3]=-1.0;e=w+304|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[e+20>>2]=0;c[e+24>>2]=0;c[e+28>>2]=0;h[w+336>>3]=1.0;e=w+456|0;d=w+344|0;t=d+112|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(t|0));h[e>>3]=1.0;e=w+512|0;d=w+464|0;t=d+48|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(t|0));h[e>>3]=1.0;e=w+568|0;d=w+520|0;t=d+48|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(t|0));h[e>>3]=1.0;u=0;do{t=0;do{d=A+(u*48|0)+(t<<3)|0;h[d>>3]=0.0;f=0.0;e=0;do{f=f+ +h[x+(u*96|0)+(e<<3)>>3]*+h[w+(e*48|0)+(t<<3)>>3];e=e+1|0}while((e|0)!=12);h[d>>3]=f;t=t+1|0}while((t|0)!=6);u=u+1|0}while((u|0)!=3);J=m+(s+v+l);K=p+(j+n+o);f=g+(k+q+r);g=+h[b>>3];j=+h[b+8>>3];k=+h[b+16>>3];l=+h[b+24>>3]+(J*g+K*j+f*k);m=+h[b+32>>3];n=+h[b+40>>3];o=+h[b+48>>3];p=+h[b+56>>3]+(J*m+K*n+f*o);q=+h[b+64>>3];r=+h[b+72>>3];s=+h[b+80>>3];f=+h[b+88>>3]+(J*q+K*r+f*s);if(f==0.0){Me(3,5089,y);e=-1}else{K=f*f;h[z>>3]=(g*f-l*q)/K;h[z+8>>3]=(f*j-l*r)/K;h[z+16>>3]=(f*k-l*s)/K;h[z+24>>3]=(f*m-p*q)/K;h[z+32>>3]=(f*n-p*r)/K;h[z+40>>3]=(f*o-p*s)/K;d=0;do{f=+h[z+(d*24|0)>>3];g=+h[z+(d*24|0)+8>>3];j=+h[z+(d*24|0)+16>>3];e=0;do{y=a+(d*48|0)+(e<<3)|0;h[y>>3]=0.0;K=f*+h[A+(e<<3)>>3]+0.0;h[y>>3]=K;K=K+g*+h[A+48+(e<<3)>>3];h[y>>3]=K;h[y>>3]=K+j*+h[A+96+(e<<3)>>3];e=e+1|0}while((e|0)!=6);d=d+1|0}while((d|0)!=2);e=0}i=B;return e|0}function uf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0;j=i;i=i+48|0;h=j+24|0;g=j+12|0;f=j;c[h+4>>2]=6;c[h+8>>2]=1;c[h>>2]=a;c[g+4>>2]=e;c[g+8>>2]=1;c[g>>2]=b;c[f+4>>2]=e;c[f+8>>2]=6;c[f>>2]=d;b=Ue(f)|0;do if(b){a=Te(b,f)|0;if(!a){We(b)|0;d=-1;break}d=Te(b,g)|0;if(!d){We(b)|0;We(a)|0;d=-1;break}if((_e(a)|0)<0){We(b)|0;We(a)|0;We(d)|0;d=-1;break}else{Xe(h,a,d)|0;We(b)|0;We(a)|0;We(d)|0;d=0;break}}else d=-1;while(0);i=j;return d|0}function vf(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0,g=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0;n=i;i=i+192|0;l=n+96|0;m=n;g=+h[b>>3];k=+h[b+8>>3];d=+h[b+16>>3];c=g*g+k*k+d*d;if(c==0.0){j=0.0;e=0.0;d=1.0;c=0.0}else{c=+P(+c);j=c;e=d/c;d=g/c;c=k/c}u=+h[b+24>>3];r=+h[b+32>>3];k=+h[b+40>>3];o=+R(+j);g=1.0-o;j=+S(+j);h[l>>3]=o+d*d*g;t=c*d*g;s=e*j;h[l+8>>3]=t-s;q=d*e*g;p=c*j;h[l+16>>3]=q+p;h[l+24>>3]=u;h[l+32>>3]=t+s;h[l+40>>3]=o+c*c*g;c=c*e*g;j=d*j;h[l+48>>3]=c-j;h[l+56>>3]=r;h[l+64>>3]=q-p;h[l+72>>3]=c+j;h[l+80>>3]=o+e*e*g;h[l+88>>3]=k;f=0;do{c=+h[a+(f<<5)>>3];d=+h[a+(f<<5)+8>>3];e=+h[a+(f<<5)+16>>3];b=0;do{h[m+(f<<5)+(b<<3)>>3]=c*+h[l+(b<<3)>>3]+d*+h[l+32+(b<<3)>>3]+e*+h[l+64+(b<<3)>>3];b=b+1|0}while((b|0)!=4);b=m+(f<<5)+24|0;h[b>>3]=+h[a+(f<<5)+24>>3]+ +h[b>>3];f=f+1|0}while((f|0)!=3);b=0;do{h[a+(b<<5)>>3]=+h[m+(b<<5)>>3];h[a+(b<<5)+8>>3]=+h[m+(b<<5)+8>>3];h[a+(b<<5)+16>>3]=+h[m+(b<<5)+16>>3];h[a+(b<<5)+24>>3]=+h[m+(b<<5)+24>>3];b=b+1|0}while((b|0)!=3);i=n;return 0}function wf(a){a=a|0;var b=0,d=0;b=Uj(136)|0;if(!b)b=0;else{d=0;do{h[b+(d<<5)>>3]=+h[a+(d<<5)>>3];h[b+(d<<5)+8>>3]=+h[a+(d<<5)+8>>3];h[b+(d<<5)+16>>3]=+h[a+(d<<5)+16>>3];h[b+(d<<5)+24>>3]=+h[a+(d<<5)+24>>3];d=d+1|0}while((d|0)!=3);c[b+96>>2]=10;h[b+104>>3]=.10000000149011612;h[b+112>>3]=.9900000095367432;h[b+120>>3]=4.0;h[b+128>>3]=.5}return b|0}function xf(a){a=a|0;var b=0;b=c[a>>2]|0;if(!b)b=-1;else{Vj(b);c[a>>2]=0;b=0}return b|0}function yf(a,b){a=a|0;b=+b;if(!a)a=-1;else{h[a+128>>3]=b;a=0}return a|0}function zf(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,j=0.0,k=0,l=0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0.0,A=0.0;y=i;i=i+176|0;l=y+168|0;k=y+160|0;u=y+48|0;w=y+64|0;v=y;s=b+8|0;g=c[s>>2]|0;do if((g|0)>=3){x=Uj(g*96|0)|0;if(!x){Me(3,5109,k);g=-1;break}t=Uj(g<<4)|0;if(!t){Me(3,5109,l);Vj(x);g=-1;break}else g=0;do{h[e+(g<<5)>>3]=+h[d+(g<<5)>>3];h[e+(g<<5)+8>>3]=+h[d+(g<<5)+8>>3];h[e+(g<<5)+16>>3]=+h[d+(g<<5)+16>>3];h[e+(g<<5)+24>>3]=+h[d+(g<<5)+24>>3];g=g+1|0}while((g|0)!=3);q=b+4|0;l=u+8|0;d=a+104|0;n=a+120|0;o=a+112|0;p=a+96|0;m=0.0;r=0;a:while(1){Ne(a,e,w)|0;g=c[s>>2]|0;if((g|0)>0){j=0.0;k=0;do{if((sf(u,w,(c[q>>2]|0)+(k*24|0)|0)|0)<0){k=10;break a}g=c[b>>2]|0;A=+h[g+(k<<4)>>3]-+h[u>>3];z=+h[g+(k<<4)+8>>3]-+h[l>>3];j=j+(A*A+z*z);g=k<<1;h[t+(g<<3)>>3]=A;h[t+((g|1)<<3)>>3]=z;k=k+1|0;g=c[s>>2]|0}while((k|0)<(g|0))}else j=0.0;j=j/+(g|0);if(j<+h[d>>3]){k=24;break}if(((r|0)>0?j<+h[n>>3]:0)?j/m>+h[o>>3]:0){k=24;break}if((r|0)==(c[p>>2]|0)){k=24;break}if((g|0)>0){k=0;do{if((tf(x+(k*12<<3)|0,a,e,(c[q>>2]|0)+(k*24|0)|0)|0)<0){k=20;break a}k=k+1|0;g=c[s>>2]|0}while((k|0)<(g|0))}if((uf(v,t,x,g<<1)|0)<0){k=22;break}vf(e,v)|0;m=j;r=r+1|0}if((k|0)==10){Af(x,t);g=-1;break}else if((k|0)==20){Af(x,t);g=-1;break}else if((k|0)==22){Af(x,t);g=-1;break}else if((k|0)==24){h[f>>3]=j;Vj(x);Vj(t);g=0;break}}else g=-1;while(0);i=y;return g|0}function Af(a,b){a=a|0;b=b|0;Vj(a);Vj(b);return}function Bf(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,j=0.0,k=0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;G=i;i=i+192|0;n=G+184|0;m=G+176|0;l=G+168|0;g=G+160|0;B=G+48|0;D=G+64|0;C=G;A=b+8|0;k=c[A>>2]|0;do if((k|0)>=4){o=~~(+(k|0)*+h[a+128>>3])+-1|0;o=(o|0)<3?3:o;F=Uj(k*96|0)|0;if(!F){Me(3,5109,g);g=-1;break}E=Uj(k<<4)|0;if(!E){Me(3,5109,l);Vj(F);g=-1;break}g=k<<3;z=Uj(g)|0;if(!z){Me(3,5109,m);Vj(F);Vj(E);g=-1;break}y=Uj(g)|0;if(!y){Me(3,5109,n);Vj(F);Vj(E);Vj(z);g=-1;break}else g=0;do{h[e+(g<<5)>>3]=+h[d+(g<<5)>>3];h[e+(g<<5)+8>>3]=+h[d+(g<<5)+8>>3];h[e+(g<<5)+16>>3]=+h[d+(g<<5)+16>>3];h[e+(g<<5)+24>>3]=+h[d+(g<<5)+24>>3];g=g+1|0}while((g|0)!=3);w=b+4|0;x=B+8|0;n=y+(o<<3)|0;d=a+104|0;o=a+120|0;t=a+112|0;u=a+96|0;r=0.0;v=0;a:while(1){Ne(a,e,D)|0;g=c[A>>2]|0;if((g|0)>0){k=0;do{if((sf(B,D,(c[w>>2]|0)+(k*24|0)|0)|0)<0){k=14;break a}g=c[b>>2]|0;q=+h[g+(k<<4)>>3]-+h[B>>3];s=+h[g+(k<<4)+8>>3]-+h[x>>3];g=k<<1;h[E+(g<<3)>>3]=q;h[E+((g|1)<<3)>>3]=s;s=q*q+s*s;h[y+(k<<3)>>3]=s;h[z+(k<<3)>>3]=s;k=k+1|0;g=c[A>>2]|0}while((k|0)<(g|0))}rj(y,g,8,1);s=+h[n>>3]*4.0;s=s<16.0?16.0:s;k=c[A>>2]|0;q=s/6.0;if((k|0)>0){j=0.0;g=0;do{p=+h[y+(g<<3)>>3];if(p>s)p=q;else{p=1.0-p/s;p=q*(1.0-p*(p*p))}j=j+p;g=g+1|0}while((g|0)<(k|0))}else j=0.0;j=j/+(k|0);if(j<+h[d>>3]){k=36;break}if(((v|0)>0?j<+h[o>>3]:0)?j/r>+h[t>>3]:0){k=36;break}if((v|0)==(c[u>>2]|0)){k=36;break}if((k|0)>0){m=0;g=0;do{p=+h[z+(m<<3)>>3];if(p<=s){k=g*6|0;l=F+(k<<3)|0;if((tf(l,a,e,(c[w>>2]|0)+(m*24|0)|0)|0)<0){k=28;break a}r=1.0-p/s;r=r*r;h[l>>3]=+h[l>>3]*r;l=F+((k|1)<<3)|0;h[l>>3]=+h[l>>3]*r;l=F+(k+2<<3)|0;h[l>>3]=r*+h[l>>3];l=F+(k+3<<3)|0;h[l>>3]=r*+h[l>>3];l=F+(k+4<<3)|0;h[l>>3]=r*+h[l>>3];l=F+(k+5<<3)|0;h[l>>3]=r*+h[l>>3];l=F+(k+6<<3)|0;h[l>>3]=r*+h[l>>3];l=F+(k+7<<3)|0;h[l>>3]=r*+h[l>>3];l=F+(k+8<<3)|0;h[l>>3]=r*+h[l>>3];l=F+(k+9<<3)|0;h[l>>3]=r*+h[l>>3];l=F+(k+10<<3)|0;h[l>>3]=r*+h[l>>3];k=F+(k+11<<3)|0;h[k>>3]=r*+h[k>>3];k=m<<1;h[E+(g<<3)>>3]=r*+h[E+(k<<3)>>3];h[E+(g+1<<3)>>3]=r*+h[E+((k|1)<<3)>>3];k=c[A>>2]|0;g=g+2|0}m=m+1|0}while((m|0)<(k|0))}else g=0;if((g|0)<6){k=32;break}if((uf(C,E,F,g)|0)<0){k=34;break}vf(e,C)|0;r=j;v=v+1|0}if((k|0)==14){Cf(F,E,z,y);g=-1;break}else if((k|0)==28){Cf(F,E,z,y);g=-1;break}else if((k|0)==32){Cf(F,E,z,y);g=-1;break}else if((k|0)==34){Cf(F,E,z,y);g=-1;break}else if((k|0)==36){h[f>>3]=j;Vj(F);Vj(E);Vj(z);Vj(y);g=0;break}}else g=-1;while(0);i=G;return g|0}function Cf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Vj(a);Vj(b);Vj(c);Vj(d);return}function Df(a,b){a=a|0;b=b|0;var c=0.0;c=+h[a>>3]-+h[b>>3];return (c<0.0?-1:c>0.0&1)|0}function Ef(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,j=0.0,k=0.0,l=0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0,x=0,y=0,z=0,A=0.0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0,V=0,W=0,X=0,Y=0,Z=0;U=i;i=i+64|0;D=U+48|0;z=U+40|0;y=U+32|0;x=U+24|0;u=U+16|0;o=U+8|0;l=U;a:do if((e|0)>=4){g=0;while(1){if((g|0)>=(e|0))break;if(+h[d+(g*24|0)+16>>3]!=0.0){g=-1;break a}else g=g+1|0}if((((((((!(+h[a>>3]==0.0)?!(+h[a+32>>3]!=0.0):0)?(B=a+40|0,!(+h[B>>3]==0.0)):0)?!(+h[a+64>>3]!=0.0):0)?!(+h[a+72>>3]!=0.0):0)?!(+h[a+80>>3]!=1.0):0)?!(+h[a+24>>3]!=0.0):0)?!(+h[a+56>>3]!=0.0):0)?!(+h[a+88>>3]!=0.0):0){g=e<<1;C=Re(g,8)|0;if(!C){Me(3,5124,l);g=-1;break}w=Re(g,1)|0;if(!w){We(C)|0;Me(3,5150,o);g=-1;break}if(e){g=c[C>>2]|0;l=c[w>>2]|0;o=0;do{Z=d+(o*24|0)|0;V=o<<4;h[g+(V<<3)>>3]=+h[Z>>3];Y=d+(o*24|0)+8|0;h[g+((V|1)<<3)>>3]=+h[Y>>3];h[g+((V|2)<<3)>>3]=1.0;h[g+((V|3)<<3)>>3]=0.0;h[g+((V|4)<<3)>>3]=0.0;h[g+((V|5)<<3)>>3]=0.0;X=b+(o<<4)|0;h[g+((V|6)<<3)>>3]=-(+h[Z>>3]*+h[X>>3]);h[g+((V|7)<<3)>>3]=-(+h[Y>>3]*+h[X>>3]);h[g+((V|8)<<3)>>3]=0.0;h[g+((V|9)<<3)>>3]=0.0;h[g+((V|10)<<3)>>3]=0.0;h[g+((V|11)<<3)>>3]=+h[Z>>3];h[g+((V|12)<<3)>>3]=+h[Y>>3];h[g+((V|13)<<3)>>3]=1.0;W=b+(o<<4)+8|0;h[g+((V|14)<<3)>>3]=-(+h[Z>>3]*+h[W>>3]);h[g+((V|15)<<3)>>3]=-(+h[Y>>3]*+h[W>>3]);V=o<<1;h[l+(V<<3)>>3]=+h[X>>3];h[l+((V|1)<<3)>>3]=+h[W>>3];o=o+1|0}while((o|0)!=(e|0))}e=Ue(C)|0;if(!e){We(C)|0;We(w)|0;Me(3,5176,u);g=-1;break}o=Te(e,C)|0;if(!o){We(C)|0;We(w)|0;We(e)|0;Me(3,5202,x);g=-1;break}l=Te(e,w)|0;if(!l){We(C)|0;We(w)|0;We(e)|0;We(o)|0;Me(3,5228,y);g=-1;break}if((_e(o)|0)<0){We(C)|0;We(w)|0;We(e)|0;We(o)|0;We(l)|0;Me(3,5254,z);g=-1;break}g=Te(o,l)|0;if(!g){We(C)|0;We(w)|0;We(e)|0;We(o)|0;We(l)|0;Me(3,5280,D);g=-1;break}Z=c[g>>2]|0;p=+h[Z+48>>3];S=+h[a+48>>3];t=+h[B>>3];j=(+h[Z+24>>3]-p*S)/t;s=+h[a+16>>3];T=+h[a+8>>3];r=+h[a>>3];q=(+h[Z>>3]-p*s-j*T)/r;k=+h[Z+56>>3];m=(+h[Z+32>>3]-S*k)/t;n=(+h[Z+8>>3]-s*k-T*m)/r;t=(+h[Z+40>>3]-S)/t;r=(+h[Z+16>>3]-s-T*t)/r;We(C)|0;We(w)|0;We(e)|0;We(o)|0;We(l)|0;We(g)|0;T=+P(+(p*p+(j*j+q*q)));s=+P(+(k*k+(m*m+n*n)));q=q/T;j=j/T;p=p/T;n=n/s;m=m/s;k=k/s;s=(T+s)*.5;r=r/s;T=1.0/s;if(T<0.0){O=-j;k=-k;m=-m;p=-p;n=-n;Q=-q;S=-r;R=-T}else{O=j;Q=q;S=r;R=t/s}j=k*O-m*p;q=n*p-k*Q;r=m*Q-n*O;s=+P(+(r*r+(j*j+q*q)));do if(!(s==0.0)){t=j/s;q=q/s;j=r/s;N=k*p+(m*O+n*Q);N=N<0.0?-N:N;N=(+P(+(N+1.0))+ +P(+(1.0-N)))*.5;if(Q*q-O*t!=0.0){g=0;E=Q;v=O;F=p;I=t;H=q}else{Z=Q*j-p*t!=0.0;g=Z?1:2;E=Z?Q:p;v=Z?p:O;F=Z?O:Q;I=Z?t:j;H=Z?j:q;j=Z?q:t}r=E*H;s=v*I;q=r-s;if(q==0.0){q=O;j=Q;break}G=(v*j-F*H)/q;A=N*H/q;r=s-r;q=(E*j-F*I)/r;r=N*I/r;s=G*G+q*q+1.0;t=G*A+q*r;v=t*t-s*(A*A+r*r+-1.0);if(v<0.0){q=O;j=Q;break}M=+P(+v);L=(M-t)/s;F=A+G*L;K=r+q*L;M=(-t-M)/s;G=A+G*M;r=r+q*M;Z=(g|0)==1;q=Z?H:j;s=Z?j:H;J=Z?L:K;L=Z?K:L;K=Z?M:r;H=Z?r:M;Z=(g|0)==2&(Z^1);r=Z?I:q;q=Z?q:I;M=Z?L:F;L=Z?F:L;j=Z?H:G;I=Z?G:H;if(n*s-m*q!=0.0){g=0;E=n;v=m;F=k;H=q;A=s}else{Z=n*r-k*q!=0.0;g=Z?1:2;E=Z?n:k;v=Z?k:m;F=Z?m:n;H=Z?q:r;A=Z?r:s;r=Z?s:q}s=E*A;t=v*H;q=s-t;if(q==0.0){q=O;j=Q;break}G=(v*r-F*A)/q;A=N*A/q;q=t-s;v=(E*r-F*H)/q;q=N*H/q;r=G*G+v*v+1.0;s=G*A+v*q;t=s*s-r*(A*A+q*q+-1.0);if(t<0.0){q=O;j=Q;break}t=+P(+t);k=(t-s)/r;Q=A+G*k;O=q+v*k;t=(-s-t)/r;p=A+G*t;n=q+v*t;Z=(g|0)==1;m=Z?k:O;k=Z?O:k;v=Z?t:n;t=Z?n:t;Z=(g|0)==2&(Z^1);n=Z?k:Q;k=Z?Q:k;A=Z?t:p;t=Z?p:t;p=L*k+(J*m+M*n);p=p<0.0?-p:p;q=L*t+(J*v+M*A);q=q<0.0?-q:q;r=I*k+(K*m+j*n);r=r<0.0?-r:r;s=I*t+(K*v+j*A);s=s<0.0?-s:s;if(p<q)if(p<r){if(p<s){q=J;p=L;j=M;break}q=K;k=t;m=v;p=I;n=A;break}else{if(r<s){q=K;p=I;break}q=K;k=t;m=v;p=I;n=A;break}else if(q<r){if(q<s){q=J;k=t;m=v;p=L;n=A;j=M;break}q=K;k=t;m=v;p=I;n=A;break}else{if(r<s){q=K;p=I;break}q=K;k=t;m=v;p=I;n=A;break}}else{q=O;j=Q}while(0);M=k*q-m*p;N=n*p-k*j;O=m*j-n*q;Q=+P(+(O*O+(M*M+N*N)));h[f>>3]=j;h[f+32>>3]=q;h[f+64>>3]=p;h[f+8>>3]=n;h[f+40>>3]=m;h[f+72>>3]=k;h[f+16>>3]=M/Q;h[f+48>>3]=N/Q;h[f+80>>3]=O/Q;h[f+24>>3]=S;h[f+56>>3]=R;h[f+88>>3]=T;g=0}else g=-1}else g=-1;while(0);i=U;return g|0}function Ff(a){a=a|0;Vj(c[a>>2]|0);Vj(a);return 0}function Gf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return +(+If(a,b,c,d,0))}function Hf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return +(+If(a,b,c,d,1))}function If(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0.0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+208|0;z=F+200|0;y=F+192|0;A=F+96|0;B=F;C=e+4|0;p=c[C>>2]|0;q=e+112|0;r=e+120|0;if((p|0)>0){u=c[e>>2]|0;v=(d|0)>0;w=(d|0)>0;x=0;do{if(!(c[u+(x*320|0)+4>>2]|0)){if(v){k=c[u+(x*320|0)>>2]|0;l=0;j=-1;do{if((c[b+(l<<8)+8>>2]|0)==(k|0)?(n=+h[b+(l<<8)+40>>3],!(n<+h[q>>3])):0)if(!((j|0)!=-1?!(+h[b+(j<<8)+40>>3]<n):0))j=l;l=l+1|0}while((l|0)<(d|0))}else j=-1;c[u+(x*320|0)+304>>2]=j;if((j|0)>-1)c[b+(j<<8)+16>>2]=c[b+(j<<8)+20>>2]}else{l=u+(x*320|0)+312|0;m=u+(x*320|0)|0;if(w){o=0;j=-1;do{k=c[b+(o<<8)+12>>2]|0;if((k|0)==0?(t=b+(o<<8)+248|0,s=c[t>>2]|0,t=c[t+4>>2]|0,!((s|0)==0&(t|0)==0)):0){k=l;if((s|0)==(c[k>>2]|0)?(t|0)==(c[k+4>>2]|0):0)E=20}else if((k|0)==(c[m>>2]|0))E=20;if((E|0)==20){E=0;g=+h[b+(o<<8)+48>>3];if(!(g<+h[r>>3]))if(!((j|0)!=-1?!(+h[b+(j<<8)+48>>3]<g):0))j=o}o=o+1|0}while((o|0)<(d|0))}else j=-1;c[u+(x*320|0)+304>>2]=j;if((j|0)>-1)c[b+(j<<8)+16>>2]=c[b+(j<<8)+24>>2]}x=x+1|0}while((x|0)<(p|0))}if((p|0)>0){q=0;j=0;p=0;k=0;while(1){l=c[e>>2]|0;m=c[l+(q*320|0)+304>>2]|0;do if((m|0)<0)l=p;else{o=b+(m<<8)|0;if(+ke(a,o,+h[l+(q*320|0)+8>>3],B)>4.0){c[(c[e>>2]|0)+(q*320|0)+304>>2]=-1;l=b+(m<<8)+236|0;if(c[l>>2]|0){l=p;break}c[l>>2]=7;l=p;break}l=c[o>>2]|0;if((k|0)==0|(p|0)<(l|0)){j=0;do{h[A+(j<<5)>>3]=+h[B+(j<<5)>>3];h[A+(j<<5)+8>>3]=+h[B+(j<<5)+8>>3];h[A+(j<<5)+16>>3]=+h[B+(j<<5)+16>>3];h[A+(j<<5)+24>>3]=+h[B+(j<<5)+24>>3];j=j+1|0}while((j|0)!=3);j=q}else l=p;k=k+1|0}while(0);q=q+1|0;if((q|0)>=(c[C>>2]|0))break;else p=l}}else{j=0;k=0}do if((k|0)!=0?(k|0)>=(c[e+128>>2]|0):0){Ne(A,(c[e>>2]|0)+(j*320|0)+112|0,B)|0;p=k<<2;r=Uj(k<<6)|0;if(!r){Me(3,5472,y);rb(1)}q=Uj(k*96|0)|0;if(!q){Me(3,5472,z);rb(1)}l=c[C>>2]|0;if((l|0)>0){m=c[e>>2]|0;o=0;j=0;do{k=c[m+(o*320|0)+304>>2]|0;if((k|0)>=0){y=c[b+(k<<8)+16>>2]|0;d=(4-y|0)%4|0;z=j<<3;h[r+(z<<3)>>3]=+h[b+(k<<8)+168+(d<<4)>>3];h[r+((z|1)<<3)>>3]=+h[b+(k<<8)+168+(d<<4)+8>>3];d=(5-y|0)%4|0;h[r+((z|2)<<3)>>3]=+h[b+(k<<8)+168+(d<<4)>>3];h[r+((z|3)<<3)>>3]=+h[b+(k<<8)+168+(d<<4)+8>>3];d=(6-y|0)%4|0;h[r+((z|4)<<3)>>3]=+h[b+(k<<8)+168+(d<<4)>>3];h[r+((z|5)<<3)>>3]=+h[b+(k<<8)+168+(d<<4)+8>>3];y=(7-y|0)%4|0;h[r+((z|6)<<3)>>3]=+h[b+(k<<8)+168+(y<<4)>>3];h[r+((z|7)<<3)>>3]=+h[b+(k<<8)+168+(y<<4)+8>>3];z=j*12|0;h[q+(z<<3)>>3]=+h[m+(o*320|0)+208>>3];h[q+((z|1)<<3)>>3]=+h[m+(o*320|0)+216>>3];h[q+((z|2)<<3)>>3]=+h[m+(o*320|0)+224>>3];h[q+((z|3)<<3)>>3]=+h[m+(o*320|0)+232>>3];h[q+(z+4<<3)>>3]=+h[m+(o*320|0)+240>>3];h[q+(z+5<<3)>>3]=+h[m+(o*320|0)+248>>3];h[q+(z+6<<3)>>3]=+h[m+(o*320|0)+256>>3];h[q+(z+7<<3)>>3]=+h[m+(o*320|0)+264>>3];h[q+(z+8<<3)>>3]=+h[m+(o*320|0)+272>>3];h[q+(z+9<<3)>>3]=+h[m+(o*320|0)+280>>3];y=c[e>>2]|0;h[q+(z+10<<3)>>3]=+h[y+(o*320|0)+288>>3];h[q+(z+11<<3)>>3]=+h[y+(o*320|0)+296>>3];j=j+1|0}o=o+1|0}while((o|0)<(l|0))}m=e+104|0;k=(f|0)!=0;if(!(c[m>>2]|0)){j=e+8|0;g=+me(a,B,r,q,p,j);if(k&g>=20.0){yf(c[a>>2]|0,.8)|0;g=+ne(a,B,r,q,p,j);if(g>=20.0){yf(c[a>>2]|0,.6)|0;g=+ne(a,B,r,q,p,j);if(g>=20.0){yf(c[a>>2]|0,.4)|0;g=+ne(a,B,r,q,p,j);if(g>=20.0){yf(c[a>>2]|0,0.0)|0;g=+ne(a,B,r,q,p,j)}}}}Vj(q);Vj(r)}else{g=+me(a,B,r,q,p,A);l=e+8|0;n=+me(a,l,r,q,p,l);j=g<n;do if(k){if(j){j=0;do{h[e+8+(j<<5)>>3]=+h[A+(j<<5)>>3];h[e+8+(j<<5)+8>>3]=+h[A+(j<<5)+8>>3];h[e+8+(j<<5)+16>>3]=+h[A+(j<<5)+16>>3];h[e+8+(j<<5)+24>>3]=+h[A+(j<<5)+24>>3];j=j+1|0}while((j|0)!=3)}else g=n;if(g>=20.0){yf(c[a>>2]|0,.8)|0;g=+ne(a,B,r,q,p,A);n=+ne(a,l,r,q,p,l);if(g<n){j=0;do{h[e+8+(j<<5)>>3]=+h[A+(j<<5)>>3];h[e+8+(j<<5)+8>>3]=+h[A+(j<<5)+8>>3];h[e+8+(j<<5)+16>>3]=+h[A+(j<<5)+16>>3];h[e+8+(j<<5)+24>>3]=+h[A+(j<<5)+24>>3];j=j+1|0}while((j|0)!=3)}else g=n;if(g>=20.0){yf(c[a>>2]|0,.6)|0;g=+ne(a,B,r,q,p,A);n=+ne(a,l,r,q,p,l);if(g<n){j=0;do{h[e+8+(j<<5)>>3]=+h[A+(j<<5)>>3];h[e+8+(j<<5)+8>>3]=+h[A+(j<<5)+8>>3];h[e+8+(j<<5)+16>>3]=+h[A+(j<<5)+16>>3];h[e+8+(j<<5)+24>>3]=+h[A+(j<<5)+24>>3];j=j+1|0}while((j|0)!=3)}else g=n;if(g>=20.0){yf(c[a>>2]|0,.4)|0;g=+ne(a,B,r,q,p,A);n=+ne(a,l,r,q,p,l);if(g<n){j=0;do{h[e+8+(j<<5)>>3]=+h[A+(j<<5)>>3];h[e+8+(j<<5)+8>>3]=+h[A+(j<<5)+8>>3];h[e+8+(j<<5)+16>>3]=+h[A+(j<<5)+16>>3];h[e+8+(j<<5)+24>>3]=+h[A+(j<<5)+24>>3];j=j+1|0}while((j|0)!=3)}else g=n;if(g>=20.0){yf(c[a>>2]|0,0.0)|0;g=+ne(a,B,r,q,p,A);n=+ne(a,l,r,q,p,l);if(g<n)j=0;else{g=n;break}do{h[e+8+(j<<5)>>3]=+h[A+(j<<5)>>3];h[e+8+(j<<5)+8>>3]=+h[A+(j<<5)+8>>3];h[e+8+(j<<5)+16>>3]=+h[A+(j<<5)+16>>3];h[e+8+(j<<5)+24>>3]=+h[A+(j<<5)+24>>3];j=j+1|0}while((j|0)!=3)}}}}}else if(j){j=0;do{h[e+8+(j<<5)>>3]=+h[A+(j<<5)>>3];h[e+8+(j<<5)+8>>3]=+h[A+(j<<5)+8>>3];h[e+8+(j<<5)+16>>3]=+h[A+(j<<5)+16>>3];h[e+8+(j<<5)+24>>3]=+h[A+(j<<5)+24>>3];j=j+1|0}while((j|0)!=3)}else g=n;while(0);Vj(q);Vj(r)}if(g<20.0){c[m>>2]=1;break}c[m>>2]=0;m=c[C>>2]|0;if((m|0)>0){j=c[e>>2]|0;l=0;do{k=c[j+(l*320|0)+304>>2]|0;if((k|0)>=0?(D=b+(k<<8)+236|0,(c[D>>2]|0)==0):0)c[D>>2]=8;l=l+1|0}while((l|0)<(m|0))}}else E=38;while(0);if((E|0)==38){c[e+104>>2]=0;g=-1.0}i=F;return +g}function Jf(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0.0,W=0.0;U=i;i=i+2544|0;S=U+208|0;R=U+200|0;G=U+184|0;Q=U+176|0;F=U+168|0;E=U+152|0;P=U+144|0;D=U+136|0;M=U+128|0;L=U+120|0;K=U+112|0;C=U+104|0;j=U+96|0;g=U+88|0;f=U+80|0;e=U+72|0;d=U+64|0;H=U;I=U+2280|0;J=U+232|0;z=U+224|0;O=U+220|0;A=U+216|0;B=U+212|0;T=_i(a,5306)|0;a:do if(!T){c[d>>2]=a;Me(3,5308,d);d=ri(c[(qi()|0)>>2]|0)|0;c[e>>2]=5367;c[e+4>>2]=d;Me(3,5361,e);d=0}else{Kf(I,T);c[f>>2]=O;if((kj(I,5368,f)|0)!=1){c[g>>2]=a;Me(3,5371,g);Wi(T)|0;d=0;break}d=c[O>>2]|0;N=Uj(d*320|0)|0;if(!N){Me(3,5472,j);rb(1)}r=H+8|0;s=H+16|0;t=H+24|0;u=H+32|0;v=H+40|0;w=H+48|0;x=H+56|0;y=(b|0)==0;b:do if((d|0)>0){d=0;f=0;c:while(1){Kf(I,T);e=N+(d*320|0)|0;g=N+(d*320|0)+312|0;c[C>>2]=g;c[C+4>>2]=z;if((kj(I,5489,C)|0)==1){q=c[g>>2]|0;c[e>>2]=(q&-32768|0)==0&0==0?q&32767:0;c[N+(d*320|0)+4>>2]=1;f=f|2}else{if(y){e=10;break}if(!(Qe(J,a,2048,1)|0)){e=12;break}Cj(J,I,2047-(Bj(J)|0)|0)|0;q=Ke(b,J)|0;c[e>>2]=q;if((q|0)<0){e=14;break}c[N+(d*320|0)+4>>2]=0;f=f|1}Kf(I,T);e=N+(d*320|0)+8|0;c[D>>2]=e;if((kj(I,5785,D)|0)!=1){e=18;break}Kf(I,T);o=N+(d*320|0)+16|0;p=N+(d*320|0)+24|0;q=N+(d*320|0)+40|0;c[E>>2]=o;c[E+4>>2]=p;c[E+8>>2]=N+(d*320|0)+32;c[E+12>>2]=q;if((kj(I,5894,E)|0)!=4){c[F>>2]=A;c[F+4>>2]=B;if((kj(I,5910,F)|0)==2)g=0;else{e=21;break}}else g=1;do{Kf(I,T);c[G>>2]=N+(d*320|0)+16+(g<<5);c[G+4>>2]=N+(d*320|0)+16+(g<<5)+8;c[G+8>>2]=N+(d*320|0)+16+(g<<5)+16;c[G+12>>2]=N+(d*320|0)+16+(g<<5)+24;if((kj(I,5894,G)|0)!=4){e=23;break c}g=g+1|0}while((g|0)<3);Oe(o,N+(d*320|0)+112|0)|0;W=+h[e>>3];V=W*-.5;h[H>>3]=V;W=W*.5;h[r>>3]=W;h[s>>3]=W;h[t>>3]=W;h[u>>3]=W;h[v>>3]=V;h[w>>3]=V;h[x>>3]=V;e=N+(d*320|0)+48|0;g=N+(d*320|0)+56|0;j=N+(d*320|0)+72|0;k=N+(d*320|0)+80|0;l=N+(d*320|0)+88|0;m=N+(d*320|0)+104|0;n=0;do{V=+h[H+(n<<4)>>3];W=+h[H+(n<<4)+8>>3];h[N+(d*320|0)+208+(n*24|0)>>3]=+h[q>>3]+(+h[o>>3]*V+ +h[p>>3]*W);h[N+(d*320|0)+208+(n*24|0)+8>>3]=+h[j>>3]+(+h[e>>3]*V+ +h[g>>3]*W);h[N+(d*320|0)+208+(n*24|0)+16>>3]=+h[m>>3]+(+h[k>>3]*V+ +h[l>>3]*W);n=n+1|0}while((n|0)!=4);d=d+1|0;if((d|0)>=(c[O>>2]|0))break b}if((e|0)==10){c[K>>2]=a;c[K+4>>2]=I;Me(3,5496,K)}else if((e|0)==12){c[L>>2]=a;Me(3,5624,L)}else if((e|0)==14){c[M>>2]=a;c[M+4>>2]=J;Me(3,5708,M)}else if((e|0)==18){c[P>>2]=a;c[P+4>>2]=d+1;Me(3,5789,P)}else if((e|0)==21){c[Q>>2]=a;c[Q+4>>2]=d+1;Me(3,5916,Q)}else if((e|0)==23){c[R>>2]=a;c[R+4>>2]=d+1;Me(3,5916,R)}Wi(T)|0;Vj(N);d=0;break a}else f=0;while(0);Wi(T)|0;d=Uj(136)|0;if(!d){Me(3,5472,S);rb(1)}c[d>>2]=N;c[d+4>>2]=c[O>>2];c[d+104>>2]=0;do if((f&3|0)!=3){e=d+108|0;if(!(f&1)){c[e>>2]=1;break}else{c[e>>2]=0;break}}else c[d+108>>2]=2;while(0);h[d+112>>3]=.5;h[d+120>>3]=.5}while(0);i=U;return d|0}function Kf(b,c){b=b|0;c=c|0;var d=0,e=0;a:do if(Zi(b,256,c)|0)while(1){d=Bj(b)|0;b:do if(d)while(1){d=d+-1|0;e=b+d|0;switch(a[e>>0]|0){case 13:case 10:break;default:break b}a[e>>0]=0;if(!d)break b}while(0);switch(a[b>>0]|0){case 0:case 35:break;default:break a}if(!(Zi(b,256,c)|0))break a}while(0);return}function Lf(a,b,d,e){a=a|0;b=+b;d=+d;e=e|0;var f=0,g=0.0,j=0.0,k=0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+400|0;n=r+296|0;q=r+200|0;o=r+128|0;p=r;k=c[a>>2]|0;f=c[a+4>>2]|0;if((bf(a+8|0,n,q)|0)<0)Me(3,6025,r+392|0);else{j=+(f+-1|0);f=n+32|0;h[f>>3]=j*+h[n+64>>3]-+h[f>>3];f=n+40|0;h[f>>3]=j*+h[n+72>>3]-+h[f>>3];f=n+48|0;h[f>>3]=j*+h[n+80>>3]-+h[f>>3];f=n+56|0;h[f>>3]=j*+h[n+88>>3]-+h[f>>3];g=+h[n+80>>3];f=0;do{h[o+(f*24|0)>>3]=+h[n+(f<<5)>>3]/g;h[o+(f*24|0)+8>>3]=+h[n+(f<<5)+8>>3]/g;h[o+(f*24|0)+16>>3]=+h[n+(f<<5)+16>>3]/g;f=f+1|0}while((f|0)!=3);g=+(k+-1|0);h[p>>3]=+h[o>>3]*2.0/g;h[p+8>>3]=+h[o+8>>3]*2.0/g;h[p+16>>3]=+h[o+16>>3]*2.0/g+-1.0;k=p+24|0;c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;h[p+40>>3]=+h[o+32>>3]*2.0/j;h[p+48>>3]=+h[o+40>>3]*2.0/j+-1.0;k=p+56|0;g=d-b;c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;c[k+20>>2]=0;h[p+80>>3]=(b+d)/g;h[p+88>>3]=d*-2.0*b/g;k=p+96|0;c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;h[p+112>>3]=1.0;h[p+120>>3]=0.0;g=+h[q+24>>3];j=+h[q+56>>3];d=+h[q+88>>3];k=0;do{b=+h[p+(k<<5)>>3];f=p+(k<<5)+8|0;a=p+(k<<5)+16|0;l=+h[f>>3];m=+h[a>>3];n=0;do{h[e+((n<<2)+k<<3)>>3]=b*+h[q+(n<<3)>>3]+l*+h[q+32+(n<<3)>>3]+m*+h[q+64+(n<<3)>>3];n=n+1|0}while((n|0)!=3);h[e+(k+12<<3)>>3]=+h[p+(k<<5)+24>>3]+(b*g+ +h[f>>3]*j+ +h[a>>3]*d);k=k+1|0}while((k|0)!=4)}i=r;return}function Mf(a){a=a|0;c[496]=a;return}function Nf(){return c[496]|0}function Of(a){a=a|0;var b=0,d=0;b=a+212|0;d=c[b>>2]|0;if(d){ze(d)|0;Qd(c[b>>2]|0)|0;c[b>>2]=0}b=a+224|0;if(c[b>>2]|0){Ld(b)|0;c[b>>2]=0}b=a+192|0;if(c[b>>2]|0){kf(b)|0;c[b>>2]=0}return}function Pf(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;g=i;i=i+16|0;d=g;c[d>>2]=a;if(!(Cg(2044,d)|0))a=-1;else{f=Dg(2044,d)|0;a=f+196|0;b=c[a>>2]|0;if(b){Vj(b);c[a>>2]=0;c[f+200>>2]=0}Of(f);Ce(c[f+216>>2]|0)|0;Eg(2044,d)|0;d=f+248|0;e=f+252|0;a=c[d>>2]|0;if((c[e>>2]|0)!=(a|0)){b=0;do{Ff(c[a+(b<<3)+4>>2]|0)|0;b=b+1|0;a=c[d>>2]|0}while(b>>>0<(c[e>>2]|0)-a>>3>>>0)}Fg(d);Lh(d);Fg(f+248|0);Lh(f);a=0}i=g;return a|0}function Qf(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;h=i;i=i+208|0;g=h+192|0;f=h;e=h+196|0;if(!(a[b>>0]&1))d=b+1|0;else d=c[b+8>>2]|0;if((ef(d,1,f,h+184|0)|0)<0){if(!(a[b>>0]&1))d=b+1|0;else d=c[b+8>>2]|0;c[g>>2]=d;Me(3,6093,g);d=-1}else{d=c[521]|0;c[521]=d+1;c[e>>2]=d;ik(Gg(2064,e)|0,f|0,184)|0}i=h;return d|0}function Rf(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,j=0,k=0,l=0,m=0,n=0;n=i;i=i+48|0;m=n+24|0;l=n+16|0;j=n+8|0;f=n;d=n+32|0;e=n+28|0;c[d>>2]=a;c[e>>2]=b;do if((Cg(2044,d)|0)!=0?(k=Dg(2044,d)|0,(Hg(2064,e)|0)!=0):0){g=k+8|0;ik(g|0,Gg(2064,e)|0,184)|0;e=c[g>>2]|0;d=k+204|0;b=c[k+12>>2]|0;a=k+208|0;if(!((e|0)==(c[d>>2]|0)?(b|0)==(c[a>>2]|0):0)){c[f>>2]=e;c[f+4>>2]=b;Me(2,6152,f);af(g,c[d>>2]|0,c[a>>2]|0,g)|0}Of(k);d=jf(g,15)|0;a=k+192|0;c[a>>2]=d;if(!d){Me(3,6199,j);d=-1;break}d=Md(d)|0;b=k+212|0;c[b>>2]=d;if(!d){Me(3,6237,l);d=-1;break}Nd(d,2)|0;l=Jd(g)|0;c[k+224>>2]=l;if(!l){Me(3,6274,m);d=-1;break}else{ye(c[b>>2]|0,c[k+216>>2]|0)|0;Lf(c[a>>2]|0,+h[k+232>>3],+h[k+240>>3],k+264|0);d=0;break}}else d=-1;while(0);i=n;return d|0}function Sf(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;j=i;i=i+16|0;h=j+8|0;g=j;e=j+12|0;c[e>>2]=b;if(Cg(2044,e)|0){f=Dg(2044,e)|0;if(!(a[d>>0]&1))d=d+1|0;else d=c[d+8>>2]|0;b=f+216|0;e=Ke(c[b>>2]|0,d)|0;c[f+260>>2]=e;if((e|0)<0){c[g>>2]=d;Me(3,6312,g);Ce(c[b>>2]|0)|0;Me(3,6358,h);e=-1}}else e=-1;i=j;return e|0}function Tf(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0;l=i;i=i+32|0;g=l+16|0;f=l+8|0;e=l+20|0;k=l;c[e>>2]=b;do if(Cg(2044,e)|0){j=Dg(2044,e)|0;if(!(a[d>>0]&1))e=d+1|0;else e=c[d+8>>2]|0;b=c[j+212>>2]|0;d=j+216|0;h=j+220|0;e=Jf(e,c[d>>2]|0)|0;c[h>>2]=e;if(!e){Me(3,6402,f);Ce(c[d>>2]|0)|0;Me(3,6429,g);e=-1;break}switch(c[e+108>>2]|0){case 0:{Zd(b,0)|0;break}case 1:{Zd(b,2)|0;break}default:Zd(b,3)|0}b=j+248|0;d=j+252|0;f=c[d>>2]|0;e=f-(c[b>>2]|0)>>3;g=k;c[g>>2]=0;c[g+4>>2]=0;c[k>>2]=e;c[k+4>>2]=c[h>>2];if((f|0)==(c[j+256>>2]|0)){Ig(b,k);break}else{j=k;e=c[j>>2]|0;j=c[j+4>>2]|0;k=f;c[k>>2]=e;c[k+4>>2]=j;c[d>>2]=(c[d>>2]|0)+8;break}}else e=-1;while(0);i=l;return e|0}function Uf(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=i;i=i+16|0;d=g;c[d>>2]=a;if(((Cg(2044,d)|0)!=0?(e=Dg(2044,d)|0,(b|0)>=0):0)?(f=c[e+248>>2]|0,(c[e+252>>2]|0)-f>>3>>>0>b>>>0):0)d=c[(c[f+(b<<3)+4>>2]|0)+4>>2]|0;else d=-1;i=g;return d|0}function Vf(a){a=a|0;var b=0,d=0;d=i;i=i+16|0;b=d;c[b>>2]=a;if(!(Cg(2044,b)|0))b=-1;else{b=Dg(2044,b)|0;b=(c[b+252>>2]|0)-(c[b+248>>2]|0)>>3}i=d;return b|0}function Wf(a,b){a=a|0;b=+b;var d=0,e=0;e=i;i=i+16|0;d=e;c[d>>2]=a;if(Cg(2044,d)|0)h[(Dg(2044,d)|0)+232>>3]=b;i=e;return}function Xf(a){a=a|0;var b=0.0,d=0,e=0;e=i;i=i+16|0;d=e;c[d>>2]=a;if(!(Cg(2044,d)|0))b=-1.0;else b=+h[(Dg(2044,d)|0)+232>>3];i=e;return +b}function Yf(a,b){a=a|0;b=+b;var d=0,e=0;e=i;i=i+16|0;d=e;c[d>>2]=a;if(Cg(2044,d)|0)h[(Dg(2044,d)|0)+240>>3]=b;i=e;return}function Zf(a){a=a|0;var b=0.0,d=0,e=0;e=i;i=i+16|0;d=e;c[d>>2]=a;if(!(Cg(2044,d)|0))b=-1.0;else b=+h[(Dg(2044,d)|0)+240>>3];i=e;return +b}function _f(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=i;i=i+16|0;e=f;d=f+4|0;c[d>>2]=a;if((Cg(2044,d)|0)!=0?(Zd(c[(Dg(2044,d)|0)+212>>2]|0,b)|0)==0:0){c[e>>2]=b;Me(1,6478,e)}i=f;return}function $f(a){a=a|0;var b=0,d=0,e=0;e=i;i=i+16|0;b=e+4|0;d=e;c[b>>2]=a;if(!(Cg(2044,b)|0)){i=e;return -1}else{a=(ae(c[(Dg(2044,b)|0)+212>>2]|0,d)|0)==0;i=e;return (a?c[d>>2]|0:-1)|0}return 0}function ag(a,b){a=a|0;b=+b;var d=0,e=0,f=0.0,g=0,j=0,k=0;k=i;i=i+16|0;j=k;d=k+8|0;c[d>>2]=a;if((((Cg(2044,d)|0)!=0?(e=Dg(2044,d)|0,!(b<=0.0|b>=1.0)):0)?(f=b,g=c[e+212>>2]|0,(g|0)!=0):0)?(be(g,f)|0)==0:0){h[j>>3]=f;Me(1,6513,j)}i=k;return}function bg(a){a=a|0;var b=0,d=0,e=0,f=0;f=i;i=i+16|0;b=f+8|0;e=f;c[b>>2]=a;if((Cg(2044,b)|0)!=0?(d=c[(Dg(2044,b)|0)+212>>2]|0,(d|0)!=0):0){a=(ce(d,e)|0)==0;i=f;return +(a?+h[e>>3]:-1.0)}i=f;return -1.0}function cg(a,b){a=a|0;b=b|0;var d=0,e=0;e=i;i=i+16|0;d=e;c[d>>2]=a;if(Cg(2044,d)|0)_d(c[(Dg(2044,d)|0)+212>>2]|0,b)|0;i=e;return}function dg(a){a=a|0;var b=0,d=0,e=0;e=i;i=i+16|0;b=e+4|0;d=e;c[b>>2]=a;if(!(Cg(2044,b)|0))b=-1;else{$d(c[(Dg(2044,b)|0)+212>>2]|0,d)|0;b=c[d>>2]|0}i=e;return b|0}function eg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=i;i=i+16|0;e=f;d=f+4|0;c[d>>2]=a;if((Cg(2044,d)|0)!=0?(Sd(c[(Dg(2044,d)|0)+212>>2]|0,b)|0)==0:0){c[e>>2]=b;Me(1,6544,e)}i=f;return}function fg(a){a=a|0;var b=0,d=0,e=0;e=i;i=i+16|0;b=e+4|0;d=e;c[b>>2]=a;if(!(Cg(2044,b)|0)){i=e;return -1}else{a=(Td(c[(Dg(2044,b)|0)+212>>2]|0,d)|0)==0;i=e;return (a?c[d>>2]|0:-1)|0}return 0}function gg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=i;i=i+16|0;f=g;d=g+4|0;c[d>>2]=a;if(((Cg(2044,d)|0)!=0?(e=Dg(2044,d)|0,b>>>0<=255):0)?(Ud(c[e+212>>2]|0,b)|0)==0:0){c[f>>2]=b;Me(1,6569,f)}i=g;return}function hg(a){a=a|0;var b=0,d=0,e=0;e=i;i=i+16|0;b=e+4|0;d=e;c[b>>2]=a;if(!(Cg(2044,b)|0)){i=e;return -1}else{a=(Vd(c[(Dg(2044,b)|0)+212>>2]|0,d)|0)==0;i=e;return (a?c[d>>2]|0:-1)|0}return 0}function ig(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=i;i=i+16|0;e=f;d=f+4|0;c[d>>2]=a;if((Cg(2044,d)|0)!=0?(Pd(c[(Dg(2044,d)|0)+212>>2]|0,b)|0)==0:0){c[e>>2]=b;Me(1,6590,e)}i=f;return}function jg(a){a=a|0;var b=0,d=0,e=0;e=i;i=i+16|0;b=e+4|0;d=e;c[b>>2]=a;if(!(Cg(2044,b)|0)){i=e;return -1}else{a=(Wd(c[(Dg(2044,b)|0)+212>>2]|0,d)|0)==0;i=e;return (a?c[d>>2]|0:-1)|0}return 0}function kg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=i;i=i+16|0;e=f;d=f+4|0;c[d>>2]=a;if(!(Cg(2044,d)|0))b=0;else{a=(b|0)!=0;Od(c[(Dg(2044,d)|0)+212>>2]|0,a&1)|0;c[e>>2]=a?6616:6620;Me(1,6625,e)}i=f;return b|0}function lg(a){a=a|0;var b=0,d=0;d=i;i=i+16|0;b=d;c[b>>2]=a;if(!(Cg(2044,b)|0))b=0;else b=c[(c[(Dg(2044,b)|0)+212>>2]|0)+4834148>>2]|0;i=d;return b|0}function mg(a){a=a|0;var b=0,d=0,e=0;e=i;i=i+16|0;b=e+4|0;d=e;c[b>>2]=a;if(!(Cg(2044,b)|0))b=0;else{Rd(c[(Dg(2044,b)|0)+212>>2]|0,d)|0;b=c[d>>2]|0}i=e;return b|0}function ng(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=i;i=i+16|0;e=f;d=f+4|0;c[d>>2]=a;if((Cg(2044,d)|0)!=0?(Xd(c[(Dg(2044,d)|0)+212>>2]|0,b)|0)==0:0){c[e>>2]=b;Me(1,6647,e)}i=f;return}function og(a){a=a|0;var b=0,d=0,e=0;e=i;i=i+16|0;b=e+4|0;d=e;c[b>>2]=a;if(!(Cg(2044,b)|0)){i=e;return -1}else{a=(Yd(c[(Dg(2044,b)|0)+212>>2]|0,d)|0)==0;i=e;return (a?c[d>>2]|0:-1)|0}return 0}function pg(a,b){a=a|0;b=b|0;var c=0;c=0;do{h[b+(c<<5)>>3]=+h[a+(c<<5)>>3];h[b+(c<<5)+8>>3]=+h[a+(c<<5)+8>>3];h[b+(c<<5)+16>>3]=+h[a+(c<<5)+16>>3];h[b+(c<<5)+24>>3]=+h[a+(c<<5)+24>>3];c=c+1|0}while((c|0)!=3);return}function qg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=i;i=i+16|0;e=f;c[e>>2]=a;do if(Cg(2044,e)|0){e=Dg(2044,e)|0;a=c[e+212>>2]|0;if((c[a+44>>2]|0)>(b|0)){+ke(c[e+224>>2]|0,(b|0)<0?8:a+48+(b<<8)|0,+(d|0),264);e=0;break}else{e=c[523]|0;break}}else e=c[522]|0;while(0);i=f;return e|0}function rg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=i;i=i+16|0;e=f;c[e>>2]=a;do if(Cg(2044,e)|0){e=Dg(2044,e)|0;a=c[e+212>>2]|0;if((c[a+44>>2]|0)>(b|0)){+le(c[e+224>>2]|0,(b|0)<0?8:a+48+(b<<8)|0,264,+(d|0),264);e=0;break}else{e=c[523]|0;break}}else e=c[522]|0;while(0);i=f;return e|0}function sg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=i;i=i+16|0;e=f;c[e>>2]=a;do if(Cg(2044,e)|0){e=c[(Dg(2044,e)|0)+212>>2]|0;if((c[e+44>>2]|0)>(b|0)){c[((b|0)<0?8:e+48+(b<<8)|0)+16>>2]=d;e=0;break}else{e=c[523]|0;break}}else e=c[522]|0;while(0);i=f;return e|0}function tg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,g=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0;e=i;i=i+16|0;d=e;c[d>>2]=a;do if(Cg(2044,d)|0){d=c[(Dg(2044,d)|0)+212>>2]|0;if((c[d+44>>2]|0)>(b|0)){d=(b|0)<0?8:d+48+(b<<8)|0;o=+h[33];h[d+168>>3]=o;k=+h[34];h[d+176>>3]=k;n=+h[35];h[d+184>>3]=n;j=+h[36];h[d+192>>3]=j;m=+h[37];h[d+200>>3]=m;g=+h[38];h[d+208>>3]=g;l=+h[39];h[d+216>>3]=l;f=+h[40];h[d+224>>3]=f;h[d+56>>3]=(o+n+m+l)*.25;h[d+64>>3]=(k+j+g+f)*.25;d=0;break}else{d=c[523]|0;break}}else d=c[522]|0;while(0);i=e;return d|0}function ug(a,b){a=a|0;b=b|0;var d=0,e=0;e=i;i=i+16|0;d=e;c[d>>2]=a;do if(Cg(2044,d)|0){d=Dg(2044,d)|0;a=c[d+248>>2]|0;if((b|0)<0?1:(c[d+252>>2]|0)-a>>3>>>0<=b>>>0){d=c[524]|0;break}else{b=c[a+(b<<3)+4>>2]|0;a=c[d+212>>2]|0;+Hf(c[d+224>>2]|0,a+48|0,c[a+44>>2]|0,b);pg(b+8|0,264);d=0;break}}else d=c[522]|0;while(0);i=e;return d|0}function vg(a,b){a=a|0;b=b|0;var d=0,e=0;e=i;i=i+16|0;d=e;c[d>>2]=a;do if(Cg(2044,d)|0){d=Dg(2044,d)|0;a=c[d+248>>2]|0;if((b|0)<0?1:(c[d+252>>2]|0)-a>>3>>>0<=b>>>0){d=c[524]|0;break}else{b=c[a+(b<<3)+4>>2]|0;a=c[d+212>>2]|0;+Gf(c[d+224>>2]|0,a+48|0,c[a+44>>2]|0,b);pg(b+8|0,264);d=0;break}}else d=c[522]|0;while(0);i=e;return d|0}function wg(a){a=a|0;var b=0,d=0;d=i;i=i+16|0;b=d;c[b>>2]=a;if(!(Cg(2044,b)|0))b=c[522]|0;else{b=Dg(2044,b)|0;b=de(c[b+212>>2]|0,c[b+196>>2]|0)|0}i=d;return b|0}function xg(a){a=a|0;var b=0,d=0;d=i;i=i+16|0;b=d;c[b>>2]=a;if(!(Cg(2044,b)|0))b=2088;else b=(c[(Dg(2044,b)|0)+212>>2]|0)+44|0;i=d;return c[b>>2]|0}function yg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=i;i=i+16|0;e=f;c[e>>2]=a;do if(Cg(2044,e)|0){a=Dg(2044,e)|0;e=c[a+248>>2]|0;if((b|0)<0?1:(c[a+252>>2]|0)-e>>3>>>0<=b>>>0){e=c[524]|0;break}e=c[e+(b<<3)+4>>2]|0;if((d|0)<0?1:(c[e+4>>2]|0)<=(d|0)){e=c[523]|0;break}else{e=c[e>>2]|0;pg(e+(d*320|0)+16|0,264);Lb(0,c[e+(d*320|0)+304>>2]|0,c[e+(d*320|0)>>2]|0,c[e+(d*320|0)+4>>2]|0,+(+h[e+(d*320|0)+8>>3]))|0;e=0;break}}else e=c[522]|0;while(0);i=f;return e|0}function zg(a,b){a=a|0;b=b|0;var d=0,e=0;e=i;i=i+16|0;d=e;c[d>>2]=a;do if(Cg(2044,d)|0){d=c[(Dg(2044,d)|0)+212>>2]|0;if((c[d+44>>2]|0)>(b|0)){d=(b|0)<0?8:d+48+(b<<8)|0;Qa(1,c[d>>2]|0,c[d+4>>2]|0,c[d+8>>2]|0,c[d+12>>2]|0,c[d+16>>2]|0,c[d+20>>2]|0,c[d+24>>2]|0,+(+h[d+32>>3]),+(+h[d+40>>3]),+(+h[d+48>>3]),+(+h[d+56>>3]),+(+h[d+64>>3]),+(+h[d+72>>3]),+(+h[d+80>>3]),+(+h[d+88>>3]),+(+h[d+96>>3]),+(+h[d+104>>3]),+(+h[d+112>>3]),+(+h[d+120>>3]),+(+h[d+128>>3]),+(+h[d+136>>3]),+(+h[d+144>>3]),+(+h[d+152>>3]),+(+h[d+160>>3]),+(+h[d+168>>3]),+(+h[d+176>>3]),+(+h[d+184>>3]),+(+h[d+192>>3]),+(+h[d+200>>3]),+(+h[d+208>>3]),+(+h[d+216>>3]),+(+h[d+224>>3]),c[d+240>>2]|0)|0;d=0;break}else{d=c[523]|0;break}}else d=c[522]|0;while(0);i=e;return d|0}function Ag(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;h=i;i=i+16|0;g=h+8|0;f=h+12|0;e=c[525]|0;c[525]=e+1;c[f>>2]=e;f=Dg(2044,f)|0;c[f>>2]=e;c[f+204>>2]=a;c[f+208>>2]=b;j=$(a<<2,b)|0;b=f+200|0;c[b>>2]=j;a=f+196|0;c[a>>2]=Uj(j)|0;j=Ae()|0;c[f+216>>2]=j;if(!j)Me(3,8285,h);Rf(e,d)|0;c[g>>2]=c[b>>2];Me(1,8322,g);Kb(2,c[f>>2]|0,c[a>>2]|0,c[b>>2]|0,f+264|0,264)|0;i=h;return c[f>>2]|0}function Bg(a){a=a|0;var b=0;a=i;i=i+16|0;b=a;Jg(8591,7);Kg(8597,3);Lg(8606,2);Lg(8617,3);Mg(8633,4);Kg(8651,4);Ng(8671,5);Jg(8683,8);Mg(8700,5);Jg(8720,9);Jg(8738,10);Mg(8760,6);Mg(8783,7);Kg(8812,6);Kg(8825,7);Jg(8838,11);Mg(8857,8);Mg(8867,9);Kg(8880,8);Kg(8893,9);Og(8912,10);Pg(8924,1);Qg(8936,1);Rg(8959,1);Qg(8982,2);Rg(9004,2);Sg(9026,1);Kg(9043,10);Sg(9060,2);Kg(9073,11);Sg(9086,3);Kg(9110,12);Tg(9134,3);Rg(9147,3);Sg(9160,4);Kg(9178,13);Sg(9196,5);Kg(9212,14);Sg(9228,6);Kg(9245,15);Ug(9262,2088);Ug(9291,2096);Ug(9319,2092);Cb(9352,680,0);Cb(9369,680,1);Cb(9385,680,0);Cb(9407,680,0);Cb(9432,680,1);Cb(9457,680,1);Cb(9482,680,100);Cb(9509,680,0);Cb(9535,680,1);Cb(9561,680,0);Cb(9588,680,0);Cb(9615,680,1);Cb(9641,680,2);Cb(9666,680,3);Cb(9704,680,4);Cb(9741,680,0);Cb(9775,680,0);Cb(9799,680,1);Cb(9825,680,2);Cb(9852,680,2);Cb(9886,680,5);h[b>>3]=.5;Vg(9904,b);Cb(9925,680,0);Cb(9944,680,1);Cb(9962,680,2);Cb(9980,680,3);Cb(9999,680,4);Cb(10021,680,3);Cb(10040,680,515);Cb(10069,680,259);Cb(10097,680,4);Cb(10116,680,772);Cb(10146,680,1028);Cb(10176,680,0);Cb(10207,680,1);Cb(10243,680,2);Cb(10277,680,3);Cb(10315,680,0);Cb(10348,680,1);Cb(10395,680,2);Cb(10437,680,3);Cb(10480,680,4);Cb(10532,680,5);Cb(10583,680,6);Cb(10628,680,7);Cb(10667,680,8);Cb(10712,680,9);i=a;return}function Cg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=c[b>>2]|0;f=c[a+4>>2]|0;a:do if(f){g=f+-1|0;h=(g&f|0)==0;if(h)e=g&d;else e=(d>>>0)%(f>>>0)|0;b=c[(c[a>>2]|0)+(e<<2)>>2]|0;if(b)do{b=c[b>>2]|0;if(!b){b=0;break a}a=c[b+4>>2]|0;if(h)a=a&g;else a=(a>>>0)%(f>>>0)|0;if((a|0)!=(e|0)){b=0;break a}}while((c[b+8>>2]|0)!=(d|0));else b=0}else b=0;while(0);return b|0}function Dg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=i;i=i+32|0;f=g+8|0;e=g;d=Cg(a,b)|0;if(!d){wh(f,a,b);xh(e,a,c[f>>2]|0);d=c[e>>2]|0;c[f>>2]=0}i=g;return d+16|0}function Eg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=i;i=i+16|0;d=f+4|0;e=f;b=Cg(a,b)|0;if(!b)b=0;else{c[e>>2]=b;c[d>>2]=c[e>>2];uh(a,d)|0;b=1}i=f;return b|0}function Fg(a){a=a|0;var b=0,d=0;d=c[a>>2]|0;if(d){b=a+4|0;a=c[b>>2]|0;if((a|0)!=(d|0)){do a=a+-8|0;while((a|0)!=(d|0));c[b>>2]=a}Lh(d)}return}function Gg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=i;i=i+32|0;f=g+8|0;e=g;d=Hg(a,b)|0;if(!d){qh(f,a,b);rh(e,a,c[f>>2]|0);d=c[e>>2]|0;c[f>>2]=0}i=g;return d+16|0}function Hg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=c[b>>2]|0;f=c[a+4>>2]|0;a:do if(f){g=f+-1|0;h=(g&f|0)==0;if(h)e=g&d;else e=(d>>>0)%(f>>>0)|0;b=c[(c[a>>2]|0)+(e<<2)>>2]|0;if(b)do{b=c[b>>2]|0;if(!b){b=0;break a}a=c[b+4>>2]|0;if(h)a=a&g;else a=(a>>>0)%(f>>>0)|0;if((a|0)!=(e|0)){b=0;break a}}while((c[b+8>>2]|0)!=(d|0));else b=0}else b=0;while(0);return b|0}function Ig(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0;j=i;i=i+32|0;h=j;g=a+4|0;d=c[a>>2]|0;f=((c[g>>2]|0)-d>>3)+1|0;if(f>>>0>536870911)Jh(a);e=d;d=(c[a+8>>2]|0)-e|0;if(d>>3>>>0<268435455){d=d>>2;d=d>>>0<f>>>0?f:d}else d=536870911;nh(h,d,(c[g>>2]|0)-e>>3,a+8|0);g=h+8|0;f=c[g>>2]|0;d=b;e=c[d+4>>2]|0;b=f;c[b>>2]=c[d>>2];c[b+4>>2]=e;c[g>>2]=f+8;oh(a,h);ph(h);i=j;return}function Jg(a,b){a=a|0;b=b|0;Oa(a|0,4,2200,10911,1,b|0);return}function Kg(a,b){a=a|0;b=b|0;Oa(a|0,2,2192,10801,10,b|0);return}function Lg(a,b){a=a|0;b=b|0;Oa(a|0,3,2180,10906,12,b|0);return}function Mg(a,b){a=a|0;b=b|0;Oa(a|0,3,2168,10906,13,b|0);return}function Ng(a,b){a=a|0;b=b|0;Oa(a|0,2,2160,10801,11,b|0);return}function Og(a,b){a=a|0;b=b|0;Oa(a|0,2,2152,10797,7,b|0);return}function Pg(a,b){a=a|0;b=b|0;Oa(a|0,1,2148,10794,16,b|0);return}function Qg(a,b){a=a|0;b=b|0;Oa(a|0,3,2136,10789,1,b|0);return}function Rg(a,b){a=a|0;b=b|0;Oa(a|0,2,2128,10785,1,b|0);return}function Sg(a,b){a=a|0;b=b|0;Oa(a|0,3,2116,10780,1,b|0);return}function Tg(a,b){a=a|0;b=b|0;Oa(a|0,3,2104,10775,2,b|0);return}function Ug(a,b){a=a|0;b=b|0;Cb(a|0,680,c[b>>2]|0);return}function Vg(a,b){a=a|0;b=b|0;Cb(a|0,720,~~+h[b>>3]>>>0|0);return}function Wg(){c[511]=0;c[512]=0;c[513]=0;c[514]=0;g[515]=1.0;ub(11,2044,n|0)|0;c[516]=0;c[517]=0;c[518]=0;c[519]=0;g[520]=1.0;ub(12,2064,n|0)|0;Bg(0);return}function Xg(a){a=a|0;$g(a);return}function Yg(a){a=a|0;Zg(a);return}function Zg(a){a=a|0;var b=0;_g(a,c[a+8>>2]|0);b=c[a>>2]|0;c[a>>2]=0;if(b)Lh(b);return}function _g(a,b){a=a|0;b=b|0;if(b)do{a=b;b=c[b>>2]|0;Lh(a)}while((b|0)!=0);return}function $g(a){a=a|0;var b=0;ah(a,c[a+8>>2]|0);b=c[a>>2]|0;c[a>>2]=0;if(b)Lh(b);return}function ah(a,b){a=a|0;b=b|0;if(b)do{a=b;b=c[b>>2]|0;Fg(a+264|0);Lh(a)}while((b|0)!=0);return}function bh(a,b,c){a=a|0;b=b|0;c=+c;Tb[a&3](b,c);return}function ch(a,b,c){a=a|0;b=b|0;c=c|0;Xb[a&7](b,c);return}function dh(a,b){a=a|0;b=b|0;return +(+Ub[a&3](b))}function eh(a,b,c){a=a|0;b=b|0;c=+c;Tb[a&3](b,c);return}function fh(a){a=a|0;return Vb[a&1]()|0}function gh(a,b){a=a|0;b=b|0;Wb[a&15](b);return}function hh(a,b){a=a|0;b=b|0;var c=0,d=0;c=i;i=i+16|0;d=c;ih(d,b);a=Yb[a&31](d)|0;bk(d);i=c;return a|0}function ih(a,b){a=a|0;b=b|0;ak(a,b+4|0,c[b>>2]|0);return}function jh(a,b,c){a=a|0;b=b|0;c=c|0;return cc[a&15](b,c)|0}function kh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=i;i=i+16|0;e=d;ih(e,c);a=cc[a&15](b,e)|0;bk(e);i=d;return a|0}function lh(a,b){a=a|0;b=b|0;return Yb[a&31](b)|0}function mh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Qb[a&15](b,c,d)|0}function nh(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;c[a+12>>2]=0;c[a+16>>2]=e;if(!b)e=0;else e=Kh(b<<3)|0;c[a>>2]=e;d=e+(d<<3)|0;c[a+8>>2]=d;c[a+4>>2]=d;c[a+12>>2]=e+(b<<3);return}function oh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;e=c[a>>2]|0;g=a+4|0;d=b+4|0;f=(c[g>>2]|0)-e|0;h=(c[d>>2]|0)+(0-(f>>3)<<3)|0;c[d>>2]=h;ik(h|0,e|0,f|0)|0;f=c[a>>2]|0;c[a>>2]=c[d>>2];c[d>>2]=f;f=b+8|0;e=c[g>>2]|0;c[g>>2]=c[f>>2];c[f>>2]=e;f=a+8|0;a=b+12|0;e=c[f>>2]|0;c[f>>2]=c[a>>2];c[a>>2]=e;c[b>>2]=c[d>>2];return}function ph(a){a=a|0;var b=0,d=0,e=0;d=c[a+4>>2]|0;e=a+8|0;b=c[e>>2]|0;if((b|0)!=(d|0)){do b=b+-8|0;while((b|0)!=(d|0));c[e>>2]=b}b=c[a>>2]|0;if(b)Lh(b);return}function qh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=Kh(200)|0;c[e+8>>2]=c[d>>2];ek(e+16|0,0,184)|0;c[a>>2]=e;a=a+4|0;c[a>>2]=b+8;c[a+4>>2]=257;return}function rh(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0.0,k=0.0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;m=c[e+8>>2]|0;s=e+4|0;c[s>>2]=m;r=d+4|0;l=c[r>>2]|0;q=(l|0)==0;a:do if(!q){n=l+-1|0;o=(n&l|0)==0;if(o)h=n&m;else h=(m>>>0)%(l>>>0)|0;f=c[(c[d>>2]|0)+(h<<2)>>2]|0;if(!f)p=12;else while(1){i=c[f>>2]|0;if(!i){p=12;break a}f=c[i+4>>2]|0;if(o)f=f&n;else f=(f>>>0)%(l>>>0)|0;if((f|0)!=(h|0)){p=12;break a}if((c[i+8>>2]|0)==(m|0)){f=0;e=i;break}else f=i}}else{h=0;p=12}while(0);if((p|0)==12){m=d+12|0;j=+(((c[m>>2]|0)+1|0)>>>0);k=+g[d+16>>2];do if(q|j>+(l>>>0)*k){if(l>>>0>2)f=(l+-1&l|0)==0;else f=0;i=(f&1|l<<1)^1;f=~~+_(+(j/k))>>>0;sh(d,i>>>0<f>>>0?f:i);i=c[r>>2]|0;f=c[s>>2]|0;h=i+-1|0;if(!(h&i)){l=i;h=h&f;break}else{l=i;h=(f>>>0)%(i>>>0)|0;break}}while(0);f=c[(c[d>>2]|0)+(h<<2)>>2]|0;if(!f){f=d+8|0;c[e>>2]=c[f>>2];c[f>>2]=e;c[(c[d>>2]|0)+(h<<2)>>2]=f;f=c[e>>2]|0;if(f){f=c[f+4>>2]|0;h=l+-1|0;if(!(h&l))f=f&h;else f=(f>>>0)%(l>>>0)|0;c[(c[d>>2]|0)+(f<<2)>>2]=e}}else{c[e>>2]=c[f>>2];c[f>>2]=e}c[m>>2]=(c[m>>2]|0)+1;f=1}c[b>>2]=e;a[b+4>>0]=f;return}
  10. function zd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l*3|0)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){do if(((d[s+1>>0]|0)+(d[s>>0]|0)+(d[s+2>>0]|0)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+3|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+6|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Ad(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<1)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){p=d[s>>0]|0;q=d[s+1>>0]|0;do if(((p&248)+10+(p<<5&224)+(q>>>3&28)+(q<<3&248)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Bd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<2)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){do if(((d[s+1>>0]|0)+(d[s>>0]|0)+(d[s+2>>0]|0)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+4|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+8|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Cd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<1)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){q=d[s>>0]|0;do if(((q&240)+24+(q<<4&240)+((d[s+1>>0]|0)&240)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Dd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<1)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){p=d[s>>0]|0;q=d[s+1>>0]|0;do if(((p&248)+12+(p<<5&224)+(q>>>3&24)+(q<<2&248)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Ed(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<2)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){do if(((d[s+2>>0]|0)+(d[s+1>>0]|0)+(d[s+3>>0]|0)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+4|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+8|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Fd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+l|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+1|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+2|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Gd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+(l<<1)|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t+1>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+2|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+4|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Hd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+(l<<1)|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+2|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+4|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Id(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;m=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;l=(c[k+4>>2]|0)+m|0;z=1;e=e+m|0;o=o+(m<<1)|0;j=j+m|0;m=0;b:while(1){if(y){u=1;t=e;s=m;while(1){do if((d[t>>0]|0)>(d[j>>0]|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+1|0;j=j+1|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}z=z+1|0;if((z|0)>=(B|0)){p=m;D=52;break a}else{l=l+2|0;e=e+2|0;o=o+4|0;j=j+2|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((p|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(p|0)){e=e+1|0;n=n+4|0}else break}}j=k+8|0;l=m+-1|0;c[j>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[j>>2]|0))}if((p|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(p|0))}if((c[j>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[j>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Jd(a){a=a|0;return Kd(a+8|0)|0}function Kd(a){a=a|0;var b=0,d=0;d=i;i=i+16|0;b=Uj(4)|0;if(!b){Me(3,5472,d);rb(1)}a=wf(a)|0;c[b>>2]=a;if(!a){Vj(b);b=0}i=d;return b|0}function Ld(a){a=a|0;var b=0;b=c[a>>2]|0;if(!b)b=-1;else{xf(b)|0;Vj(c[a>>2]|0);c[a>>2]=0;b=0}return b|0}function Md(a){a=a|0;var b=0,d=0,e=0;d=i;i=i+16|0;b=Uj(7062432)|0;if(!b){Me(3,5472,d);rb(1)}c[b>>2]=0;c[b+4834148>>2]=0;c[b+7062408>>2]=0;c[b+4>>2]=-1;c[b+8>>2]=0;c[b+12>>2]=1;c[b+16>>2]=100;c[b+20>>2]=0;c[b+24>>2]=0;c[b+28>>2]=2;h[b+7062416>>3]=.5;c[b+7062424>>2]=3;c[b+32>>2]=a;e=c[a>>2]|0;c[b+36>>2]=e;a=c[a+4>>2]|0;c[b+40>>2]=a;c[b+44>>2]=0;c[b+15408>>2]=0;c[b+4834152>>2]=0;c[b+4818296>>2]=0;a=Uj($(e<<1,a)|0)|0;c[b+4834144>>2]=a;if(!a){Me(3,5472,d+8|0);rb(1)}else{c[b+7062384>>2]=0;Nd(b,2)|0;Od(b,0)|0;c[b+7062388>>2]=-1;Pd(b,0)|0;c[b+7062392>>2]=7;c[b+7062396>>2]=0;i=d;return b|0}return 0}function Nd(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=i;i=i+16|0;d=g;a:do if(a){e=a+4|0;if((c[e>>2]|0)!=(b|0)){switch(b|0){case 11:case 10:case 9:case 8:case 7:case 6:case 4:case 3:case 2:case 1:case 0:{f=0;break}case 14:case 13:case 12:case 5:{f=1;break}default:{c[d>>2]=b;Me(3,3936,d);d=-1;break a}}c[e>>2]=b;c[a+8>>2]=Pe(b)|0;d=a+7062408|0;b=c[d>>2]|0;if(b){pe(b);c[d>>2]=oe(c[a+36>>2]|0,c[a+40>>2]|0,c[e>>2]|0,0)|0}d=a+24|0;b=c[d>>2]|0;if(!f)switch(b|0){case 1:{c[d>>2]=4;d=0;break a}case 4:{c[d>>2]=3;d=0;break a}default:{d=0;break a}}else switch(b|0){case 0:{c[d>>2]=1;d=0;break a}case 3:{c[d>>2]=4;d=0;break a}default:{d=0;break a}}}else d=0}else d=-1;while(0);i=g;return d|0}function Od(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=i;i=i+16|0;e=f;do if(a)if((c[a>>2]|0)!=(b|0)){c[a>>2]=b;if(!b){d=a+4834148|0;Vj(c[d>>2]|0);c[d>>2]=0;d=0;break}b=Uj($(c[a+40>>2]|0,c[a+36>>2]|0)|0)|0;c[a+4834148>>2]=b;if(!b){Me(3,5472,e);rb(1)}else d=0}else d=0;else d=-1;while(0);i=f;return d|0}function Pd(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0;j=i;i=i+16|0;h=j+8|0;f=j;if(a){g=a+7062388|0;if((c[g>>2]|0)!=(b|0)){d=a+7062408|0;e=c[d>>2]|0;if(e){pe(e);c[d>>2]=0}switch(b|0){case 3:case 2:case 1:{c[d>>2]=oe(c[a+36>>2]|0,c[a+40>>2]|0,c[a+4>>2]|0,0)|0;break}case 4:{c[a+7062404>>2]=1;c[a+7062400>>2]=1;b=4;break}case 0:{b=0;break}default:{Me(3,3985,f);b=0}}c[g>>2]=b;if((c[a>>2]|0)==1){c[h>>2]=c[760+(b<<2)>>2];Me(3,4059,h);b=0}else b=0}else b=0}else b=-1;i=j;return b|0}function Qd(a){a=a|0;var b=0,d=0;if(!a)b=-1;else{b=a+7062408|0;d=c[b>>2]|0;if(d){pe(d);c[b>>2]=0}Vj(c[a+4834144>>2]|0);Vj(c[a+4834148>>2]|0);Vj(a);b=0}return b|0}function Rd(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a>>2];a=0}else a=-1;return a|0}function Sd(a,b){a=a|0;b=b|0;if((a|0)!=0&b>>>0<2){c[a+12>>2]=b;a=0}else a=-1;return a|0}function Td(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+12>>2];a=0}else a=-1;return a|0}function Ud(a,b){a=a|0;b=b|0;if((a|0)==0|b>>>0>255)a=-1;else{c[a+16>>2]=b;a=0}return a|0}function Vd(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+16>>2];a=0}else a=-1;return a|0}function Wd(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+7062388>>2];a=0}else a=-1;return a|0}function Xd(a,b){a=a|0;b=b|0;if((a|0)!=0&b>>>0<2){c[a+20>>2]=b;a=0}else a=-1;return a|0}function Yd(a,b){a=a|0;b=b|0;if(!a)a=-1;else{c[b>>2]=c[a+20>>2];a=0}return a|0}function Zd(a,b){a=a|0;b=b|0;if((a|0)!=0&b>>>0<5){c[a+24>>2]=b;a=0}else a=-1;return a|0}function _d(a,b){a=a|0;b=b|0;if(!a)a=-1;else{c[a+7062424>>2]=b;a=0}return a|0}function $d(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+7062424>>2];a=0}else a=-1;return a|0}function ae(a,b){a=a|0;b=b|0;if(!a)a=-1;else{c[b>>2]=c[a+24>>2];a=0}return a|0}function be(a,b){a=a|0;b=+b;if((a|0)!=0?!(b<=0.0|b>=1.0):0){h[a+7062416>>3]=b;a=0}else a=-1;return a|0}function ce(a,b){a=a|0;b=b|0;if(!a)a=-1;else{h[b>>3]=+h[a+7062416>>3];a=0}return a|0}function de(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,j=0.0,k=0,l=0,m=0,n=0.0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0.0,S=0.0;Q=i;i=i+80|0;M=Q+32|0;G=Q+24|0;z=Q;y=Q+52|0;D=Q+40|0;L=Q+64|0;P=a+44|0;c[P>>2]=0;J=a+7062388|0;f=c[J>>2]|0;a:do if((f|0)==4){I=a+7062396|0;e=c[I>>2]|0;do if((e|0)>0){f=4;e=e+-1|0}else{C=a+16|0;F=c[C>>2]|0;E=a+7062400|0;A=(c[E>>2]|0)+F|0;A=(A|0)>255?255:A;c[y>>2]=A;H=a+7062404|0;B=F-(c[H>>2]|0)|0;B=(B|0)<0?0:B;c[y+4>>2]=B;c[y+8>>2]=F;e=a+36|0;f=a+40|0;g=a+4|0;k=a+12|0;l=a+20|0;m=a+4834144|0;p=a+15416|0;q=a+15408|0;r=a+7062384|0;s=a+24|0;t=a+32|0;u=a+7062416|0;v=a+48|0;w=a+7062424|0;x=0;do{if((xe(b,c[e>>2]|0,c[f>>2]|0,c[g>>2]|0,c[a>>2]|0,c[k>>2]|0,c[y+(x<<2)>>2]|0,c[l>>2]|0,m,0)|0)<0){e=-1;break a}if((fe(c[e>>2]|0,c[f>>2]|0,m,c[l>>2]|0,1e6,70,1.0,p,q)|0)<0){e=-1;break a}if((je(b,c[e>>2]|0,c[f>>2]|0,c[g>>2]|0,p,c[q>>2]|0,c[r>>2]|0,c[l>>2]|0,c[s>>2]|0,(c[t>>2]|0)+184|0,+h[u>>3],v,P,c[w>>2]|0)|0)<0){e=-1;break a}c[D+(x<<2)>>2]=c[P>>2];x=x+1|0}while((x|0)<3);if((c[a>>2]|0)==1){N=c[D+4>>2]|0;g=c[D+8>>2]|0;f=c[D>>2]|0;c[z>>2]=B;c[z+4>>2]=N;c[z+8>>2]=F;c[z+12>>2]=g;c[z+16>>2]=A;c[z+20>>2]=f;Me(3,4153,z)}else{f=c[D>>2]|0;g=c[D+8>>2]|0}e=c[D+4>>2]|0;if((f|0)>(g|0)|(e|0)>(g|0)){f=(f|0)>=(e|0)?A:B;c[C>>2]=f;e=f-F|0;if((e|0)>0){c[E>>2]=e;e=1}else{c[E>>2]=1;e=0-e|0}c[H>>2]=e;if((c[a>>2]|0)==1){c[G>>2]=f;Me(3,4229,G)}f=c[J>>2]|0;e=c[a+7062392>>2]|0;break}e=c[E>>2]|0;f=c[H>>2]|0;do if((e|0)>=(f|0))if((e|0)>(f|0)){c[H>>2]=f+1;break}else{e=e+1|0;c[E>>2]=e;c[H>>2]=f+1;break}else{e=e+1|0;c[E>>2]=e}while(0);if((e+F|0)>254){c[E>>2]=1;e=1}if((F|0)<=(e|0))c[H>>2]=1;c[I>>2]=c[a+7062392>>2];N=47;break a}while(0);c[I>>2]=e;N=30}else N=30;while(0);b:do if((N|0)==30){c:do switch(f|0){case 3:{f=a+7062408|0;e=we(c[f>>2]|0,b,9,-7)|0;if((e|0)<0)break b;e=c[f>>2]|0;f=a+4834144|0;e=xe(c[e>>2]|0,c[e+8>>2]|0,c[e+12>>2]|0,5,c[a>>2]|0,c[a+12>>2]|0,0,0,f,c[e+4>>2]|0)|0;if((e|0)<0)break b;e=a+36|0;g=a+40|0;k=a+20|0;break}case 2:case 1:{g=a+7062396|0;e=c[g>>2]|0;if((e|0)>0){c[g>>2]=e+-1;N=44;break c}e=c[a+7062408>>2]|0;if((f|0)==1)e=ue(e,b,L)|0;else e=ve(e,b,L)|0;if((e|0)<0)break b;e=a+16|0;if((c[a>>2]|0)==1?(K=d[L>>0]|0,(c[e>>2]|0)!=(K|0)):0){c[M>>2]=(c[J>>2]|0)==1?4281:4288;c[M+4>>2]=K;Me(3,4293,M)}c[e>>2]=d[L>>0];c[g>>2]=c[a+7062392>>2];N=44;break}default:N=44}while(0);if((N|0)==44){e=a+36|0;g=a+40|0;k=a+20|0;f=a+4834144|0;if((xe(b,c[e>>2]|0,c[g>>2]|0,c[a+4>>2]|0,c[a>>2]|0,c[a+12>>2]|0,c[a+16>>2]|0,c[k>>2]|0,f,0)|0)<0){e=-1;break}}l=a+15416|0;m=a+15408|0;if((fe(c[e>>2]|0,c[g>>2]|0,f,c[k>>2]|0,1e6,70,1.0,l,m)|0)>=0?(je(b,c[e>>2]|0,c[g>>2]|0,c[a+4>>2]|0,l,c[m>>2]|0,c[a+7062384>>2]|0,c[k>>2]|0,c[a+24>>2]|0,(c[a+32>>2]|0)+184|0,+h[a+7062416>>3],a+48|0,P,c[a+7062424>>2]|0)|0)>=0:0)N=47;else e=-1}while(0);d:do if((N|0)==47){t=a+28|0;if((c[t>>2]|0)==1){ee(a);e=0;break}u=a+4818296|0;r=a+24|0;q=c[u>>2]|0;if((q|0)>0){s=0;do{f=c[P>>2]|0;g=a+4818304+(s*264|0)+56|0;k=a+4818304+(s*264|0)+64|0;if((f|0)>0){o=+(c[a+4818304+(s*264|0)>>2]|0);e=-1;l=0;n=.5;while(1){j=+(c[a+48+(l<<8)>>2]|0);R=o/j;if(!(R<.7|R>1.43)?(R=+h[a+48+(l<<8)+56>>3]-+h[g>>3],O=+h[a+48+(l<<8)+64>>3]-+h[k>>3],O=(R*R+O*O)/j,O<n):0){e=l;j=O}else j=n;l=l+1|0;if((l|0)>=(f|0)){p=e;break}else n=j}}else p=-1;e:do if((p|0)>-1){m=c[r>>2]|0;switch(m|0){case 2:case 1:case 0:break;case 4:case 3:{g=a+48+(p<<8)+40|0;j=+h[a+4818304+(s*264|0)+40>>3];if(!(+h[g>>3]<j)){e=a+48+(p<<8)+48|0;f=a+4818304+(s*264|0)+48|0;if(!(+h[e>>3]<+h[f>>3]))break e}else{f=a+4818304+(s*264|0)+48|0;e=a+48+(p<<8)+48|0}h[g>>3]=j;c[a+48+(p<<8)+8>>2]=c[a+4818304+(s*264|0)+8>>2];h[e>>3]=+h[f>>3];c[a+48+(p<<8)+12>>2]=c[a+4818304+(s*264|0)+12>>2];e=-1;n=1.0e8;g=0;while(1){j=0.0;f=0;do{b=(f+g|0)%4|0;o=+h[a+4818304+(s*264|0)+168+(f<<4)>>3]-+h[a+48+(p<<8)+168+(b<<4)>>3];R=+h[a+4818304+(s*264|0)+168+(f<<4)+8>>3]-+h[a+48+(p<<8)+168+(b<<4)+8>>3];j=j+(o*o+R*R);f=f+1|0}while((f|0)!=4);f=j<n;e=f?g:e;g=g+1|0;if((g|0)==4)break;else n=f?j:n}b=4-e|0;c[a+48+(p<<8)+20>>2]=(b+(c[a+4818304+(s*264|0)+20>>2]|0)|0)%4|0;c[a+48+(p<<8)+24>>2]=(b+(c[a+4818304+(s*264|0)+24>>2]|0)|0)%4|0;break e}default:{e=-1;break d}}e=a+48+(p<<8)+32|0;o=+h[a+4818304+(s*264|0)+32>>3];if(+h[e>>3]<o){h[e>>3]=o;l=c[a+4818304+(s*264|0)+4>>2]|0;c[a+48+(p<<8)+4>>2]=l;g=a+4818304+(s*264|0)+16|0;e=-1;n=1.0e8;k=0;while(1){j=0.0;f=0;do{b=(f+k|0)%4|0;S=+h[a+4818304+(s*264|0)+168+(f<<4)>>3]-+h[a+48+(p<<8)+168+(b<<4)>>3];R=+h[a+4818304+(s*264|0)+168+(f<<4)+8>>3]-+h[a+48+(p<<8)+168+(b<<4)+8>>3];j=j+(S*S+R*R);f=f+1|0}while((f|0)!=4);if(j<n)e=(4-k+(c[g>>2]|0)|0)%4|0;else j=n;k=k+1|0;if((k|0)==4)break;else n=j}c[a+48+(p<<8)+16>>2]=e;if(m>>>0<2){c[a+48+(p<<8)+8>>2]=l;h[a+48+(p<<8)+40>>3]=o;c[a+48+(p<<8)+20>>2]=e;break}else{c[a+48+(p<<8)+12>>2]=l;h[a+48+(p<<8)+48>>3]=o;c[a+48+(p<<8)+24>>2]=e;break}}}while(0);s=s+1|0}while((s|0)<(q|0))}ee(a);if((c[u>>2]|0)>0){g=0;e=0;do{f=a+4818304+(g*264|0)|0;N=a+4818304+(g*264|0)+256|0;b=(c[N>>2]|0)+1|0;c[N>>2]=b;if((b|0)<4){if((g|0)!=(e|0))ik(a+4818304+(e*264|0)|0,f|0,264)|0;e=e+1|0}g=g+1|0}while((g|0)<(c[u>>2]|0))}else e=0;c[u>>2]=e;e=c[P>>2]|0;f:do if((e|0)>0){m=0;do{k=a+48+(m<<8)|0;g=c[a+48+(m<<8)+4>>2]|0;if((g|0)>=0){l=c[u>>2]|0;g:do if((l|0)>0){f=0;do{if((c[a+4818304+(f*264|0)+4>>2]|0)==(g|0))break g;f=f+1|0}while((f|0)<(l|0))}else f=0;while(0);if((f|0)==(l|0)){if((l|0)==60)break f;c[u>>2]=l+1}ik(a+4818304+(f*264|0)|0,k|0,256)|0;c[a+4818304+(f*264|0)+256>>2]=1}m=m+1|0;e=c[P>>2]|0}while((m|0)<(e|0))}while(0);if((c[t>>2]|0)!=2?(c[u>>2]|0)>0:0){l=0;while(1){g=a+4818304+(l*264|0)+56|0;k=a+4818304+(l*264|0)+64|0;h:do if((e|0)>0){n=+(c[a+4818304+(l*264|0)>>2]|0);f=0;do{j=+(c[a+48+(f<<8)>>2]|0);S=n/j;if(!(S<.7|S>1.43)?(R=+h[a+48+(f<<8)+56>>3]-+h[g>>3],S=+h[a+48+(f<<8)+64>>3]-+h[k>>3],(R*R+S*S)/j<.5):0)break h;f=f+1|0}while((f|0)<(e|0))}else f=0;while(0);if((f|0)==(e|0)){ik(a+48+(e<<8)|0,a+4818304+(l*264|0)|0,256)|0;e=(c[P>>2]|0)+1|0;c[P>>2]=e}l=l+1|0;if((l|0)>=(c[u>>2]|0)){e=0;break}}}else e=0}while(0);i=Q;return e|0}function ee(a){a=a|0;var b=0,d=0,e=0,f=0;switch(c[a+24>>2]|0){case 1:case 0:{d=c[a+44>>2]|0;if((d|0)>0){e=0;do{b=a+48+(e<<8)+4|0;if((c[b>>2]|0)>-1?+h[a+48+(e<<8)+32>>3]<.5:0){c[a+48+(e<<8)+8>>2]=-1;c[b>>2]=-1;c[a+48+(e<<8)+236>>2]=6}e=e+1|0}while((e|0)<(d|0))}break}case 2:{d=c[a+44>>2]|0;if((d|0)>0){e=0;do{b=a+48+(e<<8)+4|0;if((c[b>>2]|0)>-1?+h[a+48+(e<<8)+32>>3]<.5:0){c[a+48+(e<<8)+12>>2]=-1;c[b>>2]=-1;c[a+48+(e<<8)+236>>2]=6}e=e+1|0}while((e|0)<(d|0))}break}default:{e=c[a+44>>2]|0;if((e|0)>0){f=0;do{b=a+48+(f<<8)+8|0;if((c[b>>2]|0)>-1?+h[a+48+(f<<8)+40>>3]<.5:0){c[b>>2]=-1;d=0}else d=1;b=a+48+(f<<8)+12|0;if(((c[b>>2]|0)>-1?+h[a+48+(f<<8)+48>>3]<.5:0)?(c[b>>2]=-1,(d|0)==0):0)c[a+48+(f<<8)+236>>2]=6;f=f+1|0}while((f|0)<(e|0))}}}return}function fe(a,b,d,e,f,g,j,k,l){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;j=+j;k=k|0;l=l|0;var m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0.0;L=i;i=i+96|0;F=L+56|0;H=L+48|0;G=L+8|0;I=L;K=(e|0)==1;if(K){a=(a|0)/2|0;b=(b|0)/2|0;f=(f|0)/4|0;g=(g|0)/4|0}c[l>>2]=0;C=d+8|0;D=a+-2|0;z=b+-2|0;A=d+1179664|0;a:do if((c[C>>2]|0)>0){B=0;while(1){w=d+12+(B<<2)|0;y=c[w>>2]|0;b:do if(((((!((y|0)<(g|0)|(y|0)>(f|0))?(E=d+131084+(B<<4)|0,(c[E>>2]|0)!=1):0)?(c[d+131084+(B<<4)+4>>2]|0)!=(D|0):0)?(c[d+131084+(B<<4)+8>>2]|0)!=1:0)?(c[d+131084+(B<<4)+12>>2]|0)!=(z|0):0)?(ge(c[d>>2]|0,a,0,A,B+1|0,E,k+((c[l>>2]|0)*80048|0)|0)|0)>=0:0){t=c[w>>2]|0;x=c[l>>2]|0;u=k+(x*80048|0)+28|0;b=c[u>>2]|0;v=k+(x*80048|0)+40028|0;n=c[v>>2]|0;y=k+(x*80048|0)+24|0;o=(c[y>>2]|0)+-1|0;if((o|0)>1){r=0;s=1;e=0;while(1){p=(c[k+(x*80048|0)+28+(s<<2)>>2]|0)-b|0;p=$(p,p)|0;q=(c[k+(x*80048|0)+40028+(s<<2)>>2]|0)-n|0;p=($(q,q)|0)+p|0;q=(p|0)>(r|0);e=q?s:e;s=s+1|0;if((s|0)>=(o|0))break;else r=q?p:r}}else e=0;m=+(t|0)/.75*.01*j;c[H>>2]=0;c[I>>2]=0;c:do if((he(u,v,0,e,m,F,H)|0)>=0?(he(u,v,e,(c[y>>2]|0)+-1|0,m,G,I)|0)>=0:0){b=c[H>>2]|0;n=c[I>>2]|0;do if((b|0)==1&(n|0)==1){b=c[G>>2]|0;n=c[F>>2]|0}else{if((b|0)>1&(n|0)==0){b=(e|0)/2|0;c[I>>2]=0;c[H>>2]=0;if((he(u,v,0,b,m,F,H)|0)<0)break c;if((he(u,v,b,e,m,G,I)|0)<0)break c;if(!((c[H>>2]|0)==1&(c[I>>2]|0)==1))break c;b=e;n=c[F>>2]|0;e=c[G>>2]|0;break}if(!((b|0)==0&(n|0)>1))break c;b=(e+-1+(c[y>>2]|0)|0)/2|0;c[I>>2]=0;c[H>>2]=0;if((he(u,v,e,b,m,F,H)|0)<0)break c;if((he(u,v,b,(c[y>>2]|0)+-1|0,m,G,I)|0)<0)break c;if(!((c[H>>2]|0)==1&(c[I>>2]|0)==1))break c;b=c[G>>2]|0;n=e;e=c[F>>2]|0}while(0);c[k+(x*80048|0)+80028>>2]=0;c[k+(x*80048|0)+80032>>2]=n;c[k+(x*80048|0)+80036>>2]=e;c[k+(x*80048|0)+80040>>2]=b;c[k+(x*80048|0)+80044>>2]=(c[y>>2]|0)+-1;c[k+((c[l>>2]|0)*80048|0)>>2]=c[w>>2];y=c[l>>2]|0;h[k+(y*80048|0)+8>>3]=+h[d+655376+(B<<4)>>3];h[k+(y*80048|0)+16>>3]=+h[d+655376+(B<<4)+8>>3];y=y+1|0;c[l>>2]=y;if((y|0)==60){e=60;break a}else break b}while(0)}while(0);B=B+1|0;if((B|0)>=(c[C>>2]|0)){J=4;break}}}else J=4;while(0);if((J|0)==4)e=c[l>>2]|0;if((e|0)>0){o=0;do{a=o;o=o+1|0;g=k+(a*80048|0)+16|0;n=k+(a*80048|0)|0;if((o|0)<(e|0)){j=+h[k+(a*80048|0)+8>>3];f=o;do{M=j-+h[k+(f*80048|0)+8>>3];m=+h[g>>3]-+h[k+(f*80048|0)+16>>3];m=M*M+m*m;e=c[n>>2]|0;a=k+(f*80048|0)|0;b=c[a>>2]|0;if((e|0)>(b|0)){if(m<+((e|0)/4|0|0))c[a>>2]=0}else if(m<+((b|0)/4|0|0))c[n>>2]=0;f=f+1|0;e=c[l>>2]|0}while((f|0)<(e|0))}}while((o|0)<(e|0))}if((e|0)>0){f=0;do{if(!(c[k+(f*80048|0)>>2]|0)){a=f+1|0;if((a|0)<(e|0)){e=f;b=a;while(1){ik(k+(e*80048|0)|0,k+(b*80048|0)|0,80048)|0;e=c[l>>2]|0;a=b+1|0;if((a|0)<(e|0)){e=b;b=a}else break}}e=e+-1|0;c[l>>2]=e}f=f+1|0}while((f|0)<(e|0))}if(K&(e|0)>0){b=0;while(1){c[k>>2]=c[k>>2]<<2;e=k+8|0;h[e>>3]=+h[e>>3]*2.0;e=k+16|0;h[e>>3]=+h[e>>3]*2.0;e=k+24|0;if((c[e>>2]|0)>0){a=0;do{K=k+28+(a<<2)|0;c[K>>2]=c[K>>2]<<1;K=k+40028+(a<<2)|0;c[K>>2]=c[K>>2]<<1;a=a+1|0}while((a|0)<(c[e>>2]|0))}b=b+1|0;if((b|0)>=(c[l>>2]|0))break;else k=k+80048|0}}i=L;return 0}function ge(a,d,e,f,g,h,j){a=a|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;w=i;i=i+80032|0;p=w+16|0;o=w+8|0;l=w;u=w+40024|0;v=w+24|0;t=c[h+8>>2]|0;e=c[h>>2]|0;h=c[h+4>>2]|0;a:do if((e|0)<=(h|0)){k=e;e=a+(($(t,d)|0)+e<<1)|0;while(1){s=b[e>>1]|0;if(s<<16>>16>0?(c[f+((s<<16>>16)+-1<<2)>>2]|0)==(g|0):0){n=k;break}if((k|0)<(h|0)){k=k+1|0;e=e+2|0}else{x=6;break a}}q=j+24|0;c[q>>2]=1;r=j+28|0;c[r>>2]=n;s=j+40028|0;c[s>>2]=t;f=t;m=n;k=1;e=5;while(1){h=(e+5|0)%8|0;e=0;while(1){g=c[776+(h<<2)>>2]|0;l=c[808+(h<<2)>>2]|0;if((b[a+(l+m+($(g+f|0,d)|0)<<1)>>1]|0)>0){e=g;g=h;break}e=e+1|0;h=(h+1|0)%8|0;if((e|0)>=8){x=11;break}}if((x|0)==11){x=0;if((e|0)==8){x=13;break}l=c[808+(h<<2)>>2]|0;e=c[776+(h<<2)>>2]|0;g=h}c[j+28+(k<<2)>>2]=l+m;h=c[q>>2]|0;c[j+40028+(h<<2)>>2]=e+(c[j+40028+(h+-1<<2)>>2]|0);e=c[q>>2]|0;h=j+28+(e<<2)|0;if((c[h>>2]|0)==(n|0)?(c[j+40028+(e<<2)>>2]|0)==(t|0):0){f=e;x=16;break}k=e+1|0;c[q>>2]=k;if((k|0)==9999){x=19;break}f=c[j+40028+(e<<2)>>2]|0;m=c[h>>2]|0;e=g}if((x|0)==13){Me(3,4347,o);e=-1;break}else if((x|0)==16){if((f|0)>1){l=0;g=1;h=0;while(1){e=(c[j+28+(g<<2)>>2]|0)-n|0;e=$(e,e)|0;k=(c[j+40028+(g<<2)>>2]|0)-t|0;e=($(k,k)|0)+e|0;k=(e|0)>(l|0);h=k?g:h;g=g+1|0;if((g|0)>=(f|0))break;else l=k?e:l}}else h=0;if((h|0)>0){e=0;do{c[u+(e<<2)>>2]=c[j+28+(e<<2)>>2];c[v+(e<<2)>>2]=c[j+40028+(e<<2)>>2];e=e+1|0}while((e|0)<(h|0))}if((h|0)<(f|0)){e=h;do{t=e-h|0;c[j+28+(t<<2)>>2]=c[j+28+(e<<2)>>2];c[j+40028+(t<<2)>>2]=c[j+40028+(e<<2)>>2];e=e+1|0}while((e|0)<(c[q>>2]|0))}if((h|0)>0){e=0;do{t=e-h|0;c[j+28+((c[q>>2]|0)+t<<2)>>2]=c[u+(e<<2)>>2];c[j+40028+((c[q>>2]|0)+t<<2)>>2]=c[v+(e<<2)>>2];e=e+1|0}while((e|0)<(h|0))}c[j+28+(c[q>>2]<<2)>>2]=c[r>>2];c[j+40028+(c[q>>2]<<2)>>2]=c[s>>2];c[q>>2]=(c[q>>2]|0)+1;e=0;break}else if((x|0)==19){Me(3,4354,p);e=-1;break}}else x=6;while(0);if((x|0)==6){Me(3,4340,l);e=-1}i=w;return e|0}function he(a,b,d,e,f,g,h){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;g=g|0;h=h|0;var i=0,j=0.0,k=0.0,l=0,m=0.0,n=0,o=0.0,p=0,q=0,r=0,s=0.0;i=c[b+(e<<2)>>2]|0;q=c[b+(d<<2)>>2]|0;o=+(i-q|0);l=c[a+(d<<2)>>2]|0;r=c[a+(e<<2)>>2]|0;m=+(l-r|0);k=+(($(r,q)|0)-($(l,i)|0)|0);i=d+1|0;if((i|0)<(e|0)){j=0.0;l=i;do{s=k+(o*+(c[a+(l<<2)>>2]|0)+m*+(c[b+(l<<2)>>2]|0));s=s*s;r=s>j;j=r?s:j;i=r?l:i;l=l+1|0}while((l|0)<(e|0))}else j=0.0;if(j/(o*o+m*m)>f)if(((he(a,b,d,i,f,g,h)|0)>=0?(n=c[h>>2]|0,(n|0)<=5):0)?(c[g+(n<<2)>>2]=i,c[h>>2]=(c[h>>2]|0)+1,(he(a,b,i,e,f,g,h)|0)>=0):0)p=7;else i=-1;else p=7;if((p|0)==7)i=0;return i|0}function ie(a,b,d,e,f,j,k){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;j=j|0;k=k|0;var l=0,m=0.0,n=0,o=0.0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;y=i;i=i+16|0;t=y+4|0;u=y;v=nf(2)|0;w=nf(2)|0;x=Re(2,2)|0;q=0;a:while(1){r=q;q=q+1|0;s=c[e+(q<<2)>>2]|0;l=c[e+(r<<2)>>2]|0;p=+(s+1-l|0)*.05+.5;l=~~(+(l|0)+p);s=~~(+(s|0)-p)-l|0;n=s+1|0;d=Re(n,2)|0;if((s|0)>-1){s=0;do{z=s+l|0;if((mf(f,+(c[a+(z<<2)>>2]|0),+(c[b+(z<<2)>>2]|0),t,u)|0)<0){l=10;break a}z=s<<1;A=c[d>>2]|0;h[A+(z<<3)>>3]=+g[t>>2];h[A+((z|1)<<3)>>3]=+g[u>>2];s=s+1|0}while((s|0)<(n|0))}if((Ye(d,x,v,w)|0)<0){l=10;break}A=c[x>>2]|0;o=+h[A+8>>3];h[j+(r*24|0)>>3]=o;p=-+h[A>>3];h[j+(r*24|0)+8>>3]=p;A=c[w>>2]|0;h[j+(r*24|0)+16>>3]=-(o*+h[A>>3]+ +h[A+8>>3]*p);We(d)|0;if((q|0)>=4){l=7;break}}b:do if((l|0)==7){We(x)|0;of(w)|0;of(v)|0;q=0;while(1){d=(q+3|0)%4|0;l=j+(d*24|0)|0;m=+h[j+(q*24|0)+8>>3];n=j+(q*24|0)|0;o=+h[j+(d*24|0)+8>>3];p=+h[l>>3]*m-+h[n>>3]*o;if(+O(+p)<.0001){d=-1;break b}A=j+(q*24|0)+16|0;z=j+(d*24|0)+16|0;h[k+(q<<4)>>3]=(o*+h[A>>3]-m*+h[z>>3])/p;h[k+(q<<4)+8>>3]=(+h[n>>3]*+h[z>>3]-+h[l>>3]*+h[A>>3])/p;q=q+1|0;if((q|0)>=4){d=0;break}}}else if((l|0)==10){We(d)|0;We(x)|0;of(w)|0;of(v)|0;d=-1}while(0);i=y;return d|0}function je(a,b,d,e,f,j,k,l,m,n,o,p,q,r){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=+o;p=p|0;q=q|0;r=r|0;var s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;D=F+4|0;E=F;z=m>>>0<2;A=(m|0)==2;if((j|0)>0){C=0;s=0;do{c[p+(s<<8)>>2]=c[f+(C*80048|0)>>2];if((mf(n,+h[f+(C*80048|0)+8>>3],+h[f+(C*80048|0)+16>>3],D,E)|0)>=0?(h[p+(s<<8)+56>>3]=+g[D>>2],h[p+(s<<8)+64>>3]=+g[E>>2],B=p+(s<<8)+168|0,(ie(f+(C*80048|0)+28|0,f+(C*80048|0)+40028|0,c[f+(C*80048|0)+24>>2]|0,f+(C*80048|0)+80028|0,n,p+(s<<8)+72|0,B)|0)>=0):0){t=p+(s<<8)+8|0;u=p+(s<<8)+20|0;v=p+(s<<8)+40|0;w=p+(s<<8)+12|0;x=p+(s<<8)+24|0;y=p+(s<<8)+48|0;switch(De(k,l,m,a,b,d,e,n,B,o,t,u,v,w,x,y,r,p+(s<<8)+240|0,p+(s<<8)+248|0)|0){case 0:{c[p+(s<<8)+236>>2]=0;break}case -1:{c[p+(s<<8)+236>>2]=2;break}case -2:{c[p+(s<<8)+236>>2]=3;break}case -3:{c[p+(s<<8)+236>>2]=4;break}case -4:{c[p+(s<<8)+236>>2]=5;break}case -5:{c[p+(s<<8)+236>>2]=9;break}case -6:{c[p+(s<<8)+236>>2]=1;break}default:{}}if(!z){if(A){c[p+(s<<8)+4>>2]=c[w>>2];c[p+(s<<8)+16>>2]=c[x>>2];h[p+(s<<8)+32>>3]=+h[y>>3]}}else{c[p+(s<<8)+4>>2]=c[t>>2];c[p+(s<<8)+16>>2]=c[u>>2];h[p+(s<<8)+32>>3]=+h[v>>3]}s=s+1|0}C=C+1|0}while((C|0)<(j|0))}else s=0;c[q>>2]=s;i=F;return 0}function ke(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0;k=i;i=i+288|0;m=k+200|0;l=k+104|0;f=k+264|0;j=k+8|0;g=k;o=c[b+16>>2]|0;p=(4-o|0)%4|0;h[m>>3]=+h[b+168+(p<<4)>>3];h[m+8>>3]=+h[b+168+(p<<4)+8>>3];p=(5-o|0)%4|0;h[m+16>>3]=+h[b+168+(p<<4)>>3];h[m+24>>3]=+h[b+168+(p<<4)+8>>3];p=(6-o|0)%4|0;h[m+32>>3]=+h[b+168+(p<<4)>>3];h[m+40>>3]=+h[b+168+(p<<4)+8>>3];o=(7-o|0)%4|0;h[m+48>>3]=+h[b+168+(o<<4)>>3];h[m+56>>3]=+h[b+168+(o<<4)+8>>3];n=d*-.5;h[l>>3]=n;d=d*.5;h[l+8>>3]=d;h[l+16>>3]=0.0;h[l+24>>3]=d;h[l+32>>3]=d;h[l+40>>3]=0.0;h[l+48>>3]=d;h[l+56>>3]=n;h[l+64>>3]=0.0;h[l+72>>3]=n;h[l+80>>3]=n;h[l+88>>3]=0.0;c[f>>2]=m;c[f+4>>2]=l;c[f+8>>2]=4;if((Ef(c[a>>2]|0,m,l,4,j)|0)<0)d=1.0e8;else{p=(zf(c[a>>2]|0,f,j,e,g)|0)<0;d=p?1.0e8:+h[g>>3]}i=k;return +d}function le(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=+e;f=f|0;var g=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0;j=i;i=i+192|0;m=j+104|0;l=j+8|0;k=j+168|0;g=j;o=c[b+16>>2]|0;p=(4-o|0)%4|0;h[m>>3]=+h[b+168+(p<<4)>>3];h[m+8>>3]=+h[b+168+(p<<4)+8>>3];p=(5-o|0)%4|0;h[m+16>>3]=+h[b+168+(p<<4)>>3];h[m+24>>3]=+h[b+168+(p<<4)+8>>3];p=(6-o|0)%4|0;h[m+32>>3]=+h[b+168+(p<<4)>>3];h[m+40>>3]=+h[b+168+(p<<4)+8>>3];o=(7-o|0)%4|0;h[m+48>>3]=+h[b+168+(o<<4)>>3];h[m+56>>3]=+h[b+168+(o<<4)+8>>3];n=e*-.5;h[l>>3]=n;e=e*.5;h[l+8>>3]=e;h[l+16>>3]=0.0;h[l+24>>3]=e;h[l+32>>3]=e;h[l+40>>3]=0.0;h[l+48>>3]=e;h[l+56>>3]=n;h[l+64>>3]=0.0;h[l+72>>3]=n;h[l+80>>3]=n;h[l+88>>3]=0.0;c[k>>2]=m;c[k+4>>2]=l;c[k+8>>2]=4;b=(zf(c[a>>2]|0,k,d,f,g)|0)<0;i=j;return +(b?1.0e8:+h[g>>3])}function me(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+32|0;m=p+20|0;n=p;j=Uj(f<<4)|0;c[m>>2]=j;if(!j){Me(3,5472,p+8|0);rb(1)}k=Uj(f*24|0)|0;l=m+4|0;c[l>>2]=k;if(!k){Me(3,5472,p+16|0);rb(1)}if((f|0)>0){o=0;do{h[j+(o<<4)>>3]=+h[d+(o<<4)>>3];h[j+(o<<4)+8>>3]=+h[d+(o<<4)+8>>3];h[k+(o*24|0)>>3]=+h[e+(o*24|0)>>3];h[k+(o*24|0)+8>>3]=+h[e+(o*24|0)+8>>3];h[k+(o*24|0)+16>>3]=+h[e+(o*24|0)+16>>3];o=o+1|0}while((o|0)<(f|0))}c[m+8>>2]=f;if((zf(c[a>>2]|0,m,b,g,n)|0)<0)h[n>>3]=1.0e8;Vj(c[m>>2]|0);Vj(c[l>>2]|0);i=p;return +(+h[n>>3])}function ne(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+32|0;m=p+20|0;n=p;j=Uj(f<<4)|0;c[m>>2]=j;if(!j){Me(3,5472,p+8|0);rb(1)}k=Uj(f*24|0)|0;l=m+4|0;c[l>>2]=k;if(!k){Me(3,5472,p+16|0);rb(1)}if((f|0)>0){o=0;do{h[j+(o<<4)>>3]=+h[d+(o<<4)>>3];h[j+(o<<4)+8>>3]=+h[d+(o<<4)+8>>3];h[k+(o*24|0)>>3]=+h[e+(o*24|0)>>3];h[k+(o*24|0)+8>>3]=+h[e+(o*24|0)+8>>3];h[k+(o*24|0)+16>>3]=+h[e+(o*24|0)+16>>3];o=o+1|0}while((o|0)<(f|0))}c[m+8>>2]=f;if((Bf(c[a>>2]|0,m,b,g,n)|0)<0)h[n>>3]=1.0e8;Vj(c[m>>2]|0);Vj(c[l>>2]|0);i=p;return +(+h[n>>3])}function oe(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=Uj(2080)|0;a:do if(f){c[f+2068>>2]=d;b:do if(!e){switch(d|0){case 5:case 12:case 13:case 14:break;default:{g=4;break b}}c[f+2076>>2]=0}else g=4;while(0);do if((g|0)==4){g=Uj($(b,a)|0)|0;c[f>>2]=g;if(!g){Vj(f);f=0;break a}else{c[f+2076>>2]=1;break}}while(0);c[f+2072>>2]=e;c[f+4>>2]=0;c[f+8>>2]=a;c[f+12>>2]=b}while(0);return f|0}function pe(a){a=a|0;if(a){if(c[a+2076>>2]|0)Vj(c[a>>2]|0);Vj(c[a+4>>2]|0);Vj(a)}return}function qe(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0;k=i;i=i+16|0;g=k;f=c[b+2068>>2]|0;a:do switch(f|0){case 5:case 12:case 13:case 14:if(!(c[b+2072>>2]|0)){c[b>>2]=e;f=0;break a}else{ik(c[b>>2]|0,e|0,$(c[b+12>>2]|0,c[b+8>>2]|0)|0)|0;f=0;break a}default:{if((f&-2|0)==2){f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=(((d[e+(j|1)>>0]|0)+(d[e+j>>0]|0)+(d[e+(j|2)>>0]|0)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break a}else j=j+4|0}}if((f&-3|0)==4){f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=(((d[e+(j|2)>>0]|0)+(d[e+(j|1)>>0]|0)+(d[e+(j|3)>>0]|0)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break a}else j=j+4|0}}if(f>>>0<2){f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=(((d[e+(j+1)>>0]|0)+(d[e+j>>0]|0)+(d[e+(j+2)>>0]|0)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break a}else j=j+3|0}}switch(f|0){case 8:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=a[e+j>>0]|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 7:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=a[e+(j|1)>>0]|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 9:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){m=d[e+j>>0]|0;l=d[e+(j|1)>>0]|0;a[(c[b>>2]|0)+h>>0]=(((m&248)+10+(m<<5&224)+(l>>>3&28)+(l<<3&248)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 10:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){l=d[e+j>>0]|0;m=d[e+(j|1)>>0]|0;a[(c[b>>2]|0)+h>>0]=(((l&248)+12+(l<<5&224)+(m>>>3&24)+(m<<2&248)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 11:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){m=d[e+j>>0]|0;a[(c[b>>2]|0)+h>>0]=(((m&240)+24+(m<<4&240)+((d[e+(j|1)>>0]|0)&240)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}default:{Me(3,4361,g);f=-1;break a}}}}while(0);i=k;return f|0}function re(a,b){a=a|0;b=b|0;var e=0,f=0;if((a|0)!=0&(b|0)!=0?(qe(a,b)|0)>=0:0){ek(a+16|0,0,1024)|0;b=c[a>>2]|0;f=$(c[a+12>>2]|0,c[a+8>>2]|0)|0;e=b+f|0;if((f|0)>0){do{f=a+16+((d[b>>0]|0)<<2)|0;c[f>>2]=(c[f>>2]|0)+1;b=b+1|0}while(b>>>0<e>>>0);b=0}else b=0}else b=-1;return b|0}function se(a,b){a=a|0;b=b|0;var d=0;b=re(a,b)|0;if((b|0)>=0){b=0;d=0;do{b=(c[a+16+(d<<2)>>2]|0)+b|0;c[a+1040+(d<<2)>>2]=b;d=d+1|0}while((d|0)!=256);b=0}return b|0}function te(b,d,e,f){b=b|0;d=d|0;e=+e;f=f|0;var g=0,h=0,i=0;if(!(e<0.0|e>1.0)){d=se(b,d)|0;if((d|0)>=0){i=~~(+($(c[b+12>>2]|0,c[b+8>>2]|0)|0)*e)>>>0;d=0;while(1){h=d&255;g=c[b+1040+(h<<2)>>2]|0;if(g>>>0<i>>>0)d=d+1<<24>>24;else break}if((g|0)==(i|0))do d=d+1<<24>>24;while((c[b+1040+((d&255)<<2)>>2]|0)==(i|0));a[f>>0]=((d&255)+h|0)>>>1;d=0}}else d=-1;return d|0}function ue(a,b,c){a=a|0;b=b|0;c=c|0;return te(a,b,.5,c)|0}function ve(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,g=0,h=0.0,i=0.0,j=0.0,k=0.0,l=0,m=0.0,n=0.0;d=re(b,d)|0;if((d|0)>=0){d=1;f=0.0;do{f=f+ +(($(c[b+16+(d<<2)>>2]|0,d)|0)>>>0);d=d+1|0}while((d|0)!=256);k=+($(c[b+12>>2]|0,c[b+8>>2]|0)|0);l=0;h=0.0;d=0;j=0.0;m=0.0;while(1){g=c[b+16+(l<<2)>>2]|0;m=m+ +(g>>>0);if(m!=0.0){i=k-m;if(i==0.0)break;h=h+ +(($(l,g)|0)>>>0);n=h/m-(f-h)/i;i=n*(m*i*n);if(i>j)d=l&255;else i=j}else i=j;if((l&255)<<24>>24==-1)break;else{l=l+1|0;j=i}}a[e>>0]=d;d=0}return d|0}function we(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;e=re(b,e)|0;do if((e|0)>=0){t=b+4|0;if(!(c[t>>2]|0)){e=b+8|0;h=b+12|0;s=Uj($(c[h>>2]|0,c[e>>2]|0)|0)|0;c[t>>2]=s;if(!s){e=-1;break}else s=e}else{s=b+8|0;h=b+12|0}q=f>>1;r=0-q|0;e=c[h>>2]|0;if((e|0)>0){n=(q|0)<(r|0);o=(q|0)<(r|0);p=0;do{e=c[s>>2]|0;if((e|0)>0){m=0;do{if(n){i=0;f=0}else{i=0;l=r;f=0;while(1){j=l+p|0;if(((j|0)>=0?(j|0)<(c[h>>2]|0):0)?(u=$(e,j)|0,!o):0){k=r;while(1){j=k+m|0;if((j|0)>-1&(j|0)<(e|0)){i=i+1|0;f=(d[(c[b>>2]|0)+(u+j)>>0]|0)+f|0}if((k|0)<(q|0))k=k+1|0;else break}}if((l|0)<(q|0))l=l+1|0;else break}}l=($(e,p)|0)+m|0;a[(c[t>>2]|0)+l>>0]=(f|0)/(i|0)|0;m=m+1|0;e=c[s>>2]|0}while((m|0)<(e|0))}p=p+1|0;e=c[h>>2]|0}while((p|0)<(e|0))}if((g|0)!=0?($(e,c[s>>2]|0)|0)>0:0){e=0;do{b=(c[t>>2]|0)+e|0;a[b>>0]=(d[b>>0]|0)+g;e=e+1|0}while((e|0)<($(c[h>>2]|0,c[s>>2]|0)|0));e=0}else e=0}while(0);return e|0}function xe(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0;a:do switch(e|0){case 0:{switch(f|0){case 1:{if(j){k=Fc(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=wc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=yc(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Bc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Cc(a,b,c,g,i)|0;break a}case 8:{k=Ec(a,b,c,g,i)|0;break a}case 7:{k=Dc(a,b,c,g,i)|0;break a}case 9:{k=xc(a,b,c,g,i)|0;break a}case 10:{k=Ac(a,b,c,g,i)|0;break a}case 11:{k=zc(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=nc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=pc(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=sc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=tc(a,b,c,g,i)|0;break a}case 8:{k=vc(a,b,c,g,i)|0;break a}case 7:{k=uc(a,b,c,g,i)|0;break a}case 9:{k=oc(a,b,c,g,i)|0;break a}case 10:{k=rc(a,b,c,g,i)|0;break a}case 11:{k=qc(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}case 0:{if(j){k=Yc(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=Pc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=Rc(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Uc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Vc(a,b,c,g,i)|0;break a}case 8:{k=Xc(a,b,c,g,i)|0;break a}case 7:{k=Wc(a,b,c,g,i)|0;break a}case 9:{k=Qc(a,b,c,g,i)|0;break a}case 10:{k=Tc(a,b,c,g,i)|0;break a}case 11:{k=Sc(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=Gc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=Ic(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Lc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Mc(a,b,c,g,i)|0;break a}case 8:{k=Oc(a,b,c,g,i)|0;break a}case 7:{k=Nc(a,b,c,g,i)|0;break a}case 9:{k=Hc(a,b,c,g,i)|0;break a}case 10:{k=Kc(a,b,c,g,i)|0;break a}case 11:{k=Jc(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}default:rb(0)}break}case 1:{switch(f|0){case 1:{if(j){k=pd(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=gd(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=id(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=ld(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=md(a,b,c,g,i)|0;break a}case 8:{k=od(a,b,c,g,i)|0;break a}case 7:{k=nd(a,b,c,g,i)|0;break a}case 9:{k=hd(a,b,c,g,i)|0;break a}case 10:{k=kd(a,b,c,g,i)|0;break a}case 11:{k=jd(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=Zc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=$c(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=cd(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=dd(a,b,c,g,i)|0;break a}case 8:{k=fd(a,b,c,g,i)|0;break a}case 7:{k=ed(a,b,c,g,i)|0;break a}case 9:{k=_c(a,b,c,g,i)|0;break a}case 10:{k=bd(a,b,c,g,i)|0;break a}case 11:{k=ad(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}case 0:{if(j){k=Id(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=zd(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=Bd(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Ed(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Fd(a,b,c,g,i)|0;break a}case 8:{k=Hd(a,b,c,g,i)|0;break a}case 7:{k=Gd(a,b,c,g,i)|0;break a}case 9:{k=Ad(a,b,c,g,i)|0;break a}case 10:{k=Dd(a,b,c,g,i)|0;break a}case 11:{k=Cd(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=qd(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=sd(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=vd(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=wd(a,b,c,g,i)|0;break a}case 8:{k=yd(a,b,c,g,i)|0;break a}case 7:{k=xd(a,b,c,g,i)|0;break a}case 9:{k=rd(a,b,c,g,i)|0;break a}case 10:{k=ud(a,b,c,g,i)|0;break a}case 11:{k=td(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}default:rb(0)}break}default:rb(0)}while(0);return k|0}function ye(a,b){a=a|0;b=b|0;var d=0;if((a|0)!=0?(d=a+7062384|0,(c[d>>2]|0)==0):0){c[d>>2]=b;d=0}else d=-1;return d|0}function ze(a){a=a|0;var b=0;if((a|0)!=0?(b=a+7062384|0,(c[b>>2]|0)!=0):0){c[b>>2]=0;b=0}else b=-1;return b|0}function Ae(){return Be(16,50)|0}function Be(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+64|0;q=r+56|0;p=r+48|0;j=r+40|0;h=r+32|0;g=r+24|0;f=r+16|0;e=r+8|0;d=r;a:do if(!((a+-16|0)>>>0>48|(b|0)<1)){n=Uj(32)|0;if(!n){Me(3,5472,d);rb(1)}c[n>>2]=0;c[n+4>>2]=b;c[n+28>>2]=a;m=Uj(b<<2)|0;c[n+8>>2]=m;if(!m){Me(3,5472,e);rb(1)}d=b<<4;l=Uj(d)|0;c[n+12>>2]=l;if(!l){Me(3,5472,f);rb(1)}f=Uj(d)|0;k=n+20|0;c[k>>2]=f;if(!f){Me(3,5472,g);rb(1)}d=b<<5;g=Uj(d)|0;c[n+16>>2]=g;if(!g){Me(3,5472,h);rb(1)}h=Uj(d)|0;c[n+24>>2]=h;if(!h){Me(3,5472,j);rb(1)}e=$(a,a)|0;d=e*12|0;e=e<<2;if((b|0)>0){a=0;b:while(1){c[m+(a<<2)>>2]=0;f=a<<2;h=0;while(1){if((h|0)>=4)break;j=Uj(d)|0;g=h+f|0;c[l+(g<<2)>>2]=j;if(!j){d=18;break b}j=Uj(e)|0;c[(c[k>>2]|0)+(g<<2)>>2]=j;if(!j){d=20;break b}else h=h+1|0}a=a+1|0;if((a|0)>=(b|0)){o=n;break a}}if((d|0)==18){Me(3,5472,p);rb(1)}else if((d|0)==20){Me(3,5472,q);rb(1)}}else o=n}else o=0;while(0);i=r;return o|0}function Ce(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;if(!a)b=-1;else{b=a+4|0;d=a+8|0;e=a+12|0;f=a+20|0;if((c[b>>2]|0)>0){g=0;do{if(c[(c[d>>2]|0)+(g<<2)>>2]|0)Le(a,g)|0;h=g<<2;Vj(c[(c[e>>2]|0)+(h<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(h<<2)>>2]|0);i=1+h|0;Vj(c[(c[e>>2]|0)+(i<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(i<<2)>>2]|0);i=2+h|0;Vj(c[(c[e>>2]|0)+(i<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(i<<2)>>2]|0);h=3+h|0;Vj(c[(c[e>>2]|0)+(h<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(h<<2)>>2]|0);g=g+1|0}while((g|0)<(c[b>>2]|0))}Vj(a);b=0}return b|0}function De(b,e,f,g,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x){b=b|0;e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=+o;p=p|0;q=q|0;r=r|0;s=s|0;t=t|0;u=u|0;v=v|0;w=w|0;x=x|0;var y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;L=i;i=i+12448|0;A=L+12440|0;z=L+8|0;J=L;I=L+12312|0;K=L+24|0;do if((f+-2|0)>>>0<3){if((v|0)!=2830){y=v&255;if((Ee(e,2,y,y*3|0,g,j,k,l,m,n,o,K)|0)<0){c[s>>2]=-1;y=-6;break}y=Fe(K,y,s,t,u,v,w)|0;if(!x)break;c[x>>2]=0;c[x+4>>2]=0;break}if((Ee(e,2,14,42,g,j,k,l,m,n,.875,K)|0)<0){c[s>>2]=-1;y=-6;break}c[z>>2]=0;c[z+4>>2]=182;c[z+8>>2]=195;c[z+12>>2]=13;v=a[K+(c[z>>2]|0)>>0]|0;y=(v&255)>0?v:0;v=(v&255)<255?v:-1;H=a[K+(c[z+4>>2]|0)>>0]|0;y=(H&255)>(y&255)?H:y;v=(H&255)<(v&255)?H:v;H=a[K+(c[z+8>>2]|0)>>0]|0;y=(H&255)>(y&255)?H:y;v=(H&255)<(v&255)?H:v;H=a[K+(c[z+12>>2]|0)>>0]|0;y=((H&255)>(y&255)?H:y)&255;v=((H&255)<(v&255)?H:v)&255;a:do if((y-v|0)>=30){H=(y+v|0)>>>1;a[A>>0]=(d[K+(c[z>>2]|0)>>0]|0)>>>0<H>>>0&1;a[A+1>>0]=(d[K+(c[z+4>>2]|0)>>0]|0)>>>0<H>>>0&1;a[A+2>>0]=(d[K+(c[z+8>>2]|0)>>0]|0)>>>0<H>>>0&1;a[A+3>>0]=(d[K+(c[z+12>>2]|0)>>0]|0)>>>0<H>>>0&1;v=0;while(1){y=v+1|0;if(((a[A+v>>0]|0)==1?(a[A+((y|0)%4|0)>>0]|0)==1:0)?(a[A+((v+2|0)%4|0)>>0]|0)==0:0){G=v;break}if((y|0)<4)v=y;else{G=y;break}}switch(G|0){case 4:{c[t>>2]=0;h[u>>3]=-1.0;y=-3;v=0;z=0;break a}case 0:{z=119;y=255;v=0;do{D=v+-3|0;B=(v&-2|0)==12;C=v*14|0;A=0;do{if(((A+-3|D)>>>0>=8?(F=A&-2,(A|v)>>>0>=2):0)?!(B&((F|0)==0|(F|0)==12)):0){E=(d[K+(A+C)>>0]|0)-H|0;a[I+z>>0]=E>>>31;E=(E|0)>-1?E:0-E|0;z=z+-1|0;y=(E|0)<(y|0)?E:y}A=A+1|0}while((A|0)!=14);v=v+1|0}while((v|0)!=14);break}case 1:{z=119;y=255;v=0;do{D=v+-3|0;C=v&-2;B=(C|0)==0;C=(C|0)==12;A=13;while(1){if(((A+-3|D)>>>0>=8?(E=(A&-2|0)==12,!(B&E)):0)?!(C&(A>>>0<2|E)):0){F=(d[K+((A*14|0)+v)>>0]|0)-H|0;a[I+z>>0]=F>>>31;F=(F|0)>-1?F:0-F|0;z=z+-1|0;y=(F|0)<(y|0)?F:y}if((A|0)>0)A=A+-1|0;else break}v=v+1|0}while((v|0)!=14);break}case 2:{v=119;y=255;D=13;while(1){B=D+-3|0;C=D>>>0<2|(D&-2|0)==12;A=D*14|0;z=13;while(1){if((z+-3|B)>>>0>=8?!((z|D)>>>0<2|C&(z&-2|0)==12):0){F=(d[K+(z+A)>>0]|0)-H|0;a[I+v>>0]=F>>>31;F=(F|0)>-1?F:0-F|0;v=v+-1|0;y=(F|0)<(y|0)?F:y}if((z|0)>0)z=z+-1|0;else break}if((D|0)>0)D=D+-1|0;else break}break}case 3:{v=119;y=255;D=13;while(1){C=D+-3|0;B=D&-2;A=(B|0)==12;B=(B|0)==0;z=0;do{if(((z+-3|C)>>>0>=8?!(A&z>>>0<2|(z|D)>>>0<2):0)?!(B&(z&-2|0)==12):0){F=(d[K+((z*14|0)+D)>>0]|0)-H|0;a[I+v>>0]=F>>>31;F=(F|0)>-1?F:0-F|0;v=v+-1|0;y=(F|0)<(y|0)?F:y}z=z+1|0}while((z|0)!=14);if((D|0)>0)D=D+-1|0;else break}break}default:y=255}c[t>>2]=G;h[u>>3]=(y|0)>30?1.0:+(y|0)/30.0;y=Ie(2830,0,0,I,J)|0;if((y|0)<0){y=-4;v=0;z=0}else{if(w)c[w>>2]=y;z=J;y=0;v=c[z>>2]|0;z=c[z+4>>2]|0}}else{c[t>>2]=0;h[u>>3]=-1.0;y=-2;v=0;z=0}while(0);if((y|0)<0){c[s>>2]=-1;break}if((v|0)==-1&(z|0)==-1){c[s>>2]=-1;y=-5;break}c[s>>2]=(v&-32768|0)==0&0==0?v&32767:0;if(!x)y=0;else{y=x;c[y>>2]=v;c[y+4>>2]=z;y=0}}else y=1;while(0);b:do switch(f|0){case 0:case 1:case 3:case 4:{if(!b){c[p>>2]=-1;v=-1;break b}v=b+28|0;z=c[v>>2]|0;A=z<<2;switch(f|0){case 0:case 3:if((Ee(e,0,z,A,g,j,k,l,m,n,o,K)|0)<0){c[p>>2]=-1;v=-6;break b}else{v=Ge(b,0,K,c[v>>2]|0,p,q,r)|0;break b}default:if((Ee(e,1,z,A,g,j,k,l,m,n,o,K)|0)<0){c[p>>2]=-1;v=-6;break b}else{v=Ge(b,1,K,c[v>>2]|0,p,q,r)|0;break b}}}default:v=1}while(0);if((y|0)!=1){if((v|0)!=1)y=(v&y|0)<0?v:0}else y=v;i=L;return y|0}
  11. function _j(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;k=i;i=i+16|0;b=k+8|0;h=k+4|0;d=k;c[h>>2]=a;do if(a>>>0>=212){g=(a>>>0)/210|0;e=g*210|0;c[d>>2]=a-e;b=($j(3712,3904,d,b)|0)-3712>>2;f=b;b=(c[3712+(b<<2)>>2]|0)+e|0;a:while(1){e=5;while(1){if(e>>>0>=47){e=211;j=8;break}d=c[3520+(e<<2)>>2]|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=106;break a}if((b|0)==($(a,d)|0))break;else e=e+1|0}b:do if((j|0)==8)while(1){j=0;d=(b>>>0)/(e>>>0)|0;if(d>>>0<e>>>0){j=105;break a}if((b|0)==($(d,e)|0))break b;d=e+10|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+12|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+16|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+18|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+22|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+28|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+30|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+36|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+40|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+42|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+46|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+52|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+58|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+60|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+66|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+70|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+72|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+78|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+82|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+88|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+96|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+100|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+102|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+106|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+108|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+112|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+120|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+126|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+130|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+136|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+138|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+142|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+148|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+150|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+156|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+162|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+166|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+168|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+172|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+178|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+180|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+186|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+190|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+192|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+196|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+198|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+208|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0<d>>>0){j=105;break a}if((b|0)==($(a,d)|0))break;else{e=e+210|0;j=8}}while(0);e=f+1|0;b=(e|0)==48;e=b?0:e;b=(b&1)+g|0;f=e;g=b;b=(c[3712+(e<<2)>>2]|0)+(b*210|0)|0}if((j|0)==105){c[h>>2]=b;break}else if((j|0)==106){c[h>>2]=b;break}}else b=c[($j(3520,3712,h,b)|0)>>2]|0;while(0);i=k;return b|0}function $j(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=c[d>>2]|0;e=a;d=b-a>>2;a:while(1){while(1){if(!d)break a;a=(d|0)/2|0;if((c[e+(a<<2)>>2]|0)>>>0<f>>>0)break;else d=a}e=e+(a+1<<2)|0;d=d+-1-a|0}return e|0}function ak(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;if(e>>>0>4294967279)oi(b);if(e>>>0<11){a[b>>0]=e<<1;b=b+1|0}else{g=e+16&-16;f=Kh(g)|0;c[b+8>>2]=f;c[b>>2]=g|1;c[b+4>>2]=e;b=f}ik(b|0,d|0,e|0)|0;a[b+e>>0]=0;return}function bk(b){b=b|0;if(a[b>>0]&1)Lh(c[b+8>>2]|0);return}function ck(){}function dk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;d=b-d-(c>>>0>a>>>0|0)>>>0;return (D=d,a-c>>>0|0)|0}function ek(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=b+e|0;if((e|0)>=20){d=d&255;h=b&3;i=d|d<<8|d<<16|d<<24;g=f&~3;if(h){h=b+4-h|0;while((b|0)<(h|0)){a[b>>0]=d;b=b+1|0}}while((b|0)<(g|0)){c[b>>2]=i;b=b+4|0}}while((b|0)<(f|0)){a[b>>0]=d;b=b+1|0}return b-e|0}function fk(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b<<c|(a&(1<<c)-1<<32-c)>>>32-c;return a<<c}D=a<<c-32;return 0}function gk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;c=a+c>>>0;return (D=b+d+(c>>>0<a>>>0|0)>>>0,c|0)|0}function hk(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b>>>c;return a>>>c|(b&(1<<c)-1)<<32-c}D=0;return b>>>c-32|0}function ik(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if((e|0)>=4096)return Xa(b|0,d|0,e|0)|0;f=b|0;if((b&3)==(d&3)){while(b&3){if(!e)return f|0;a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}while((e|0)>=4){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0;e=e-4|0}}while((e|0)>0){a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}return f|0}function jk(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b>>c;return a>>>c|(b&(1<<c)-1)<<32-c}D=(b|0)<0?-1:0;return b>>c-32|0}function kk(b){b=b|0;var c=0;c=a[m+(b&255)>>0]|0;if((c|0)<8)return c|0;c=a[m+(b>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=a[m+(b>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return (a[m+(b>>>24)>>0]|0)+24|0}function lk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;f=a&65535;e=b&65535;c=$(e,f)|0;d=a>>>16;a=(c>>>16)+($(e,d)|0)|0;e=b>>>16;b=$(e,f)|0;return (D=(a>>>16)+($(e,d)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|c&65535|0)|0}function mk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=b>>31|((b|0)<0?-1:0)<<1;i=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;f=d>>31|((d|0)<0?-1:0)<<1;e=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;h=dk(j^a,i^b,j,i)|0;g=D;a=f^j;b=e^i;return dk((rk(h,g,dk(f^c,e^d,f,e)|0,D,0)|0)^a,D^b,a,b)|0}function nk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0;f=i;i=i+16|0;j=f|0;h=b>>31|((b|0)<0?-1:0)<<1;g=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;l=e>>31|((e|0)<0?-1:0)<<1;k=((e|0)<0?-1:0)>>31|((e|0)<0?-1:0)<<1;a=dk(h^a,g^b,h,g)|0;b=D;rk(a,b,dk(l^d,k^e,l,k)|0,D,j)|0;e=dk(c[j>>2]^h,c[j+4>>2]^g,h,g)|0;d=D;i=f;return (D=d,e)|0}function ok(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;f=c;c=lk(e,f)|0;a=D;return (D=($(b,f)|0)+($(d,e)|0)+a|a&0,c|0|0)|0}function pk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return rk(a,b,c,d,0)|0}function qk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;g=i;i=i+16|0;f=g|0;rk(a,b,d,e,f)|0;i=g;return (D=c[f+4>>2]|0,c[f>>2]|0)|0}function rk(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;l=a;j=b;k=j;h=d;n=e;i=n;if(!k){g=(f|0)!=0;if(!i){if(g){c[f>>2]=(l>>>0)%(h>>>0);c[f+4>>2]=0}n=0;f=(l>>>0)/(h>>>0)>>>0;return (D=n,f)|0}else{if(!g){n=0;f=0;return (D=n,f)|0}c[f>>2]=a|0;c[f+4>>2]=b&0;n=0;f=0;return (D=n,f)|0}}g=(i|0)==0;do if(h){if(!g){g=(ba(i|0)|0)-(ba(k|0)|0)|0;if(g>>>0<=31){m=g+1|0;i=31-g|0;b=g-31>>31;h=m;a=l>>>(m>>>0)&b|k<<i;b=k>>>(m>>>0)&b;g=0;i=l<<i;break}if(!f){n=0;f=0;return (D=n,f)|0}c[f>>2]=a|0;c[f+4>>2]=j|b&0;n=0;f=0;return (D=n,f)|0}g=h-1|0;if(g&h){i=(ba(h|0)|0)+33-(ba(k|0)|0)|0;p=64-i|0;m=32-i|0;j=m>>31;o=i-32|0;b=o>>31;h=i;a=m-1>>31&k>>>(o>>>0)|(k<<m|l>>>(i>>>0))&b;b=b&k>>>(i>>>0);g=l<<p&j;i=(k<<p|l>>>(o>>>0))&j|l<<m&i-33>>31;break}if(f){c[f>>2]=g&l;c[f+4>>2]=0}if((h|0)==1){o=j|b&0;p=a|0|0;return (D=o,p)|0}else{p=kk(h|0)|0;o=k>>>(p>>>0)|0;p=k<<32-p|l>>>(p>>>0)|0;return (D=o,p)|0}}else{if(g){if(f){c[f>>2]=(k>>>0)%(h>>>0);c[f+4>>2]=0}o=0;p=(k>>>0)/(h>>>0)>>>0;return (D=o,p)|0}if(!l){if(f){c[f>>2]=0;c[f+4>>2]=(k>>>0)%(i>>>0)}o=0;p=(k>>>0)/(i>>>0)>>>0;return (D=o,p)|0}g=i-1|0;if(!(g&i)){if(f){c[f>>2]=a|0;c[f+4>>2]=g&k|b&0}o=0;p=k>>>((kk(i|0)|0)>>>0);return (D=o,p)|0}g=(ba(i|0)|0)-(ba(k|0)|0)|0;if(g>>>0<=30){b=g+1|0;i=31-g|0;h=b;a=k<<i|l>>>(b>>>0);b=k>>>(b>>>0);g=0;i=l<<i;break}if(!f){o=0;p=0;return (D=o,p)|0}c[f>>2]=a|0;c[f+4>>2]=j|b&0;o=0;p=0;return (D=o,p)|0}while(0);if(!h){k=i;j=0;i=0}else{m=d|0|0;l=n|e&0;k=gk(m|0,l|0,-1,-1)|0;d=D;j=i;i=0;do{e=j;j=g>>>31|j<<1;g=i|g<<1;e=a<<1|e>>>31|0;n=a>>>31|b<<1|0;dk(k,d,e,n)|0;p=D;o=p>>31|((p|0)<0?-1:0)<<1;i=o&1;a=dk(e,n,o&m,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&l)|0;b=D;h=h-1|0}while((h|0)!=0);k=j;j=0}h=0;if(f){c[f>>2]=a;c[f+4>>2]=b}o=(g|0)>>>31|(k|h)<<1|(h<<1|g>>>31)&0|j;p=(g<<1|0>>>31)&-2|i;return (D=o,p)|0}function sk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Qb[a&15](b|0,c|0,d|0)|0}function tk(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Rb[a&3](b|0,c|0,d|0,e|0,f|0)}function uk(a,b,c){a=a|0;b=b|0;c=c|0;return +Sb[a&1](b|0,c|0)}function vk(a,b,c){a=a|0;b=b|0;c=+c;Tb[a&3](b|0,+c)}function wk(a,b){a=a|0;b=b|0;return +Ub[a&3](b|0)}function xk(a){a=a|0;return Vb[a&1]()|0}function yk(a,b){a=a|0;b=b|0;Wb[a&15](b|0)}function zk(a,b,c){a=a|0;b=b|0;c=c|0;Xb[a&7](b|0,c|0)}function Ak(a,b){a=a|0;b=b|0;return Yb[a&31](b|0)|0}function Bk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Zb[a&1](b|0,c|0,d|0)}function Ck(a){a=a|0;_b[a&0]()}function Dk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;$b[a&3](b|0,c|0,+d)}function Ek(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ac[a&1](b|0,c|0,d|0,e|0)|0}function Fk(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;bc[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function Gk(a,b,c){a=a|0;b=b|0;c=c|0;return cc[a&15](b|0,c|0)|0}function Hk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;dc[a&3](b|0,c|0,d|0,e|0)}function Ik(a,b,c){a=a|0;b=b|0;c=c|0;ca(0);return 0}function Jk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(1)}function Kk(a,b){a=a|0;b=b|0;ca(2);return 0.0}function Lk(a,b){a=a|0;b=+b;ca(3)}function Mk(a){a=a|0;ca(4);return 0.0}function Nk(){ca(5);return 0}function Ok(a){a=a|0;ca(6)}function Pk(a,b){a=a|0;b=b|0;ca(7)}function Qk(a){a=a|0;ca(8);return 0}function Rk(a,b,c){a=a|0;b=b|0;c=c|0;ca(9)}function Sk(){ca(10)}function Tk(a,b,c){a=a|0;b=b|0;c=+c;ca(11)}function Uk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(12);return 0}function Vk(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(13)}function Wk(a,b){a=a|0;b=b|0;ca(14);return 0}function Xk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(15)}
  12. // EMSCRIPTEN_END_FUNCS
  13. var Qb=[Ik,Zh,_h,Qj,Qi,Pi,Ri,Ag,sg,qg,rg,yg,kh,jh,Oi,Mj];var Rb=[Jk,ki,ji,gi];var Sb=[Kk,dh];var Tb=[Lk,Wf,Yf,ag];var Ub=[Mk,Xf,Zf,bg];var Vb=[Nk,Nf];var Wb=[Ok,Mh,Nh,Sh,Vh,Th,Uh,Wh,Xh,Yh,Mf,Xg,Yg,Ij,Jj,Ok];var Xb=[Pk,ig,gg,_f,cg,eg,ng,gh];var Yb=[Qk,Oh,Ni,Pf,Vf,Qf,wg,xg,mg,lg,jg,hg,$f,dg,fg,og,fh,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk];var Zb=[Rk,ch];var _b=[Sk];var $b=[Tk,eh,bh,Tk];var ac=[Uk,mh];var bc=[Vk,ni,mi,li];var cc=[Wk,Df,Sf,Tf,Uf,tg,vg,ug,zg,kg,lh,hh,Wk,Wk,Wk,Wk];var dc=[Xk,ai,bi,di];return{_i64Subtract:dk,_fflush:Yi,_i64Add:gk,_memset:ek,_malloc:Uj,_memcpy:ik,___getTypeName:Ah,_bitshift64Lshr:hk,_free:Vj,___errno_location:qi,_bitshift64Shl:fk,__GLOBAL__sub_I_ARToolKitJS_cpp:Wg,__GLOBAL__sub_I_bind_cpp:Ch,runPostSets:ck,stackAlloc:ec,stackSave:fc,stackRestore:gc,establishStackSpace:hc,setThrew:ic,setTempRet0:lc,getTempRet0:mc,dynCall_iiii:sk,dynCall_viiiii:tk,dynCall_dii:uk,dynCall_vid:vk,dynCall_di:wk,dynCall_i:xk,dynCall_vi:yk,dynCall_vii:zk,dynCall_ii:Ak,dynCall_viii:Bk,dynCall_v:Ck,dynCall_viid:Dk,dynCall_iiiii:Ek,dynCall_viiiiii:Fk,dynCall_iii:Gk,dynCall_viiii:Hk}})
  14. // EMSCRIPTEN_END_ASM
  15. (Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var __GLOBAL__sub_I_bind_cpp=Module["__GLOBAL__sub_I_bind_cpp"]=asm["__GLOBAL__sub_I_bind_cpp"];var _fflush=Module["_fflush"]=asm["_fflush"];var __GLOBAL__sub_I_ARToolKitJS_cpp=Module["__GLOBAL__sub_I_ARToolKitJS_cpp"]=asm["__GLOBAL__sub_I_ARToolKitJS_cpp"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _memset=Module["_memset"]=asm["_memset"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var ___getTypeName=Module["___getTypeName"]=asm["___getTypeName"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _free=Module["_free"]=asm["_free"];var ___errno_location=Module["___errno_location"]=asm["___errno_location"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_dii=Module["dynCall_dii"]=asm["dynCall_dii"];var dynCall_vid=Module["dynCall_vid"]=asm["dynCall_vid"];var dynCall_di=Module["dynCall_di"]=asm["dynCall_di"];var dynCall_i=Module["dynCall_i"]=asm["dynCall_i"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_viid=Module["dynCall_viid"]=asm["dynCall_viid"];var dynCall_iiiii=Module["dynCall_iiiii"]=asm["dynCall_iiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];Runtime.stackAlloc=asm["stackAlloc"];Runtime.stackSave=asm["stackSave"];Runtime.stackRestore=asm["stackRestore"];Runtime.establishStackSpace=asm["establishStackSpace"];Runtime.setTempRet0=asm["setTempRet0"];Runtime.getTempRet0=asm["getTempRet0"];function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var preloadStartTime=null;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=Module.callMain=function callMain(args){assert(runDependencies==0,"cannot call main when async dependencies remain! (listen on __ATMAIN__)");assert(__ATPRERUN__.length==0,"cannot call main when preRun functions remain to be called");args=args||[];ensureInitRuntime();var argc=args.length+1;function pad(){for(var i=0;i<4-1;i++){argv.push(0)}}var argv=[allocate(intArrayFromString(Module["thisProgram"]),"i8",ALLOC_NORMAL)];pad();for(var i=0;i<argc-1;i=i+1){argv.push(allocate(intArrayFromString(args[i]),"i8",ALLOC_NORMAL));pad()}argv.push(0);argv=allocate(argv,"i32",ALLOC_NORMAL);try{var ret=Module["_main"](argc,argv,0);exit(ret,true)}catch(e){if(e instanceof ExitStatus){return}else if(e=="SimulateInfiniteLoop"){Module["noExitRuntime"]=true;return}else{if(e&&typeof e==="object"&&e.stack)Module.printErr("exception thrown: "+[e,e.stack]);throw e}}finally{calledMain=true}};function run(args){args=args||Module["arguments"];if(preloadStartTime===null)preloadStartTime=Date.now();if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(Module["_main"]&&shouldRunNow)Module["callMain"](args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=Module.run=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["stdout"]["once"]("drain",(function(){process["exit"](status)}));console.log(" ");setTimeout((function(){process["exit"](status)}),500)}else if(ENVIRONMENT_IS_SHELL&&typeof quit==="function"){quit(status)}throw new ExitStatus(status)}Module["exit"]=Module.exit=exit;var abortDecorators=[];function abort(what){if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;var extra="\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";var output="abort("+what+") at "+stackTrace()+extra;if(abortDecorators){abortDecorators.forEach((function(decorator){output=decorator(output,what)}))}throw output}Module["abort"]=Module.abort=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=true;if(Module["noInitialRun"]){shouldRunNow=false}run()
  16. ;(function() {
  17. 'use strict'
  18. /**
  19. The ARController is the main object for doing AR marker detection with JSARToolKit.
  20. To use an ARController, you need to tell it the dimensions to use for the AR processing canvas and
  21. pass it an ARCameraParam to define the camera parameters to use when processing images.
  22. The ARCameraParam defines the lens distortion and aspect ratio of the camera used.
  23. See https://www.artoolworks.com/support/library/Calibrating_your_camera for more information about AR camera parameteters and how to make and use them.
  24. If you pass an image as the first argument, the ARController uses that as the image to process,
  25. using the dimensions of the image as AR processing canvas width and height. If the first argument
  26. to ARController is an image, the second argument is used as the camera param.
  27. The camera parameters argument can be either an ARCameraParam or an URL to a camera definition file.
  28. If the camera argument is an URL, it is loaded into a new ARCameraParam, and the ARController dispatches
  29. a 'load' event and calls the onload method if it is defined.
  30. @exports ARController
  31. @constructor
  32. @param {number} width The width of the images to process.
  33. @param {number} height The height of the images to process.
  34. @param {ARCameraParam | string} camera The ARCameraParam to use for image processing. If this is a string, the ARController treats it as an URL and tries to load it as a ARCameraParam definition file, calling ARController#onload on success.
  35. */
  36. var ARController = function(width, height, camera) {
  37. var id;
  38. var w = width, h = height;
  39. this.orientation = 'landscape';
  40. this.listeners = {};
  41. if (typeof width !== 'number') {
  42. var image = width;
  43. camera = height;
  44. w = image.videoWidth || image.width;
  45. h = image.videoHeight || image.height;
  46. this.image = image;
  47. }
  48. this.defaultMarkerWidth = 1;
  49. this.patternMarkers = {};
  50. this.barcodeMarkers = {};
  51. this.transform_mat = new Float32Array(16);
  52. this.canvas = document.createElement('canvas');
  53. this.canvas.width = w;
  54. this.canvas.height = h;
  55. this.ctx = this.canvas.getContext('2d');
  56. this.videoWidth = w;
  57. this.videoHeight = h;
  58. if (typeof camera === 'string') {
  59. var self = this;
  60. this.cameraParam = new ARCameraParam(camera, function() {
  61. self._initialize();
  62. }, function(err) {
  63. console.error("ARController: Failed to load ARCameraParam", err);
  64. });
  65. } else {
  66. this.cameraParam = camera;
  67. this._initialize();
  68. }
  69. };
  70. /**
  71. Destroys the ARController instance and frees all associated resources.
  72. After calling dispose, the ARController can't be used any longer. Make a new one if you need one.
  73. Calling this avoids leaking Emscripten memory, which may be important if you're using multiple ARControllers.
  74. */
  75. ARController.prototype.dispose = function() {
  76. artoolkit.teardown(this.id);
  77. for (var t in this) {
  78. this[t] = null;
  79. }
  80. };
  81. /**
  82. Detects markers in the given image. The process method dispatches marker detection events during its run.
  83. The marker detection process proceeds by first dispatching a markerNum event that tells you how many
  84. markers were found in the image. Next, a getMarker event is dispatched for each found marker square.
  85. Finally, getMultiMarker is dispatched for every found multimarker, followed by getMultiMarkerSub events
  86. dispatched for each of the markers in the multimarker.
  87. arController.addEventListener('markerNum', function(ev) {
  88. console.log("Detected " + ev.data + " markers.")
  89. });
  90. arController.addEventListener('getMarker', function(ev) {
  91. console.log("Detected marker with ids:", ev.data.marker.id, ev.data.marker.idPatt, ev.data.marker.idMatrix);
  92. console.log("Marker data", ev.data.marker);
  93. console.log("Marker transform matrix:", [].join.call(ev.data.matrix, ', '));
  94. });
  95. arController.addEventListener('getMultiMarker', function(ev) {
  96. console.log("Detected multimarker with id:", ev.data.multiMarkerId);
  97. });
  98. arController.addEventListener('getMultiMarkerSub', function(ev) {
  99. console.log("Submarker for " + ev.data.multiMarkerId, ev.data.markerIndex, ev.data.marker);
  100. });
  101. arController.process(image);
  102. If no image is given, defaults to this.image.
  103. If the debugSetup has been called, draws debug markers on the debug canvas.
  104. @param {ImageElement | VideoElement} image The image to process [optional].
  105. */
  106. ARController.prototype.process = function(image) {
  107. this.detectMarker(image);
  108. var markerNum = this.getMarkerNum();
  109. var k,o;
  110. for (k in this.patternMarkers) {
  111. o = this.patternMarkers[k]
  112. o.inPrevious = o.inCurrent;
  113. o.inCurrent = false;
  114. }
  115. for (k in this.barcodeMarkers) {
  116. o = this.barcodeMarkers[k]
  117. o.inPrevious = o.inCurrent;
  118. o.inCurrent = false;
  119. }
  120. for (var i=0; i<markerNum; i++) {
  121. var markerInfo = this.getMarker(i);
  122. var markerType = artoolkit.UNKNOWN_MARKER;
  123. var visible = this.trackPatternMarkerId(-1);
  124. if (markerInfo.idPatt > -1 && (markerInfo.id === markerInfo.idPatt || markerInfo.idMatrix === -1)) {
  125. visible = this.trackPatternMarkerId(markerInfo.idPatt);
  126. markerType = artoolkit.PATTERN_MARKER;
  127. if (markerInfo.dir !== markerInfo.dirPatt) {
  128. this.setMarkerInfoDir(i, markerInfo.dirPatt);
  129. }
  130. } else if (markerInfo.idMatrix > -1) {
  131. visible = this.trackBarcodeMarkerId(markerInfo.idMatrix);
  132. markerType = artoolkit.BARCODE_MARKER;
  133. if (markerInfo.dir !== markerInfo.dirMatrix) {
  134. this.setMarkerInfoDir(i, markerInfo.dirMatrix);
  135. }
  136. }
  137. if (markerType !== artoolkit.UNKNOWN_MARKER && visible.inPrevious) {
  138. this.getTransMatSquareCont(i, visible.markerWidth, visible.matrix, visible.matrix);
  139. } else {
  140. this.getTransMatSquare(i, visible.markerWidth, visible.matrix);
  141. }
  142. // this.getTransMatSquare(i, visible.markerWidth, visible.matrix);
  143. visible.inCurrent = true;
  144. this.transMatToGLMat(visible.matrix, this.transform_mat);
  145. this.dispatchEvent({
  146. name: 'getMarker',
  147. target: this,
  148. data: {
  149. index: i,
  150. type: markerType,
  151. marker: markerInfo,
  152. matrix: this.transform_mat
  153. }
  154. });
  155. }
  156. var multiMarkerCount = this.getMultiMarkerCount();
  157. for (var i=0; i<multiMarkerCount; i++) {
  158. var subMarkerCount = this.getMultiMarkerPatternCount(i);
  159. var visible = false;
  160. artoolkit.getTransMatMultiSquareRobust(this.id, i);
  161. this.transMatToGLMat(this.marker_transform_mat, this.transform_mat);
  162. for (var j=0; j<subMarkerCount; j++) {
  163. var multiEachMarkerInfo = this.getMultiEachMarker(i, j);
  164. if (multiEachMarkerInfo.visible >= 0) {
  165. visible = true;
  166. this.dispatchEvent({
  167. name: 'getMultiMarker',
  168. target: this,
  169. data: {
  170. multiMarkerId: i,
  171. matrix: this.transform_mat
  172. }
  173. });
  174. break;
  175. }
  176. }
  177. if (visible) {
  178. for (var j=0; j<subMarkerCount; j++) {
  179. var multiEachMarkerInfo = this.getMultiEachMarker(i, j);
  180. this.transMatToGLMat(this.marker_transform_mat, this.transform_mat);
  181. this.dispatchEvent({
  182. name: 'getMultiMarkerSub',
  183. target: this,
  184. data: {
  185. multiMarkerId: i,
  186. markerIndex: j,
  187. marker: multiEachMarkerInfo,
  188. matrix: this.transform_mat
  189. }
  190. });
  191. }
  192. }
  193. }
  194. if (this._bwpointer) {
  195. this.debugDraw();
  196. }
  197. };
  198. /**
  199. Adds the given pattern marker ID to the index of tracked IDs.
  200. Sets the markerWidth for the pattern marker to markerWidth.
  201. Used by process() to implement continuous tracking,
  202. keeping track of the marker's transformation matrix
  203. and customizable marker widths.
  204. @param {number} id ID of the pattern marker to track.
  205. @param {number} markerWidth The width of the marker to track.
  206. @return {Object} The marker tracking object.
  207. */
  208. ARController.prototype.trackPatternMarkerId = function(id, markerWidth) {
  209. var obj = this.patternMarkers[id];
  210. if (!obj) {
  211. this.patternMarkers[id] = obj = {
  212. inPrevious: false,
  213. inCurrent: false,
  214. matrix: new Float32Array(12),
  215. markerWidth: markerWidth || this.defaultMarkerWidth
  216. };
  217. }
  218. if (markerWidth) {
  219. obj.markerWidth = markerWidth;
  220. }
  221. return obj;
  222. };
  223. /**
  224. Adds the given barcode marker ID to the index of tracked IDs.
  225. Sets the markerWidth for the pattern marker to markerWidth.
  226. Used by process() to implement continuous tracking,
  227. keeping track of the marker's transformation matrix
  228. and customizable marker widths.
  229. @param {number} id ID of the barcode marker to track.
  230. @param {number} markerWidth The width of the marker to track.
  231. @return {Object} The marker tracking object.
  232. */
  233. ARController.prototype.trackBarcodeMarkerId = function(id, markerWidth) {
  234. var obj = this.barcodeMarkers[id];
  235. if (!obj) {
  236. this.barcodeMarkers[id] = obj = {
  237. inPrevious: false,
  238. inCurrent: false,
  239. matrix: new Float32Array(12),
  240. markerWidth: markerWidth || this.defaultMarkerWidth
  241. };
  242. }
  243. if (markerWidth) {
  244. obj.markerWidth = markerWidth;
  245. }
  246. return obj;
  247. };
  248. /**
  249. Returns the number of multimarkers registered on this ARController.
  250. @return {number} Number of multimarkers registered.
  251. */
  252. ARController.prototype.getMultiMarkerCount = function() {
  253. return artoolkit.getMultiMarkerCount(this.id);
  254. };
  255. /**
  256. Returns the number of markers in the multimarker registered for the given multiMarkerId.
  257. @param {number} multiMarkerId The id number of the multimarker to access. Given by loadMultiMarker.
  258. @return {number} Number of markers in the multimarker. Negative value indicates failure to find the multimarker.
  259. */
  260. ARController.prototype.getMultiMarkerPatternCount = function(multiMarkerId) {
  261. return artoolkit.getMultiMarkerNum(this.id, multiMarkerId);
  262. };
  263. /**
  264. Add an event listener on this ARController for the named event, calling the callback function
  265. whenever that event is dispatched.
  266. Possible events are:
  267. * getMarker - dispatched whenever process() finds a square marker
  268. * getMultiMarker - dispatched whenever process() finds a visible registered multimarker
  269. * getMultiMarkerSub - dispatched by process() for each marker in a visible multimarker
  270. * load - dispatched when the ARController is ready to use (useful if passing in a camera URL in the constructor)
  271. @param {string} name Name of the event to listen to.
  272. @param {function} callback Callback function to call when an event with the given name is dispatched.
  273. */
  274. ARController.prototype.addEventListener = function(name, callback) {
  275. if (!this.listeners[name]) {
  276. this.listeners[name] = [];
  277. }
  278. this.listeners[name].push(callback);
  279. };
  280. /**
  281. Remove an event listener from the named event.
  282. @param {string} name Name of the event to stop listening to.
  283. @param {function} callback Callback function to remove from the listeners of the named event.
  284. */
  285. ARController.prototype.removeEventListener = function(name, callback) {
  286. if (this.listeners[name]) {
  287. var index = this.listeners[name].indexOf(callback);
  288. if (index > -1) {
  289. this.listeners[name].splice(index, 1);
  290. }
  291. }
  292. };
  293. /**
  294. Dispatches the given event to all registered listeners on event.name.
  295. @param {Object} event Event to dispatch.
  296. */
  297. ARController.prototype.dispatchEvent = function(event) {
  298. var listeners = this.listeners[event.name];
  299. if (listeners) {
  300. for (var i=0; i<listeners.length; i++) {
  301. listeners[i].call(this, event);
  302. }
  303. }
  304. };
  305. /**
  306. Sets up a debug canvas for the AR detection. Draws a red marker on top of each detected square in the image.
  307. The debug canvas is added to document.body.
  308. */
  309. ARController.prototype.debugSetup = function() {
  310. document.body.appendChild(this.canvas)
  311. this.setDebugMode(1);
  312. this._bwpointer = this.getProcessingImage();
  313. };
  314. /**
  315. Loads a pattern marker from the given URL and calls the onSuccess callback with the UID of the marker.
  316. arController.loadMarker(markerURL, onSuccess, onError);
  317. @param {string} markerURL - The URL of the marker pattern file to load.
  318. @param {function} onSuccess - The success callback. Called with the id of the loaded marker on a successful load.
  319. @param {function} onError - The error callback. Called with the encountered error if the load fails.
  320. */
  321. ARController.prototype.loadMarker = function(markerURL, onSuccess, onError) {
  322. return artoolkit.addMarker(this.id, markerURL, onSuccess, onError);
  323. };
  324. /**
  325. Loads a multimarker from the given URL and calls the onSuccess callback with the UID of the marker.
  326. arController.loadMultiMarker(markerURL, onSuccess, onError);
  327. @param {string} markerURL - The URL of the multimarker pattern file to load.
  328. @param {function} onSuccess - The success callback. Called with the id and the number of sub-markers of the loaded marker on a successful load.
  329. @param {function} onError - The error callback. Called with the encountered error if the load fails.
  330. */
  331. ARController.prototype.loadMultiMarker = function(markerURL, onSuccess, onError) {
  332. return artoolkit.addMultiMarker(this.id, markerURL, onSuccess, onError);
  333. };
  334. /**
  335. * Populates the provided float array with the current transformation for the specified marker. After
  336. * a call to detectMarker, all marker information will be current. Marker transformations can then be
  337. * checked.
  338. * @param {number} markerUID The unique identifier (UID) of the marker to query
  339. * @param {number} markerWidth The width of the marker
  340. * @param {Float64Array} dst The float array to populate with the 3x4 marker transformation matrix
  341. * @return {Float64Array} The dst array.
  342. */
  343. ARController.prototype.getTransMatSquare = function(markerIndex, markerWidth, dst) {
  344. artoolkit.getTransMatSquare(this.id, markerIndex, markerWidth);
  345. dst.set(this.marker_transform_mat);
  346. return dst;
  347. };
  348. /**
  349. * Populates the provided float array with the current transformation for the specified marker, using
  350. * previousMarkerTransform as the previously detected transformation. After
  351. * a call to detectMarker, all marker information will be current. Marker transformations can then be
  352. * checked.
  353. * @param {number} markerUID The unique identifier (UID) of the marker to query
  354. * @param {number} markerWidth The width of the marker
  355. * @param {Float64Array} previousMarkerTransform The float array to use as the previous 3x4 marker transformation matrix
  356. * @param {Float64Array} dst The float array to populate with the 3x4 marker transformation matrix
  357. * @return {Float64Array} The dst array.
  358. */
  359. ARController.prototype.getTransMatSquareCont = function(markerIndex, markerWidth, previousMarkerTransform, dst) {
  360. this.marker_transform_mat.set(previousMarkerTransform)
  361. artoolkit.getTransMatSquareCont(this.id, markerIndex, markerWidth);
  362. dst.set(this.marker_transform_mat);
  363. return dst;
  364. };
  365. /**
  366. * Populates the provided float array with the current transformation for the specified multimarker. After
  367. * a call to detectMarker, all marker information will be current. Marker transformations can then be
  368. * checked.
  369. *
  370. * @param {number} markerUID The unique identifier (UID) of the marker to query
  371. * @param {number} markerWidth The width of the marker
  372. * @param {Float64Array} dst The float array to populate with the 3x4 marker transformation matrix
  373. * @return {Float64Array} The dst array.
  374. */
  375. ARController.prototype.getTransMatMultiSquare = function(multiMarkerId, dst) {
  376. artoolkit.getTransMatMultiSquare(this.id, multiMarkerId);
  377. dst.set(this.marker_transform_mat);
  378. return dst;
  379. };
  380. /**
  381. * Populates the provided float array with the current robust transformation for the specified multimarker. After
  382. * a call to detectMarker, all marker information will be current. Marker transformations can then be
  383. * checked.
  384. * @param {number} markerUID The unique identifier (UID) of the marker to query
  385. * @param {number} markerWidth The width of the marker
  386. * @param {Float64Array} dst The float array to populate with the 3x4 marker transformation matrix
  387. * @return {Float64Array} The dst array.
  388. */
  389. ARController.prototype.getTransMatMultiSquareRobust = function(multiMarkerId, dst) {
  390. artoolkit.getTransMatMultiSquare(this.id, multiMarkerId);
  391. dst.set(this.marker_transform_mat);
  392. return dst;
  393. };
  394. /**
  395. Converts the given 3x4 marker transformation matrix in the 12-element transMat array
  396. into a 4x4 WebGL matrix and writes the result into the 16-element glMat array.
  397. If scale parameter is given, scales the transform of the glMat by the scale parameter.
  398. @param {Float64Array} transMat The 3x4 marker transformation matrix.
  399. @param {Float64Array} glMat The 4x4 GL transformation matrix.
  400. @param {number} scale The scale for the transform.
  401. */
  402. ARController.prototype.transMatToGLMat = function(transMat, glMat, scale) {
  403. glMat[0 + 0*4] = transMat[0]; // R1C1
  404. glMat[0 + 1*4] = transMat[1]; // R1C2
  405. glMat[0 + 2*4] = transMat[2];
  406. glMat[0 + 3*4] = transMat[3];
  407. glMat[1 + 0*4] = transMat[4]; // R2
  408. glMat[1 + 1*4] = transMat[5];
  409. glMat[1 + 2*4] = transMat[6];
  410. glMat[1 + 3*4] = transMat[7];
  411. glMat[2 + 0*4] = transMat[8]; // R3
  412. glMat[2 + 1*4] = transMat[9];
  413. glMat[2 + 2*4] = transMat[10];
  414. glMat[2 + 3*4] = transMat[11];
  415. glMat[3 + 0*4] = 0.0;
  416. glMat[3 + 1*4] = 0.0;
  417. glMat[3 + 2*4] = 0.0;
  418. glMat[3 + 3*4] = 1.0;
  419. if (scale != undefined && scale !== 0.0) {
  420. glMat[12] *= scale;
  421. glMat[13] *= scale;
  422. glMat[14] *= scale;
  423. }
  424. return glMat;
  425. };
  426. /**
  427. This is the core ARToolKit marker detection function. It calls through to a set of
  428. internal functions to perform the key marker detection steps of binarization and
  429. labelling, contour extraction, and template matching and/or matrix code extraction.
  430. Typically, the resulting set of detected markers is retrieved by calling arGetMarkerNum
  431. to get the number of markers detected and arGetMarker to get an array of ARMarkerInfo
  432. structures with information on each detected marker, followed by a step in which
  433. detected markers are possibly examined for some measure of goodness of match (e.g. by
  434. examining the match confidence value) and pose extraction.
  435. @param {image} Image to be processed to detect markers.
  436. @return {number} 0 if the function proceeded without error, or a value less than 0 in case of error.
  437. A result of 0 does not however, imply any markers were detected.
  438. */
  439. ARController.prototype.detectMarker = function(image) {
  440. if (this._copyImageToHeap(image)) {
  441. return artoolkit.detectMarker(this.id);
  442. }
  443. return -99;
  444. };
  445. /**
  446. Get the number of markers detected in a video frame.
  447. @return {number} The number of detected markers in the most recent image passed to arDetectMarker.
  448. Note that this is actually a count, not an index. A better name for this function would be
  449. arGetDetectedMarkerCount, but the current name lives on for historical reasons.
  450. */
  451. ARController.prototype.getMarkerNum = function() {
  452. return artoolkit.getMarkerNum(this.id);
  453. };
  454. /**
  455. Get the marker info struct for the given marker index in detected markers.
  456. Call this.detectMarker first, then use this.getMarkerNum to get the detected marker count.
  457. The returned object is the global artoolkit.markerInfo object and will be overwritten
  458. by subsequent calls. If you need to hang on to it, create a copy using this.cloneMarkerInfo();
  459. Returns undefined if no marker was found.
  460. A markerIndex of -1 is used to access the global custom marker.
  461. The fields of the markerInfo struct are:
  462. @field area Area in pixels of the largest connected region, comprising the marker border and regions connected to it. Note that this is
  463. not the same as the actual onscreen area inside the marker border.
  464. @field id If pattern detection mode is either pattern mode OR matrix but not both, will be marker ID (>= 0) if marker is valid, or -1 if invalid.
  465. @field idPatt If pattern detection mode includes a pattern mode, will be marker ID (>= 0) if marker is valid, or -1 if invalid.
  466. @field idMatrix If pattern detection mode includes a matrix mode, will be marker ID (>= 0) if marker is valid, or -1 if invalid.
  467. @field dir If pattern detection mode is either pattern mode OR matrix but not both, and id != -1, will be marker direction (range 0 to 3, inclusive).
  468. @field dirPatt If pattern detection mode includes a pattern mode, and id != -1, will be marker direction (range 0 to 3, inclusive).
  469. @field dirMatrix If pattern detection mode includes a matrix mode, and id != -1, will be marker direction (range 0 to 3, inclusive).
  470. @field cf If pattern detection mode is either pattern mode OR matrix but not both, will be marker matching confidence (range 0.0 to 1.0 inclusive) if marker is valid, or -1.0 if marker is invalid.
  471. @field cfPatt If pattern detection mode includes a pattern mode, will be marker matching confidence (range 0.0 to 1.0 inclusive) if marker is valid, or -1.0 if marker is invalid.
  472. @field cfMatrix If pattern detection mode includes a matrix mode, will be marker matching confidence (range 0.0 to 1.0 inclusive) if marker is valid, or -1.0 if marker is invalid.
  473. @field pos 2D position (in camera image coordinates, origin at top-left) of the centre of the marker.
  474. @field line Line equations for the 4 sides of the marker.
  475. @field vertex 2D positions (in camera image coordinates, origin at top-left) of the corners of the marker. vertex[(4 - dir)%4][] is the top-left corner of the marker. Other vertices proceed clockwise from this. These are idealised coordinates (i.e. the onscreen position aligns correctly with the undistorted camera image.)
  476. @param {number} markerIndex The index of the marker to query.
  477. @returns {Object} The markerInfo struct.
  478. */
  479. ARController.prototype.getMarker = function(markerIndex) {
  480. if (0 === artoolkit.getMarker(this.id, markerIndex)) {
  481. return artoolkit.markerInfo;
  482. }
  483. };
  484. /**
  485. Set marker vertices to the given vertexData[4][2] array.
  486. Sets the marker pos to the center of the vertices.
  487. Useful for building custom markers for getTransMatSquare.
  488. A markerIndex of -1 is used to access the global custom marker.
  489. @param {number} markerIndex The index of the marker to edit.
  490. */
  491. ARController.prototype.setMarkerInfoVertex = function(markerIndex, vertexData) {
  492. for (var i=0; i<vertexData.length; i++) {
  493. this.marker_transform_mat[i*2+0] = vertexData[i][0];
  494. this.marker_transform_mat[i*2+1] = vertexData[i][1];
  495. }
  496. return artoolkit.setMarkerInfoVertex(this.id, markerIndex);
  497. };
  498. /**
  499. Makes a deep copy of the given marker info.
  500. @param {Object} markerInfo The marker info object to copy.
  501. @return {Object} The new copy of the marker info.
  502. */
  503. ARController.prototype.cloneMarkerInfo = function(markerInfo) {
  504. return JSON.parse(JSON.stringify(markerInfo));
  505. };
  506. /**
  507. Get the marker info struct for the given marker index in detected markers.
  508. Call this.detectMarker first, then use this.getMarkerNum to get the detected marker count.
  509. The returned object is the global artoolkit.markerInfo object and will be overwritten
  510. by subsequent calls. If you need to hang on to it, create a copy using this.cloneMarkerInfo();
  511. Returns undefined if no marker was found.
  512. @field {number} pattId The index of the marker.
  513. @field {number} pattType The type of the marker. Either AR_MULTI_PATTERN_TYPE_TEMPLATE or AR_MULTI_PATTERN_TYPE_MATRIX.
  514. @field {number} visible 0 or larger if the marker is visible
  515. @field {number} width The width of the marker.
  516. @param {number} multiMarkerId The multimarker to query.
  517. @param {number} markerIndex The index of the marker to query.
  518. @returns {Object} The markerInfo struct.
  519. */
  520. ARController.prototype.getMultiEachMarker = function(multiMarkerId, markerIndex) {
  521. if (0 === artoolkit.getMultiEachMarker(this.id, multiMarkerId, markerIndex)) {
  522. return artoolkit.multiEachMarkerInfo;
  523. }
  524. };
  525. /**
  526. Returns the 16-element WebGL transformation matrix used by ARController.process to
  527. pass marker WebGL matrices to event listeners.
  528. Unique to each ARController.
  529. @return {Float64Array} The 16-element WebGL transformation matrix used by the ARController.
  530. */
  531. ARController.prototype.getTransformationMatrix = function() {
  532. return this.transform_mat;
  533. };
  534. /**
  535. * Returns the projection matrix computed from camera parameters for the ARController.
  536. *
  537. * @return {Float64Array} The 16-element WebGL camera matrix for the ARController camera parameters.
  538. */
  539. ARController.prototype.getCameraMatrix = function() {
  540. return this.camera_mat;
  541. };
  542. /**
  543. Returns the shared ARToolKit 3x4 marker transformation matrix, used for passing and receiving
  544. marker transforms to/from the Emscripten side.
  545. @return {Float64Array} The 12-element 3x4 row-major marker transformation matrix used by ARToolKit.
  546. */
  547. ARController.prototype.getMarkerTransformationMatrix = function() {
  548. return this.marker_transform_mat;
  549. };
  550. /* Setter / Getter Proxies */
  551. /**
  552. * Enables or disables debug mode in the tracker. When enabled, a black and white debug
  553. * image is generated during marker detection. The debug image is useful for visualising
  554. * the binarization process and choosing a threshold value.
  555. * @param {number} debug true to enable debug mode, false to disable debug mode
  556. * @see getDebugMode()
  557. */
  558. ARController.prototype.setDebugMode = function(mode) {
  559. return artoolkit.setDebugMode(this.id, mode);
  560. };
  561. /**
  562. * Returns whether debug mode is currently enabled.
  563. * @return true when debug mode is enabled, false when debug mode is disabled
  564. * @see setDebugMode()
  565. */
  566. ARController.prototype.getDebugMode = function() {
  567. return artoolkit.getDebugMode(this.id);
  568. };
  569. /**
  570. Returns the Emscripten HEAP offset to the debug processing image used by ARToolKit.
  571. @return {number} HEAP offset to the debug processing image.
  572. */
  573. ARController.prototype.getProcessingImage = function() {
  574. return artoolkit.getProcessingImage(this.id);
  575. }
  576. /**
  577. Sets the logging level to use by ARToolKit.
  578. @param
  579. */
  580. ARController.prototype.setLogLevel = function(mode) {
  581. return artoolkit.setLogLevel(mode);
  582. };
  583. ARController.prototype.getLogLevel = function() {
  584. return artoolkit.getLogLevel();
  585. };
  586. ARController.prototype.setMarkerInfoDir = function(markerIndex, dir) {
  587. return artoolkit.setMarkerInfoDir(this.id, markerIndex, dir);
  588. };
  589. ARController.prototype.setProjectionNearPlane = function(value) {
  590. return artoolkit.setProjectionNearPlane(this.id, value);
  591. };
  592. ARController.prototype.getProjectionNearPlane = function() {
  593. return artoolkit.getProjectionNearPlane(this.id);
  594. };
  595. ARController.prototype.setProjectionFarPlane = function(value) {
  596. return artoolkit.setProjectionFarPlane(this.id, value);
  597. };
  598. ARController.prototype.getProjectionFarPlane = function() {
  599. return artoolkit.getProjectionFarPlane(this.id);
  600. };
  601. /**
  602. Set the labeling threshold mode (auto/manual).
  603. @param {number} mode An integer specifying the mode. One of:
  604. AR_LABELING_THRESH_MODE_MANUAL,
  605. AR_LABELING_THRESH_MODE_AUTO_MEDIAN,
  606. AR_LABELING_THRESH_MODE_AUTO_OTSU,
  607. AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE,
  608. AR_LABELING_THRESH_MODE_AUTO_BRACKETING
  609. */
  610. ARController.prototype.setThresholdMode = function(mode) {
  611. return artoolkit.setThresholdMode(this.id, mode);
  612. };
  613. /**
  614. * Gets the current threshold mode used for image binarization.
  615. * @return {number} The current threshold mode
  616. * @see getVideoThresholdMode()
  617. */
  618. ARController.prototype.getThresholdMode = function() {
  619. return artoolkit.getThresholdMode(this.id);
  620. };
  621. /**
  622. Set the labeling threshhold.
  623. This function forces sets the threshold value.
  624. The default value is AR_DEFAULT_LABELING_THRESH which is 100.
  625. The current threshold mode is not affected by this call.
  626. Typically, this function is used when labeling threshold mode
  627. is AR_LABELING_THRESH_MODE_MANUAL.
  628. The threshold value is not relevant if threshold mode is
  629. AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE.
  630. Background: The labeling threshold is the value which
  631. the AR library uses to differentiate between black and white
  632. portions of an ARToolKit marker. Since the actual brightness,
  633. contrast, and gamma of incoming images can vary signficantly
  634. between different cameras and lighting conditions, this
  635. value typically needs to be adjusted dynamically to a
  636. suitable midpoint between the observed values for black
  637. and white portions of the markers in the image.
  638. @param {number} thresh An integer in the range [0,255] (inclusive).
  639. */
  640. ARController.prototype.setThreshold = function(threshold) {
  641. return artoolkit.setThreshold(this.id, threshold);
  642. };
  643. /**
  644. Get the current labeling threshold.
  645. This function queries the current labeling threshold. For,
  646. AR_LABELING_THRESH_MODE_AUTO_MEDIAN, AR_LABELING_THRESH_MODE_AUTO_OTSU,
  647. and AR_LABELING_THRESH_MODE_AUTO_BRACKETING
  648. the threshold value is only valid until the next auto-update.
  649. The current threshold mode is not affected by this call.
  650. The threshold value is not relevant if threshold mode is
  651. AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE.
  652. @return {number} The current threshold value.
  653. */
  654. ARController.prototype.getThreshold = function() {
  655. return artoolkit.getThreshold(this.id);
  656. };
  657. /**
  658. Set the pattern detection mode
  659. The pattern detection determines the method by which ARToolKit
  660. matches detected squares in the video image to marker templates
  661. and/or IDs. ARToolKit v4.x can match against pictorial "template" markers,
  662. whose pattern files are created with the mk_patt utility, in either colour
  663. or mono, and additionally can match against 2D-barcode-type "matrix"
  664. markers, which have an embedded marker ID. Two different two-pass modes
  665. are also available, in which a matrix-detection pass is made first,
  666. followed by a template-matching pass.
  667. @param {number} mode
  668. Options for this field are:
  669. AR_TEMPLATE_MATCHING_COLOR
  670. AR_TEMPLATE_MATCHING_MONO
  671. AR_MATRIX_CODE_DETECTION
  672. AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX
  673. AR_TEMPLATE_MATCHING_MONO_AND_MATRIX
  674. The default mode is AR_TEMPLATE_MATCHING_COLOR.
  675. */
  676. ARController.prototype.setPatternDetectionMode = function(value) {
  677. return artoolkit.setPatternDetectionMode(this.id, value);
  678. };
  679. /**
  680. Returns the current pattern detection mode.
  681. @return {number} The current pattern detection mode.
  682. */
  683. ARController.prototype.getPatternDetectionMode = function() {
  684. return artoolkit.getPatternDetectionMode(this.id);
  685. };
  686. /**
  687. Set the size and ECC algorithm to be used for matrix code (2D barcode) marker detection.
  688. When matrix-code (2D barcode) marker detection is enabled (see arSetPatternDetectionMode)
  689. then the size of the barcode pattern and the type of error checking and correction (ECC)
  690. with which the markers were produced can be set via this function.
  691. This setting is global to a given ARHandle; It is not possible to have two different matrix
  692. code types in use at once.
  693. @param type The type of matrix code (2D barcode) in use. Options include:
  694. AR_MATRIX_CODE_3x3
  695. AR_MATRIX_CODE_3x3_HAMMING63
  696. AR_MATRIX_CODE_3x3_PARITY65
  697. AR_MATRIX_CODE_4x4
  698. AR_MATRIX_CODE_4x4_BCH_13_9_3
  699. AR_MATRIX_CODE_4x4_BCH_13_5_5
  700. The default mode is AR_MATRIX_CODE_3x3.
  701. */
  702. ARController.prototype.setMatrixCodeType = function(value) {
  703. return artoolkit.setMatrixCodeType(this.id, value);
  704. };
  705. /**
  706. Returns the current matrix code (2D barcode) marker detection type.
  707. @return {number} The current matrix code type.
  708. */
  709. ARController.prototype.getMatrixCodeType = function() {
  710. return artoolkit.getMatrixCodeType(this.id);
  711. };
  712. /**
  713. Select between detection of black markers and white markers.
  714. ARToolKit's labelling algorithm can work with both black-bordered
  715. markers on a white background (AR_LABELING_BLACK_REGION) or
  716. white-bordered markers on a black background (AR_LABELING_WHITE_REGION).
  717. This function allows you to specify the type of markers to look for.
  718. Note that this does not affect the pattern-detection algorith
  719. which works on the interior of the marker.
  720. @param {number} mode
  721. Options for this field are:
  722. AR_LABELING_WHITE_REGION
  723. AR_LABELING_BLACK_REGION
  724. The default mode is AR_LABELING_BLACK_REGION.
  725. */
  726. ARController.prototype.setLabelingMode = function(value) {
  727. return artoolkit.setLabelingMode(this.id, value);
  728. };
  729. /**
  730. Enquire whether detection is looking for black markers or white markers.
  731. See discussion for setLabelingMode.
  732. @result {number} The current labeling mode.
  733. */
  734. ARController.prototype.getLabelingMode = function() {
  735. return artoolkit.getLabelingMode(this.id);
  736. };
  737. /**
  738. Set the width/height of the marker pattern space, as a proportion of marker width/height.
  739. @param {number} pattRatio The the width/height of the marker pattern space, as a proportion of marker
  740. width/height. To set the default, pass AR_PATT_RATIO.
  741. If compatibility with ARToolKit verions 1.0 through 4.4 is required, this value
  742. must be 0.5.
  743. */
  744. ARController.prototype.setPattRatio = function(value) {
  745. return artoolkit.setPattRatio(this.id, value);
  746. };
  747. /**
  748. Returns the current ratio of the marker pattern to the total marker size.
  749. @return {number} The current pattern ratio.
  750. */
  751. ARController.prototype.getPattRatio = function() {
  752. return artoolkit.getPattRatio(this.id);
  753. };
  754. /**
  755. Set the image processing mode.
  756. When the image processing mode is AR_IMAGE_PROC_FRAME_IMAGE,
  757. ARToolKit processes all pixels in each incoming image
  758. to locate markers. When the mode is AR_IMAGE_PROC_FIELD_IMAGE,
  759. ARToolKit processes pixels in only every second pixel row and
  760. column. This is useful both for handling images from interlaced
  761. video sources (where alternate lines are assembled from alternate
  762. fields and thus have one field time-difference, resulting in a
  763. "comb" effect) such as Digital Video cameras.
  764. The effective reduction by 75% in the pixels processed also
  765. has utility in accelerating tracking by effectively reducing
  766. the image size to one quarter size, at the cost of pose accuraccy.
  767. @param {number} mode
  768. Options for this field are:
  769. AR_IMAGE_PROC_FRAME_IMAGE
  770. AR_IMAGE_PROC_FIELD_IMAGE
  771. The default mode is AR_IMAGE_PROC_FRAME_IMAGE.
  772. */
  773. ARController.prototype.setImageProcMode = function(value) {
  774. return artoolkit.setImageProcMode(this.id, value);
  775. };
  776. /**
  777. Get the image processing mode.
  778. See arSetImageProcMode() for a complete description.
  779. @return {number} The current image processing mode.
  780. */
  781. ARController.prototype.getImageProcMode = function() {
  782. return artoolkit.getImageProcMode(this.id);
  783. };
  784. /**
  785. Draw the black and white image and debug markers to the ARController canvas.
  786. See setDebugMode.
  787. */
  788. ARController.prototype.debugDraw = function() {
  789. var debugBuffer = new Uint8ClampedArray(Module.HEAPU8.buffer, this._bwpointer, this.framesize);
  790. var id = new ImageData(debugBuffer, this.canvas.width, this.canvas.height)
  791. this.ctx.putImageData(id, 0, 0)
  792. var marker_num = this.getMarkerNum();
  793. for (var i=0; i<marker_num; i++) {
  794. this._debugMarker(this.getMarker(i));
  795. }
  796. };
  797. // private
  798. ARController.prototype._initialize = function() {
  799. this.id = artoolkit.setup(this.canvas.width, this.canvas.height, this.cameraParam.id);
  800. var params = artoolkit.frameMalloc;
  801. this.framepointer = params.framepointer;
  802. this.framesize = params.framesize;
  803. this.dataHeap = new Uint8Array(Module.HEAPU8.buffer, this.framepointer, this.framesize);
  804. this.camera_mat = new Float64Array(Module.HEAPU8.buffer, params.camera, 16);
  805. this.marker_transform_mat = new Float64Array(Module.HEAPU8.buffer, params.transform, 12);
  806. this.setProjectionNearPlane(0.1)
  807. this.setProjectionFarPlane(1000);
  808. var self = this;
  809. setTimeout(function() {
  810. if (self.onload) {
  811. self.onload();
  812. }
  813. self.dispatchEvent({
  814. name: 'load',
  815. target: self
  816. });
  817. }, 1);
  818. };
  819. /*
  820. ARController.prototype._copyImageToHeap = function(image) {
  821. if (!image) {
  822. image = this.image;
  823. }
  824. // if (this.orientation === 'portrait') {
  825. // this.ctx.save();
  826. // this.ctx.translate(this.canvas.width, 0);
  827. // this.ctx.rotate(Math.PI/2);
  828. // this.ctx.drawImage(image, 0, 0, this.canvas.height, this.canvas.width); // draw video
  829. // this.ctx.restore();
  830. // } else {
  831. // debugger
  832. // this.ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height); // draw video
  833. // }
  834. this.ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height); // draw video
  835. var imageData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height);
  836. var data = imageData.data;
  837. if (this.dataHeap) {
  838. this.dataHeap.set( data );
  839. return true;
  840. }
  841. return false;
  842. };
  843. */
  844. ARController.prototype._copyImageToHeap = function(image) {
  845. if (!image) {
  846. image = this.image;
  847. }
  848. if( (image.nodeName === 'IMG' && image.width > image.height ) ||
  849. (image.nodeName === 'VIDEO' && image.videoWidth > image.videoHeight) ){
  850. // if landscape
  851. this.ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height); // draw video
  852. }else{
  853. // if portrait
  854. this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
  855. var scale = this.canvas.height / this.canvas.width;
  856. var scaledHeight = this.canvas.width*scale;
  857. var scaledWidth = this.canvas.height*scale;
  858. var marginLeft = ( this.canvas.width - scaledWidth)/2;
  859. this.ctx.drawImage(image, marginLeft, 0, scaledWidth, scaledHeight); // draw video
  860. }
  861. var imageData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height);
  862. var data = imageData.data;
  863. if (this.dataHeap) {
  864. this.dataHeap.set( data );
  865. return true;
  866. }
  867. return false;
  868. };
  869. ARController.prototype._debugMarker = function(marker) {
  870. var vertex, pos;
  871. vertex = marker.vertex;
  872. var ctx = this.ctx;
  873. ctx.strokeStyle = 'red';
  874. ctx.beginPath()
  875. ctx.moveTo(vertex[0][0], vertex[0][1])
  876. ctx.lineTo(vertex[1][0], vertex[1][1])
  877. ctx.stroke();
  878. ctx.beginPath()
  879. ctx.moveTo(vertex[2][0], vertex[2][1])
  880. ctx.lineTo(vertex[3][0], vertex[3][1])
  881. ctx.stroke()
  882. ctx.strokeStyle = 'green';
  883. ctx.beginPath()
  884. ctx.lineTo(vertex[1][0], vertex[1][1])
  885. ctx.lineTo(vertex[2][0], vertex[2][1])
  886. ctx.stroke();
  887. ctx.beginPath()
  888. ctx.moveTo(vertex[3][0], vertex[3][1])
  889. ctx.lineTo(vertex[0][0], vertex[0][1])
  890. ctx.stroke();
  891. pos = marker.pos
  892. ctx.beginPath()
  893. ctx.arc(pos[0], pos[1], 8, 0, Math.PI * 2)
  894. ctx.fillStyle = 'red'
  895. ctx.fill()
  896. };
  897. // static
  898. /**
  899. ARController.getUserMedia gets a device camera video feed and calls the given onSuccess callback with it.
  900. Tries to start playing the video. Playing the video can fail on Chrome for Android,
  901. so ARController.getUserMedia adds user input event listeners to the window
  902. that try to start playing the video. On success, the event listeners are removed.
  903. To use ARController.getUserMedia, call it with an object with the onSuccess attribute set to a callback function.
  904. ARController.getUserMedia({
  905. onSuccess: function(video) {
  906. console.log("Got video", video);
  907. }
  908. });
  909. The configuration object supports the following attributes:
  910. {
  911. onSuccess : function(video),
  912. onError : function(error),
  913. width : number | {min: number, ideal: number, max: number},
  914. height : number | {min: number, ideal: number, max: number},
  915. facingMode : 'environment' | 'user' | 'left' | 'right' | { exact: 'environment' | ... }
  916. }
  917. See https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia for more information about the
  918. width, height and facingMode attributes.
  919. @param {object} configuration The configuration object.
  920. @return {VideoElement} Returns the created video element.
  921. */
  922. ARController.getUserMedia = function(configuration) {
  923. var facing = configuration.facingMode || 'environment';
  924. var onSuccess = configuration.onSuccess;
  925. var onError = configuration.onError || function(err) { console.error("ARController.getUserMedia", err); };
  926. var video = document.createElement('video');
  927. var initProgress = function() {
  928. if (this.videoWidth !== 0) {
  929. onSuccess(video);
  930. }
  931. };
  932. var readyToPlay = false;
  933. var eventNames = [
  934. 'touchstart', 'touchend', 'touchmove', 'touchcancel',
  935. 'click', 'mousedown', 'mouseup', 'mousemove',
  936. 'keydown', 'keyup', 'keypress', 'scroll'
  937. ];
  938. var play = function(ev) {
  939. if (readyToPlay) {
  940. video.play();
  941. if (!video.paused) {
  942. eventNames.forEach(function(eventName) {
  943. window.removeEventListener(eventName, play, true);
  944. });
  945. }
  946. }
  947. };
  948. eventNames.forEach(function(eventName) {
  949. window.addEventListener(eventName, play, true);
  950. });
  951. var success = function(stream) {
  952. video.addEventListener('loadedmetadata', initProgress, false);
  953. video.src = window.URL.createObjectURL(stream);
  954. readyToPlay = true;
  955. play(); // Try playing without user input, should work on non-Android Chrome
  956. };
  957. var constraints = {};
  958. var mediaDevicesConstraints = {};
  959. if (configuration.width) {
  960. mediaDevicesConstraints.width = configuration.width;
  961. if (typeof configuration.width === 'object') {
  962. if (configuration.width.max) {
  963. constraints.maxWidth = configuration.width.max;
  964. }
  965. if (configuration.width.min) {
  966. constraints.minWidth = configuration.width.max;
  967. }
  968. } else {
  969. constraints.maxWidth = configuration.width;
  970. }
  971. }
  972. if (configuration.height) {
  973. mediaDevicesConstraints.height = configuration.height;
  974. if (typeof configuration.height === 'object') {
  975. if (configuration.height.max) {
  976. constraints.maxHeight = configuration.height.max;
  977. }
  978. if (configuration.height.min) {
  979. constraints.minHeight = configuration.height.max;
  980. }
  981. } else {
  982. constraints.maxHeight = configuration.height;
  983. }
  984. }
  985. mediaDevicesConstraints.facingMode = facing;
  986. navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
  987. var hdConstraints = {
  988. audio: false,
  989. video: {
  990. mandatory: constraints
  991. }
  992. };
  993. if ( false ) {
  994. // if ( navigator.mediaDevices || window.MediaStreamTrack) {
  995. if (navigator.mediaDevices) {
  996. navigator.mediaDevices.getUserMedia({
  997. audio: false,
  998. video: mediaDevicesConstraints
  999. }).then(success, onError);
  1000. } else {
  1001. MediaStreamTrack.getSources(function(sources) {
  1002. var facingDir = mediaDevicesConstraints.facingMode;
  1003. if (facing && facing.exact) {
  1004. facingDir = facing.exact;
  1005. }
  1006. for (var i=0; i<sources.length; i++) {
  1007. if (sources[i].kind === 'video' && sources[i].facing === facingDir) {
  1008. hdConstraints.video.mandatory.sourceId = sources[i].id;
  1009. break;
  1010. }
  1011. }
  1012. if (facing && facing.exact && !hdConstraints.video.mandatory.sourceId) {
  1013. onError('Failed to get camera facing the wanted direction');
  1014. } else {
  1015. if (navigator.getUserMedia) {
  1016. navigator.getUserMedia(hdConstraints, success, onError);
  1017. } else {
  1018. onError('navigator.getUserMedia is not supported on your browser');
  1019. }
  1020. }
  1021. });
  1022. }
  1023. } else {
  1024. if (navigator.getUserMedia) {
  1025. navigator.getUserMedia(hdConstraints, success, onError);
  1026. } else {
  1027. onError('navigator.getUserMedia is not supported on your browser');
  1028. }
  1029. }
  1030. return video;
  1031. };
  1032. /**
  1033. ARController.getUserMediaARController gets an ARController for the device camera video feed and calls the
  1034. given onSuccess callback with it.
  1035. To use ARController.getUserMediaARController, call it with an object with the cameraParam attribute set to
  1036. a camera parameter file URL, and the onSuccess attribute set to a callback function.
  1037. ARController.getUserMediaARController({
  1038. cameraParam: 'Data/camera_para.dat',
  1039. onSuccess: function(arController, arCameraParam) {
  1040. console.log("Got ARController", arController);
  1041. console.log("Got ARCameraParam", arCameraParam);
  1042. console.log("Got video", arController.image);
  1043. }
  1044. });
  1045. The configuration object supports the following attributes:
  1046. {
  1047. onSuccess : function(ARController, ARCameraParam),
  1048. onError : function(error),
  1049. cameraParam: url, // URL to camera parameters definition file.
  1050. maxARVideoSize: number, // Maximum max(width, height) for the AR processing canvas.
  1051. width : number | {min: number, ideal: number, max: number},
  1052. height : number | {min: number, ideal: number, max: number},
  1053. facingMode : 'environment' | 'user' | 'left' | 'right' | { exact: 'environment' | ... }
  1054. }
  1055. See https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia for more information about the
  1056. width, height and facingMode attributes.
  1057. The orientation attribute of the returned ARController is set to "portrait" if the userMedia video has larger
  1058. height than width. Otherwise it's set to "landscape". The videoWidth and videoHeight attributes of the arController
  1059. are set to be always in landscape configuration so that width is larger than height.
  1060. @param {object} configuration The configuration object.
  1061. @return {VideoElement} Returns the created video element.
  1062. */
  1063. ARController.getUserMediaARController = function(configuration) {
  1064. var obj = {};
  1065. for (var i in configuration) {
  1066. obj[i] = configuration[i];
  1067. }
  1068. var onSuccess = configuration.onSuccess;
  1069. var cameraParamURL = configuration.cameraParam;
  1070. obj.onSuccess = function() {
  1071. new ARCameraParam(cameraParamURL, function() {
  1072. var arCameraParam = this;
  1073. var maxSize = configuration.maxARVideoSize || Math.max(video.videoWidth, video.videoHeight);
  1074. var f = maxSize / Math.max(video.videoWidth, video.videoHeight);
  1075. var w = f * video.videoWidth;
  1076. var h = f * video.videoHeight;
  1077. if (video.videoWidth < video.videoHeight) {
  1078. var tmp = w;
  1079. w = h;
  1080. h = tmp;
  1081. }
  1082. var arController = new ARController(w, h, arCameraParam);
  1083. arController.image = video;
  1084. if (video.videoWidth < video.videoHeight) {
  1085. arController.orientation = 'portrait';
  1086. arController.videoWidth = video.videoHeight;
  1087. arController.videoHeight = video.videoWidth;
  1088. } else {
  1089. arController.orientation = 'landscape';
  1090. arController.videoWidth = video.videoWidth;
  1091. arController.videoHeight = video.videoHeight;
  1092. }
  1093. onSuccess(arController, arCameraParam);
  1094. }, function(err) {
  1095. console.error("ARController: Failed to load ARCameraParam", err);
  1096. });
  1097. };
  1098. var video = this.getUserMedia(obj);
  1099. return video;
  1100. };
  1101. /**
  1102. ARCameraParam is used for loading AR camera parameters for use with ARController.
  1103. Use by passing in an URL and a callback function.
  1104. var camera = new ARCameraParam('Data/camera_para.dat', function() {
  1105. console.log('loaded camera', this.id);
  1106. },
  1107. function(err) {
  1108. console.log('failed to load camera', err);
  1109. });
  1110. @exports ARCameraParam
  1111. @constructor
  1112. @param {string} src URL to load camera parameters from.
  1113. @param {string} onload Onload callback to be called on successful parameter loading.
  1114. @param {string} onerror Error callback to called when things don't work out.
  1115. */
  1116. var ARCameraParam = function(src, onload, onerror) {
  1117. this.id = -1;
  1118. this._src = '';
  1119. this.complete = false;
  1120. this.onload = onload;
  1121. this.onerror = onerror;
  1122. if (src) {
  1123. this.load(src);
  1124. }
  1125. };
  1126. /**
  1127. Loads the given URL as camera parameters definition file into this ARCameraParam.
  1128. Can only be called on an unloaded ARCameraParam instance.
  1129. @param {string} src URL to load.
  1130. */
  1131. ARCameraParam.prototype.load = function(src) {
  1132. if (this._src !== '') {
  1133. throw("ARCameraParam: Trying to load camera parameters twice.")
  1134. }
  1135. this._src = src;
  1136. if (src) {
  1137. var self = this;
  1138. artoolkit.loadCamera(src, function(id) {
  1139. self.id = id;
  1140. self.complete = true;
  1141. self.onload();
  1142. }, function(err) {
  1143. self.onerror(err);
  1144. });
  1145. }
  1146. };
  1147. Object.defineProperty(ARCameraParam.prototype, 'src', {
  1148. set: function(src) {
  1149. this.load(src);
  1150. },
  1151. get: function() {
  1152. return this._src;
  1153. }
  1154. });
  1155. /**
  1156. Destroys the camera parameter and frees associated Emscripten resources.
  1157. */
  1158. ARCameraParam.prototype.dispose = function() {
  1159. if (this.id !== -1) {
  1160. artoolkit.deleteCamera(this.id);
  1161. }
  1162. this.id = -1;
  1163. this._src = '';
  1164. this.complete = false;
  1165. };
  1166. // ARToolKit exported JS API
  1167. //
  1168. var artoolkit = {
  1169. UNKNOWN_MARKER: -1,
  1170. PATTERN_MARKER: 0,
  1171. BARCODE_MARKER: 1,
  1172. loadCamera: loadCamera,
  1173. addMarker: addMarker,
  1174. addMultiMarker: addMultiMarker,
  1175. };
  1176. var FUNCTIONS = [
  1177. 'setup',
  1178. 'teardown',
  1179. 'setLogLevel',
  1180. 'getLogLevel',
  1181. 'setDebugMode',
  1182. 'getDebugMode',
  1183. 'getProcessingImage',
  1184. 'setMarkerInfoDir',
  1185. 'setMarkerInfoVertex',
  1186. 'getTransMatSquare',
  1187. 'getTransMatSquareCont',
  1188. 'getTransMatMultiSquare',
  1189. 'getTransMatMultiSquareRobust',
  1190. 'getMultiMarkerNum',
  1191. 'getMultiMarkerCount',
  1192. 'detectMarker',
  1193. 'getMarkerNum',
  1194. 'getMarker',
  1195. 'getMultiEachMarker',
  1196. 'setProjectionNearPlane',
  1197. 'getProjectionNearPlane',
  1198. 'setProjectionFarPlane',
  1199. 'getProjectionFarPlane',
  1200. 'setThresholdMode',
  1201. 'getThresholdMode',
  1202. 'setThreshold',
  1203. 'getThreshold',
  1204. 'setPatternDetectionMode',
  1205. 'getPatternDetectionMode',
  1206. 'setMatrixCodeType',
  1207. 'getMatrixCodeType',
  1208. 'setLabelingMode',
  1209. 'getLabelingMode',
  1210. 'setPattRatio',
  1211. 'getPattRatio',
  1212. 'setImageProcMode',
  1213. 'getImageProcMode',
  1214. ];
  1215. function runWhenLoaded() {
  1216. FUNCTIONS.forEach(function(n) {
  1217. artoolkit[n] = Module[n];
  1218. })
  1219. for (var m in Module) {
  1220. if (m.match(/^AR/))
  1221. artoolkit[m] = Module[m];
  1222. }
  1223. }
  1224. var marker_count = 0;
  1225. function addMarker(arId, url, callback) {
  1226. var filename = '/marker_' + marker_count++;
  1227. ajax(url, filename, function() {
  1228. var id = Module._addMarker(arId, filename);
  1229. if (callback) callback(id);
  1230. });
  1231. }
  1232. function bytesToString(array) {
  1233. return String.fromCharCode.apply(String, array);
  1234. }
  1235. function parseMultiFile(bytes) {
  1236. var str = bytesToString(bytes);
  1237. var lines = str.split('\n');
  1238. var files = [];
  1239. var state = 0; // 0 - read,
  1240. var markers = 0;
  1241. lines.forEach(function(line) {
  1242. line = line.trim();
  1243. if (!line || line.startsWith('#')) return;
  1244. switch (state) {
  1245. case 0:
  1246. markers = +line;
  1247. state = 1;
  1248. return;
  1249. case 1: // filename or barcode
  1250. if (!line.match(/^\d+$/)) {
  1251. files.push(line);
  1252. }
  1253. case 2: // width
  1254. case 3: // matrices
  1255. case 4:
  1256. state++;
  1257. return;
  1258. case 5:
  1259. state = 1;
  1260. return;
  1261. }
  1262. });
  1263. return files;
  1264. }
  1265. var multi_marker_count = 0;
  1266. function addMultiMarker(arId, url, callback) {
  1267. var filename = '/multi_marker_' + multi_marker_count++;
  1268. ajax(url, filename, function(bytes) {
  1269. var files = parseMultiFile(bytes);
  1270. function ok() {
  1271. var markerID = Module._addMultiMarker(arId, filename);
  1272. var markerNum = Module.getMultiMarkerNum(arId, markerID);
  1273. if (callback) callback(markerID, markerNum);
  1274. }
  1275. if (!files.length) return ok();
  1276. var path = url.split('/').slice(0, -1).join('/')
  1277. files = files.map(function(file) {
  1278. // FIXME super kludge - remove it
  1279. // console.assert(file !== '')
  1280. if( file === 'patt.hiro' || file === 'patt.kanji' || file === 'patt2.hiro' || file === 'patt2.kanji' ){
  1281. // debugger
  1282. return ['http://127.0.0.1:8080/data/data/' + file, file]
  1283. }
  1284. return [path + '/' + file, file]
  1285. })
  1286. ajaxDependencies(files, ok);
  1287. });
  1288. }
  1289. var camera_count = 0;
  1290. function loadCamera(url, callback) {
  1291. var filename = '/camera_param_' + camera_count++;
  1292. var writeCallback = function() {
  1293. var id = Module._loadCamera(filename);
  1294. if (callback) callback(id);
  1295. };
  1296. if (typeof url === 'object') { // Maybe it's a byte array
  1297. writeByteArrayToFS(filename, url, writeCallback);
  1298. } else if (url.indexOf("\n") > -1) { // Or a string with the camera param
  1299. writeStringToFS(filename, url, writeCallback);
  1300. } else {
  1301. ajax(url, filename, writeCallback);
  1302. }
  1303. }
  1304. // transfer image
  1305. function writeStringToFS(target, string, callback) {
  1306. var byteArray = new Uint8Array(string.length);
  1307. for (var i=0; i<byteArray.length; i++) {
  1308. byteArray[i] = string.charCodeAt(i) & 0xff;
  1309. }
  1310. writeByteArrayToFS(target, byteArray, callback);
  1311. }
  1312. function writeByteArrayToFS(target, byteArray, callback) {
  1313. FS.writeFile(target, byteArray, { encoding: 'binary' });
  1314. // console.log('FS written', target);
  1315. callback(byteArray);
  1316. }
  1317. // Eg.
  1318. // ajax('../bin/Data2/markers.dat', '/Data2/markers.dat', callback);
  1319. // ajax('../bin/Data/patt.hiro', '/patt.hiro', callback);
  1320. function ajax(url, target, callback) {
  1321. var oReq = new XMLHttpRequest();
  1322. oReq.open('GET', url, true);
  1323. oReq.responseType = 'arraybuffer'; // blob arraybuffer
  1324. oReq.onload = function(oEvent) {
  1325. // console.log('ajax done for ', url);
  1326. var arrayBuffer = oReq.response;
  1327. var byteArray = new Uint8Array(arrayBuffer);
  1328. // console.log('writeByteArrayToFS', target, byteArray.length, 'byte. url', url)
  1329. writeByteArrayToFS(target, byteArray, callback);
  1330. };
  1331. oReq.send();
  1332. }
  1333. function ajaxDependencies(files, callback) {
  1334. var next = files.pop();
  1335. if (next) {
  1336. ajax(next[0], next[1], function() {
  1337. ajaxDependencies(files, callback);
  1338. });
  1339. } else {
  1340. callback();
  1341. }
  1342. }
  1343. /* Exports */
  1344. window.artoolkit = artoolkit;
  1345. window.ARController = ARController;
  1346. window.ARCameraParam = ARCameraParam;
  1347. if (window.Module) {
  1348. runWhenLoaded();
  1349. } else {
  1350. window.Module = {
  1351. onRuntimeInitialized: function() {
  1352. runWhenLoaded();
  1353. }
  1354. };
  1355. }
  1356. })();
  1357. /*
  1358. Copyright (c) 2011 Juan Mellado
  1359. Permission is hereby granted, free of charge, to any person obtaining a copy
  1360. of this software and associated documentation files (the "Software"), to deal
  1361. in the Software without restriction, including without limitation the rights
  1362. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1363. copies of the Software, and to permit persons to whom the Software is
  1364. furnished to do so, subject to the following conditions:
  1365. The above copyright notice and this permission notice shall be included in
  1366. all copies or substantial portions of the Software.
  1367. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1368. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1369. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1370. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1371. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1372. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1373. THE SOFTWARE.
  1374. */
  1375. /*
  1376. References:
  1377. - "ArUco: a minimal library for Augmented Reality applications based on OpenCv"
  1378. http://www.uco.es/investiga/grupos/ava/node/26
  1379. */
  1380. var AR = AR || {};
  1381. AR.Marker = function(id, corners){
  1382. this.id = id;
  1383. this.corners = corners;
  1384. };
  1385. AR.Detector = function(){
  1386. this.grey = new CV.Image();
  1387. this.thres = new CV.Image();
  1388. this.homography = new CV.Image();
  1389. this.binary = [];
  1390. this.contours = [];
  1391. this.polys = [];
  1392. this.candidates = [];
  1393. };
  1394. AR.Detector.prototype.detect = function(image){
  1395. CV.grayscale(image, this.grey);
  1396. CV.adaptiveThreshold(this.grey, this.thres, 2, 7);
  1397. this.contours = CV.findContours(this.thres, this.binary);
  1398. this.candidates = this.findCandidates(this.contours, image.width * 0.20, 0.05, 10);
  1399. this.candidates = this.clockwiseCorners(this.candidates);
  1400. this.candidates = this.notTooNear(this.candidates, 10);
  1401. return this.findMarkers(this.grey, this.candidates, 49);
  1402. };
  1403. AR.Detector.prototype.findCandidates = function(contours, minSize, epsilon, minLength){
  1404. var candidates = [], len = contours.length, contour, poly, i;
  1405. this.polys = [];
  1406. for (i = 0; i < len; ++ i){
  1407. contour = contours[i];
  1408. if (contour.length >= minSize){
  1409. poly = CV.approxPolyDP(contour, contour.length * epsilon);
  1410. this.polys.push(poly);
  1411. if ( (4 === poly.length) && ( CV.isContourConvex(poly) ) ){
  1412. if ( CV.minEdgeLength(poly) >= minLength){
  1413. candidates.push(poly);
  1414. }
  1415. }
  1416. }
  1417. }
  1418. return candidates;
  1419. };
  1420. AR.Detector.prototype.clockwiseCorners = function(candidates){
  1421. var len = candidates.length, dx1, dx2, dy1, dy2, swap, i;
  1422. for (i = 0; i < len; ++ i){
  1423. dx1 = candidates[i][1].x - candidates[i][0].x;
  1424. dy1 = candidates[i][1].y - candidates[i][0].y;
  1425. dx2 = candidates[i][2].x - candidates[i][0].x;
  1426. dy2 = candidates[i][2].y - candidates[i][0].y;
  1427. if ( (dx1 * dy2 - dy1 * dx2) < 0){
  1428. swap = candidates[i][1];
  1429. candidates[i][1] = candidates[i][3];
  1430. candidates[i][3] = swap;
  1431. }
  1432. }
  1433. return candidates;
  1434. };
  1435. AR.Detector.prototype.notTooNear = function(candidates, minDist){
  1436. var notTooNear = [], len = candidates.length, dist, dx, dy, i, j, k;
  1437. for (i = 0; i < len; ++ i){
  1438. for (j = i + 1; j < len; ++ j){
  1439. dist = 0;
  1440. for (k = 0; k < 4; ++ k){
  1441. dx = candidates[i][k].x - candidates[j][k].x;
  1442. dy = candidates[i][k].y - candidates[j][k].y;
  1443. dist += dx * dx + dy * dy;
  1444. }
  1445. if ( (dist / 4) < (minDist * minDist) ){
  1446. if ( CV.perimeter( candidates[i] ) < CV.perimeter( candidates[j] ) ){
  1447. candidates[i].tooNear = true;
  1448. }else{
  1449. candidates[j].tooNear = true;
  1450. }
  1451. }
  1452. }
  1453. }
  1454. for (i = 0; i < len; ++ i){
  1455. if ( !candidates[i].tooNear ){
  1456. notTooNear.push( candidates[i] );
  1457. }
  1458. }
  1459. return notTooNear;
  1460. };
  1461. AR.Detector.prototype.findMarkers = function(imageSrc, candidates, warpSize){
  1462. var markers = [], len = candidates.length, candidate, marker, i;
  1463. for (i = 0; i < len; ++ i){
  1464. candidate = candidates[i];
  1465. CV.warp(imageSrc, this.homography, candidate, warpSize);
  1466. CV.threshold(this.homography, this.homography, CV.otsu(this.homography) );
  1467. marker = this.getMarker(this.homography, candidate);
  1468. if (marker){
  1469. markers.push(marker);
  1470. }
  1471. }
  1472. return markers;
  1473. };
  1474. AR.Detector.prototype.getMarker = function(imageSrc, candidate){
  1475. var width = (imageSrc.width / 7) >>> 0,
  1476. minZero = (width * width) >> 1,
  1477. bits = [], rotations = [], distances = [],
  1478. square, pair, inc, i, j;
  1479. for (i = 0; i < 7; ++ i){
  1480. inc = (0 === i || 6 === i)? 1: 6;
  1481. for (j = 0; j < 7; j += inc){
  1482. square = {x: j * width, y: i * width, width: width, height: width};
  1483. if ( CV.countNonZero(imageSrc, square) > minZero){
  1484. return null;
  1485. }
  1486. }
  1487. }
  1488. for (i = 0; i < 5; ++ i){
  1489. bits[i] = [];
  1490. for (j = 0; j < 5; ++ j){
  1491. square = {x: (j + 1) * width, y: (i + 1) * width, width: width, height: width};
  1492. bits[i][j] = CV.countNonZero(imageSrc, square) > minZero? 1: 0;
  1493. }
  1494. }
  1495. rotations[0] = bits;
  1496. distances[0] = this.hammingDistance( rotations[0] );
  1497. pair = {first: distances[0], second: 0};
  1498. for (i = 1; i < 4; ++ i){
  1499. rotations[i] = this.rotate( rotations[i - 1] );
  1500. distances[i] = this.hammingDistance( rotations[i] );
  1501. if (distances[i] < pair.first){
  1502. pair.first = distances[i];
  1503. pair.second = i;
  1504. }
  1505. }
  1506. if (0 !== pair.first){
  1507. return null;
  1508. }
  1509. return new AR.Marker(
  1510. this.mat2id( rotations[pair.second] ),
  1511. this.rotate2(candidate, 4 - pair.second)
  1512. );
  1513. };
  1514. AR.Detector.prototype.hammingDistance = function(bits){
  1515. var ids = [ [1,0,0,0,0], [1,0,1,1,1], [0,1,0,0,1], [0,1,1,1,0] ],
  1516. dist = 0, sum, minSum, i, j, k;
  1517. for (i = 0; i < 5; ++ i){
  1518. minSum = Infinity;
  1519. for (j = 0; j < 4; ++ j){
  1520. sum = 0;
  1521. for (k = 0; k < 5; ++ k){
  1522. sum += bits[i][k] === ids[j][k]? 0: 1;
  1523. }
  1524. if (sum < minSum){
  1525. minSum = sum;
  1526. }
  1527. }
  1528. dist += minSum;
  1529. }
  1530. return dist;
  1531. };
  1532. AR.Detector.prototype.mat2id = function(bits){
  1533. var id = 0, i;
  1534. for (i = 0; i < 5; ++ i){
  1535. id <<= 1;
  1536. id |= bits[i][1];
  1537. id <<= 1;
  1538. id |= bits[i][3];
  1539. }
  1540. return id;
  1541. };
  1542. AR.Detector.prototype.rotate = function(src){
  1543. var dst = [], len = src.length, i, j;
  1544. for (i = 0; i < len; ++ i){
  1545. dst[i] = [];
  1546. for (j = 0; j < src[i].length; ++ j){
  1547. dst[i][j] = src[src[i].length - j - 1][i];
  1548. }
  1549. }
  1550. return dst;
  1551. };
  1552. AR.Detector.prototype.rotate2 = function(src, rotation){
  1553. var dst = [], len = src.length, i;
  1554. for (i = 0; i < len; ++ i){
  1555. dst[i] = src[ (rotation + i) % len ];
  1556. }
  1557. return dst;
  1558. };
  1559. /*
  1560. Copyright (c) 2011 Juan Mellado
  1561. Permission is hereby granted, free of charge, to any person obtaining a copy
  1562. of this software and associated documentation files (the "Software"), to deal
  1563. in the Software without restriction, including without limitation the rights
  1564. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1565. copies of the Software, and to permit persons to whom the Software is
  1566. furnished to do so, subject to the following conditions:
  1567. The above copyright notice and this permission notice shall be included in
  1568. all copies or substantial portions of the Software.
  1569. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1570. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1571. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1572. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1573. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1574. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1575. THE SOFTWARE.
  1576. */
  1577. /*
  1578. References:
  1579. - "OpenCV: Open Computer Vision Library"
  1580. http://sourceforge.net/projects/opencvlibrary/
  1581. - "Stack Blur: Fast But Goodlooking"
  1582. http://incubator.quasimondo.com/processing/fast_blur_deluxe.php
  1583. */
  1584. var CV = CV || {};
  1585. CV.Image = function(width, height, data){
  1586. this.width = width || 0;
  1587. this.height = height || 0;
  1588. this.data = data || [];
  1589. };
  1590. CV.grayscale = function(imageSrc, imageDst){
  1591. var src = imageSrc.data, dst = imageDst.data, len = src.length,
  1592. i = 0, j = 0;
  1593. for (; i < len; i += 4){
  1594. dst[j ++] =
  1595. (src[i] * 0.299 + src[i + 1] * 0.587 + src[i + 2] * 0.114 + 0.5) & 0xff;
  1596. }
  1597. imageDst.width = imageSrc.width;
  1598. imageDst.height = imageSrc.height;
  1599. return imageDst;
  1600. };
  1601. CV.threshold = function(imageSrc, imageDst, threshold){
  1602. var src = imageSrc.data, dst = imageDst.data,
  1603. len = src.length, tab = [], i;
  1604. for (i = 0; i < 256; ++ i){
  1605. tab[i] = i <= threshold? 0: 255;
  1606. }
  1607. for (i = 0; i < len; ++ i){
  1608. dst[i] = tab[ src[i] ];
  1609. }
  1610. imageDst.width = imageSrc.width;
  1611. imageDst.height = imageSrc.height;
  1612. return imageDst;
  1613. };
  1614. CV.adaptiveThreshold = function(imageSrc, imageDst, kernelSize, threshold){
  1615. var src = imageSrc.data, dst = imageDst.data, len = src.length, tab = [], i;
  1616. CV.stackBoxBlur(imageSrc, imageDst, kernelSize);
  1617. for (i = 0; i < 768; ++ i){
  1618. tab[i] = (i - 255 <= -threshold)? 255: 0;
  1619. }
  1620. for (i = 0; i < len; ++ i){
  1621. dst[i] = tab[ src[i] - dst[i] + 255 ];
  1622. }
  1623. imageDst.width = imageSrc.width;
  1624. imageDst.height = imageSrc.height;
  1625. return imageDst;
  1626. };
  1627. CV.otsu = function(imageSrc){
  1628. var src = imageSrc.data, len = src.length, hist = [],
  1629. threshold = 0, sum = 0, sumB = 0, wB = 0, wF = 0, max = 0,
  1630. mu, between, i;
  1631. for (i = 0; i < 256; ++ i){
  1632. hist[i] = 0;
  1633. }
  1634. for (i = 0; i < len; ++ i){
  1635. hist[ src[i] ] ++;
  1636. }
  1637. for (i = 0; i < 256; ++ i){
  1638. sum += hist[i] * i;
  1639. }
  1640. for (i = 0; i < 256; ++ i){
  1641. wB += hist[i];
  1642. if (0 !== wB){
  1643. wF = len - wB;
  1644. if (0 === wF){
  1645. break;
  1646. }
  1647. sumB += hist[i] * i;
  1648. mu = (sumB / wB) - ( (sum - sumB) / wF );
  1649. between = wB * wF * mu * mu;
  1650. if (between > max){
  1651. max = between;
  1652. threshold = i;
  1653. }
  1654. }
  1655. }
  1656. return threshold;
  1657. };
  1658. CV.stackBoxBlurMult =
  1659. [1, 171, 205, 293, 57, 373, 79, 137, 241, 27, 391, 357, 41, 19, 283, 265];
  1660. CV.stackBoxBlurShift =
  1661. [0, 9, 10, 11, 9, 12, 10, 11, 12, 9, 13, 13, 10, 9, 13, 13];
  1662. CV.BlurStack = function(){
  1663. this.color = 0;
  1664. this.next = null;
  1665. };
  1666. CV.stackBoxBlur = function(imageSrc, imageDst, kernelSize){
  1667. var src = imageSrc.data, dst = imageDst.data,
  1668. height = imageSrc.height, width = imageSrc.width,
  1669. heightMinus1 = height - 1, widthMinus1 = width - 1,
  1670. size = kernelSize + kernelSize + 1, radius = kernelSize + 1,
  1671. mult = CV.stackBoxBlurMult[kernelSize],
  1672. shift = CV.stackBoxBlurShift[kernelSize],
  1673. stack, stackStart, color, sum, pos, start, p, x, y, i;
  1674. stack = stackStart = new CV.BlurStack();
  1675. for (i = 1; i < size; ++ i){
  1676. stack = stack.next = new CV.BlurStack();
  1677. }
  1678. stack.next = stackStart;
  1679. pos = 0;
  1680. for (y = 0; y < height; ++ y){
  1681. start = pos;
  1682. color = src[pos];
  1683. sum = radius * color;
  1684. stack = stackStart;
  1685. for (i = 0; i < radius; ++ i){
  1686. stack.color = color;
  1687. stack = stack.next;
  1688. }
  1689. for (i = 1; i < radius; ++ i){
  1690. stack.color = src[pos + i];
  1691. sum += stack.color;
  1692. stack = stack.next;
  1693. }
  1694. stack = stackStart;
  1695. for (x = 0; x < width; ++ x){
  1696. dst[pos ++] = (sum * mult) >>> shift;
  1697. p = x + radius;
  1698. p = start + (p < widthMinus1? p: widthMinus1);
  1699. sum -= stack.color - src[p];
  1700. stack.color = src[p];
  1701. stack = stack.next;
  1702. }
  1703. }
  1704. for (x = 0; x < width; ++ x){
  1705. pos = x;
  1706. start = pos + width;
  1707. color = dst[pos];
  1708. sum = radius * color;
  1709. stack = stackStart;
  1710. for (i = 0; i < radius; ++ i){
  1711. stack.color = color;
  1712. stack = stack.next;
  1713. }
  1714. for (i = 1; i < radius; ++ i){
  1715. stack.color = dst[start];
  1716. sum += stack.color;
  1717. stack = stack.next;
  1718. start += width;
  1719. }
  1720. stack = stackStart;
  1721. for (y = 0; y < height; ++ y){
  1722. dst[pos] = (sum * mult) >>> shift;
  1723. p = y + radius;
  1724. p = x + ( (p < heightMinus1? p: heightMinus1) * width );
  1725. sum -= stack.color - dst[p];
  1726. stack.color = dst[p];
  1727. stack = stack.next;
  1728. pos += width;
  1729. }
  1730. }
  1731. return imageDst;
  1732. };
  1733. CV.gaussianBlur = function(imageSrc, imageDst, imageMean, kernelSize){
  1734. var kernel = CV.gaussianKernel(kernelSize);
  1735. imageDst.width = imageSrc.width;
  1736. imageDst.height = imageSrc.height;
  1737. imageMean.width = imageSrc.width;
  1738. imageMean.height = imageSrc.height;
  1739. CV.gaussianBlurFilter(imageSrc, imageMean, kernel, true);
  1740. CV.gaussianBlurFilter(imageMean, imageDst, kernel, false);
  1741. return imageDst;
  1742. };
  1743. CV.gaussianBlurFilter = function(imageSrc, imageDst, kernel, horizontal){
  1744. var src = imageSrc.data, dst = imageDst.data,
  1745. height = imageSrc.height, width = imageSrc.width,
  1746. pos = 0, limit = kernel.length >> 1,
  1747. cur, value, i, j, k;
  1748. for (i = 0; i < height; ++ i){
  1749. for (j = 0; j < width; ++ j){
  1750. value = 0.0;
  1751. for (k = -limit; k <= limit; ++ k){
  1752. if (horizontal){
  1753. cur = pos + k;
  1754. if (j + k < 0){
  1755. cur = pos;
  1756. }
  1757. else if (j + k >= width){
  1758. cur = pos;
  1759. }
  1760. }else{
  1761. cur = pos + (k * width);
  1762. if (i + k < 0){
  1763. cur = pos;
  1764. }
  1765. else if (i + k >= height){
  1766. cur = pos;
  1767. }
  1768. }
  1769. value += kernel[limit + k] * src[cur];
  1770. }
  1771. dst[pos ++] = horizontal? value: (value + 0.5) & 0xff;
  1772. }
  1773. }
  1774. return imageDst;
  1775. };
  1776. CV.gaussianKernel = function(kernelSize){
  1777. var tab =
  1778. [ [1],
  1779. [0.25, 0.5, 0.25],
  1780. [0.0625, 0.25, 0.375, 0.25, 0.0625],
  1781. [0.03125, 0.109375, 0.21875, 0.28125, 0.21875, 0.109375, 0.03125] ],
  1782. kernel = [], center, sigma, scale2X, sum, x, i;
  1783. if ( (kernelSize <= 7) && (kernelSize % 2 === 1) ){
  1784. kernel = tab[kernelSize >> 1];
  1785. }else{
  1786. center = (kernelSize - 1.0) * 0.5;
  1787. sigma = 0.8 + (0.3 * (center - 1.0) );
  1788. scale2X = -0.5 / (sigma * sigma);
  1789. sum = 0.0;
  1790. for (i = 0; i < kernelSize; ++ i){
  1791. x = i - center;
  1792. sum += kernel[i] = Math.exp(scale2X * x * x);
  1793. }
  1794. sum = 1 / sum;
  1795. for (i = 0; i < kernelSize; ++ i){
  1796. kernel[i] *= sum;
  1797. }
  1798. }
  1799. return kernel;
  1800. };
  1801. CV.findContours = function(imageSrc, binary){
  1802. var width = imageSrc.width, height = imageSrc.height, contours = [],
  1803. src, deltas, pos, pix, nbd, outer, hole, i, j;
  1804. src = CV.binaryBorder(imageSrc, binary);
  1805. deltas = CV.neighborhoodDeltas(width + 2);
  1806. pos = width + 3;
  1807. nbd = 1;
  1808. for (i = 0; i < height; ++ i, pos += 2){
  1809. for (j = 0; j < width; ++ j, ++ pos){
  1810. pix = src[pos];
  1811. if (0 !== pix){
  1812. outer = hole = false;
  1813. if (1 === pix && 0 === src[pos - 1]){
  1814. outer = true;
  1815. }
  1816. else if (pix >= 1 && 0 === src[pos + 1]){
  1817. hole = true;
  1818. }
  1819. if (outer || hole){
  1820. ++ nbd;
  1821. contours.push( CV.borderFollowing(src, pos, nbd, {x: j, y: i}, hole, deltas) );
  1822. }
  1823. }
  1824. }
  1825. }
  1826. return contours;
  1827. };
  1828. CV.borderFollowing = function(src, pos, nbd, point, hole, deltas){
  1829. var contour = [], pos1, pos3, pos4, s, s_end, s_prev;
  1830. contour.hole = hole;
  1831. s = s_end = hole? 0: 4;
  1832. do{
  1833. s = (s - 1) & 7;
  1834. pos1 = pos + deltas[s];
  1835. if (src[pos1] !== 0){
  1836. break;
  1837. }
  1838. }while(s !== s_end);
  1839. if (s === s_end){
  1840. src[pos] = -nbd;
  1841. contour.push( {x: point.x, y: point.y} );
  1842. }else{
  1843. pos3 = pos;
  1844. s_prev = s ^ 4;
  1845. while(true){
  1846. s_end = s;
  1847. do{
  1848. pos4 = pos3 + deltas[++ s];
  1849. }while(src[pos4] === 0);
  1850. s &= 7;
  1851. if ( ( (s - 1) >>> 0) < (s_end >>> 0) ){
  1852. src[pos3] = -nbd;
  1853. }
  1854. else if (src[pos3] === 1){
  1855. src[pos3] = nbd;
  1856. }
  1857. contour.push( {x: point.x, y: point.y} );
  1858. s_prev = s;
  1859. point.x += CV.neighborhood[s][0];
  1860. point.y += CV.neighborhood[s][1];
  1861. if ( (pos4 === pos) && (pos3 === pos1) ){
  1862. break;
  1863. }
  1864. pos3 = pos4;
  1865. s = (s + 4) & 7;
  1866. }
  1867. }
  1868. return contour;
  1869. };
  1870. CV.neighborhood =
  1871. [ [1, 0], [1, -1], [0, -1], [-1, -1], [-1, 0], [-1, 1], [0, 1], [1, 1] ];
  1872. CV.neighborhoodDeltas = function(width){
  1873. var deltas = [], len = CV.neighborhood.length, i = 0;
  1874. for (; i < len; ++ i){
  1875. deltas[i] = CV.neighborhood[i][0] + (CV.neighborhood[i][1] * width);
  1876. }
  1877. return deltas.concat(deltas);
  1878. };
  1879. CV.approxPolyDP = function(contour, epsilon){
  1880. var slice = {start_index: 0, end_index: 0},
  1881. right_slice = {start_index: 0, end_index: 0},
  1882. poly = [], stack = [], len = contour.length,
  1883. pt, start_pt, end_pt, dist, max_dist, le_eps,
  1884. dx, dy, i, j, k;
  1885. epsilon *= epsilon;
  1886. k = 0;
  1887. for (i = 0; i < 3; ++ i){
  1888. max_dist = 0;
  1889. k = (k + right_slice.start_index) % len;
  1890. start_pt = contour[k];
  1891. if (++ k === len) {k = 0;}
  1892. for (j = 1; j < len; ++ j){
  1893. pt = contour[k];
  1894. if (++ k === len) {k = 0;}
  1895. dx = pt.x - start_pt.x;
  1896. dy = pt.y - start_pt.y;
  1897. dist = dx * dx + dy * dy;
  1898. if (dist > max_dist){
  1899. max_dist = dist;
  1900. right_slice.start_index = j;
  1901. }
  1902. }
  1903. }
  1904. if (max_dist <= epsilon){
  1905. poly.push( {x: start_pt.x, y: start_pt.y} );
  1906. }else{
  1907. slice.start_index = k;
  1908. slice.end_index = (right_slice.start_index += slice.start_index);
  1909. right_slice.start_index -= right_slice.start_index >= len? len: 0;
  1910. right_slice.end_index = slice.start_index;
  1911. if (right_slice.end_index < right_slice.start_index){
  1912. right_slice.end_index += len;
  1913. }
  1914. stack.push( {start_index: right_slice.start_index, end_index: right_slice.end_index} );
  1915. stack.push( {start_index: slice.start_index, end_index: slice.end_index} );
  1916. }
  1917. while(stack.length !== 0){
  1918. slice = stack.pop();
  1919. end_pt = contour[slice.end_index % len];
  1920. start_pt = contour[k = slice.start_index % len];
  1921. if (++ k === len) {k = 0;}
  1922. if (slice.end_index <= slice.start_index + 1){
  1923. le_eps = true;
  1924. }else{
  1925. max_dist = 0;
  1926. dx = end_pt.x - start_pt.x;
  1927. dy = end_pt.y - start_pt.y;
  1928. for (i = slice.start_index + 1; i < slice.end_index; ++ i){
  1929. pt = contour[k];
  1930. if (++ k === len) {k = 0;}
  1931. dist = Math.abs( (pt.y - start_pt.y) * dx - (pt.x - start_pt.x) * dy);
  1932. if (dist > max_dist){
  1933. max_dist = dist;
  1934. right_slice.start_index = i;
  1935. }
  1936. }
  1937. le_eps = max_dist * max_dist <= epsilon * (dx * dx + dy * dy);
  1938. }
  1939. if (le_eps){
  1940. poly.push( {x: start_pt.x, y: start_pt.y} );
  1941. }else{
  1942. right_slice.end_index = slice.end_index;
  1943. slice.end_index = right_slice.start_index;
  1944. stack.push( {start_index: right_slice.start_index, end_index: right_slice.end_index} );
  1945. stack.push( {start_index: slice.start_index, end_index: slice.end_index} );
  1946. }
  1947. }
  1948. return poly;
  1949. };
  1950. CV.warp = function(imageSrc, imageDst, contour, warpSize){
  1951. var src = imageSrc.data, dst = imageDst.data,
  1952. width = imageSrc.width, height = imageSrc.height,
  1953. pos = 0,
  1954. sx1, sx2, dx1, dx2, sy1, sy2, dy1, dy2, p1, p2, p3, p4,
  1955. m, r, s, t, u, v, w, x, y, i, j;
  1956. m = CV.getPerspectiveTransform(contour, warpSize - 1);
  1957. r = m[8];
  1958. s = m[2];
  1959. t = m[5];
  1960. for (i = 0; i < warpSize; ++ i){
  1961. r += m[7];
  1962. s += m[1];
  1963. t += m[4];
  1964. u = r;
  1965. v = s;
  1966. w = t;
  1967. for (j = 0; j < warpSize; ++ j){
  1968. u += m[6];
  1969. v += m[0];
  1970. w += m[3];
  1971. x = v / u;
  1972. y = w / u;
  1973. sx1 = x >>> 0;
  1974. sx2 = (sx1 === width - 1)? sx1: sx1 + 1;
  1975. dx1 = x - sx1;
  1976. dx2 = 1.0 - dx1;
  1977. sy1 = y >>> 0;
  1978. sy2 = (sy1 === height - 1)? sy1: sy1 + 1;
  1979. dy1 = y - sy1;
  1980. dy2 = 1.0 - dy1;
  1981. p1 = p2 = sy1 * width;
  1982. p3 = p4 = sy2 * width;
  1983. dst[pos ++] =
  1984. (dy2 * (dx2 * src[p1 + sx1] + dx1 * src[p2 + sx2]) +
  1985. dy1 * (dx2 * src[p3 + sx1] + dx1 * src[p4 + sx2]) ) & 0xff;
  1986. }
  1987. }
  1988. imageDst.width = warpSize;
  1989. imageDst.height = warpSize;
  1990. return imageDst;
  1991. };
  1992. CV.getPerspectiveTransform = function(src, size){
  1993. var rq = CV.square2quad(src);
  1994. rq[0] /= size;
  1995. rq[1] /= size;
  1996. rq[3] /= size;
  1997. rq[4] /= size;
  1998. rq[6] /= size;
  1999. rq[7] /= size;
  2000. return rq;
  2001. };
  2002. CV.square2quad = function(src){
  2003. var sq = [], px, py, dx1, dx2, dy1, dy2, den;
  2004. px = src[0].x - src[1].x + src[2].x - src[3].x;
  2005. py = src[0].y - src[1].y + src[2].y - src[3].y;
  2006. if (0 === px && 0 === py){
  2007. sq[0] = src[1].x - src[0].x;
  2008. sq[1] = src[2].x - src[1].x;
  2009. sq[2] = src[0].x;
  2010. sq[3] = src[1].y - src[0].y;
  2011. sq[4] = src[2].y - src[1].y;
  2012. sq[5] = src[0].y;
  2013. sq[6] = 0;
  2014. sq[7] = 0;
  2015. sq[8] = 1;
  2016. }else{
  2017. dx1 = src[1].x - src[2].x;
  2018. dx2 = src[3].x - src[2].x;
  2019. dy1 = src[1].y - src[2].y;
  2020. dy2 = src[3].y - src[2].y;
  2021. den = dx1 * dy2 - dx2 * dy1;
  2022. sq[6] = (px * dy2 - dx2 * py) / den;
  2023. sq[7] = (dx1 * py - px * dy1) / den;
  2024. sq[8] = 1;
  2025. sq[0] = src[1].x - src[0].x + sq[6] * src[1].x;
  2026. sq[1] = src[3].x - src[0].x + sq[7] * src[3].x;
  2027. sq[2] = src[0].x;
  2028. sq[3] = src[1].y - src[0].y + sq[6] * src[1].y;
  2029. sq[4] = src[3].y - src[0].y + sq[7] * src[3].y;
  2030. sq[5] = src[0].y;
  2031. }
  2032. return sq;
  2033. };
  2034. CV.isContourConvex = function(contour){
  2035. var orientation = 0, convex = true,
  2036. len = contour.length, i = 0, j = 0,
  2037. cur_pt, prev_pt, dxdy0, dydx0, dx0, dy0, dx, dy;
  2038. prev_pt = contour[len - 1];
  2039. cur_pt = contour[0];
  2040. dx0 = cur_pt.x - prev_pt.x;
  2041. dy0 = cur_pt.y - prev_pt.y;
  2042. for (; i < len; ++ i){
  2043. if (++ j === len) {j = 0;}
  2044. prev_pt = cur_pt;
  2045. cur_pt = contour[j];
  2046. dx = cur_pt.x - prev_pt.x;
  2047. dy = cur_pt.y - prev_pt.y;
  2048. dxdy0 = dx * dy0;
  2049. dydx0 = dy * dx0;
  2050. orientation |= dydx0 > dxdy0? 1: (dydx0 < dxdy0? 2: 3);
  2051. if (3 === orientation){
  2052. convex = false;
  2053. break;
  2054. }
  2055. dx0 = dx;
  2056. dy0 = dy;
  2057. }
  2058. return convex;
  2059. };
  2060. CV.perimeter = function(poly){
  2061. var len = poly.length, i = 0, j = len - 1,
  2062. p = 0.0, dx, dy;
  2063. for (; i < len; j = i ++){
  2064. dx = poly[i].x - poly[j].x;
  2065. dy = poly[i].y - poly[j].y;
  2066. p += Math.sqrt(dx * dx + dy * dy) ;
  2067. }
  2068. return p;
  2069. };
  2070. CV.minEdgeLength = function(poly){
  2071. var len = poly.length, i = 0, j = len - 1,
  2072. min = Infinity, d, dx, dy;
  2073. for (; i < len; j = i ++){
  2074. dx = poly[i].x - poly[j].x;
  2075. dy = poly[i].y - poly[j].y;
  2076. d = dx * dx + dy * dy;
  2077. if (d < min){
  2078. min = d;
  2079. }
  2080. }
  2081. return Math.sqrt(min);
  2082. };
  2083. CV.countNonZero = function(imageSrc, square){
  2084. var src = imageSrc.data, height = square.height, width = square.width,
  2085. pos = square.x + (square.y * imageSrc.width),
  2086. span = imageSrc.width - width,
  2087. nz = 0, i, j;
  2088. for (i = 0; i < height; ++ i){
  2089. for (j = 0; j < width; ++ j){
  2090. if ( 0 !== src[pos ++] ){
  2091. ++ nz;
  2092. }
  2093. }
  2094. pos += span;
  2095. }
  2096. return nz;
  2097. };
  2098. CV.binaryBorder = function(imageSrc, dst){
  2099. var src = imageSrc.data, height = imageSrc.height, width = imageSrc.width,
  2100. posSrc = 0, posDst = 0, i, j;
  2101. for (j = -2; j < width; ++ j){
  2102. dst[posDst ++] = 0;
  2103. }
  2104. for (i = 0; i < height; ++ i){
  2105. dst[posDst ++] = 0;
  2106. for (j = 0; j < width; ++ j){
  2107. dst[posDst ++] = (0 === src[posSrc ++]? 0: 1);
  2108. }
  2109. dst[posDst ++] = 0;
  2110. }
  2111. for (j = -2; j < width; ++ j){
  2112. dst[posDst ++] = 0;
  2113. }
  2114. return dst;
  2115. };
  2116. /*
  2117. Copyright (c) 2012 Juan Mellado
  2118. Permission is hereby granted, free of charge, to any person obtaining a copy
  2119. of this software and associated documentation files (the "Software"), to deal
  2120. in the Software without restriction, including without limitation the rights
  2121. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2122. copies of the Software, and to permit persons to whom the Software is
  2123. furnished to do so, subject to the following conditions:
  2124. The above copyright notice and this permission notice shall be included in
  2125. all copies or substantial portions of the Software.
  2126. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2127. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2128. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2129. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2130. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2131. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2132. THE SOFTWARE.
  2133. */
  2134. /*
  2135. References:
  2136. - "Iterative Pose Estimation using Coplanar Feature Points"
  2137. Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis
  2138. http://www.cfar.umd.edu/~daniel/daniel_papersfordownload/CoplanarPts.pdf
  2139. */
  2140. var POS = POS || {};
  2141. POS.Posit = function(modelSize, focalLength){
  2142. this.objectPoints = this.buildModel(modelSize);
  2143. this.focalLength = focalLength;
  2144. this.objectVectors = [];
  2145. this.objectNormal = [];
  2146. this.objectMatrix = [[],[],[]];
  2147. this.init();
  2148. };
  2149. POS.Posit.prototype.buildModel = function(modelSize){
  2150. var half = modelSize / 2.0;
  2151. return [
  2152. [-half, half, 0.0],
  2153. [ half, half, 0.0],
  2154. [ half, -half, 0.0],
  2155. [-half, -half, 0.0]
  2156. ];
  2157. };
  2158. POS.Posit.prototype.init = function(){
  2159. var np = this.objectPoints.length,
  2160. vectors = [], n = [], len = 0.0, row = 2, i;
  2161. for (i = 0; i < np; ++ i){
  2162. this.objectVectors[i] = [this.objectPoints[i][0] - this.objectPoints[0][0],
  2163. this.objectPoints[i][1] - this.objectPoints[0][1],
  2164. this.objectPoints[i][2] - this.objectPoints[0][2]];
  2165. vectors[i] = [this.objectVectors[i][0],
  2166. this.objectVectors[i][1],
  2167. this.objectVectors[i][2]];
  2168. }
  2169. while(0.0 === len){
  2170. n[0] = this.objectVectors[1][1] * this.objectVectors[row][2] -
  2171. this.objectVectors[1][2] * this.objectVectors[row][1];
  2172. n[1] = this.objectVectors[1][2] * this.objectVectors[row][0] -
  2173. this.objectVectors[1][0] * this.objectVectors[row][2];
  2174. n[2] = this.objectVectors[1][0] * this.objectVectors[row][1] -
  2175. this.objectVectors[1][1] * this.objectVectors[row][0];
  2176. len = Math.sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);
  2177. ++ row;
  2178. }
  2179. for (i = 0; i < 3; ++ i){
  2180. this.objectNormal[i] = n[i] / len;
  2181. }
  2182. POS.pseudoInverse(vectors, np, this.objectMatrix);
  2183. };
  2184. POS.Posit.prototype.pose = function(imagePoints){
  2185. var posRotation1 = [[],[],[]], posRotation2 = [[],[],[]], posTranslation = [],
  2186. rotation1 = [[],[],[]], rotation2 = [[],[],[]], translation1 = [], translation2 = [],
  2187. error1, error2, valid1, valid2, i, j;
  2188. this.pos(imagePoints, posRotation1, posRotation2, posTranslation);
  2189. valid1 = this.isValid(posRotation1, posTranslation);
  2190. if (valid1){
  2191. error1 = this.iterate(imagePoints, posRotation1, posTranslation, rotation1, translation1);
  2192. }else{
  2193. error1 = {euclidean: -1.0, pixels: -1, maximum: -1.0};
  2194. }
  2195. valid2 = this.isValid(posRotation2, posTranslation);
  2196. if (valid2){
  2197. error2 = this.iterate(imagePoints, posRotation2, posTranslation, rotation2, translation2);
  2198. }else{
  2199. error2 = {euclidean: -1.0, pixels: -1, maximum: -1.0};
  2200. }
  2201. for (i = 0; i < 3; ++ i){
  2202. for (j = 0; j < 3; ++ j){
  2203. if (valid1){
  2204. translation1[i] -= rotation1[i][j] * this.objectPoints[0][j];
  2205. }
  2206. if (valid2){
  2207. translation2[i] -= rotation2[i][j] * this.objectPoints[0][j];
  2208. }
  2209. }
  2210. }
  2211. return error1.euclidean < error2.euclidean?
  2212. new POS.Pose(error1.pixels, rotation1, translation1, error2.pixels, rotation2, translation2):
  2213. new POS.Pose(error2.pixels, rotation2, translation2, error1.pixels, rotation1, translation1);
  2214. };
  2215. POS.Posit.prototype.pos = function(imagePoints, rotation1, rotation2, translation){
  2216. var np = this.objectPoints.length, imageVectors = [],
  2217. i0 = [], j0 = [], ivec = [], jvec = [], row1 = [], row2 = [], row3 = [],
  2218. i0i0, j0j0, i0j0, delta, q, lambda, mu, scale, i, j;
  2219. for (i = 0; i < np; ++ i){
  2220. imageVectors[i] = [imagePoints[i].x - imagePoints[0].x,
  2221. imagePoints[i].y - imagePoints[0].y];
  2222. }
  2223. //i0 and j0
  2224. for (i = 0; i < 3; ++ i){
  2225. i0[i] = 0.0;
  2226. j0[i] = 0.0;
  2227. for (j = 0; j < np; ++ j){
  2228. i0[i] += this.objectMatrix[i][j] * imageVectors[j][0];
  2229. j0[i] += this.objectMatrix[i][j] * imageVectors[j][1];
  2230. }
  2231. }
  2232. i0i0 = i0[0] * i0[0] + i0[1] * i0[1] + i0[2] * i0[2];
  2233. j0j0 = j0[0] * j0[0] + j0[1] * j0[1] + j0[2] * j0[2];
  2234. i0j0 = i0[0] * j0[0] + i0[1] * j0[1] + i0[2] * j0[2];
  2235. //Lambda and mu
  2236. delta = (j0j0 - i0i0) * (j0j0 - i0i0) + 4.0 * (i0j0 * i0j0);
  2237. if (j0j0 - i0i0 >= 0.0){
  2238. q = (j0j0 - i0i0 + Math.sqrt(delta) ) / 2.0;
  2239. }else{
  2240. q = (j0j0 - i0i0 - Math.sqrt(delta) ) / 2.0;
  2241. }
  2242. if (q >= 0.0){
  2243. lambda = Math.sqrt(q);
  2244. if (0.0 === lambda){
  2245. mu = 0.0;
  2246. }else{
  2247. mu = -i0j0 / lambda;
  2248. }
  2249. }else{
  2250. lambda = Math.sqrt( -(i0j0 * i0j0) / q);
  2251. if (0.0 === lambda){
  2252. mu = Math.sqrt(i0i0 - j0j0);
  2253. }else{
  2254. mu = -i0j0 / lambda;
  2255. }
  2256. }
  2257. //First rotation
  2258. for (i = 0; i < 3; ++ i){
  2259. ivec[i] = i0[i] + lambda * this.objectNormal[i];
  2260. jvec[i] = j0[i] + mu * this.objectNormal[i];
  2261. }
  2262. scale = Math.sqrt(ivec[0] * ivec[0] + ivec[1] * ivec[1] + ivec[2] * ivec[2]);
  2263. for (i = 0; i < 3; ++ i){
  2264. row1[i] = ivec[i] / scale;
  2265. row2[i] = jvec[i] / scale;
  2266. }
  2267. row3[0] = row1[1] * row2[2] - row1[2] * row2[1];
  2268. row3[1] = row1[2] * row2[0] - row1[0] * row2[2];
  2269. row3[2] = row1[0] * row2[1] - row1[1] * row2[0];
  2270. for (i = 0; i < 3; ++ i){
  2271. rotation1[0][i] = row1[i];
  2272. rotation1[1][i] = row2[i];
  2273. rotation1[2][i] = row3[i];
  2274. }
  2275. //Second rotation
  2276. for (i = 0; i < 3; ++ i){
  2277. ivec[i] = i0[i] - lambda * this.objectNormal[i];
  2278. jvec[i] = j0[i] - mu * this.objectNormal[i];
  2279. }
  2280. for (i = 0; i < 3; ++ i){
  2281. row1[i] = ivec[i] / scale;
  2282. row2[i] = jvec[i] / scale;
  2283. }
  2284. row3[0] = row1[1] * row2[2] - row1[2] * row2[1];
  2285. row3[1] = row1[2] * row2[0] - row1[0] * row2[2];
  2286. row3[2] = row1[0] * row2[1] - row1[1] * row2[0];
  2287. for (i = 0; i < 3; ++ i){
  2288. rotation2[0][i] = row1[i];
  2289. rotation2[1][i] = row2[i];
  2290. rotation2[2][i] = row3[i];
  2291. }
  2292. //Translation
  2293. translation[0] = imagePoints[0].x / scale;
  2294. translation[1] = imagePoints[0].y / scale;
  2295. translation[2] = this.focalLength / scale;
  2296. };
  2297. POS.Posit.prototype.isValid = function(rotation, translation){
  2298. var np = this.objectPoints.length, zmin = Infinity, i = 0, zi;
  2299. for (; i < np; ++ i){
  2300. zi = translation[2] +
  2301. (rotation[2][0] * this.objectVectors[i][0] +
  2302. rotation[2][1] * this.objectVectors[i][1] +
  2303. rotation[2][2] * this.objectVectors[i][2]
  2304. );
  2305. if (zi < zmin){
  2306. zmin = zi;
  2307. }
  2308. }
  2309. return zmin >= 0.0;
  2310. };
  2311. POS.Posit.prototype.iterate = function(imagePoints, posRotation, posTranslation, rotation, translation){
  2312. var np = this.objectPoints.length,
  2313. oldSopImagePoints = [], sopImagePoints = [],
  2314. rotation1 = [[],[],[]], rotation2 = [[],[],[]],
  2315. translation1 = [], translation2 = [],
  2316. converged = false, iteration = 0,
  2317. oldImageDifference, imageDifference, factor,
  2318. error, error1, error2, delta, i, j;
  2319. for (i = 0; i < np; ++ i){
  2320. oldSopImagePoints[i] = {x: imagePoints[i].x,
  2321. y: imagePoints[i].y
  2322. };
  2323. }
  2324. for (i = 0; i < 3; ++ i){
  2325. for (j = 0; j < 3; ++ j){
  2326. rotation[i][j] = posRotation[i][j];
  2327. }
  2328. translation[i] = posTranslation[i];
  2329. }
  2330. for (i = 0; i < np; ++ i){
  2331. factor = 0.0;
  2332. for (j = 0; j < 3; ++ j){
  2333. factor += this.objectVectors[i][j] * rotation[2][j] / translation[2];
  2334. }
  2335. sopImagePoints[i] = {x: (1.0 + factor) * imagePoints[i].x,
  2336. y: (1.0 + factor) * imagePoints[i].y
  2337. };
  2338. }
  2339. imageDifference = 0.0;
  2340. for (i = 0; i < np; ++ i){
  2341. imageDifference += Math.abs(sopImagePoints[i].x - oldSopImagePoints[i].x);
  2342. imageDifference += Math.abs(sopImagePoints[i].y - oldSopImagePoints[i].y);
  2343. }
  2344. for (i = 0; i < 3; ++ i){
  2345. translation1[i] = translation[i] -
  2346. (rotation[i][0] * this.objectPoints[0][0] +
  2347. rotation[i][1] * this.objectPoints[0][1] +
  2348. rotation[i][2] * this.objectPoints[0][2]
  2349. );
  2350. }
  2351. error = error1 = this.error(imagePoints, rotation, translation1);
  2352. //Convergence
  2353. converged = (0.0 === error1.pixels) || (imageDifference < 0.01);
  2354. while( iteration ++ < 100 && !converged ){
  2355. for (i = 0; i < np; ++ i){
  2356. oldSopImagePoints[i].x = sopImagePoints[i].x;
  2357. oldSopImagePoints[i].y = sopImagePoints[i].y;
  2358. }
  2359. this.pos(sopImagePoints, rotation1, rotation2, translation);
  2360. for (i = 0; i < 3; ++ i){
  2361. translation1[i] = translation[i] -
  2362. (rotation1[i][0] * this.objectPoints[0][0] +
  2363. rotation1[i][1] * this.objectPoints[0][1] +
  2364. rotation1[i][2] * this.objectPoints[0][2]
  2365. );
  2366. translation2[i] = translation[i] -
  2367. (rotation2[i][0] * this.objectPoints[0][0] +
  2368. rotation2[i][1] * this.objectPoints[0][1] +
  2369. rotation2[i][2] * this.objectPoints[0][2]
  2370. );
  2371. }
  2372. error1 = this.error(imagePoints, rotation1, translation1);
  2373. error2 = this.error(imagePoints, rotation2, translation2);
  2374. if ( (error1.euclidean >= 0.0) && (error2.euclidean >= 0.0) ){
  2375. if (error2.euclidean < error1.euclidean){
  2376. error = error2;
  2377. for (i = 0; i < 3; ++ i){
  2378. for (j = 0; j < 3; ++ j){
  2379. rotation[i][j] = rotation2[i][j];
  2380. }
  2381. }
  2382. }else{
  2383. error = error1;
  2384. for (i = 0; i < 3; ++ i){
  2385. for (j = 0; j < 3; ++ j){
  2386. rotation[i][j] = rotation1[i][j];
  2387. }
  2388. }
  2389. }
  2390. }
  2391. if ( (error1.euclidean < 0.0) && (error2.euclidean >= 0.0) ){
  2392. error = error2;
  2393. for (i = 0; i < 3; ++ i){
  2394. for (j = 0; j < 3; ++ j){
  2395. rotation[i][j] = rotation2[i][j];
  2396. }
  2397. }
  2398. }
  2399. if ( (error2.euclidean < 0.0) && (error1.euclidean >= 0.0) ){
  2400. error = error1;
  2401. for (i = 0; i < 3; ++ i){
  2402. for (j = 0; j < 3; ++ j){
  2403. rotation[i][j] = rotation1[i][j];
  2404. }
  2405. }
  2406. }
  2407. for (i = 0; i < np; ++ i){
  2408. factor = 0.0;
  2409. for (j = 0; j < 3; ++ j){
  2410. factor += this.objectVectors[i][j] * rotation[2][j] / translation[2];
  2411. }
  2412. sopImagePoints[i].x = (1.0 + factor) * imagePoints[i].x;
  2413. sopImagePoints[i].y = (1.0 + factor) * imagePoints[i].y;
  2414. }
  2415. oldImageDifference = imageDifference;
  2416. imageDifference = 0.0;
  2417. for (i = 0; i < np; ++ i){
  2418. imageDifference += Math.abs(sopImagePoints[i].x - oldSopImagePoints[i].x);
  2419. imageDifference += Math.abs(sopImagePoints[i].y - oldSopImagePoints[i].y);
  2420. }
  2421. delta = Math.abs(imageDifference - oldImageDifference);
  2422. converged = (0.0 === error.pixels) || (delta < 0.01);
  2423. }
  2424. return error;
  2425. };
  2426. POS.Posit.prototype.error = function(imagePoints, rotation, translation){
  2427. var np = this.objectPoints.length,
  2428. move = [], projection = [], errorvec = [],
  2429. euclidean = 0.0, pixels = 0.0, maximum = 0.0,
  2430. i, j, k;
  2431. if ( !this.isValid(rotation, translation) ){
  2432. return {euclidean: -1.0, pixels: -1, maximum: -1.0};
  2433. }
  2434. for (i = 0; i < np; ++ i){
  2435. move[i] = [];
  2436. for (j = 0; j < 3; ++ j){
  2437. move[i][j] = translation[j];
  2438. }
  2439. }
  2440. for (i = 0; i < np; ++ i){
  2441. for (j = 0; j < 3; ++ j){
  2442. for (k = 0; k < 3; ++ k){
  2443. move[i][j] += rotation[j][k] * this.objectPoints[i][k];
  2444. }
  2445. }
  2446. }
  2447. for (i = 0; i < np; ++ i){
  2448. projection[i] = [];
  2449. for (j = 0; j < 2; ++ j){
  2450. projection[i][j] = this.focalLength * move[i][j] / move[i][2];
  2451. }
  2452. }
  2453. for (i = 0; i < np; ++ i){
  2454. errorvec[i] = [projection[i][0] - imagePoints[i].x,
  2455. projection[i][1] - imagePoints[i].y];
  2456. }
  2457. for (i = 0; i < np; ++ i){
  2458. euclidean += Math.sqrt(errorvec[i][0] * errorvec[i][0] +
  2459. errorvec[i][1] * errorvec[i][1]
  2460. );
  2461. pixels += Math.abs( Math.round(projection[i][0]) - Math.round(imagePoints[i].x) ) +
  2462. Math.abs( Math.round(projection[i][1]) - Math.round(imagePoints[i].y) );
  2463. if (Math.abs(errorvec[i][0]) > maximum){
  2464. maximum = Math.abs(errorvec[i][0]);
  2465. }
  2466. if (Math.abs(errorvec[i][1]) > maximum){
  2467. maximum = Math.abs(errorvec[i][1]);
  2468. }
  2469. }
  2470. return {euclidean: euclidean / np, pixels: pixels, maximum: maximum};
  2471. };
  2472. POS.pseudoInverse = function(a, n, b){
  2473. var w = [], v = [[],[],[]], s = [[],[],[]],
  2474. wmax = 0.0, cn = 0,
  2475. i, j, k;
  2476. SVD.svdcmp(a, n, 3, w, v);
  2477. for (i = 0; i < 3; ++ i){
  2478. if (w[i] > wmax){
  2479. wmax = w[i];
  2480. }
  2481. }
  2482. wmax *= 0.01;
  2483. for (i = 0; i < 3; ++ i){
  2484. if (w[i] < wmax){
  2485. w[i] = 0.0;
  2486. }
  2487. }
  2488. for (j = 0; j < 3; ++ j){
  2489. if (0.0 === w[j]){
  2490. ++ cn;
  2491. for (k = j; k < 2; ++ k){
  2492. for (i = 0; i < n; ++ i){
  2493. a[i][k] = a[i][k + 1];
  2494. }
  2495. for (i = 0; i < 3; ++ i){
  2496. v[i][k] = v[i][k + 1];
  2497. }
  2498. }
  2499. }
  2500. }
  2501. for (j = 0; j < 2; ++ j){
  2502. if (0.0 === w[j]){
  2503. w[j] = w[j + 1];
  2504. }
  2505. }
  2506. for (i = 0; i < 3; ++ i){
  2507. for (j = 0; j < 3 - cn; ++ j){
  2508. s[i][j] = v[i][j] / w[j];
  2509. }
  2510. }
  2511. for (i = 0; i < 3; ++ i){
  2512. for (j = 0; j < n; ++ j){
  2513. b[i][j] = 0.0;
  2514. for (k = 0; k < 3 - cn; ++ k){
  2515. b[i][j] += s[i][k] * a[j][k];
  2516. }
  2517. }
  2518. }
  2519. };
  2520. POS.Pose = function(error1, rotation1, translation1, error2, rotation2, translation2){
  2521. this.bestError = error1;
  2522. this.bestRotation = rotation1;
  2523. this.bestTranslation = translation1;
  2524. this.alternativeError = error2;
  2525. this.alternativeRotation = rotation2;
  2526. this.alternativeTranslation = translation2;
  2527. };
  2528. /*
  2529. Copyright (c) 2012 Juan Mellado
  2530. Permission is hereby granted, free of charge, to any person obtaining a copy
  2531. of this software and associated documentation files (the "Software"), to deal
  2532. in the Software without restriction, including without limitation the rights
  2533. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2534. copies of the Software, and to permit persons to whom the Software is
  2535. furnished to do so, subject to the following conditions:
  2536. The above copyright notice and this permission notice shall be included in
  2537. all copies or substantial portions of the Software.
  2538. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2539. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2540. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2541. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2542. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2543. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2544. THE SOFTWARE.
  2545. */
  2546. /*
  2547. References:
  2548. - "Numerical Recipes in C - Second Edition"
  2549. http://www.nr.com/
  2550. */
  2551. var SVD = SVD || {};
  2552. SVD.svdcmp = function(a, m, n, w, v){
  2553. var flag, i, its, j, jj, k, l, nm,
  2554. anorm = 0.0, c, f, g = 0.0, h, s, scale = 0.0, x, y, z, rv1 = [];
  2555. //Householder reduction to bidiagonal form
  2556. for (i = 0; i < n; ++ i){
  2557. l = i + 1;
  2558. rv1[i] = scale * g;
  2559. g = s = scale = 0.0;
  2560. if (i < m){
  2561. for (k = i; k < m; ++ k){
  2562. scale += Math.abs( a[k][i] );
  2563. }
  2564. if (0.0 !== scale){
  2565. for (k = i; k < m; ++ k){
  2566. a[k][i] /= scale;
  2567. s += a[k][i] * a[k][i];
  2568. }
  2569. f = a[i][i];
  2570. g = -SVD.sign( Math.sqrt(s), f );
  2571. h = f * g - s;
  2572. a[i][i] = f - g;
  2573. for (j = l; j < n; ++ j){
  2574. for (s = 0.0, k = i; k < m; ++ k){
  2575. s += a[k][i] * a[k][j];
  2576. }
  2577. f = s / h;
  2578. for (k = i; k < m; ++ k){
  2579. a[k][j] += f * a[k][i];
  2580. }
  2581. }
  2582. for (k = i; k < m; ++ k){
  2583. a[k][i] *= scale;
  2584. }
  2585. }
  2586. }
  2587. w[i] = scale * g;
  2588. g = s = scale = 0.0;
  2589. if ( (i < m) && (i !== n - 1) ){
  2590. for (k = l; k < n; ++ k){
  2591. scale += Math.abs( a[i][k] );
  2592. }
  2593. if (0.0 !== scale){
  2594. for (k = l; k < n; ++ k){
  2595. a[i][k] /= scale;
  2596. s += a[i][k] * a[i][k];
  2597. }
  2598. f = a[i][l];
  2599. g = -SVD.sign( Math.sqrt(s), f );
  2600. h = f * g - s;
  2601. a[i][l] = f - g;
  2602. for (k = l; k < n; ++ k){
  2603. rv1[k] = a[i][k] / h;
  2604. }
  2605. for (j = l; j < m; ++ j){
  2606. for (s = 0.0, k = l; k < n; ++ k){
  2607. s += a[j][k] * a[i][k];
  2608. }
  2609. for (k = l; k < n; ++ k){
  2610. a[j][k] += s * rv1[k];
  2611. }
  2612. }
  2613. for (k = l; k < n; ++ k){
  2614. a[i][k] *= scale;
  2615. }
  2616. }
  2617. }
  2618. anorm = Math.max(anorm, ( Math.abs( w[i] ) + Math.abs( rv1[i] ) ) );
  2619. }
  2620. //Acumulation of right-hand transformation
  2621. for (i = n - 1; i >= 0; -- i){
  2622. if (i < n - 1){
  2623. if (0.0 !== g){
  2624. for (j = l; j < n; ++ j){
  2625. v[j][i] = ( a[i][j] / a[i][l] ) / g;
  2626. }
  2627. for (j = l; j < n; ++ j){
  2628. for (s = 0.0, k = l; k < n; ++ k){
  2629. s += a[i][k] * v[k][j];
  2630. }
  2631. for (k = l; k < n; ++ k){
  2632. v[k][j] += s * v[k][i];
  2633. }
  2634. }
  2635. }
  2636. for (j = l; j < n; ++ j){
  2637. v[i][j] = v[j][i] = 0.0;
  2638. }
  2639. }
  2640. v[i][i] = 1.0;
  2641. g = rv1[i];
  2642. l = i;
  2643. }
  2644. //Acumulation of left-hand transformation
  2645. for (i = Math.min(n, m) - 1; i >= 0; -- i){
  2646. l = i + 1;
  2647. g = w[i];
  2648. for (j = l; j < n; ++ j){
  2649. a[i][j] = 0.0;
  2650. }
  2651. if (0.0 !== g){
  2652. g = 1.0 / g;
  2653. for (j = l; j < n; ++ j){
  2654. for (s = 0.0, k = l; k < m; ++ k){
  2655. s += a[k][i] * a[k][j];
  2656. }
  2657. f = (s / a[i][i]) * g;
  2658. for (k = i; k < m; ++ k){
  2659. a[k][j] += f * a[k][i];
  2660. }
  2661. }
  2662. for (j = i; j < m; ++ j){
  2663. a[j][i] *= g;
  2664. }
  2665. }else{
  2666. for (j = i; j < m; ++ j){
  2667. a[j][i] = 0.0;
  2668. }
  2669. }
  2670. ++ a[i][i];
  2671. }
  2672. //Diagonalization of the bidiagonal form
  2673. for (k = n - 1; k >= 0; -- k){
  2674. for (its = 1; its <= 30; ++ its){
  2675. flag = true;
  2676. for (l = k; l >= 0; -- l){
  2677. nm = l - 1;
  2678. if ( Math.abs( rv1[l] ) + anorm === anorm ){
  2679. flag = false;
  2680. break;
  2681. }
  2682. if ( Math.abs( w[nm] ) + anorm === anorm ){
  2683. break;
  2684. }
  2685. }
  2686. if (flag){
  2687. c = 0.0;
  2688. s = 1.0;
  2689. for (i = l; i <= k; ++ i){
  2690. f = s * rv1[i];
  2691. if ( Math.abs(f) + anorm === anorm ){
  2692. break;
  2693. }
  2694. g = w[i];
  2695. h = SVD.pythag(f, g);
  2696. w[i] = h;
  2697. h = 1.0 / h;
  2698. c = g * h;
  2699. s = -f * h;
  2700. for (j = 1; j <= m; ++ j){
  2701. y = a[j][nm];
  2702. z = a[j][i];
  2703. a[j][nm] = y * c + z * s;
  2704. a[j][i] = z * c - y * s;
  2705. }
  2706. }
  2707. }
  2708. //Convergence
  2709. z = w[k];
  2710. if (l === k){
  2711. if (z < 0.0){
  2712. w[k] = -z;
  2713. for (j = 0; j < n; ++ j){
  2714. v[j][k] = -v[j][k];
  2715. }
  2716. }
  2717. break;
  2718. }
  2719. if (30 === its){
  2720. return false;
  2721. }
  2722. //Shift from bottom 2-by-2 minor
  2723. x = w[l];
  2724. nm = k - 1;
  2725. y = w[nm];
  2726. g = rv1[nm];
  2727. h = rv1[k];
  2728. f = ( (y - z) * (y + z) + (g - h) * (g + h) ) / (2.0 * h * y);
  2729. g = SVD.pythag( f, 1.0 );
  2730. f = ( (x - z) * (x + z) + h * ( (y / (f + SVD.sign(g, f) ) ) - h) ) / x;
  2731. //Next QR transformation
  2732. c = s = 1.0;
  2733. for (j = l; j <= nm; ++ j){
  2734. i = j + 1;
  2735. g = rv1[i];
  2736. y = w[i];
  2737. h = s * g;
  2738. g = c * g;
  2739. z = SVD.pythag(f, h);
  2740. rv1[j] = z;
  2741. c = f / z;
  2742. s = h / z;
  2743. f = x * c + g * s;
  2744. g = g * c - x * s;
  2745. h = y * s;
  2746. y *= c;
  2747. for (jj = 0; jj < n; ++ jj){
  2748. x = v[jj][j];
  2749. z = v[jj][i];
  2750. v[jj][j] = x * c + z * s;
  2751. v[jj][i] = z * c - x * s;
  2752. }
  2753. z = SVD.pythag(f, h);
  2754. w[j] = z;
  2755. if (0.0 !== z){
  2756. z = 1.0 / z;
  2757. c = f * z;
  2758. s = h * z;
  2759. }
  2760. f = c * g + s * y;
  2761. x = c * y - s * g;
  2762. for (jj = 0; jj < m; ++ jj){
  2763. y = a[jj][j];
  2764. z = a[jj][i];
  2765. a[jj][j] = y * c + z * s;
  2766. a[jj][i] = z * c - y * s;
  2767. }
  2768. }
  2769. rv1[l] = 0.0;
  2770. rv1[k] = f;
  2771. w[k] = x;
  2772. }
  2773. }
  2774. return true;
  2775. };
  2776. SVD.pythag = function(a, b){
  2777. var at = Math.abs(a), bt = Math.abs(b), ct;
  2778. if (at > bt){
  2779. ct = bt / at;
  2780. return at * Math.sqrt(1.0 + ct * ct);
  2781. }
  2782. if (0.0 === bt){
  2783. return 0.0;
  2784. }
  2785. ct = at / bt;
  2786. return bt * Math.sqrt(1.0 + ct * ct);
  2787. };
  2788. SVD.sign = function(a, b){
  2789. return b >= 0.0? Math.abs(a): -Math.abs(a);
  2790. };
  2791. var THREEx = THREEx || {}
  2792. THREEx.ArucoContext = function(parameters){
  2793. // handle default parameters
  2794. parameters = parameters || {}
  2795. this.parameters = {
  2796. // debug - true if one should display artoolkit debug canvas, false otherwise
  2797. debug: parameters.debug !== undefined ? parameters.debug : false,
  2798. // resolution of at which we detect pose in the source image
  2799. canvasWidth: parameters.canvasWidth !== undefined ? parameters.canvasWidth : 640,
  2800. canvasHeight: parameters.canvasHeight !== undefined ? parameters.canvasHeight : 480,
  2801. }
  2802. this.canvas = document.createElement('canvas');
  2803. this.detector = new AR.Detector()
  2804. // setup THREEx.ArucoDebug if needed
  2805. this.debug = null
  2806. if( parameters.debug == true ){
  2807. this.debug = new THREEx.ArucoDebug(this)
  2808. }
  2809. // honor parameters.canvasWidth/.canvasHeight
  2810. this.setSize(this.parameters.canvasWidth, this.parameters.canvasHeight)
  2811. }
  2812. THREEx.ArucoContext.prototype.setSize = function (width, height) {
  2813. this.canvas.width = width
  2814. this.canvas.height = height
  2815. if( this.debug !== null ){
  2816. this.debug.setSize(width, height)
  2817. }
  2818. }
  2819. THREEx.ArucoContext.prototype.detect = function (videoElement) {
  2820. var _this = this
  2821. var canvas = this.canvas
  2822. // get imageData from videoElement
  2823. var context = canvas.getContext('2d');
  2824. context.drawImage(videoElement, 0, 0, canvas.width, canvas.height);
  2825. var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
  2826. // detect markers in imageData
  2827. var detectedMarkers = this.detector.detect(imageData);
  2828. return detectedMarkers
  2829. };
  2830. /**
  2831. * crappy function to update a object3d with a detectedMarker - super crappy
  2832. */
  2833. THREEx.ArucoContext.prototype.updateObject3D = function(object3D, arucoPosit, markerSize, detectedMarker){
  2834. var markerCorners = detectedMarker.corners;
  2835. var canvas = this.canvas
  2836. // convert the corners
  2837. var poseCorners = new Array(markerCorners.length)
  2838. for (var i = 0; i < markerCorners.length; ++ i){
  2839. var markerCorner = markerCorners[i];
  2840. poseCorners[i] = {
  2841. x: markerCorner.x - (canvas.width / 2),
  2842. y: -markerCorner.y + (canvas.height/ 2)
  2843. }
  2844. }
  2845. // estimate pose from corners
  2846. var pose = arucoPosit.pose(poseCorners);
  2847. var rotation = pose.bestRotation
  2848. var translation = pose.bestTranslation
  2849. object3D.position.x = translation[0];
  2850. object3D.position.y = translation[1];
  2851. object3D.position.z = -translation[2];
  2852. object3D.rotation.x = -Math.asin(-rotation[1][2]);
  2853. object3D.rotation.y = -Math.atan2(rotation[0][2], rotation[2][2]);
  2854. object3D.rotation.z = Math.atan2(rotation[1][0], rotation[1][1]);
  2855. object3D.scale.x = markerSize;
  2856. object3D.scale.y = markerSize;
  2857. object3D.scale.z = markerSize;
  2858. }
  2859. var THREEx = THREEx || {};
  2860. //////////////////////////////////////////////////////////////////////////////
  2861. // monkey patch AR.Detector
  2862. //////////////////////////////////////////////////////////////////////////////
  2863. AR.Detector.prototype.detect = function(image){
  2864. var opts = this.datGUIOptions
  2865. CV.grayscale(image, this.grey);
  2866. CV.adaptiveThreshold(this.grey, this.thres, opts.adaptativeThreshold.kernelSize, opts.adaptativeThreshold.threshold);
  2867. this.contours = CV.findContours(this.thres, this.binary);
  2868. this.candidates = this.findCandidates(this.contours, image.width * opts.candidates.minSize, opts.candidates.epsilon, opts.candidates.minLength);
  2869. this.candidates = this.clockwiseCorners(this.candidates);
  2870. this.candidates = this.notTooNear(this.candidates, opts.notTooNear.minDist);
  2871. return this.findMarkers(this.grey, this.candidates, opts.findMarkers.warpSize);
  2872. };
  2873. // make names explicits - make unit explicit too
  2874. AR.Detector.prototype.datGUIOptions = {
  2875. adaptativeThreshold : {
  2876. kernelSize: 2,
  2877. threshold: 7,
  2878. },
  2879. candidates: {
  2880. minSize: 0.20,
  2881. epsilon: 0.05,
  2882. minLength: 10,
  2883. },
  2884. notTooNear : {
  2885. minDist: 10,
  2886. },
  2887. findMarkers : {
  2888. warpSize: 49,
  2889. }
  2890. }
  2891. // see https://github.com/jeromeetienne/threex.geometricglow/blob/master/threex.atmospherematerialdatgui.js
  2892. THREEx.addArucoDatGui = function(arucoContext, datGui){
  2893. var datGUIOptions = arucoContext.detector.datGUIOptions
  2894. var options = {
  2895. resolution: '640x480',
  2896. }
  2897. var onChange = function(){
  2898. // honor option resolution
  2899. var matches = options.resolution.match(/(\d+)x(\d+)/)
  2900. var width = parseInt(matches[1])
  2901. var height = parseInt(matches[2])
  2902. arucoContext.setSize(width, height)
  2903. }
  2904. onChange();
  2905. datGui.add( options, 'resolution', [ '320x240', '640x480' ]).onChange( onChange )
  2906. var folder = datGui.addFolder('Adaptative Threshold')
  2907. folder.open()
  2908. folder.add( arucoContext.detector.datGUIOptions.adaptativeThreshold, 'kernelSize').min(0).step(1)
  2909. .onChange( onChange )
  2910. folder.add( arucoContext.detector.datGUIOptions.adaptativeThreshold, 'threshold').min(0).step(1)
  2911. .onChange( onChange )
  2912. var folder = datGui.addFolder('Candidates')
  2913. folder.open()
  2914. folder.add( arucoContext.detector.datGUIOptions.candidates, 'minSize').min(0).max(1)
  2915. .onChange( onChange )
  2916. folder.add( arucoContext.detector.datGUIOptions.candidates, 'epsilon').min(0)
  2917. .onChange( onChange )
  2918. folder.add( arucoContext.detector.datGUIOptions.candidates, 'minLength').min(0).step(1)
  2919. .onChange( onChange )
  2920. var folder = datGui.addFolder('notTooNear')
  2921. folder.open()
  2922. folder.add( arucoContext.detector.datGUIOptions.notTooNear, 'minDist').min(0).step(1)
  2923. .onChange( onChange )
  2924. var folder = datGui.addFolder('findMarkers')
  2925. folder.open()
  2926. folder.add( arucoContext.detector.datGUIOptions.findMarkers, 'warpSize').min(0).step(1)
  2927. .onChange( onChange )
  2928. }
  2929. var THREEx = THREEx || {}
  2930. THREEx.ArucoDebug = function(arucoContext){
  2931. this.arucoContext = arucoContext
  2932. // TODO to rename canvasElement into canvas
  2933. this.canvasElement = document.createElement('canvas');
  2934. this.canvasElement.width = this.arucoContext.canvas.width
  2935. this.canvasElement.height = this.arucoContext.canvas.height
  2936. }
  2937. THREEx.ArucoDebug.prototype.setSize = function (width, height) {
  2938. if( this.canvasElement.width !== width ) this.canvasElement.width = width
  2939. if( this.canvasElement.height !== height ) this.canvasElement.height = height
  2940. }
  2941. THREEx.ArucoDebug.prototype.clear = function(){
  2942. var canvas = this.canvasElement
  2943. var context = canvas.getContext('2d');
  2944. context.clearRect(0,0,canvas.width, canvas.height)
  2945. }
  2946. THREEx.ArucoDebug.prototype.drawContoursContours = function(){
  2947. var contours = this.arucoContext.detector.contours
  2948. var canvas = this.canvasElement
  2949. this.drawContours(contours, 0, 0, canvas.width, canvas.height, function(hole){
  2950. return hole? "magenta": "blue"
  2951. })
  2952. }
  2953. THREEx.ArucoDebug.prototype.drawContoursPolys = function(){
  2954. var contours = this.arucoContext.detector.polys
  2955. var canvas = this.canvasElement
  2956. this.drawContours(contours, 0, 0, canvas.width, canvas.height, function(){
  2957. return 'green'
  2958. })
  2959. }
  2960. THREEx.ArucoDebug.prototype.drawContoursCandidates = function(){
  2961. var contours = this.arucoContext.detector.candidates
  2962. var canvas = this.canvasElement
  2963. this.drawContours(contours, 0, 0, canvas.width, canvas.height, function(){
  2964. return 'red'
  2965. })
  2966. }
  2967. THREEx.ArucoDebug.prototype.drawContours = function(contours, x, y, width, height, fn){
  2968. var i = contours.length, j, contour, point;
  2969. var canvas = this.canvasElement
  2970. var context = canvas.getContext('2d');
  2971. context.save();
  2972. while(i --){
  2973. contour = contours[i];
  2974. context.strokeStyle = fn(contour.hole);
  2975. context.beginPath();
  2976. for (j = 0; j < contour.length; ++ j){
  2977. point = contour[j];
  2978. context.moveTo(x + point.x, y + point.y);
  2979. point = contour[(j + 1) % contour.length];
  2980. context.lineTo(x + point.x, y + point.y);
  2981. }
  2982. context.stroke();
  2983. context.closePath();
  2984. }
  2985. context.restore();
  2986. }
  2987. //////////////////////////////////////////////////////////////////////////////
  2988. // Code Separator
  2989. //////////////////////////////////////////////////////////////////////////////
  2990. THREEx.ArucoDebug.prototype.drawDetectorGrey = function(){
  2991. var cvImage = arucoContext.detector.grey
  2992. this.drawCVImage( cvImage )
  2993. }
  2994. THREEx.ArucoDebug.prototype.drawDetectorThreshold = function(){
  2995. var cvImage = arucoContext.detector.thres
  2996. this.drawCVImage( cvImage )
  2997. }
  2998. //////////////////////////////////////////////////////////////////////////////
  2999. // Code Separator
  3000. //////////////////////////////////////////////////////////////////////////////
  3001. THREEx.ArucoDebug.prototype.drawCVImage = function(cvImage){
  3002. var detector = this.arucoContext.detector
  3003. var canvas = this.canvasElement
  3004. var context = canvas.getContext('2d');
  3005. var imageData = context.createImageData(canvas.width, canvas.height);
  3006. this.copyCVImage2ImageData(cvImage, imageData)
  3007. context.putImageData( imageData, 0, 0);
  3008. }
  3009. THREEx.ArucoDebug.prototype.copyCVImage2ImageData = function(cvImage, imageData){
  3010. var i = cvImage.data.length, j = (i * 4) + 3;
  3011. while(i --){
  3012. imageData.data[j -= 4] = 255;
  3013. imageData.data[j - 1] = imageData.data[j - 2] = imageData.data[j - 3] = cvImage.data[i];
  3014. }
  3015. return imageData;
  3016. };
  3017. //////////////////////////////////////////////////////////////////////////////
  3018. // Code Separator
  3019. //////////////////////////////////////////////////////////////////////////////
  3020. THREEx.ArucoDebug.prototype.drawVideo = function(videoElement){
  3021. var canvas = this.canvasElement
  3022. var context = canvas.getContext('2d');
  3023. context.drawImage(videoElement, 0, 0, canvas.width, canvas.height);
  3024. }
  3025. //////////////////////////////////////////////////////////////////////////////
  3026. // Code Separator
  3027. //////////////////////////////////////////////////////////////////////////////
  3028. THREEx.ArucoDebug.prototype.drawMarkerIDs = function(markers){
  3029. var canvas = this.canvasElement
  3030. var context = canvas.getContext('2d');
  3031. var corners, corner, x, y, i, j;
  3032. context.save();
  3033. context.strokeStyle = "blue";
  3034. context.lineWidth = 1;
  3035. for (i = 0; i !== markers.length; ++ i){
  3036. corners = markers[i].corners;
  3037. x = Infinity;
  3038. y = Infinity;
  3039. for (j = 0; j !== corners.length; ++ j){
  3040. corner = corners[j];
  3041. x = Math.min(x, corner.x);
  3042. y = Math.min(y, corner.y);
  3043. }
  3044. context.strokeText(markers[i].id, x, y)
  3045. }
  3046. context.restore();
  3047. }
  3048. //////////////////////////////////////////////////////////////////////////////
  3049. // Code Separator
  3050. //////////////////////////////////////////////////////////////////////////////
  3051. THREEx.ArucoDebug.prototype.drawMarkerCorners = function(markers){
  3052. var canvas = this.canvasElement
  3053. var corners, corner, i, j;
  3054. var context = canvas.getContext('2d');
  3055. context.save();
  3056. context.lineWidth = 3;
  3057. for (i = 0; i < markers.length; ++ i){
  3058. corners = markers[i].corners;
  3059. context.strokeStyle = 'red';
  3060. context.beginPath();
  3061. for (j = 0; j < corners.length; ++ j){
  3062. corner = corners[j];
  3063. context.moveTo(corner.x, corner.y);
  3064. corner = corners[(j + 1) % corners.length];
  3065. context.lineTo(corner.x, corner.y);
  3066. }
  3067. context.stroke();
  3068. context.closePath();
  3069. context.strokeStyle = 'green';
  3070. context.strokeRect(corners[0].x - 2, corners[0].y - 2, 4, 4);
  3071. }
  3072. context.restore();
  3073. }
  3074. var THREEx = THREEx || {}
  3075. THREEx.ArucoMarkerGenerator = function(){
  3076. }
  3077. //////////////////////////////////////////////////////////////////////////////
  3078. // Code Separator
  3079. //////////////////////////////////////////////////////////////////////////////
  3080. THREEx.ArucoMarkerGenerator.createSVG = function(markerId, svgSize){
  3081. var domElement = document.createElement('div');
  3082. domElement.innerHTML = new ArucoMarker(markerId).toSVG(svgSize);
  3083. return domElement
  3084. }
  3085. THREEx.ArucoMarkerGenerator.createImage = function(markerId, width){
  3086. // create canvas
  3087. var canvas = this.createCanvas(markerId, width)
  3088. var imageURL = canvas.toDataURL()
  3089. // create imageElement
  3090. var imageElement = document.createElement('img');
  3091. imageElement.src = imageURL
  3092. // return imageElement
  3093. return imageElement;
  3094. }
  3095. //////////////////////////////////////////////////////////////////////////////
  3096. // Code Separator
  3097. //////////////////////////////////////////////////////////////////////////////
  3098. THREEx.ArucoMarkerGenerator.createCanvas = function(markerId, width){
  3099. var canvas = document.createElement('canvas');
  3100. var context = canvas.getContext('2d')
  3101. canvas.width = width
  3102. canvas.height = width
  3103. var arucoMarker = new ArucoMarker(markerId)
  3104. var marker = arucoMarker.markerMatrix()
  3105. var margin = canvas.width*0.1
  3106. var innerW = width-margin*2
  3107. var squareW = innerW/7
  3108. context.fillStyle = 'white'
  3109. context.fillRect(0, 0, canvas.width, canvas.height)
  3110. context.fillStyle = 'black'
  3111. context.fillRect(margin, margin, canvas.width-margin*2, canvas.height-margin*2)
  3112. for(var y = 0; y < 5; y++){
  3113. for(var x = 0; x < 5; x++){
  3114. if (marker[x][y] !== 1) continue
  3115. context.fillStyle = 'white'
  3116. context.fillRect(margin+(x+1)*squareW, margin+(y+1)*squareW, squareW+1, squareW+1)
  3117. }
  3118. }
  3119. return canvas
  3120. }
  3121. /*
  3122. * Copyright 2017 Google Inc. All Rights Reserved.
  3123. * Licensed under the Apache License, Version 2.0 (the "License");
  3124. * you may not use this file except in compliance with the License.
  3125. * You may obtain a copy of the License at
  3126. *
  3127. * http://www.apache.org/licenses/LICENSE-2.0
  3128. *
  3129. * Unless required by applicable law or agreed to in writing, software
  3130. * distributed under the License is distributed on an "AS IS" BASIS,
  3131. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3132. * See the License for the specific language governing permissions and
  3133. * limitations under the License.
  3134. */
  3135. /**
  3136. * @namespace
  3137. */
  3138. var THREE = THREE || require("three");
  3139. /**
  3140. * The WebAR namespace inside the THREE namespace. This namespace includes different utilities to be able to handle WebAR functionalities on top of the ThreeJS framework/engine in an easier way.
  3141. *
  3142. * NOTE: As a coding standard all the variables/functions starting with an underscore '_' are considered as private and should not be used/called outside of the namespace/class they are defined in.
  3143. * @namespace
  3144. */
  3145. THREE.WebAR = {};
  3146. THREE.WebAR.MAX_FLOAT32_VALUE = 3.4028e38;
  3147. /**
  3148. * A class that allows to manage the point cloud acquisition and representation in ThreeJS. A buffer geometry is generated to represent the point cloud. The point cloud is provided using a VRDisplay instance that shows the capability to do so. The point cloud is actually exposed using a TypedArray. The array includes 3 values per point in the cloud. There are 2 ways of exposing this array:
  3149. * 1.- Using a new TypedArray for every frame/update. The advantage is that the TypedArray is always of the correct size depending on the number of points detected. The disadvantage is that there is a performance hit from the creation and copying of the array (and future garbage collection).
  3150. * 2.- Using the same reference to a single TypedArray. The advantage is that the performance is as good as it can get with no creation/destruction and copy penalties. The disadvantage is that the size of the array is the biggest possible point cloud provided by the underlying hardware. The non used values are filled with THREE.WebAR.MAX_FLOAT32_VALUE.
  3151. * @constructor
  3152. * @param {window.VRDisplay} vrDisplay The reference to the VRDisplay instance that is capable of providing the point cloud.
  3153. *
  3154. * NOTE: The buffer geometry that can be retrieved from instances of this class can be used along with THREE.Point and THREE.PointMaterial to render the point cloud using points. This class represents the vertices colors with the color white.
  3155. */
  3156. THREE.WebAR.VRPointCloud = function(vrDisplay) {
  3157. this._vrDisplay = vrDisplay;
  3158. this._numberOfPointsInLastPointCloud = 0;
  3159. this._bufferGeometry = new THREE.BufferGeometry();
  3160. this._bufferGeometry.frustumCulled = false;
  3161. var positions = null;
  3162. if (vrDisplay) {
  3163. this._pointCloud = new VRPointCloud();
  3164. vrDisplay.getPointCloud(this._pointCloud, false, 0, false);
  3165. positions = this._pointCloud.points;
  3166. }
  3167. else {
  3168. positions = new Float32Array(
  3169. [-1, 1, -2, 1, 1, -2, 1, -1, -2, -1, -1, -2 ]);
  3170. }
  3171. var colors = new Float32Array( positions.length );
  3172. var color = new THREE.Color();
  3173. for ( var i = 0; i < colors.length; i += 3 ) {
  3174. if (vrDisplay) {
  3175. positions[ i ] = THREE.WebAR.MAX_FLOAT32_VALUE;
  3176. positions[ i + 1 ] = THREE.WebAR.MAX_FLOAT32_VALUE;
  3177. positions[ i + 2 ] = THREE.WebAR.MAX_FLOAT32_VALUE;
  3178. }
  3179. color.setRGB( 1, 1, 1 );
  3180. colors[ i ] = color.r;
  3181. colors[ i + 1 ] = color.g;
  3182. colors[ i + 2 ] = color.b;
  3183. }
  3184. this._positions = new THREE.BufferAttribute( positions, 3 );
  3185. this._bufferGeometry.addAttribute( 'position', this._positions );
  3186. this._colors = new THREE.BufferAttribute( colors, 3 );
  3187. this._bufferGeometry.addAttribute( 'color', this._colors );
  3188. this._bufferGeometry.computeBoundingSphere();
  3189. return this;
  3190. };
  3191. /**
  3192. * Returns the THREE.BufferGeometry instance that represents the points in the pont cloud.
  3193. * @return {THREE.BufferGeometry} The buffer geometry that represents the points in the point cloud.
  3194. *
  3195. * NOTE: A possible way to render the point cloud could be to use the THREE.BufferGeometry instance returned by this method along with THREE.Points and THREE.PointMaterial.
  3196. var pointCloud = new THREE.VRPointCloud(vrDisplay, true);
  3197. var material = new THREE.PointsMaterial( { size: 0.01, vertexColors: THREE.VertexColors } );
  3198. var points = new THREE.Points( pointCloud.getBufferGeometry(), material );
  3199. */
  3200. THREE.WebAR.VRPointCloud.prototype.getBufferGeometry = function() {
  3201. return this._bufferGeometry;
  3202. };
  3203. /**
  3204. * Update the point cloud. The THREE.BufferGeometry that this class provides will automatically be updated with the point cloud retrieved by the underlying hardware.
  3205. * @param {boolean} updateBufferGeometry A flag to indicate if the underlying THREE.BufferGeometry should also be updated. Updating the THREE.BufferGeometry is very cost innefficient so it is better to only do it if necessary (only if the buffer geometry is going to be rendered for example). If this flag is set to false, then the underlying point cloud is updated but not buffer geometry that represents it. Updating the point cloud is important to be able to call functions that operate with it, like the getPickingPointAndPlaneInPointCloud function.
  3206. * @param {number} pointsToSkip A positive integer from 0-N that specifies the number of points to skip when returning the point cloud. If the updateBufferGeometry flag is activated (true) then this parameter allows to specify the density of the point cloud. A values of 0 means all the detected points need to be returned. A number of 1 means that 1 every other point needs to be skipped and thus, half of the detected points will be retrieved, and so on. If the parameter is not specified, 0 is considered.
  3207. * @param {boolean} transformPoints A flag to specify if the points should be transformed in the native side or not. If the points are not transformed in the native side, they should be transformed in the JS side (in a vertex shader for example).
  3208. */
  3209. THREE.WebAR.VRPointCloud.prototype.update = function(updateBufferGeometry, pointsToSkip, transformPoints) {
  3210. if (!this._vrDisplay) return;
  3211. this._vrDisplay.getPointCloud(this._pointCloud,
  3212. !updateBufferGeometry, typeof(pointsToSkip) === "number" ?
  3213. pointsToSkip : 0, !!transformPoints);
  3214. if (!updateBufferGeometry) return;
  3215. if (this._pointCloud.numberOfPoints > 0) {
  3216. this._positions.needsUpdate = true;
  3217. }
  3218. };
  3219. /**
  3220. * Provides an index based on an orientation angle. The corresponding index to the angle is:
  3221. * orientation = 0 <-> index = 0
  3222. * orientation = 90 <-> index = 1
  3223. * orientation = 180 <-> index = 2
  3224. * orientation = 270 <-> index = 3
  3225. * @param {number} orientation The orientation angle. Values are: 0, 90, 180, 270.
  3226. * @return {number} An index from 0 to 3 that corresponds to the give orientation angle.
  3227. */
  3228. THREE.WebAR.getIndexFromOrientation = function(orientation) {
  3229. var index = 0;
  3230. switch (orientation) {
  3231. case 90:
  3232. index = 1;
  3233. break;
  3234. case 180:
  3235. index = 2;
  3236. break;
  3237. case 270:
  3238. index = 3;
  3239. break;
  3240. default:
  3241. index = 0;
  3242. break;
  3243. }
  3244. return index;
  3245. };
  3246. /**
  3247. * Returns an index that is based on the combination between the display orientation and the see through camera orientation. This index will always be device natural orientation independent.
  3248. * @param {VRDisplay} vrDisplay The VRDisplay that is capable to provide a correct VRSeeThroughCamera instance.
  3249. * @return {number} The index from 0 to 3 that represents the combination of the device and see through camera orientations.
  3250. */
  3251. THREE.WebAR.getIndexFromScreenAndSeeThroughCameraOrientations = function(vrDisplay) {
  3252. var screenOrientation = screen.orientation.angle;
  3253. var seeThroughCamera = vrDisplay ? vrDisplay.getSeeThroughCamera() : null;
  3254. var seeThroughCameraOrientation = seeThroughCamera ?
  3255. seeThroughCamera.orientation : 0;
  3256. var seeThroughCameraOrientationIndex =
  3257. THREE.WebAR.getIndexFromOrientation(seeThroughCameraOrientation);
  3258. var screenOrientationIndex =
  3259. THREE.WebAR.getIndexFromOrientation(screenOrientation);
  3260. ret = screenOrientationIndex - seeThroughCameraOrientationIndex;
  3261. if (ret < 0) {
  3262. ret += 4;
  3263. }
  3264. return (ret % 4);
  3265. }
  3266. /**
  3267. * A utility function that helps create a THREE.Mesh instance to be able to show the VRSeeThroughCamera as a background quad with the correct texture coordinates and a THREE.VideoTexture instance.
  3268. * @param {VRDisplay} vrDisplay The VRDisplay that is capable to provide a correct VRSeeThroughCamera instance. It can be null/undefined.
  3269. * @param {string} fallbackVideoPath The path to a video in case there is no vrDisplay. If this parameter is not provided, a default video at path "../resources/sintel.webm" will be used.
  3270. * @return {THREE.Mesh} The THREE.Mesh instance that represents a quad to be able to present the see through camera.
  3271. */
  3272. THREE.WebAR.createVRSeeThroughCameraMesh = function(vrDisplay,
  3273. fallbackVideoPath) {
  3274. var video;
  3275. var geometry = new THREE.BufferGeometry();
  3276. // The camera or video and the texture coordinates may vary depending if the vrDisplay has the see through camera.
  3277. if (vrDisplay) {
  3278. var seeThroughCamera = vrDisplay.getSeeThroughCamera();
  3279. if (!seeThroughCamera)
  3280. throw "ERROR: Could not get the see through camera!";
  3281. video = seeThroughCamera;
  3282. // HACK: Needed to tell the THREE.VideoTexture that the video is ready and
  3283. // that the texture needs update.
  3284. video.readyState = 2;
  3285. video.HAVE_CURRENT_DATA = 2;
  3286. // All the possible texture coordinates for the 4 possible orientations.
  3287. // The ratio between the texture size and the camera size is used in order
  3288. // to be compatible with the YUV to RGB conversion option (not recommended
  3289. // but still available).
  3290. var u = seeThroughCamera.width / seeThroughCamera.textureWidth;
  3291. var v = seeThroughCamera.height / seeThroughCamera.textureHeight;
  3292. geometry.WebAR_textureCoords = [
  3293. new Float32Array([
  3294. 0.0, 0.0,
  3295. 0.0, v,
  3296. u, 0.0,
  3297. u, v
  3298. ]),
  3299. new Float32Array([
  3300. u, 0.0,
  3301. 0.0, 0.0,
  3302. u, v,
  3303. 0.0, v
  3304. ]),
  3305. new Float32Array([
  3306. u, v,
  3307. u, 0.0,
  3308. 0.0, v,
  3309. 0.0, 0.0
  3310. ]),
  3311. new Float32Array([
  3312. 0.0, v,
  3313. u, v,
  3314. 0.0, 0.0,
  3315. u, 0.0
  3316. ])
  3317. ];
  3318. }
  3319. else {
  3320. var video = document.createElement("video");
  3321. video.src = typeof(fallbackVideoPath) === "string" ?
  3322. fallbackVideoPath : "../../resources/videos/sintel.webm";
  3323. video.play();
  3324. // All the possible texture coordinates for the 4 possible orientations.
  3325. geometry.WebAR_textureCoords = [
  3326. new Float32Array([0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0]),
  3327. new Float32Array([1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0]),
  3328. new Float32Array([1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]),
  3329. new Float32Array([0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0])
  3330. ];
  3331. }
  3332. geometry.addAttribute("position", new THREE.BufferAttribute(
  3333. new Float32Array([
  3334. -1.0, 1.0, 0.0,
  3335. -1.0, -1.0, 0.0,
  3336. 1.0, 1.0, 0.0,
  3337. 1.0, -1.0, 0.0
  3338. ]), 3));
  3339. geometry.setIndex(new THREE.BufferAttribute(
  3340. new Uint16Array([0, 1, 2, 2, 1, 3]), 1));
  3341. geometry.WebAR_textureCoordIndex =
  3342. THREE.WebAR.getIndexFromScreenAndSeeThroughCameraOrientations(vrDisplay);
  3343. var textureCoords =
  3344. geometry.WebAR_textureCoords[geometry.WebAR_textureCoordIndex];
  3345. geometry.addAttribute("uv", new THREE.BufferAttribute(
  3346. new Float32Array(textureCoords), 2 ));
  3347. geometry.computeBoundingSphere();
  3348. var videoTexture = new THREE.VideoTexture(video);
  3349. videoTexture.minFilter = THREE.NearestFilter;
  3350. videoTexture.magFilter = THREE.NearestFilter;
  3351. videoTexture.format = THREE.RGBFormat;
  3352. videoTexture.flipY = false;
  3353. // The material is different if the see through camera is provided inside the vrDisplay or not.
  3354. var material;
  3355. if (vrDisplay) {
  3356. var vertexShaderSource = [
  3357. 'attribute vec3 position;',
  3358. 'attribute vec2 uv;',
  3359. '',
  3360. 'uniform mat4 modelViewMatrix;',
  3361. 'uniform mat4 projectionMatrix;',
  3362. '',
  3363. 'varying vec2 vUV;',
  3364. '',
  3365. 'void main(void) {',
  3366. ' gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);',
  3367. ' vUV = uv;',
  3368. '}'
  3369. ];
  3370. var fragmentShaderSource = [
  3371. '#extension GL_OES_EGL_image_external : require',
  3372. 'precision mediump float;',
  3373. '',
  3374. 'varying vec2 vUV;',
  3375. '',
  3376. 'uniform samplerExternalOES map;',
  3377. '',
  3378. 'void main(void) {',
  3379. ' gl_FragColor = texture2D(map, vUV);',
  3380. '}'
  3381. ];
  3382. material = new THREE.RawShaderMaterial({
  3383. uniforms: {
  3384. map: {type: 't', value: videoTexture},
  3385. },
  3386. vertexShader: vertexShaderSource.join( '\r\n' ),
  3387. fragmentShader: fragmentShaderSource.join( '\r\n' ),
  3388. side: THREE.DoubleSide,
  3389. });
  3390. }
  3391. else {
  3392. material = new THREE.MeshBasicMaterial(
  3393. {color: 0xFFFFFF, side: THREE.DoubleSide, map: videoTexture } );
  3394. }
  3395. var mesh = new THREE.Mesh(geometry, material);
  3396. return mesh;
  3397. };
  3398. /**
  3399. * Updates the camera mesh texture coordinates depending on the orientation of the current screen and the see through camera.
  3400. * @param {VRDisplay} vrDisplay The VRDisplay that holds the VRSeeThroughCamera. If could be null/undefined.
  3401. * @param {THREE.Mesh} cameraMesh The ThreeJS mesh that represents the camera quad that needs to be updated/rotated depending on the device and camera orientations. This instance should have been created by calling THREE.WebAR.createVRSeeThroughCameraMesh.
  3402. */
  3403. THREE.WebAR.updateCameraMeshOrientation = function(vrDisplay, cameraMesh) {
  3404. var textureCoordIndex = THREE.WebAR.getIndexFromScreenAndSeeThroughCameraOrientations(vrDisplay);
  3405. if (textureCoordIndex != cameraMesh.geometry.WebAR_textureCoordIndex) {
  3406. var uvs = cameraMesh.geometry.getAttribute("uv");
  3407. var textureCoords =
  3408. cameraMesh.geometry.WebAR_textureCoords[textureCoordIndex];
  3409. cameraMesh.geometry.WebAR_textureCoordIndex = textureCoordIndex;
  3410. for (var i = 0; i < uvs.length; i++) {
  3411. uvs.array[i] = textureCoords[i];
  3412. }
  3413. uvs.needsUpdate = true;
  3414. }
  3415. };
  3416. /**
  3417. * A utility function to create a THREE.Camera instance with as frustum that is obtainer from the underlying vrdisplay see through camera information. This camera can be used to correctly render 3D objects on top of the underlying camera image.
  3418. * @param {VRDisplay} vrDisplay - The VRDisplay that is capable to provide a correct VRSeeThroughCamera instance in order to obtain the camera lens information and create the correct projection matrix/frustum. It could be null/undefined.
  3419. * @param {number} near The near plane value to be used to create the correct projection matrix frustum.
  3420. * @param {number} far The far plane value to be used to create the correct projection matrix frustum.
  3421. * @return {THREE.Camera} A camera instance to be used to correctly render a scene on top of the camera video feed.
  3422. */
  3423. THREE.WebAR.createVRSeeThroughCamera = function(vrDisplay, near, far) {
  3424. var camera = new THREE.PerspectiveCamera( 60,
  3425. window.innerWidth / window.innerHeight, near, far );
  3426. if (vrDisplay) {
  3427. THREE.WebAR.resizeVRSeeThroughCamera(vrDisplay, camera);
  3428. }
  3429. return camera;
  3430. };
  3431. /**
  3432. * Recalculate a camera projection matrix depending on the current device and see through camera orientation and specification.
  3433. * @param {VRDisplay} vrDisplay The VRDisplay that handles the see through camera.
  3434. * @param {THREE.Camera} camera The ThreeJS camera instance to update its projection matrix depending on the current device orientation and see through camera properties.
  3435. */
  3436. THREE.WebAR.resizeVRSeeThroughCamera = function(vrDisplay, camera) {
  3437. camera.aspect = window.innerWidth / window.innerHeight;
  3438. if (vrDisplay) {
  3439. var windowWidthBiggerThanHeight = window.innerWidth > window.innerHeight;
  3440. var seeThroughCamera = vrDisplay.getSeeThroughCamera();
  3441. if (seeThroughCamera) {
  3442. var cameraWidthBiggerThanHeight =
  3443. seeThroughCamera.width > seeThroughCamera.height;
  3444. var swapWidthAndHeight =
  3445. !(windowWidthBiggerThanHeight && cameraWidthBiggerThanHeight);
  3446. var width = swapWidthAndHeight ?
  3447. seeThroughCamera.height : seeThroughCamera.width;
  3448. var height = swapWidthAndHeight ?
  3449. seeThroughCamera.width : seeThroughCamera.height;
  3450. var fx = swapWidthAndHeight ?
  3451. seeThroughCamera.focalLengthY : seeThroughCamera.focalLengthX;
  3452. var fy = swapWidthAndHeight ?
  3453. seeThroughCamera.focalLengthX : seeThroughCamera.focalLengthY;
  3454. var cx = swapWidthAndHeight ?
  3455. seeThroughCamera.pointY : seeThroughCamera.pointX;
  3456. var cy = swapWidthAndHeight ?
  3457. seeThroughCamera.pointX : seeThroughCamera.pointY;
  3458. var xscale = camera.near / fx;
  3459. var yscale = camera.near / fy;
  3460. var xoffset = (cx - (width / 2.0)) * xscale;
  3461. // Color camera's coordinates has Y pointing downwards so we negate this term.
  3462. var yoffset = -(cy - (height / 2.0)) * yscale;
  3463. var left = xscale * -width / 2.0 - xoffset;
  3464. var right = xscale * width / 2.0 - xoffset;
  3465. var bottom = yscale * -height / 2.0 - yoffset;
  3466. var top = yscale * height / 2.0 - yoffset;
  3467. // camera.projectionMatrix.makeFrustum(
  3468. // left, right, bottom, top, camera.near, camera.far);
  3469. camera.projectionMatrix.makePerspective(
  3470. left, right, top, bottom, camera.near, camera.far);
  3471. // Recalculate the fov as threejs is not doing it.
  3472. camera.fov = THREE.Math.radToDeg(
  3473. Math.atan((top * camera.zoom) / camera.near)) * 2.0;
  3474. }
  3475. }
  3476. else {
  3477. camera.updateProjectionMatrix();
  3478. }
  3479. }
  3480. // Some precalculated private objects to avoid garbage collection
  3481. THREE.WebAR._worldUp = new THREE.Vector3(0.0, 1.0, 0.0);
  3482. THREE.WebAR._normalY = new THREE.Vector3();
  3483. THREE.WebAR._normalZ = new THREE.Vector3();
  3484. THREE.WebAR._rotationMatrix = new THREE.Matrix4();
  3485. THREE.WebAR._planeNormal = new THREE.Vector3();
  3486. THREE.WebAR.rotateObject3D = function(normal1, normal2, object3d) {
  3487. if (normal1 instanceof THREE.Vector3 || normal1 instanceof THREE.Vector4) {
  3488. THREE.WebAR._planeNormal.set(normal1.x, normal1.y, normal1.z);
  3489. }
  3490. else if (normal1 instanceof Float32Array) {
  3491. THREE.WebAR._planeNormal.set(normal1[0], normal1[1], normal1[2]);
  3492. }
  3493. else {
  3494. throw "Unknown normal1 type.";
  3495. }
  3496. if (normal2 instanceof THREE.Vector3 || normal2 instanceof THREE.Vector4) {
  3497. THREE.WebAR._normalZ.set(normal2.x, normal2.y, normal2.z);
  3498. }
  3499. else if (normal1 instanceof Float32Array) {
  3500. THREE.WebAR._normalZ.set(normal2[0], normal2[1], normal2[2]);
  3501. }
  3502. else {
  3503. throw "Unknown normal2 type.";
  3504. }
  3505. THREE.WebAR._normalY.crossVectors(THREE.WebAR._planeNormal,
  3506. THREE.WebAR._normalZ).normalize();
  3507. THREE.WebAR._rotationMatrix.elements[ 0] = THREE.WebAR._planeNormal.x;
  3508. THREE.WebAR._rotationMatrix.elements[ 1] = THREE.WebAR._planeNormal.y;
  3509. THREE.WebAR._rotationMatrix.elements[ 2] = THREE.WebAR._planeNormal.z;
  3510. THREE.WebAR._rotationMatrix.elements[ 4] = THREE.WebAR._normalZ.x;
  3511. THREE.WebAR._rotationMatrix.elements[ 5] = THREE.WebAR._normalZ.y;
  3512. THREE.WebAR._rotationMatrix.elements[ 6] = THREE.WebAR._normalZ.z;
  3513. THREE.WebAR._rotationMatrix.elements[ 8] = THREE.WebAR._normalY.x;
  3514. THREE.WebAR._rotationMatrix.elements[ 9] = THREE.WebAR._normalY.y;
  3515. THREE.WebAR._rotationMatrix.elements[10] = THREE.WebAR._normalY.z;
  3516. object3d.quaternion.setFromRotationMatrix(THREE.WebAR._rotationMatrix);
  3517. };
  3518. /**
  3519. * Transform a given THREE.Object3D instance to be correctly oriented according to a given plane normal.
  3520. * @param {THREE.Vector3|THREE.Vector4|Float32Array} plane A vector that represents the normal of the plane to be used to orient the object3d.
  3521. * @param {THREE.Object3D} object3d The object3d to be transformed so it is oriented according to the given plane.
  3522. */
  3523. THREE.WebAR.rotateObject3DWithPickingPlane = function(plane, object3d) {
  3524. if (plane instanceof THREE.Vector3 || plane instanceof THREE.Vector4) {
  3525. THREE.WebAR._planeNormal.set(plane.x, plane.y, plane.z);
  3526. }
  3527. else if (plane instanceof Float32Array) {
  3528. THREE.WebAR._planeNormal.set(plane[0], plane[1], plane[2]);
  3529. }
  3530. else {
  3531. throw "Unknown plane type.";
  3532. }
  3533. THREE.WebAR._normalY.set(0.0, 1.0, 0.0);
  3534. var threshold = 0.5;
  3535. if (Math.abs(THREE.WebAR._planeNormal.dot(THREE.WebAR._worldUp)) >
  3536. threshold) {
  3537. THREE.WebAR._normalY.set(0.0, 0.0, 1.0);
  3538. }
  3539. THREE.WebAR._normalZ.crossVectors(THREE.WebAR._planeNormal,
  3540. THREE.WebAR._normalY).normalize();
  3541. THREE.WebAR._normalY.crossVectors(THREE.WebAR._normalZ,
  3542. THREE.WebAR._planeNormal).normalize();
  3543. THREE.WebAR._rotationMatrix.elements[ 0] = THREE.WebAR._planeNormal.x;
  3544. THREE.WebAR._rotationMatrix.elements[ 1] = THREE.WebAR._planeNormal.y;
  3545. THREE.WebAR._rotationMatrix.elements[ 2] = THREE.WebAR._planeNormal.z;
  3546. THREE.WebAR._rotationMatrix.elements[ 4] = THREE.WebAR._normalY.x;
  3547. THREE.WebAR._rotationMatrix.elements[ 5] = THREE.WebAR._normalY.y;
  3548. THREE.WebAR._rotationMatrix.elements[ 6] = THREE.WebAR._normalY.z;
  3549. THREE.WebAR._rotationMatrix.elements[ 8] = THREE.WebAR._normalZ.x;
  3550. THREE.WebAR._rotationMatrix.elements[ 9] = THREE.WebAR._normalZ.y;
  3551. THREE.WebAR._rotationMatrix.elements[10] = THREE.WebAR._normalZ.z;
  3552. object3d.quaternion.setFromRotationMatrix(THREE.WebAR._rotationMatrix);
  3553. };
  3554. /**
  3555. * Transform a given THREE.Object3D instance to be correctly positioned according to a given point position.
  3556. * @param {THREE.Vector3|THREE.Vector4|Float32Array} point A vector that represents the position where the object3d should be positioned.
  3557. * @param {THREE.Object3D} object3d The object3d to be transformed so it is positioned according to the given point.
  3558. */
  3559. THREE.WebAR.positionObject3DWithPickingPoint = function(point, object3d) {
  3560. if (point instanceof THREE.Vector3 || point instanceof THREE.Vector4) {
  3561. object3d.position.set(point.x, point.y, point.z);
  3562. }
  3563. else if (point instanceof Float32Array) {
  3564. object3d.position.set(point[0], point[1], point[2]);
  3565. }
  3566. else {
  3567. throw "Unknown point type.";
  3568. }
  3569. };
  3570. /**
  3571. * Transform a given THREE.Object3D instance to be correctly positioned and oriented according to a given VRPickingPointAndPlane and a scale (half the size of the object3d for example).
  3572. * @param {VRPickingPointandPlane} pointAndPlane The point and plane retrieved using the VRDisplay.getPickingPointAndPlaneInPointCloud function.
  3573. * @param {THREE.Object3D} object3d The object3d to be transformed so it is positioned and oriented according to the given point and plane.
  3574. * @param {number} scale The value the object3d will be positioned in the direction of the normal of the plane to be correctly positioned. Objects usually have their position value referenced as the center of the geometry. In this case, positioning the object in the picking point would lead to have the object3d positioned in the plane, not on top of it. this scale value will allow to correctly position the object in the picking point and in the direction of the normal of the plane. Half the size of the object3d would be a correct value in this case.
  3575. */
  3576. THREE.WebAR.positionAndRotateObject3DWithPickingPointAndPlaneInPointCloud =
  3577. function(pointAndPlane, object3d, scale) {
  3578. THREE.WebAR.rotateObject3DWithPickingPlane(pointAndPlane.plane, object3d);
  3579. THREE.WebAR.positionObject3DWithPickingPoint(pointAndPlane.point, object3d);
  3580. object3d.position.add(THREE.WebAR._planeNormal.multiplyScalar(scale));
  3581. };
  3582. /**
  3583. * Transform a given THREE.Object3D instance to be correctly positioned and oriented according to an axis formed by 2 plane normals, a position and a scale (half the size of the object3d for example).
  3584. * @param {VRPickingPointandPlane} pointAndPlane The point and plane retrieved using the VRDisplay.getPickingPointAndPlaneInPointCloud function.
  3585. * @param {THREE.Object3D} object3d The object3d to be transformed so it is positioned and oriented according to the given point and plane.
  3586. * @param {number} scale The value the object3d will be positioned in the direction of the normal of the plane to be correctly positioned. Objects usually have their position value referenced as the center of the geometry. In this case, positioning the object in the picking point would lead to have the object3d positioned in the plane, not on top of it. this scale value will allow to correctly position the object in the picking point and in the direction of the normal of the plane. Half the size of the object3d would be a correct value in this case.
  3587. */
  3588. THREE.WebAR.positionAndRotateObject3D =
  3589. function(position, normal1, normal2, object3d, scale) {
  3590. THREE.WebAR.rotateObject3D(normal1, normal2, object3d);
  3591. THREE.WebAR.positionObject3DWithPickingPoint(position, object3d);
  3592. object3d.position.add(THREE.WebAR._planeNormal.multiplyScalar(scale));
  3593. };
  3594. // UMD
  3595. (function (root, factory) {
  3596. if (typeof define === 'function' && define.amd) {
  3597. define(['WebAR'], factory);
  3598. } else if (typeof exports === 'object') {
  3599. module.exports = factory();
  3600. } else {
  3601. root.WebAR = factory();
  3602. }
  3603. }(this, function() {
  3604. return THREE.WebAR;
  3605. }));
  3606. /*
  3607. JS Signals <http://millermedeiros.github.com/js-signals/>
  3608. Released under the MIT license
  3609. Author: Miller Medeiros
  3610. Version: 0.7.4 - Build: 252 (2012/02/24 10:30 PM)
  3611. */
  3612. (function(h){function g(a,b,c,d,e){this._listener=b;this._isOnce=c;this.context=d;this._signal=a;this._priority=e||0}function f(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}var e={VERSION:"0.7.4"};g.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());return b},detach:function(){return this.isBound()?
  3613. this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},getListener:function(){return this._listener},_destroy:function(){delete this._signal;delete this._listener;delete this.context},isOnce:function(){return this._isOnce},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};e.Signal=function(){this._bindings=[];this._prevParams=null};e.Signal.prototype={memorize:!1,_shouldPropagate:!0,
  3614. active:!0,_registerListener:function(a,b,c,d){var e=this._indexOfListener(a,c);if(e!==-1){if(a=this._bindings[e],a.isOnce()!==b)throw Error("You cannot add"+(b?"":"Once")+"() then add"+(!b?"":"Once")+"() the same listener without removing the relationship first.");}else a=new g(this,a,b,c,d),this._addBinding(a);this.memorize&&this._prevParams&&a.execute(this._prevParams);return a},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);
  3615. this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c=this._bindings.length,d;c--;)if(d=this._bindings[c],d._listener===a&&d.context===b)return c;return-1},has:function(a,b){return this._indexOfListener(a,b)!==-1},add:function(a,b,c){f(a,"add");return this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){f(a,"addOnce");return this._registerListener(a,!0,b,c)},remove:function(a,b){f(a,"remove");var c=this._indexOfListener(a,b);c!==-1&&(this._bindings[c]._destroy(),this._bindings.splice(c,
  3616. 1));return a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(a){if(this.active){var b=Array.prototype.slice.call(arguments),c=this._bindings.length,d;if(this.memorize)this._prevParams=b;if(c){d=this._bindings.slice();this._shouldPropagate=!0;do c--;while(d[c]&&this._shouldPropagate&&d[c].execute(b)!==!1)}}},forget:function(){this._prevParams=
  3617. null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};typeof define==="function"&&define.amd?define(e):typeof module!=="undefined"&&module.exports?module.exports=e:h.signals=e})(this);var THREEx = THREEx || {}
  3618. THREEx.ArBaseControls = function(object3d){
  3619. this.id = THREEx.ArBaseControls.id++
  3620. this.object3d = object3d
  3621. this.object3d.matrixAutoUpdate = false;
  3622. this.object3d.visible = false
  3623. // Events to honor
  3624. // this.dispatchEvent({ type: 'becameVisible' })
  3625. // this.dispatchEvent({ type: 'markerVisible' }) // replace markerFound
  3626. // this.dispatchEvent({ type: 'becameUnVisible' })
  3627. }
  3628. THREEx.ArBaseControls.id = 0
  3629. Object.assign( THREEx.ArBaseControls.prototype, THREE.EventDispatcher.prototype );
  3630. //////////////////////////////////////////////////////////////////////////////
  3631. // Functions
  3632. //////////////////////////////////////////////////////////////////////////////
  3633. /**
  3634. * error catching function for update()
  3635. */
  3636. THREEx.ArBaseControls.prototype.update = function(){
  3637. console.assert(false, 'you need to implement your own update')
  3638. }
  3639. /**
  3640. * error catching function for name()
  3641. */
  3642. THREEx.ArBaseControls.prototype.name = function(){
  3643. console.assert(false, 'you need to implement your own .name()')
  3644. return 'Not yet implemented - name()'
  3645. }
  3646. var THREEx = THREEx || {}
  3647. // TODO this is useless - prefere arjs-HitTesting.js
  3648. /**
  3649. * - maybe support .onClickFcts in each object3d
  3650. * - seems an easy light layer for clickable object
  3651. * - up to
  3652. */
  3653. THREEx.ARClickability = function(sourceElement){
  3654. this._sourceElement = sourceElement
  3655. // Create cameraPicking
  3656. var fullWidth = parseInt(sourceElement.style.width)
  3657. var fullHeight = parseInt(sourceElement.style.height)
  3658. this._cameraPicking = new THREE.PerspectiveCamera(42, fullWidth / fullHeight, 0.1, 100);
  3659. console.warn('THREEx.ARClickability works only in modelViewMatrix')
  3660. console.warn('OBSOLETE OBSOLETE! instead use THREEx.HitTestingPlane or THREEx.HitTestingTango')
  3661. }
  3662. THREEx.ARClickability.prototype.onResize = function(){
  3663. var sourceElement = this._sourceElement
  3664. var cameraPicking = this._cameraPicking
  3665. var fullWidth = parseInt(sourceElement.style.width)
  3666. var fullHeight = parseInt(sourceElement.style.height)
  3667. cameraPicking.aspect = fullWidth / fullHeight;
  3668. cameraPicking.updateProjectionMatrix();
  3669. }
  3670. THREEx.ARClickability.prototype.computeIntersects = function(domEvent, objects){
  3671. var sourceElement = this._sourceElement
  3672. var cameraPicking = this._cameraPicking
  3673. // compute mouse coordinatge with [-1,1]
  3674. var eventCoords = new THREE.Vector3();
  3675. eventCoords.x = ( domEvent.layerX / parseInt(sourceElement.style.width) ) * 2 - 1;
  3676. eventCoords.y = - ( domEvent.layerY / parseInt(sourceElement.style.height) ) * 2 + 1;
  3677. // compute intersections between eventCoords and pickingPlane
  3678. var raycaster = new THREE.Raycaster();
  3679. raycaster.setFromCamera( eventCoords, cameraPicking );
  3680. var intersects = raycaster.intersectObjects( objects )
  3681. return intersects
  3682. }
  3683. THREEx.ARClickability.prototype.update = function(){
  3684. }
  3685. //////////////////////////////////////////////////////////////////////////////
  3686. // Code Separator
  3687. //////////////////////////////////////////////////////////////////////////////
  3688. THREEx.ARClickability.tangoPickingPointCloud = function(artoolkitContext, mouseX, mouseY){
  3689. // THIS IS CRAP!!!! use THREEx.HitTestingTango
  3690. var vrDisplay = artoolkitContext._tangoContext.vrDisplay
  3691. if (vrDisplay === null ) return null
  3692. var pointAndPlane = vrDisplay.getPickingPointAndPlaneInPointCloud(mouseX, mouseY)
  3693. if( pointAndPlane == null ) {
  3694. console.warn('Could not retrieve the correct point and plane.')
  3695. return null
  3696. }
  3697. // FIXME not sure what this is
  3698. var boundingSphereRadius = 0.01
  3699. // the bigger the number the likeliest it crash chromium-webar
  3700. // Orient and position the model in the picking point according
  3701. // to the picking plane. The offset is half of the model size.
  3702. var object3d = new THREE.Object3D
  3703. THREE.WebAR.positionAndRotateObject3DWithPickingPointAndPlaneInPointCloud(
  3704. pointAndPlane, object3d, boundingSphereRadius
  3705. )
  3706. object3d.rotateZ(-Math.PI/2)
  3707. // return the result
  3708. var result = {}
  3709. result.position = object3d.position
  3710. result.quaternion = object3d.quaternion
  3711. return result
  3712. }
  3713. var THREEx = THREEx || {}
  3714. /**
  3715. * - videoTexture
  3716. * - cloakWidth
  3717. * - cloakHeight
  3718. * - cloakSegmentsHeight
  3719. * - remove all mentions of cache, for cloak
  3720. */
  3721. THREEx.ArMarkerCloak = function(videoTexture){
  3722. var updateInShaderEnabled = true
  3723. // build cloakMesh
  3724. // TODO if webgl2 use repeat warp, and not multi segment, this will reduce the geometry to draw
  3725. var geometry = new THREE.PlaneGeometry(1.3+0.25,1.85+0.25, 1, 8).translate(0,-0.3,0)
  3726. var material = new THREE.ShaderMaterial( {
  3727. vertexShader: THREEx.ArMarkerCloak.vertexShader,
  3728. fragmentShader: THREEx.ArMarkerCloak.fragmentShader,
  3729. transparent: true,
  3730. uniforms: {
  3731. texture: {
  3732. value: videoTexture
  3733. },
  3734. opacity: {
  3735. value: 0.5
  3736. }
  3737. },
  3738. defines: {
  3739. updateInShaderEnabled: updateInShaderEnabled ? 1 : 0,
  3740. }
  3741. });
  3742. var cloakMesh = new THREE.Mesh( geometry, material );
  3743. cloakMesh.rotation.x = -Math.PI/2
  3744. this.object3d = cloakMesh
  3745. //////////////////////////////////////////////////////////////////////////////
  3746. // Code Separator
  3747. //////////////////////////////////////////////////////////////////////////////
  3748. var xMin = -0.65
  3749. var xMax = 0.65
  3750. var yMin = 0.65 + 0.1
  3751. var yMax = 0.95 + 0.1
  3752. //////////////////////////////////////////////////////////////////////////////
  3753. // originalsFaceVertexUvs
  3754. //////////////////////////////////////////////////////////////////////////////
  3755. var originalsFaceVertexUvs = [[]]
  3756. // build originalsFaceVertexUvs array
  3757. for(var faceIndex = 0; faceIndex < cloakMesh.geometry.faces.length; faceIndex ++ ){
  3758. originalsFaceVertexUvs[0][faceIndex] = []
  3759. originalsFaceVertexUvs[0][faceIndex][0] = new THREE.Vector2()
  3760. originalsFaceVertexUvs[0][faceIndex][1] = new THREE.Vector2()
  3761. originalsFaceVertexUvs[0][faceIndex][2] = new THREE.Vector2()
  3762. }
  3763. // set values in originalsFaceVertexUvs
  3764. for(var i = 0; i < cloakMesh.geometry.parameters.heightSegments/2; i ++ ){
  3765. // one segment height - even row - normale orientation
  3766. originalsFaceVertexUvs[0][i*4+0][0].set( xMin/2+0.5, yMax/2+0.5 )
  3767. originalsFaceVertexUvs[0][i*4+0][1].set( xMin/2+0.5, yMin/2+0.5 )
  3768. originalsFaceVertexUvs[0][i*4+0][2].set( xMax/2+0.5, yMax/2+0.5 )
  3769. originalsFaceVertexUvs[0][i*4+1][0].set( xMin/2+0.5, yMin/2+0.5 )
  3770. originalsFaceVertexUvs[0][i*4+1][1].set( xMax/2+0.5, yMin/2+0.5 )
  3771. originalsFaceVertexUvs[0][i*4+1][2].set( xMax/2+0.5, yMax/2+0.5 )
  3772. // one segment height - odd row - mirror-y orientation
  3773. originalsFaceVertexUvs[0][i*4+2][0].set( xMin/2+0.5, yMin/2+0.5 )
  3774. originalsFaceVertexUvs[0][i*4+2][1].set( xMin/2+0.5, yMax/2+0.5 )
  3775. originalsFaceVertexUvs[0][i*4+2][2].set( xMax/2+0.5, yMin/2+0.5 )
  3776. originalsFaceVertexUvs[0][i*4+3][0].set( xMin/2+0.5, yMax/2+0.5 )
  3777. originalsFaceVertexUvs[0][i*4+3][1].set( xMax/2+0.5, yMax/2+0.5 )
  3778. originalsFaceVertexUvs[0][i*4+3][2].set( xMax/2+0.5, yMin/2+0.5 )
  3779. }
  3780. if( updateInShaderEnabled === true ){
  3781. cloakMesh.geometry.faceVertexUvs = originalsFaceVertexUvs
  3782. cloakMesh.geometry.uvsNeedUpdate = true
  3783. }
  3784. //////////////////////////////////////////////////////////////////////////////
  3785. // Code Separator
  3786. //////////////////////////////////////////////////////////////////////////////
  3787. var originalOrthoVertices = []
  3788. originalOrthoVertices.push( new THREE.Vector3(xMin, yMax, 0))
  3789. originalOrthoVertices.push( new THREE.Vector3(xMax, yMax, 0))
  3790. originalOrthoVertices.push( new THREE.Vector3(xMin, yMin, 0))
  3791. originalOrthoVertices.push( new THREE.Vector3(xMax, yMin, 0))
  3792. // build debugMesh
  3793. var material = new THREE.MeshNormalMaterial({
  3794. transparent : true,
  3795. opacity: 0.5,
  3796. side: THREE.DoubleSide
  3797. });
  3798. var geometry = new THREE.PlaneGeometry(1,1);
  3799. var orthoMesh = new THREE.Mesh(geometry, material);
  3800. this.orthoMesh = orthoMesh
  3801. //////////////////////////////////////////////////////////////////////////////
  3802. // Code Separator
  3803. //////////////////////////////////////////////////////////////////////////////
  3804. this.update = function(modelViewMatrix, cameraProjectionMatrix){
  3805. updateOrtho(modelViewMatrix, cameraProjectionMatrix)
  3806. if( updateInShaderEnabled === false ){
  3807. updateUvs(modelViewMatrix, cameraProjectionMatrix)
  3808. }
  3809. }
  3810. return
  3811. // update cloakMesh
  3812. function updateUvs(modelViewMatrix, cameraProjectionMatrix){
  3813. var transformedUv = new THREE.Vector3()
  3814. originalsFaceVertexUvs[0].forEach(function(faceVertexUvs, faceIndex){
  3815. faceVertexUvs.forEach(function(originalUv, uvIndex){
  3816. // set transformedUv - from UV coord to clip coord
  3817. transformedUv.x = originalUv.x * 2.0 - 1.0;
  3818. transformedUv.y = originalUv.y * 2.0 - 1.0;
  3819. transformedUv.z = 0
  3820. // apply modelViewMatrix and projectionMatrix
  3821. transformedUv.applyMatrix4( modelViewMatrix )
  3822. transformedUv.applyMatrix4( cameraProjectionMatrix )
  3823. // apply perspective
  3824. transformedUv.x /= transformedUv.z
  3825. transformedUv.y /= transformedUv.z
  3826. // set back from clip coord to Uv coord
  3827. transformedUv.x = transformedUv.x / 2.0 + 0.5;
  3828. transformedUv.y = transformedUv.y / 2.0 + 0.5;
  3829. // copy the trasnformedUv into the geometry
  3830. cloakMesh.geometry.faceVertexUvs[0][faceIndex][uvIndex].set(transformedUv.x, transformedUv.y)
  3831. })
  3832. })
  3833. // cloakMesh.geometry.faceVertexUvs = faceVertexUvs
  3834. cloakMesh.geometry.uvsNeedUpdate = true
  3835. }
  3836. // update orthoMesh
  3837. function updateOrtho(modelViewMatrix, cameraProjectionMatrix){
  3838. // compute transformedUvs
  3839. var transformedUvs = []
  3840. originalOrthoVertices.forEach(function(originalOrthoVertices, index){
  3841. var transformedUv = originalOrthoVertices.clone()
  3842. // apply modelViewMatrix and projectionMatrix
  3843. transformedUv.applyMatrix4( modelViewMatrix )
  3844. transformedUv.applyMatrix4( cameraProjectionMatrix )
  3845. // apply perspective
  3846. transformedUv.x /= transformedUv.z
  3847. transformedUv.y /= transformedUv.z
  3848. // store it
  3849. transformedUvs.push(transformedUv)
  3850. })
  3851. // change orthoMesh vertices
  3852. for(var i = 0; i < transformedUvs.length; i++){
  3853. orthoMesh.geometry.vertices[i].copy(transformedUvs[i])
  3854. }
  3855. orthoMesh.geometry.computeBoundingSphere()
  3856. orthoMesh.geometry.verticesNeedUpdate = true
  3857. }
  3858. }
  3859. //////////////////////////////////////////////////////////////////////////////
  3860. // Shaders
  3861. //////////////////////////////////////////////////////////////////////////////
  3862. THREEx.ArMarkerCloak.markerSpaceShaderFunction = '\n'+
  3863. ' vec2 transformUvToMarkerSpace(vec2 originalUv){\n'+
  3864. ' vec3 transformedUv;\n'+
  3865. ' // set transformedUv - from UV coord to clip coord\n'+
  3866. ' transformedUv.x = originalUv.x * 2.0 - 1.0;\n'+
  3867. ' transformedUv.y = originalUv.y * 2.0 - 1.0;\n'+
  3868. ' transformedUv.z = 0.0;\n'+
  3869. '\n'+
  3870. ' // apply modelViewMatrix and projectionMatrix\n'+
  3871. ' transformedUv = (projectionMatrix * modelViewMatrix * vec4( transformedUv, 1.0 ) ).xyz;\n'+
  3872. '\n'+
  3873. ' // apply perspective\n'+
  3874. ' transformedUv.x /= transformedUv.z;\n'+
  3875. ' transformedUv.y /= transformedUv.z;\n'+
  3876. '\n'+
  3877. ' // set back from clip coord to Uv coord\n'+
  3878. ' transformedUv.x = transformedUv.x / 2.0 + 0.5;\n'+
  3879. ' transformedUv.y = transformedUv.y / 2.0 + 0.5;\n'+
  3880. '\n'+
  3881. ' // return the result\n'+
  3882. ' return transformedUv.xy;\n'+
  3883. ' }'
  3884. THREEx.ArMarkerCloak.vertexShader = THREEx.ArMarkerCloak.markerSpaceShaderFunction +
  3885. ' varying vec2 vUv;\n'+
  3886. '\n'+
  3887. ' void main(){\n'+
  3888. ' // pass the UV to the fragment\n'+
  3889. ' #if (updateInShaderEnabled == 1)\n'+
  3890. ' vUv = transformUvToMarkerSpace(uv);\n'+
  3891. ' #else\n'+
  3892. ' vUv = uv;\n'+
  3893. ' #endif\n'+
  3894. '\n'+
  3895. ' // compute gl_Position\n'+
  3896. ' vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n'+
  3897. ' gl_Position = projectionMatrix * mvPosition;\n'+
  3898. ' }';
  3899. THREEx.ArMarkerCloak.fragmentShader = '\n'+
  3900. ' varying vec2 vUv;\n'+
  3901. ' uniform sampler2D texture;\n'+
  3902. ' uniform float opacity;\n'+
  3903. '\n'+
  3904. ' void main(void){\n'+
  3905. ' vec3 color = texture2D( texture, vUv ).rgb;\n'+
  3906. '\n'+
  3907. ' gl_FragColor = vec4( color, opacity);\n'+
  3908. ' }'
  3909. var ARjs = ARjs || {}
  3910. var THREEx = THREEx || {}
  3911. ARjs.MarkerControls = THREEx.ArMarkerControls = function(context, object3d, parameters){
  3912. var _this = this
  3913. THREEx.ArBaseControls.call(this, object3d)
  3914. this.context = context
  3915. // handle default parameters
  3916. this.parameters = {
  3917. // size of the marker in meter
  3918. size : 1,
  3919. // type of marker - ['pattern', 'barcode', 'unknown' ]
  3920. type : 'unknown',
  3921. // url of the pattern - IIF type='pattern'
  3922. patternUrl : null,
  3923. // value of the barcode - IIF type='barcode'
  3924. barcodeValue : null,
  3925. // change matrix mode - [modelViewMatrix, cameraTransformMatrix]
  3926. changeMatrixMode : 'modelViewMatrix',
  3927. // minimal confidence in the marke recognition - between [0, 1] - default to 1
  3928. minConfidence: 0.6,
  3929. }
  3930. // sanity check
  3931. var possibleValues = ['pattern', 'barcode', 'unknown']
  3932. console.assert(possibleValues.indexOf(this.parameters.type) !== -1, 'illegal value', this.parameters.type)
  3933. var possibleValues = ['modelViewMatrix', 'cameraTransformMatrix' ]
  3934. console.assert(possibleValues.indexOf(this.parameters.changeMatrixMode) !== -1, 'illegal value', this.parameters.changeMatrixMode)
  3935. // create the marker Root
  3936. this.object3d = object3d
  3937. this.object3d.matrixAutoUpdate = false;
  3938. this.object3d.visible = false
  3939. //////////////////////////////////////////////////////////////////////////////
  3940. // setParameters
  3941. //////////////////////////////////////////////////////////////////////////////
  3942. setParameters(parameters)
  3943. function setParameters(parameters){
  3944. if( parameters === undefined ) return
  3945. for( var key in parameters ){
  3946. var newValue = parameters[ key ]
  3947. if( newValue === undefined ){
  3948. console.warn( "THREEx.ArMarkerControls: '" + key + "' parameter is undefined." )
  3949. continue
  3950. }
  3951. var currentValue = _this.parameters[ key ]
  3952. if( currentValue === undefined ){
  3953. console.warn( "THREEx.ArMarkerControls: '" + key + "' is not a property of this material." )
  3954. continue
  3955. }
  3956. _this.parameters[ key ] = newValue
  3957. }
  3958. }
  3959. //////////////////////////////////////////////////////////////////////////////
  3960. // Code Separator
  3961. //////////////////////////////////////////////////////////////////////////////
  3962. // add this marker to artoolkitsystem
  3963. // TODO rename that .addMarkerControls
  3964. context.addMarker(this)
  3965. if( _this.context.parameters.trackingBackend === 'artoolkit' ){
  3966. this._initArtoolkit()
  3967. }else if( _this.context.parameters.trackingBackend === 'aruco' ){
  3968. // TODO create a ._initAruco
  3969. // put aruco second
  3970. this._arucoPosit = new POS.Posit(this.parameters.size, _this.context.arucoContext.canvas.width)
  3971. }else if( _this.context.parameters.trackingBackend === 'tango' ){
  3972. this._initTango()
  3973. }else console.assert(false)
  3974. }
  3975. ARjs.MarkerControls.prototype = Object.create( THREEx.ArBaseControls.prototype );
  3976. ARjs.MarkerControls.prototype.constructor = THREEx.ArMarkerControls;
  3977. ARjs.MarkerControls.prototype.dispose = function(){
  3978. this.context.removeMarker(this)
  3979. // TODO remove the event listener if needed
  3980. // unloadMaker ???
  3981. }
  3982. //////////////////////////////////////////////////////////////////////////////
  3983. // update controls with new modelViewMatrix
  3984. //////////////////////////////////////////////////////////////////////////////
  3985. /**
  3986. * When you actually got a new modelViewMatrix, you need to perfom a whole bunch
  3987. * of things. it is done here.
  3988. */
  3989. ARjs.MarkerControls.prototype.updateWithModelViewMatrix = function(modelViewMatrix){
  3990. var markerObject3D = this.object3d;
  3991. // mark object as visible
  3992. markerObject3D.visible = true
  3993. if( this.context.parameters.trackingBackend === 'artoolkit' ){
  3994. // apply context._axisTransformMatrix - change artoolkit axis to match usual webgl one
  3995. var tmpMatrix = new THREE.Matrix4().copy(this.context._artoolkitProjectionAxisTransformMatrix)
  3996. tmpMatrix.multiply(modelViewMatrix)
  3997. modelViewMatrix.copy(tmpMatrix)
  3998. }else if( this.context.parameters.trackingBackend === 'aruco' ){
  3999. // ...
  4000. }else if( this.context.parameters.trackingBackend === 'tango' ){
  4001. // ...
  4002. }else console.assert(false)
  4003. if( this.context.parameters.trackingBackend !== 'tango' ){
  4004. // change axis orientation on marker - artoolkit say Z is normal to the marker - ar.js say Y is normal to the marker
  4005. var markerAxisTransformMatrix = new THREE.Matrix4().makeRotationX(Math.PI/2)
  4006. modelViewMatrix.multiply(markerAxisTransformMatrix)
  4007. }
  4008. // change markerObject3D.matrix based on parameters.changeMatrixMode
  4009. if( this.parameters.changeMatrixMode === 'modelViewMatrix' ){
  4010. markerObject3D.matrix.copy(modelViewMatrix)
  4011. }else if( this.parameters.changeMatrixMode === 'cameraTransformMatrix' ){
  4012. markerObject3D.matrix.getInverse( modelViewMatrix )
  4013. }else {
  4014. console.assert(false)
  4015. }
  4016. // decompose - the matrix into .position, .quaternion, .scale
  4017. markerObject3D.matrix.decompose(markerObject3D.position, markerObject3D.quaternion, markerObject3D.scale)
  4018. // dispatchEvent
  4019. this.dispatchEvent( { type: 'markerFound' } );
  4020. }
  4021. //////////////////////////////////////////////////////////////////////////////
  4022. // utility functions
  4023. //////////////////////////////////////////////////////////////////////////////
  4024. /**
  4025. * provide a name for a marker
  4026. * - silly heuristic for now
  4027. * - should be improved
  4028. */
  4029. ARjs.MarkerControls.prototype.name = function(){
  4030. var name = ''
  4031. name += this.parameters.type;
  4032. if( this.parameters.type === 'pattern' ){
  4033. var url = this.parameters.patternUrl
  4034. var basename = url.replace(/^.*\//g, '')
  4035. name += ' - ' + basename
  4036. }else if( this.parameters.type === 'barcode' ){
  4037. name += ' - ' + this.parameters.barcodeValue
  4038. }else{
  4039. console.assert(false, 'no .name() implemented for this marker controls')
  4040. }
  4041. return name
  4042. }
  4043. //////////////////////////////////////////////////////////////////////////////
  4044. // init for Artoolkit
  4045. //////////////////////////////////////////////////////////////////////////////
  4046. ARjs.MarkerControls.prototype._initArtoolkit = function(){
  4047. var _this = this
  4048. var artoolkitMarkerId = null
  4049. var delayedInitTimerId = setInterval(function(){
  4050. // check if arController is init
  4051. var arController = _this.context.arController
  4052. if( arController === null ) return
  4053. // stop looping if it is init
  4054. clearInterval(delayedInitTimerId)
  4055. delayedInitTimerId = null
  4056. // launch the _postInitArtoolkit
  4057. postInit()
  4058. }, 1000/50)
  4059. return
  4060. function postInit(){
  4061. // check if arController is init
  4062. var arController = _this.context.arController
  4063. console.assert(arController !== null )
  4064. // start tracking this pattern
  4065. if( _this.parameters.type === 'pattern' ){
  4066. arController.loadMarker(_this.parameters.patternUrl, function(markerId) {
  4067. artoolkitMarkerId = markerId
  4068. arController.trackPatternMarkerId(artoolkitMarkerId, _this.parameters.size);
  4069. });
  4070. }else if( _this.parameters.type === 'barcode' ){
  4071. artoolkitMarkerId = _this.parameters.barcodeValue
  4072. arController.trackBarcodeMarkerId(artoolkitMarkerId, _this.parameters.size);
  4073. }else if( _this.parameters.type === 'unknown' ){
  4074. artoolkitMarkerId = null
  4075. }else{
  4076. console.log(false, 'invalid marker type', _this.parameters.type)
  4077. }
  4078. // listen to the event
  4079. arController.addEventListener('getMarker', function(event){
  4080. if( event.data.type === artoolkit.PATTERN_MARKER && _this.parameters.type === 'pattern' ){
  4081. if( artoolkitMarkerId === null ) return
  4082. if( event.data.marker.idPatt === artoolkitMarkerId ) onMarkerFound(event)
  4083. }else if( event.data.type === artoolkit.BARCODE_MARKER && _this.parameters.type === 'barcode' ){
  4084. // console.log('BARCODE_MARKER idMatrix', event.data.marker.idMatrix, artoolkitMarkerId )
  4085. if( artoolkitMarkerId === null ) return
  4086. if( event.data.marker.idMatrix === artoolkitMarkerId ) onMarkerFound(event)
  4087. }else if( event.data.type === artoolkit.UNKNOWN_MARKER && _this.parameters.type === 'unknown'){
  4088. onMarkerFound(event)
  4089. }
  4090. })
  4091. }
  4092. function onMarkerFound(event){
  4093. // honor his.parameters.minConfidence
  4094. if( event.data.type === artoolkit.PATTERN_MARKER && event.data.marker.cfPatt < _this.parameters.minConfidence ) return
  4095. if( event.data.type === artoolkit.BARCODE_MARKER && event.data.marker.cfMatt < _this.parameters.minConfidence ) return
  4096. var modelViewMatrix = new THREE.Matrix4().fromArray(event.data.matrix)
  4097. _this.updateWithModelViewMatrix(modelViewMatrix)
  4098. }
  4099. }
  4100. //////////////////////////////////////////////////////////////////////////////
  4101. // aruco specific
  4102. //////////////////////////////////////////////////////////////////////////////
  4103. ARjs.MarkerControls.prototype._initAruco = function(){
  4104. this._arucoPosit = new POS.Posit(this.parameters.size, _this.context.arucoContext.canvas.width)
  4105. }
  4106. //////////////////////////////////////////////////////////////////////////////
  4107. // init for Artoolkit
  4108. //////////////////////////////////////////////////////////////////////////////
  4109. ARjs.MarkerControls.prototype._initTango = function(){
  4110. var _this = this
  4111. console.log('init tango ArMarkerControls')
  4112. }
  4113. var THREEx = THREEx || {}
  4114. THREEx.ArMarkerHelper = function(markerControls){
  4115. this.object3d = new THREE.Group
  4116. var mesh = new THREE.AxisHelper()
  4117. this.object3d.add(mesh)
  4118. var text = markerControls.id
  4119. // debugger
  4120. // var text = markerControls.parameters.patternUrl.slice(-1).toUpperCase();
  4121. var canvas = document.createElement( 'canvas' );
  4122. canvas.width = 64;
  4123. canvas.height = 64;
  4124. var context = canvas.getContext( '2d' );
  4125. var texture = new THREE.CanvasTexture( canvas );
  4126. // put the text in the sprite
  4127. context.font = '48px monospace';
  4128. context.fillStyle = 'rgba(192,192,255, 0.5)';
  4129. context.fillRect( 0, 0, canvas.width, canvas.height );
  4130. context.fillStyle = 'darkblue';
  4131. context.fillText(text, canvas.width/4, 3*canvas.height/4 )
  4132. texture.needsUpdate = true
  4133. // var geometry = new THREE.CubeGeometry(1, 1, 1)
  4134. var geometry = new THREE.PlaneGeometry(1, 1)
  4135. var material = new THREE.MeshBasicMaterial({
  4136. map: texture,
  4137. transparent: true
  4138. });
  4139. var mesh = new THREE.Mesh(geometry, material)
  4140. mesh.rotation.x = -Math.PI/2
  4141. this.object3d.add(mesh)
  4142. }
  4143. var THREEx = THREEx || {}
  4144. /**
  4145. * - lerp position/quaternino/scale
  4146. * - minDelayDetected
  4147. * - minDelayUndetected
  4148. * @param {[type]} object3d [description]
  4149. * @param {[type]} parameters [description]
  4150. */
  4151. THREEx.ArSmoothedControls = function(object3d, parameters){
  4152. var _this = this
  4153. THREEx.ArBaseControls.call(this, object3d)
  4154. // copy parameters
  4155. this.object3d.visible = false
  4156. this._lastLerpStepAt = null
  4157. this._visibleStartedAt = null
  4158. this._unvisibleStartedAt = null
  4159. // handle default parameters
  4160. parameters = parameters || {}
  4161. this.parameters = {
  4162. // lerp coeficient for the position - between [0,1] - default to 1
  4163. lerpPosition: 0.8,
  4164. // lerp coeficient for the quaternion - between [0,1] - default to 1
  4165. lerpQuaternion: 0.2,
  4166. // lerp coeficient for the scale - between [0,1] - default to 1
  4167. lerpScale: 0.7,
  4168. // delay for lerp fixed steps - in seconds - default to 1/120
  4169. lerpStepDelay: 1/60,
  4170. // minimum delay the sub-control must be visible before this controls become visible - default to 0 seconds
  4171. minVisibleDelay: 0.0,
  4172. // minimum delay the sub-control must be unvisible before this controls become unvisible - default to 0 seconds
  4173. minUnvisibleDelay: 0.2,
  4174. }
  4175. //////////////////////////////////////////////////////////////////////////////
  4176. // setParameters
  4177. //////////////////////////////////////////////////////////////////////////////
  4178. setParameters(parameters)
  4179. function setParameters(parameters){
  4180. if( parameters === undefined ) return
  4181. for( var key in parameters ){
  4182. var newValue = parameters[ key ]
  4183. if( newValue === undefined ){
  4184. console.warn( "THREEx.ArSmoothedControls: '" + key + "' parameter is undefined." )
  4185. continue
  4186. }
  4187. var currentValue = _this.parameters[ key ]
  4188. if( currentValue === undefined ){
  4189. console.warn( "THREEx.ArSmoothedControls: '" + key + "' is not a property of this material." )
  4190. continue
  4191. }
  4192. _this.parameters[ key ] = newValue
  4193. }
  4194. }
  4195. }
  4196. THREEx.ArSmoothedControls.prototype = Object.create( THREEx.ArBaseControls.prototype );
  4197. THREEx.ArSmoothedControls.prototype.constructor = THREEx.ArSmoothedControls;
  4198. //////////////////////////////////////////////////////////////////////////////
  4199. // update function
  4200. //////////////////////////////////////////////////////////////////////////////
  4201. THREEx.ArSmoothedControls.prototype.update = function(targetObject3d){
  4202. var object3d = this.object3d
  4203. var parameters = this.parameters
  4204. var wasVisible = object3d.visible
  4205. var present = performance.now()/1000
  4206. //////////////////////////////////////////////////////////////////////////////
  4207. // handle object3d.visible with minVisibleDelay/minUnvisibleDelay
  4208. //////////////////////////////////////////////////////////////////////////////
  4209. if( targetObject3d.visible === false ) this._visibleStartedAt = null
  4210. if( targetObject3d.visible === true ) this._unvisibleStartedAt = null
  4211. if( targetObject3d.visible === true && this._visibleStartedAt === null ) this._visibleStartedAt = present
  4212. if( targetObject3d.visible === false && this._unvisibleStartedAt === null ) this._unvisibleStartedAt = present
  4213. if( wasVisible === false && targetObject3d.visible === true ){
  4214. var visibleFor = present - this._visibleStartedAt
  4215. if( visibleFor >= this.parameters.minVisibleDelay ){
  4216. object3d.visible = true
  4217. snapDirectlyToTarget()
  4218. }
  4219. // console.log('visibleFor', visibleFor)
  4220. }
  4221. if( wasVisible === true && targetObject3d.visible === false ){
  4222. var unvisibleFor = present - this._unvisibleStartedAt
  4223. if( unvisibleFor >= this.parameters.minUnvisibleDelay ){
  4224. object3d.visible = false
  4225. }
  4226. }
  4227. //////////////////////////////////////////////////////////////////////////////
  4228. // apply lerp on positon/quaternion/scale
  4229. //////////////////////////////////////////////////////////////////////////////
  4230. // apply lerp steps - require fix time steps to behave the same no matter the fps
  4231. if( this._lastLerpStepAt === null ){
  4232. applyOneSlerpStep()
  4233. this._lastLerpStepAt = present
  4234. }else{
  4235. var nStepsToDo = Math.floor( (present - this._lastLerpStepAt)/this.parameters.lerpStepDelay )
  4236. for(var i = 0; i < nStepsToDo; i++){
  4237. applyOneSlerpStep()
  4238. this._lastLerpStepAt += this.parameters.lerpStepDelay
  4239. }
  4240. }
  4241. // disable the lerp by directly copying targetObject3d position/quaternion/scale
  4242. if( false ){
  4243. snapDirectlyToTarget()
  4244. }
  4245. // update the matrix
  4246. this.object3d.updateMatrix()
  4247. //////////////////////////////////////////////////////////////////////////////
  4248. // honor becameVisible/becameUnVisible event
  4249. //////////////////////////////////////////////////////////////////////////////
  4250. // honor becameVisible event
  4251. if( wasVisible === false && object3d.visible === true ){
  4252. this.dispatchEvent({ type: 'becameVisible' })
  4253. }
  4254. // honor becameUnVisible event
  4255. if( wasVisible === true && object3d.visible === false ){
  4256. this.dispatchEvent({ type: 'becameUnVisible' })
  4257. }
  4258. return
  4259. function snapDirectlyToTarget(){
  4260. object3d.position.copy( targetObject3d.position )
  4261. object3d.quaternion.copy( targetObject3d.quaternion )
  4262. object3d.scale.copy( targetObject3d.scale )
  4263. }
  4264. function applyOneSlerpStep(){
  4265. object3d.position.lerp(targetObject3d.position, parameters.lerpPosition)
  4266. object3d.quaternion.slerp(targetObject3d.quaternion, parameters.lerpQuaternion)
  4267. object3d.scale.lerp(targetObject3d.scale, parameters.lerpScale)
  4268. }
  4269. }
  4270. var ARjs = ARjs || {}
  4271. var THREEx = THREEx || {}
  4272. ARjs.Context = THREEx.ArToolkitContext = function(parameters){
  4273. var _this = this
  4274. _this._updatedAt = null
  4275. // handle default parameters
  4276. this.parameters = {
  4277. // AR backend - ['artoolkit', 'aruco', 'tango']
  4278. trackingBackend: 'artoolkit',
  4279. // debug - true if one should display artoolkit debug canvas, false otherwise
  4280. debug: false,
  4281. // the mode of detection - ['color', 'color_and_matrix', 'mono', 'mono_and_matrix']
  4282. detectionMode: 'mono',
  4283. // type of matrix code - valid iif detectionMode end with 'matrix' - [3x3, 3x3_HAMMING63, 3x3_PARITY65, 4x4, 4x4_BCH_13_9_3, 4x4_BCH_13_5_5]
  4284. matrixCodeType: '3x3',
  4285. // url of the camera parameters
  4286. cameraParametersUrl: ARjs.Context.baseURL + 'parameters/camera_para.dat',
  4287. // tune the maximum rate of pose detection in the source image
  4288. maxDetectionRate: 60,
  4289. // resolution of at which we detect pose in the source image
  4290. canvasWidth: 640,
  4291. canvasHeight: 480,
  4292. // the patternRatio inside the artoolkit marker - artoolkit only
  4293. patternRatio: 0.5,
  4294. // enable image smoothing or not for canvas copy - default to true
  4295. // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled
  4296. imageSmoothingEnabled : false,
  4297. }
  4298. // parameters sanity check
  4299. console.assert(['artoolkit', 'aruco', 'tango'].indexOf(this.parameters.trackingBackend) !== -1, 'invalid parameter trackingBackend', this.parameters.trackingBackend)
  4300. console.assert(['color', 'color_and_matrix', 'mono', 'mono_and_matrix'].indexOf(this.parameters.detectionMode) !== -1, 'invalid parameter detectionMode', this.parameters.detectionMode)
  4301. this.arController = null;
  4302. this.arucoContext = null;
  4303. _this.initialized = false
  4304. this._arMarkersControls = []
  4305. //////////////////////////////////////////////////////////////////////////////
  4306. // setParameters
  4307. //////////////////////////////////////////////////////////////////////////////
  4308. setParameters(parameters)
  4309. function setParameters(parameters){
  4310. if( parameters === undefined ) return
  4311. for( var key in parameters ){
  4312. var newValue = parameters[ key ]
  4313. if( newValue === undefined ){
  4314. console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
  4315. continue
  4316. }
  4317. var currentValue = _this.parameters[ key ]
  4318. if( currentValue === undefined ){
  4319. console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
  4320. continue
  4321. }
  4322. _this.parameters[ key ] = newValue
  4323. }
  4324. }
  4325. }
  4326. Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
  4327. // ARjs.Context.baseURL = '../'
  4328. // default to github page
  4329. ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
  4330. ARjs.Context.REVISION = '1.6.2'
  4331. /**
  4332. * Create a default camera for this trackingBackend
  4333. * @param {string} trackingBackend - the tracking to user
  4334. * @return {THREE.Camera} the created camera
  4335. */
  4336. ARjs.Context.createDefaultCamera = function( trackingBackend ){
  4337. console.assert(false, 'use ARjs.Utils.createDefaultCamera instead')
  4338. // Create a camera
  4339. if( trackingBackend === 'artoolkit' ){
  4340. var camera = new THREE.Camera();
  4341. }else if( trackingBackend === 'aruco' ){
  4342. var camera = new THREE.PerspectiveCamera(42, renderer.domElement.width / renderer.domElement.height, 0.01, 100);
  4343. }else if( trackingBackend === 'tango' ){
  4344. var camera = new THREE.PerspectiveCamera(42, renderer.domElement.width / renderer.domElement.height, 0.01, 100);
  4345. }else console.assert(false)
  4346. return camera
  4347. }
  4348. //////////////////////////////////////////////////////////////////////////////
  4349. // init functions
  4350. //////////////////////////////////////////////////////////////////////////////
  4351. ARjs.Context.prototype.init = function(onCompleted){
  4352. var _this = this
  4353. if( this.parameters.trackingBackend === 'artoolkit' ){
  4354. this._initArtoolkit(done)
  4355. }else if( this.parameters.trackingBackend === 'aruco' ){
  4356. this._initAruco(done)
  4357. }else if( this.parameters.trackingBackend === 'tango' ){
  4358. this._initTango(done)
  4359. }else console.assert(false)
  4360. return
  4361. function done(){
  4362. // dispatch event
  4363. _this.dispatchEvent({
  4364. type: 'initialized'
  4365. });
  4366. _this.initialized = true
  4367. onCompleted && onCompleted()
  4368. }
  4369. }
  4370. ////////////////////////////////////////////////////////////////////////////////
  4371. // update function
  4372. ////////////////////////////////////////////////////////////////////////////////
  4373. ARjs.Context.prototype.update = function(srcElement){
  4374. // be sure arController is fully initialized
  4375. if(this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false;
  4376. // honor this.parameters.maxDetectionRate
  4377. var present = performance.now()
  4378. if( this._updatedAt !== null && present - this._updatedAt < 1000/this.parameters.maxDetectionRate ){
  4379. return false
  4380. }
  4381. this._updatedAt = present
  4382. // mark all markers to invisible before processing this frame
  4383. this._arMarkersControls.forEach(function(markerControls){
  4384. markerControls.object3d.visible = false
  4385. })
  4386. // process this frame
  4387. if(this.parameters.trackingBackend === 'artoolkit'){
  4388. this._updateArtoolkit(srcElement)
  4389. }else if( this.parameters.trackingBackend === 'aruco' ){
  4390. this._updateAruco(srcElement)
  4391. }else if( this.parameters.trackingBackend === 'tango' ){
  4392. this._updateTango(srcElement)
  4393. }else{
  4394. console.assert(false)
  4395. }
  4396. // dispatch event
  4397. this.dispatchEvent({
  4398. type: 'sourceProcessed'
  4399. });
  4400. // return true as we processed the frame
  4401. return true;
  4402. }
  4403. ////////////////////////////////////////////////////////////////////////////////
  4404. // Add/Remove markerControls
  4405. ////////////////////////////////////////////////////////////////////////////////
  4406. ARjs.Context.prototype.addMarker = function(arMarkerControls){
  4407. console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
  4408. this._arMarkersControls.push(arMarkerControls)
  4409. }
  4410. ARjs.Context.prototype.removeMarker = function(arMarkerControls){
  4411. console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
  4412. // console.log('remove marker for', arMarkerControls)
  4413. var index = this.arMarkerControlss.indexOf(artoolkitMarker);
  4414. console.assert(index !== index )
  4415. this._arMarkersControls.splice(index, 1)
  4416. }
  4417. //////////////////////////////////////////////////////////////////////////////
  4418. // artoolkit specific
  4419. //////////////////////////////////////////////////////////////////////////////
  4420. ARjs.Context.prototype._initArtoolkit = function(onCompleted){
  4421. var _this = this
  4422. // set this._artoolkitProjectionAxisTransformMatrix to change artoolkit projection matrix axis to match usual webgl one
  4423. this._artoolkitProjectionAxisTransformMatrix = new THREE.Matrix4()
  4424. this._artoolkitProjectionAxisTransformMatrix.multiply(new THREE.Matrix4().makeRotationY(Math.PI))
  4425. this._artoolkitProjectionAxisTransformMatrix.multiply(new THREE.Matrix4().makeRotationZ(Math.PI))
  4426. // get cameraParameters
  4427. var cameraParameters = new ARCameraParam(_this.parameters.cameraParametersUrl, function(){
  4428. // init controller
  4429. var arController = new ARController(_this.parameters.canvasWidth, _this.parameters.canvasHeight, cameraParameters);
  4430. _this.arController = arController
  4431. // honor this.parameters.imageSmoothingEnabled
  4432. arController.ctx.mozImageSmoothingEnabled = _this.parameters.imageSmoothingEnabled;
  4433. arController.ctx.webkitImageSmoothingEnabled = _this.parameters.imageSmoothingEnabled;
  4434. arController.ctx.msImageSmoothingEnabled = _this.parameters.imageSmoothingEnabled;
  4435. arController.ctx.imageSmoothingEnabled = _this.parameters.imageSmoothingEnabled;
  4436. // honor this.parameters.debug
  4437. if( _this.parameters.debug === true ){
  4438. arController.debugSetup();
  4439. arController.canvas.style.position = 'absolute'
  4440. arController.canvas.style.top = '0px'
  4441. arController.canvas.style.opacity = '0.6'
  4442. arController.canvas.style.pointerEvents = 'none'
  4443. arController.canvas.style.zIndex = '-1'
  4444. }
  4445. // setPatternDetectionMode
  4446. var detectionModes = {
  4447. 'color' : artoolkit.AR_TEMPLATE_MATCHING_COLOR,
  4448. 'color_and_matrix' : artoolkit.AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX,
  4449. 'mono' : artoolkit.AR_TEMPLATE_MATCHING_MONO,
  4450. 'mono_and_matrix' : artoolkit.AR_TEMPLATE_MATCHING_MONO_AND_MATRIX,
  4451. }
  4452. var detectionMode = detectionModes[_this.parameters.detectionMode]
  4453. console.assert(detectionMode !== undefined)
  4454. arController.setPatternDetectionMode(detectionMode);
  4455. // setMatrixCodeType
  4456. var matrixCodeTypes = {
  4457. '3x3' : artoolkit.AR_MATRIX_CODE_3x3,
  4458. '3x3_HAMMING63' : artoolkit.AR_MATRIX_CODE_3x3_HAMMING63,
  4459. '3x3_PARITY65' : artoolkit.AR_MATRIX_CODE_3x3_PARITY65,
  4460. '4x4' : artoolkit.AR_MATRIX_CODE_4x4,
  4461. '4x4_BCH_13_9_3': artoolkit.AR_MATRIX_CODE_4x4_BCH_13_9_3,
  4462. '4x4_BCH_13_5_5': artoolkit.AR_MATRIX_CODE_4x4_BCH_13_5_5,
  4463. }
  4464. var matrixCodeType = matrixCodeTypes[_this.parameters.matrixCodeType]
  4465. console.assert(matrixCodeType !== undefined)
  4466. arController.setMatrixCodeType(matrixCodeType);
  4467. // set the patternRatio for artoolkit
  4468. arController.setPattRatio(_this.parameters.patternRatio);
  4469. // set thresholding in artoolkit
  4470. // this seems to be the default
  4471. // arController.setThresholdMode(artoolkit.AR_LABELING_THRESH_MODE_MANUAL)
  4472. // adatative consume a LOT of cpu...
  4473. // arController.setThresholdMode(artoolkit.AR_LABELING_THRESH_MODE_AUTO_ADAPTIVE)
  4474. // arController.setThresholdMode(artoolkit.AR_LABELING_THRESH_MODE_AUTO_OTSU)
  4475. // notify
  4476. onCompleted()
  4477. })
  4478. return this
  4479. }
  4480. /**
  4481. * return the projection matrix
  4482. */
  4483. ARjs.Context.prototype.getProjectionMatrix = function(srcElement){
  4484. // FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix
  4485. // keep a backward compatibility with a console.warn
  4486. console.assert( this.parameters.trackingBackend === 'artoolkit' )
  4487. console.assert(this.arController, 'arController MUST be initialized to call this function')
  4488. // get projectionMatrixArr from artoolkit
  4489. var projectionMatrixArr = this.arController.getCameraMatrix();
  4490. var projectionMatrix = new THREE.Matrix4().fromArray(projectionMatrixArr)
  4491. // apply context._axisTransformMatrix - change artoolkit axis to match usual webgl one
  4492. projectionMatrix.multiply(this._artoolkitProjectionAxisTransformMatrix)
  4493. // return the result
  4494. return projectionMatrix
  4495. }
  4496. ARjs.Context.prototype._updateArtoolkit = function(srcElement){
  4497. this.arController.process(srcElement)
  4498. }
  4499. //////////////////////////////////////////////////////////////////////////////
  4500. // aruco specific
  4501. //////////////////////////////////////////////////////////////////////////////
  4502. ARjs.Context.prototype._initAruco = function(onCompleted){
  4503. this.arucoContext = new THREEx.ArucoContext()
  4504. // honor this.parameters.canvasWidth/.canvasHeight
  4505. this.arucoContext.canvas.width = this.parameters.canvasWidth
  4506. this.arucoContext.canvas.height = this.parameters.canvasHeight
  4507. // honor this.parameters.imageSmoothingEnabled
  4508. var context = this.arucoContext.canvas.getContext('2d')
  4509. // context.mozImageSmoothingEnabled = this.parameters.imageSmoothingEnabled;
  4510. context.webkitImageSmoothingEnabled = this.parameters.imageSmoothingEnabled;
  4511. context.msImageSmoothingEnabled = this.parameters.imageSmoothingEnabled;
  4512. context.imageSmoothingEnabled = this.parameters.imageSmoothingEnabled;
  4513. setTimeout(function(){
  4514. onCompleted()
  4515. }, 0)
  4516. }
  4517. ARjs.Context.prototype._updateAruco = function(srcElement){
  4518. // console.log('update aruco here')
  4519. var _this = this
  4520. var arMarkersControls = this._arMarkersControls
  4521. var detectedMarkers = this.arucoContext.detect(srcElement)
  4522. detectedMarkers.forEach(function(detectedMarker){
  4523. var foundControls = null
  4524. for(var i = 0; i < arMarkersControls.length; i++){
  4525. console.assert( arMarkersControls[i].parameters.type === 'barcode' )
  4526. if( arMarkersControls[i].parameters.barcodeValue === detectedMarker.id ){
  4527. foundControls = arMarkersControls[i]
  4528. break;
  4529. }
  4530. }
  4531. if( foundControls === null ) return
  4532. var tmpObject3d = new THREE.Object3D
  4533. _this.arucoContext.updateObject3D(tmpObject3d, foundControls._arucoPosit, foundControls.parameters.size, detectedMarker);
  4534. tmpObject3d.updateMatrix()
  4535. foundControls.updateWithModelViewMatrix(tmpObject3d.matrix)
  4536. })
  4537. }
  4538. //////////////////////////////////////////////////////////////////////////////
  4539. // tango specific
  4540. //////////////////////////////////////////////////////////////////////////////
  4541. ARjs.Context.prototype._initTango = function(onCompleted){
  4542. var _this = this
  4543. // check webvr is available
  4544. if (navigator.getVRDisplays){
  4545. // do nothing
  4546. } else if (navigator.getVRDevices){
  4547. alert("Your browser supports WebVR but not the latest version. See <a href='http://webvr.info'>webvr.info</a> for more info.");
  4548. } else {
  4549. alert("Your browser does not support WebVR. See <a href='http://webvr.info'>webvr.info</a> for assistance.");
  4550. }
  4551. this._tangoContext = {
  4552. vrDisplay: null,
  4553. vrPointCloud: null,
  4554. frameData: new VRFrameData(),
  4555. }
  4556. // get vrDisplay
  4557. navigator.getVRDisplays().then(function (vrDisplays){
  4558. if( vrDisplays.length === 0 ) alert('no vrDisplays available')
  4559. var vrDisplay = _this._tangoContext.vrDisplay = vrDisplays[0]
  4560. console.log('vrDisplays.displayName :', vrDisplay.displayName)
  4561. // init vrPointCloud
  4562. if( vrDisplay.displayName === "Tango VR Device" ){
  4563. _this._tangoContext.vrPointCloud = new THREE.WebAR.VRPointCloud(vrDisplay, true)
  4564. }
  4565. // NOTE it doesnt seem necessary and it fails on tango
  4566. // var canvasElement = document.createElement('canvas')
  4567. // document.body.appendChild(canvasElement)
  4568. // _this._tangoContext.requestPresent([{ source: canvasElement }]).then(function(){
  4569. // console.log('vrdisplay request accepted')
  4570. // });
  4571. onCompleted()
  4572. });
  4573. }
  4574. ARjs.Context.prototype._updateTango = function(srcElement){
  4575. // console.log('update aruco here')
  4576. var _this = this
  4577. var arMarkersControls = this._arMarkersControls
  4578. var tangoContext= this._tangoContext
  4579. var vrDisplay = this._tangoContext.vrDisplay
  4580. // check vrDisplay is already initialized
  4581. if( vrDisplay === null ) return
  4582. // Update the point cloud. Only if the point cloud will be shown the geometry is also updated.
  4583. if( vrDisplay.displayName === "Tango VR Device" ){
  4584. var showPointCloud = true
  4585. var pointsToSkip = 0
  4586. _this._tangoContext.vrPointCloud.update(showPointCloud, pointsToSkip, true)
  4587. }
  4588. if( this._arMarkersControls.length === 0 ) return
  4589. // TODO here do a fake search on barcode/1001 ?
  4590. var foundControls = this._arMarkersControls[0]
  4591. var frameData = this._tangoContext.frameData
  4592. // read frameData
  4593. vrDisplay.getFrameData(frameData);
  4594. if( frameData.pose.position === null ) return
  4595. if( frameData.pose.orientation === null ) return
  4596. // create cameraTransformMatrix
  4597. var position = new THREE.Vector3().fromArray(frameData.pose.position)
  4598. var quaternion = new THREE.Quaternion().fromArray(frameData.pose.orientation)
  4599. var scale = new THREE.Vector3(1,1,1)
  4600. var cameraTransformMatrix = new THREE.Matrix4().compose(position, quaternion, scale)
  4601. // compute modelViewMatrix from cameraTransformMatrix
  4602. var modelViewMatrix = new THREE.Matrix4()
  4603. modelViewMatrix.getInverse( cameraTransformMatrix )
  4604. foundControls.updateWithModelViewMatrix(modelViewMatrix)
  4605. // console.log('position', position)
  4606. // if( position.x !== 0 || position.y !== 0 || position.z !== 0 ){
  4607. // console.log('vrDisplay tracking')
  4608. // }else{
  4609. // console.log('vrDisplay NOT tracking')
  4610. // }
  4611. }
  4612. var ARjs = ARjs || {}
  4613. var THREEx = THREEx || {}
  4614. /**
  4615. * ArToolkitProfile helps you build parameters for artoolkit
  4616. * - it is fully independent of the rest of the code
  4617. * - all the other classes are still expecting normal parameters
  4618. * - you can use this class to understand how to tune your specific usecase
  4619. * - it is made to help people to build parameters without understanding all the underlying details.
  4620. */
  4621. ARjs.Profile = THREEx.ArToolkitProfile = function(){
  4622. this.reset()
  4623. this.performance('default')
  4624. }
  4625. ARjs.Profile.prototype._guessPerformanceLabel = function() {
  4626. var isMobile = navigator.userAgent.match(/Android/i)
  4627. || navigator.userAgent.match(/webOS/i)
  4628. || navigator.userAgent.match(/iPhone/i)
  4629. || navigator.userAgent.match(/iPad/i)
  4630. || navigator.userAgent.match(/iPod/i)
  4631. || navigator.userAgent.match(/BlackBerry/i)
  4632. || navigator.userAgent.match(/Windows Phone/i)
  4633. ? true : false
  4634. if( isMobile === true ){
  4635. return 'phone-normal'
  4636. }
  4637. return 'desktop-normal'
  4638. }
  4639. //////////////////////////////////////////////////////////////////////////////
  4640. // Code Separator
  4641. //////////////////////////////////////////////////////////////////////////////
  4642. /**
  4643. * reset all parameters
  4644. */
  4645. ARjs.Profile.prototype.reset = function () {
  4646. this.sourceParameters = {
  4647. // to read from the webcam
  4648. sourceType : 'webcam',
  4649. }
  4650. this.contextParameters = {
  4651. cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat',
  4652. detectionMode: 'mono',
  4653. }
  4654. this.defaultMarkerParameters = {
  4655. type : 'pattern',
  4656. patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro',
  4657. changeMatrixMode: 'modelViewMatrix',
  4658. }
  4659. return this
  4660. };
  4661. //////////////////////////////////////////////////////////////////////////////
  4662. // Performance
  4663. //////////////////////////////////////////////////////////////////////////////
  4664. ARjs.Profile.prototype.performance = function(label) {
  4665. if( label === 'default' ){
  4666. label = this._guessPerformanceLabel()
  4667. }
  4668. if( label === 'desktop-fast' ){
  4669. this.contextParameters.canvasWidth = 640*3
  4670. this.contextParameters.canvasHeight = 480*3
  4671. this.contextParameters.maxDetectionRate = 30
  4672. }else if( label === 'desktop-normal' ){
  4673. this.contextParameters.canvasWidth = 640
  4674. this.contextParameters.canvasHeight = 480
  4675. this.contextParameters.maxDetectionRate = 60
  4676. }else if( label === 'phone-normal' ){
  4677. this.contextParameters.canvasWidth = 80*4
  4678. this.contextParameters.canvasHeight = 60*4
  4679. this.contextParameters.maxDetectionRate = 30
  4680. }else if( label === 'phone-slow' ){
  4681. this.contextParameters.canvasWidth = 80*3
  4682. this.contextParameters.canvasHeight = 60*3
  4683. this.contextParameters.maxDetectionRate = 30
  4684. }else {
  4685. console.assert(false, 'unknonwn label '+label)
  4686. }
  4687. return this
  4688. }
  4689. //////////////////////////////////////////////////////////////////////////////
  4690. // Marker
  4691. //////////////////////////////////////////////////////////////////////////////
  4692. ARjs.Profile.prototype.defaultMarker = function (trackingBackend) {
  4693. trackingBackend = trackingBackend || this.contextParameters.trackingBackend
  4694. if( trackingBackend === 'artoolkit' ){
  4695. this.contextParameters.detectionMode = 'mono'
  4696. this.defaultMarkerParameters.type = 'pattern'
  4697. this.defaultMarkerParameters.patternUrl = THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro'
  4698. }else if( trackingBackend === 'aruco' ){
  4699. this.contextParameters.detectionMode = 'mono'
  4700. this.defaultMarkerParameters.type = 'barcode'
  4701. this.defaultMarkerParameters.barcodeValue = 1001
  4702. }else if( trackingBackend === 'tango' ){
  4703. // FIXME temporary placeholder - to reevaluate later
  4704. this.defaultMarkerParameters.type = 'barcode'
  4705. this.defaultMarkerParameters.barcodeValue = 1001
  4706. }else console.assert(false)
  4707. return this
  4708. }
  4709. //////////////////////////////////////////////////////////////////////////////
  4710. // Source
  4711. //////////////////////////////////////////////////////////////////////////////
  4712. ARjs.Profile.prototype.sourceWebcam = function () {
  4713. this.sourceParameters.sourceType = 'webcam'
  4714. delete this.sourceParameters.sourceUrl
  4715. return this
  4716. }
  4717. ARjs.Profile.prototype.sourceVideo = function (url) {
  4718. this.sourceParameters.sourceType = 'video'
  4719. this.sourceParameters.sourceUrl = url
  4720. return this
  4721. }
  4722. ARjs.Profile.prototype.sourceImage = function (url) {
  4723. this.sourceParameters.sourceType = 'image'
  4724. this.sourceParameters.sourceUrl = url
  4725. return this
  4726. }
  4727. //////////////////////////////////////////////////////////////////////////////
  4728. // trackingBackend
  4729. //////////////////////////////////////////////////////////////////////////////
  4730. ARjs.Profile.prototype.trackingBackend = function (trackingBackend) {
  4731. console.warn('stop profile.trackingBackend() obsolete function. use .trackingMethod instead')
  4732. this.contextParameters.trackingBackend = trackingBackend
  4733. return this
  4734. }
  4735. //////////////////////////////////////////////////////////////////////////////
  4736. // trackingBackend
  4737. //////////////////////////////////////////////////////////////////////////////
  4738. ARjs.Profile.prototype.changeMatrixMode = function (changeMatrixMode) {
  4739. this.defaultMarkerParameters.changeMatrixMode = changeMatrixMode
  4740. return this
  4741. }
  4742. //////////////////////////////////////////////////////////////////////////////
  4743. // trackingBackend
  4744. //////////////////////////////////////////////////////////////////////////////
  4745. ARjs.Profile.prototype.trackingMethod = function (trackingMethod) {
  4746. var data = ARjs.Utils.parseTrackingMethod(trackingMethod)
  4747. this.defaultMarkerParameters.markersAreaEnabled = data.markersAreaEnabled
  4748. this.contextParameters.trackingBackend = data.trackingBackend
  4749. return this
  4750. }
  4751. /**
  4752. * check if the profile is valid. Throw an exception is not valid
  4753. */
  4754. ARjs.Profile.prototype.checkIfValid = function () {
  4755. if( this.contextParameters.trackingBackend === 'tango' ){
  4756. this.sourceImage(THREEx.ArToolkitContext.baseURL + '../data/images/img.jpg')
  4757. }
  4758. return this
  4759. }
  4760. var ARjs = ARjs || {}
  4761. var THREEx = THREEx || {}
  4762. ARjs.Source = THREEx.ArToolkitSource = function(parameters){
  4763. var _this = this
  4764. this.ready = false
  4765. this.domElement = null
  4766. // handle default parameters
  4767. this.parameters = {
  4768. // type of source - ['webcam', 'image', 'video']
  4769. sourceType : 'webcam',
  4770. // url of the source - valid if sourceType = image|video
  4771. sourceUrl : null,
  4772. // Device id of the camera to use (optional)
  4773. deviceId : null,
  4774. // resolution of at which we initialize in the source image
  4775. sourceWidth: 640,
  4776. sourceHeight: 480,
  4777. // resolution displayed for the source
  4778. displayWidth: 640,
  4779. displayHeight: 480,
  4780. }
  4781. //////////////////////////////////////////////////////////////////////////////
  4782. // setParameters
  4783. //////////////////////////////////////////////////////////////////////////////
  4784. setParameters(parameters)
  4785. function setParameters(parameters){
  4786. if( parameters === undefined ) return
  4787. for( var key in parameters ){
  4788. var newValue = parameters[ key ]
  4789. if( newValue === undefined ){
  4790. console.warn( "THREEx.ArToolkitSource: '" + key + "' parameter is undefined." )
  4791. continue
  4792. }
  4793. var currentValue = _this.parameters[ key ]
  4794. if( currentValue === undefined ){
  4795. console.warn( "THREEx.ArToolkitSource: '" + key + "' is not a property of this material." )
  4796. continue
  4797. }
  4798. _this.parameters[ key ] = newValue
  4799. }
  4800. }
  4801. }
  4802. //////////////////////////////////////////////////////////////////////////////
  4803. // Code Separator
  4804. //////////////////////////////////////////////////////////////////////////////
  4805. ARjs.Source.prototype.init = function(onReady, onError){
  4806. var _this = this
  4807. if( this.parameters.sourceType === 'image' ){
  4808. var domElement = this._initSourceImage(onSourceReady, onError)
  4809. }else if( this.parameters.sourceType === 'video' ){
  4810. var domElement = this._initSourceVideo(onSourceReady, onError)
  4811. }else if( this.parameters.sourceType === 'webcam' ){
  4812. // var domElement = this._initSourceWebcamOld(onSourceReady)
  4813. var domElement = this._initSourceWebcam(onSourceReady, onError)
  4814. }else{
  4815. console.assert(false)
  4816. }
  4817. // attach
  4818. this.domElement = domElement
  4819. this.domElement.style.position = 'absolute'
  4820. this.domElement.style.top = '0px'
  4821. this.domElement.style.left = '0px'
  4822. this.domElement.style.zIndex = '-2'
  4823. return this
  4824. function onSourceReady(){
  4825. document.body.appendChild(_this.domElement);
  4826. _this.ready = true
  4827. onReady && onReady()
  4828. }
  4829. }
  4830. ////////////////////////////////////////////////////////////////////////////////
  4831. // init image source
  4832. ////////////////////////////////////////////////////////////////////////////////
  4833. ARjs.Source.prototype._initSourceImage = function(onReady) {
  4834. // TODO make it static
  4835. var domElement = document.createElement('img')
  4836. domElement.src = this.parameters.sourceUrl
  4837. domElement.width = this.parameters.sourceWidth
  4838. domElement.height = this.parameters.sourceHeight
  4839. domElement.style.width = this.parameters.displayWidth+'px'
  4840. domElement.style.height = this.parameters.displayHeight+'px'
  4841. // wait until the video stream is ready
  4842. var interval = setInterval(function() {
  4843. if (!domElement.naturalWidth) return;
  4844. onReady()
  4845. clearInterval(interval)
  4846. }, 1000/50);
  4847. return domElement
  4848. }
  4849. ////////////////////////////////////////////////////////////////////////////////
  4850. // init video source
  4851. ////////////////////////////////////////////////////////////////////////////////
  4852. ARjs.Source.prototype._initSourceVideo = function(onReady) {
  4853. // TODO make it static
  4854. var domElement = document.createElement('video');
  4855. domElement.src = this.parameters.sourceUrl
  4856. domElement.style.objectFit = 'initial'
  4857. domElement.autoplay = true;
  4858. domElement.webkitPlaysinline = true;
  4859. domElement.controls = false;
  4860. domElement.loop = true;
  4861. domElement.muted = true
  4862. // trick to trigger the video on android
  4863. document.body.addEventListener('click', function onClick(){
  4864. document.body.removeEventListener('click', onClick);
  4865. domElement.play()
  4866. })
  4867. domElement.width = this.parameters.sourceWidth
  4868. domElement.height = this.parameters.sourceHeight
  4869. domElement.style.width = this.parameters.displayWidth+'px'
  4870. domElement.style.height = this.parameters.displayHeight+'px'
  4871. // wait until the video stream is ready
  4872. var interval = setInterval(function() {
  4873. if (!domElement.videoWidth) return;
  4874. onReady()
  4875. clearInterval(interval)
  4876. }, 1000/50);
  4877. return domElement
  4878. }
  4879. ////////////////////////////////////////////////////////////////////////////////
  4880. // handle webcam source
  4881. ////////////////////////////////////////////////////////////////////////////////
  4882. ARjs.Source.prototype._initSourceWebcam = function(onReady, onError) {
  4883. var _this = this
  4884. // init default value
  4885. onError = onError || function(error){
  4886. alert('Webcam Error\nName: '+error.name + '\nMessage: '+error.message)
  4887. }
  4888. var domElement = document.createElement('video');
  4889. domElement.setAttribute('autoplay', '');
  4890. domElement.setAttribute('muted', '');
  4891. domElement.setAttribute('playsinline', '');
  4892. domElement.style.width = this.parameters.displayWidth+'px'
  4893. domElement.style.height = this.parameters.displayHeight+'px'
  4894. // check API is available
  4895. if (navigator.mediaDevices === undefined
  4896. || navigator.mediaDevices.enumerateDevices === undefined
  4897. || navigator.mediaDevices.getUserMedia === undefined ){
  4898. if( navigator.mediaDevices === undefined ) var fctName = 'navigator.mediaDevices'
  4899. else if( navigator.mediaDevices.enumerateDevices === undefined ) var fctName = 'navigator.mediaDevices.enumerateDevices'
  4900. else if( navigator.mediaDevices.getUserMedia === undefined ) var fctName = 'navigator.mediaDevices.getUserMedia'
  4901. else console.assert(false)
  4902. onError({
  4903. name: '',
  4904. message: 'WebRTC issue-! '+fctName+' not present in your browser'
  4905. })
  4906. return null
  4907. }
  4908. // get available devices
  4909. navigator.mediaDevices.enumerateDevices().then(function(devices) {
  4910. var userMediaConstraints = {
  4911. audio: false,
  4912. video: {
  4913. facingMode: 'environment',
  4914. width: {
  4915. ideal: _this.parameters.sourceWidth,
  4916. // min: 1024,
  4917. // max: 1920
  4918. },
  4919. height: {
  4920. ideal: _this.parameters.sourceHeight,
  4921. // min: 776,
  4922. // max: 1080
  4923. }
  4924. }
  4925. }
  4926. if (null !== _this.parameters.deviceId) {
  4927. userMediaConstraints.video.deviceId = {
  4928. exact: _this.parameters.deviceId
  4929. };
  4930. }
  4931. // get a device which satisfy the constraints
  4932. navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream) {
  4933. // set the .src of the domElement
  4934. domElement.srcObject = stream;
  4935. // to start the video, when it is possible to start it only on userevent. like in android
  4936. document.body.addEventListener('click', function(){
  4937. domElement.play();
  4938. })
  4939. // domElement.play();
  4940. // TODO listen to loadedmetadata instead
  4941. // wait until the video stream is ready
  4942. var interval = setInterval(function() {
  4943. if (!domElement.videoWidth) return;
  4944. onReady()
  4945. clearInterval(interval)
  4946. }, 1000/50);
  4947. }).catch(function(error) {
  4948. onError({
  4949. name: error.name,
  4950. message: error.message
  4951. });
  4952. });
  4953. }).catch(function(error) {
  4954. onError({
  4955. message: error.message
  4956. });
  4957. });
  4958. return domElement
  4959. }
  4960. //////////////////////////////////////////////////////////////////////////////
  4961. // Handle Mobile Torch
  4962. //////////////////////////////////////////////////////////////////////////////
  4963. ARjs.Source.prototype.hasMobileTorch = function(){
  4964. var stream = arToolkitSource.domElement.srcObject
  4965. if( stream instanceof MediaStream === false ) return false
  4966. if( this._currentTorchStatus === undefined ){
  4967. this._currentTorchStatus = false
  4968. }
  4969. var videoTrack = stream.getVideoTracks()[0];
  4970. // if videoTrack.getCapabilities() doesnt exist, return false now
  4971. if( videoTrack.getCapabilities === undefined ) return false
  4972. var capabilities = videoTrack.getCapabilities()
  4973. return capabilities.torch ? true : false
  4974. }
  4975. /**
  4976. * toggle the flash/torch of the mobile fun if applicable.
  4977. * Great post about it https://www.oberhofer.co/mediastreamtrack-and-its-capabilities/
  4978. */
  4979. ARjs.Source.prototype.toggleMobileTorch = function(){
  4980. // sanity check
  4981. console.assert(this.hasMobileTorch() === true)
  4982. var stream = arToolkitSource.domElement.srcObject
  4983. if( stream instanceof MediaStream === false ){
  4984. alert('enabling mobile torch is available only on webcam')
  4985. return
  4986. }
  4987. if( this._currentTorchStatus === undefined ){
  4988. this._currentTorchStatus = false
  4989. }
  4990. var videoTrack = stream.getVideoTracks()[0];
  4991. var capabilities = videoTrack.getCapabilities()
  4992. if( !capabilities.torch ){
  4993. alert('no mobile torch is available on your camera')
  4994. return
  4995. }
  4996. this._currentTorchStatus = this._currentTorchStatus === false ? true : false
  4997. videoTrack.applyConstraints({
  4998. advanced: [{
  4999. torch: this._currentTorchStatus
  5000. }]
  5001. }).catch(function(error){
  5002. console.log(error)
  5003. });
  5004. }
  5005. ARjs.Source.prototype.domElementWidth = function(){
  5006. return parseInt(this.domElement.style.width)
  5007. }
  5008. ARjs.Source.prototype.domElementHeight = function(){
  5009. return parseInt(this.domElement.style.height)
  5010. }
  5011. ////////////////////////////////////////////////////////////////////////////////
  5012. // handle resize
  5013. ////////////////////////////////////////////////////////////////////////////////
  5014. ARjs.Source.prototype.onResizeElement = function(){
  5015. var _this = this
  5016. var screenWidth = window.innerWidth
  5017. var screenHeight = window.innerHeight
  5018. // sanity check
  5019. console.assert( arguments.length === 0 )
  5020. // compute sourceWidth, sourceHeight
  5021. if( this.domElement.nodeName === "IMG" ){
  5022. var sourceWidth = this.domElement.naturalWidth
  5023. var sourceHeight = this.domElement.naturalHeight
  5024. }else if( this.domElement.nodeName === "VIDEO" ){
  5025. var sourceWidth = this.domElement.videoWidth
  5026. var sourceHeight = this.domElement.videoHeight
  5027. }else{
  5028. console.assert(false)
  5029. }
  5030. // compute sourceAspect
  5031. var sourceAspect = sourceWidth / sourceHeight
  5032. // compute screenAspect
  5033. var screenAspect = screenWidth / screenHeight
  5034. // if screenAspect < sourceAspect, then change the width, else change the height
  5035. if( screenAspect < sourceAspect ){
  5036. // compute newWidth and set .width/.marginLeft
  5037. var newWidth = sourceAspect * screenHeight
  5038. this.domElement.style.width = newWidth+'px'
  5039. this.domElement.style.marginLeft = -(newWidth-screenWidth)/2+'px'
  5040. // init style.height/.marginTop to normal value
  5041. this.domElement.style.height = screenHeight+'px'
  5042. this.domElement.style.marginTop = '0px'
  5043. }else{
  5044. // compute newHeight and set .height/.marginTop
  5045. var newHeight = 1 / (sourceAspect / screenWidth)
  5046. this.domElement.style.height = newHeight+'px'
  5047. this.domElement.style.marginTop = -(newHeight-screenHeight)/2+'px'
  5048. // init style.width/.marginLeft to normal value
  5049. this.domElement.style.width = screenWidth+'px'
  5050. this.domElement.style.marginLeft = '0px'
  5051. }
  5052. }
  5053. /*
  5054. ARjs.Source.prototype.copyElementSizeTo = function(otherElement){
  5055. otherElement.style.width = this.domElement.style.width
  5056. otherElement.style.height = this.domElement.style.height
  5057. otherElement.style.marginLeft = this.domElement.style.marginLeft
  5058. otherElement.style.marginTop = this.domElement.style.marginTop
  5059. }
  5060. */
  5061. ARjs.Source.prototype.copyElementSizeTo = function(otherElement){
  5062. if (window.innerWidth > window.innerHeight)
  5063. {
  5064. //landscape
  5065. otherElement.style.width = this.domElement.style.width
  5066. otherElement.style.height = this.domElement.style.height
  5067. otherElement.style.marginLeft = this.domElement.style.marginLeft
  5068. otherElement.style.marginTop = this.domElement.style.marginTop
  5069. }
  5070. else {
  5071. //portrait
  5072. otherElement.style.height = this.domElement.style.height
  5073. otherElement.style.width = (parseInt(otherElement.style.height) * 4/3)+"px";
  5074. otherElement.style.marginLeft = ((window.innerWidth- parseInt(otherElement.style.width))/2)+"px";
  5075. otherElement.style.marginTop = 0;
  5076. }
  5077. }
  5078. //////////////////////////////////////////////////////////////////////////////
  5079. // Code Separator
  5080. //////////////////////////////////////////////////////////////////////////////
  5081. ARjs.Source.prototype.copySizeTo = function(){
  5082. console.warn('obsolete function arToolkitSource.copySizeTo. Use arToolkitSource.copyElementSizeTo' )
  5083. this.copyElementSizeTo.apply(this, arguments)
  5084. }
  5085. //////////////////////////////////////////////////////////////////////////////
  5086. // Code Separator
  5087. //////////////////////////////////////////////////////////////////////////////
  5088. ARjs.Source.prototype.onResize = function(arToolkitContext, renderer, camera){
  5089. if( arguments.length !== 3 ){
  5090. console.warn('obsolete function arToolkitSource.onResize. Use arToolkitSource.onResizeElement' )
  5091. return this.onResizeElement.apply(this, arguments)
  5092. }
  5093. var trackingBackend = arToolkitContext.parameters.trackingBackend
  5094. // RESIZE DOMELEMENT
  5095. if( trackingBackend === 'artoolkit' ){
  5096. this.onResizeElement()
  5097. var isAframe = renderer.domElement.dataset.aframeCanvas ? true : false
  5098. if( isAframe === false ){
  5099. this.copyElementSizeTo(renderer.domElement)
  5100. }else{
  5101. }
  5102. if( arToolkitContext.arController !== null ){
  5103. this.copyElementSizeTo(arToolkitContext.arController.canvas)
  5104. }
  5105. }else if( trackingBackend === 'aruco' ){
  5106. this.onResizeElement()
  5107. this.copyElementSizeTo(renderer.domElement)
  5108. this.copyElementSizeTo(arToolkitContext.arucoContext.canvas)
  5109. }else if( trackingBackend === 'tango' ){
  5110. renderer.setSize( window.innerWidth, window.innerHeight )
  5111. }else console.assert(false, 'unhandled trackingBackend '+trackingBackend)
  5112. // UPDATE CAMERA
  5113. if( trackingBackend === 'artoolkit' ){
  5114. if( arToolkitContext.arController !== null ){
  5115. camera.projectionMatrix.copy( arToolkitContext.getProjectionMatrix() );
  5116. }
  5117. }else if( trackingBackend === 'aruco' ){
  5118. camera.aspect = renderer.domElement.width / renderer.domElement.height;
  5119. camera.updateProjectionMatrix();
  5120. }else if( trackingBackend === 'tango' ){
  5121. var vrDisplay = arToolkitContext._tangoContext.vrDisplay
  5122. // make camera fit vrDisplay
  5123. if( vrDisplay && vrDisplay.displayName === "Tango VR Device" ) THREE.WebAR.resizeVRSeeThroughCamera(vrDisplay, camera)
  5124. }else console.assert(false, 'unhandled trackingBackend '+trackingBackend)
  5125. }
  5126. var THREEx = THREEx || {}
  5127. THREEx.ArVideoInWebgl = function(videoTexture){
  5128. var _this = this
  5129. //////////////////////////////////////////////////////////////////////////////
  5130. // plane always in front of the camera, exactly as big as the viewport
  5131. //////////////////////////////////////////////////////////////////////////////
  5132. var geometry = new THREE.PlaneGeometry(2, 2);
  5133. var material = new THREE.MeshBasicMaterial({
  5134. // map : new THREE.TextureLoader().load('images/water.jpg'),
  5135. map : videoTexture,
  5136. // side: THREE.DoubleSide,
  5137. // opacity: 0.5,
  5138. // color: 'pink',
  5139. // transparent: true,
  5140. });
  5141. var seethruPlane = new THREE.Mesh(geometry, material);
  5142. this.object3d = seethruPlane
  5143. // scene.add(seethruPlane);
  5144. // arToolkitSource.domElement.style.visibility = 'hidden'
  5145. // TODO extract the fov from the projectionMatrix
  5146. // camera.fov = 43.1
  5147. this.update = function(camera){
  5148. camera.updateMatrixWorld(true)
  5149. // get seethruPlane position
  5150. var position = new THREE.Vector3(-0,0,-20) // TODO how come you got that offset on x ???
  5151. var position = new THREE.Vector3(-0,0,-20) // TODO how come you got that offset on x ???
  5152. seethruPlane.position.copy(position)
  5153. camera.localToWorld(seethruPlane.position)
  5154. // get seethruPlane quaternion
  5155. camera.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
  5156. seethruPlane.quaternion.copy( camera.quaternion )
  5157. // extract the fov from the projectionMatrix
  5158. var fov = THREE.Math.radToDeg(Math.atan(1/camera.projectionMatrix.elements[5]))*2;
  5159. // console.log('fov', fov)
  5160. var elementWidth = parseFloat( arToolkitSource.domElement.style.width.replace(/px$/,''), 10 )
  5161. var elementHeight = parseFloat( arToolkitSource.domElement.style.height.replace(/px$/,''), 10 )
  5162. var aspect = elementWidth / elementHeight
  5163. // camera.fov = fov
  5164. // if( vrDisplay.isPresenting ){
  5165. // fov *= 2
  5166. // aspect *= 2
  5167. // }
  5168. // get seethruPlane height relative to fov
  5169. seethruPlane.scale.y = Math.tan(THREE.Math.DEG2RAD * fov/2)*position.length()
  5170. // get seethruPlane aspect
  5171. seethruPlane.scale.x = seethruPlane.scale.y * aspect
  5172. }
  5173. //////////////////////////////////////////////////////////////////////////////
  5174. // Code Separator
  5175. //////////////////////////////////////////////////////////////////////////////
  5176. // var video = arToolkitSource.domElement;
  5177. //
  5178. // window.addEventListener('resize', function(){
  5179. // updateSeeThruAspectUv(seethruPlane)
  5180. // })
  5181. // video.addEventListener('canplaythrough', function(){
  5182. // updateSeeThruAspectUv(seethruPlane)
  5183. // })
  5184. // function updateSeeThruAspectUv(plane){
  5185. //
  5186. // // if video isnt yet ready to play
  5187. // if( video.videoWidth === 0 || video.videoHeight === 0 ) return
  5188. //
  5189. // var faceVertexUvs = plane.geometry.faceVertexUvs[0]
  5190. // var screenAspect = window.innerWidth / window.innerHeight
  5191. // var videoAspect = video.videoWidth / video.videoHeight
  5192. //
  5193. // plane.geometry.uvsNeedUpdate = true
  5194. // if( screenAspect >= videoAspect ){
  5195. // var actualHeight = videoAspect / screenAspect;
  5196. // // faceVertexUvs y 0
  5197. // faceVertexUvs[0][1].y = 0.5 - actualHeight/2
  5198. // faceVertexUvs[1][0].y = 0.5 - actualHeight/2
  5199. // faceVertexUvs[1][1].y = 0.5 - actualHeight/2
  5200. // // faceVertexUvs y 1
  5201. // faceVertexUvs[0][0].y = 0.5 + actualHeight/2
  5202. // faceVertexUvs[0][2].y = 0.5 + actualHeight/2
  5203. // faceVertexUvs[1][2].y = 0.5 + actualHeight/2
  5204. // }else{
  5205. // var actualWidth = screenAspect / videoAspect;
  5206. // // faceVertexUvs x 0
  5207. // faceVertexUvs[0][0].x = 0.5 - actualWidth/2
  5208. // faceVertexUvs[0][1].x = 0.5 - actualWidth/2
  5209. // faceVertexUvs[1][0].x = 0.5 - actualWidth/2
  5210. //
  5211. // // faceVertexUvs x 1
  5212. // faceVertexUvs[0][2].x = 0.5 + actualWidth/2
  5213. // faceVertexUvs[1][1].x = 0.5 + actualWidth/2
  5214. // faceVertexUvs[1][2].x = 0.5 + actualWidth/2
  5215. // }
  5216. // }
  5217. }
  5218. var THREEx = THREEx || {}
  5219. // TODO this is useless - prefere arjs-HitTesting.js
  5220. /**
  5221. * - maybe support .onClickFcts in each object3d
  5222. * - seems an easy light layer for clickable object
  5223. * - up to
  5224. */
  5225. THREEx.HitTestingPlane = function(sourceElement){
  5226. this._sourceElement = sourceElement
  5227. // create _pickingScene
  5228. this._pickingScene = new THREE.Scene
  5229. // create _pickingPlane
  5230. var geometry = new THREE.PlaneGeometry(20,20,19,19).rotateX(-Math.PI/2)
  5231. // var geometry = new THREE.PlaneGeometry(20,20).rotateX(-Math.PI/2)
  5232. var material = new THREE.MeshBasicMaterial({
  5233. // opacity: 0.5,
  5234. // transparent: true,
  5235. wireframe: true
  5236. })
  5237. // material.visible = false
  5238. this._pickingPlane = new THREE.Mesh(geometry, material)
  5239. this._pickingScene.add(this._pickingPlane)
  5240. // Create pickingCamera
  5241. var fullWidth = parseInt(sourceElement.style.width)
  5242. var fullHeight = parseInt(sourceElement.style.height)
  5243. // TODO hardcoded fov - couch
  5244. this._pickingCamera = new THREE.PerspectiveCamera(42, fullWidth / fullHeight, 0.1, 30);
  5245. }
  5246. //////////////////////////////////////////////////////////////////////////////
  5247. // update function
  5248. //////////////////////////////////////////////////////////////////////////////
  5249. THREEx.HitTestingPlane.prototype.update = function(camera, pickingRoot, changeMatrixMode){
  5250. this.onResize()
  5251. if( changeMatrixMode === 'modelViewMatrix' ){
  5252. // set pickingPlane position
  5253. var pickingPlane = this._pickingPlane
  5254. pickingRoot.parent.updateMatrixWorld()
  5255. pickingPlane.matrix.copy(pickingRoot.parent.matrixWorld)
  5256. // set position/quaternion/scale from pickingPlane.matrix
  5257. pickingPlane.matrix.decompose(pickingPlane.position, pickingPlane.quaternion, pickingPlane.scale)
  5258. }else if( changeMatrixMode === 'cameraTransformMatrix' ){
  5259. // set pickingPlane position
  5260. var pickingCamera = this._pickingCamera
  5261. camera.updateMatrixWorld()
  5262. pickingCamera.matrix.copy(camera.matrixWorld)
  5263. // set position/quaternion/scale from pickingCamera.matrix
  5264. pickingCamera.matrix.decompose(pickingCamera.position, pickingCamera.quaternion, pickingCamera.scale)
  5265. }else console.assert(false)
  5266. // var position = this._pickingPlane.position
  5267. // console.log('pickingPlane position', position.x.toFixed(2), position.y.toFixed(2), position.z.toFixed(2))
  5268. // var position = this._pickingCamera.position
  5269. // console.log('his._pickingCamera position', position.x.toFixed(2), position.y.toFixed(2), position.z.toFixed(2))
  5270. }
  5271. //////////////////////////////////////////////////////////////////////////////
  5272. // resize camera
  5273. //////////////////////////////////////////////////////////////////////////////
  5274. THREEx.HitTestingPlane.prototype.onResize = function(){
  5275. var sourceElement = this._sourceElement
  5276. var pickingCamera = this._pickingCamera
  5277. // FIXME why using css here ??? not even computed style
  5278. // should get the size of the elment directly independantly
  5279. var fullWidth = parseInt(sourceElement.style.width)
  5280. var fullHeight = parseInt(sourceElement.style.height)
  5281. pickingCamera.aspect = fullWidth / fullHeight
  5282. pickingCamera.updateProjectionMatrix()
  5283. }
  5284. //////////////////////////////////////////////////////////////////////////////
  5285. // Perform test
  5286. //////////////////////////////////////////////////////////////////////////////
  5287. THREEx.HitTestingPlane.prototype.test = function(mouseX, mouseY){
  5288. // convert mouseX, mouseY to [-1, +1]
  5289. mouseX = (mouseX-0.5)*2
  5290. mouseY =-(mouseY-0.5)*2
  5291. this._pickingScene.updateMatrixWorld(true)
  5292. // compute intersections between mouseVector3 and pickingPlane
  5293. var raycaster = new THREE.Raycaster();
  5294. var mouseVector3 = new THREE.Vector3(mouseX, mouseY, 1);
  5295. raycaster.setFromCamera( mouseVector3, this._pickingCamera )
  5296. var intersects = raycaster.intersectObjects( [this._pickingPlane] )
  5297. if( intersects.length === 0 ) return null
  5298. // set new demoRoot position
  5299. var position = this._pickingPlane.worldToLocal( intersects[0].point.clone() )
  5300. // TODO here do a look at the camera ?
  5301. var quaternion = new THREE.Quaternion
  5302. var scale = new THREE.Vector3(1,1,1)//.multiplyScalar(1)
  5303. return {
  5304. position : position,
  5305. quaternion : quaternion,
  5306. scale : scale
  5307. }
  5308. }
  5309. //////////////////////////////////////////////////////////////////////////////
  5310. // render the pickingPlane for debug
  5311. //////////////////////////////////////////////////////////////////////////////
  5312. THREEx.HitTestingPlane.prototype.renderDebug = function(renderer){
  5313. // render sceneOrtho
  5314. renderer.render( this._pickingScene, this._pickingCamera )
  5315. }
  5316. var THREEx = THREEx || {}
  5317. /**
  5318. * @class
  5319. *
  5320. * @return {[type]} [description]
  5321. */
  5322. THREEx.HitTestingTango = function(arContext){
  5323. this._arContext = arContext
  5324. // seems to be the object bounding sphere for picking
  5325. this.boundingSphereRadius = 0.01
  5326. // default result scale
  5327. this.resultScale = new THREE.Vector3(1,1,1).multiplyScalar(1)
  5328. }
  5329. //////////////////////////////////////////////////////////////////////////////
  5330. // update function
  5331. //////////////////////////////////////////////////////////////////////////////
  5332. THREEx.HitTestingTango.prototype.update = function(){
  5333. }
  5334. //////////////////////////////////////////////////////////////////////////////
  5335. // Code Separator
  5336. //////////////////////////////////////////////////////////////////////////////
  5337. /**
  5338. * do the actual testing
  5339. *
  5340. * @param {ARjs.Context} arContext - context to use
  5341. * @param {Number} mouseX - mouse x coordinate in [0, 1]
  5342. * @param {Numer} mouseY - mouse y coordinate in [0, 1]
  5343. * @return {Object} - result
  5344. */
  5345. THREEx.HitTestingTango.prototype.test = function(mouseX, mouseY){
  5346. var vrDisplay = this._arContext._tangoContext.vrDisplay
  5347. if (vrDisplay === null ) return null
  5348. if( vrDisplay.displayName !== "Tango VR Device" ) return null
  5349. var pointAndPlane = vrDisplay.getPickingPointAndPlaneInPointCloud(mouseX, mouseY)
  5350. if( pointAndPlane == null ) {
  5351. console.warn('Could not retrieve the correct point and plane.')
  5352. return null
  5353. }
  5354. // FIXME not sure what this is
  5355. var boundingSphereRadius = 0.01
  5356. // the bigger the number the likeliest it crash chromium-webar
  5357. // Orient and position the model in the picking point according
  5358. // to the picking plane. The offset is half of the model size.
  5359. var object3d = new THREE.Object3D
  5360. THREE.WebAR.positionAndRotateObject3DWithPickingPointAndPlaneInPointCloud(
  5361. pointAndPlane, object3d, this.boundingSphereRadius
  5362. )
  5363. object3d.rotateZ(-Math.PI/2)
  5364. // return the result
  5365. var result = {
  5366. position : object3d.position,
  5367. quaternion : object3d.quaternion,
  5368. scale : this.resultScale,
  5369. }
  5370. return result
  5371. }
  5372. // @namespace
  5373. var ARjs = ARjs || {}
  5374. // TODO this is a controls... should i give the object3d here ?
  5375. // not according to 'no three.js dependancy'
  5376. /**
  5377. * Create an anchor in the real world
  5378. *
  5379. * @param {ARjs.Session} arSession - the session on which we create the anchor
  5380. * @param {Object} markerParameters - parameter of this anchor
  5381. */
  5382. ARjs.Anchor = function(arSession, markerParameters){
  5383. var _this = this
  5384. var arContext = arSession.arContext
  5385. var scene = arSession.parameters.scene
  5386. var camera = arSession.parameters.camera
  5387. this.arSession = arSession
  5388. this.parameters = markerParameters
  5389. // log to debug
  5390. console.log('ARjs.Anchor -', 'changeMatrixMode:', this.parameters.changeMatrixMode, '/ markersAreaEnabled:', markerParameters.markersAreaEnabled)
  5391. var markerRoot = new THREE.Group
  5392. scene.add(markerRoot)
  5393. // set controlledObject depending on changeMatrixMode
  5394. if( markerParameters.changeMatrixMode === 'modelViewMatrix' ){
  5395. var controlledObject = markerRoot
  5396. }else if( markerParameters.changeMatrixMode === 'cameraTransformMatrix' ){
  5397. var controlledObject = camera
  5398. }else console.assert(false)
  5399. if( markerParameters.markersAreaEnabled === false ){
  5400. var markerControls = new THREEx.ArMarkerControls(arContext, controlledObject, markerParameters)
  5401. this.controls = markerControls
  5402. }else{
  5403. // sanity check - MUST be a trackingBackend with markers
  5404. console.assert( arContext.parameters.trackingBackend === 'artoolkit' || arContext.parameters.trackingBackend === 'aruco' )
  5405. // honor markers-page-resolution for https://webxr.io/augmented-website
  5406. if( location.hash.substring(1).startsWith('markers-page-resolution=') === true ){
  5407. // get resolutionW/resolutionH from url
  5408. var markerPageResolution = location.hash.substring(1)
  5409. var matches = markerPageResolution.match(/markers-page-resolution=(\d+)x(\d+)/)
  5410. console.assert(matches.length === 3)
  5411. var resolutionW = parseInt(matches[1])
  5412. var resolutionH = parseInt(matches[2])
  5413. var arContext = arSession.arContext
  5414. // generate and store the ARjsMultiMarkerFile
  5415. ARjs.MarkersAreaUtils.storeMarkersAreaFileFromResolution(arContext.parameters.trackingBackend, resolutionW, resolutionH)
  5416. }
  5417. // if there is no ARjsMultiMarkerFile, build a default one
  5418. if( localStorage.getItem('ARjsMultiMarkerFile') === null ){
  5419. ARjs.MarkersAreaUtils.storeDefaultMultiMarkerFile(arContext.parameters.trackingBackend)
  5420. }
  5421. // get multiMarkerFile from localStorage
  5422. console.assert( localStorage.getItem('ARjsMultiMarkerFile') !== null )
  5423. var multiMarkerFile = localStorage.getItem('ARjsMultiMarkerFile')
  5424. // set controlledObject depending on changeMatrixMode
  5425. if( markerParameters.changeMatrixMode === 'modelViewMatrix' ){
  5426. var parent3D = scene
  5427. }else if( markerParameters.changeMatrixMode === 'cameraTransformMatrix' ){
  5428. var parent3D = camera
  5429. }else console.assert(false)
  5430. // build a multiMarkerControls
  5431. var multiMarkerControls = ARjs.MarkersAreaControls.fromJSON(arContext, parent3D, controlledObject, multiMarkerFile)
  5432. this.controls = multiMarkerControls
  5433. // honor markerParameters.changeMatrixMode
  5434. multiMarkerControls.parameters.changeMatrixMode = markerParameters.changeMatrixMode
  5435. // TODO put subMarkerControls visibility into an external file. with 2 handling for three.js and babylon.js
  5436. // create ArMarkerHelper - useful to debug - super three.js specific
  5437. var markerHelpers = []
  5438. multiMarkerControls.subMarkersControls.forEach(function(subMarkerControls){
  5439. // add an helper to visuable each sub-marker
  5440. var markerHelper = new THREEx.ArMarkerHelper(subMarkerControls)
  5441. markerHelper.object3d.visible = false
  5442. // subMarkerControls.object3d.add( markerHelper.object3d )
  5443. subMarkerControls.object3d.add( markerHelper.object3d )
  5444. // add it to markerHelpers
  5445. markerHelpers.push(markerHelper)
  5446. })
  5447. // define API specific to markersArea
  5448. this.markersArea = {}
  5449. this.markersArea.setSubMarkersVisibility = function(visible){
  5450. markerHelpers.forEach(function(markerHelper){
  5451. markerHelper.object3d.visible = visible
  5452. })
  5453. }
  5454. }
  5455. this.object3d = new THREE.Group()
  5456. //////////////////////////////////////////////////////////////////////////////
  5457. // THREEx.ArSmoothedControls
  5458. //////////////////////////////////////////////////////////////////////////////
  5459. var shouldBeSmoothed = true
  5460. if( arContext.parameters.trackingBackend === 'tango' ) shouldBeSmoothed = false
  5461. if( shouldBeSmoothed === true ){
  5462. // build a smoothedControls
  5463. var smoothedRoot = new THREE.Group()
  5464. scene.add(smoothedRoot)
  5465. var smoothedControls = new THREEx.ArSmoothedControls(smoothedRoot)
  5466. smoothedRoot.add(this.object3d)
  5467. }else{
  5468. markerRoot.add(this.object3d)
  5469. }
  5470. //////////////////////////////////////////////////////////////////////////////
  5471. // Code Separator
  5472. //////////////////////////////////////////////////////////////////////////////
  5473. this.update = function(){
  5474. // update _this.object3d.visible
  5475. _this.object3d.visible = _this.object3d.parent.visible
  5476. // console.log('controlledObject.visible', _this.object3d.parent.visible)
  5477. if( smoothedControls !== undefined ){
  5478. // update smoothedControls parameters depending on how many markers are visible in multiMarkerControls
  5479. if( multiMarkerControls !== undefined ){
  5480. multiMarkerControls.updateSmoothedControls(smoothedControls)
  5481. }
  5482. // update smoothedControls
  5483. smoothedControls.update(markerRoot)
  5484. }
  5485. }
  5486. }
  5487. // @namespace
  5488. var ARjs = ARjs || {}
  5489. /**
  5490. * Create an debug UI for an ARjs.Anchor
  5491. *
  5492. * @param {ARjs.Anchor} arAnchor - the anchor to user
  5493. */
  5494. ARjs.SessionDebugUI = function(arSession, tangoPointCloud){
  5495. var trackingBackend = arSession.arContext.parameters.trackingBackend
  5496. this.domElement = document.createElement('div')
  5497. this.domElement.style.color = 'rgba(0,0,0,0.9)'
  5498. this.domElement.style.backgroundColor = 'rgba(127,127,127,0.5)'
  5499. this.domElement.style.display = 'inline-block'
  5500. this.domElement.style.padding = '0.5em'
  5501. this.domElement.style.margin = '0.5em'
  5502. this.domElement.style.textAlign = 'left'
  5503. //////////////////////////////////////////////////////////////////////////////
  5504. // add title
  5505. //////////////////////////////////////////////////////////////////////////////
  5506. // var domElement = document.createElement('div')
  5507. // domElement.style.display = 'block'
  5508. // domElement.style.fontWeight = 'bold'
  5509. // domElement.style.fontSize = '120%'
  5510. // this.domElement.appendChild(domElement)
  5511. // domElement.innerHTML = 'AR.js Session Debug'
  5512. //////////////////////////////////////////////////////////////////////////////
  5513. // current-tracking-backend
  5514. //////////////////////////////////////////////////////////////////////////////
  5515. var domElement = document.createElement('span')
  5516. domElement.style.display = 'block'
  5517. this.domElement.appendChild(domElement)
  5518. domElement.innerHTML = '<b>trackingBackend</b> : ' +trackingBackend
  5519. //////////////////////////////////////////////////////////////////////////////
  5520. // augmented-websites
  5521. //////////////////////////////////////////////////////////////////////////////
  5522. if( ARjs.SessionDebugUI.AugmentedWebsiteURL ){
  5523. var domElement = document.createElement('a')
  5524. domElement.innerHTML = 'Share on augmented-websites'
  5525. domElement.style.display = 'block'
  5526. // domElement.setAttribute('target', '_blank')
  5527. domElement.href = ARjs.SessionDebugUI.AugmentedWebsiteURL + '?'+location.href
  5528. this.domElement.appendChild(domElement)
  5529. }
  5530. //////////////////////////////////////////////////////////////////////////////
  5531. // toggle-point-cloud
  5532. //////////////////////////////////////////////////////////////////////////////
  5533. if( trackingBackend === 'tango' && tangoPointCloud ){
  5534. var domElement = document.createElement('button')
  5535. this.domElement.appendChild(domElement)
  5536. domElement.id= 'buttonTangoTogglePointCloud'
  5537. domElement.innerHTML = 'toggle-point-cloud'
  5538. domElement.href='javascript:void(0)'
  5539. domElement.addEventListener('click', function(){
  5540. var scene = arSession.parameters.scene
  5541. // TODO how tangoPointCloud, get connected here ???
  5542. // in arguments simply ?
  5543. if( tangoPointCloud.object3d.parent ){
  5544. scene.remove(tangoPointCloud.object3d)
  5545. }else{
  5546. scene.add(tangoPointCloud.object3d)
  5547. }
  5548. })
  5549. }
  5550. }
  5551. /**
  5552. * Url of augmented-website service - if === '' then dont include augmented-website link
  5553. * @type {String}
  5554. */
  5555. ARjs.SessionDebugUI.AugmentedWebsiteURL = 'https://webxr.io/augmented-website'
  5556. //////////////////////////////////////////////////////////////////////////////
  5557. // ARjs.AnchorDebugUI
  5558. //////////////////////////////////////////////////////////////////////////////
  5559. /**
  5560. * Create an debug UI for an ARjs.Anchor
  5561. *
  5562. * @param {ARjs.Anchor} arAnchor - the anchor to user
  5563. */
  5564. ARjs.AnchorDebugUI = function(arAnchor){
  5565. var _this = this
  5566. var arSession = arAnchor.arSession
  5567. var trackingBackend = arSession.arContext.parameters.trackingBackend
  5568. this.domElement = document.createElement('div')
  5569. this.domElement.style.color = 'rgba(0,0,0,0.9)'
  5570. this.domElement.style.backgroundColor = 'rgba(127,127,127,0.5)'
  5571. this.domElement.style.display = 'inline-block'
  5572. this.domElement.style.padding = '0.5em'
  5573. this.domElement.style.margin = '0.5em'
  5574. this.domElement.style.textAlign = 'left'
  5575. //////////////////////////////////////////////////////////////////////////////
  5576. // add title
  5577. //////////////////////////////////////////////////////////////////////////////
  5578. // var domElement = document.createElement('div')
  5579. // domElement.style.display = 'block'
  5580. // domElement.style.fontWeight = 'bold'
  5581. // domElement.style.fontSize = '120%'
  5582. // this.domElement.appendChild(domElement)
  5583. // domElement.innerHTML = 'Anchor Marker Debug'
  5584. //////////////////////////////////////////////////////////////////////////////
  5585. // current-tracking-backend
  5586. //////////////////////////////////////////////////////////////////////////////
  5587. var domElement = document.createElement('span')
  5588. domElement.style.display = 'block'
  5589. this.domElement.appendChild(domElement)
  5590. domElement.innerHTML = '<b>markersAreaEnabled</b> :' +arAnchor.parameters.markersAreaEnabled
  5591. //////////////////////////////////////////////////////////////////////////////
  5592. // toggle-marker-helper
  5593. //////////////////////////////////////////////////////////////////////////////
  5594. if( arAnchor.parameters.markersAreaEnabled ){
  5595. var domElement = document.createElement('button')
  5596. domElement.style.display = 'block'
  5597. this.domElement.appendChild(domElement)
  5598. domElement.id= 'buttonToggleMarkerHelpers'
  5599. domElement.innerHTML = 'toggle-marker-helper'
  5600. domElement.href='javascript:void(0)'
  5601. var subMarkerHelpersVisible = false
  5602. domElement.addEventListener('click', function(){
  5603. subMarkerHelpersVisible = subMarkerHelpersVisible ? false : true
  5604. arAnchor.markersArea.setSubMarkersVisibility(subMarkerHelpersVisible)
  5605. })
  5606. }
  5607. //////////////////////////////////////////////////////////////////////////////
  5608. // Learn-new-marker-area
  5609. //////////////////////////////////////////////////////////////////////////////
  5610. if( arAnchor.parameters.markersAreaEnabled ){
  5611. var domElement = document.createElement('button')
  5612. domElement.style.display = 'block'
  5613. this.domElement.appendChild(domElement)
  5614. domElement.id = 'buttonMarkersAreaLearner'
  5615. domElement.innerHTML = 'Learn-new-marker-area'
  5616. domElement.href ='javascript:void(0)'
  5617. domElement.addEventListener('click', function(){
  5618. if( ARjs.AnchorDebugUI.MarkersAreaLearnerURL !== null ){
  5619. var learnerURL = ARjs.AnchorDebugUI.MarkersAreaLearnerURL
  5620. }else{
  5621. var learnerURL = ARjs.Context.baseURL + 'examples/multi-markers/examples/learner.html'
  5622. }
  5623. ARjs.MarkersAreaUtils.navigateToLearnerPage(learnerURL, trackingBackend)
  5624. })
  5625. }
  5626. //////////////////////////////////////////////////////////////////////////////
  5627. // Reset-marker-area
  5628. //////////////////////////////////////////////////////////////////////////////
  5629. if( arAnchor.parameters.markersAreaEnabled ){
  5630. var domElement = document.createElement('button')
  5631. domElement.style.display = 'block'
  5632. this.domElement.appendChild(domElement)
  5633. domElement.id = 'buttonMarkersAreaReset'
  5634. domElement.innerHTML = 'Reset-marker-area'
  5635. domElement.href ='javascript:void(0)'
  5636. domElement.addEventListener('click', function(){
  5637. ARjs.MarkersAreaUtils.storeDefaultMultiMarkerFile(trackingBackend)
  5638. location.reload()
  5639. })
  5640. }
  5641. }
  5642. /**
  5643. * url for the markers-area learner. if not set, take the default one
  5644. * @type {String}
  5645. */
  5646. ARjs.AnchorDebugUI.MarkersAreaLearnerURL = null
  5647. // @namespace
  5648. var ARjs = ARjs || {}
  5649. /**
  5650. * Create an anchor in the real world
  5651. *
  5652. * @param {ARjs.Session} arSession - the session on which we create the anchor
  5653. * @param {Object} markerParameters - parameter of this anchor
  5654. */
  5655. ARjs.HitTesting = function(arSession){
  5656. var _this = this
  5657. var arContext = arSession.arContext
  5658. var trackingBackend = arContext.parameters.trackingBackend
  5659. this.enabled = true
  5660. this._arSession = arSession
  5661. this._hitTestingPlane = null
  5662. this._hitTestingTango = null
  5663. if( trackingBackend === 'tango' ){
  5664. _this._hitTestingTango = new THREEx.HitTestingTango(arContext)
  5665. }else{
  5666. _this._hitTestingPlane = new THREEx.HitTestingPlane(arSession.arSource.domElement)
  5667. }
  5668. }
  5669. //////////////////////////////////////////////////////////////////////////////
  5670. // update function
  5671. //////////////////////////////////////////////////////////////////////////////
  5672. /**
  5673. * update
  5674. *
  5675. * @param {THREE.Camera} camera - the camera to use
  5676. * @param {THREE.Object3D} object3d -
  5677. */
  5678. ARjs.HitTesting.prototype.update = function (camera, pickingRoot, changeMatrixMode) {
  5679. // if it isnt enabled, do nothing
  5680. if( this.enabled === false ) return
  5681. if( this._hitTestingTango !== null ){
  5682. this._hitTestingTango.update()
  5683. }else if( this._hitTestingPlane !== null ){
  5684. this._hitTestingPlane.update(camera, pickingRoot, changeMatrixMode)
  5685. }else console.assert(false)
  5686. }
  5687. //////////////////////////////////////////////////////////////////////////////
  5688. // actual hit testing
  5689. //////////////////////////////////////////////////////////////////////////////
  5690. /**
  5691. * Test the real world for intersections directly from a DomEvent
  5692. *
  5693. * @param {Number} mouseX - position X of the hit [-1, +1]
  5694. * @param {Number} mouseY - position Y of the hit [-1, +1]
  5695. * @return {[ARjs.HitTesting.Result]} - array of result
  5696. */
  5697. ARjs.HitTesting.prototype.testDomEvent = function(domEvent){
  5698. var trackingBackend = this._arSession.arContext.parameters.trackingBackend
  5699. var arSource = this._arSession.arSource
  5700. // if it isnt enabled, do nothing
  5701. if( this.enabled === false ) return []
  5702. if( trackingBackend === 'tango' ){
  5703. var mouseX = domEvent.pageX / window.innerWidth
  5704. var mouseY = domEvent.pageY / window.innerHeight
  5705. }else{
  5706. var mouseX = domEvent.clientX / arSource.domElementWidth()
  5707. var mouseY = domEvent.clientY / arSource.domElementHeight()
  5708. }
  5709. return this.test(mouseX, mouseY)
  5710. }
  5711. /**
  5712. * Test the real world for intersections.
  5713. *
  5714. * @param {Number} mouseX - position X of the hit [0, +1]
  5715. * @param {Number} mouseY - position Y of the hit [0, +1]
  5716. * @return {[ARjs.HitTesting.Result]} - array of result
  5717. */
  5718. ARjs.HitTesting.prototype.test = function(mouseX, mouseY){
  5719. var arContext = this._arSession.arContext
  5720. var trackingBackend = arContext.parameters.trackingBackend
  5721. var hitTestResults = []
  5722. // if it isnt enabled, do nothing
  5723. if( this.enabled === false ) return []
  5724. var result = null
  5725. if( trackingBackend === 'tango' ){
  5726. var result = this._hitTestingTango.test(mouseX, mouseY)
  5727. }else{
  5728. var result = this._hitTestingPlane.test(mouseX, mouseY)
  5729. }
  5730. // if no result is found, return now
  5731. if( result === null ) return hitTestResults
  5732. // build a ARjs.HitTesting.Result
  5733. var hitTestResult = new ARjs.HitTesting.Result(result.position, result.quaternion, result.scale)
  5734. hitTestResults.push(hitTestResult)
  5735. return hitTestResults
  5736. }
  5737. //////////////////////////////////////////////////////////////////////////////
  5738. // ARjs.HitTesting.Result
  5739. //////////////////////////////////////////////////////////////////////////////
  5740. /**
  5741. * Contains the result of ARjs.HitTesting.test()
  5742. *
  5743. * @param {THREE.Vector3} position - position to use
  5744. * @param {THREE.Quaternion} quaternion - quaternion to use
  5745. * @param {THREE.Vector3} scale - scale
  5746. */
  5747. ARjs.HitTesting.Result = function(position, quaternion, scale){
  5748. this.position = position
  5749. this.quaternion = quaternion
  5750. this.scale = scale
  5751. }
  5752. /**
  5753. * Apply to a controlled object3d
  5754. *
  5755. * @param {THREE.Object3D} object3d - the result to apply
  5756. */
  5757. ARjs.HitTesting.Result.prototype.apply = function(object3d){
  5758. object3d.position.copy(this.position)
  5759. object3d.quaternion.copy(this.quaternion)
  5760. object3d.scale.copy(this.scale)
  5761. object3d.updateMatrix()
  5762. }
  5763. /**
  5764. * Apply to a controlled object3d
  5765. *
  5766. * @param {THREE.Object3D} object3d - the result to apply
  5767. */
  5768. ARjs.HitTesting.Result.prototype.applyPosition = function(object3d){
  5769. object3d.position.copy(this.position)
  5770. object3d.updateMatrix()
  5771. return this
  5772. }
  5773. /**
  5774. * Apply to a controlled object3d
  5775. *
  5776. * @param {THREE.Object3D} object3d - the result to apply
  5777. */
  5778. ARjs.HitTesting.Result.prototype.applyQuaternion = function(object3d){
  5779. object3d.quaternion.copy(this.quaternion)
  5780. object3d.updateMatrix()
  5781. return this
  5782. }
  5783. var ARjs = ARjs || {}
  5784. /**
  5785. * define a ARjs.Session
  5786. *
  5787. * @param {Object} parameters - parameters for this session
  5788. */
  5789. ARjs.Session = function(parameters){
  5790. var _this = this
  5791. // handle default parameters
  5792. this.parameters = {
  5793. renderer: null,
  5794. camera: null,
  5795. scene: null,
  5796. sourceParameters: {},
  5797. contextParameters: {},
  5798. }
  5799. this.signals = {
  5800. sourceReady : new signals.Signal(),
  5801. contextInitialized: new signals.Signal(),
  5802. }
  5803. //////////////////////////////////////////////////////////////////////////////
  5804. // setParameters
  5805. //////////////////////////////////////////////////////////////////////////////
  5806. setParameters(parameters)
  5807. function setParameters(parameters){
  5808. if( parameters === undefined ) return
  5809. for( var key in parameters ){
  5810. var newValue = parameters[ key ]
  5811. if( newValue === undefined ){
  5812. console.warn( "THREEx.Session: '" + key + "' parameter is undefined." )
  5813. continue
  5814. }
  5815. var currentValue = _this.parameters[ key ]
  5816. if( currentValue === undefined ){
  5817. console.warn( "THREEx.Session: '" + key + "' is not a property of this material." )
  5818. continue
  5819. }
  5820. _this.parameters[ key ] = newValue
  5821. }
  5822. }
  5823. // sanity check
  5824. console.assert(this.parameters.renderer instanceof THREE.WebGLRenderer)
  5825. console.assert(this.parameters.camera instanceof THREE.Camera)
  5826. console.assert(this.parameters.scene instanceof THREE.Scene)
  5827. // backward emulation
  5828. Object.defineProperty(this, 'renderer', {get: function(){
  5829. console.warn('use .parameters.renderer renderer')
  5830. return this.parameters.renderer;
  5831. }});
  5832. Object.defineProperty(this, 'camera', {get: function(){
  5833. console.warn('use .parameters.camera instead')
  5834. return this.parameters.camera;
  5835. }});
  5836. Object.defineProperty(this, 'scene', {get: function(){
  5837. console.warn('use .parameters.scene instead')
  5838. return this.parameters.scene;
  5839. }});
  5840. // log the version
  5841. console.log('AR.js', ARjs.Context.REVISION, '- trackingBackend:', parameters.contextParameters.trackingBackend)
  5842. //////////////////////////////////////////////////////////////////////////////
  5843. // init arSource
  5844. //////////////////////////////////////////////////////////////////////////////
  5845. var arSource = _this.arSource = new ARjs.Source(parameters.sourceParameters)
  5846. arSource.init(function onReady(){
  5847. arSource.onResize(arContext, _this.parameters.renderer, _this.parameters.camera)
  5848. _this.signals.sourceReady.dispatch()
  5849. })
  5850. // handle resize
  5851. window.addEventListener('resize', function(){
  5852. arSource.onResize(arContext, _this.parameters.renderer, _this.parameters.camera)
  5853. })
  5854. //////////////////////////////////////////////////////////////////////////////
  5855. // init arContext
  5856. //////////////////////////////////////////////////////////////////////////////
  5857. // create atToolkitContext
  5858. var arContext = _this.arContext = new ARjs.Context(parameters.contextParameters)
  5859. // initialize it
  5860. _this.arContext.init()
  5861. arContext.addEventListener('initialized', function(event){
  5862. arSource.onResize(arContext, _this.parameters.renderer, _this.parameters.camera)
  5863. _this.signals.contextInitialized.dispatch()
  5864. })
  5865. //////////////////////////////////////////////////////////////////////////////
  5866. // update function
  5867. //////////////////////////////////////////////////////////////////////////////
  5868. // update artoolkit on every frame
  5869. this.update = function(){
  5870. if( arSource.ready === false ) return
  5871. arContext.update( arSource.domElement )
  5872. }
  5873. }
  5874. ARjs.Session.prototype.onResize = function () {
  5875. this.arSource.onResize(this.arContext, this.parameters.renderer, this.parameters.camera)
  5876. };
  5877. // @namespace
  5878. var ARjs = ARjs || {}
  5879. ARjs.TangoPointCloud = function(arSession){
  5880. var _this = this
  5881. var arContext = arSession.arContext
  5882. this.object3d = new THREE.Group
  5883. console.warn('Work only on cameraTransformMatrix - fix me - useless limitation')
  5884. arContext.addEventListener('initialized', function(event){
  5885. var vrPointCloud = arContext._tangoContext.vrPointCloud
  5886. var geometry = vrPointCloud.getBufferGeometry()
  5887. var material = new THREE.PointsMaterial({
  5888. size: 0.01,
  5889. // colorWrite: false, // good for occlusion
  5890. depthWrite: false,
  5891. })
  5892. var pointsObject = new THREE.Points(geometry, material)
  5893. // Points are changing all the time so calculating the frustum culling volume is not very convenient.
  5894. pointsObject.frustumCulled = false;
  5895. pointsObject.renderDepth = 0;
  5896. _this.object3d.add(pointsObject)
  5897. })
  5898. }
  5899. // @namespace
  5900. var ARjs = ARjs || {}
  5901. ARjs.TangoVideoMesh = function(arSession){
  5902. var arContext = arSession.arContext
  5903. var renderer = arSession.renderer
  5904. var videoMesh = null
  5905. var vrDisplay = null
  5906. // Create the see through camera scene and camera
  5907. var sceneOrtho = new THREE.Scene()
  5908. var cameraOrtho = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 100 )
  5909. this._sceneOrtho = sceneOrtho
  5910. this._cameraOrtho = cameraOrtho
  5911. // tango only - init cameraMesh
  5912. arContext.addEventListener('initialized', function(event){
  5913. // sanity check
  5914. console.assert( arContext.parameters.trackingBackend === 'tango' )
  5915. // variable declaration
  5916. vrDisplay = arContext._tangoContext.vrDisplay
  5917. console.assert(vrDisplay, 'vrDisplay MUST be defined')
  5918. // if vrDisplay isnt for tango, do nothing. It may be another vrDisplay (e.g. webvr emulator in chrome)
  5919. if( vrDisplay.displayName !== "Tango VR Device" ) return
  5920. // init videoPlane
  5921. videoMesh = THREE.WebAR.createVRSeeThroughCameraMesh(vrDisplay)
  5922. sceneOrtho.add(videoMesh)
  5923. })
  5924. //////////////////////////////////////////////////////////////////////////////
  5925. // Code Separator
  5926. //////////////////////////////////////////////////////////////////////////////
  5927. this.update = function(){
  5928. // sanity check
  5929. console.assert( arContext.parameters.trackingBackend === 'tango' )
  5930. // if not yet initialized, return now
  5931. if( videoMesh === null ) return
  5932. // Make sure that the camera is correctly displayed depending on the device and camera orientations.
  5933. THREE.WebAR.updateCameraMeshOrientation(vrDisplay, videoMesh)
  5934. }
  5935. //////////////////////////////////////////////////////////////////////////////
  5936. // Code Separator
  5937. //////////////////////////////////////////////////////////////////////////////
  5938. this.render = function(){
  5939. // sanity check
  5940. console.assert( arContext.parameters.trackingBackend === 'tango' )
  5941. // render sceneOrtho
  5942. renderer.render( sceneOrtho, cameraOrtho )
  5943. // Render the perspective scene
  5944. renderer.clearDepth()
  5945. }
  5946. }
  5947. var ARjs = ARjs || {}
  5948. ARjs.Utils = {}
  5949. /**
  5950. * Create a default rendering camera for this trackingBackend. They may be modified later. to fit physical camera parameters
  5951. *
  5952. * @param {string} trackingBackend - the tracking to user
  5953. * @return {THREE.Camera} the created camera
  5954. */
  5955. ARjs.Utils.createDefaultCamera = function(trackingMethod){
  5956. var trackingBackend = this.parseTrackingMethod(trackingMethod).trackingBackend
  5957. // Create a camera
  5958. if( trackingBackend === 'artoolkit' ){
  5959. var camera = new THREE.Camera();
  5960. }else if( trackingBackend === 'aruco' ){
  5961. var camera = new THREE.PerspectiveCamera(42, window.innerWidth / window.innerHeight, 0.01, 100);
  5962. }else if( trackingBackend === 'tango' ){
  5963. var camera = new THREE.PerspectiveCamera(42, window.innerWidth / window.innerHeight, 0.01, 100);
  5964. }else console.assert(false, 'unknown trackingBackend: '+trackingBackend)
  5965. return camera
  5966. }
  5967. /**
  5968. * test if the code is running on tango
  5969. *
  5970. * @return {boolean} - true if running on tango, false otherwise
  5971. */
  5972. ARjs.Utils.isTango = function(){
  5973. // FIXME: this test is super bad
  5974. var isTango = navigator.userAgent.match('Chrome/57.0.2987.5') !== null ? true : false
  5975. return isTango
  5976. }
  5977. /**
  5978. * parse tracking method
  5979. *
  5980. * @param {String} trackingMethod - the tracking method to parse
  5981. * @return {Object} - various field of the tracking method
  5982. */
  5983. ARjs.Utils.parseTrackingMethod = function(trackingMethod){
  5984. if( trackingMethod === 'best' ){
  5985. trackingMethod = ARjs.Utils.isTango() ? 'tango' : 'area-artoolkit'
  5986. }
  5987. if( trackingMethod.startsWith('area-') ){
  5988. return {
  5989. trackingBackend : trackingMethod.replace('area-', ''),
  5990. markersAreaEnabled : true,
  5991. }
  5992. }else{
  5993. return {
  5994. trackingBackend : trackingMethod,
  5995. markersAreaEnabled : false,
  5996. }
  5997. }
  5998. }
  5999. var ARjs = ARjs || {}
  6000. var THREEx = THREEx || {}
  6001. ARjs.MarkersAreaControls = THREEx.ArMultiMarkerControls = function(arToolkitContext, object3d, parameters){
  6002. var _this = this
  6003. THREEx.ArBaseControls.call(this, object3d)
  6004. if( arguments.length > 3 ) console.assert('wrong api for', THREEx.ArMultiMarkerControls)
  6005. // have a parameters in argument
  6006. this.parameters = {
  6007. // list of controls for each subMarker
  6008. subMarkersControls: parameters.subMarkersControls,
  6009. // list of pose for each subMarker relative to the origin
  6010. subMarkerPoses: parameters.subMarkerPoses,
  6011. // change matrix mode - [modelViewMatrix, cameraTransformMatrix]
  6012. changeMatrixMode : parameters.changeMatrixMode !== undefined ? parameters.changeMatrixMode : 'modelViewMatrix',
  6013. }
  6014. this.object3d.visible = false
  6015. // honor obsolete stuff - add a warning to use
  6016. this.subMarkersControls = this.parameters.subMarkersControls
  6017. this.subMarkerPoses = this.parameters.subMarkerPoses
  6018. // listen to arToolkitContext event 'sourceProcessed'
  6019. // - after we fully processed one image, aka when we know all detected poses in it
  6020. arToolkitContext.addEventListener('sourceProcessed', function(){
  6021. _this._onSourceProcessed()
  6022. })
  6023. }
  6024. ARjs.MarkersAreaControls.prototype = Object.create( THREEx.ArBaseControls.prototype );
  6025. ARjs.MarkersAreaControls.prototype.constructor = ARjs.MarkersAreaControls;
  6026. //////////////////////////////////////////////////////////////////////////////
  6027. // Code Separator
  6028. //////////////////////////////////////////////////////////////////////////////
  6029. /**
  6030. * What to do when a image source is fully processed
  6031. */
  6032. ARjs.MarkersAreaControls.prototype._onSourceProcessed = function(){
  6033. var _this = this
  6034. var stats = {
  6035. count: 0,
  6036. position : {
  6037. sum: new THREE.Vector3(0,0,0),
  6038. average: new THREE.Vector3(0,0,0),
  6039. },
  6040. quaternion : {
  6041. sum: new THREE.Quaternion(0,0,0,0),
  6042. average: new THREE.Quaternion(0,0,0,0),
  6043. },
  6044. scale : {
  6045. sum: new THREE.Vector3(0,0,0),
  6046. average: new THREE.Vector3(0,0,0),
  6047. },
  6048. }
  6049. var firstQuaternion = _this.parameters.subMarkersControls[0].object3d.quaternion
  6050. this.parameters.subMarkersControls.forEach(function(markerControls, markerIndex){
  6051. var markerObject3d = markerControls.object3d
  6052. // if this marker is not visible, ignore it
  6053. if( markerObject3d.visible === false ) return
  6054. // transformation matrix of this.object3d according to this sub-markers
  6055. var matrix = markerObject3d.matrix.clone()
  6056. var markerPose = _this.parameters.subMarkerPoses[markerIndex]
  6057. matrix.multiply(new THREE.Matrix4().getInverse(markerPose))
  6058. // decompose the matrix into .position, .quaternion, .scale
  6059. var position = new THREE.Vector3
  6060. var quaternion = new THREE.Quaternion()
  6061. var scale = new THREE.Vector3
  6062. matrix.decompose(position, quaternion, scale)
  6063. // http://wiki.unity3d.com/index.php/Averaging_Quaternions_and_Vectors
  6064. stats.count++
  6065. ARjs.MarkersAreaControls.averageVector3(stats.position.sum, position, stats.count, stats.position.average)
  6066. ARjs.MarkersAreaControls.averageQuaternion(stats.quaternion.sum, quaternion, firstQuaternion, stats.count, stats.quaternion.average)
  6067. ARjs.MarkersAreaControls.averageVector3(stats.scale.sum, scale, stats.count, stats.scale.average)
  6068. })
  6069. // honor _this.object3d.visible
  6070. if( stats.count > 0 ){
  6071. _this.object3d.visible = true
  6072. }else{
  6073. _this.object3d.visible = false
  6074. }
  6075. // if at least one sub-marker has been detected, make the average of all detected markers
  6076. if( stats.count > 0 ){
  6077. // compute modelViewMatrix
  6078. var modelViewMatrix = new THREE.Matrix4()
  6079. modelViewMatrix.compose(stats.position.average, stats.quaternion.average, stats.scale.average)
  6080. // change _this.object3d.matrix based on parameters.changeMatrixMode
  6081. if( this.parameters.changeMatrixMode === 'modelViewMatrix' ){
  6082. _this.object3d.matrix.copy(modelViewMatrix)
  6083. }else if( this.parameters.changeMatrixMode === 'cameraTransformMatrix' ){
  6084. _this.object3d.matrix.getInverse( modelViewMatrix )
  6085. }else {
  6086. console.assert(false)
  6087. }
  6088. // decompose - the matrix into .position, .quaternion, .scale
  6089. _this.object3d.matrix.decompose(_this.object3d.position, _this.object3d.quaternion, _this.object3d.scale)
  6090. }
  6091. }
  6092. //////////////////////////////////////////////////////////////////////////////
  6093. // Utility functions
  6094. //////////////////////////////////////////////////////////////////////////////
  6095. /**
  6096. * from http://wiki.unity3d.com/index.php/Averaging_Quaternions_and_Vectors
  6097. */
  6098. ARjs.MarkersAreaControls.averageQuaternion = function(quaternionSum, newQuaternion, firstQuaternion, count, quaternionAverage){
  6099. quaternionAverage = quaternionAverage || new THREE.Quaternion()
  6100. // sanity check
  6101. console.assert(firstQuaternion instanceof THREE.Quaternion === true)
  6102. // from http://wiki.unity3d.com/index.php/Averaging_Quaternions_and_Vectors
  6103. if( newQuaternion.dot(firstQuaternion) > 0 ){
  6104. newQuaternion = new THREE.Quaternion(-newQuaternion.x, -newQuaternion.y, -newQuaternion.z, -newQuaternion.w)
  6105. }
  6106. quaternionSum.x += newQuaternion.x
  6107. quaternionSum.y += newQuaternion.y
  6108. quaternionSum.z += newQuaternion.z
  6109. quaternionSum.w += newQuaternion.w
  6110. quaternionAverage.x = quaternionSum.x/count
  6111. quaternionAverage.y = quaternionSum.y/count
  6112. quaternionAverage.z = quaternionSum.z/count
  6113. quaternionAverage.w = quaternionSum.w/count
  6114. quaternionAverage.normalize()
  6115. return quaternionAverage
  6116. }
  6117. ARjs.MarkersAreaControls.averageVector3 = function(vector3Sum, vector3, count, vector3Average){
  6118. vector3Average = vector3Average || new THREE.Vector3()
  6119. vector3Sum.x += vector3.x
  6120. vector3Sum.y += vector3.y
  6121. vector3Sum.z += vector3.z
  6122. vector3Average.x = vector3Sum.x / count
  6123. vector3Average.y = vector3Sum.y / count
  6124. vector3Average.z = vector3Sum.z / count
  6125. return vector3Average
  6126. }
  6127. //////////////////////////////////////////////////////////////////////////////
  6128. // Utility function
  6129. //////////////////////////////////////////////////////////////////////////////
  6130. /**
  6131. * compute the center of this multimarker file
  6132. */
  6133. ARjs.MarkersAreaControls.computeCenter = function(jsonData){
  6134. var multiMarkerFile = JSON.parse(jsonData)
  6135. var stats = {
  6136. count : 0,
  6137. position : {
  6138. sum: new THREE.Vector3(0,0,0),
  6139. average: new THREE.Vector3(0,0,0),
  6140. },
  6141. quaternion : {
  6142. sum: new THREE.Quaternion(0,0,0,0),
  6143. average: new THREE.Quaternion(0,0,0,0),
  6144. },
  6145. scale : {
  6146. sum: new THREE.Vector3(0,0,0),
  6147. average: new THREE.Vector3(0,0,0),
  6148. },
  6149. }
  6150. var firstQuaternion = new THREE.Quaternion() // FIXME ???
  6151. multiMarkerFile.subMarkersControls.forEach(function(item){
  6152. var poseMatrix = new THREE.Matrix4().fromArray(item.poseMatrix)
  6153. var position = new THREE.Vector3
  6154. var quaternion = new THREE.Quaternion
  6155. var scale = new THREE.Vector3
  6156. poseMatrix.decompose(position, quaternion, scale)
  6157. // http://wiki.unity3d.com/index.php/Averaging_Quaternions_and_Vectors
  6158. stats.count++
  6159. ARjs.MarkersAreaControls.averageVector3(stats.position.sum, position, stats.count, stats.position.average)
  6160. ARjs.MarkersAreaControls.averageQuaternion(stats.quaternion.sum, quaternion, firstQuaternion, stats.count, stats.quaternion.average)
  6161. ARjs.MarkersAreaControls.averageVector3(stats.scale.sum, scale, stats.count, stats.scale.average)
  6162. })
  6163. var averageMatrix = new THREE.Matrix4()
  6164. averageMatrix.compose(stats.position.average, stats.quaternion.average, stats.scale.average)
  6165. return averageMatrix
  6166. }
  6167. ARjs.MarkersAreaControls.computeBoundingBox = function(jsonData){
  6168. var multiMarkerFile = JSON.parse(jsonData)
  6169. var boundingBox = new THREE.Box3()
  6170. multiMarkerFile.subMarkersControls.forEach(function(item){
  6171. var poseMatrix = new THREE.Matrix4().fromArray(item.poseMatrix)
  6172. var position = new THREE.Vector3
  6173. var quaternion = new THREE.Quaternion
  6174. var scale = new THREE.Vector3
  6175. poseMatrix.decompose(position, quaternion, scale)
  6176. boundingBox.expandByPoint(position)
  6177. })
  6178. return boundingBox
  6179. }
  6180. //////////////////////////////////////////////////////////////////////////////
  6181. // updateSmoothedControls
  6182. //////////////////////////////////////////////////////////////////////////////
  6183. ARjs.MarkersAreaControls.prototype.updateSmoothedControls = function(smoothedControls, lerpsValues){
  6184. // handle default values
  6185. if( lerpsValues === undefined ){
  6186. // FIXME this parameter format is uselessly cryptic
  6187. // lerpValues = [
  6188. // {lerpPosition: 0.5, lerpQuaternion: 0.2, lerpQuaternion: 0.7}
  6189. // ]
  6190. lerpsValues = [
  6191. [0.3+.1, 0.1, 0.3],
  6192. [0.4+.1, 0.1, 0.4],
  6193. [0.4+.1, 0.2, 0.5],
  6194. [0.5+.1, 0.2, 0.7],
  6195. [0.5+.1, 0.2, 0.7],
  6196. ]
  6197. }
  6198. // count how many subMarkersControls are visible
  6199. var nVisible = 0
  6200. this.parameters.subMarkersControls.forEach(function(markerControls, markerIndex){
  6201. var markerObject3d = markerControls.object3d
  6202. if( markerObject3d.visible === true ) nVisible ++
  6203. })
  6204. // find the good lerpValues
  6205. if( lerpsValues[nVisible-1] !== undefined ){
  6206. var lerpValues = lerpsValues[nVisible-1]
  6207. }else{
  6208. var lerpValues = lerpsValues[lerpsValues.length-1]
  6209. }
  6210. // modify lerpValues in smoothedControls
  6211. smoothedControls.parameters.lerpPosition = lerpValues[0]
  6212. smoothedControls.parameters.lerpQuaternion = lerpValues[1]
  6213. smoothedControls.parameters.lerpScale = lerpValues[2]
  6214. }
  6215. //////////////////////////////////////////////////////////////////////////////
  6216. // Create THREEx.ArMultiMarkerControls from JSON
  6217. //////////////////////////////////////////////////////////////////////////////
  6218. ARjs.MarkersAreaControls.fromJSON = function(arToolkitContext, parent3D, markerRoot, jsonData, parameters){
  6219. var multiMarkerFile = JSON.parse(jsonData)
  6220. // declare variables
  6221. var subMarkersControls = []
  6222. var subMarkerPoses = []
  6223. // handle default arguments
  6224. parameters = parameters || {}
  6225. // prepare the parameters
  6226. multiMarkerFile.subMarkersControls.forEach(function(item){
  6227. // create a markerRoot
  6228. var markerRoot = new THREE.Object3D()
  6229. parent3D.add(markerRoot)
  6230. // create markerControls for our markerRoot
  6231. var subMarkerControls = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, item.parameters)
  6232. // if( true ){
  6233. // store it in the parameters
  6234. subMarkersControls.push(subMarkerControls)
  6235. subMarkerPoses.push(new THREE.Matrix4().fromArray(item.poseMatrix))
  6236. // }else{
  6237. // // build a smoothedControls
  6238. // var smoothedRoot = new THREE.Group()
  6239. // parent3D.add(smoothedRoot)
  6240. // var smoothedControls = new THREEx.ArSmoothedControls(smoothedRoot, {
  6241. // lerpPosition : 0.1,
  6242. // lerpQuaternion : 0.1,
  6243. // lerpScale : 0.1,
  6244. // minVisibleDelay: 0,
  6245. // minUnvisibleDelay: 0,
  6246. // })
  6247. // onRenderFcts.push(function(delta){
  6248. // smoothedControls.update(markerRoot) // TODO this is a global
  6249. // })
  6250. //
  6251. //
  6252. // // store it in the parameters
  6253. // subMarkersControls.push(smoothedControls)
  6254. // subMarkerPoses.push(new THREE.Matrix4().fromArray(item.poseMatrix))
  6255. // }
  6256. })
  6257. parameters.subMarkersControls = subMarkersControls
  6258. parameters.subMarkerPoses = subMarkerPoses
  6259. // create a new THREEx.ArMultiMarkerControls
  6260. var multiMarkerControls = new THREEx.ArMultiMarkerControls(arToolkitContext, markerRoot, parameters)
  6261. // return it
  6262. return multiMarkerControls
  6263. }
  6264. var ARjs = ARjs || {}
  6265. var THREEx = THREEx || {}
  6266. ARjs.MarkersAreaLearning = THREEx.ArMultiMakersLearning = function(arToolkitContext, subMarkersControls){
  6267. var _this = this
  6268. this._arToolkitContext = arToolkitContext
  6269. // Init variables
  6270. this.subMarkersControls = subMarkersControls
  6271. this.enabled = true
  6272. // listen to arToolkitContext event 'sourceProcessed'
  6273. // - after we fully processed one image, aka when we know all detected poses in it
  6274. arToolkitContext.addEventListener('sourceProcessed', function(){
  6275. _this._onSourceProcessed()
  6276. })
  6277. }
  6278. //////////////////////////////////////////////////////////////////////////////
  6279. // statistic collection
  6280. //////////////////////////////////////////////////////////////////////////////
  6281. /**
  6282. * What to do when a image source is fully processed
  6283. */
  6284. ARjs.MarkersAreaLearning.prototype._onSourceProcessed = function(){
  6285. var originQuaternion = this.subMarkersControls[0].object3d.quaternion
  6286. // here collect the statistic on relative positioning
  6287. // honor this.enabled
  6288. if( this.enabled === false ) return
  6289. // keep only the visible markers
  6290. var visibleMarkerControls = this.subMarkersControls.filter(function(markerControls){
  6291. return markerControls.object3d.visible === true
  6292. })
  6293. var count = Object.keys(visibleMarkerControls).length
  6294. var positionDelta = new THREE.Vector3()
  6295. var quaternionDelta = new THREE.Quaternion()
  6296. var scaleDelta = new THREE.Vector3()
  6297. var tmpMatrix = new THREE.Matrix4()
  6298. // go thru all the visibleMarkerControls
  6299. for(var i = 0; i < count; i++){
  6300. var markerControls1 = visibleMarkerControls[i]
  6301. for(var j = 0; j < count; j++){
  6302. var markerControls2 = visibleMarkerControls[j]
  6303. // if markerControls1 is markerControls2, then skip it
  6304. if( i === j ) continue
  6305. //////////////////////////////////////////////////////////////////////////////
  6306. // create data in markerControls1.object3d.userData if needed
  6307. //////////////////////////////////////////////////////////////////////////////
  6308. // create seenCouples for markerControls1 if needed
  6309. if( markerControls1.object3d.userData.seenCouples === undefined ){
  6310. markerControls1.object3d.userData.seenCouples = {}
  6311. }
  6312. var seenCouples = markerControls1.object3d.userData.seenCouples
  6313. // create the multiMarkerPosition average if needed`
  6314. if( seenCouples[markerControls2.id] === undefined ){
  6315. // console.log('create seenCouples between', markerControls1.id, 'and', markerControls2.id)
  6316. seenCouples[markerControls2.id] = {
  6317. count : 0,
  6318. position : {
  6319. sum: new THREE.Vector3(0,0,0),
  6320. average: new THREE.Vector3(0,0,0),
  6321. },
  6322. quaternion : {
  6323. sum: new THREE.Quaternion(0,0,0,0),
  6324. average: new THREE.Quaternion(0,0,0,0),
  6325. },
  6326. scale : {
  6327. sum: new THREE.Vector3(0,0,0),
  6328. average: new THREE.Vector3(0,0,0),
  6329. },
  6330. }
  6331. }
  6332. //////////////////////////////////////////////////////////////////////////////
  6333. // Compute markerControls2 position relative to markerControls1
  6334. //////////////////////////////////////////////////////////////////////////////
  6335. // compute markerControls2 position/quaternion/scale in relation with markerControls1
  6336. tmpMatrix.getInverse(markerControls1.object3d.matrix)
  6337. tmpMatrix.multiply(markerControls2.object3d.matrix)
  6338. tmpMatrix.decompose(positionDelta, quaternionDelta, scaleDelta)
  6339. //////////////////////////////////////////////////////////////////////////////
  6340. // update statistics
  6341. //////////////////////////////////////////////////////////////////////////////
  6342. var stats = seenCouples[markerControls2.id]
  6343. // update the count
  6344. stats.count++
  6345. // update the average of position/rotation/scale
  6346. THREEx.ArMultiMarkerControls.averageVector3(stats.position.sum, positionDelta, stats.count, stats.position.average)
  6347. THREEx.ArMultiMarkerControls.averageQuaternion(stats.quaternion.sum, quaternionDelta, originQuaternion, stats.count, stats.quaternion.average)
  6348. THREEx.ArMultiMarkerControls.averageVector3(stats.scale.sum, scaleDelta, stats.count, stats.scale.average)
  6349. }
  6350. }
  6351. }
  6352. //////////////////////////////////////////////////////////////////////////////
  6353. // Compute markers transformation matrix from current stats
  6354. //////////////////////////////////////////////////////////////////////////////
  6355. ARjs.MarkersAreaLearning.prototype.computeResult = function(){
  6356. var _this = this
  6357. var originSubControls = this.subMarkersControls[0]
  6358. this.deleteResult()
  6359. // special case of originSubControls averageMatrix
  6360. originSubControls.object3d.userData.result = {
  6361. averageMatrix : new THREE.Matrix4(),
  6362. confidenceFactor: 1,
  6363. }
  6364. // TODO here check if the originSubControls has been seen at least once!!
  6365. /**
  6366. * ALGO in pseudo code
  6367. *
  6368. * - Set confidenceFactor of origin sub markers as 1
  6369. *
  6370. * Start Looping
  6371. * - For a given sub marker, skip it if it already has a result.
  6372. * - if no result, check all seen couple and find n ones which has a progress of 1 or more.
  6373. * - So the other seen sub markers, got a valid transformation matrix.
  6374. * - So take local averages position/orientation/scale, compose a transformation matrix.
  6375. * - aka transformation matrix from parent matrix * transf matrix pos/orientation/scale
  6376. * - Multiple it by the other seen marker matrix.
  6377. * - Loop on the array until one pass could not compute any new sub marker
  6378. */
  6379. do{
  6380. var resultChanged = false
  6381. // loop over each subMarkerControls
  6382. this.subMarkersControls.forEach(function(subMarkerControls){
  6383. // if subMarkerControls already has a result, do nothing
  6384. var result = subMarkerControls.object3d.userData.result
  6385. var isLearned = (result !== undefined && result.confidenceFactor >= 1) ? true : false
  6386. if( isLearned === true ) return
  6387. // console.log('compute subMarkerControls', subMarkerControls.name())
  6388. var otherSubControlsID = _this._getLearnedCoupleStats(subMarkerControls)
  6389. if( otherSubControlsID === null ){
  6390. // console.log('no learnedCoupleStats')
  6391. return
  6392. }
  6393. var otherSubControls = _this._getSubMarkerControlsByID(otherSubControlsID)
  6394. var seenCoupleStats = subMarkerControls.object3d.userData.seenCouples[otherSubControlsID]
  6395. var averageMatrix = new THREE.Matrix4()
  6396. averageMatrix.compose(seenCoupleStats.position.average, seenCoupleStats.quaternion.average, seenCoupleStats.scale.average)
  6397. var otherAverageMatrix = otherSubControls.object3d.userData.result.averageMatrix
  6398. var matrix = new THREE.Matrix4().getInverse(otherAverageMatrix).multiply(averageMatrix)
  6399. matrix = new THREE.Matrix4().getInverse(matrix)
  6400. console.assert( subMarkerControls.object3d.userData.result === undefined )
  6401. subMarkerControls.object3d.userData.result = {
  6402. averageMatrix: matrix,
  6403. confidenceFactor: 1
  6404. }
  6405. resultChanged = true
  6406. })
  6407. // console.log('loop')
  6408. }while(resultChanged === true)
  6409. // debugger
  6410. // console.log('json:', this.toJSON())
  6411. // this.subMarkersControls.forEach(function(subMarkerControls){
  6412. // var hasResult = subMarkerControls.object3d.userData.result !== undefined
  6413. // console.log('marker', subMarkerControls.name(), hasResult ? 'has' : 'has NO', 'result')
  6414. // })
  6415. }
  6416. //////////////////////////////////////////////////////////////////////////////
  6417. // Utility function
  6418. //////////////////////////////////////////////////////////////////////////////
  6419. /**
  6420. * get a _this.subMarkersControls id based on markerControls.id
  6421. */
  6422. ARjs.MarkersAreaLearning.prototype._getLearnedCoupleStats = function(subMarkerControls){
  6423. // if this subMarkerControls has never been seen with another subMarkerControls
  6424. if( subMarkerControls.object3d.userData.seenCouples === undefined ) return null
  6425. var seenCouples = subMarkerControls.object3d.userData.seenCouples
  6426. var coupleControlsIDs = Object.keys(seenCouples).map(Number)
  6427. for(var i = 0; i < coupleControlsIDs.length; i++){
  6428. var otherSubControlsID = coupleControlsIDs[i]
  6429. // get otherSubControls
  6430. var otherSubControls = this._getSubMarkerControlsByID(otherSubControlsID)
  6431. // if otherSubControls isnt learned, skip it
  6432. var result = otherSubControls.object3d.userData.result
  6433. var isLearned = (result !== undefined && result.confidenceFactor >= 1) ? true : false
  6434. if( isLearned === false ) continue
  6435. // return this seenCouplesStats
  6436. return otherSubControlsID
  6437. }
  6438. // if none is found, return null
  6439. return null
  6440. }
  6441. /**
  6442. * get a _this.subMarkersControls based on markerControls.id
  6443. */
  6444. ARjs.MarkersAreaLearning.prototype._getSubMarkerControlsByID = function(controlsID){
  6445. for(var i = 0; i < this.subMarkersControls.length; i++){
  6446. var subMarkerControls = this.subMarkersControls[i]
  6447. if( subMarkerControls.id === controlsID ){
  6448. return subMarkerControls
  6449. }
  6450. }
  6451. return null
  6452. }
  6453. //////////////////////////////////////////////////////////////////////////////
  6454. // JSON file building
  6455. //////////////////////////////////////////////////////////////////////////////
  6456. ARjs.MarkersAreaLearning.prototype.toJSON = function(){
  6457. // compute the average matrix before generating the file
  6458. this.computeResult()
  6459. //////////////////////////////////////////////////////////////////////////////
  6460. // actually build the json
  6461. //////////////////////////////////////////////////////////////////////////////
  6462. var data = {
  6463. meta : {
  6464. createdBy : "Area Learning - AR.js "+THREEx.ArToolkitContext.REVISION,
  6465. createdAt : new Date().toJSON(),
  6466. },
  6467. trackingBackend: this._arToolkitContext.parameters.trackingBackend,
  6468. subMarkersControls : [],
  6469. }
  6470. var originSubControls = this.subMarkersControls[0]
  6471. var originMatrixInverse = new THREE.Matrix4().getInverse(originSubControls.object3d.matrix)
  6472. this.subMarkersControls.forEach(function(subMarkerControls, index){
  6473. // if a subMarkerControls has no result, ignore it
  6474. if( subMarkerControls.object3d.userData.result === undefined ) return
  6475. var poseMatrix = subMarkerControls.object3d.userData.result.averageMatrix
  6476. console.assert(poseMatrix instanceof THREE.Matrix4)
  6477. // build the info
  6478. var info = {
  6479. parameters : {
  6480. // to fill ...
  6481. },
  6482. poseMatrix : poseMatrix.toArray(),
  6483. }
  6484. if( subMarkerControls.parameters.type === 'pattern' ){
  6485. info.parameters.type = subMarkerControls.parameters.type
  6486. info.parameters.patternUrl = subMarkerControls.parameters.patternUrl
  6487. }else if( subMarkerControls.parameters.type === 'barcode' ){
  6488. info.parameters.type = subMarkerControls.parameters.type
  6489. info.parameters.barcodeValue = subMarkerControls.parameters.barcodeValue
  6490. }else console.assert(false)
  6491. data.subMarkersControls.push(info)
  6492. })
  6493. var strJSON = JSON.stringify(data, null, '\t');
  6494. //////////////////////////////////////////////////////////////////////////////
  6495. // round matrix elements to ease readability - for debug
  6496. //////////////////////////////////////////////////////////////////////////////
  6497. var humanReadable = false
  6498. if( humanReadable === true ){
  6499. var tmp = JSON.parse(strJSON)
  6500. tmp.subMarkersControls.forEach(function(markerControls){
  6501. markerControls.poseMatrix = markerControls.poseMatrix.map(function(value){
  6502. var roundingFactor = 100
  6503. return Math.round(value*roundingFactor)/roundingFactor
  6504. })
  6505. })
  6506. strJSON = JSON.stringify(tmp, null, '\t');
  6507. }
  6508. return strJSON;
  6509. }
  6510. //////////////////////////////////////////////////////////////////////////////
  6511. // utility function
  6512. //////////////////////////////////////////////////////////////////////////////
  6513. /**
  6514. * reset all collected statistics
  6515. */
  6516. ARjs.MarkersAreaLearning.prototype.resetStats = function(){
  6517. this.deleteResult()
  6518. this.subMarkersControls.forEach(function(markerControls){
  6519. delete markerControls.object3d.userData.seenCouples
  6520. })
  6521. }
  6522. /**
  6523. * reset all collected statistics
  6524. */
  6525. ARjs.MarkersAreaLearning.prototype.deleteResult = function(){
  6526. this.subMarkersControls.forEach(function(markerControls){
  6527. delete markerControls.object3d.userData.result
  6528. })
  6529. }
  6530. var THREEx = THREEx || {}
  6531. var ARjs = ARjs || {}
  6532. var THREEx = THREEx || {}
  6533. ARjs.MarkersAreaUtils = THREEx.ArMultiMarkerUtils = {}
  6534. //////////////////////////////////////////////////////////////////////////////
  6535. // navigateToLearnerPage
  6536. //////////////////////////////////////////////////////////////////////////////
  6537. /**
  6538. * Navigate to the multi-marker learner page
  6539. *
  6540. * @param {String} learnerBaseURL - the base url for the learner
  6541. * @param {String} trackingBackend - the tracking backend to use
  6542. */
  6543. ARjs.MarkersAreaUtils.navigateToLearnerPage = function(learnerBaseURL, trackingBackend){
  6544. var learnerParameters = {
  6545. backURL : location.href,
  6546. trackingBackend: trackingBackend,
  6547. markersControlsParameters: ARjs.MarkersAreaUtils.createDefaultMarkersControlsParameters(trackingBackend),
  6548. }
  6549. location.href = learnerBaseURL + '?' + encodeURIComponent(JSON.stringify(learnerParameters))
  6550. }
  6551. //////////////////////////////////////////////////////////////////////////////
  6552. // DefaultMultiMarkerFile
  6553. //////////////////////////////////////////////////////////////////////////////
  6554. /**
  6555. * Create and store a default multi-marker file
  6556. *
  6557. * @param {String} trackingBackend - the tracking backend to use
  6558. */
  6559. ARjs.MarkersAreaUtils.storeDefaultMultiMarkerFile = function(trackingBackend){
  6560. var file = ARjs.MarkersAreaUtils.createDefaultMultiMarkerFile(trackingBackend)
  6561. // json.strinfy the value and store it in localStorage
  6562. localStorage.setItem('ARjsMultiMarkerFile', JSON.stringify(file))
  6563. }
  6564. /**
  6565. * Create a default multi-marker file
  6566. * @param {String} trackingBackend - the tracking backend to use
  6567. * @return {Object} - json object of the multi-marker file
  6568. */
  6569. ARjs.MarkersAreaUtils.createDefaultMultiMarkerFile = function(trackingBackend){
  6570. console.assert(trackingBackend)
  6571. if( trackingBackend === undefined ) debugger
  6572. // create absoluteBaseURL
  6573. var link = document.createElement('a')
  6574. link.href = ARjs.Context.baseURL
  6575. var absoluteBaseURL = link.href
  6576. // create the base file
  6577. var file = {
  6578. meta : {
  6579. createdBy : 'AR.js ' + ARjs.Context.REVISION + ' - Default Marker',
  6580. createdAt : new Date().toJSON(),
  6581. },
  6582. trackingBackend : trackingBackend,
  6583. subMarkersControls : [
  6584. // empty for now... being filled
  6585. ]
  6586. }
  6587. // add a subMarkersControls
  6588. file.subMarkersControls[0] = {
  6589. parameters: {},
  6590. poseMatrix: new THREE.Matrix4().makeTranslation(0,0, 0).toArray(),
  6591. }
  6592. if( trackingBackend === 'artoolkit' ){
  6593. file.subMarkersControls[0].parameters.type = 'pattern'
  6594. file.subMarkersControls[0].parameters.patternUrl = absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-hiro.patt'
  6595. }else if( trackingBackend === 'aruco' ){
  6596. file.subMarkersControls[0].parameters.type = 'barcode'
  6597. file.subMarkersControls[0].parameters.barcodeValue = 1001
  6598. }else console.assert(false)
  6599. // json.strinfy the value and store it in localStorage
  6600. return file
  6601. }
  6602. //////////////////////////////////////////////////////////////////////////////
  6603. // createDefaultMarkersControlsParameters
  6604. //////////////////////////////////////////////////////////////////////////////
  6605. /**
  6606. * Create a default controls parameters for the multi-marker learner
  6607. *
  6608. * @param {String} trackingBackend - the tracking backend to use
  6609. * @return {Object} - json object containing the controls parameters
  6610. */
  6611. ARjs.MarkersAreaUtils.createDefaultMarkersControlsParameters = function(trackingBackend){
  6612. // create absoluteBaseURL
  6613. var link = document.createElement('a')
  6614. link.href = ARjs.Context.baseURL
  6615. var absoluteBaseURL = link.href
  6616. if( trackingBackend === 'artoolkit' ){
  6617. // pattern hiro/kanji/a/b/c/f
  6618. var markersControlsParameters = [
  6619. {
  6620. type : 'pattern',
  6621. patternUrl : absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-hiro.patt',
  6622. },
  6623. {
  6624. type : 'pattern',
  6625. patternUrl : absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-kanji.patt',
  6626. },
  6627. {
  6628. type : 'pattern',
  6629. patternUrl : absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-letterA.patt',
  6630. },
  6631. {
  6632. type : 'pattern',
  6633. patternUrl : absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-letterB.patt',
  6634. },
  6635. {
  6636. type : 'pattern',
  6637. patternUrl : absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-letterC.patt',
  6638. },
  6639. {
  6640. type : 'pattern',
  6641. patternUrl : absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-letterF.patt',
  6642. },
  6643. ]
  6644. }else if( trackingBackend === 'aruco' ){
  6645. var markersControlsParameters = [
  6646. {
  6647. type : 'barcode',
  6648. barcodeValue: 1001,
  6649. },
  6650. {
  6651. type : 'barcode',
  6652. barcodeValue: 1002,
  6653. },
  6654. {
  6655. type : 'barcode',
  6656. barcodeValue: 1003,
  6657. },
  6658. {
  6659. type : 'barcode',
  6660. barcodeValue: 1004,
  6661. },
  6662. {
  6663. type : 'barcode',
  6664. barcodeValue: 1005,
  6665. },
  6666. {
  6667. type : 'barcode',
  6668. barcodeValue: 1006,
  6669. },
  6670. ]
  6671. }else console.assert(false)
  6672. return markersControlsParameters
  6673. }
  6674. //////////////////////////////////////////////////////////////////////////////
  6675. // Code Separator
  6676. //////////////////////////////////////////////////////////////////////////////
  6677. /**
  6678. * generate areaFile
  6679. */
  6680. ARjs.MarkersAreaUtils.storeMarkersAreaFileFromResolution = function (trackingBackend, resolutionW, resolutionH) {
  6681. // generate areaFile
  6682. var areaFile = this.buildMarkersAreaFileFromResolution(trackingBackend, resolutionW, resolutionH)
  6683. // store areaFile in localStorage
  6684. localStorage.setItem('ARjsMultiMarkerFile', JSON.stringify(areaFile))
  6685. }
  6686. //////////////////////////////////////////////////////////////////////////////
  6687. // Code Separator
  6688. //////////////////////////////////////////////////////////////////////////////
  6689. ARjs.MarkersAreaUtils.buildMarkersAreaFileFromResolution = function(trackingBackend, resolutionW, resolutionH){
  6690. // create the base file
  6691. var file = {
  6692. meta : {
  6693. createdBy : 'AR.js - Augmented Website',
  6694. createdAt : new Date().toJSON(),
  6695. },
  6696. trackingBackend : trackingBackend,
  6697. subMarkersControls : [
  6698. // empty for now...
  6699. ]
  6700. }
  6701. var whiteMargin = 0.1
  6702. if( resolutionW > resolutionH ){
  6703. var markerImageSize = 0.4 * resolutionH
  6704. }else if( resolutionW < resolutionH ){
  6705. var markerImageSize = 0.4 * resolutionW
  6706. }else if( resolutionW === resolutionH ){
  6707. // specific for twitter player - https://dev.twitter.com/cards/types/player
  6708. var markerImageSize = 0.33 * resolutionW
  6709. }else console.assert(false)
  6710. // console.warn('using new markerImageSize computation')
  6711. var actualMarkerSize = markerImageSize * (1 - 2*whiteMargin)
  6712. var deltaX = (resolutionW - markerImageSize)/2 / actualMarkerSize
  6713. var deltaZ = (resolutionH - markerImageSize)/2 / actualMarkerSize
  6714. var subMarkerControls = buildSubMarkerControls('center', 0, 0)
  6715. file.subMarkersControls.push(subMarkerControls)
  6716. var subMarkerControls = buildSubMarkerControls('topleft', -deltaX, -deltaZ)
  6717. file.subMarkersControls.push(subMarkerControls)
  6718. var subMarkerControls = buildSubMarkerControls('topright', +deltaX, -deltaZ)
  6719. file.subMarkersControls.push(subMarkerControls)
  6720. var subMarkerControls = buildSubMarkerControls('bottomleft', -deltaX, +deltaZ)
  6721. file.subMarkersControls.push(subMarkerControls)
  6722. var subMarkerControls = buildSubMarkerControls('bottomright', +deltaX, +deltaZ)
  6723. file.subMarkersControls.push(subMarkerControls)
  6724. return file
  6725. //////////////////////////////////////////////////////////////////////////////
  6726. // Code Separator
  6727. //////////////////////////////////////////////////////////////////////////////
  6728. function buildSubMarkerControls(layout, positionX, positionZ){
  6729. console.log('buildSubMarkerControls', layout, positionX, positionZ)
  6730. // create subMarkersControls
  6731. var subMarkersControls = {
  6732. parameters: {},
  6733. poseMatrix: new THREE.Matrix4().makeTranslation(positionX,0, positionZ).toArray(),
  6734. }
  6735. // fill the parameters
  6736. if( trackingBackend === 'artoolkit' ){
  6737. layout2MarkerParametersArtoolkit(subMarkersControls.parameters, layout)
  6738. }else if( trackingBackend === 'aruco' ){
  6739. layout2MarkerParametersAruco(subMarkersControls.parameters, layout)
  6740. }else console.assert(false)
  6741. // return subMarkersControls
  6742. return subMarkersControls
  6743. }
  6744. function layout2MarkerParametersArtoolkit(parameters, layout){
  6745. // create absoluteBaseURL
  6746. var link = document.createElement('a')
  6747. link.href = ARjs.Context.baseURL
  6748. var absoluteBaseURL = link.href
  6749. var layout2PatternUrl = {
  6750. 'center' : convertRelativeUrlToAbsolute(absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-hiro.patt'),
  6751. 'topleft' : convertRelativeUrlToAbsolute(absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-letterA.patt'),
  6752. 'topright' : convertRelativeUrlToAbsolute(absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-letterB.patt'),
  6753. 'bottomleft' : convertRelativeUrlToAbsolute(absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-letterC.patt'),
  6754. 'bottomright' : convertRelativeUrlToAbsolute(absoluteBaseURL + 'examples/marker-training/examples/pattern-files/pattern-letterF.patt'),
  6755. }
  6756. console.assert(layout2PatternUrl[layout] !== undefined )
  6757. parameters.type = 'pattern'
  6758. parameters.patternUrl = layout2PatternUrl[layout]
  6759. return
  6760. function convertRelativeUrlToAbsolute(relativeUrl){
  6761. var tmpLink = document.createElement('a');
  6762. tmpLink.href = relativeUrl
  6763. return tmpLink.href
  6764. }
  6765. }
  6766. function layout2MarkerParametersAruco(parameters, layout){
  6767. var layout2Barcode = {
  6768. 'center' : 1001,
  6769. 'topleft' : 1002,
  6770. 'topright' : 1003,
  6771. 'bottomleft' : 1004,
  6772. 'bottomright' : 1005,
  6773. }
  6774. console.assert(layout2Barcode[layout])
  6775. parameters.type = 'barcode'
  6776. parameters.barcodeValue = layout2Barcode[layout]
  6777. }
  6778. }
  6779. AFRAME.registerSystem('arjs', {
  6780. schema: {
  6781. trackingMethod : {
  6782. type: 'string',
  6783. default: 'best',
  6784. },
  6785. debugUIEnabled :{
  6786. type: 'boolean',
  6787. default: true,
  6788. },
  6789. areaLearningButton : {
  6790. type: 'boolean',
  6791. default: true,
  6792. },
  6793. performanceProfile : {
  6794. type: 'string',
  6795. default: 'default',
  6796. },
  6797. tangoPointCloudEnabled : {
  6798. type: 'boolean',
  6799. default: false,
  6800. },
  6801. // old parameters
  6802. debug : {
  6803. type: 'boolean',
  6804. default: false
  6805. },
  6806. detectionMode : {
  6807. type: 'string',
  6808. default: '',
  6809. },
  6810. matrixCodeType : {
  6811. type: 'string',
  6812. default: '',
  6813. },
  6814. patternRatio : {
  6815. type: 'number',
  6816. default: -1,
  6817. },
  6818. cameraParametersUrl : {
  6819. type: 'string',
  6820. default: '',
  6821. },
  6822. maxDetectionRate : {
  6823. type: 'number',
  6824. default: -1
  6825. },
  6826. sourceType : {
  6827. type: 'string',
  6828. default: '',
  6829. },
  6830. sourceUrl : {
  6831. type: 'string',
  6832. default: '',
  6833. },
  6834. sourceWidth : {
  6835. type: 'number',
  6836. default: -1
  6837. },
  6838. sourceHeight : {
  6839. type: 'number',
  6840. default: -1
  6841. },
  6842. deviceId : {
  6843. type: 'string',
  6844. default: ''
  6845. },
  6846. displayWidth : {
  6847. type: 'number',
  6848. default: -1
  6849. },
  6850. displayHeight : {
  6851. type: 'number',
  6852. default: -1
  6853. },
  6854. canvasWidth : {
  6855. type: 'number',
  6856. default: -1
  6857. },
  6858. canvasHeight : {
  6859. type: 'number',
  6860. default: -1
  6861. },
  6862. },
  6863. //////////////////////////////////////////////////////////////////////////////
  6864. // Code Separator
  6865. //////////////////////////////////////////////////////////////////////////////
  6866. init: function () {
  6867. var _this = this
  6868. //////////////////////////////////////////////////////////////////////////////
  6869. // setup arProfile
  6870. //////////////////////////////////////////////////////////////////////////////
  6871. this._arSession = null
  6872. _this.isReady = false
  6873. _this.needsOverride = true
  6874. if(window.ARjs) {
  6875. var arProfile = this._arProfile = new ARjs.Profile()
  6876. .trackingMethod(this.data.trackingMethod)
  6877. .performance(this.data.performanceProfile)
  6878. .defaultMarker()
  6879. //////////////////////////////////////////////////////////////////////////////
  6880. // honor this.data and setup arProfile with it
  6881. //////////////////////////////////////////////////////////////////////////////
  6882. // honor this.data and push what has been modified into arProfile
  6883. if( this.data.debug !== false ) arProfile.contextParameters.debug = this.data.debug
  6884. if( this.data.detectionMode !== '' ) arProfile.contextParameters.detectionMode = this.data.detectionMode
  6885. if( this.data.matrixCodeType !== '' ) arProfile.contextParameters.matrixCodeType = this.data.matrixCodeType
  6886. if( this.data.patternRatio !== -1 ) arProfile.contextParameters.patternRatio = this.data.patternRatio
  6887. if( this.data.cameraParametersUrl !== '' ) arProfile.contextParameters.cameraParametersUrl = this.data.cameraParametersUrl
  6888. if( this.data.maxDetectionRate !== -1 ) arProfile.contextParameters.maxDetectionRate = this.data.maxDetectionRate
  6889. if( this.data.canvasWidth !== -1 ) arProfile.contextParameters.canvasWidth = this.data.canvasWidth
  6890. if( this.data.canvasHeight !== -1 ) arProfile.contextParameters.canvasHeight = this.data.canvasHeight
  6891. if( this.data.sourceType !== '' ) arProfile.sourceParameters.sourceType = this.data.sourceType
  6892. if( this.data.sourceUrl !== '' ) arProfile.sourceParameters.sourceUrl = this.data.sourceUrl
  6893. if( this.data.sourceWidth !== -1 ) arProfile.sourceParameters.sourceWidth = this.data.sourceWidth
  6894. if( this.data.sourceHeight !== -1 ) arProfile.sourceParameters.sourceHeight = this.data.sourceHeight
  6895. if( this.data.deviceId !== '' ) arProfile.sourceParameters.deviceId = this.data.deviceId
  6896. if( this.data.displayWidth !== -1 ) arProfile.sourceParameters.displayWidth = this.data.displayWidth
  6897. if( this.data.displayHeight !== -1 ) arProfile.sourceParameters.displayHeight = this.data.displayHeight
  6898. arProfile.checkIfValid()
  6899. //////////////////////////////////////////////////////////////////////////////
  6900. // Code Separator
  6901. //////////////////////////////////////////////////////////////////////////////
  6902. this._arSession = null
  6903. _this.isReady = false
  6904. _this.needsOverride = true
  6905. // wait until the renderer is isReady
  6906. // this.el.sceneEl.addEventListener('makeActiveCamera', function(){
  6907. // console.log('GET FROM SCENE!!');
  6908. // })
  6909. //'renderstart'
  6910. this.el.sceneEl.addEventListener('makeActiveCamera', function(){
  6911. if(_this._arSession){
  6912. return
  6913. }
  6914. //let arCamera = document.getElementById('arControlParent').getAttribute('camera');
  6915. var scene = _this.el.sceneEl.object3D
  6916. var camera = _this.el.sceneEl.camera
  6917. var renderer = _this.el.sceneEl.renderer
  6918. //////////////////////////////////////////////////////////////////////////////
  6919. // build ARjs.Session
  6920. //////////////////////////////////////////////////////////////////////////////
  6921. var arSession = _this._arSession = new ARjs.Session({
  6922. scene: scene,
  6923. renderer: renderer,
  6924. camera: camera,
  6925. sourceParameters: arProfile.sourceParameters,
  6926. contextParameters: arProfile.contextParameters
  6927. })
  6928. //////////////////////////////////////////////////////////////////////////////
  6929. // tango specifics - _tangoPointCloud
  6930. //////////////////////////////////////////////////////////////////////////////
  6931. _this._tangoPointCloud = null
  6932. if( arProfile.contextParameters.trackingBackend === 'tango' && _this.data.tangoPointCloudEnabled ){
  6933. // init tangoPointCloud
  6934. var tangoPointCloud = _this._tangoPointCloud = new ARjs.TangoPointCloud(arSession)
  6935. scene.add(tangoPointCloud.object3d)
  6936. }
  6937. //////////////////////////////////////////////////////////////////////////////
  6938. // tango specifics - _tangoVideoMesh
  6939. //////////////////////////////////////////////////////////////////////////////
  6940. _this._tangoVideoMesh = null
  6941. if( arProfile.contextParameters.trackingBackend === 'tango' ){
  6942. // init tangoVideoMesh
  6943. var tangoVideoMesh = _this._tangoVideoMesh = new ARjs.TangoVideoMesh(arSession)
  6944. // override renderer.render to render tangoVideoMesh
  6945. var rendererRenderFct = renderer.render;
  6946. renderer.render = function customRender(scene, camera, renderTarget, forceClear) {
  6947. renderer.autoClear = false;
  6948. // clear it all
  6949. renderer.clear()
  6950. // render tangoVideoMesh
  6951. if( arProfile.contextParameters.trackingBackend === 'tango' ){
  6952. // FIXME fails on three.js r84
  6953. // render sceneOrtho
  6954. rendererRenderFct.call(renderer, tangoVideoMesh._sceneOrtho, tangoVideoMesh._cameraOrtho, renderTarget, forceClear)
  6955. // Render the perspective scene
  6956. renderer.clearDepth()
  6957. }
  6958. // render 3d scene
  6959. rendererRenderFct.call(renderer, scene, camera, renderTarget, forceClear);
  6960. }
  6961. }
  6962. //////////////////////////////////////////////////////////////////////////////
  6963. // Code Separator
  6964. //////////////////////////////////////////////////////////////////////////////
  6965. _this.isReady = true
  6966. //////////////////////////////////////////////////////////////////////////////
  6967. // awefull resize trick
  6968. //////////////////////////////////////////////////////////////////////////////
  6969. // KLUDGE
  6970. window.addEventListener('resize', onResize)
  6971. function onResize(){
  6972. var arSource = _this._arSession.arSource
  6973. // ugly kludge to get resize on aframe... not even sure it works
  6974. if( arProfile.contextParameters.trackingBackend !== 'tango' ){
  6975. arSource.copyElementSizeTo(document.body)
  6976. }
  6977. // fixing a-frame css
  6978. var buttonElement = document.querySelector('.a-enter-vr')
  6979. if( buttonElement ){
  6980. buttonElement.style.position = 'fixed'
  6981. }
  6982. }
  6983. //////////////////////////////////////////////////////////////////////////////
  6984. // honor .debugUIEnabled
  6985. //////////////////////////////////////////////////////////////////////////////
  6986. if( _this.data.debugUIEnabled ) initDebugUI()
  6987. function initDebugUI(){
  6988. // get or create containerElement
  6989. var containerElement = document.querySelector('#arjsDebugUIContainer')
  6990. if( containerElement === null ){
  6991. containerElement = document.createElement('div')
  6992. containerElement.id = 'arjsDebugUIContainer'
  6993. containerElement.setAttribute('style', 'position: fixed; bottom: 10px; width:100%; text-align: center; z-index: 1;color: grey;')
  6994. document.body.appendChild(containerElement)
  6995. }
  6996. // create sessionDebugUI
  6997. var sessionDebugUI = new ARjs.SessionDebugUI(arSession)
  6998. containerElement.appendChild(sessionDebugUI.domElement)
  6999. }
  7000. })
  7001. //////////////////////////////////////////////////////////////////////////////
  7002. // Code Separator
  7003. //////////////////////////////////////////////////////////////////////////////
  7004. // TODO this is crappy - code an exponential backoff - max 1 seconds
  7005. // KLUDGE: kludge to write a 'resize' event
  7006. var startedAt = Date.now()
  7007. var timerId = setInterval(function(){
  7008. if( Date.now() - startedAt > 10000*1000 ){
  7009. clearInterval(timerId)
  7010. return
  7011. }
  7012. // onResize()
  7013. window.dispatchEvent(new Event('resize'));
  7014. }, 1000/30)
  7015. }
  7016. },
  7017. tick : function(now, delta){
  7018. var _this = this
  7019. // skip it if not yet isInitialised
  7020. if( this.isReady === false ) return
  7021. var arSession = this._arSession
  7022. // update arSession
  7023. this._arSession.update()
  7024. if( _this._tangoVideoMesh !== null ) _this._tangoVideoMesh.update()
  7025. // copy projection matrix to camera
  7026. this._arSession.onResize()
  7027. },
  7028. })