1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *)(* Copyright (c) 2022 DaiLambda, Inc. <contact@dailambda,jp> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)openProtocolopenEnvironmentopenError_monadopenAlpha_contextopenScript_typed_irmoduleStack_utils=structtypekinstr_rewritek={apply:'b'u'r'f.('b,'u)stack_ty->('b,'u,'r,'f)kinstr->('b,'u,'r,'f)kinstr;}[@@ocaml.unboxed](* An existential wrapper around failed [kinstr], whose final stack type
is hidden as it is irrelevant. *)type('a,'s)failed_kinstr_cast={cast:'b'u.('a,'s,'b,'u)kinstr}[@@ocaml.unboxed](* This is a view on a deconstructed [kinstr]. Its type parameters refer to
the type of the viewed [kinstr], while existentials inside describe types of
[kinstr]'s components. The [reconstruct] field in each record stores a
function which reconstructs the original instruction from its components. *)type('a,'s,'r,'f)ex_split_kinstr=|Ex_split_kinstr:{cont_init_stack:('b,'u)stack_ty;continuation:('b,'u,'r,'f)kinstr;reconstruct:('b,'u,'r,'f)kinstr->('a,'s,'r,'f)kinstr;}->('a,'s,'r,'f)ex_split_kinstr|Ex_split_log:{stack:('a,'s)stack_ty;continuation:('a,'s,'r,'f)kinstr;reconstruct:('a,'s,'r,'f)kinstr->('a,'s,'r,'f)kinstr;}->('a,'s,'r,'f)ex_split_kinstr|Ex_split_loop_may_fail:{body_init_stack:('b,'u)stack_ty;body:('b,'u,'r,'f)kinstr;cont_init_stack:('c,'v)stack_ty;continuation:('c,'v,'t,'g)kinstr;reconstruct:('b,'u,'r,'f)kinstr->('c,'v,'t,'g)kinstr->('a,'s,'t,'g)kinstr;}->('a,'s,'t,'g)ex_split_kinstr|Ex_split_loop_may_not_fail:{body_init_stack:('b,'u)stack_ty;body:('b,'u,'r,'f)kinstr;continuation:('c,'v,'t,'g)kinstr;aft_body_stack_transform:('r,'f)stack_ty->('c,'v)stack_tytzresult;reconstruct:('b,'u,'r,'f)kinstr->('c,'v,'t,'g)kinstr->('a,'s,'t,'g)kinstr;}->('a,'s,'t,'g)ex_split_kinstr|Ex_split_if:{left_init_stack:('b,'u)stack_ty;left_branch:('b,'u,'r,'f)kinstr;right_init_stack:('c,'v)stack_ty;right_branch:('c,'v,'r,'f)kinstr;continuation:('r,'f,'t,'g)kinstr;reconstruct:('b,'u,'r,'f)kinstr->('c,'v,'r,'f)kinstr->('r,'f,'t,'g)kinstr->('a,'s,'t,'g)kinstr;}->('a,'s,'t,'g)ex_split_kinstr|Ex_split_halt:Script.location->('a,'s,'a,'s)ex_split_kinstr|Ex_split_failwith:{location:Script.location;arg_ty:('a,_)ty;cast:('a,'s)failed_kinstr_cast;}->('a,'s,'r,'f)ex_split_kinstr(** An existential container for an instruction paired with its
initial stack type. This is used internally to pack together
execution branches with different initial stack types but
the same final stack type (which we want to compute). *)type('r,'f)ex_init_stack_ty=|Ex_init_stack_ty:('a,'s)stack_ty*('a,'s,'r,'f)kinstr->('r,'f)ex_init_stack_tyletrecstack_prefix_preservation_witness_split_input:typeasbtcudv.(b,t,c,u,a,s,d,v)stack_prefix_preservation_witness->(a,s)stack_ty->(b,t)stack_ty=funws->match(w,s)with|KPrefix(_,_,w),Item_t(_,s)->stack_prefix_preservation_witness_split_inputws|KRest,s->sletrecstack_prefix_preservation_witness_split_output:typeasbtcudv.(b,t,c,u,a,s,d,v)stack_prefix_preservation_witness->(c,u)stack_ty->(d,v)stack_ty=funws->match(w,s)with|KPrefix(_,a,w),s->Item_t(a,stack_prefix_preservation_witness_split_outputws)|KRest,s->s(* We apply this function to optional type information which must be present
if functions from this module were called. Use with care. *)letassert_some=functionNone->assertfalse|Somex->xletkinstr_split:typeasrf.(a,s)stack_ty->(a,s,r,f)kinstr->(a,s,r,f)ex_split_kinstrtzresult=funsi->letdummy=Micheline.dummy_locationinmatch(i,s)with|IDrop(loc,k),Item_t(_a,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IDrop(loc,k));}|IDup(loc,k),Item_t(a,s)->lets=Item_t(a,Item_t(a,s))inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IDup(loc,k));}|ISwap(loc,k),Item_t(a,Item_t(b,s))->lets=Item_t(b,Item_t(a,s))inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISwap(loc,k));}|IConst(loc,a,x,k),s->lets=Item_t(a,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IConst(loc,a,x,k));}|ICons_pair(loc,k),Item_t(a,Item_t(b,s))->pair_tdummyab>|?fun(Ty_ex_cc)->lets=Item_t(c,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICons_pair(loc,k));}|ICar(loc,k),Item_t(Pair_t(a,_b,_meta,_),s)->lets=Item_t(a,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICar(loc,k));}|ICdr(loc,k),Item_t(Pair_t(_a,b,_meta,_),s)->lets=Item_t(b,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICdr(loc,k));}|IUnpair(loc,k),Item_t(Pair_t(a,b,_meta,_),s)->lets=Item_t(a,Item_t(b,s))inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IUnpair(loc,k));}|ICons_some(loc,k),Item_t(a,s)->option_tdummya>|?funo->lets=Item_t(o,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICons_some(loc,k));}|ICons_none(loc,a,k),s->option_tdummya>|?funo->lets=Item_t(o,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICons_none(loc,a,k));}|(IIf_none{loc;branch_if_none;branch_if_some;k},Item_t(Option_t(a,_meta,_),s))->ok@@Ex_split_if{left_init_stack=s;left_branch=branch_if_none;right_init_stack=Item_t(a,s);right_branch=branch_if_some;continuation=k;reconstruct=(funbranch_if_nonebranch_if_somek->IIf_none{loc;branch_if_none;branch_if_some;k});}|IOpt_map{loc;body;k},Item_t(Option_t(a,_meta,_),s)->ok@@Ex_split_loop_may_not_fail{body_init_stack=Item_t(a,s);body;continuation=k;aft_body_stack_transform=(function|Item_t(b,s)->option_tdummyb>|?funo->Item_t(o,s));reconstruct=(funbodyk->IOpt_map{loc;body;k});}|ICons_left(loc,b,k),Item_t(a,s)->union_tdummyab>|?fun(Ty_ex_cc)->lets=Item_t(c,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICons_left(loc,b,k));}|ICons_right(loc,a,k),Item_t(b,s)->union_tdummyab>|?fun(Ty_ex_cc)->lets=Item_t(c,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICons_right(loc,a,k));}|(IIf_left{loc;branch_if_left;branch_if_right;k},Item_t(Union_t(a,b,_meta,_),s))->ok@@Ex_split_if{left_init_stack=Item_t(a,s);left_branch=branch_if_left;right_init_stack=Item_t(b,s);right_branch=branch_if_right;continuation=k;reconstruct=(funbranch_if_leftbranch_if_rightk->IIf_left{loc;branch_if_left;branch_if_right;k});}|ICons_list(loc,k),Item_t(_a,Item_t(l,s))->lets=Item_t(l,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICons_list(loc,k));}|INil(loc,a,k),s->list_tdummya>|?funl->lets=Item_t(l,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INil(loc,a,k));}|(IIf_cons{loc;branch_if_cons;branch_if_nil;k},Item_t((List_t(a,_meta)asl),s))->ok@@Ex_split_if{left_init_stack=Item_t(a,Item_t(l,s));left_branch=branch_if_cons;right_init_stack=s;right_branch=branch_if_nil;continuation=k;reconstruct=(funbranch_if_consbranch_if_nilk->IIf_cons{loc;branch_if_cons;branch_if_nil;k});}|IList_map(loc,body,ty,k),Item_t(List_t(a,_meta),s)->lets=Item_t(a,s)inok@@Ex_split_loop_may_not_fail{body_init_stack=s;body;continuation=k;aft_body_stack_transform=(function|Item_t(b,s)->list_tdummyb>|?funl->Item_t(l,s));reconstruct=(funbodyk->IList_map(loc,body,ty,k));}|IList_iter(loc,ty,body,k),Item_t(List_t(a,_meta),s)->ok@@Ex_split_loop_may_fail{body_init_stack=Item_t(a,s);body;cont_init_stack=s;continuation=k;reconstruct=(funbodyk->IList_iter(loc,ty,body,k));}|IList_size(loc,k),Item_t(_l,s)->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IList_size(loc,k));}|IEmpty_set(loc,a,k),s->set_tdummya>|?funb->lets=Item_t(b,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IEmpty_set(loc,a,k));}|ISet_iter(loc,a,body,k),Item_t(_b,s)->ok@@Ex_split_loop_may_fail{body_init_stack=Item_t(assert_somea,s);body;cont_init_stack=s;continuation=k;reconstruct=(funbodyk->ISet_iter(loc,a,body,k));}|ISet_mem(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISet_mem(loc,k));}|ISet_update(loc,k),Item_t(_,Item_t(_,s))->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISet_update(loc,k));}|ISet_size(loc,k),Item_t(_,s)->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISet_size(loc,k));}|IEmpty_map(loc,cty,vty,k),s->map_tdummycty(assert_somevty)>|?funm->lets=Item_t(m,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IEmpty_map(loc,cty,vty,k));}|IMap_map(loc,ty,body,k),Item_t(Map_t(kty,vty,_meta),s)->let(Map_t(key_ty,_,_))=assert_sometyinpair_tdummykey_tyvty>|?fun(Ty_ex_cp)->Ex_split_loop_may_not_fail{body_init_stack=Item_t(p,s);body;continuation=k;aft_body_stack_transform=(fun(Item_t(b,s))->map_tdummyktyb>|?funm->Item_t(m,s));reconstruct=(funbodyk->IMap_map(loc,ty,body,k));}|IMap_iter(loc,kvty,body,k),Item_t(_,stack)->ok@@Ex_split_loop_may_fail{body_init_stack=Item_t(assert_somekvty,stack);body;cont_init_stack=stack;continuation=k;reconstruct=(funbodyk->IMap_iter(loc,kvty,body,k));}|IMap_mem(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMap_mem(loc,k));}|IMap_get(loc,k),Item_t(_,Item_t(Map_t(_kty,vty,_meta),s))->option_tdummyvty>|?funo->lets=Item_t(o,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMap_get(loc,k));}|IMap_update(loc,k),Item_t(_,Item_t(_,s))->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMap_update(loc,k));}|IMap_get_and_update(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMap_get_and_update(loc,k));}|IMap_size(loc,k),Item_t(_,s)->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMap_size(loc,k));}|IEmpty_big_map(loc,cty,ty,k),s->big_map_tdummyctyty>|?funb->lets=Item_t(b,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IEmpty_big_map(loc,cty,ty,k));}|IBig_map_mem(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IBig_map_mem(loc,k));}|IBig_map_get(loc,k),Item_t(_,Item_t(Big_map_t(_kty,vty,_meta),s))->option_tdummyvty>|?funo->lets=Item_t(o,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IBig_map_get(loc,k));}|IBig_map_update(loc,k),Item_t(_,Item_t(_,s))->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IBig_map_update(loc,k));}|IBig_map_get_and_update(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IBig_map_get_and_update(loc,k));}|IConcat_string(loc,k),Item_t(_,s)->lets=Item_t(string_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IConcat_string(loc,k));}|IConcat_string_pair(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IConcat_string_pair(loc,k));}|ISlice_string(loc,k),Item_t(_,Item_t(_,Item_t(_,s)))->lets=Item_t(option_string_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISlice_string(loc,k));}|IString_size(loc,k),Item_t(_,s)->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IString_size(loc,k));}|IConcat_bytes(loc,k),Item_t(_,s)->lets=Item_t(bytes_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IConcat_bytes(loc,k));}|IConcat_bytes_pair(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IConcat_bytes_pair(loc,k));}|ISlice_bytes(loc,k),Item_t(_,Item_t(_,Item_t(_,s)))->lets=Item_t(option_bytes_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISlice_bytes(loc,k));}|IBytes_size(loc,k),Item_t(_,s)->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IBytes_size(loc,k));}|ILsl_bytes(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(bytes_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ILsl_bytes(loc,k));}|ILsr_bytes(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(bytes_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ILsr_bytes(loc,k));}|IOr_bytes(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IOr_bytes(loc,k));}|IAnd_bytes(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAnd_bytes(loc,k));}|IXor_bytes(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IXor_bytes(loc,k));}|INot_bytes(loc,k),Item_t(_,s)->lets=Item_t(bytes_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INot_bytes(loc,k));}|IBytes_nat(loc,k),Item_t(_,s)->lets=Item_t(bytes_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IBytes_nat(loc,k));}|INat_bytes(loc,k),Item_t(_,s)->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INat_bytes(loc,k));}|IBytes_int(loc,k),Item_t(_,s)->lets=Item_t(bytes_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IBytes_int(loc,k));}|IInt_bytes(loc,k),Item_t(_,s)->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IInt_bytes(loc,k));}|IAdd_seconds_to_timestamp(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAdd_seconds_to_timestamp(loc,k));}|IAdd_timestamp_to_seconds(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(timestamp_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAdd_timestamp_to_seconds(loc,k));}|ISub_timestamp_seconds(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(timestamp_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISub_timestamp_seconds(loc,k));}|IDiff_timestamps(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IDiff_timestamps(loc,k));}|IAdd_tez(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAdd_tez(loc,k));}|ISub_tez(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(option_mutez_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISub_tez(loc,k));}|ISub_tez_legacy(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISub_tez_legacy(loc,k));}|IMul_teznat(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(mutez_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMul_teznat(loc,k));}|IMul_nattez(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMul_nattez(loc,k));}|IEdiv_teznat(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(option_pair_mutez_mutez_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IEdiv_teznat(loc,k));}|IEdiv_tez(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(option_pair_nat_mutez_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IEdiv_tez(loc,k));}|IOr(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IOr(loc,k));}|IAnd(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAnd(loc,k));}|IXor(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IXor(loc,k));}|INot(loc,k),s->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INot(loc,k));}|IIs_nat(loc,k),Item_t(_,s)->lets=Item_t(option_nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IIs_nat(loc,k));}|INeg(loc,k),Item_t(_,s)->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INeg(loc,k));}|IAbs_int(loc,k),Item_t(_,s)->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAbs_int(loc,k));}|IInt_nat(loc,k),Item_t(_,s)->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IInt_nat(loc,k));}|IAdd_int(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAdd_int(loc,k));}|IAdd_nat(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAdd_nat(loc,k));}|ISub_int(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISub_int(loc,k));}|IMul_int(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMul_int(loc,k));}|IMul_nat(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMul_nat(loc,k));}|IEdiv_int(loc,k),Item_t(_,Item_t(_,s))->lets=Item_t(option_pair_int_nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IEdiv_int(loc,k));}|IEdiv_nat(loc,k),Item_t(_,Item_t(a,s))->pair_tdummyanat_t>>?fun(Ty_ex_cp)->option_tdummyp>|?funo->lets=Item_t(o,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IEdiv_nat(loc,k));}|ILsl_nat(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ILsl_nat(loc,k));}|ILsr_nat(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ILsr_nat(loc,k));}|IOr_nat(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IOr_nat(loc,k));}|IAnd_nat(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAnd_nat(loc,k));}|IAnd_int_nat(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAnd_int_nat(loc,k));}|IXor_nat(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IXor_nat(loc,k));}|INot_int(loc,k),Item_t(_,s)->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INot_int(loc,k));}|IIf{loc;branch_if_true;branch_if_false;k},Item_t(_,s)->ok@@Ex_split_if{left_init_stack=s;left_branch=branch_if_true;right_init_stack=s;right_branch=branch_if_false;continuation=k;reconstruct=(funbranch_if_truebranch_if_falsek->IIf{loc;branch_if_true;branch_if_false;k});}|ILoop(loc,body,k),Item_t(_,s)->ok@@Ex_split_loop_may_fail{body_init_stack=s;body;cont_init_stack=s;continuation=k;reconstruct=(funbodyk->ILoop(loc,body,k));}|ILoop_left(loc,kl,kr),Item_t(Union_t(a,b,_meta,_),s)->ok@@Ex_split_loop_may_fail{body_init_stack=Item_t(a,s);body=kl;cont_init_stack=Item_t(b,s);continuation=kr;reconstruct=(funklkr->ILoop_left(loc,kl,kr));}|IDip(loc,body,ty,k),Item_t(a,s)->ok@@Ex_split_loop_may_not_fail{body_init_stack=s;body;continuation=k;aft_body_stack_transform=(funs->ok@@Item_t(a,s));reconstruct=(funbodyk->IDip(loc,body,ty,k));}|IExec(loc,sty,k),Item_t(_,Item_t(Lambda_t(_,b,_meta),s))->lets=Item_t(b,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IExec(loc,sty,k));}|(IApply(loc,ty,k),Item_t(_,Item_t(Lambda_t(Pair_t(_,a,_,_),b,_),s)))->lambda_tdummyab>|?funl->lets=Item_t(l,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IApply(loc,ty,k));}|ILambda(loc,(Lam(desc,_)asl),k),s->let(Item_t(a,Bot_t))=desc.kbefinlet(Item_t(b,Bot_t))=desc.kaftinlambda_tdummyab>|?funlam->lets=Item_t(lam,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ILambda(loc,l,k));}|ILambda(loc,(LamRec(desc,_)asl),k),s->let(Item_t(a,Item_t(Lambda_t_,Bot_t)))=desc.kbefinlet(Item_t(b,Bot_t))=desc.kaftinlambda_tdummyab>|?funlam->lets=Item_t(lam,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ILambda(loc,l,k));}|IFailwith(location,arg_ty),_->ok@@Ex_split_failwith{location;arg_ty;cast={cast=IFailwith(location,arg_ty)}}|ICompare(loc,ty,k),Item_t(_,Item_t(_,s))->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICompare(loc,ty,k));}|IEq(loc,k),Item_t(_,s)->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IEq(loc,k));}|INeq(loc,k),Item_t(_,s)->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INeq(loc,k));}|ILt(loc,k),Item_t(_,s)->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ILt(loc,k));}|IGt(loc,k),Item_t(_,s)->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IGt(loc,k));}|ILe(loc,k),Item_t(_,s)->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ILe(loc,k));}|IGe(loc,k),Item_t(_,s)->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IGe(loc,k));}|IAddress(loc,k),Item_t(_,s)->lets=Item_t(address_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAddress(loc,k));}|IContract(loc,ty,code,k),Item_t(_,s)->contract_tdummyty>>?func->option_tdummyc>|?funo->lets=Item_t(o,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IContract(loc,ty,code,k));}|ITransfer_tokens(loc,k),Item_t(_,Item_t(_,Item_t(_,s)))->lets=Item_t(operation_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ITransfer_tokens(loc,k));}|(IView(loc,(View_signature{output_ty;_}asview_signature),sty,k),Item_t(_,Item_t(_,s)))->option_tdummyoutput_ty>|?funb->lets=Item_t(b,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IView(loc,view_signature,sty,k));}|IImplicit_account(loc,k),Item_t(_,s)->lets=Item_t(contract_unit_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IImplicit_account(loc,k));}|(ICreate_contract{loc;storage_type;code;k},Item_t(_,Item_t(_,Item_t(_,s))))->ok@@Ex_split_kinstr{cont_init_stack=Item_t(operation_t,Item_t(address_t,s));continuation=k;reconstruct=(funk->ICreate_contract{loc;storage_type;code;k});}|ISet_delegate(loc,k),Item_t(_,s)->lets=Item_t(operation_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISet_delegate(loc,k));}|INow(loc,k),s->lets=Item_t(timestamp_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INow(loc,k));}|IBalance(loc,k),s->lets=Item_t(mutez_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IBalance(loc,k));}|ILevel(loc,k),s->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ILevel(loc,k));}|ICheck_signature(loc,k),Item_t(_,Item_t(_,Item_t(_,s)))->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ICheck_signature(loc,k));}|IHash_key(loc,k),Item_t(_,s)->lets=Item_t(key_hash_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IHash_key(loc,k));}|IPack(loc,ty,k),Item_t(_,s)->lets=Item_t(bytes_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IPack(loc,ty,k));}|IUnpack(loc,ty,k),Item_t(_,s)->option_tdummyty>|?funo->lets=Item_t(o,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IUnpack(loc,ty,k));}|IBlake2b(loc,k),s->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IBlake2b(loc,k));}|ISha256(loc,k),s->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISha256(loc,k));}|ISha512(loc,k),s->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISha512(loc,k));}|ISource(loc,k),s->lets=Item_t(address_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISource(loc,k));}|ISender(loc,k),s->lets=Item_t(address_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISender(loc,k));}|ISelf(loc,ty,ep,k),s->contract_tdummyty>|?func->lets=Item_t(c,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISelf(loc,ty,ep,k));}|ISelf_address(loc,k),s->lets=Item_t(address_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISelf_address(loc,k));}|IAmount(loc,k),s->lets=Item_t(mutez_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAmount(loc,k));}|ISapling_empty_state(loc,memo_size,k),s->ok@@Ex_split_kinstr{cont_init_stack=Item_t(sapling_state_t~memo_size,s);continuation=k;reconstruct=(funk->ISapling_empty_state(loc,memo_size,k));}|(ISapling_verify_update_deprecated(loc,k),Item_t(_,Item_t(state_ty,s)))->pair_tdummyint_tstate_ty>>?fun(Ty_ex_cpair_ty)->option_tdummypair_ty>|?funty->Ex_split_kinstr{cont_init_stack=Item_t(ty,s);continuation=k;reconstruct=(funk->ISapling_verify_update_deprecated(loc,k));}|ISapling_verify_update(loc,k),Item_t(_,Item_t(state_ty,s))->pair_tdummyint_tstate_ty>>?fun(Ty_ex_cint_state_ty)->pair_tdummybytes_tint_state_ty>>?fun(Ty_ex_cpair_ty)->option_tdummypair_ty>|?funty->lets=Item_t(ty,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISapling_verify_update(loc,k));}|IDig(loc,n,p,k),s->let(Item_t(b,s))=stack_prefix_preservation_witness_split_inputpsinlets=stack_prefix_preservation_witness_split_outputpsinlets=Item_t(b,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IDig(loc,n,p,k));}|IDug(loc,n,p,k),Item_t(a,s)->lets=stack_prefix_preservation_witness_split_inputpsinlets=Item_t(a,s)inlets=stack_prefix_preservation_witness_split_outputpsinok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IDug(loc,n,p,k));}|IDipn(loc,n,p,k1,k2),s->ok@@Ex_split_loop_may_not_fail{body_init_stack=stack_prefix_preservation_witness_split_inputps;body=k1;continuation=k2;aft_body_stack_transform=(funs->ok@@stack_prefix_preservation_witness_split_outputps);reconstruct=(funk1k2->IDipn(loc,n,p,k1,k2));}|IDropn(loc,n,p,k),s->lets=stack_prefix_preservation_witness_split_inputpsinok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IDropn(loc,n,p,k));}|IChainId(loc,k),s->lets=Item_t(chain_id_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IChainId(loc,k));}|INeverlocation,Item_t(arg_ty,_)->ok@@Ex_split_failwith{location;arg_ty;cast={cast=INeverlocation}}|IVoting_power(loc,k),Item_t(_,s)->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IVoting_power(loc,k));}|ITotal_voting_power(loc,k),s->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ITotal_voting_power(loc,k));}|IKeccak(loc,k),s->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IKeccak(loc,k));}|ISha3(loc,k),s->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISha3(loc,k));}|IAdd_bls12_381_g1(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAdd_bls12_381_g1(loc,k));}|IAdd_bls12_381_g2(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAdd_bls12_381_g2(loc,k));}|IAdd_bls12_381_fr(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IAdd_bls12_381_fr(loc,k));}|IMul_bls12_381_g1(loc,k),Item_t(g1,Item_t(_,s))->lets=Item_t(g1,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMul_bls12_381_g1(loc,k));}|IMul_bls12_381_g2(loc,k),Item_t(g2,Item_t(_,s))->lets=Item_t(g2,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMul_bls12_381_g2(loc,k));}|IMul_bls12_381_fr(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMul_bls12_381_fr(loc,k));}|IMul_bls12_381_z_fr(loc,k),Item_t(fr,Item_t(_,s))->lets=Item_t(fr,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMul_bls12_381_z_fr(loc,k));}|IMul_bls12_381_fr_z(loc,k),Item_t(_,s)->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMul_bls12_381_fr_z(loc,k));}|IInt_bls12_381_fr(loc,k),Item_t(_,s)->lets=Item_t(int_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IInt_bls12_381_fr(loc,k));}|INeg_bls12_381_g1(loc,k),s->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INeg_bls12_381_g1(loc,k));}|INeg_bls12_381_g2(loc,k),s->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INeg_bls12_381_g2(loc,k));}|INeg_bls12_381_fr(loc,k),s->ok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->INeg_bls12_381_fr(loc,k));}|IPairing_check_bls12_381(loc,k),Item_t(_,s)->lets=Item_t(bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IPairing_check_bls12_381(loc,k));}|IComb(loc,n,p,k),s->letrecaux:typeabscdt.(a,b*s)stack_ty->(a,b,s,c,d,t)comb_gadt_witness->(c,d*t)stack_tytzresult=funsw->match(w,s)with|Comb_one,s->oks|Comb_succw,Item_t(a,s)->auxsw>>?fun(Item_t(c,t))->pair_tdummyac>|?fun(Ty_ex_cp)->Item_t(p,t)inauxsp>|?funs->Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IComb(loc,n,p,k));}|IUncomb(loc,n,p,k),s->letrecaux:typeabscdt.(a,b*s)stack_ty->(a,b,s,c,d,t)uncomb_gadt_witness->(c,d*t)stack_ty=funsw->match(w,s)with|Uncomb_one,s->s|Uncomb_succw,Item_t(Pair_t(a,b,_meta,_),s)->lets=aux(Item_t(b,s))winItem_t(a,s)inlets=auxspinok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IUncomb(loc,n,p,k));}|IComb_get(loc,n,p,k),Item_t(c,s)->letrecaux:typeccca.(c,cc)ty->(c,a)comb_get_gadt_witness->aty_ex_c=funcw->match(w,c)with|Comb_get_zero,c->Ty_ex_cc|Comb_get_one,Pair_t(hd,_tl,_meta,_)->Ty_ex_chd|Comb_get_plus_twow,Pair_t(_hd,tl,_meta,_)->auxtlwinlets=let(Ty_ex_cty)=auxcpinItem_t(ty,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IComb_get(loc,n,p,k));}|IComb_set(loc,n,p,k),Item_t(a,Item_t(b,s))->letrecaux:typeabccacb.(a,ca)ty->(b,cb)ty->(a,b,c)comb_set_gadt_witness->cty_ex_ctzresult=funabw->match(w,b)with|Comb_set_zero,_->ok(Ty_ex_ca)|Comb_set_one,Pair_t(_hd,tl,_meta,_)->pair_tdummyatl|Comb_set_plus_twow,Pair_t(hd,tl,_meta,_)->auxatlw>>?fun(Ty_ex_cc)->pair_tdummyhdcinauxabp>|?fun(Ty_ex_cc)->lets=Item_t(c,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IComb_set(loc,n,p,k));}|IDup_n(loc,n,p,k),s->letrecaux:typeabst.(a,b*s)stack_ty->(a,b,s,t)dup_n_gadt_witness->tty_ex_c=funsw->match(w,s)with|Dup_n_succw,Item_t(_,s)->auxsw|Dup_n_zero,Item_t(a,_)->Ty_ex_cainlets=let(Ty_ex_cty)=auxspinItem_t(ty,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IDup_n(loc,n,p,k));}|ITicket(loc,cty,k),Item_t(_,Item_t(_,s))->ticket_tdummy(assert_somecty)>>?option_tloc>|?funt->lets=Item_t(t,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ITicket(loc,cty,k));}|ITicket_deprecated(loc,cty,k),Item_t(_,Item_t(_,s))->ticket_tdummy(assert_somecty)>|?funt->lets=Item_t(t,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ITicket_deprecated(loc,cty,k));}|IRead_ticket(loc,a,k),s->pair_tdummy(assert_somea)nat_t>>?fun(Ty_ex_cp)->pair_tdummyaddress_tp>|?fun(Ty_ex_ct)->lets=Item_t(t,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IRead_ticket(loc,a,k));}|ISplit_ticket(loc,k),Item_t(t,Item_t(_,s))->pair_tdummytt>>?fun(Ty_ex_cp)->option_tdummyp>|?funo->lets=Item_t(o,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->ISplit_ticket(loc,k));}|IJoin_tickets(loc,ty,k),Item_t(Pair_t(t,_t,_meta,_),s)->option_tdummyt>|?funo->lets=Item_t(o,s)inEx_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IJoin_tickets(loc,ty,k));}|IOpen_chest(loc,k),Item_t(_,Item_t(_,Item_t(_,s)))->lets=Item_t(union_bytes_bool_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IOpen_chest(loc,k));}|IMin_block_time(loc,k),s->lets=Item_t(nat_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IMin_block_time(loc,k));}|IEmit{loc;ty;unparsed_ty;tag;k},Item_t(_,s)->lets=Item_t(operation_t,s)inok@@Ex_split_kinstr{cont_init_stack=s;continuation=k;reconstruct=(funk->IEmit{loc;ty;unparsed_ty;tag;k});}|IEmit_,Bot_t->.|IHaltloc,_s->ok@@Ex_split_haltloc|ILog(loc,_stack_ty,event,logger,continuation),stack->ok@@Ex_split_log{stack;continuation;reconstruct=(funk->ILog(loc,s,event,logger,k));}(* [kinstr_final_stack_type sty instr] computes the stack type after
[instr] has been executed, assuming [sty] is the type of the stack
prior to execution. For the rare instructions which can return stacks
of any type ([FAILWITH] and [NEVER]), this function returns [None]. *)letreckinstr_final_stack_type:typeasrf.(a,s)stack_ty->(a,s,r,f)kinstr->(r,f)stack_tyoptiontzresult=funsi->kinstr_splitsi>>?function|Ex_split_kinstr{cont_init_stack;continuation;_}->kinstr_final_stack_typecont_init_stackcontinuation|Ex_split_log{stack;continuation;_}->kinstr_final_stack_typestackcontinuation|Ex_split_loop_may_fail{cont_init_stack;continuation;_}->kinstr_final_stack_typecont_init_stackcontinuation|Ex_split_loop_may_not_fail{body_init_stack;body;continuation;aft_body_stack_transform;_}->(kinstr_final_stack_typebody_init_stackbody>>?function|Someafter_body->aft_body_stack_transformafter_body>>?funbefore_k->kinstr_final_stack_typebefore_kcontinuation|None->okNone)|Ex_split_if{left_init_stack;left_branch;right_init_stack;right_branch;continuation;_;}->(kinstr_final_stack_typeleft_init_stackleft_branch>>?function|Someafter_branch_a->kinstr_final_stack_typeafter_branch_acontinuation|None->(kinstr_final_stack_typeright_init_stackright_branch>>?function|Someafter_branch_b->kinstr_final_stack_typeafter_branch_bcontinuation|None->okNone))|Ex_split_halt_->ok@@Somes|Ex_split_failwith{cast={cast=_};_}->okNone(* The same as [kinstr_final_stack_type], but selects from multiple
possible execution branches. If the first instr ends with FAILWITH,
it will try the next and so on. Note that all instructions must
result in the same stack type. *)letrecbranched_final_stack_type:typerf.(r,f)ex_init_stack_tylist->(r,f)stack_tyoptiontzresult=function|[]->okNone|Ex_init_stack_ty(init_sty,branch)::bs->(kinstr_final_stack_typeinit_stybranch>>?function|Some_assty->oksty|None->branched_final_stack_typebs)letkinstr_rewritek:typeasrf.(a,s)stack_ty->(a,s,r,f)kinstr->kinstr_rewritek->(a,s,r,f)kinstrtzresult=funsif->kinstr_splitsi>>?function|Ex_split_kinstr{cont_init_stack;continuation;reconstruct}->ok@@reconstruct(f.applycont_init_stackcontinuation)|Ex_split_log{continuation;reconstruct;_}->ok@@reconstructcontinuation|Ex_split_loop_may_fail{body_init_stack;body;cont_init_stack;continuation;reconstruct}->ok@@reconstruct(f.applybody_init_stackbody)(f.applycont_init_stackcontinuation)|Ex_split_loop_may_not_fail{body_init_stack;body;continuation;aft_body_stack_transform;reconstruct;}->(kinstr_final_stack_typebody_init_stackbody>>?function|Someafter_body->aft_body_stack_transformafter_body>|?funbefore_k->f.applybefore_kcontinuation|None->okcontinuation)>|?funk->reconstruct(f.applybody_init_stackbody)k|Ex_split_if{left_init_stack;left_branch;right_init_stack;right_branch;continuation;reconstruct;}->(kinstr_final_stack_typeleft_init_stackleft_branch>>?function|Someafter_left_branch->ok@@f.applyafter_left_branchcontinuation|None->(kinstr_final_stack_typeright_init_stackright_branch>>?function|Someafter_right_branch->ok@@f.applyafter_right_branchcontinuation|None->okcontinuation))>|?funk->reconstruct(f.applyleft_init_stackleft_branch)(f.applyright_init_stackright_branch)k|Ex_split_haltloc->ok@@IHaltloc|Ex_split_failwith{location;arg_ty;_}->ok@@IFailwith(location,arg_ty)(** [dipn_stack_ty witness stack_ty] returns the type of the stack
on which instructions inside dipped block will be operating. *)letrecdipn_stack_ty:typeasezcudw.(a,s,e,z,c,u,d,w)stack_prefix_preservation_witness->(c,u)stack_ty->(a,s)stack_ty=funwitnessstack->match(witness,stack)with|KPrefix(_,_,witness'),Item_t(_,sty)->dipn_stack_tywitness'sty|KRest,sty->sty(** [instrument_cont logger sty] creates a function instrumenting
continuations starting from the stack type described by [sty].
Instrumentation consists in wrapping inner continuations in
[KLog] continuation so that logging continues. *)letinstrument_cont:typeabcd.logger->(a,b)stack_ty->(a,b,c,d)continuation->(a,b,c,d)continuation=funloggersty->functionKLog_ask->k|k->KLog(k,sty,logger)endmoduletypeLogger_base=sigvallog_interp:('a,'s,'b,'f,'c,'u)logging_functionvallog_entry:('a,'s,'b,'f,'a,'s)logging_functionvallog_control:('a,'s,'b,'f)continuation->unitvallog_exit:('a,'s,'b,'f,'c,'u)logging_functionvalget_log:unit->execution_traceoptiontzresultLwt.tendmoduleLogger(Base:Logger_base)=structopenStack_utilsopenLocal_gas_counteropenScript_interpreter_defsopenScript_interpreter.Internals.Raw(** [log_entry ctxt gas instr sty accu stack] simply calls the
[Base.log_entry] function with the appropriate arguments. *)letlog_entryctxtgaskstyaccustack=letctxt=Local_gas_counter.update_contextgasctxtinBase.log_entrykctxt(kinstr_locationk)sty(accu,stack)(** [log_exit ctxt gas loc instr sty accu stack] simply calls the
[Base.log_exit] function with the appropriate arguments. *)letlog_exitctxtgasloc_prevkstyaccustack=letctxt=Local_gas_counter.update_contextgasctxtinBase.log_exitkctxtloc_prevsty(accu,stack)(** [log_control continuation] simply calls the [Base.log_control]
function with the appropriate arguments. *)letlog_controlks=Base.log_controlks(** [log_kinstr logger sty instr] returns [instr] prefixed by an
[ILog] instruction to log the first instruction in [instr]. *)letlog_kinstrloggerstyi=ILog(kinstr_locationi,sty,LogEntry,logger,i)(* [log_next_kinstr logger i] instruments the next instruction of [i]
with [ILog] instructions to make sure it will be logged.
This instrumentation has a performance cost, but importantly, it is
only ever paid when logging is enabled. Otherwise, the possibility
to instrument the script is costless.
Notice that the instrumentation breaks the sharing of continuations
that is normally enforced between branches of conditionals. This
has a performance cost. Anyway, the instrumentation allocates many
new [ILog] instructions and [KLog] continuations which makes
the execution of instrumented code significantly slower than
non-instrumented code. "Zero-cost logging" means that the normal
non-instrumented execution is not impacted by the ability to
instrument it, not that the logging itself has no cost.
*)letlog_next_kinstrloggerstyi=letapplystyk=ILog(kinstr_locationk,sty,LogExit(kinstr_locationi),logger,log_kinstrloggerstyk)inkinstr_rewritekstyi{apply}(** [log_next_continuation logger sty cont] instruments the next
continuation in [cont] with [KLog] continuations to ensure
logging.
This instrumentation has a performance cost, but importantly, it
is only ever paid when logging is enabled. Otherwise, the
possibility to instrument the script is costless. *)letlog_next_continuation:typeabcd.logger->(a,b)stack_ty->(a,b,c,d)continuation->(a,b,c,d)continuationtzresult=funloggerstack_tycont->letenable_logstyki=log_kinstrloggerstykiinmatchcontwith|KCons(ki,k)->(letki'=enable_logstack_tykiinkinstr_final_stack_typestack_tyki>|?function|None->KCons(ki',k)|Somesty->KCons(ki',instrument_contloggerstyk))|KLoop_in(ki,k)->let(Item_t(Bool_t,sty))=stack_tyinok@@KLoop_in(enable_logstyki,instrument_contloggerstyk)|KReturn(stack,sty,k)->letk'=instrument_contlogger(assert_somesty)kinok@@KReturn(stack,sty,k')|KLoop_in_left(ki,k)->let(Item_t(Union_t(a_ty,b_ty,_,_),rest))=stack_tyinletki'=enable_log(Item_t(a_ty,rest))kiinletk'=instrument_contlogger(Item_t(b_ty,rest))kinok@@KLoop_in_left(ki',k')|KUndip(x,ty,k)->letk'=instrument_contlogger(Item_t(assert_somety,stack_ty))kinok@@KUndip(x,ty,k')|KIter(body,xty,xs,k)->letbody'=enable_log(Item_t(assert_somexty,stack_ty))bodyinletk'=instrument_contloggerstack_tykinok@@KIter(body',xty,xs,k')|KList_enter_body(body,xs,ys,ty,len,k)->letk'=instrument_contlogger(Item_t(assert_somety,stack_ty))kinok@@KList_enter_body(body,xs,ys,ty,len,k')|KList_exit_body(body,xs,ys,ty,len,k)->let(Item_t(_,sty))=stack_tyinletk'=instrument_contlogger(Item_t(assert_somety,sty))kinok@@KList_exit_body(body,xs,ys,ty,len,k')|KMap_enter_body(body,xs,ys,ty,k)->letk'=instrument_contlogger(Item_t(assert_somety,stack_ty))kinok@@KMap_enter_body(body,xs,ys,ty,k')|KMap_exit_body(body,xs,ys,yk,ty,k)->let(Item_t(_,sty))=stack_tyinletk'=instrument_contlogger(Item_t(assert_somety,sty))kinok@@KMap_exit_body(body,xs,ys,yk,ty,k')|KMap_head(_,_)|KView_exit(_,_)|KLog_(* This case should never happen. *)|KNil->okcont(*
Zero-cost logging
=================
*)(*
The following functions insert a logging instruction to continue
the logging process in the next execution steps.
There is a special treatment of instructions that generate fresh
continuations: we pass a constructor as argument to their
evaluation rules so that they can instrument these fresh
continuations by themselves. Instructions that create continuations
without calling specialized functions have their branches from [step]
function duplicated and adjusted here.
This on-the-fly instrumentation of the execution allows zero-cost
logging since logging instructions are only introduced if an
initial logging continuation is pushed in the initial continuation
that starts the evaluation.
*)letilog:typeasbtrf.logger->logging_event->(a,s)stack_ty->(a,s,b,t,r,f)step_type=funloggereventsty((ctxt,_)asg)gaskksaccustack->(match(k,event)with|ILog_,LogEntry->()|_,LogEntry->log_entryctxtgaskstyaccustack|_,LogExitprev_loc->log_exitctxtgasprev_lockstyaccustack);log_next_kinstrloggerstyk>>?=funk->(* We need to match on instructions that create continuations so
that we can instrument those continuations with [KLog] (see
comment above). For functions that don't do this, we simply call
[step], as they don't require any special treatment. *)matchkwith|IIf_none{branch_if_none;branch_if_some;k;_}->(let(Item_t(Option_t(ty,_,_),rest))=styinbranched_final_stack_type[Ex_init_stack_ty(rest,branch_if_none);Ex_init_stack_ty(Item_t(ty,rest),branch_if_some);]>>?=funsty_opt->letks'=matchsty_optwith|None->KCons(k,ks)|Somesty'->instrument_contloggersty'@@KCons(k,ks)inmatchaccuwith|None->letaccu,stack=stackin(step[@ocaml.tailcall])ggasbranch_if_noneks'accustack|Somev->(step[@ocaml.tailcall])ggasbranch_if_someks'vstack)|IOpt_map{body;k;loc=_}->(matchaccuwith|None->(step[@ocaml.tailcall])ggaskksNonestack|Somev->let(Item_t(Option_t(ty,_,_),rest))=styinletbsty=Item_t(ty,rest)inletkmap_head=KMap_head(Option.some,KCons(k,ks))inkinstr_final_stack_typebstybody>>?=funsty_opt->letks'=matchsty_optwith|None->kmap_head|Somesty'->instrument_contloggersty'kmap_headin(step[@ocaml.tailcall])ggasbodyks'vstack)|IIf_left{branch_if_left;branch_if_right;k;_}->(let(Item_t(Union_t(lty,rty,_,_),rest))=styinbranched_final_stack_type[Ex_init_stack_ty(Item_t(lty,rest),branch_if_left);Ex_init_stack_ty(Item_t(rty,rest),branch_if_right);]>>?=funsty_opt->letk'=matchsty_optwith|None->KCons(k,ks)|Somesty'->instrument_contloggersty'@@KCons(k,ks)inmatchaccuwith|Lv->(step[@ocaml.tailcall])ggasbranch_if_leftk'vstack|Rv->(step[@ocaml.tailcall])ggasbranch_if_rightk'vstack)|IIf_cons{branch_if_cons;branch_if_nil;k;_}->(let(Item_t((List_t(elty,_)aslty),rest))=styinbranched_final_stack_type[Ex_init_stack_ty(rest,branch_if_nil);Ex_init_stack_ty(Item_t(elty,Item_t(lty,rest)),branch_if_cons);]>>?=funsty'->letk'=matchsty'with|None->KCons(k,ks)|Somesty'->instrument_contloggersty'@@KCons(k,ks)inmatchScript_list.unconsaccuwith|None->letaccu,stack=stackin(step[@ocaml.tailcall])ggasbranch_if_nilk'accustack|Some(hd,tl)->(step[@ocaml.tailcall])ggasbranch_if_consk'hd(tl,stack))|IList_map(_,body,ty,k)->let(Item_t(_,sty'))=styinletinstrument=instrument_contloggersty'in(ilist_map[@ocaml.tailcall])instrumentggasbodykkstyaccustack|IList_iter(_,ty,body,k)->let(Item_t(_,sty'))=styinletinstrument=instrument_contloggersty'in(ilist_iter[@ocaml.tailcall])instrumentggasbodytykksaccustack|ISet_iter(_,ty,body,k)->let(Item_t(_,rest))=styinletinstrument=instrument_contloggerrestin(iset_iter[@ocaml.tailcall])instrumentggasbodytykksaccustack|IMap_map(_,ty,body,k)->let(Item_t(_,rest))=styinletinstrument=instrument_contloggerrestin(imap_map[@ocaml.tailcall])instrumentggasbodykkstyaccustack|IMap_iter(_,kvty,body,k)->let(Item_t(_,rest))=styinletinstrument=instrument_contloggerrestin(imap_iter[@ocaml.tailcall])instrumentggasbodykvtykksaccustack|IMul_teznat(loc,k)->(imul_teznat[@ocaml.tailcall])(Somelogger)ggaslockksaccustack|IMul_nattez(loc,k)->(imul_nattez[@ocaml.tailcall])(Somelogger)ggaslockksaccustack|ILsl_nat(loc,k)->(ilsl_nat[@ocaml.tailcall])(Somelogger)ggaslockksaccustack|ILsr_nat(loc,k)->(ilsr_nat[@ocaml.tailcall])(Somelogger)ggaslockksaccustack|IIf{branch_if_true;branch_if_false;k;_}->let(Item_t(Bool_t,rest))=styinbranched_final_stack_type[Ex_init_stack_ty(rest,branch_if_true);Ex_init_stack_ty(rest,branch_if_false);]>>?=funsty'->letk'=matchsty'with|None->KCons(k,ks)|Somesty'->instrument_contloggersty'@@KCons(k,ks)inletres,stack=stackinifaccuthen(step[@ocaml.tailcall])ggasbranch_if_truek'resstackelse(step[@ocaml.tailcall])ggasbranch_if_falsek'resstack|ILoop(_,body,k)->letks=instrument_contloggersty@@KLoop_in(body,KCons(k,ks))in(next[@ocaml.tailcall])ggasksaccustack|ILoop_left(_,bl,br)->letks=instrument_contloggersty@@KLoop_in_left(bl,KCons(br,ks))in(next[@ocaml.tailcall])ggasksaccustack|IDip(_,b,ty,k)->let(Item_t(_,rest))=styinkinstr_final_stack_typerestb>>?=funrest'->letign=accuinletks=matchrest'with|None->KUndip(ign,ty,KCons(k,ks))|Somerest'->instrument_contloggerrest'(KUndip(ign,ty,KCons(k,ks)))inletaccu,stack=stackin(step[@ocaml.tailcall])ggasbksaccustack|IExec(_,stack_ty,k)->let(Item_t(_,Item_t(Lambda_t(_,ret,_),_)))=styinletsty'=Item_t(ret,Bot_t)inletinstrument=instrument_contloggersty'iniexecinstrument(Somelogger)ggasstack_tykksaccustack|IFailwith(kloc,tv)->let{ifailwith}=ifailwithin(ifailwith[@ocaml.tailcall])(Somelogger)ggaskloctvaccu|IDipn(_,_n,n',b,k)->letaccu,stack,restore_prefix=kundipn'accustackkinletdipped_sty=dipn_stack_tyn'styinkinstr_final_stack_typedipped_styb>>?=funsty'->letks=matchsty'with|None->KCons(restore_prefix,ks)|Somesty'->instrument_contloggersty'@@KCons(restore_prefix,ks)in(step[@ocaml.tailcall])ggasbksaccustack|IView(_,(View_signature{output_ty;_}asview_signature),stack_ty,k)->letsty'=Item_t(output_ty,Bot_t)inletinstrument=instrument_contloggersty'in(iview[@ocaml.tailcall])instrumentggasview_signaturestack_tykksaccustack|_->(step[@ocaml.tailcall])ggaskksaccustack[@@inline]letklog:typeasrf.logger->outdated_context*step_constants->local_gas_counter->(a,s)stack_ty->(a,s,r,f)continuation->(a,s,r,f)continuation->a->s->(r*f*outdated_context*local_gas_counter)tzresultLwt.t=funloggerggasstack_tyk0ksaccustack->letty_for_logging_unsafe=function(* This function is only called when logging is enabled. If
that's the case, the elaborator must have been called with
[logging_enabled] option, which ensures that this will not be
[None]. Realistically, it can happen that the [logging_enabled]
option was omitted, resulting in a crash here. But this is
acceptable, because logging is never enabled during block
validation, so the layer 1 is safe. *)|None->assertfalse|Somety->tyin(matchkswithKLog_->()|_->log_controlks);log_next_continuationloggerstack_tyks>>?=function|KCons(ki,k)->(step[@ocaml.tailcall])ggaskikaccustack|KLoop_in(ki,k)->(kloop_in[@ocaml.tailcall])ggask0kikaccustack|KReturn(_,_,_)ask->(next[@ocaml.tailcall])ggaskaccustack|KLoop_in_left(ki,k)->(kloop_in_left[@ocaml.tailcall])ggask0kikaccustack|KUndip(_,_,_)ask->(next[@ocaml.tailcall])ggaskaccustack|KIter(body,xty,xs,k)->letinstrument=instrument_contloggerstack_tyin(kiter[@ocaml.tailcall])instrumentggasbodyxtyxskaccustack|KList_enter_body(body,xs,ys,ty_opt,len,k)->letinstrument=letty=ty_for_logging_unsafety_optinlet(List_t(vty,_))=tyinletsty=Item_t(vty,stack_ty)ininstrument_contloggerstyin(klist_enter[@ocaml.tailcall])instrumentggasbodyxsysty_optlenkaccustack|KList_exit_body(body,xs,ys,ty_opt,len,k)->let(Item_t(_,rest))=stack_tyinletinstrument=instrument_contloggerrestin(klist_exit[@ocaml.tailcall])instrumentggasbodyxsysty_optlenkaccustack|KMap_enter_body(body,xs,ys,ty_opt,k)->letinstrument=letty=ty_for_logging_unsafety_optinlet(Map_t(_,vty,_))=tyinletsty=Item_t(vty,stack_ty)ininstrument_contloggerstyin(kmap_enter[@ocaml.tailcall])instrumentggasbodyxsty_optyskaccustack|KMap_exit_body(body,xs,ys,yk,ty_opt,k)->let(Item_t(_,rest))=stack_tyinletinstrument=instrument_contloggerrestin(kmap_exit[@ocaml.tailcall])instrumentggasbodyxsty_optysykkaccustack|KMap_head(f,k)->(next[@ocaml.tailcall])ggask(faccu)stack|KView_exit(scs,k)->(next[@ocaml.tailcall])(fstg,scs)gaskaccustack|KLog_ask->(* This case should never happen. *)(next[@ocaml.tailcall])ggaskaccustack|KNilask->(next[@ocaml.tailcall])ggaskaccustack[@@inline]endletmake(moduleBase:Logger_base)=letmoduleLogger=Logger(Base)inletopenLoggerinletopenBasein{log_interp;get_log;log_kinstr;klog;ilog}