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
/* automatically generated by rust-bindgen 0.59.1 */

pub const M3_VERSION_MAJOR: u32 = 0;
pub const M3_VERSION_MINOR: u32 = 4;
pub const M3_VERSION_REV: u32 = 7;
pub const M3_VERSION: &'static [u8; 6usize] = b"0.4.7\0";
pub const M3_COMPILER_CLANG: u32 = 1;
pub const M3_ARCH: &'static [u8; 7usize] = b"x86_64\0";
pub type size_t = cty::c_ulong;
pub type __int8_t = cty::c_schar;
pub type __uint8_t = cty::c_uchar;
pub type __int16_t = cty::c_short;
pub type __uint16_t = cty::c_ushort;
pub type __int32_t = cty::c_int;
pub type __uint32_t = cty::c_uint;
pub type __int64_t = cty::c_long;
pub type __uint64_t = cty::c_ulong;
pub type M3Result = *const cty::c_char;
pub type IM3Environment = *mut M3Environment;
pub type IM3Runtime = *mut M3Runtime;
pub type IM3Module = *mut M3Module;
pub type IM3Function = *mut M3Function;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3ErrorInfo {
    pub result: M3Result,
    pub runtime: IM3Runtime,
    pub module: IM3Module,
    pub function: IM3Function,
    pub file: *const cty::c_char,
    pub line: u32,
    pub message: *const cty::c_char,
}
pub mod _bindgen_ty_1 {
    pub type Type = cty::c_uint;
    pub const c_m3Type_none: Type = 0;
    pub const c_m3Type_i32: Type = 1;
    pub const c_m3Type_i64: Type = 2;
    pub const c_m3Type_f32: Type = 3;
    pub const c_m3Type_f64: Type = 4;
    pub const c_m3Type_void: Type = 5;
    pub const c_m3Type_ptr: Type = 6;
    pub const c_m3Type_trap: Type = 7;
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3ImportInfo {
    pub moduleUtf8: *const cty::c_char,
    pub fieldUtf8: *const cty::c_char,
}
pub type IM3ImportInfo = *mut M3ImportInfo;
extern "C" {
    pub static mut m3Err_none: M3Result;
}
extern "C" {
    pub static mut m3Err_typeListOverflow: M3Result;
}
extern "C" {
    pub static mut m3Err_mallocFailed: M3Result;
}
extern "C" {
    pub static mut m3Err_incompatibleWasmVersion: M3Result;
}
extern "C" {
    pub static mut m3Err_wasmMalformed: M3Result;
}
extern "C" {
    pub static mut m3Err_misorderedWasmSection: M3Result;
}
extern "C" {
    pub static mut m3Err_wasmUnderrun: M3Result;
}
extern "C" {
    pub static mut m3Err_wasmOverrun: M3Result;
}
extern "C" {
    pub static mut m3Err_wasmMissingInitExpr: M3Result;
}
extern "C" {
    pub static mut m3Err_lebOverflow: M3Result;
}
extern "C" {
    pub static mut m3Err_missingUTF8: M3Result;
}
extern "C" {
    pub static mut m3Err_wasmSectionUnderrun: M3Result;
}
extern "C" {
    pub static mut m3Err_wasmSectionOverrun: M3Result;
}
extern "C" {
    pub static mut m3Err_invalidTypeId: M3Result;
}
extern "C" {
    pub static mut m3Err_tooManyMemorySections: M3Result;
}
extern "C" {
    pub static mut m3Err_moduleAlreadyLinked: M3Result;
}
extern "C" {
    pub static mut m3Err_functionLookupFailed: M3Result;
}
extern "C" {
    pub static mut m3Err_functionImportMissing: M3Result;
}
extern "C" {
    pub static mut m3Err_malformedFunctionSignature: M3Result;
}
extern "C" {
    pub static mut m3Err_funcSignatureMissingReturnType: M3Result;
}
extern "C" {
    pub static mut m3Err_noCompiler: M3Result;
}
extern "C" {
    pub static mut m3Err_unknownOpcode: M3Result;
}
extern "C" {
    pub static mut m3Err_functionStackOverflow: M3Result;
}
extern "C" {
    pub static mut m3Err_functionStackUnderrun: M3Result;
}
extern "C" {
    pub static mut m3Err_mallocFailedCodePage: M3Result;
}
extern "C" {
    pub static mut m3Err_settingImmutableGlobal: M3Result;
}
extern "C" {
    pub static mut m3Err_optimizerFailed: M3Result;
}
extern "C" {
    pub static mut m3Err_missingCompiledCode: M3Result;
}
extern "C" {
    pub static mut m3Err_wasmMemoryOverflow: M3Result;
}
extern "C" {
    pub static mut m3Err_globalMemoryNotAllocated: M3Result;
}
extern "C" {
    pub static mut m3Err_globaIndexOutOfBounds: M3Result;
}
extern "C" {
    pub static mut m3Err_argumentCountMismatch: M3Result;
}
extern "C" {
    pub static mut m3Err_trapOutOfBoundsMemoryAccess: M3Result;
}
extern "C" {
    pub static mut m3Err_trapDivisionByZero: M3Result;
}
extern "C" {
    pub static mut m3Err_trapIntegerOverflow: M3Result;
}
extern "C" {
    pub static mut m3Err_trapIntegerConversion: M3Result;
}
extern "C" {
    pub static mut m3Err_trapIndirectCallTypeMismatch: M3Result;
}
extern "C" {
    pub static mut m3Err_trapTableIndexOutOfRange: M3Result;
}
extern "C" {
    pub static mut m3Err_trapTableElementIsNull: M3Result;
}
extern "C" {
    pub static mut m3Err_trapExit: M3Result;
}
extern "C" {
    pub static mut m3Err_trapAbort: M3Result;
}
extern "C" {
    pub static mut m3Err_trapUnreachable: M3Result;
}
extern "C" {
    pub static mut m3Err_trapStackOverflow: M3Result;
}
extern "C" {
    pub fn m3_NewEnvironment() -> IM3Environment;
}
extern "C" {
    pub fn m3_FreeEnvironment(i_environment: IM3Environment);
}
extern "C" {
    pub fn m3_NewRuntime(
        io_environment: IM3Environment,
        i_stackSizeInBytes: u32,
        unused: *mut cty::c_void,
    ) -> IM3Runtime;
}
extern "C" {
    pub fn m3_FreeRuntime(i_runtime: IM3Runtime);
}
extern "C" {
    pub fn m3_GetMemory(
        i_runtime: IM3Runtime,
        o_memorySizeInBytes: *mut u32,
        i_memoryIndex: u32,
    ) -> *mut u8;
}
extern "C" {
    pub fn m3_ParseModule(
        i_environment: IM3Environment,
        o_module: *mut IM3Module,
        i_wasmBytes: *const u8,
        i_numWasmBytes: u32,
    ) -> M3Result;
}
extern "C" {
    pub fn m3_FreeModule(i_module: IM3Module);
}
extern "C" {
    pub fn m3_LoadModule(io_runtime: IM3Runtime, io_module: IM3Module) -> M3Result;
}
pub type M3RawCall = ::core::option::Option<
    unsafe extern "C" fn(
        runtime: IM3Runtime,
        _sp: *mut u64,
        _mem: *mut cty::c_void,
    ) -> *const cty::c_void,
>;
extern "C" {
    pub fn m3_LinkRawFunction(
        io_module: IM3Module,
        i_moduleName: *const cty::c_char,
        i_functionName: *const cty::c_char,
        i_signature: *const cty::c_char,
        i_function: M3RawCall,
    ) -> M3Result;
}
pub type M3RawCallEx = ::core::option::Option<
    unsafe extern "C" fn(
        runtime: IM3Runtime,
        _sp: *mut u64,
        _mem: *mut cty::c_void,
        cookie: *mut cty::c_void,
    ) -> *const cty::c_void,
>;
extern "C" {
    pub fn m3_LinkRawFunctionEx(
        io_module: IM3Module,
        i_moduleName: *const cty::c_char,
        i_functionName: *const cty::c_char,
        i_signature: *const cty::c_char,
        i_function: M3RawCallEx,
        i_cookie: *mut cty::c_void,
    ) -> M3Result;
}
extern "C" {
    pub fn m3_Yield() -> M3Result;
}
extern "C" {
    pub fn m3_FindFunction(
        o_function: *mut IM3Function,
        i_runtime: IM3Runtime,
        i_functionName: *const cty::c_char,
    ) -> M3Result;
}
extern "C" {
    pub fn m3_Call(i_function: IM3Function) -> M3Result;
}
extern "C" {
    pub fn m3_CallWithArgs(
        i_function: IM3Function,
        i_argc: u32,
        i_argv: *const *const cty::c_char,
    ) -> M3Result;
}
extern "C" {
    pub fn m3_GetErrorInfo(i_runtime: IM3Runtime, info: *mut M3ErrorInfo);
}
extern "C" {
    pub fn m3_ResetErrorInfo(i_runtime: IM3Runtime);
}
extern "C" {
    pub fn m3_PrintRuntimeInfo(i_runtime: IM3Runtime);
}
extern "C" {
    pub fn m3_PrintM3Info();
}
extern "C" {
    pub fn m3_PrintProfilerInfo();
}
pub type f64_ = f64;
pub type f32_ = f32;
pub type u64_ = u64;
pub type i64_ = i64;
pub type u32_ = u32;
pub type i32_ = i32;
pub type u16_ = u16;
pub type i16_ = i16;
pub type u8_ = u8;
pub type i8_ = i8;
pub type m3ret_t = *const cty::c_void;
pub type cstr_t = *const cty::c_char;
pub type ccstr_t = *const cty::c_char;
pub type bytes_t = *const u8_;
pub type cbytes_t = *const u8_;
pub type m3opcode_t = u16_;
pub type m3reg_t = i64_;
pub type m3slot_t = u32_;
pub type m3stack_t = *mut m3slot_t;
pub type code_t = *mut cty::c_void;
pub type pc_t = *const code_t;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3MemoryHeader {
    pub runtime: IM3Runtime,
    pub maxStack: *mut cty::c_void,
    pub length: size_t,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3CodePageHeader {
    pub next: *mut M3CodePage,
    pub lineIndex: u32_,
    pub numLines: u32_,
    pub sequence: u32_,
    pub usageCount: u32_,
}
extern "C" {
    pub fn m3_Malloc(o_ptr: *mut *mut cty::c_void, i_size: size_t) -> M3Result;
}
extern "C" {
    pub fn m3_Realloc(
        io_ptr: *mut *mut cty::c_void,
        i_newSize: size_t,
        i_oldSize: size_t,
    ) -> M3Result;
}
extern "C" {
    pub fn m3_Free(io_ptr: *mut *mut cty::c_void);
}
extern "C" {
    pub fn m3_CopyMem(
        o_to: *mut *mut cty::c_void,
        i_from: *const cty::c_void,
        i_size: size_t,
    ) -> M3Result;
}
extern "C" {
    pub fn NormalizeType(o_type: *mut u8_, i_convolutedWasmType: i8_) -> M3Result;
}
extern "C" {
    pub fn IsIntType(i_wasmType: u8_) -> bool;
}
extern "C" {
    pub fn IsFpType(i_wasmType: u8_) -> bool;
}
extern "C" {
    pub fn Is64BitType(i_m3Type: u8_) -> bool;
}
extern "C" {
    pub fn SizeOfType(i_m3Type: u8_) -> u32_;
}
extern "C" {
    pub fn Read_u64(o_value: *mut u64_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn Read_u32(o_value: *mut u32_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn Read_f64(o_value: *mut f64_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn Read_f32(o_value: *mut f32_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn Read_u8(o_value: *mut u8_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn ReadLebUnsigned(
        o_value: *mut u64_,
        i_maxNumBits: u32_,
        io_bytes: *mut bytes_t,
        i_end: cbytes_t,
    ) -> M3Result;
}
extern "C" {
    pub fn ReadLebSigned(
        o_value: *mut i64_,
        i_maxNumBits: u32_,
        io_bytes: *mut bytes_t,
        i_end: cbytes_t,
    ) -> M3Result;
}
extern "C" {
    pub fn ReadLEB_u32(o_value: *mut u32_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn ReadLEB_u7(o_value: *mut u8_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn ReadLEB_i7(o_value: *mut i8_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn ReadLEB_i32(o_value: *mut i32_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn ReadLEB_i64(o_value: *mut i64_, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn Read_utf8(o_utf8: *mut cstr_t, io_bytes: *mut bytes_t, i_end: cbytes_t) -> M3Result;
}
extern "C" {
    pub fn SPrintArg(
        o_string: *mut cty::c_char,
        i_n: size_t,
        i_sp: m3stack_t,
        i_type: u8_,
    ) -> size_t;
}
extern "C" {
    pub fn ReportError(
        io_runtime: IM3Runtime,
        i_module: IM3Module,
        i_function: IM3Function,
        i_errorMessage: ccstr_t,
        i_file: ccstr_t,
        i_lineNum: u32_,
    );
}
extern "C" {
    pub fn m3_LinkTracer(io_module: IM3Module) -> M3Result;
}
pub type IM3Operation = ::core::option::Option<
    unsafe extern "C" fn(
        _pc: pc_t,
        _sp: m3stack_t,
        _mem: *mut M3MemoryHeader,
        _r0: m3reg_t,
        _fp0: f64_,
    ) -> m3ret_t,
>;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3CodePage {
    pub info: M3CodePageHeader,
    pub code: [code_t; 1usize],
}
pub type IM3CodePage = *mut M3CodePage;
extern "C" {
    pub fn NewCodePage(i_minNumLines: u32_) -> IM3CodePage;
}
extern "C" {
    pub fn FreeCodePages(io_list: *mut IM3CodePage);
}
extern "C" {
    pub fn NumFreeLines(i_page: IM3CodePage) -> u32_;
}
extern "C" {
    pub fn GetPageStartPC(i_page: IM3CodePage) -> pc_t;
}
extern "C" {
    pub fn GetPagePC(i_page: IM3CodePage) -> pc_t;
}
extern "C" {
    pub fn EmitWord_impl(i_page: IM3CodePage, i_word: *mut cty::c_void);
}
extern "C" {
    pub fn EmitWord32(i_page: IM3CodePage, i_word: u32_);
}
extern "C" {
    pub fn EmitWord64(i_page: IM3CodePage, i_word: u64_);
}
extern "C" {
    pub fn PushCodePage(io_list: *mut IM3CodePage, i_codePage: IM3CodePage);
}
extern "C" {
    pub fn PopCodePage(io_list: *mut IM3CodePage) -> IM3CodePage;
}
extern "C" {
    pub fn GetEndCodePage(i_list: IM3CodePage) -> IM3CodePage;
}
extern "C" {
    pub fn CountCodePages(i_list: IM3CodePage) -> u32_;
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3BranchPatch {
    pub next: *mut M3BranchPatch,
    pub location: *mut pc_t,
}
pub type IM3BranchPatch = *mut M3BranchPatch;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3CompilationScope {
    pub outer: *mut M3CompilationScope,
    pub pc: pc_t,
    pub patches: IM3BranchPatch,
    pub depth: i32_,
    pub initStackIndex: i16_,
    pub type_: u8_,
    pub opcode: m3opcode_t,
    pub isPolymorphic: bool,
}
pub type IM3CompilationScope = *mut M3CompilationScope;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3Compilation {
    pub runtime: IM3Runtime,
    pub module: IM3Module,
    pub wasm: bytes_t,
    pub wasmEnd: bytes_t,
    pub block: M3CompilationScope,
    pub function: IM3Function,
    pub page: IM3CodePage,
    pub releasedPatches: IM3BranchPatch,
    pub numEmits: u32_,
    pub numOpcodes: u32_,
    pub firstDynamicStackIndex: u16_,
    pub stackIndex: u16_,
    pub firstConstSlotIndex: u16_,
    pub maxConstSlotIndex: u16_,
    pub firstLocalSlotIndex: u16_,
    pub firstDynamicSlotIndex: u16_,
    pub constants: [m3slot_t; 120usize],
    pub wasmStack: [u16_; 2000usize],
    pub typeStack: [u8_; 2000usize],
    pub m3Slots: [u8_; 4000usize],
    pub maxAllocatedSlotPlusOne: u16_,
    pub regStackIndexPlusOne: [u16_; 2usize],
    pub previousOpcode: m3opcode_t,
}
pub type IM3Compilation = *mut M3Compilation;
pub type M3Compiler = ::core::option::Option<
    unsafe extern "C" fn(arg1: IM3Compilation, arg2: m3opcode_t) -> M3Result,
>;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3OpInfo {
    pub stackOffset: i8_,
    pub type_: u8_,
    pub operations: [IM3Operation; 4usize],
    pub compiler: M3Compiler,
}
pub type IM3OpInfo = *const M3OpInfo;
extern "C" {
    pub fn GetTypeNumSlots(i_type: u8_) -> u16_;
}
extern "C" {
    pub fn AlignSlotIndexToType(io_slotIndex: *mut u16_, i_type: u8_);
}
extern "C" {
    pub fn IsRegisterAllocated(o: IM3Compilation, i_register: u32_) -> bool;
}
extern "C" {
    pub fn IsRegisterLocation(i_location: i16_) -> bool;
}
extern "C" {
    pub fn IsFpRegisterLocation(i_location: i16_) -> bool;
}
extern "C" {
    pub fn IsIntRegisterLocation(i_location: i16_) -> bool;
}
extern "C" {
    pub fn IsStackPolymorphic(o: IM3Compilation) -> bool;
}
extern "C" {
    pub fn CompileBlock(io: IM3Compilation, i_blockType: u8_, i_blockOpcode: u8_) -> M3Result;
}
extern "C" {
    pub fn Compile_BlockStatements(io: IM3Compilation) -> M3Result;
}
extern "C" {
    pub fn Compile_Function(io_function: IM3Function) -> M3Result;
}
extern "C" {
    pub fn GetMaxUsedSlotPlusOne(o: IM3Compilation) -> u16_;
}
extern "C" {
    pub fn BridgeToNewPageIfNecessary(o: IM3Compilation) -> M3Result;
}
extern "C" {
    pub fn EnsureCodePageNumLines(o: IM3Compilation, i_numLines: u32_) -> M3Result;
}
extern "C" {
    pub fn EmitOp(o: IM3Compilation, i_operation: IM3Operation) -> M3Result;
}
extern "C" {
    pub fn EmitConstant32(o: IM3Compilation, i_immediate: u32_);
}
extern "C" {
    pub fn EmitSlotOffset(o: IM3Compilation, i_offset: i32_);
}
extern "C" {
    pub fn EmitPointer(o: IM3Compilation, i_pointer: *const cty::c_void);
}
extern "C" {
    pub fn ReservePointer(o: IM3Compilation) -> *mut cty::c_void;
}
extern "C" {
    pub fn GetPC(o: IM3Compilation) -> pc_t;
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3FuncType {
    pub next: *mut M3FuncType,
    pub numArgs: u32_,
    pub returnType: u8_,
    pub argTypes: [u8_; 3usize],
}
pub type IM3FuncType = *mut M3FuncType;
extern "C" {
    pub fn AllocFuncType(o_functionType: *mut IM3FuncType, i_numArgs: u32_) -> M3Result;
}
extern "C" {
    pub fn AreFuncTypesEqual(i_typeA: IM3FuncType, i_typeB: IM3FuncType) -> bool;
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3Function {
    pub module: *mut M3Module,
    pub import: M3ImportInfo,
    pub wasm: bytes_t,
    pub wasmEnd: bytes_t,
    pub name: cstr_t,
    pub funcType: IM3FuncType,
    pub compiled: pc_t,
    pub maxStackSlots: u16_,
    pub numArgSlots: u16_,
    pub numLocals: u16_,
    pub numLocalBytes: u16_,
    pub constants: *mut cty::c_void,
    pub numConstantBytes: u16_,
    pub ownsWasmCode: bool,
}
extern "C" {
    pub fn Function_Release(i_function: IM3Function);
}
extern "C" {
    pub fn Function_FreeCompiledCode(i_function: IM3Function);
}
extern "C" {
    pub fn GetFunctionImportModuleName(i_function: IM3Function) -> cstr_t;
}
extern "C" {
    pub fn GetFunctionName(i_function: IM3Function) -> cstr_t;
}
extern "C" {
    pub fn GetFunctionNumArgs(i_function: IM3Function) -> u32_;
}
extern "C" {
    pub fn GetFunctionNumReturns(i_function: IM3Function) -> u32_;
}
extern "C" {
    pub fn GetFunctionReturnType(i_function: IM3Function) -> u8_;
}
extern "C" {
    pub fn GetFunctionNumArgsAndLocals(i_function: IM3Function) -> u32_;
}
extern "C" {
    pub fn SPrintFunctionArgList(i_function: IM3Function, i_sp: m3stack_t) -> cstr_t;
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3MemoryInfo {
    pub initPages: u32_,
    pub maxPages: u32_,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3Memory {
    pub mallocated: *mut M3MemoryHeader,
    pub numPages: u32_,
    pub maxPages: u32_,
}
pub type IM3Memory = *mut M3Memory;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3DataSegment {
    pub initExpr: *const u8_,
    pub data: *const u8_,
    pub initExprSize: u32_,
    pub memoryRegion: u32_,
    pub size: u32_,
}
extern "C" {
    pub fn FreeImportInfo(i_info: *mut M3ImportInfo);
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3Global {
    pub import: M3ImportInfo,
    pub __bindgen_anon_1: M3Global__bindgen_ty_1,
    pub initExpr: bytes_t,
    pub initExprSize: u32_,
    pub type_: u8_,
    pub imported: bool,
    pub isMutable: bool,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union M3Global__bindgen_ty_1 {
    pub intValue: i64_,
    pub f64Value: f64_,
    pub f32Value: f32_,
}
pub type IM3Global = *mut M3Global;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3Module {
    pub runtime: *mut M3Runtime,
    pub environment: *mut M3Environment,
    pub name: cstr_t,
    pub numFuncTypes: u32_,
    pub funcTypes: *mut IM3FuncType,
    pub numImports: u32_,
    pub imports: *mut IM3Function,
    pub numFunctions: u32_,
    pub functions: *mut M3Function,
    pub startFunction: i32_,
    pub numDataSegments: u32_,
    pub dataSegments: *mut M3DataSegment,
    pub importedGlobals: u32_,
    pub numGlobals: u32_,
    pub globals: *mut M3Global,
    pub numElementSegments: u32_,
    pub elementSection: bytes_t,
    pub elementSectionEnd: bytes_t,
    pub table0: *mut IM3Function,
    pub table0Size: u32_,
    pub memoryInfo: M3MemoryInfo,
    pub memoryImported: bool,
    pub hasWasmCodeCopy: bool,
    pub next: *mut M3Module,
}
extern "C" {
    pub fn Module_AddGlobal(
        io_module: IM3Module,
        o_global: *mut IM3Global,
        i_type: u8_,
        i_mutable: bool,
        i_isImported: bool,
    ) -> M3Result;
}
extern "C" {
    pub fn Module_AddFunction(
        io_module: IM3Module,
        i_typeIndex: u32_,
        i_importInfo: IM3ImportInfo,
    ) -> M3Result;
}
extern "C" {
    pub fn Module_GetFunction(i_module: IM3Module, i_functionIndex: u32_) -> IM3Function;
}
pub const c_m3NumTypesPerPage: u32_ = 8;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3Environment {
    pub funcTypes: IM3FuncType,
    pub pagesReleased: *mut M3CodePage,
}
extern "C" {
    pub fn Environment_Release(i_environment: IM3Environment);
}
extern "C" {
    pub fn Environment_AddFuncType(i_environment: IM3Environment, io_funcType: *mut IM3FuncType);
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct M3Runtime {
    pub compilation: M3Compilation,
    pub environment: IM3Environment,
    pub pagesOpen: *mut M3CodePage,
    pub pagesFull: *mut M3CodePage,
    pub numCodePages: u32_,
    pub numActiveCodePages: u32_,
    pub modules: IM3Module,
    pub stack: *mut cty::c_void,
    pub stackSize: u32_,
    pub numStackSlots: u32_,
    pub argc: u32_,
    pub argv: *mut ccstr_t,
    pub runtimeError: M3Result,
    pub memory: M3Memory,
    pub memoryLimit: u32_,
    pub error: M3ErrorInfo,
    pub error_message: [cty::c_char; 256usize],
    pub exit_code: i32_,
}
extern "C" {
    pub fn InitRuntime(io_runtime: IM3Runtime, i_stackSizeInBytes: u32_);
}
extern "C" {
    pub fn Runtime_Release(io_runtime: IM3Runtime);
}
extern "C" {
    pub fn ResizeMemory(io_runtime: IM3Runtime, i_numPages: u32_) -> M3Result;
}
pub type ModuleVisitor = ::core::option::Option<
    unsafe extern "C" fn(i_module: IM3Module, i_info: *mut cty::c_void) -> *mut cty::c_void,
>;
extern "C" {
    pub fn ForEachModule(
        i_runtime: IM3Runtime,
        i_visitor: ModuleVisitor,
        i_info: *mut cty::c_void,
    ) -> *mut cty::c_void;
}
extern "C" {
    pub fn AcquireCodePage(io_runtime: IM3Runtime) -> IM3CodePage;
}
extern "C" {
    pub fn AcquireCodePageWithCapacity(io_runtime: IM3Runtime, i_lineCount: u32_) -> IM3CodePage;
}
extern "C" {
    pub fn ReleaseCodePage(io_runtime: IM3Runtime, i_codePage: IM3CodePage);
}
extern "C" {
    pub fn ConvertTypeCharToTypeId(i_code: cty::c_char) -> u8_;
}
extern "C" {
    pub fn SignatureToFuncType(o_functionType: *mut IM3FuncType, i_signature: ccstr_t) -> M3Result;
}
extern "C" {
    pub fn m3_LinkWASI(io_module: IM3Module) -> M3Result;
}
extern "C" {
    pub fn m3_LinkLibC(io_module: IM3Module) -> M3Result;
}
extern "C" {
    pub fn m3_LinkSpecTest(io_module: IM3Module) -> M3Result;
}