om2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception note om/frontier/frontier_gen.om note Pure Seeded OM-2 Frontier Graphics Compiler & WebAssembly v128 + i64 Binary Emitter. note Zero C, zero GCC, zero libc, zero Emscripten, zero LLVM. note Modes: note default : emits deterministic 4-page Wasm v128 + i64 binary on stdout note --selftest : executes Q32.32/Q16.16/WattCBF/FNV-64 native parity suite note --corrupt : emits truncated negative-control Wasm (WebAssembly.validate === false) const FNV_OFF ulong 14695981039346656037 const FNV_PRM ulong 1099511628211 const EARTH_R_Q32 long 27363237986304000 const TOOTH_08MM_Q32 long 3435974 const SNAP_500MM_Q32 long 2147483648 const WATT_MAX_MW ulong 80000 global w_buf uchar 16384 global w_len ulong 1 global s_buf uchar 8192 global s_len ulong 1 global f_buf uchar 4096 global f_len ulong 1 global g_arg uchar 64 global g_out uchar 256 text t_st "--selftest" text t_cor "--corrupt" text t_hex "0123456789abcdef" text t_pass_a "OMEGA_FRONTIER_SELFTEST PASS q32_tooth_delta=3435974 f32_collapse=0 watt_refuse=81 fnv64=" text t_nl "\n" text exp_mem "memory" text exp_wave "step_wave_v128" text exp_caus "eval_caustic_v128" text exp_clth "step_cloth_verlet_v128" text exp_mscl "filter_multiscale_v128" text exp_q32 "q32_rel_offset_m" text exp_f32 "f32_world_collapse_m" text exp_fnv "fnv64_mix" text exp_watt "check_watt_cbf" note ================= Native Frontier Math & Self-Test ================= fn fnv_mix_u64 h ulong v ulong to ulong x = xor h v ret mul x FNV_PRM end fn q32_rel_offset world_q32 long anchor_q32 long to long ret sub world_q32 anchor_q32 end fn snap500mm_q32 world_q32 long to long ret mul (div world_q32 SNAP_500MM_Q32) SNAP_500MM_Q32 end fn gerstner_jacobian_q16 q_sum long to long ret sub long 65536 q_sum end fn filter_roughness_q16 r0 ulong slope_var ulong to ulong s = add r0 slope_var if ge s ulong 65536 ret ulong 65536 end ret s end fn step_hull_ccd_q16 y long target_y long floor_y long rad long role ulong to long if eq role ulong 1 ret target_y end min_y = add floor_y rad if ge y min_y if lt target_y min_y ret min_y end end ret target_y end fn step_saccade_q16 tick ulong to long ph = rem tick ulong 16 if lt ph ulong 4 ret long 820 end if lt ph ulong 8 ret long -640 end if lt ph ulong 12 ret long 390 end ret long -210 end fn check_watt_cbf cpu_mw ulong gpu_mw ulong to ulong tot = add cpu_mw gpu_mw if ge tot WATT_MAX_MW ret ulong 81 end ret ulong 0 end fn arg_eq_txt idx ulong pat view uchar * to bool pn = len pat n = argread idx g_arg ulong 0 ulong 60 if ne n (long pn) ret false end for i ulong pn bound 64 if ne (get g_arg i) (get pat i) ret false end end ret true end fn write_hex64 v ulong to void for i ulong 16 bound 17 sh = mul (sub ulong 15 i) ulong 4 put g_out i (get t_hex (and (shr v sh) ulong 15)) end k = write int 1 g_out ulong 0 ulong 16 end fn selftest_check_a to ulong w_tooth = add EARTH_R_Q32 TOOTH_08MM_Q32 d_q32 = q32_rel_offset w_tooth EARTH_R_Q32 d_f32 = sub (snap500mm_q32 w_tooth) (snap500mm_q32 EARTH_R_Q32) if ne d_q32 TOOTH_08MM_Q32 ret ulong 0 end if ne d_f32 long 0 ret ulong 0 end jac = gerstner_jacobian_q16 long 48000 if ne jac long 17536 ret ulong 0 end h = fnv_mix_u64 FNV_OFF (bitcast ulong d_q32) ret fnv_mix_u64 h (bitcast ulong jac) end fn selftest_check_b h_in ulong to ulong rf = filter_roughness_q16 ulong 8192 ulong 16384 rf_cap = filter_roughness_q16 ulong 40000 ulong 40000 if ne rf ulong 24576 ret ulong 0 end if ne rf_cap ulong 65536 ret ulong 0 end h_sol = step_hull_ccd_q16 long 131072 long -65536 long 0 long 32768 ulong 0 h_flu = step_hull_ccd_q16 long 131072 long -65536 long 0 long 32768 ulong 1 if ne h_sol long 32768 ret ulong 0 end if ne h_flu long -65536 ret ulong 0 end h = fnv_mix_u64 h_in rf ret fnv_mix_u64 h (bitcast ulong h_sol) end fn run_selftest to int h1 = selftest_check_a if eq h1 ulong 0 ret int 1 end h2 = selftest_check_b h1 if eq h2 ulong 0 ret int 2 end sac = step_saccade_q16 ulong 5 w_ok = check_watt_cbf ulong 42000 ulong 28000 w_bad = check_watt_cbf ulong 50000 ulong 45000 if ne w_ok ulong 0 ret int 8 end if ne w_bad ulong 81 ret int 9 end h = fnv_mix_u64 h2 (bitcast ulong sac) h = fnv_mix_u64 h w_bad k1 = write int 1 t_pass_a ulong 0 (len t_pass_a) write_hex64 h k2 = write int 1 t_nl ulong 0 (len t_nl) ret int 0 end note ================= WebAssembly Buffer & LEB128 Helpers ================= fn w_u8 b uchar to void p = get w_len ulong 0 if lt p ulong 16384 put w_buf p b put w_len ulong 0 (add p ulong 1) end end fn w_uleb v ulong to void x = v done = false while not done bound 16 b = and x ulong 127 x = shr x ulong 7 if ne x ulong 0 b = or b ulong 128 else done = true end w_u8 (uchar b) end end fn s_reset to void put s_len ulong 0 ulong 0 end fn s_u8 b uchar to void p = get s_len ulong 0 if lt p ulong 8192 put s_buf p b put s_len ulong 0 (add p ulong 1) end end fn s_uleb v ulong to void x = v done = false while not done bound 16 b = and x ulong 127 x = shr x ulong 7 if ne x ulong 0 b = or b ulong 128 else done = true end s_u8 (uchar b) end end fn s_str name view uchar * to void n = len name s_uleb n for i ulong n bound 128 s_u8 (get name i) end end fn s_flush sec_id uchar to void n = get s_len ulong 0 w_u8 sec_id w_uleb n for i ulong n bound 8192 w_u8 (get s_buf i) end s_reset end fn f_reset to void put f_len ulong 0 ulong 0 end fn f_u8 b uchar to void p = get f_len ulong 0 if lt p ulong 4096 put f_buf p b put f_len ulong 0 (add p ulong 1) end end fn f_uleb v ulong to void x = v done = false while not done bound 16 b = and x ulong 127 x = shr x ulong 7 if ne x ulong 0 b = or b ulong 128 else done = true end f_u8 (uchar b) end end fn f_sleb v long to void x = v done = false while not done bound 16 b = and x long 127 x = shr x long 7 sb = and b long 64 if and (eq x long 0) (eq sb long 0) done = true else if and (eq x long -1) (ne sb long 0) done = true else b = or b long 128 end end f_u8 (uchar and b long 255) end end fn f_flush_to_s to void n = get f_len ulong 0 s_uleb n for i ulong n bound 4096 s_u8 (get f_buf i) end f_reset end note ================= Wasm Instruction Emitters ================= fn op_lget idx ulong to void f_u8 uchar 0x20 f_uleb idx end fn op_lset idx ulong to void f_u8 uchar 0x21 f_uleb idx end fn op_i32c v long to void f_u8 uchar 0x41 f_sleb v end fn op_i64c v long to void f_u8 uchar 0x42 f_sleb v end fn op_f32c b0 uchar b1 uchar b2 uchar b3 uchar to void f_u8 uchar 0x43 f_u8 b0 f_u8 b1 f_u8 b2 f_u8 b3 end fn op_f64c_inv2p32 to void note Exact IEEE-754 f64 constant 2^-32 = 0x3df0000000000000 little-endian f_u8 uchar 0x44 f_u8 uchar 0x00 f_u8 uchar 0x00 f_u8 uchar 0x00 f_u8 uchar 0x00 f_u8 uchar 0x00 f_u8 uchar 0x00 f_u8 uchar 0xf0 f_u8 uchar 0x3d end fn op_simd op ulong to void f_u8 uchar 0xfd f_uleb op end fn op_vload align ulong off ulong to void op_simd ulong 0x00 f_uleb align f_uleb off end fn op_vstore align ulong off ulong to void op_simd ulong 0x0b f_uleb align f_uleb off end fn op_f32x4_rep lane ulong to void op_simd ulong 0x20 f_u8 (uchar and lane ulong 3) end fn emit_header to void w_u8 uchar 0x00 w_u8 uchar 0x61 w_u8 uchar 0x73 w_u8 uchar 0x6d w_u8 uchar 0x01 w_u8 uchar 0x00 w_u8 uchar 0x00 w_u8 uchar 0x00 end fn emit_types_a to void note Type 0: (i32, i32, i32, i32, f32, f32) -> () s_u8 uchar 0x60 s_uleb ulong 6 s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7d s_u8 uchar 0x7d s_uleb ulong 0 note Type 1: (i32, i32, i32, f32, f32) -> () s_u8 uchar 0x60 s_uleb ulong 5 s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7d s_u8 uchar 0x7d s_uleb ulong 0 note Type 2: (i32, i32, i32, f32, f32, f32, f32) -> () s_u8 uchar 0x60 s_uleb ulong 7 s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7d s_u8 uchar 0x7d s_u8 uchar 0x7d s_u8 uchar 0x7d s_uleb ulong 0 note Type 3: (i32, i32, i32, i32, f32) -> () s_u8 uchar 0x60 s_uleb ulong 5 s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7f s_u8 uchar 0x7d s_uleb ulong 0 end fn emit_types_b to void note Type 4: (i64, i64) -> (f32) s_u8 uchar 0x60 s_uleb ulong 2 s_u8 uchar 0x7e s_u8 uchar 0x7e s_uleb ulong 1 s_u8 uchar 0x7d note Type 5: (i64, i64) -> (i64) s_u8 uchar 0x60 s_uleb ulong 2 s_u8 uchar 0x7e s_u8 uchar 0x7e s_uleb ulong 1 s_u8 uchar 0x7e note Type 6: (i32, i32) -> (i32) s_u8 uchar 0x60 s_uleb ulong 2 s_u8 uchar 0x7f s_u8 uchar 0x7f s_uleb ulong 1 s_u8 uchar 0x7f end fn emit_type_section to void s_reset s_uleb ulong 7 emit_types_a emit_types_b s_flush uchar 1 end fn emit_function_section to void s_reset s_uleb ulong 8 s_uleb ulong 0 s_uleb ulong 1 s_uleb ulong 2 s_uleb ulong 3 s_uleb ulong 4 s_uleb ulong 4 s_uleb ulong 5 s_uleb ulong 6 s_flush uchar 3 end fn emit_memory_section to void note 4 linear memory pages = 256 KiB shared with WebGL2 textures & buffers s_reset s_uleb ulong 1 s_u8 uchar 0x00 s_uleb ulong 4 s_flush uchar 5 end fn emit_export_section to void s_reset s_uleb ulong 9 s_str exp_mem s_u8 uchar 0x02 s_uleb ulong 0 s_str exp_wave s_u8 uchar 0x00 s_uleb ulong 0 s_str exp_caus s_u8 uchar 0x00 s_uleb ulong 1 s_str exp_clth s_u8 uchar 0x00 s_uleb ulong 2 s_str exp_mscl s_u8 uchar 0x00 s_uleb ulong 3 s_str exp_q32 s_u8 uchar 0x00 s_uleb ulong 4 s_str exp_f32 s_u8 uchar 0x00 s_uleb ulong 5 s_str exp_fnv s_u8 uchar 0x00 s_uleb ulong 6 s_str exp_watt s_u8 uchar 0x00 s_uleb ulong 7 s_flush uchar 7 end note Shared 5-point 64x64 f32x4 stencil Laplacian helper: pushes laplacian(v128) for base local ptr_idx note Offsets for (row 1, col 1) relative to base (row 0, col 0): N=4, W=256, C=260, E=264, S=516 fn emit_lap5_v128 ptr_idx ulong center_loc ulong to void op_lget ptr_idx op_vload ulong 2 ulong 260 op_lset center_loc op_lget ptr_idx op_vload ulong 2 ulong 4 op_lget ptr_idx op_vload ulong 2 ulong 516 op_simd ulong 0xe4 op_lget ptr_idx op_vload ulong 2 ulong 256 op_lget ptr_idx op_vload ulong 2 ulong 264 op_simd ulong 0xe4 op_simd ulong 0xe4 op_lget center_loc op_f32c uchar 0x00 uchar 0x00 uchar 0x80 uchar 0x40 op_simd ulong 0x13 op_simd ulong 0xe6 op_simd ulong 0xe5 end note Func 0: step_wave_v128(p_curr=0, p_prev=1, p_next=2, n_vec4=3, c2dt2=4, damp=5) fn emit_fn_wave to void f_reset note Locals: 6=i(i32), 7=vc(v128), 8=vc2(v128), 9=vdamp(v128), 10=v2(v128) f_uleb ulong 2 f_uleb ulong 1 f_u8 uchar 0x7f f_uleb ulong 4 f_u8 uchar 0x7b op_lget ulong 4 op_simd ulong 0x13 op_lset ulong 8 op_lget ulong 5 op_simd ulong 0x13 op_lset ulong 9 op_f32c uchar 0x00 uchar 0x00 uchar 0x00 uchar 0x40 op_simd ulong 0x13 op_lset ulong 10 f_u8 uchar 0x02 f_u8 uchar 0x40 f_u8 uchar 0x03 f_u8 uchar 0x40 op_lget ulong 6 op_lget ulong 3 f_u8 uchar 0x4f f_u8 uchar 0x0d f_uleb ulong 1 op_lget ulong 2 emit_lap5_v128 ulong 0 ulong 7 op_lget ulong 8 op_simd ulong 0xe6 op_lget ulong 7 op_lget ulong 10 op_simd ulong 0xe6 op_lget ulong 1 op_vload ulong 2 ulong 260 op_simd ulong 0xe5 op_simd ulong 0xe4 op_lget ulong 9 op_simd ulong 0xe6 op_f32c uchar 0x00 uchar 0x00 uchar 0xc0 uchar 0x3f op_simd ulong 0x13 op_simd ulong 0xe8 op_f32c uchar 0x00 uchar 0x00 uchar 0xc0 uchar 0xbf op_simd ulong 0x13 op_simd ulong 0xe9 op_vstore ulong 2 ulong 260 op_lget ulong 0 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 0 op_lget ulong 1 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 1 op_lget ulong 2 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 2 op_lget ulong 6 op_i32c long 1 f_u8 uchar 0x6a op_lset ulong 6 f_u8 uchar 0x0c f_uleb ulong 0 f_u8 uchar 0x0b f_u8 uchar 0x0b f_u8 uchar 0x0b f_flush_to_s end note Func 1: eval_caustic_v128(p_h=0, p_out=1, n_vec4=2, depth_scale=3, base_int=4) fn emit_fn_caustic to void f_reset note Locals: 5=i(i32), 6=vc(v128), 7=vd(v128), 8=vb(v128), 9=v1(v128) f_uleb ulong 2 f_uleb ulong 1 f_u8 uchar 0x7f f_uleb ulong 4 f_u8 uchar 0x7b op_lget ulong 3 op_simd ulong 0x13 op_lset ulong 7 op_lget ulong 4 op_simd ulong 0x13 op_lset ulong 8 op_f32c uchar 0x00 uchar 0x00 uchar 0x80 uchar 0x3f op_simd ulong 0x13 op_lset ulong 9 f_u8 uchar 0x02 f_u8 uchar 0x40 f_u8 uchar 0x03 f_u8 uchar 0x40 op_lget ulong 5 op_lget ulong 2 f_u8 uchar 0x4f f_u8 uchar 0x0d f_uleb ulong 1 op_lget ulong 1 op_lget ulong 8 op_lget ulong 9 emit_lap5_v128 ulong 0 ulong 6 op_lget ulong 7 op_simd ulong 0xe6 op_simd ulong 0xe4 op_f32c uchar 0x00 uchar 0x00 uchar 0x40 uchar 0x3e op_simd ulong 0x13 op_simd ulong 0xe9 op_simd ulong 0xe7 op_f32c uchar 0x00 uchar 0x00 uchar 0x90 uchar 0x40 op_simd ulong 0x13 op_simd ulong 0xe8 op_f32c uchar 0x00 uchar 0x00 uchar 0x80 uchar 0x3d op_simd ulong 0x13 op_simd ulong 0xe9 op_vstore ulong 2 ulong 260 op_lget ulong 0 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 0 op_lget ulong 1 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 1 op_lget ulong 5 op_i32c long 1 f_u8 uchar 0x6a op_lset ulong 5 f_u8 uchar 0x0c f_uleb ulong 0 f_u8 uchar 0x0b f_u8 uchar 0x0b f_u8 uchar 0x0b f_flush_to_s end note Func 2: step_cloth_verlet_v128(p_pos=0, p_prev=1, n_vec4=2, ax=3, ay=4, az=5, damp=6) fn emit_fn_cloth to void f_reset note Locals: 7=i(i32), 8=vacc(v128), 9=vdamp(v128), 10=vpos(v128), 11=vnext(v128) f_uleb ulong 2 f_uleb ulong 1 f_u8 uchar 0x7f f_uleb ulong 4 f_u8 uchar 0x7b op_f32c uchar 0x00 uchar 0x00 uchar 0x00 uchar 0x00 op_simd ulong 0x13 op_lget ulong 3 op_f32x4_rep ulong 0 op_lget ulong 4 op_f32x4_rep ulong 1 op_lget ulong 5 op_f32x4_rep ulong 2 op_lset ulong 8 op_lget ulong 6 op_simd ulong 0x13 op_lset ulong 9 f_u8 uchar 0x02 f_u8 uchar 0x40 f_u8 uchar 0x03 f_u8 uchar 0x40 op_lget ulong 7 op_lget ulong 2 f_u8 uchar 0x4f f_u8 uchar 0x0d f_uleb ulong 1 op_lget ulong 0 op_vload ulong 2 ulong 0 op_lset ulong 10 op_lget ulong 10 op_lget ulong 10 op_lget ulong 1 op_vload ulong 2 ulong 0 op_simd ulong 0xe5 op_lget ulong 9 op_simd ulong 0xe6 op_simd ulong 0xe4 op_lget ulong 8 op_simd ulong 0xe4 op_lset ulong 11 op_lget ulong 1 op_lget ulong 10 op_vstore ulong 2 ulong 0 op_lget ulong 0 op_lget ulong 11 op_vstore ulong 2 ulong 0 op_lget ulong 0 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 0 op_lget ulong 1 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 1 op_lget ulong 7 op_i32c long 1 f_u8 uchar 0x6a op_lset ulong 7 f_u8 uchar 0x0c f_uleb ulong 0 f_u8 uchar 0x0b f_u8 uchar 0x0b f_u8 uchar 0x0b f_flush_to_s end note Func 3: filter_multiscale_v128(p_r0=0, p_fp=1, p_out=2, n_vec4=3, slope_var=4) fn emit_fn_multiscale to void f_reset note Locals: 5=i(i32), 6=vsv(v128), 7=v1(v128), 8=vr(v128), 9=vfp(v128) f_uleb ulong 2 f_uleb ulong 1 f_u8 uchar 0x7f f_uleb ulong 4 f_u8 uchar 0x7b op_lget ulong 4 op_simd ulong 0x13 op_lset ulong 6 op_f32c uchar 0x00 uchar 0x00 uchar 0x80 uchar 0x3f op_simd ulong 0x13 op_lset ulong 7 f_u8 uchar 0x02 f_u8 uchar 0x40 f_u8 uchar 0x03 f_u8 uchar 0x40 op_lget ulong 5 op_lget ulong 3 f_u8 uchar 0x4f f_u8 uchar 0x0d f_uleb ulong 1 op_lget ulong 0 op_vload ulong 2 ulong 0 op_lset ulong 8 op_lget ulong 1 op_vload ulong 2 ulong 0 op_lset ulong 9 op_lget ulong 2 op_lget ulong 8 op_lget ulong 8 op_simd ulong 0xe6 op_lget ulong 9 op_lget ulong 9 op_simd ulong 0xe6 op_lget ulong 6 op_simd ulong 0xe6 op_simd ulong 0xe4 op_simd ulong 0xe3 op_lget ulong 7 op_simd ulong 0xe8 op_vstore ulong 2 ulong 0 op_lget ulong 0 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 0 op_lget ulong 1 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 1 op_lget ulong 2 op_i32c long 16 f_u8 uchar 0x6a op_lset ulong 2 op_lget ulong 5 op_i32c long 1 f_u8 uchar 0x6a op_lset ulong 5 f_u8 uchar 0x0c f_uleb ulong 0 f_u8 uchar 0x0b f_u8 uchar 0x0b f_u8 uchar 0x0b f_flush_to_s end note Func 4: q32_rel_offset_m(world_q32=0, anchor_q32=1) -> f32 fn emit_fn_q32_rel to void f_reset f_uleb ulong 0 op_lget ulong 0 op_lget ulong 1 f_u8 uchar 0x7d f_u8 uchar 0xb9 op_f64c_inv2p32 f_u8 uchar 0xa2 f_u8 uchar 0xb6 f_u8 uchar 0x0b f_flush_to_s end note Func 5: f32_world_collapse_m(world_q32=0, anchor_q32=1) -> f32 fn emit_fn_f32_collapse to void f_reset f_uleb ulong 0 op_lget ulong 0 f_u8 uchar 0xb9 op_f64c_inv2p32 f_u8 uchar 0xa2 f_u8 uchar 0xb6 op_lget ulong 1 f_u8 uchar 0xb9 op_f64c_inv2p32 f_u8 uchar 0xa2 f_u8 uchar 0xb6 f_u8 uchar 0x93 f_u8 uchar 0x0b f_flush_to_s end note Func 6: fnv64_mix(h=0, v=1) -> i64 fn emit_fn_fnv64 to void f_reset f_uleb ulong 0 op_lget ulong 0 op_lget ulong 1 f_u8 uchar 0x85 op_i64c long 1099511628211 f_u8 uchar 0x7e f_u8 uchar 0x0b f_flush_to_s end note Func 7: check_watt_cbf(cpu_mw=0, gpu_mw=1) -> i32 (0 ok, 81 refused if >= 80000) fn emit_fn_watt to void f_reset f_uleb ulong 0 op_lget ulong 0 op_lget ulong 1 f_u8 uchar 0x6a op_i32c long 80000 f_u8 uchar 0x49 f_u8 uchar 0x04 f_u8 uchar 0x7f op_i32c long 0 f_u8 uchar 0x05 op_i32c long 81 f_u8 uchar 0x0b f_u8 uchar 0x0b f_flush_to_s end fn emit_code_section to void s_reset s_uleb ulong 8 emit_fn_wave emit_fn_caustic emit_fn_cloth emit_fn_multiscale emit_fn_q32_rel emit_fn_f32_collapse emit_fn_fnv64 emit_fn_watt s_flush uchar 10 end fn write_all n ulong to bool off = ulong 0 while lt off n bound 1024 k = write int 1 w_buf off (sub n off) if le k long 0 ret false end off = add off (ulong k) end ret true end fn main to int ac = argcnt if gt ac long 1 if arg_eq_txt ulong 1 t_st ret run_selftest end end put w_len ulong 0 ulong 0 emit_header emit_type_section emit_function_section emit_memory_section emit_export_section emit_code_section total = get w_len ulong 0 if gt ac long 1 if arg_eq_txt ulong 1 t_cor if gt total ulong 12 total = sub total ulong 12 end end end if not (write_all total) ret int 1 end ret int 0 end