package tezos-protocol-016-PtMumbai

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file michelson_v1_gas_costs_generated.ml

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com>     *)
(* Copyright (c) 2019-2022 Nomadic Labs <contact@nomadic-labs.com>           *)
(* Copyright (c) 2020 Metastate AG <hello@metastate.dev>                     *)
(* 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.                                                 *)
(*                                                                           *)
(*****************************************************************************)

module S = Saturation_repr
module S_syntax = S.Syntax

(* This file is planned to be automatically generated. *)
(* If you want to update the following functions, update the gas model instead. *)

(* model N_IAbs_int *)
(* Allocates [size] bytes. *)
let cost_N_IAbs_int size = S.safe_int (20 + (size lsr 1))

(* model N_IAdd_bls12_381_fr *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IAdd_bls12_381_fr = S.safe_int 30

(* model N_IAdd_bls12_381_g1 *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IAdd_bls12_381_g1 = S.safe_int 900

(* model N_IAdd_bls12_381_g2 *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IAdd_bls12_381_g2 = S.safe_int 2_470

(* Allocates [max size1 size2] *)
let cost_linear_op_int size1 size2 =
  let open S_syntax in
  let v0 = S.safe_int (Compare.Int.max size1 size2) in
  S.safe_int 35 + (v0 lsr 1)

(* model N_IAdd_int *)
(* Approximating 0.078154 x term *)
let cost_N_IAdd_int = cost_linear_op_int

(* model N_IAdd_nat *)
(* Approximating 0.077807 x term *)
let cost_N_IAdd_nat = cost_linear_op_int

(* model N_IAdd_seconds_to_timestamp *)
(* Approximating 0.078056 x term *)
let cost_N_IAdd_seconds_to_timestamp = cost_linear_op_int

(* model N_IAdd_tez *)
let cost_N_IAdd_tez = S.safe_int 20

(* model N_IAdd_timestamp_to_seconds *)
(* Approximating 0.077771 x term *)
let cost_N_IAdd_timestamp_to_seconds = cost_linear_op_int

(* model N_IAddress *)
let cost_N_IAddress = S.safe_int 10

(* model N_IAmount *)
let cost_N_IAmount = S.safe_int 10

(* model N_IAnd *)
let cost_N_IAnd = S.safe_int 10

(* model N_IAnd_int_nat *)
(* Allocates [min size1 size2] *)
let cost_N_IAnd_int_nat size1 size2 =
  let open S_syntax in
  let v0 = S.safe_int (Compare.Int.min size1 size2) in
  S.safe_int 35 + (v0 lsr 1)

(* model N_IAnd_nat *)
(* Allocates [min size1 size2] *)
let cost_N_IAnd_nat size1 size2 =
  let open S_syntax in
  let v0 = S.safe_int (Compare.Int.min size1 size2) in
  S.safe_int 35 + (v0 lsr 1)

(* model N_IAnd_bytes *)
(* Allocates [min size1 size2] *)
(* fun size1 -> fun size2 -> (34.8914840649 + (0.398826813115 * (min size1 size2))) *)
let cost_N_IAnd_bytes size1 size2 =
  let open S_syntax in
  let v0 = S.safe_int (Compare.Int.min size1 size2) in
  S.safe_int 35 + (v0 lsr 1)

(* model N_IBalance *)
let cost_N_IBalance = S.safe_int 10

(* model N_IBlake2b *)
(* Approximating 1.120804 x term *)
let cost_N_IBlake2b size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 430 + v0 + (v0 lsr 3)

(* model N_IBytes_size *)
let cost_N_IBytes_size = S.safe_int 10

(* model N_IByte_nat *)
(* fun size -> (73.6648173983 + (2.97857716538 * size)) *)
let cost_N_IBytes_nat size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 75 + (v0 lsl 1) + v0

(* model N_INat_bytes *)
(* fun size -> (41.2414840649 + (2.47956362254 * size)) *)
let cost_N_INat_bytes size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 45 + (v0 lsl 1) + (v0 lsr 1)

(* model N_IBytes_int *)
(* fun size -> (87.7348173983 + (3.04617929025 * size)) *)
let cost_N_IBytes_int size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 90 + (v0 lsl 1) + v0

(* model N_IInt_bytes *)
(* fun size -> (17.8814840649 + (2.57086493257 * size)) *)
let cost_N_IInt_bytes size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 20 + (v0 lsl 1) + (v0 lsr 1)

(* model N_ICar *)
let cost_N_ICar = S.safe_int 10

(* model N_ICdr *)
let cost_N_ICdr = S.safe_int 10

(* model N_IChainId *)
let cost_N_IChainId = S.safe_int 15

(* model N_ICheck_signature_ed25519 *)
(* Approximating 1.123507 x term *)
let cost_N_ICheck_signature_ed25519 size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 65_800 + (v0 + (v0 lsr 3))

(* model N_ICheck_signature_p256 *)
(* Approximating 1.111539 x term *)
let cost_N_ICheck_signature_p256 size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 990_000 + (v0 + (v0 lsr 3))

(* model N_ICheck_signature_secp256k1 *)
(* Approximating 1.125404 x term *)
let cost_N_ICheck_signature_secp256k1 size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 51_600 + (v0 + (v0 lsr 3))

(* model N_ICheck_signature_bls *)
(* fun size -> (1566529.36815 + (2.94695684559 * size)) *)
let cost_N_ICheck_signature_bls size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 1_570_000 + (v0 lsl 1) + v0

(* model N_IComb *)
(* Approximating 3.531001 x term *)
(* Note: size >= 2, so the cost is never 0 *)
let cost_N_IComb size =
  let open S_syntax in
  let v0 = S.safe_int size in
  (S.safe_int 3 * v0) + (v0 lsr 1) + (v0 lsr 5)

(* model N_IComb_get *)
(* Approximating 0.573180 x term *)
let cost_N_IComb_get size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 20 + (v0 lsr 1) + (v0 lsr 4)

(* model N_IComb_set *)
(* Approximating 1.287531 x term *)
let cost_N_IComb_set size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 20 + (v0 + (v0 lsr 2) + (v0 lsr 5))

(* Model N_ICompare *)
(* Approximating 0.024413 x term *)
let cost_N_ICompare size1 size2 =
  let open S_syntax in
  let v0 = S.safe_int (Compare.Int.min size1 size2) in
  S.safe_int 35 + ((v0 lsr 6) + (v0 lsr 7))

(* model N_IConcat_bytes_pair *)
(* Allocates [size1 + size2] *)
let cost_N_IConcat_bytes_pair size1 size2 =
  let open S_syntax in
  let v0 = S.safe_int size1 + S.safe_int size2 in
  S.safe_int 45 + (v0 lsr 1)

(* model N_IConcat_string_pair *)
(* Allocates [size1 + size2] *)
let cost_N_IConcat_string_pair size1 size2 =
  let open S_syntax in
  let v0 = S.safe_int size1 + S.safe_int size2 in
  S.safe_int 45 + (v0 lsr 1)

(* model N_ICons_list *)
let cost_N_ICons_list = S.safe_int 10

(* model N_ICons_none *)
let cost_N_ICons_none = S.safe_int 10

(* model N_ICons_pair *)
let cost_N_ICons_pair = S.safe_int 10

(* model N_ICons_some *)
let cost_N_ICons_some = S.safe_int 10

(* model N_IConst *)
let cost_N_IConst = S.safe_int 10

(* model N_IContract *)
let cost_N_IContract = S.safe_int 30

(* model N_ICreate_contract *)
let cost_N_ICreate_contract = S.safe_int 60

(* model N_IDiff_timestamps *)
(* Approximating 0.077922 x term *)
let cost_N_IDiff_timestamps = cost_linear_op_int

(* model N_IDig *)
(* Approximating 6.750442 x term *)
let cost_N_IDig size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 30 + ((S.safe_int 6 * v0) + (v0 lsr 1) + (v0 lsr 2))

(* model N_IDip *)
let cost_N_IDip = S.safe_int 10

(* model N_IDipN *)
(* Approximating 4.05787663635 x term *)
let cost_N_IDipN size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 15 + (S.safe_int 4 * v0)

(* model N_IView *)
let cost_N_IView = S.safe_int 1460

(* model N_IDrop *)
let cost_N_IDrop = S.safe_int 10

(* model N_IDropN *)
(* Approximating 2.713108 x term *)
let cost_N_IDropN size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 30 + (S.safe_int 2 * v0) + (v0 lsr 1) + (v0 lsr 3)

(* model N_IDug *)
(* Approximating 6.718396 x term *)
let cost_N_IDug size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 35 + ((S.safe_int 6 * v0) + (v0 lsr 1) + (v0 lsr 2))

(* model N_IDup *)
let cost_N_IDup = S.safe_int 10

(* model N_IDupN *)
(* Approximating 1.222263 x term *)
let cost_N_IDupN size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 20 + v0 + (v0 lsr 2)

let cost_div_int size1 size2 =
  (* Allocates at most [size1] bytes *)
  let q = size1 - size2 in
  let open S_syntax in
  let v1 = S.safe_int size1 in
  if Compare.Int.(q < 0) then S.safe_int 105 + (v1 lsr 1)
  else
    let v0 = S.safe_int q * S.safe_int size2 in
    S.safe_int 105 + (v0 lsr 10) + (v0 lsr 11) + (v0 lsr 13) + (v1 lsr 1)

(* model N_IEdiv_int *)
(* Approximating 0.001591 x term *)
let cost_N_IEdiv_int = cost_div_int

(* model N_IEdiv_nat *)
(* Approximating 0.001605 x term *)
let cost_N_IEdiv_nat = cost_div_int

(* model N_IEdiv_tez *)
let cost_N_IEdiv_tez = S.safe_int 80

(* model N_IEmpty_big_map *)
let cost_N_IEmpty_big_map = S.safe_int 300

(* model N_IEmpty_map *)
let cost_N_IEmpty_map = S.safe_int 300

(* model N_IEmpty_set *)
let cost_N_IEmpty_set = S.safe_int 300

(* model N_IEq *)
let cost_N_IEq = S.safe_int 10

(* model N_IExec *)
let cost_N_IExec = S.safe_int 10

(* model N_IFailwith *)
(* let cost_N_IFailwith = S.safe_int 105 *)

(* model N_IGe *)
let cost_N_IGe = S.safe_int 10

(* model N_IGt *)
let cost_N_IGt = S.safe_int 10

(* model N_IHalt *)
let cost_N_IHalt = S.safe_int 15

(* model N_IHash_key *)
let cost_N_IHash_key = S.safe_int 605

(* model N_IIf *)
let cost_N_IIf = S.safe_int 10

(* model N_IIf_cons *)
let cost_N_IIf_cons = S.safe_int 10

(* model N_IIf_left *)
let cost_N_IIf_left = S.safe_int 10

(* model N_IIf_none *)
let cost_N_IIf_none = S.safe_int 10

(* model N_IOpt_map *)
let cost_N_IOpt_map = S.safe_int 10

(* model N_IImplicit_account *)
let cost_N_IImplicit_account = S.safe_int 10

(* model N_IInt_bls12_381_z_fr *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IInt_bls12_381_z_fr = S.safe_int 115

(* model N_IInt_nat *)
let cost_N_IInt_nat = S.safe_int 10

(* model N_IIs_nat *)
let cost_N_IIs_nat = S.safe_int 10

(* model N_IKeccak *)
(* Approximating 8.276352 x term *)
let cost_N_IKeccak size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 1350 + ((S.safe_int 8 * v0) + (v0 lsr 2))

(* model N_ILambda *)
let cost_N_ILambda = S.safe_int 10

(* model N_ILe *)
let cost_N_ILe = S.safe_int 10

(* model N_ILeft *)
let cost_N_ILeft = S.safe_int 10

(* model N_ILevel *)
let cost_N_ILevel = S.safe_int 10

(* model N_IList_iter *)
let cost_N_IList_iter = S.safe_int 20

(* model N_IList_map *)
let cost_N_IList_map = S.safe_int 20

(* model N_IList_size *)
let cost_N_IList_size = S.safe_int 10

(* model N_ILoop *)
let cost_N_ILoop = S.safe_int 10

(* model N_ILoop_left *)
let cost_N_ILoop_left = S.safe_int 10

(* model N_ILsl_nat *)
(* Allocates at most [size + 256] bytes *)
let cost_N_ILsl_nat size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 128 + (v0 lsr 1)

(* model N_ILsr_nat *)
(* Allocates at most [size] bytes*)
let cost_N_ILsr_nat size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 45 + (v0 lsr 1)

(* model N_ILsl_bytes *)
(* Allocates [size + shift / 8] bytes *)
(* fun size1 -> fun size2 -> ((63.0681507316 + (0.667539714647 * size1)) + (0. * size2)) *)
let cost_N_ILsl_bytes size shift =
  let open S_syntax in
  let v1 = S.safe_int size in
  let v0 = S.safe_int shift in
  S.safe_int 65 + (v1 lsr 1) + (v1 lsr 2) + (v0 lsr 4)

(* model N_ILsr_bytes *)
(* Allocates [max 0 (size - shift / 8)] bytes *)
(* fun size1 -> fun size2 -> let q = (size1 - (size2 * 0.125)) in (53.9248173983 + (0.658785032381 * (if (0 < q) then q else 0))) *)
let cost_N_ILsr_bytes size shift =
  let q = size - (shift lsr 3) in
  let open S.Syntax in
  if Compare.Int.(q < 0) then S.safe_int 55
  else
    let v0 = S.safe_int q in
    S.safe_int 55 + (v0 lsr 1) + (v0 lsr 2)

(* model N_ILt *)
let cost_N_ILt = S.safe_int 10

(* model N_IMap_get *)
(* Approximating 0.048359 x term *)
let cost_N_IMap_get size1 size2 =
  let open S_syntax in
  let size1 = S.safe_int size1 in
  let size2 = S.safe_int size2 in
  let v0 = size1 * log2 size2 in
  S.safe_int 45 + (v0 lsr 5) + (v0 lsr 6)

(* model N_IMap_get_and_update *)
(* Approximating 0.145661 x term *)
let cost_N_IMap_get_and_update size1 size2 =
  let open S_syntax in
  let size1 = S.safe_int size1 in
  let size2 = S.safe_int size2 in
  let v0 = size1 * log2 size2 in
  S.safe_int 75 + (v0 lsr 3) + (v0 lsr 6)

(* model N_IMap_iter *)
(* Approximating 7.621331 x term *)
let cost_N_IMap_iter size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 50 + (S.safe_int 7 * v0) + (v0 lsr 1) + (v0 lsr 3)

(* model N_IMap_map *)
(* Approximating 8.38965386732 x term *)
let cost_N_IMap_map size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 40 + ((S.safe_int 8 * v0) + (v0 lsr 1))

(* model N_IMap_mem *)
(* Approximating 0.048446 x term *)
let cost_N_IMap_mem size1 size2 =
  let open S_syntax in
  let size1 = S.safe_int size1 in
  let size2 = S.safe_int size2 in
  let v0 = size1 * log2 size2 in
  S.safe_int 45 + (v0 lsr 5) + (v0 lsr 6)

(* model N_IMap_size *)
let cost_N_IMap_size = S.safe_int 10

(* model N_IMap_update *)
(* Approximating 0.097072 x term *)
let cost_N_IMap_update size1 size2 =
  let open S_syntax in
  let size1 = S.safe_int size1 in
  let size2 = S.safe_int size2 in
  let v0 = size1 * log2 size2 in
  S.safe_int 55 + (v0 lsr 4) + (v0 lsr 5)

(* model N_IMul_bls12_381_fr *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IMul_bls12_381_fr = S.safe_int 45

(* model N_IMul_bls12_381_fr_z *)
(* Approximating 1.059386 x term *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IMul_bls12_381_fr_z size1 =
  let open S_syntax in
  let v0 = S.safe_int size1 in
  S.safe_int 265 + v0 + (v0 lsr 4)

(* model N_IMul_bls12_381_g1 *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IMul_bls12_381_g1 = S.safe_int 103_000

(* model N_IMul_bls12_381_g2 *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IMul_bls12_381_g2 = S.safe_int 220_000

(* model N_IMul_bls12_381_z_fr *)
(* Approximating 1.068674 x term *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IMul_bls12_381_z_fr size1 =
  let open S_syntax in
  let v0 = S.safe_int size1 in
  S.safe_int 265 + v0 + (v0 lsr 4)

let cost_mul size1 size2 =
  let open S_syntax in
  let a = S.add (S.safe_int size1) (S.safe_int size2) in
  let v0 = a * log2 a in
  S.safe_int 55 + (v0 lsr 1) + (v0 lsr 2) + (v0 lsr 4)

(* model N_IMul_int *)
(* Approximating 0.857931 x term *)
let cost_N_IMul_int = cost_mul

(* model N_IMul_nat *)
(* Approximating 0.861823 x term *)
let cost_N_IMul_nat = cost_mul

(* model N_INeg_bls12_381_fr *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_INeg_bls12_381_fr = S.safe_int 30

(* model N_INeg_bls12_381_g1 *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_INeg_bls12_381_g1 = S.safe_int 50

(* model N_INeg_bls12_381_g2 *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_INeg_bls12_381_g2 = S.safe_int 70

(* model N_INeg *)
(* Allocates [size] bytes *)
let cost_N_INeg size =
  let open S_syntax in
  S.safe_int 25 + (S.safe_int size lsr 1)

(* model N_INeq *)
let cost_N_INeq = S.safe_int 10

(* model N_INil *)
let cost_N_INil = S.safe_int 10

(* model N_INot *)
let cost_N_INot = S.safe_int 10

(* model N_INot_int *)
(* Allocates [size] bytes *)
let cost_N_INot_int size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 25 + (v0 lsr 1)

(* model N_INot_bytes *)
(* Allocates [size] bytes *)
let cost_N_INot_bytes size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 30 + (v0 lsr 1)

(* model N_INow *)
let cost_N_INow = S.safe_int 10

(* model N_IMin_block_time *)
let cost_N_IMin_block_time = S.safe_int 20

(* model N_IOpen_chest *)
(* 612000 + chest * 19 + time * 19050 *)
let cost_N_IOpen_chest time chest =
  let open S_syntax in
  let v0 = S.safe_int chest in
  let v1 = S.safe_int time in
  S.safe_int 612_000 + (S.safe_int 19 * v0) + (S.safe_int 19050 * v1)

(* model N_IOr *)
let cost_N_IOr = S.safe_int 10

(* model N_IOr_nat *)
(* Approximating 0.075758 x term *)
let cost_N_IOr_nat = cost_linear_op_int

(* model N_IOr_bytes *)
(* Allocates [max size1 size2] bytes *)
(* fun size1 -> fun size2 -> (32.5381507316 + (0.232425212131 * (max size1 size2))) *)
let cost_N_IOr_bytes size1 size2 =
  let open S_syntax in
  let v0 = S.safe_int (Compare.Int.max size1 size2) in
  S.safe_int 35 + (v0 lsr 1)

(* model N_IPairing_check_bls12_381 *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_N_IPairing_check_bls12_381 size =
  S.add (S.safe_int 450_000) (S.mul (S.safe_int 342_500) (S.safe_int size))

(* model N_IRead_ticket *)
let cost_N_IRead_ticket = S.safe_int 10

(* model N_IRight *)
let cost_N_IRight = S.safe_int 10

(* model N_ISapling_empty_state *)
let cost_N_ISapling_empty_state = S.safe_int 300

(* model N_ISelf_address *)
let cost_N_ISelf_address = S.safe_int 10

(* model N_ISelf *)
let cost_N_ISelf = S.safe_int 10

(* model N_ISender *)
let cost_N_ISender = S.safe_int 10

(* model N_ISet_delegate *)
let cost_N_ISet_delegate = S.safe_int 60

(* model N_ISet_iter *)
(* Approximating 7.633555 x term *)
let cost_N_ISet_iter size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 50 + (S.safe_int 7 * v0) + (v0 lsr 1) + (v0 lsr 3)

(* model N_ISet_size *)
let cost_N_ISet_size = S.safe_int 10

(* model N_ISha256 *)
(* Approximating 4.763264 x term *)
let cost_N_ISha256 size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 600 + ((S.safe_int 4 * v0) + (v0 lsr 1) + (v0 lsr 2))

(* model N_ISha3 *)
(* Approximating 8.362339 x term *)
let cost_N_ISha3 = cost_N_IKeccak

(* model N_ISha512 *)
(* Approximating 3.074641 x term *)
let cost_N_ISha512 size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 680 + (S.safe_int 3 * v0)

(* model N_ISlice_bytes *)
(* Allocates [size] bytes *)
let cost_N_ISlice_bytes size =
  let open S_syntax in
  S.safe_int 25 + (S.safe_int size lsr 1)

(* model N_ISlice_string *)
(* Allocates [size] bytes *)
let cost_N_ISlice_string size =
  let open S_syntax in
  S.safe_int 25 + (S.safe_int size lsr 1)

(* model N_ISource *)
let cost_N_ISource = S.safe_int 10

(* model N_ISplit_ticket *)
(* Allocates [max size1 size2] *)
let cost_N_ISplit_ticket size1 size2 =
  let open S_syntax in
  let v1 = S.safe_int (Compare.Int.max size1 size2) in
  S.safe_int 40 + (v1 lsr 1)

(* model N_IString_size *)
let cost_N_IString_size = S.safe_int 15

(* model N_ISub_int *)
(* Approximating 0.077849 x term *)
let cost_N_ISub_int = cost_linear_op_int

(* model N_ISub_tez *)
let cost_N_ISub_tez = S.safe_int 15

(* model N_ISub_tez_legacy *)
let cost_N_ISub_tez_legacy = S.safe_int 20

(* model N_ISub_timestamp_seconds *)
(* Approximating 0.077794 x term *)
let cost_N_ISub_timestamp_seconds = cost_linear_op_int

(* model N_ISwap *)
let cost_N_ISwap = S.safe_int 10

(* model N_ITicket *)
let cost_N_ITicket = S.safe_int 10

(* model N_ITotal_voting_power *)
let cost_N_ITotal_voting_power = S.safe_int 450

(* model N_ITransfer_tokens *)
let cost_N_ITransfer_tokens = S.safe_int 60

(* model N_IUncomb *)
(* Approximating 3.944710 x term *)
let cost_N_IUncomb size =
  let open S_syntax in
  let v0 = S.safe_int size in
  S.safe_int 25 + (S.safe_int 4 * v0)

(* model N_IUnpair *)
let cost_N_IUnpair = S.safe_int 10

(* model N_IVoting_power *)
let cost_N_IVoting_power = S.safe_int 640

(* model N_IXor *)
let cost_N_IXor = S.safe_int 15

(* model N_IXor_nat *)
(* Approximating 0.075601 x term *)
let cost_N_IXor_nat = cost_linear_op_int

(* model N_IXor_bytes *)
(* Allocates [max size1 size2] bytes *)
(* fun size1 -> fun size2 -> (38.5110342369 + (0.397946895815 * (max size1 size2))) *)
let cost_N_IXor_bytes size1 size2 =
  let open S_syntax in
  let v0 = S.safe_int (Compare.Int.max size1 size2) in
  S.safe_int 40 + (v0 lsr 1)

(* model N_KCons *)
let cost_N_KCons = S.safe_int 10

(* model N_KList_exit_body *)
let cost_N_KList_exit_body = S.safe_int 10

(* model N_KLoop_in *)
let cost_N_KLoop_in = S.safe_int 10

(* model N_KLoop_in_left *)
let cost_N_KLoop_in_left = S.safe_int 10

(* model N_KNil *)
let cost_N_KNil = S.safe_int 15

(* model N_KReturn *)
let cost_N_KReturn = S.safe_int 10

(* model N_KView_exit *)
let cost_N_KView_exit = S.safe_int 20

(* model N_KMap_head *)
let cost_N_KMap_head = S.safe_int 20

(* model N_KUndip *)
let cost_N_KUndip = S.safe_int 10

(* model DECODING_BLS_FR *)
(* when benchmarking, compile bls12-381 without ADX, see
   https://gitlab.com/dannywillems/ocaml-bls12-381/-/blob/71d0b4d467fbfaa6452d702fcc408d7a70916a80/README.md#install
*)
let cost_DECODING_BLS_FR = S.safe_int 120

(* model DECODING_BLS_G1 *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_DECODING_BLS_G1 = S.safe_int 54_600

(* model DECODING_BLS_G2 *)
(* when benchmarking, compile bls12-381 without ADX *)
let cost_DECODING_BLS_G2 = S.safe_int 69_000

(* model B58CHECK_DECODING_CHAIN_ID *)
let cost_B58CHECK_DECODING_CHAIN_ID = S.safe_int 1_600

(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_ed25519 *)
let cost_B58CHECK_DECODING_PUBLIC_KEY_HASH_ed25519 = S.safe_int 3_300

(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_p256 *)
let cost_B58CHECK_DECODING_PUBLIC_KEY_HASH_p256 = S.safe_int 3_300

(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_secp256k1 *)
let cost_B58CHECK_DECODING_PUBLIC_KEY_HASH_secp256k1 = S.safe_int 3_300

(* model B58CHECK_DECODING_PUBLIC_KEY_HASH_bls *)
let cost_B58CHECK_DECODING_PUBLIC_KEY_HASH_bls = S.safe_int 3_600

(* model B58CHECK_DECODING_PUBLIC_KEY_ed25519 *)
let cost_B58CHECK_DECODING_PUBLIC_KEY_ed25519 = S.safe_int 4_200

(* model B58CHECK_DECODING_PUBLIC_KEY_p256 *)
let cost_B58CHECK_DECODING_PUBLIC_KEY_p256 = S.safe_int 325_000

(* model B58CHECK_DECODING_PUBLIC_KEY_secp256k1 *)
let cost_B58CHECK_DECODING_PUBLIC_KEY_secp256k1 = S.safe_int 9_000

(* model B58CHECK_DECODING_PUBLIC_KEY_bls *)
let cost_B58CHECK_DECODING_PUBLIC_KEY_bls = S.safe_int 79_000

(* model B58CHECK_DECODING_SIGNATURE_ed25519 *)
let cost_B58CHECK_DECODING_SIGNATURE_ed25519 = S.safe_int 6_400

(* model B58CHECK_DECODING_SIGNATURE_p256 *)
let cost_B58CHECK_DECODING_SIGNATURE_p256 = S.safe_int 6_400

(* model B58CHECK_DECODING_SIGNATURE_secp256k1 *)
let cost_B58CHECK_DECODING_SIGNATURE_secp256k1 = S.safe_int 6_400

(* model B58CHECK_DECODING_SIGNATURE_bls *)
let cost_B58CHECK_DECODING_SIGNATURE_bls = S.safe_int 6_400

(* model ENCODING_BLS_FR *)
let cost_ENCODING_BLS_FR = S.safe_int 80

(* model ENCODING_BLS_G1 *)
let cost_ENCODING_BLS_G1 = S.safe_int 3200

(* model ENCODING_BLS_G2 *)
let cost_ENCODING_BLS_G2 = S.safe_int 3900

(* model B58CHECK_ENCODING_CHAIN_ID *)
let cost_B58CHECK_ENCODING_CHAIN_ID = S.safe_int 1_800

(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_ed25519 *)
let cost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_ed25519 = S.safe_int 3_200

(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_p256 *)
let cost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_p256 = S.safe_int 3_200

(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_secp256k1 *)
let cost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_secp256k1 = S.safe_int 3_200

(* model B58CHECK_ENCODING_PUBLIC_KEY_HASH_bls *)
let cost_B58CHECK_ENCODING_PUBLIC_KEY_HASH_bls = S.safe_int 3_200

(* model B58CHECK_ENCODING_PUBLIC_KEY_ed25519 *)
let cost_B58CHECK_ENCODING_PUBLIC_KEY_ed25519 = S.safe_int 4_500

(* model B58CHECK_ENCODING_PUBLIC_KEY_p256 *)
let cost_B58CHECK_ENCODING_PUBLIC_KEY_p256 = S.safe_int 4_550

(* model B58CHECK_ENCODING_PUBLIC_KEY_secp256k1 *)
let cost_B58CHECK_ENCODING_PUBLIC_KEY_secp256k1 = S.safe_int 4_950

(* model B58CHECK_ENCODING_PUBLIC_KEY_bls *)
let cost_B58CHECK_ENCODING_PUBLIC_KEY_bls = S.safe_int 5_900

(* model B58CHECK_ENCODING_SIGNATURE_ed25519 *)
let cost_B58CHECK_ENCODING_SIGNATURE_ed25519 = S.safe_int 8_300

(* model B58CHECK_ENCODING_SIGNATURE_p256 *)
let cost_B58CHECK_ENCODING_SIGNATURE_p256 = S.safe_int 8_300

(* model B58CHECK_ENCODING_SIGNATURE_secp256k1 *)
let cost_B58CHECK_ENCODING_SIGNATURE_secp256k1 = S.safe_int 8_300

(* model B58CHECK_ENCODING_SIGNATURE_bls *)
let cost_B58CHECK_ENCODING_SIGNATURE_bls = S.safe_int 8_300

(* model DECODING_CHAIN_ID *)
let cost_DECODING_CHAIN_ID = S.safe_int 50

(* model DECODING_PUBLIC_KEY_HASH_ed25519 *)
let cost_DECODING_PUBLIC_KEY_HASH_ed25519 = S.safe_int 60

(* model DECODING_PUBLIC_KEY_HASH_p256 *)
let cost_DECODING_PUBLIC_KEY_HASH_p256 = S.safe_int 60

(* model DECODING_PUBLIC_KEY_HASH_secp256k1 *)
let cost_DECODING_PUBLIC_KEY_HASH_secp256k1 = S.safe_int 60

(* model DECODING_PUBLIC_KEY_HASH_bls *)
let cost_DECODING_PUBLIC_KEY_HASH_bls = S.safe_int 60

(* model DECODING_PUBLIC_KEY_ed25519 *)
let cost_DECODING_PUBLIC_KEY_ed25519 = S.safe_int 60

(* model DECODING_PUBLIC_KEY_p256 *)
let cost_DECODING_PUBLIC_KEY_p256 = S.safe_int 18_800

(* model DECODING_PUBLIC_KEY_secp256k1 *)
let cost_DECODING_PUBLIC_KEY_secp256k1 = S.safe_int 4_900

(* model DECODING_PUBLIC_KEY_bls *)
let cost_DECODING_PUBLIC_KEY_bls = S.safe_int 74_000

(* model DECODING_SIGNATURE_ed25519 *)
let cost_DECODING_SIGNATURE_ed25519 = S.safe_int 35

(* model DECODING_SIGNATURE_p256 *)
let cost_DECODING_SIGNATURE_p256 = S.safe_int 35

(* model DECODING_SIGNATURE_secp256k1 *)
let cost_DECODING_SIGNATURE_secp256k1 = S.safe_int 35

(* model DECODING_SIGNATURE_bls *)
let cost_DECODING_SIGNATURE_bls = S.safe_int 40

(* model DECODING_Chest_key *)
let cost_DECODING_Chest_key = S.safe_int 5900

(* model DECODING_Chest *)
(* Approximating 0.039349 x term *)
let cost_DECODING_Chest bytes =
  let open S_syntax in
  let v0 = S.safe_int bytes in
  S.safe_int 7400 + (v0 lsr 5) + (v0 lsr 7)

(* model ENCODING_CHAIN_ID *)
let cost_ENCODING_CHAIN_ID = S.safe_int 50

(* model ENCODING_PUBLIC_KEY_HASH_ed25519 *)
let cost_ENCODING_PUBLIC_KEY_HASH_ed25519 = S.safe_int 70

(* model ENCODING_PUBLIC_KEY_HASH_p256 *)
let cost_ENCODING_PUBLIC_KEY_HASH_p256 = S.safe_int 70

(* model ENCODING_PUBLIC_KEY_HASH_secp256k1 *)
let cost_ENCODING_PUBLIC_KEY_HASH_secp256k1 = S.safe_int 70

(* model ENCODING_PUBLIC_KEY_HASH_bls *)
let cost_ENCODING_PUBLIC_KEY_HASH_bls = S.safe_int 80

(* model ENCODING_PUBLIC_KEY_ed25519 *)
let cost_ENCODING_PUBLIC_KEY_ed25519 = S.safe_int 80

(* model ENCODING_PUBLIC_KEY_p256 *)
let cost_ENCODING_PUBLIC_KEY_p256 = S.safe_int 90

(* model ENCODING_PUBLIC_KEY_secp256k1 *)
let cost_ENCODING_PUBLIC_KEY_secp256k1 = S.safe_int 455

(* model ENCODING_PUBLIC_KEY_bls *)
let cost_ENCODING_PUBLIC_KEY_bls = S.safe_int 90

(* model ENCODING_SIGNATURE_ed25519 *)
let cost_ENCODING_SIGNATURE_ed25519 = S.safe_int 45

(* model ENCODING_SIGNATURE_p256 *)
let cost_ENCODING_SIGNATURE_p256 = S.safe_int 45

(* model ENCODING_SIGNATURE_secp256k1 *)
let cost_ENCODING_SIGNATURE_secp256k1 = S.safe_int 45

(* model ENCODING_SIGNATURE_bls *)
let cost_ENCODING_SIGNATURE_bls = S.safe_int 55

(* model ENCODING_Chest_key *)
let cost_ENCODING_Chest_key = S.safe_int 10_000

(* model ENCODING_Chest *)
(* Approximating 0.120086 x term *)
let cost_ENCODING_Chest plaintext_size =
  let open S_syntax in
  let v0 = S.safe_int plaintext_size in
  S.safe_int 12_200 + (v0 lsr 3)

(* model TIMESTAMP_READABLE_DECODING *)
(* Approximating 0.045400 x term *)
let cost_TIMESTAMP_READABLE_DECODING bytes =
  let open S_syntax in
  let b = S.safe_int bytes in
  let v0 = S.mul (S.sqrt b) b in
  S.safe_int 105 + ((v0 lsr 5) + (v0 lsr 6))

(* model TIMESTAMP_READABLE_ENCODING *)
let cost_TIMESTAMP_READABLE_ENCODING = S.safe_int 820

(* model CHECK_PRINTABLE *)
let cost_CHECK_PRINTABLE size =
  let open S_syntax in
  S.safe_int 14 + (S.safe_int 10 * S.safe_int size)

(* model IEmit *)
let cost_N_IEmit = S.safe_int 30
OCaml

Innovation. Community. Security.