nandi/vflutter_ffipublic Fork 0
81540bb
Commits
Clone
git clone https://git.rickub.com/nandi/vflutter_ffi.git
git clone ssh://git@rickub.com/nandi/vflutter_ffi.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Add a Mandelbrot example app, and a V kernel worth demonstrating

The example was two headless scripts over add()/greet(); nothing exercised
the plugin as a real Flutter app, so the CMake -> v -> clang path had never
been built. It is now a Mandelbrot explorer with the kernel in V.

vf_mandelbrot inverts the ownership story of the string API on purpose: the
caller allocates the RGBA buffer and V only fills it, so nothing crosses the
boundary needing vf_free and the hot loop allocates nothing. Bands are
independent, which is what makes the multi-isolate split safe under -gc none.

On performance, honestly: V is not meaningfully faster than Dart here.
At 800x600 / 500 iterations, V takes ~154 ms against Dart AOT's ~165 ms.
The ~2.3x headline is the parallel split, which Dart could do without any
FFI. The app is a demonstration of the bridge, not a speed claim, and both
READMEs now say so. The Dart transliteration in mandelbrot_dart.dart exists
so the comparison can be checked: the tests assert the two agree exactly.

Build fixes found along the way:

* tool/build.sh built without -gc none or -prod, so the smoke-test library
  was neither the configuration the READMEs describe nor optimised.
* src/CMakeLists.txt compiled V's generated C at the Flutter build type's
  default. At -O0 the kernel runs roughly 2x slower than Dart, which made a
  debug run of the example badly misrepresent the bridge. -O2 is now forced.

Two UI bugs, both caught by tests rather than by looking:

* The narrow layout nested a ListView inside a ListView, giving the inner one
  unbounded height and breaking that layout entirely.
* Zooming during an in-flight render mutated the view without drawing it, so
  input silently accumulated and the next frame jumped several zoom levels.
  Renders now coalesce, which is also what makes wheel zoom usable.

Reset view rebuilt the entire view, clobbering the iteration slider and the
canvas-fitted height it does not own. It now resets pan and zoom only.

Verified on Linux: flutter analyze clean, 10 tests passing, release build
run, and the headless bench/string/RSS scripts still green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
nandithebull committed 2026-09-18T16:06:23-07:00 Browse files
81540bb parent: ad0ccda
modified README.md +28 -4
@@ -74,6 +74,28 @@ await v.greetAsync('isolate'); // same, off the UI isolate
7474 calls are safe from any isolate. Use `Isolate.run` for anything long enough to
7575 jank a frame.
7676
77+For bulk data, let Dart own the buffer and have V fill it in place — then
78+nothing crosses the boundary that needs freeing, and independent slices can be
79+computed concurrently:
80+
81+```dart
82+final view = v.FractalView(width: 800, height: 600, maxIter: 500);
83+final pixels = await v.renderParallel(view, tiles: 4); // RGBA8888
84+```
85+
86+## Is V faster than Dart?
87+
88+For the numeric kernel in the example: **no, not meaningfully.** Measured at
89+800x600 / 500 iterations on an 8-core Linux box, V through C takes ~152 ms
90+against Dart AOT's ~165 ms — inside the noise of a ~10% margin. Dart's AOT
91+compiler is good at scalar floating-point loops.
92+
93+What the bridge does buy you is the ability to *write the logic in V* — or
94+reuse V you already have — with a C ABI that is cheap to call and safe to call
95+concurrently. Pick it for the language, not for an expected speedup. And build
96+with optimisation on: at `-O0` the same kernel is roughly 2x slower than Dart,
97+which is what `tool/build.sh` and `src/CMakeLists.txt` now guard against.
98+
7799 ## Adding a function
78100
79101 1. Export it in `src/vflutter.v` with `@[export: 'vf_yourthing']`, freeing temporaries.
@@ -87,10 +109,11 @@ generate the raw bindings than hand-write them.
87109
88110 ## Status
89111
90-Verified on Linux with V 0.5.2 + Dart 3: build, string round-trip, isolate
91-dispatch, and 900k-call memory stability. The Android/iOS/Windows glue is
92-written to the standard `plugin_ffi` contract but is not exercised here —
93-it needs a Flutter SDK and the respective toolchains.
112+Verified on Linux with V 0.5.2, Dart 3 and Flutter 3.47: host build, string
113+round-trip, isolate dispatch, 900k-call memory stability, and the example app
114+built and run as a release Linux binary (CMake -> `v` -> NDK/clang path
115+included). The Android/iOS/Windows glue is written to the standard `plugin_ffi`
116+contract but is not exercised here — it needs the respective toolchains.
94117
95118 ## Layout
96119
@@ -103,4 +126,5 @@ ios/, macos/ pre-generated C + podspec (static archive)
103126 android/build.gradle NDK build via externalNativeBuild
104127 tool/build.sh host build + export smoke test
105128 tool/gen_ios_sources.sh regenerate ios/ and macos/ C after editing the V source
129+example/ Flutter app exercising the bridge (see example/README.md)
106130 ```
@@ -74,6 +74,28 @@ await v.greetAsync('isolate'); // same, off the UI isolate
74 calls are safe from any isolate. Use `Isolate.run` for anything long enough to74 calls are safe from any isolate. Use `Isolate.run` for anything long enough to
75 jank a frame.75 jank a frame.
76 76
77+For bulk data, let Dart own the buffer and have V fill it in place — then
78+nothing crosses the boundary that needs freeing, and independent slices can be
79+computed concurrently:
80+
81+```dart
82+final view = v.FractalView(width: 800, height: 600, maxIter: 500);
83+final pixels = await v.renderParallel(view, tiles: 4); // RGBA8888
84+```
85+
86+## Is V faster than Dart?
87+
88+For the numeric kernel in the example: **no, not meaningfully.** Measured at
89+800x600 / 500 iterations on an 8-core Linux box, V through C takes ~152 ms
90+against Dart AOT's ~165 ms — inside the noise of a ~10% margin. Dart's AOT
91+compiler is good at scalar floating-point loops.
92+
93+What the bridge does buy you is the ability to *write the logic in V* — or
94+reuse V you already have — with a C ABI that is cheap to call and safe to call
95+concurrently. Pick it for the language, not for an expected speedup. And build
96+with optimisation on: at `-O0` the same kernel is roughly 2x slower than Dart,
97+which is what `tool/build.sh` and `src/CMakeLists.txt` now guard against.
98+
77 ## Adding a function99 ## Adding a function
78 100
79 1. Export it in `src/vflutter.v` with `@[export: 'vf_yourthing']`, freeing temporaries.101 1. Export it in `src/vflutter.v` with `@[export: 'vf_yourthing']`, freeing temporaries.
@@ -87,10 +109,11 @@ generate the raw bindings than hand-write them.
87 109
88 ## Status110 ## Status
89 111
90-Verified on Linux with V 0.5.2 + Dart 3: build, string round-trip, isolate112+Verified on Linux with V 0.5.2, Dart 3 and Flutter 3.47: host build, string
91-dispatch, and 900k-call memory stability. The Android/iOS/Windows glue is113+round-trip, isolate dispatch, 900k-call memory stability, and the example app
92-written to the standard `plugin_ffi` contract but is not exercised here —114+built and run as a release Linux binary (CMake -> `v` -> NDK/clang path
93-it needs a Flutter SDK and the respective toolchains.115+included). The Android/iOS/Windows glue is written to the standard `plugin_ffi`
116+contract but is not exercised here — it needs the respective toolchains.
94 117
95 ## Layout118 ## Layout
96 119
@@ -103,4 +126,5 @@ ios/, macos/ pre-generated C + podspec (static archive)
103 android/build.gradle NDK build via externalNativeBuild126 android/build.gradle NDK build via externalNativeBuild
104 tool/build.sh host build + export smoke test127 tool/build.sh host build + export smoke test
105 tool/gen_ios_sources.sh regenerate ios/ and macos/ C after editing the V source128 tool/gen_ios_sources.sh regenerate ios/ and macos/ C after editing the V source
129+example/ Flutter app exercising the bridge (see example/README.md)
106 ```130 ```
added example/.gitignore +48 -0
new file mode 100644
@@ -0,0 +1,48 @@
1+# Miscellaneous
2+*.class
3+*.log
4+*.pyc
5+*.swp
6+.DS_Store
7+.atom/
8+.build/
9+.buildlog/
10+.history
11+.svn/
12+.swiftpm/
13+migrate_working_dir/
14+
15+# IntelliJ related
16+*.iml
17+*.ipr
18+*.iws
19+.idea/
20+
21+# The .vscode folder contains launch configuration and tasks you configure in
22+# VS Code which you may wish to be included in version control, so this line
23+# is commented out by default.
24+#.vscode/
25+
26+# Flutter/Dart/Pub related
27+**/doc/api/
28+**/ios/Flutter/.last_build_id
29+.dart_tool/
30+.flutter-plugins-dependencies
31+.pub-cache/
32+.pub/
33+/build/
34+/coverage/
35+
36+# Symbolication related
37+app.*.symbols
38+
39+# Obfuscation related
40+app.*.map.json
41+
42+# Android Studio will place build artifacts here
43+/android/app/debug
44+/android/app/profile
45+/android/app/release
46+
47+# Widget Preview related
48+.widget_preview/
new file mode 100644
@@ -0,0 +1,48 @@
1+# Miscellaneous
2+*.class
3+*.log
4+*.pyc
5+*.swp
6+.DS_Store
7+.atom/
8+.build/
9+.buildlog/
10+.history
11+.svn/
12+.swiftpm/
13+migrate_working_dir/
14+
15+# IntelliJ related
16+*.iml
17+*.ipr
18+*.iws
19+.idea/
20+
21+# The .vscode folder contains launch configuration and tasks you configure in
22+# VS Code which you may wish to be included in version control, so this line
23+# is commented out by default.
24+#.vscode/
25+
26+# Flutter/Dart/Pub related
27+**/doc/api/
28+**/ios/Flutter/.last_build_id
29+.dart_tool/
30+.flutter-plugins-dependencies
31+.pub-cache/
32+.pub/
33+/build/
34+/coverage/
35+
36+# Symbolication related
37+app.*.symbols
38+
39+# Obfuscation related
40+app.*.map.json
41+
42+# Android Studio will place build artifacts here
43+/android/app/debug
44+/android/app/profile
45+/android/app/release
46+
47+# Widget Preview related
48+.widget_preview/
added example/.metadata +30 -0
new file mode 100644
@@ -0,0 +1,30 @@
1+# This file tracks properties of this Flutter project.
2+# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+#
4+# This file should be version controlled and should not be manually edited.
5+
6+version:
7+ revision: "6a19cca56475dbfba1478ee68d7bd0c2ef891da1"
8+ channel: "stable"
9+
10+project_type: app
11+
12+# Tracks metadata for the flutter migrate command
13+migration:
14+ platforms:
15+ - platform: root
16+ create_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1
17+ base_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1
18+ - platform: linux
19+ create_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1
20+ base_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1
21+
22+ # User provided section
23+
24+ # List of Local paths (relative to this file) that should be
25+ # ignored by the migrate tool.
26+ #
27+ # Files that are not part of the templates will be ignored by default.
28+ unmanaged_files:
29+ - 'lib/main.dart'
30+ - 'ios/Runner.xcodeproj/project.pbxproj'
new file mode 100644
@@ -0,0 +1,30 @@
1+# This file tracks properties of this Flutter project.
2+# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+#
4+# This file should be version controlled and should not be manually edited.
5+
6+version:
7+ revision: "6a19cca56475dbfba1478ee68d7bd0c2ef891da1"
8+ channel: "stable"
9+
10+project_type: app
11+
12+# Tracks metadata for the flutter migrate command
13+migration:
14+ platforms:
15+ - platform: root
16+ create_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1
17+ base_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1
18+ - platform: linux
19+ create_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1
20+ base_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1
21+
22+ # User provided section
23+
24+ # List of Local paths (relative to this file) that should be
25+ # ignored by the migrate tool.
26+ #
27+ # Files that are not part of the templates will be ignored by default.
28+ unmanaged_files:
29+ - 'lib/main.dart'
30+ - 'ios/Runner.xcodeproj/project.pbxproj'
added example/README.md +90 -0
new file mode 100644
@@ -0,0 +1,90 @@
1+# vflutter_ffi example
2+
3+A Mandelbrot explorer whose pixels are computed in V. Scroll to zoom smoothly,
4+tap to zoom in, right-click to zoom out — all anchored at the cursor. Sliders
5+control the iteration cap and how many isolates the frame is split across;
6+"Reset view" restores the framing without disturbing either.
7+
8+It exists to exercise the parts of the bridge the string demo cannot:
9+
10+* **Bulk data across the boundary.** Each frame is a full RGBA buffer, not a
11+ string. Dart allocates it and `vf_mandelbrot` fills it in place, so no V
12+ memory crosses the boundary and there is nothing to `vf_free`.
13+* **Band parallelism.** The image splits into horizontal strips rendered on
14+ separate isolates. Bands are independent by construction, and `-gc none`
15+ means no stop-the-world phase to serialise them.
16+* **An honest benchmark.** The same algorithm is written twice — in V
17+ (`src/vflutter.v`) and in Dart (`lib/mandelbrot_dart.dart`) — and the
18+ Benchmark button times both. The tests assert the two agree pixel-for-pixel,
19+ which is what makes the comparison meaningful.
20+
21+## What the numbers actually say
22+
23+Measured here (800x600, maxIter 500, release build, 8-core Linux):
24+
25+| | time |
26+|---|---|
27+| V, one isolate | ~152 ms |
28+| V, 4 isolates | ~65 ms |
29+| Dart AOT, one isolate | ~165 ms |
30+
31+**V is not meaningfully faster than Dart at this.** For a scalar
32+floating-point loop, V-through-C and Dart AOT land within ~10% of each other.
33+The 2.5x comes from the parallel split, which Dart could do on its own without
34+any FFI. Treat this app as a demonstration of the *bridge* — bulk buffers,
35+caller-owned memory, safe multi-isolate calls — not as a speed claim for V.
36+
37+Reach for V here because you want to write the logic in V, or already have it
38+in V, not because C-via-V is expected to outrun Dart AOT on arithmetic.
39+
40+## Run it
41+
42+```bash
43+cd example
44+flutter run -d linux
45+```
46+
47+Only the Linux runner is generated. For the other platforms, generate their
48+runner directories once first:
49+
50+```bash
51+flutter create --platforms=android,ios,macos,windows .
52+```
53+
54+`flutter create` leaves `lib/`, `test/` and `pubspec.yaml` alone. The native
55+library is built by the plugin itself: CMake invokes `v` on Linux, Windows and
56+Android; iOS and macOS compile the pre-generated C in `ios/Classes/`.
57+
58+## Tests
59+
60+`flutter test` runs on the host VM rather than in the app bundle, so it needs
61+the native library on the loader path:
62+
63+```bash
64+./tool/build.sh
65+cd example && LD_LIBRARY_PATH=../build flutter test
66+```
67+
68+The suite covers the zoom maths as a property (the point under the cursor stays
69+put), the buffer contract, the band split matching a single-shot render, and
70+the V and Dart kernels agreeing exactly.
71+
72+## Headless scripts
73+
74+No Flutter SDK needed — only `dart` and the host library. Run from the
75+repository root, which resolves without Flutter:
76+
77+```bash
78+./tool/build.sh
79+LD_LIBRARY_PATH=build dart example/lib/fractal_bench.dart # V vs Dart timings
80+LD_LIBRARY_PATH=build dart example/lib/main_test.dart # string round-trips
81+LD_LIBRARY_PATH=build dart example/lib/memory_check.dart # RSS regression guard
82+```
83+
84+For a like-for-like comparison with a release app, compile the benchmark AOT
85+first — `dart run` uses the JIT:
86+
87+```bash
88+dart compile exe example/lib/fractal_bench.dart -o /tmp/bench
89+LD_LIBRARY_PATH=build /tmp/bench
90+```
new file mode 100644
@@ -0,0 +1,90 @@
1+# vflutter_ffi example
2+
3+A Mandelbrot explorer whose pixels are computed in V. Scroll to zoom smoothly,
4+tap to zoom in, right-click to zoom out — all anchored at the cursor. Sliders
5+control the iteration cap and how many isolates the frame is split across;
6+"Reset view" restores the framing without disturbing either.
7+
8+It exists to exercise the parts of the bridge the string demo cannot:
9+
10+* **Bulk data across the boundary.** Each frame is a full RGBA buffer, not a
11+ string. Dart allocates it and `vf_mandelbrot` fills it in place, so no V
12+ memory crosses the boundary and there is nothing to `vf_free`.
13+* **Band parallelism.** The image splits into horizontal strips rendered on
14+ separate isolates. Bands are independent by construction, and `-gc none`
15+ means no stop-the-world phase to serialise them.
16+* **An honest benchmark.** The same algorithm is written twice — in V
17+ (`src/vflutter.v`) and in Dart (`lib/mandelbrot_dart.dart`) — and the
18+ Benchmark button times both. The tests assert the two agree pixel-for-pixel,
19+ which is what makes the comparison meaningful.
20+
21+## What the numbers actually say
22+
23+Measured here (800x600, maxIter 500, release build, 8-core Linux):
24+
25+| | time |
26+|---|---|
27+| V, one isolate | ~152 ms |
28+| V, 4 isolates | ~65 ms |
29+| Dart AOT, one isolate | ~165 ms |
30+
31+**V is not meaningfully faster than Dart at this.** For a scalar
32+floating-point loop, V-through-C and Dart AOT land within ~10% of each other.
33+The 2.5x comes from the parallel split, which Dart could do on its own without
34+any FFI. Treat this app as a demonstration of the *bridge* — bulk buffers,
35+caller-owned memory, safe multi-isolate calls — not as a speed claim for V.
36+
37+Reach for V here because you want to write the logic in V, or already have it
38+in V, not because C-via-V is expected to outrun Dart AOT on arithmetic.
39+
40+## Run it
41+
42+```bash
43+cd example
44+flutter run -d linux
45+```
46+
47+Only the Linux runner is generated. For the other platforms, generate their
48+runner directories once first:
49+
50+```bash
51+flutter create --platforms=android,ios,macos,windows .
52+```
53+
54+`flutter create` leaves `lib/`, `test/` and `pubspec.yaml` alone. The native
55+library is built by the plugin itself: CMake invokes `v` on Linux, Windows and
56+Android; iOS and macOS compile the pre-generated C in `ios/Classes/`.
57+
58+## Tests
59+
60+`flutter test` runs on the host VM rather than in the app bundle, so it needs
61+the native library on the loader path:
62+
63+```bash
64+./tool/build.sh
65+cd example && LD_LIBRARY_PATH=../build flutter test
66+```
67+
68+The suite covers the zoom maths as a property (the point under the cursor stays
69+put), the buffer contract, the band split matching a single-shot render, and
70+the V and Dart kernels agreeing exactly.
71+
72+## Headless scripts
73+
74+No Flutter SDK needed — only `dart` and the host library. Run from the
75+repository root, which resolves without Flutter:
76+
77+```bash
78+./tool/build.sh
79+LD_LIBRARY_PATH=build dart example/lib/fractal_bench.dart # V vs Dart timings
80+LD_LIBRARY_PATH=build dart example/lib/main_test.dart # string round-trips
81+LD_LIBRARY_PATH=build dart example/lib/memory_check.dart # RSS regression guard
82+```
83+
84+For a like-for-like comparison with a release app, compile the benchmark AOT
85+first — `dart run` uses the JIT:
86+
87+```bash
88+dart compile exe example/lib/fractal_bench.dart -o /tmp/bench
89+LD_LIBRARY_PATH=build /tmp/bench
90+```
added example/analysis_options.yaml +38 -0
new file mode 100644
@@ -0,0 +1,38 @@
1+# This file configures the analyzer, which statically analyzes Dart code to
2+# check for errors, warnings, and lints.
3+#
4+# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+# invoked from the command line by running `flutter analyze`.
7+
8+# The following line activates a set of recommended lints for Flutter apps,
9+# packages, and plugins designed to encourage good coding practices.
10+include: package:flutter_lints/flutter.yaml
11+
12+analyzer:
13+ exclude:
14+ - build/**
15+ - linux/**
16+ errors:
17+ # The headless scripts in lib/ are command-line tools whose entire output
18+ # is stdout, and memory_check.dart talks to dart:ffi directly on purpose.
19+ avoid_print: ignore
20+ depend_on_referenced_packages: ignore
21+
22+linter:
23+ # The lint rules applied to this project can be customized in the
24+ # section below to disable rules from the `package:flutter_lints/flutter.yaml`
25+ # included above or to enable additional rules. A list of all available lints
26+ # and their documentation is published at https://dart.dev/lints.
27+ #
28+ # Instead of disabling a lint rule for the entire project in the
29+ # section below, it can also be suppressed for a single line of code
30+ # or a specific dart file by using the `// ignore: name_of_lint` and
31+ # `// ignore_for_file: name_of_lint` syntax on the line or in the file
32+ # producing the lint.
33+ rules:
34+ # avoid_print: false # Uncomment to disable the `avoid_print` rule
35+ # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
36+
37+# Additional information about this file can be found at
38+# https://dart.dev/guides/language/analysis-options
new file mode 100644
@@ -0,0 +1,38 @@
1+# This file configures the analyzer, which statically analyzes Dart code to
2+# check for errors, warnings, and lints.
3+#
4+# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+# invoked from the command line by running `flutter analyze`.
7+
8+# The following line activates a set of recommended lints for Flutter apps,
9+# packages, and plugins designed to encourage good coding practices.
10+include: package:flutter_lints/flutter.yaml
11+
12+analyzer:
13+ exclude:
14+ - build/**
15+ - linux/**
16+ errors:
17+ # The headless scripts in lib/ are command-line tools whose entire output
18+ # is stdout, and memory_check.dart talks to dart:ffi directly on purpose.
19+ avoid_print: ignore
20+ depend_on_referenced_packages: ignore
21+
22+linter:
23+ # The lint rules applied to this project can be customized in the
24+ # section below to disable rules from the `package:flutter_lints/flutter.yaml`
25+ # included above or to enable additional rules. A list of all available lints
26+ # and their documentation is published at https://dart.dev/lints.
27+ #
28+ # Instead of disabling a lint rule for the entire project in the
29+ # section below, it can also be suppressed for a single line of code
30+ # or a specific dart file by using the `// ignore: name_of_lint` and
31+ # `// ignore_for_file: name_of_lint` syntax on the line or in the file
32+ # producing the lint.
33+ rules:
34+ # avoid_print: false # Uncomment to disable the `avoid_print` rule
35+ # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
36+
37+# Additional information about this file can be found at
38+# https://dart.dev/guides/language/analysis-options
added example/lib/fractal_bench.dart +54 -0
new file mode 100644
@@ -0,0 +1,54 @@
1+// Headless benchmark: the same Mandelbrot frame rendered by V and by Dart.
2+//
3+// LD_LIBRARY_PATH=build dart example/lib/fractal_bench.dart
4+//
5+// Also checks the two implementations agree pixel-for-pixel, which is what
6+// makes the timing comparison meaningful.
7+import 'package:vflutter_ffi/vflutter_ffi.dart' as v;
8+
9+import 'mandelbrot_dart.dart';
10+
11+Future<void> main() async {
12+ const view = v.FractalView(width: 800, height: 600, maxIter: 500);
13+ final pixels = view.width * view.height;
14+
15+ // Warm both paths: first call pays for library load / JIT.
16+ v.render(const v.FractalView(width: 64, height: 64, maxIter: 50));
17+ renderDart(const v.FractalView(width: 64, height: 64, maxIter: 50));
18+
19+ final swV = Stopwatch()..start();
20+ final fromV = v.render(view);
21+ swV.stop();
22+
23+ final swP = Stopwatch()..start();
24+ final fromParallel = await v.renderParallel(view, tiles: 4);
25+ swP.stop();
26+
27+ final swD = Stopwatch()..start();
28+ final fromDart = renderDart(view);
29+ swD.stop();
30+
31+ print('${view.width}x${view.height}, maxIter ${view.maxIter} '
32+ '($pixels px)\n');
33+ print('V, one isolate ${swV.elapsedMilliseconds} ms');
34+ print('V, 4 isolates ${swP.elapsedMilliseconds} ms');
35+ print('Dart, one isolate ${swD.elapsedMilliseconds} ms');
36+ print('speedup vs Dart '
37+ '${(swD.elapsedMicroseconds / swV.elapsedMicroseconds).toStringAsFixed(2)}x '
38+ 'serial, '
39+ '${(swD.elapsedMicroseconds / swP.elapsedMicroseconds).toStringAsFixed(2)}x '
40+ 'parallel');
41+
42+ print('\nagreement checks');
43+ print(' V serial vs V parallel : ${_diff(fromV, fromParallel)} bytes differ');
44+ print(' V serial vs Dart : ${_diff(fromV, fromDart)} bytes differ');
45+}
46+
47+int _diff(List<int> a, List<int> b) {
48+ if (a.length != b.length) return -1;
49+ var n = 0;
50+ for (var i = 0; i < a.length; i++) {
51+ if (a[i] != b[i]) n++;
52+ }
53+ return n;
54+}
new file mode 100644
@@ -0,0 +1,54 @@
1+// Headless benchmark: the same Mandelbrot frame rendered by V and by Dart.
2+//
3+// LD_LIBRARY_PATH=build dart example/lib/fractal_bench.dart
4+//
5+// Also checks the two implementations agree pixel-for-pixel, which is what
6+// makes the timing comparison meaningful.
7+import 'package:vflutter_ffi/vflutter_ffi.dart' as v;
8+
9+import 'mandelbrot_dart.dart';
10+
11+Future<void> main() async {
12+ const view = v.FractalView(width: 800, height: 600, maxIter: 500);
13+ final pixels = view.width * view.height;
14+
15+ // Warm both paths: first call pays for library load / JIT.
16+ v.render(const v.FractalView(width: 64, height: 64, maxIter: 50));
17+ renderDart(const v.FractalView(width: 64, height: 64, maxIter: 50));
18+
19+ final swV = Stopwatch()..start();
20+ final fromV = v.render(view);
21+ swV.stop();
22+
23+ final swP = Stopwatch()..start();
24+ final fromParallel = await v.renderParallel(view, tiles: 4);
25+ swP.stop();
26+
27+ final swD = Stopwatch()..start();
28+ final fromDart = renderDart(view);
29+ swD.stop();
30+
31+ print('${view.width}x${view.height}, maxIter ${view.maxIter} '
32+ '($pixels px)\n');
33+ print('V, one isolate ${swV.elapsedMilliseconds} ms');
34+ print('V, 4 isolates ${swP.elapsedMilliseconds} ms');
35+ print('Dart, one isolate ${swD.elapsedMilliseconds} ms');
36+ print('speedup vs Dart '
37+ '${(swD.elapsedMicroseconds / swV.elapsedMicroseconds).toStringAsFixed(2)}x '
38+ 'serial, '
39+ '${(swD.elapsedMicroseconds / swP.elapsedMicroseconds).toStringAsFixed(2)}x '
40+ 'parallel');
41+
42+ print('\nagreement checks');
43+ print(' V serial vs V parallel : ${_diff(fromV, fromParallel)} bytes differ');
44+ print(' V serial vs Dart : ${_diff(fromV, fromDart)} bytes differ');
45+}
46+
47+int _diff(List<int> a, List<int> b) {
48+ if (a.length != b.length) return -1;
49+ var n = 0;
50+ for (var i = 0; i < a.length; i++) {
51+ if (a[i] != b[i]) n++;
52+ }
53+ return n;
54+}
added example/lib/main.dart +490 -0
new file mode 100644
@@ -0,0 +1,490 @@
1+// A Mandelbrot explorer whose pixels are computed in V.
2+//
3+// What this is actually demonstrating:
4+// * bulk data across the FFI boundary — a full RGBA frame per render,
5+// into a buffer Dart allocates and V fills in place (nothing to vf_free)
6+// * band parallelism — the image is split into horizontal strips rendered
7+// on separate isolates, which is safe because the library is -gc none
8+// * the same algorithm written twice, in V and in Dart, so the cost of the
9+// bridge is a number on screen rather than a claim
10+import 'dart:async';
11+import 'dart:math' as math;
12+import 'dart:typed_data';
13+import 'dart:ui' as ui;
14+
15+import 'package:flutter/gestures.dart';
16+import 'package:flutter/material.dart';
17+import 'package:vflutter_ffi/vflutter_ffi.dart' as v;
18+
19+import 'mandelbrot_dart.dart';
20+
21+void main() => runApp(const ExampleApp());
22+
23+class ExampleApp extends StatelessWidget {
24+ const ExampleApp({super.key});
25+
26+ @override
27+ Widget build(BuildContext context) => MaterialApp(
28+ title: 'vflutter_ffi',
29+ debugShowCheckedModeBanner: false,
30+ theme: ThemeData.dark(useMaterial3: true).copyWith(
31+ scaffoldBackgroundColor: const Color(0xFF12141A),
32+ ),
33+ home: const ExplorerPage(),
34+ );
35+}
36+
37+class ExplorerPage extends StatefulWidget {
38+ const ExplorerPage({super.key});
39+
40+ @override
41+ State<ExplorerPage> createState() => _ExplorerPageState();
42+}
43+
44+class _ExplorerPageState extends State<ExplorerPage> {
45+ static const int _renderWidth = 720;
46+ static const int _renderHeight = 540;
47+
48+ v.FractalView _view = const v.FractalView(
49+ width: _renderWidth,
50+ height: _renderHeight,
51+ maxIter: 400,
52+ );
53+
54+ ui.Image? _image;
55+ bool _rendering = false;
56+ bool _renderQueued = false;
57+ int _lastMs = 0;
58+ int _tiles = 4;
59+ _Benchmark? _benchmark;
60+
61+ @override
62+ void initState() {
63+ super.initState();
64+ v.ensureInitialized();
65+ _render();
66+ }
67+
68+ @override
69+ void dispose() {
70+ _image?.dispose();
71+ super.dispose();
72+ }
73+
74+ /// Renders the current view, coalescing requests that arrive mid-frame.
75+ ///
76+ /// A wheel gesture emits far more events than we can render. Dropping them
77+ /// outright would leave the view mutated but never drawn, so instead the
78+ /// latest request is remembered and serviced once the in-flight frame lands.
79+ Future<void> _render() async {
80+ if (_rendering) {
81+ _renderQueued = true;
82+ return;
83+ }
84+ setState(() => _rendering = true);
85+
86+ do {
87+ _renderQueued = false;
88+ final view = _view;
89+
90+ final watch = Stopwatch()..start();
91+ final pixels = _tiles > 1
92+ ? await v.renderParallel(view, tiles: _tiles)
93+ : v.render(view);
94+ watch.stop();
95+
96+ final image = await _decode(pixels, view.width, view.height);
97+ if (!mounted) {
98+ image.dispose();
99+ return;
100+ }
101+ setState(() {
102+ _image?.dispose();
103+ _image = image;
104+ _lastMs = watch.elapsedMilliseconds;
105+ });
106+ } while (_renderQueued);
107+
108+ if (!mounted) return;
109+ setState(() => _rendering = false);
110+ }
111+
112+ static Future<ui.Image> _decode(Uint8List rgba, int w, int h) {
113+ final completer = Completer<ui.Image>();
114+ ui.decodeImageFromPixels(rgba, w, h, ui.PixelFormat.rgba8888,
115+ completer.complete);
116+ return completer.future;
117+ }
118+
119+ /// Zooms about a point, keeping that point under the cursor.
120+ void _zoomAt(Offset local, Size widgetSize, double factor) {
121+ if (widgetSize.isEmpty) return;
122+ setState(() {
123+ _view = _view.zoomedAt(
124+ local.dx / widgetSize.width,
125+ local.dy / widgetSize.height,
126+ factor,
127+ );
128+ });
129+ _render();
130+ }
131+
132+ /// Restores the starting framing.
133+ ///
134+ /// Only the pan/zoom is reset. Width and height belong to the canvas (see
135+ /// _fitToCanvas) and maxIter belongs to its slider — clobbering those made
136+ /// "Reset view" silently undo settings the button does not own, and briefly
137+ /// render at the wrong aspect ratio before the canvas corrected it.
138+ void _reset() {
139+ const home = v.FractalView(width: 1, height: 1);
140+ setState(() {
141+ _view = _view.copyWith(
142+ centerX: home.centerX,
143+ centerY: home.centerY,
144+ scale: home.scale,
145+ );
146+ });
147+ _render();
148+ }
149+
150+ /// Renders the identical frame in V and in Dart on this isolate, so the
151+ /// comparison is like-for-like rather than V-plus-parallelism vs Dart.
152+ Future<void> _runBenchmark() async {
153+ setState(() {
154+ _rendering = true;
155+ _benchmark = null;
156+ });
157+
158+ final swV = Stopwatch()..start();
159+ v.render(_view);
160+ swV.stop();
161+
162+ final swP = Stopwatch()..start();
163+ await v.renderParallel(_view, tiles: _tiles);
164+ swP.stop();
165+
166+ final swD = Stopwatch()..start();
167+ renderDart(_view);
168+ swD.stop();
169+
170+ if (!mounted) return;
171+ setState(() {
172+ _rendering = false;
173+ _benchmark = _Benchmark(
174+ vSerialMs: swV.elapsedMilliseconds,
175+ vParallelMs: swP.elapsedMilliseconds,
176+ dartMs: swD.elapsedMilliseconds,
177+ tiles: _tiles,
178+ );
179+ });
180+ }
181+
182+ @override
183+ Widget build(BuildContext context) {
184+ return Scaffold(
185+ body: SafeArea(
186+ child: LayoutBuilder(
187+ builder: (context, constraints) {
188+ final wide = constraints.maxWidth > 900;
189+ final canvas = _buildCanvas();
190+ final controls = _buildControls();
191+ return wide
192+ ? Row(
193+ crossAxisAlignment: CrossAxisAlignment.stretch,
194+ children: [
195+ Expanded(child: canvas),
196+ SizedBox(
197+ width: 340,
198+ child: SingleChildScrollView(child: controls),
199+ ),
200+ ],
201+ )
202+ : ListView(
203+ children: [
204+ AspectRatio(
205+ aspectRatio: _renderWidth / _renderHeight,
206+ child: canvas,
207+ ),
208+ controls,
209+ ],
210+ );
211+ },
212+ ),
213+ ),
214+ );
215+ }
216+
217+ /// Keeps the rendered buffer at the canvas's aspect ratio.
218+ ///
219+ /// Without this the image would be letterboxed or cropped, and the
220+ /// click-to-zoom maths — which maps widget coordinates straight into the
221+ /// complex plane — would point at the wrong place.
222+ void _fitToCanvas(Size size) {
223+ if (size.isEmpty) return;
224+ final height = (_renderWidth * size.height / size.width).round();
225+ if ((height - _view.height).abs() <= 2) return;
226+ WidgetsBinding.instance.addPostFrameCallback((_) {
227+ if (!mounted) return;
228+ setState(() => _view = _view.copyWith(height: height));
229+ _render();
230+ });
231+ }
232+
233+ Widget _buildCanvas() {
234+ return LayoutBuilder(
235+ builder: (context, constraints) {
236+ final size = Size(constraints.maxWidth, constraints.maxHeight);
237+ _fitToCanvas(size);
238+ return Listener(
239+ // Wheel zoom, anchored at the cursor like the tap zoom. One notch is
240+ // a small step so a scroll feels continuous rather than octave-wise;
241+ // the render loop coalesces whatever it cannot keep up with.
242+ onPointerSignal: (event) {
243+ if (event is! PointerScrollEvent) return;
244+ final dy = event.scrollDelta.dy;
245+ if (dy == 0) return;
246+ _zoomAt(event.localPosition, size, math.pow(1.0015, dy).toDouble());
247+ },
248+ child: GestureDetector(
249+ onTapDown: (d) => _zoomAt(d.localPosition, size, 0.5),
250+ onSecondaryTapDown: (d) => _zoomAt(d.localPosition, size, 2.0),
251+ child: Stack(
252+ fit: StackFit.expand,
253+ children: [
254+ if (_image != null)
255+ RawImage(image: _image, fit: BoxFit.fill)
256+ else
257+ const Center(child: CircularProgressIndicator()),
258+ Positioned(
259+ left: 12,
260+ bottom: 12,
261+ child: _Chip(
262+ 'zoom ${(3.0 / _view.scale).toStringAsFixed(1)}x · '
263+ '$_lastMs ms · '
264+ '${_tiles > 1 ? "$_tiles isolates" : "1 isolate"}',
265+ ),
266+ ),
267+ if (_rendering)
268+ const Positioned(
269+ right: 12,
270+ top: 12,
271+ child: SizedBox(
272+ width: 18,
273+ height: 18,
274+ child: CircularProgressIndicator(strokeWidth: 2),
275+ ),
276+ ),
277+ ],
278+ ),
279+ ),
280+ );
281+ },
282+ );
283+ }
284+
285+ /// Returns a non-scrolling column.
286+ ///
287+ /// The wide layout wraps this in its own scroll view; the narrow layout
288+ /// embeds it in the page's ListView. Making this a ListView itself would
289+ /// nest two scrollables and give the inner one unbounded height.
290+ Widget _buildControls() {
291+ final theme = Theme.of(context);
292+ return Padding(
293+ padding: const EdgeInsets.all(20),
294+ child: Column(
295+ crossAxisAlignment: CrossAxisAlignment.stretch,
296+ children: [
297+ Text('Mandelbrot in V', style: theme.textTheme.titleLarge),
298+ const SizedBox(height: 4),
299+ Text(
300+ 'Tap to zoom in, right-click to zoom out. '
301+ 'Every pixel is computed by vf_mandelbrot in src/vflutter.v.',
302+ style: theme.textTheme.bodySmall,
303+ ),
304+ const SizedBox(height: 20),
305+ _Labelled(
306+ label: 'iterations',
307+ value: '${_view.maxIter}',
308+ child: Slider(
309+ value: _view.maxIter.toDouble(),
310+ min: 50,
311+ max: 2000,
312+ divisions: 39,
313+ onChanged: (n) =>
314+ setState(() => _view = _view.copyWith(maxIter: n.round())),
315+ onChangeEnd: (_) => _render(),
316+ ),
317+ ),
318+ _Labelled(
319+ label: 'isolates',
320+ value: '$_tiles',
321+ child: Slider(
322+ value: _tiles.toDouble(),
323+ min: 1,
324+ max: 8,
325+ divisions: 7,
326+ onChanged: (n) => setState(() => _tiles = n.round()),
327+ onChangeEnd: (_) => _render(),
328+ ),
329+ ),
330+ const SizedBox(height: 8),
331+ Row(
332+ children: [
333+ Expanded(
334+ child: FilledButton.tonal(
335+ onPressed: _rendering ? null : _reset,
336+ child: const Text('Reset view'),
337+ ),
338+ ),
339+ const SizedBox(width: 12),
340+ Expanded(
341+ child: FilledButton(
342+ onPressed: _rendering ? null : _runBenchmark,
343+ child: const Text('Benchmark'),
344+ ),
345+ ),
346+ ],
347+ ),
348+ const SizedBox(height: 20),
349+ if (_benchmark != null) _BenchmarkCard(result: _benchmark!),
350+ const SizedBox(height: 12),
351+ Card(
352+ color: theme.colorScheme.surfaceContainerHighest,
353+ child: Padding(
354+ padding: const EdgeInsets.all(14),
355+ child: Text(
356+ 'The V kernel fills a buffer Dart allocates, so no V memory '
357+ 'crosses the boundary and there is nothing to free. Bands are '
358+ 'independent, which is what makes the isolate slider safe: '
359+ '-gc none means no stop-the-world phase to serialise them.',
360+ style: theme.textTheme.bodySmall,
361+ ),
362+ ),
363+ ),
364+ ],
365+ ),
366+ );
367+ }
368+}
369+
370+class _Benchmark {
371+ const _Benchmark({
372+ required this.vSerialMs,
373+ required this.vParallelMs,
374+ required this.dartMs,
375+ required this.tiles,
376+ });
377+
378+ final int vSerialMs;
379+ final int vParallelMs;
380+ final int dartMs;
381+ final int tiles;
382+}
383+
384+class _BenchmarkCard extends StatelessWidget {
385+ const _BenchmarkCard({required this.result});
386+
387+ final _Benchmark result;
388+
389+ @override
390+ Widget build(BuildContext context) {
391+ final theme = Theme.of(context);
392+ final ratio = result.dartMs / result.vSerialMs;
393+ return Card(
394+ child: Padding(
395+ padding: const EdgeInsets.all(14),
396+ child: Column(
397+ crossAxisAlignment: CrossAxisAlignment.start,
398+ children: [
399+ Text('same frame, three ways',
400+ style: theme.textTheme.titleSmall),
401+ const SizedBox(height: 10),
402+ _Row(label: 'V, 1 isolate', value: '${result.vSerialMs} ms'),
403+ _Row(
404+ label: 'V, ${result.tiles} isolates',
405+ value: '${result.vParallelMs} ms'),
406+ _Row(label: 'Dart, 1 isolate', value: '${result.dartMs} ms'),
407+ const Divider(height: 20),
408+ Text(
409+ 'V is ${ratio.toStringAsFixed(2)}x Dart on one isolate. For a '
410+ 'scalar FP loop the two are close — the real win here is the '
411+ 'parallel split, which Dart could also do. The bridge is what '
412+ 'this demonstrates, not a speed claim.',
413+ style: theme.textTheme.bodySmall,
414+ ),
415+ ],
416+ ),
417+ ),
418+ );
419+ }
420+}
421+
422+class _Row extends StatelessWidget {
423+ const _Row({required this.label, required this.value});
424+
425+ final String label;
426+ final String value;
427+
428+ @override
429+ Widget build(BuildContext context) => Padding(
430+ padding: const EdgeInsets.symmetric(vertical: 2),
431+ child: Row(
432+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
433+ children: [
434+ Text(label, style: Theme.of(context).textTheme.bodyMedium),
435+ Text(value,
436+ style: Theme.of(context)
437+ .textTheme
438+ .bodyMedium
439+ ?.copyWith(fontFeatures: const [ui.FontFeature.tabularFigures()])),
440+ ],
441+ ),
442+ );
443+}
444+
445+class _Labelled extends StatelessWidget {
446+ const _Labelled({
447+ required this.label,
448+ required this.value,
449+ required this.child,
450+ });
451+
452+ final String label;
453+ final String value;
454+ final Widget child;
455+
456+ @override
457+ Widget build(BuildContext context) {
458+ final theme = Theme.of(context);
459+ return Column(
460+ crossAxisAlignment: CrossAxisAlignment.start,
461+ children: [
462+ Row(
463+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
464+ children: [
465+ Text(label, style: theme.textTheme.labelLarge),
466+ Text(value, style: theme.textTheme.labelLarge),
467+ ],
468+ ),
469+ child,
470+ ],
471+ );
472+ }
473+}
474+
475+class _Chip extends StatelessWidget {
476+ const _Chip(this.text);
477+
478+ final String text;
479+
480+ @override
481+ Widget build(BuildContext context) => Container(
482+ padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
483+ decoration: BoxDecoration(
484+ color: Colors.black.withValues(alpha: 0.55),
485+ borderRadius: BorderRadius.circular(8),
486+ ),
487+ child: Text(text,
488+ style: const TextStyle(color: Colors.white, fontSize: 12)),
489+ );
490+}
new file mode 100644
@@ -0,0 +1,490 @@
1+// A Mandelbrot explorer whose pixels are computed in V.
2+//
3+// What this is actually demonstrating:
4+// * bulk data across the FFI boundary — a full RGBA frame per render,
5+// into a buffer Dart allocates and V fills in place (nothing to vf_free)
6+// * band parallelism — the image is split into horizontal strips rendered
7+// on separate isolates, which is safe because the library is -gc none
8+// * the same algorithm written twice, in V and in Dart, so the cost of the
9+// bridge is a number on screen rather than a claim
10+import 'dart:async';
11+import 'dart:math' as math;
12+import 'dart:typed_data';
13+import 'dart:ui' as ui;
14+
15+import 'package:flutter/gestures.dart';
16+import 'package:flutter/material.dart';
17+import 'package:vflutter_ffi/vflutter_ffi.dart' as v;
18+
19+import 'mandelbrot_dart.dart';
20+
21+void main() => runApp(const ExampleApp());
22+
23+class ExampleApp extends StatelessWidget {
24+ const ExampleApp({super.key});
25+
26+ @override
27+ Widget build(BuildContext context) => MaterialApp(
28+ title: 'vflutter_ffi',
29+ debugShowCheckedModeBanner: false,
30+ theme: ThemeData.dark(useMaterial3: true).copyWith(
31+ scaffoldBackgroundColor: const Color(0xFF12141A),
32+ ),
33+ home: const ExplorerPage(),
34+ );
35+}
36+
37+class ExplorerPage extends StatefulWidget {
38+ const ExplorerPage({super.key});
39+
40+ @override
41+ State<ExplorerPage> createState() => _ExplorerPageState();
42+}
43+
44+class _ExplorerPageState extends State<ExplorerPage> {
45+ static const int _renderWidth = 720;
46+ static const int _renderHeight = 540;
47+
48+ v.FractalView _view = const v.FractalView(
49+ width: _renderWidth,
50+ height: _renderHeight,
51+ maxIter: 400,
52+ );
53+
54+ ui.Image? _image;
55+ bool _rendering = false;
56+ bool _renderQueued = false;
57+ int _lastMs = 0;
58+ int _tiles = 4;
59+ _Benchmark? _benchmark;
60+
61+ @override
62+ void initState() {
63+ super.initState();
64+ v.ensureInitialized();
65+ _render();
66+ }
67+
68+ @override
69+ void dispose() {
70+ _image?.dispose();
71+ super.dispose();
72+ }
73+
74+ /// Renders the current view, coalescing requests that arrive mid-frame.
75+ ///
76+ /// A wheel gesture emits far more events than we can render. Dropping them
77+ /// outright would leave the view mutated but never drawn, so instead the
78+ /// latest request is remembered and serviced once the in-flight frame lands.
79+ Future<void> _render() async {
80+ if (_rendering) {
81+ _renderQueued = true;
82+ return;
83+ }
84+ setState(() => _rendering = true);
85+
86+ do {
87+ _renderQueued = false;
88+ final view = _view;
89+
90+ final watch = Stopwatch()..start();
91+ final pixels = _tiles > 1
92+ ? await v.renderParallel(view, tiles: _tiles)
93+ : v.render(view);
94+ watch.stop();
95+
96+ final image = await _decode(pixels, view.width, view.height);
97+ if (!mounted) {
98+ image.dispose();
99+ return;
100+ }
101+ setState(() {
102+ _image?.dispose();
103+ _image = image;
104+ _lastMs = watch.elapsedMilliseconds;
105+ });
106+ } while (_renderQueued);
107+
108+ if (!mounted) return;
109+ setState(() => _rendering = false);
110+ }
111+
112+ static Future<ui.Image> _decode(Uint8List rgba, int w, int h) {
113+ final completer = Completer<ui.Image>();
114+ ui.decodeImageFromPixels(rgba, w, h, ui.PixelFormat.rgba8888,
115+ completer.complete);
116+ return completer.future;
117+ }
118+
119+ /// Zooms about a point, keeping that point under the cursor.
120+ void _zoomAt(Offset local, Size widgetSize, double factor) {
121+ if (widgetSize.isEmpty) return;
122+ setState(() {
123+ _view = _view.zoomedAt(
124+ local.dx / widgetSize.width,
125+ local.dy / widgetSize.height,
126+ factor,
127+ );
128+ });
129+ _render();
130+ }
131+
132+ /// Restores the starting framing.
133+ ///
134+ /// Only the pan/zoom is reset. Width and height belong to the canvas (see
135+ /// _fitToCanvas) and maxIter belongs to its slider — clobbering those made
136+ /// "Reset view" silently undo settings the button does not own, and briefly
137+ /// render at the wrong aspect ratio before the canvas corrected it.
138+ void _reset() {
139+ const home = v.FractalView(width: 1, height: 1);
140+ setState(() {
141+ _view = _view.copyWith(
142+ centerX: home.centerX,
143+ centerY: home.centerY,
144+ scale: home.scale,
145+ );
146+ });
147+ _render();
148+ }
149+
150+ /// Renders the identical frame in V and in Dart on this isolate, so the
151+ /// comparison is like-for-like rather than V-plus-parallelism vs Dart.
152+ Future<void> _runBenchmark() async {
153+ setState(() {
154+ _rendering = true;
155+ _benchmark = null;
156+ });
157+
158+ final swV = Stopwatch()..start();
159+ v.render(_view);
160+ swV.stop();
161+
162+ final swP = Stopwatch()..start();
163+ await v.renderParallel(_view, tiles: _tiles);
164+ swP.stop();
165+
166+ final swD = Stopwatch()..start();
167+ renderDart(_view);
168+ swD.stop();
169+
170+ if (!mounted) return;
171+ setState(() {
172+ _rendering = false;
173+ _benchmark = _Benchmark(
174+ vSerialMs: swV.elapsedMilliseconds,
175+ vParallelMs: swP.elapsedMilliseconds,
176+ dartMs: swD.elapsedMilliseconds,
177+ tiles: _tiles,
178+ );
179+ });
180+ }
181+
182+ @override
183+ Widget build(BuildContext context) {
184+ return Scaffold(
185+ body: SafeArea(
186+ child: LayoutBuilder(
187+ builder: (context, constraints) {
188+ final wide = constraints.maxWidth > 900;
189+ final canvas = _buildCanvas();
190+ final controls = _buildControls();
191+ return wide
192+ ? Row(
193+ crossAxisAlignment: CrossAxisAlignment.stretch,
194+ children: [
195+ Expanded(child: canvas),
196+ SizedBox(
197+ width: 340,
198+ child: SingleChildScrollView(child: controls),
199+ ),
200+ ],
201+ )
202+ : ListView(
203+ children: [
204+ AspectRatio(
205+ aspectRatio: _renderWidth / _renderHeight,
206+ child: canvas,
207+ ),
208+ controls,
209+ ],
210+ );
211+ },
212+ ),
213+ ),
214+ );
215+ }
216+
217+ /// Keeps the rendered buffer at the canvas's aspect ratio.
218+ ///
219+ /// Without this the image would be letterboxed or cropped, and the
220+ /// click-to-zoom maths — which maps widget coordinates straight into the
221+ /// complex plane — would point at the wrong place.
222+ void _fitToCanvas(Size size) {
223+ if (size.isEmpty) return;
224+ final height = (_renderWidth * size.height / size.width).round();
225+ if ((height - _view.height).abs() <= 2) return;
226+ WidgetsBinding.instance.addPostFrameCallback((_) {
227+ if (!mounted) return;
228+ setState(() => _view = _view.copyWith(height: height));
229+ _render();
230+ });
231+ }
232+
233+ Widget _buildCanvas() {
234+ return LayoutBuilder(
235+ builder: (context, constraints) {
236+ final size = Size(constraints.maxWidth, constraints.maxHeight);
237+ _fitToCanvas(size);
238+ return Listener(
239+ // Wheel zoom, anchored at the cursor like the tap zoom. One notch is
240+ // a small step so a scroll feels continuous rather than octave-wise;
241+ // the render loop coalesces whatever it cannot keep up with.
242+ onPointerSignal: (event) {
243+ if (event is! PointerScrollEvent) return;
244+ final dy = event.scrollDelta.dy;
245+ if (dy == 0) return;
246+ _zoomAt(event.localPosition, size, math.pow(1.0015, dy).toDouble());
247+ },
248+ child: GestureDetector(
249+ onTapDown: (d) => _zoomAt(d.localPosition, size, 0.5),
250+ onSecondaryTapDown: (d) => _zoomAt(d.localPosition, size, 2.0),
251+ child: Stack(
252+ fit: StackFit.expand,
253+ children: [
254+ if (_image != null)
255+ RawImage(image: _image, fit: BoxFit.fill)
256+ else
257+ const Center(child: CircularProgressIndicator()),
258+ Positioned(
259+ left: 12,
260+ bottom: 12,
261+ child: _Chip(
262+ 'zoom ${(3.0 / _view.scale).toStringAsFixed(1)}x · '
263+ '$_lastMs ms · '
264+ '${_tiles > 1 ? "$_tiles isolates" : "1 isolate"}',
265+ ),
266+ ),
267+ if (_rendering)
268+ const Positioned(
269+ right: 12,
270+ top: 12,
271+ child: SizedBox(
272+ width: 18,
273+ height: 18,
274+ child: CircularProgressIndicator(strokeWidth: 2),
275+ ),
276+ ),
277+ ],
278+ ),
279+ ),
280+ );
281+ },
282+ );
283+ }
284+
285+ /// Returns a non-scrolling column.
286+ ///
287+ /// The wide layout wraps this in its own scroll view; the narrow layout
288+ /// embeds it in the page's ListView. Making this a ListView itself would
289+ /// nest two scrollables and give the inner one unbounded height.
290+ Widget _buildControls() {
291+ final theme = Theme.of(context);
292+ return Padding(
293+ padding: const EdgeInsets.all(20),
294+ child: Column(
295+ crossAxisAlignment: CrossAxisAlignment.stretch,
296+ children: [
297+ Text('Mandelbrot in V', style: theme.textTheme.titleLarge),
298+ const SizedBox(height: 4),
299+ Text(
300+ 'Tap to zoom in, right-click to zoom out. '
301+ 'Every pixel is computed by vf_mandelbrot in src/vflutter.v.',
302+ style: theme.textTheme.bodySmall,
303+ ),
304+ const SizedBox(height: 20),
305+ _Labelled(
306+ label: 'iterations',
307+ value: '${_view.maxIter}',
308+ child: Slider(
309+ value: _view.maxIter.toDouble(),
310+ min: 50,
311+ max: 2000,
312+ divisions: 39,
313+ onChanged: (n) =>
314+ setState(() => _view = _view.copyWith(maxIter: n.round())),
315+ onChangeEnd: (_) => _render(),
316+ ),
317+ ),
318+ _Labelled(
319+ label: 'isolates',
320+ value: '$_tiles',
321+ child: Slider(
322+ value: _tiles.toDouble(),
323+ min: 1,
324+ max: 8,
325+ divisions: 7,
326+ onChanged: (n) => setState(() => _tiles = n.round()),
327+ onChangeEnd: (_) => _render(),
328+ ),
329+ ),
330+ const SizedBox(height: 8),
331+ Row(
332+ children: [
333+ Expanded(
334+ child: FilledButton.tonal(
335+ onPressed: _rendering ? null : _reset,
336+ child: const Text('Reset view'),
337+ ),
338+ ),
339+ const SizedBox(width: 12),
340+ Expanded(
341+ child: FilledButton(
342+ onPressed: _rendering ? null : _runBenchmark,
343+ child: const Text('Benchmark'),
344+ ),
345+ ),
346+ ],
347+ ),
348+ const SizedBox(height: 20),
349+ if (_benchmark != null) _BenchmarkCard(result: _benchmark!),
350+ const SizedBox(height: 12),
351+ Card(
352+ color: theme.colorScheme.surfaceContainerHighest,
353+ child: Padding(
354+ padding: const EdgeInsets.all(14),
355+ child: Text(
356+ 'The V kernel fills a buffer Dart allocates, so no V memory '
357+ 'crosses the boundary and there is nothing to free. Bands are '
358+ 'independent, which is what makes the isolate slider safe: '
359+ '-gc none means no stop-the-world phase to serialise them.',
360+ style: theme.textTheme.bodySmall,
361+ ),
362+ ),
363+ ),
364+ ],
365+ ),
366+ );
367+ }
368+}
369+
370+class _Benchmark {
371+ const _Benchmark({
372+ required this.vSerialMs,
373+ required this.vParallelMs,
374+ required this.dartMs,
375+ required this.tiles,
376+ });
377+
378+ final int vSerialMs;
379+ final int vParallelMs;
380+ final int dartMs;
381+ final int tiles;
382+}
383+
384+class _BenchmarkCard extends StatelessWidget {
385+ const _BenchmarkCard({required this.result});
386+
387+ final _Benchmark result;
388+
389+ @override
390+ Widget build(BuildContext context) {
391+ final theme = Theme.of(context);
392+ final ratio = result.dartMs / result.vSerialMs;
393+ return Card(
394+ child: Padding(
395+ padding: const EdgeInsets.all(14),
396+ child: Column(
397+ crossAxisAlignment: CrossAxisAlignment.start,
398+ children: [
399+ Text('same frame, three ways',
400+ style: theme.textTheme.titleSmall),
401+ const SizedBox(height: 10),
402+ _Row(label: 'V, 1 isolate', value: '${result.vSerialMs} ms'),
403+ _Row(
404+ label: 'V, ${result.tiles} isolates',
405+ value: '${result.vParallelMs} ms'),
406+ _Row(label: 'Dart, 1 isolate', value: '${result.dartMs} ms'),
407+ const Divider(height: 20),
408+ Text(
409+ 'V is ${ratio.toStringAsFixed(2)}x Dart on one isolate. For a '
410+ 'scalar FP loop the two are close — the real win here is the '
411+ 'parallel split, which Dart could also do. The bridge is what '
412+ 'this demonstrates, not a speed claim.',
413+ style: theme.textTheme.bodySmall,
414+ ),
415+ ],
416+ ),
417+ ),
418+ );
419+ }
420+}
421+
422+class _Row extends StatelessWidget {
423+ const _Row({required this.label, required this.value});
424+
425+ final String label;
426+ final String value;
427+
428+ @override
429+ Widget build(BuildContext context) => Padding(
430+ padding: const EdgeInsets.symmetric(vertical: 2),
431+ child: Row(
432+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
433+ children: [
434+ Text(label, style: Theme.of(context).textTheme.bodyMedium),
435+ Text(value,
436+ style: Theme.of(context)
437+ .textTheme
438+ .bodyMedium
439+ ?.copyWith(fontFeatures: const [ui.FontFeature.tabularFigures()])),
440+ ],
441+ ),
442+ );
443+}
444+
445+class _Labelled extends StatelessWidget {
446+ const _Labelled({
447+ required this.label,
448+ required this.value,
449+ required this.child,
450+ });
451+
452+ final String label;
453+ final String value;
454+ final Widget child;
455+
456+ @override
457+ Widget build(BuildContext context) {
458+ final theme = Theme.of(context);
459+ return Column(
460+ crossAxisAlignment: CrossAxisAlignment.start,
461+ children: [
462+ Row(
463+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
464+ children: [
465+ Text(label, style: theme.textTheme.labelLarge),
466+ Text(value, style: theme.textTheme.labelLarge),
467+ ],
468+ ),
469+ child,
470+ ],
471+ );
472+ }
473+}
474+
475+class _Chip extends StatelessWidget {
476+ const _Chip(this.text);
477+
478+ final String text;
479+
480+ @override
481+ Widget build(BuildContext context) => Container(
482+ padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
483+ decoration: BoxDecoration(
484+ color: Colors.black.withValues(alpha: 0.55),
485+ borderRadius: BorderRadius.circular(8),
486+ ),
487+ child: Text(text,
488+ style: const TextStyle(color: Colors.white, fontSize: 12)),
489+ );
490+}
added example/lib/mandelbrot_dart.dart +55 -0
new file mode 100644
@@ -0,0 +1,55 @@
1+// A straight Dart transliteration of the V kernel in src/vflutter.v.
2+//
3+// It exists purely so the example can render the *same* image both ways and
4+// put a number on the difference. Keep it in sync with the V version — if the
5+// two drift, the comparison stops being honest.
6+import 'dart:math' as math;
7+import 'dart:typed_data';
8+
9+import 'package:vflutter_ffi/vflutter_ffi.dart' as v;
10+
11+Uint8List renderDart(v.FractalView view) {
12+ final out = Uint8List(view.width * view.height * 4);
13+ final aspect = view.width / view.height;
14+ final invW = 1.0 / view.width;
15+ final invH = 1.0 / view.height;
16+ final ln2 = math.log(2.0);
17+
18+ for (var y = 0; y < view.height; y++) {
19+ final im = view.centerY + (y * invH - 0.5) * view.scale;
20+ final row = y * view.width * 4;
21+ for (var x = 0; x < view.width; x++) {
22+ final re = view.centerX + (x * invW - 0.5) * view.scale * aspect;
23+
24+ var zr = 0.0, zi = 0.0, zr2 = 0.0, zi2 = 0.0;
25+ var i = 0;
26+ while (i < view.maxIter) {
27+ zr2 = zr * zr;
28+ zi2 = zi * zi;
29+ if (zr2 + zi2 > 4.0) break;
30+ zi = 2.0 * zr * zi + im;
31+ zr = zr2 - zi2 + re;
32+ i++;
33+ }
34+
35+ final idx = row + x * 4;
36+ if (i >= view.maxIter) {
37+ out[idx + 3] = 255;
38+ continue;
39+ }
40+
41+ final mag = math.sqrt(zr2 + zi2);
42+ var nu = i.toDouble();
43+ if (mag > 1.0) {
44+ nu = i + 1.0 - math.log(math.log(mag) / ln2) / ln2;
45+ }
46+ final t = nu / view.maxIter;
47+
48+ out[idx] = (255.0 * (0.5 + 0.5 * math.sin(3.0 + t * 18.0))).toInt();
49+ out[idx + 1] = (255.0 * (0.5 + 0.5 * math.sin(3.6 + t * 18.0))).toInt();
50+ out[idx + 2] = (255.0 * (0.5 + 0.5 * math.sin(4.2 + t * 18.0))).toInt();
51+ out[idx + 3] = 255;
52+ }
53+ }
54+ return out;
55+}
new file mode 100644
@@ -0,0 +1,55 @@
1+// A straight Dart transliteration of the V kernel in src/vflutter.v.
2+//
3+// It exists purely so the example can render the *same* image both ways and
4+// put a number on the difference. Keep it in sync with the V version — if the
5+// two drift, the comparison stops being honest.
6+import 'dart:math' as math;
7+import 'dart:typed_data';
8+
9+import 'package:vflutter_ffi/vflutter_ffi.dart' as v;
10+
11+Uint8List renderDart(v.FractalView view) {
12+ final out = Uint8List(view.width * view.height * 4);
13+ final aspect = view.width / view.height;
14+ final invW = 1.0 / view.width;
15+ final invH = 1.0 / view.height;
16+ final ln2 = math.log(2.0);
17+
18+ for (var y = 0; y < view.height; y++) {
19+ final im = view.centerY + (y * invH - 0.5) * view.scale;
20+ final row = y * view.width * 4;
21+ for (var x = 0; x < view.width; x++) {
22+ final re = view.centerX + (x * invW - 0.5) * view.scale * aspect;
23+
24+ var zr = 0.0, zi = 0.0, zr2 = 0.0, zi2 = 0.0;
25+ var i = 0;
26+ while (i < view.maxIter) {
27+ zr2 = zr * zr;
28+ zi2 = zi * zi;
29+ if (zr2 + zi2 > 4.0) break;
30+ zi = 2.0 * zr * zi + im;
31+ zr = zr2 - zi2 + re;
32+ i++;
33+ }
34+
35+ final idx = row + x * 4;
36+ if (i >= view.maxIter) {
37+ out[idx + 3] = 255;
38+ continue;
39+ }
40+
41+ final mag = math.sqrt(zr2 + zi2);
42+ var nu = i.toDouble();
43+ if (mag > 1.0) {
44+ nu = i + 1.0 - math.log(math.log(mag) / ln2) / ln2;
45+ }
46+ final t = nu / view.maxIter;
47+
48+ out[idx] = (255.0 * (0.5 + 0.5 * math.sin(3.0 + t * 18.0))).toInt();
49+ out[idx + 1] = (255.0 * (0.5 + 0.5 * math.sin(3.6 + t * 18.0))).toInt();
50+ out[idx + 2] = (255.0 * (0.5 + 0.5 * math.sin(4.2 + t * 18.0))).toInt();
51+ out[idx + 3] = 255;
52+ }
53+ }
54+ return out;
55+}
added example/linux/.gitignore +1 -0
new file mode 100644
@@ -0,0 +1 @@
1+flutter/ephemeral
new file mode 100644
@@ -0,0 +1 @@
1+flutter/ephemeral
added example/linux/CMakeLists.txt +128 -0
new file mode 100644
@@ -0,0 +1,128 @@
1+# Project-level configuration.
2+cmake_minimum_required(VERSION 3.13)
3+project(runner LANGUAGES CXX)
4+
5+# The name of the executable created for the application. Change this to change
6+# the on-disk name of your application.
7+set(BINARY_NAME "vflutter_ffi_example")
8+# The unique GTK application identifier for this application. See:
9+# https://wiki.gnome.org/HowDoI/ChooseApplicationID
10+set(APPLICATION_ID "com.example.vflutter_ffi_example")
11+
12+# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13+# versions of CMake.
14+cmake_policy(SET CMP0063 NEW)
15+
16+# Load bundled libraries from the lib/ directory relative to the binary.
17+set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
18+
19+# Root filesystem for cross-building.
20+if(FLUTTER_TARGET_PLATFORM_SYSROOT)
21+ set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
22+ set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
23+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
24+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
25+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
26+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
27+endif()
28+
29+# Define build configuration options.
30+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
31+ set(CMAKE_BUILD_TYPE "Debug" CACHE
32+ STRING "Flutter build mode" FORCE)
33+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
34+ "Debug" "Profile" "Release")
35+endif()
36+
37+# Compilation settings that should be applied to most targets.
38+#
39+# Be cautious about adding new options here, as plugins use this function by
40+# default. In most cases, you should add new options to specific targets instead
41+# of modifying this function.
42+function(APPLY_STANDARD_SETTINGS TARGET)
43+ target_compile_features(${TARGET} PUBLIC cxx_std_14)
44+ target_compile_options(${TARGET} PRIVATE -Wall -Werror)
45+ target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
46+ target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
47+endfunction()
48+
49+# Flutter library and tool build rules.
50+set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
51+add_subdirectory(${FLUTTER_MANAGED_DIR})
52+
53+# System-level dependencies.
54+find_package(PkgConfig REQUIRED)
55+pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
56+
57+# Application build; see runner/CMakeLists.txt.
58+add_subdirectory("runner")
59+
60+# Run the Flutter tool portions of the build. This must not be removed.
61+add_dependencies(${BINARY_NAME} flutter_assemble)
62+
63+# Only the install-generated bundle's copy of the executable will launch
64+# correctly, since the resources must in the right relative locations. To avoid
65+# people trying to run the unbundled copy, put it in a subdirectory instead of
66+# the default top-level location.
67+set_target_properties(${BINARY_NAME}
68+ PROPERTIES
69+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
70+)
71+
72+
73+# Generated plugin build rules, which manage building the plugins and adding
74+# them to the application.
75+include(flutter/generated_plugins.cmake)
76+
77+
78+# === Installation ===
79+# By default, "installing" just makes a relocatable bundle in the build
80+# directory.
81+set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
82+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
83+ set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
84+endif()
85+
86+# Start with a clean build bundle directory every time.
87+install(CODE "
88+ file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
89+ " COMPONENT Runtime)
90+
91+set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
92+set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
93+
94+install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
95+ COMPONENT Runtime)
96+
97+install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
98+ COMPONENT Runtime)
99+
100+install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
101+ COMPONENT Runtime)
102+
103+foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
104+ install(FILES "${bundled_library}"
105+ DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
106+ COMPONENT Runtime)
107+endforeach(bundled_library)
108+
109+# Copy the native assets provided by the build.dart from all packages.
110+set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
111+install(DIRECTORY "${NATIVE_ASSETS_DIR}"
112+ DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
113+ COMPONENT Runtime)
114+
115+# Fully re-copy the assets directory on each build to avoid having stale files
116+# from a previous install.
117+set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
118+install(CODE "
119+ file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
120+ " COMPONENT Runtime)
121+install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
122+ DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
123+
124+# Install the AOT library on non-Debug builds only.
125+if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
126+ install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
127+ COMPONENT Runtime)
128+endif()
new file mode 100644
@@ -0,0 +1,128 @@
1+# Project-level configuration.
2+cmake_minimum_required(VERSION 3.13)
3+project(runner LANGUAGES CXX)
4+
5+# The name of the executable created for the application. Change this to change
6+# the on-disk name of your application.
7+set(BINARY_NAME "vflutter_ffi_example")
8+# The unique GTK application identifier for this application. See:
9+# https://wiki.gnome.org/HowDoI/ChooseApplicationID
10+set(APPLICATION_ID "com.example.vflutter_ffi_example")
11+
12+# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13+# versions of CMake.
14+cmake_policy(SET CMP0063 NEW)
15+
16+# Load bundled libraries from the lib/ directory relative to the binary.
17+set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
18+
19+# Root filesystem for cross-building.
20+if(FLUTTER_TARGET_PLATFORM_SYSROOT)
21+ set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
22+ set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
23+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
24+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
25+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
26+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
27+endif()
28+
29+# Define build configuration options.
30+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
31+ set(CMAKE_BUILD_TYPE "Debug" CACHE
32+ STRING "Flutter build mode" FORCE)
33+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
34+ "Debug" "Profile" "Release")
35+endif()
36+
37+# Compilation settings that should be applied to most targets.
38+#
39+# Be cautious about adding new options here, as plugins use this function by
40+# default. In most cases, you should add new options to specific targets instead
41+# of modifying this function.
42+function(APPLY_STANDARD_SETTINGS TARGET)
43+ target_compile_features(${TARGET} PUBLIC cxx_std_14)
44+ target_compile_options(${TARGET} PRIVATE -Wall -Werror)
45+ target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
46+ target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
47+endfunction()
48+
49+# Flutter library and tool build rules.
50+set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
51+add_subdirectory(${FLUTTER_MANAGED_DIR})
52+
53+# System-level dependencies.
54+find_package(PkgConfig REQUIRED)
55+pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
56+
57+# Application build; see runner/CMakeLists.txt.
58+add_subdirectory("runner")
59+
60+# Run the Flutter tool portions of the build. This must not be removed.
61+add_dependencies(${BINARY_NAME} flutter_assemble)
62+
63+# Only the install-generated bundle's copy of the executable will launch
64+# correctly, since the resources must in the right relative locations. To avoid
65+# people trying to run the unbundled copy, put it in a subdirectory instead of
66+# the default top-level location.
67+set_target_properties(${BINARY_NAME}
68+ PROPERTIES
69+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
70+)
71+
72+
73+# Generated plugin build rules, which manage building the plugins and adding
74+# them to the application.
75+include(flutter/generated_plugins.cmake)
76+
77+
78+# === Installation ===
79+# By default, "installing" just makes a relocatable bundle in the build
80+# directory.
81+set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
82+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
83+ set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
84+endif()
85+
86+# Start with a clean build bundle directory every time.
87+install(CODE "
88+ file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
89+ " COMPONENT Runtime)
90+
91+set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
92+set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
93+
94+install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
95+ COMPONENT Runtime)
96+
97+install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
98+ COMPONENT Runtime)
99+
100+install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
101+ COMPONENT Runtime)
102+
103+foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
104+ install(FILES "${bundled_library}"
105+ DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
106+ COMPONENT Runtime)
107+endforeach(bundled_library)
108+
109+# Copy the native assets provided by the build.dart from all packages.
110+set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
111+install(DIRECTORY "${NATIVE_ASSETS_DIR}"
112+ DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
113+ COMPONENT Runtime)
114+
115+# Fully re-copy the assets directory on each build to avoid having stale files
116+# from a previous install.
117+set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
118+install(CODE "
119+ file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
120+ " COMPONENT Runtime)
121+install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
122+ DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
123+
124+# Install the AOT library on non-Debug builds only.
125+if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
126+ install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
127+ COMPONENT Runtime)
128+endif()
added example/linux/flutter/CMakeLists.txt +88 -0
new file mode 100644
@@ -0,0 +1,88 @@
1+# This file controls Flutter-level build steps. It should not be edited.
2+cmake_minimum_required(VERSION 3.10)
3+
4+set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5+
6+# Configuration provided via flutter tool.
7+include(${EPHEMERAL_DIR}/generated_config.cmake)
8+
9+# TODO: Move the rest of this into files in ephemeral. See
10+# https://github.com/flutter/flutter/issues/57146.
11+
12+# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13+# which isn't available in 3.10.
14+function(list_prepend LIST_NAME PREFIX)
15+ set(NEW_LIST "")
16+ foreach(element ${${LIST_NAME}})
17+ list(APPEND NEW_LIST "${PREFIX}${element}")
18+ endforeach(element)
19+ set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20+endfunction()
21+
22+# === Flutter Library ===
23+# System-level dependencies.
24+find_package(PkgConfig REQUIRED)
25+pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26+pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27+pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28+
29+set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30+
31+# Published to parent scope for install step.
32+set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33+set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34+set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35+set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36+
37+list(APPEND FLUTTER_LIBRARY_HEADERS
38+ "fl_basic_message_channel.h"
39+ "fl_binary_codec.h"
40+ "fl_binary_messenger.h"
41+ "fl_dart_project.h"
42+ "fl_engine.h"
43+ "fl_json_message_codec.h"
44+ "fl_json_method_codec.h"
45+ "fl_message_codec.h"
46+ "fl_method_call.h"
47+ "fl_method_channel.h"
48+ "fl_method_codec.h"
49+ "fl_method_response.h"
50+ "fl_plugin_registrar.h"
51+ "fl_plugin_registry.h"
52+ "fl_standard_message_codec.h"
53+ "fl_standard_method_codec.h"
54+ "fl_string_codec.h"
55+ "fl_value.h"
56+ "fl_view.h"
57+ "flutter_linux.h"
58+)
59+list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60+add_library(flutter INTERFACE)
61+target_include_directories(flutter INTERFACE
62+ "${EPHEMERAL_DIR}"
63+)
64+target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65+target_link_libraries(flutter INTERFACE
66+ PkgConfig::GTK
67+ PkgConfig::GLIB
68+ PkgConfig::GIO
69+)
70+add_dependencies(flutter flutter_assemble)
71+
72+# === Flutter tool backend ===
73+# _phony_ is a non-existent file to force this command to run every time,
74+# since currently there's no way to get a full input/output list from the
75+# flutter tool.
76+add_custom_command(
77+ OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78+ ${CMAKE_CURRENT_BINARY_DIR}/_phony_
79+ COMMAND ${CMAKE_COMMAND} -E env
80+ ${FLUTTER_TOOL_ENVIRONMENT}
81+ "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82+ ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83+ VERBATIM
84+)
85+add_custom_target(flutter_assemble DEPENDS
86+ "${FLUTTER_LIBRARY}"
87+ ${FLUTTER_LIBRARY_HEADERS}
88+)
new file mode 100644
@@ -0,0 +1,88 @@
1+# This file controls Flutter-level build steps. It should not be edited.
2+cmake_minimum_required(VERSION 3.10)
3+
4+set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5+
6+# Configuration provided via flutter tool.
7+include(${EPHEMERAL_DIR}/generated_config.cmake)
8+
9+# TODO: Move the rest of this into files in ephemeral. See
10+# https://github.com/flutter/flutter/issues/57146.
11+
12+# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13+# which isn't available in 3.10.
14+function(list_prepend LIST_NAME PREFIX)
15+ set(NEW_LIST "")
16+ foreach(element ${${LIST_NAME}})
17+ list(APPEND NEW_LIST "${PREFIX}${element}")
18+ endforeach(element)
19+ set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20+endfunction()
21+
22+# === Flutter Library ===
23+# System-level dependencies.
24+find_package(PkgConfig REQUIRED)
25+pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26+pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27+pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28+
29+set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30+
31+# Published to parent scope for install step.
32+set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33+set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34+set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35+set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36+
37+list(APPEND FLUTTER_LIBRARY_HEADERS
38+ "fl_basic_message_channel.h"
39+ "fl_binary_codec.h"
40+ "fl_binary_messenger.h"
41+ "fl_dart_project.h"
42+ "fl_engine.h"
43+ "fl_json_message_codec.h"
44+ "fl_json_method_codec.h"
45+ "fl_message_codec.h"
46+ "fl_method_call.h"
47+ "fl_method_channel.h"
48+ "fl_method_codec.h"
49+ "fl_method_response.h"
50+ "fl_plugin_registrar.h"
51+ "fl_plugin_registry.h"
52+ "fl_standard_message_codec.h"
53+ "fl_standard_method_codec.h"
54+ "fl_string_codec.h"
55+ "fl_value.h"
56+ "fl_view.h"
57+ "flutter_linux.h"
58+)
59+list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60+add_library(flutter INTERFACE)
61+target_include_directories(flutter INTERFACE
62+ "${EPHEMERAL_DIR}"
63+)
64+target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65+target_link_libraries(flutter INTERFACE
66+ PkgConfig::GTK
67+ PkgConfig::GLIB
68+ PkgConfig::GIO
69+)
70+add_dependencies(flutter flutter_assemble)
71+
72+# === Flutter tool backend ===
73+# _phony_ is a non-existent file to force this command to run every time,
74+# since currently there's no way to get a full input/output list from the
75+# flutter tool.
76+add_custom_command(
77+ OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78+ ${CMAKE_CURRENT_BINARY_DIR}/_phony_
79+ COMMAND ${CMAKE_COMMAND} -E env
80+ ${FLUTTER_TOOL_ENVIRONMENT}
81+ "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82+ ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83+ VERBATIM
84+)
85+add_custom_target(flutter_assemble DEPENDS
86+ "${FLUTTER_LIBRARY}"
87+ ${FLUTTER_LIBRARY_HEADERS}
88+)
added example/linux/flutter/generated_plugin_registrant.cc +11 -0
new file mode 100644
@@ -0,0 +1,11 @@
1+//
2+// Generated file. Do not edit.
3+//
4+
5+// clang-format off
6+
7+#include "generated_plugin_registrant.h"
8+
9+
10+void fl_register_plugins(FlPluginRegistry* registry) {
11+}
new file mode 100644
@@ -0,0 +1,11 @@
1+//
2+// Generated file. Do not edit.
3+//
4+
5+// clang-format off
6+
7+#include "generated_plugin_registrant.h"
8+
9+
10+void fl_register_plugins(FlPluginRegistry* registry) {
11+}
added example/linux/flutter/generated_plugin_registrant.h +15 -0
new file mode 100644
@@ -0,0 +1,15 @@
1+//
2+// Generated file. Do not edit.
3+//
4+
5+// clang-format off
6+
7+#ifndef GENERATED_PLUGIN_REGISTRANT_
8+#define GENERATED_PLUGIN_REGISTRANT_
9+
10+#include <flutter_linux/flutter_linux.h>
11+
12+// Registers Flutter plugins.
13+void fl_register_plugins(FlPluginRegistry* registry);
14+
15+#endif // GENERATED_PLUGIN_REGISTRANT_
new file mode 100644
@@ -0,0 +1,15 @@
1+//
2+// Generated file. Do not edit.
3+//
4+
5+// clang-format off
6+
7+#ifndef GENERATED_PLUGIN_REGISTRANT_
8+#define GENERATED_PLUGIN_REGISTRANT_
9+
10+#include <flutter_linux/flutter_linux.h>
11+
12+// Registers Flutter plugins.
13+void fl_register_plugins(FlPluginRegistry* registry);
14+
15+#endif // GENERATED_PLUGIN_REGISTRANT_
added example/linux/flutter/generated_plugins.cmake +24 -0
new file mode 100644
@@ -0,0 +1,24 @@
1+#
2+# Generated file, do not edit.
3+#
4+
5+list(APPEND FLUTTER_PLUGIN_LIST
6+)
7+
8+list(APPEND FLUTTER_FFI_PLUGIN_LIST
9+ vflutter_ffi
10+)
11+
12+set(PLUGIN_BUNDLED_LIBRARIES)
13+
14+foreach(plugin ${FLUTTER_PLUGIN_LIST})
15+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
16+ target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17+ list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
18+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19+endforeach(plugin)
20+
21+foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
23+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24+endforeach(ffi_plugin)
new file mode 100644
@@ -0,0 +1,24 @@
1+#
2+# Generated file, do not edit.
3+#
4+
5+list(APPEND FLUTTER_PLUGIN_LIST
6+)
7+
8+list(APPEND FLUTTER_FFI_PLUGIN_LIST
9+ vflutter_ffi
10+)
11+
12+set(PLUGIN_BUNDLED_LIBRARIES)
13+
14+foreach(plugin ${FLUTTER_PLUGIN_LIST})
15+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
16+ target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17+ list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
18+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19+endforeach(plugin)
20+
21+foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
23+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24+endforeach(ffi_plugin)
added example/linux/runner/CMakeLists.txt +26 -0
new file mode 100644
@@ -0,0 +1,26 @@
1+cmake_minimum_required(VERSION 3.13)
2+project(runner LANGUAGES CXX)
3+
4+# Define the application target. To change its name, change BINARY_NAME in the
5+# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6+# work.
7+#
8+# Any new source files that you add to the application should be added here.
9+add_executable(${BINARY_NAME}
10+ "main.cc"
11+ "my_application.cc"
12+ "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
13+)
14+
15+# Apply the standard set of build settings. This can be removed for applications
16+# that need different build settings.
17+apply_standard_settings(${BINARY_NAME})
18+
19+# Add preprocessor definitions for the application ID.
20+add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
21+
22+# Add dependency libraries. Add any application-specific dependencies here.
23+target_link_libraries(${BINARY_NAME} PRIVATE flutter)
24+target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
25+
26+target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
new file mode 100644
@@ -0,0 +1,26 @@
1+cmake_minimum_required(VERSION 3.13)
2+project(runner LANGUAGES CXX)
3+
4+# Define the application target. To change its name, change BINARY_NAME in the
5+# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6+# work.
7+#
8+# Any new source files that you add to the application should be added here.
9+add_executable(${BINARY_NAME}
10+ "main.cc"
11+ "my_application.cc"
12+ "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
13+)
14+
15+# Apply the standard set of build settings. This can be removed for applications
16+# that need different build settings.
17+apply_standard_settings(${BINARY_NAME})
18+
19+# Add preprocessor definitions for the application ID.
20+add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
21+
22+# Add dependency libraries. Add any application-specific dependencies here.
23+target_link_libraries(${BINARY_NAME} PRIVATE flutter)
24+target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
25+
26+target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
added example/linux/runner/main.cc +6 -0
new file mode 100644
@@ -0,0 +1,6 @@
1+#include "my_application.h"
2+
3+int main(int argc, char** argv) {
4+ g_autoptr(MyApplication) app = my_application_new();
5+ return g_application_run(G_APPLICATION(app), argc, argv);
6+}
new file mode 100644
@@ -0,0 +1,6 @@
1+#include "my_application.h"
2+
3+int main(int argc, char** argv) {
4+ g_autoptr(MyApplication) app = my_application_new();
5+ return g_application_run(G_APPLICATION(app), argc, argv);
6+}
added example/linux/runner/my_application.cc +148 -0
new file mode 100644
@@ -0,0 +1,148 @@
1+#include "my_application.h"
2+
3+#include <flutter_linux/flutter_linux.h>
4+#ifdef GDK_WINDOWING_X11
5+#include <gdk/gdkx.h>
6+#endif
7+
8+#include "flutter/generated_plugin_registrant.h"
9+
10+struct _MyApplication {
11+ GtkApplication parent_instance;
12+ char** dart_entrypoint_arguments;
13+};
14+
15+G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
16+
17+// Called when first Flutter frame received.
18+static void first_frame_cb(MyApplication* self, FlView* view) {
19+ gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
20+}
21+
22+// Implements GApplication::activate.
23+static void my_application_activate(GApplication* application) {
24+ MyApplication* self = MY_APPLICATION(application);
25+ GtkWindow* window =
26+ GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
27+
28+ // Use a header bar when running in GNOME as this is the common style used
29+ // by applications and is the setup most users will be using (e.g. Ubuntu
30+ // desktop).
31+ // If running on X and not using GNOME then just use a traditional title bar
32+ // in case the window manager does more exotic layout, e.g. tiling.
33+ // If running on Wayland assume the header bar will work (may need changing
34+ // if future cases occur).
35+ gboolean use_header_bar = TRUE;
36+#ifdef GDK_WINDOWING_X11
37+ GdkScreen* screen = gtk_window_get_screen(window);
38+ if (GDK_IS_X11_SCREEN(screen)) {
39+ const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
40+ if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
41+ use_header_bar = FALSE;
42+ }
43+ }
44+#endif
45+ if (use_header_bar) {
46+ GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
47+ gtk_widget_show(GTK_WIDGET(header_bar));
48+ gtk_header_bar_set_title(header_bar, "vflutter_ffi_example");
49+ gtk_header_bar_set_show_close_button(header_bar, TRUE);
50+ gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
51+ } else {
52+ gtk_window_set_title(window, "vflutter_ffi_example");
53+ }
54+
55+ gtk_window_set_default_size(window, 1280, 720);
56+
57+ g_autoptr(FlDartProject) project = fl_dart_project_new();
58+ fl_dart_project_set_dart_entrypoint_arguments(
59+ project, self->dart_entrypoint_arguments);
60+
61+ FlView* view = fl_view_new(project);
62+ GdkRGBA background_color;
63+ // Background defaults to black, override it here if necessary, e.g. #00000000
64+ // for transparent.
65+ gdk_rgba_parse(&background_color, "#000000");
66+ fl_view_set_background_color(view, &background_color);
67+ gtk_widget_show(GTK_WIDGET(view));
68+ gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
69+
70+ // Show the window when Flutter renders.
71+ // Requires the view to be realized so we can start rendering.
72+ g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb),
73+ self);
74+ gtk_widget_realize(GTK_WIDGET(view));
75+
76+ fl_register_plugins(FL_PLUGIN_REGISTRY(view));
77+
78+ gtk_widget_grab_focus(GTK_WIDGET(view));
79+}
80+
81+// Implements GApplication::local_command_line.
82+static gboolean my_application_local_command_line(GApplication* application,
83+ gchar*** arguments,
84+ int* exit_status) {
85+ MyApplication* self = MY_APPLICATION(application);
86+ // Strip out the first argument as it is the binary name.
87+ self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
88+
89+ g_autoptr(GError) error = nullptr;
90+ if (!g_application_register(application, nullptr, &error)) {
91+ g_warning("Failed to register: %s", error->message);
92+ *exit_status = 1;
93+ return TRUE;
94+ }
95+
96+ g_application_activate(application);
97+ *exit_status = 0;
98+
99+ return TRUE;
100+}
101+
102+// Implements GApplication::startup.
103+static void my_application_startup(GApplication* application) {
104+ // MyApplication* self = MY_APPLICATION(object);
105+
106+ // Perform any actions required at application startup.
107+
108+ G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
109+}
110+
111+// Implements GApplication::shutdown.
112+static void my_application_shutdown(GApplication* application) {
113+ // MyApplication* self = MY_APPLICATION(object);
114+
115+ // Perform any actions required at application shutdown.
116+
117+ G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
118+}
119+
120+// Implements GObject::dispose.
121+static void my_application_dispose(GObject* object) {
122+ MyApplication* self = MY_APPLICATION(object);
123+ g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
124+ G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
125+}
126+
127+static void my_application_class_init(MyApplicationClass* klass) {
128+ G_APPLICATION_CLASS(klass)->activate = my_application_activate;
129+ G_APPLICATION_CLASS(klass)->local_command_line =
130+ my_application_local_command_line;
131+ G_APPLICATION_CLASS(klass)->startup = my_application_startup;
132+ G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
133+ G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
134+}
135+
136+static void my_application_init(MyApplication* self) {}
137+
138+MyApplication* my_application_new() {
139+ // Set the program name to the application ID, which helps various systems
140+ // like GTK and desktop environments map this running application to its
141+ // corresponding .desktop file. This ensures better integration by allowing
142+ // the application to be recognized beyond its binary name.
143+ g_set_prgname(APPLICATION_ID);
144+
145+ return MY_APPLICATION(g_object_new(my_application_get_type(),
146+ "application-id", APPLICATION_ID, "flags",
147+ G_APPLICATION_NON_UNIQUE, nullptr));
148+}
new file mode 100644
@@ -0,0 +1,148 @@
1+#include "my_application.h"
2+
3+#include <flutter_linux/flutter_linux.h>
4+#ifdef GDK_WINDOWING_X11
5+#include <gdk/gdkx.h>
6+#endif
7+
8+#include "flutter/generated_plugin_registrant.h"
9+
10+struct _MyApplication {
11+ GtkApplication parent_instance;
12+ char** dart_entrypoint_arguments;
13+};
14+
15+G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
16+
17+// Called when first Flutter frame received.
18+static void first_frame_cb(MyApplication* self, FlView* view) {
19+ gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
20+}
21+
22+// Implements GApplication::activate.
23+static void my_application_activate(GApplication* application) {
24+ MyApplication* self = MY_APPLICATION(application);
25+ GtkWindow* window =
26+ GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
27+
28+ // Use a header bar when running in GNOME as this is the common style used
29+ // by applications and is the setup most users will be using (e.g. Ubuntu
30+ // desktop).
31+ // If running on X and not using GNOME then just use a traditional title bar
32+ // in case the window manager does more exotic layout, e.g. tiling.
33+ // If running on Wayland assume the header bar will work (may need changing
34+ // if future cases occur).
35+ gboolean use_header_bar = TRUE;
36+#ifdef GDK_WINDOWING_X11
37+ GdkScreen* screen = gtk_window_get_screen(window);
38+ if (GDK_IS_X11_SCREEN(screen)) {
39+ const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
40+ if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
41+ use_header_bar = FALSE;
42+ }
43+ }
44+#endif
45+ if (use_header_bar) {
46+ GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
47+ gtk_widget_show(GTK_WIDGET(header_bar));
48+ gtk_header_bar_set_title(header_bar, "vflutter_ffi_example");
49+ gtk_header_bar_set_show_close_button(header_bar, TRUE);
50+ gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
51+ } else {
52+ gtk_window_set_title(window, "vflutter_ffi_example");
53+ }
54+
55+ gtk_window_set_default_size(window, 1280, 720);
56+
57+ g_autoptr(FlDartProject) project = fl_dart_project_new();
58+ fl_dart_project_set_dart_entrypoint_arguments(
59+ project, self->dart_entrypoint_arguments);
60+
61+ FlView* view = fl_view_new(project);
62+ GdkRGBA background_color;
63+ // Background defaults to black, override it here if necessary, e.g. #00000000
64+ // for transparent.
65+ gdk_rgba_parse(&background_color, "#000000");
66+ fl_view_set_background_color(view, &background_color);
67+ gtk_widget_show(GTK_WIDGET(view));
68+ gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
69+
70+ // Show the window when Flutter renders.
71+ // Requires the view to be realized so we can start rendering.
72+ g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb),
73+ self);
74+ gtk_widget_realize(GTK_WIDGET(view));
75+
76+ fl_register_plugins(FL_PLUGIN_REGISTRY(view));
77+
78+ gtk_widget_grab_focus(GTK_WIDGET(view));
79+}
80+
81+// Implements GApplication::local_command_line.
82+static gboolean my_application_local_command_line(GApplication* application,
83+ gchar*** arguments,
84+ int* exit_status) {
85+ MyApplication* self = MY_APPLICATION(application);
86+ // Strip out the first argument as it is the binary name.
87+ self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
88+
89+ g_autoptr(GError) error = nullptr;
90+ if (!g_application_register(application, nullptr, &error)) {
91+ g_warning("Failed to register: %s", error->message);
92+ *exit_status = 1;
93+ return TRUE;
94+ }
95+
96+ g_application_activate(application);
97+ *exit_status = 0;
98+
99+ return TRUE;
100+}
101+
102+// Implements GApplication::startup.
103+static void my_application_startup(GApplication* application) {
104+ // MyApplication* self = MY_APPLICATION(object);
105+
106+ // Perform any actions required at application startup.
107+
108+ G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
109+}
110+
111+// Implements GApplication::shutdown.
112+static void my_application_shutdown(GApplication* application) {
113+ // MyApplication* self = MY_APPLICATION(object);
114+
115+ // Perform any actions required at application shutdown.
116+
117+ G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
118+}
119+
120+// Implements GObject::dispose.
121+static void my_application_dispose(GObject* object) {
122+ MyApplication* self = MY_APPLICATION(object);
123+ g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
124+ G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
125+}
126+
127+static void my_application_class_init(MyApplicationClass* klass) {
128+ G_APPLICATION_CLASS(klass)->activate = my_application_activate;
129+ G_APPLICATION_CLASS(klass)->local_command_line =
130+ my_application_local_command_line;
131+ G_APPLICATION_CLASS(klass)->startup = my_application_startup;
132+ G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
133+ G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
134+}
135+
136+static void my_application_init(MyApplication* self) {}
137+
138+MyApplication* my_application_new() {
139+ // Set the program name to the application ID, which helps various systems
140+ // like GTK and desktop environments map this running application to its
141+ // corresponding .desktop file. This ensures better integration by allowing
142+ // the application to be recognized beyond its binary name.
143+ g_set_prgname(APPLICATION_ID);
144+
145+ return MY_APPLICATION(g_object_new(my_application_get_type(),
146+ "application-id", APPLICATION_ID, "flags",
147+ G_APPLICATION_NON_UNIQUE, nullptr));
148+}
added example/linux/runner/my_application.h +21 -0
new file mode 100644
@@ -0,0 +1,21 @@
1+#ifndef FLUTTER_MY_APPLICATION_H_
2+#define FLUTTER_MY_APPLICATION_H_
3+
4+#include <gtk/gtk.h>
5+
6+G_DECLARE_FINAL_TYPE(MyApplication,
7+ my_application,
8+ MY,
9+ APPLICATION,
10+ GtkApplication)
11+
12+/**
13+ * my_application_new:
14+ *
15+ * Creates a new Flutter-based application.
16+ *
17+ * Returns: a new #MyApplication.
18+ */
19+MyApplication* my_application_new();
20+
21+#endif // FLUTTER_MY_APPLICATION_H_
new file mode 100644
@@ -0,0 +1,21 @@
1+#ifndef FLUTTER_MY_APPLICATION_H_
2+#define FLUTTER_MY_APPLICATION_H_
3+
4+#include <gtk/gtk.h>
5+
6+G_DECLARE_FINAL_TYPE(MyApplication,
7+ my_application,
8+ MY,
9+ APPLICATION,
10+ GtkApplication)
11+
12+/**
13+ * my_application_new:
14+ *
15+ * Creates a new Flutter-based application.
16+ *
17+ * Returns: a new #MyApplication.
18+ */
19+MyApplication* my_application_new();
20+
21+#endif // FLUTTER_MY_APPLICATION_H_
added example/pubspec.lock +220 -0
new file mode 100644
@@ -0,0 +1,220 @@
1+# Generated by pub
2+# See https://dart.dev/tools/pub/glossary#lockfile
3+packages:
4+ async:
5+ dependency: transitive
6+ description:
7+ name: async
8+ sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37
9+ url: "https://pub.dev"
10+ source: hosted
11+ version: "2.13.1"
12+ boolean_selector:
13+ dependency: transitive
14+ description:
15+ name: boolean_selector
16+ sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
17+ url: "https://pub.dev"
18+ source: hosted
19+ version: "2.1.2"
20+ characters:
21+ dependency: transitive
22+ description:
23+ name: characters
24+ sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
25+ url: "https://pub.dev"
26+ source: hosted
27+ version: "1.4.1"
28+ clock:
29+ dependency: transitive
30+ description:
31+ name: clock
32+ sha256: e51d50bca3217c9a9fa2b41a30e4a38971133f5f9ec7a3d57bae095007f1d28e
33+ url: "https://pub.dev"
34+ source: hosted
35+ version: "1.1.3"
36+ collection:
37+ dependency: transitive
38+ description:
39+ name: collection
40+ sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
41+ url: "https://pub.dev"
42+ source: hosted
43+ version: "1.19.1"
44+ fake_async:
45+ dependency: transitive
46+ description:
47+ name: fake_async
48+ sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
49+ url: "https://pub.dev"
50+ source: hosted
51+ version: "1.3.3"
52+ ffi:
53+ dependency: transitive
54+ description:
55+ name: ffi
56+ sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45"
57+ url: "https://pub.dev"
58+ source: hosted
59+ version: "2.2.0"
60+ flutter:
61+ dependency: "direct main"
62+ description: flutter
63+ source: sdk
64+ version: "0.0.0"
65+ flutter_lints:
66+ dependency: "direct dev"
67+ description:
68+ name: flutter_lints
69+ sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
70+ url: "https://pub.dev"
71+ source: hosted
72+ version: "5.0.0"
73+ flutter_test:
74+ dependency: "direct dev"
75+ description: flutter
76+ source: sdk
77+ version: "0.0.0"
78+ leak_tracker:
79+ dependency: transitive
80+ description:
81+ name: leak_tracker
82+ sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
83+ url: "https://pub.dev"
84+ source: hosted
85+ version: "11.0.2"
86+ leak_tracker_flutter_testing:
87+ dependency: transitive
88+ description:
89+ name: leak_tracker_flutter_testing
90+ sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
91+ url: "https://pub.dev"
92+ source: hosted
93+ version: "3.0.10"
94+ leak_tracker_testing:
95+ dependency: transitive
96+ description:
97+ name: leak_tracker_testing
98+ sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
99+ url: "https://pub.dev"
100+ source: hosted
101+ version: "3.0.2"
102+ lints:
103+ dependency: transitive
104+ description:
105+ name: lints
106+ sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
107+ url: "https://pub.dev"
108+ source: hosted
109+ version: "5.1.1"
110+ matcher:
111+ dependency: transitive
112+ description:
113+ name: matcher
114+ sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd"
115+ url: "https://pub.dev"
116+ source: hosted
117+ version: "0.12.20"
118+ material_color_utilities:
119+ dependency: transitive
120+ description:
121+ name: material_color_utilities
122+ sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
123+ url: "https://pub.dev"
124+ source: hosted
125+ version: "0.13.0"
126+ meta:
127+ dependency: transitive
128+ description:
129+ name: meta
130+ sha256: c82594181e3312f3d0695fc95aaaf7758d75b8d4ae2bbecf223b9fd5109a059d
131+ url: "https://pub.dev"
132+ source: hosted
133+ version: "1.18.3"
134+ path:
135+ dependency: transitive
136+ description:
137+ name: path
138+ sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
139+ url: "https://pub.dev"
140+ source: hosted
141+ version: "1.9.1"
142+ sky_engine:
143+ dependency: transitive
144+ description: flutter
145+ source: sdk
146+ version: "0.0.0"
147+ source_span:
148+ dependency: transitive
149+ description:
150+ name: source_span
151+ sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab"
152+ url: "https://pub.dev"
153+ source: hosted
154+ version: "1.10.2"
155+ stack_trace:
156+ dependency: transitive
157+ description:
158+ name: stack_trace
159+ sha256: "277654b3034d17ac6f9f1cb5595db011b1d5d41e8806866db28e0abaa101c490"
160+ url: "https://pub.dev"
161+ source: hosted
162+ version: "1.12.2"
163+ stream_channel:
164+ dependency: transitive
165+ description:
166+ name: stream_channel
167+ sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
168+ url: "https://pub.dev"
169+ source: hosted
170+ version: "2.1.4"
171+ string_scanner:
172+ dependency: transitive
173+ description:
174+ name: string_scanner
175+ sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
176+ url: "https://pub.dev"
177+ source: hosted
178+ version: "1.4.1"
179+ term_glyph:
180+ dependency: transitive
181+ description:
182+ name: term_glyph
183+ sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
184+ url: "https://pub.dev"
185+ source: hosted
186+ version: "1.2.2"
187+ test_api:
188+ dependency: transitive
189+ description:
190+ name: test_api
191+ sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11"
192+ url: "https://pub.dev"
193+ source: hosted
194+ version: "0.7.12"
195+ vector_math:
196+ dependency: transitive
197+ description:
198+ name: vector_math
199+ sha256: "1d774bbdf6b72a0b12122fc1560c9c2d2a67db5a4a4cc2bd8a5c990ab20e3188"
200+ url: "https://pub.dev"
201+ source: hosted
202+ version: "2.4.0"
203+ vflutter_ffi:
204+ dependency: "direct main"
205+ description:
206+ path: ".."
207+ relative: true
208+ source: path
209+ version: "0.1.0"
210+ vm_service:
211+ dependency: transitive
212+ description:
213+ name: vm_service
214+ sha256: "5f37239c4851efcef929cea7824e76df7f2f0970aef85d66bbc430afa40e72f0"
215+ url: "https://pub.dev"
216+ source: hosted
217+ version: "15.3.0"
218+sdks:
219+ dart: ">=3.11.0-0 <4.0.0"
220+ flutter: ">=3.18.0-18.0.pre.54"
new file mode 100644
@@ -0,0 +1,220 @@
1+# Generated by pub
2+# See https://dart.dev/tools/pub/glossary#lockfile
3+packages:
4+ async:
5+ dependency: transitive
6+ description:
7+ name: async
8+ sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37
9+ url: "https://pub.dev"
10+ source: hosted
11+ version: "2.13.1"
12+ boolean_selector:
13+ dependency: transitive
14+ description:
15+ name: boolean_selector
16+ sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
17+ url: "https://pub.dev"
18+ source: hosted
19+ version: "2.1.2"
20+ characters:
21+ dependency: transitive
22+ description:
23+ name: characters
24+ sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
25+ url: "https://pub.dev"
26+ source: hosted
27+ version: "1.4.1"
28+ clock:
29+ dependency: transitive
30+ description:
31+ name: clock
32+ sha256: e51d50bca3217c9a9fa2b41a30e4a38971133f5f9ec7a3d57bae095007f1d28e
33+ url: "https://pub.dev"
34+ source: hosted
35+ version: "1.1.3"
36+ collection:
37+ dependency: transitive
38+ description:
39+ name: collection
40+ sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
41+ url: "https://pub.dev"
42+ source: hosted
43+ version: "1.19.1"
44+ fake_async:
45+ dependency: transitive
46+ description:
47+ name: fake_async
48+ sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
49+ url: "https://pub.dev"
50+ source: hosted
51+ version: "1.3.3"
52+ ffi:
53+ dependency: transitive
54+ description:
55+ name: ffi
56+ sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45"
57+ url: "https://pub.dev"
58+ source: hosted
59+ version: "2.2.0"
60+ flutter:
61+ dependency: "direct main"
62+ description: flutter
63+ source: sdk
64+ version: "0.0.0"
65+ flutter_lints:
66+ dependency: "direct dev"
67+ description:
68+ name: flutter_lints
69+ sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
70+ url: "https://pub.dev"
71+ source: hosted
72+ version: "5.0.0"
73+ flutter_test:
74+ dependency: "direct dev"
75+ description: flutter
76+ source: sdk
77+ version: "0.0.0"
78+ leak_tracker:
79+ dependency: transitive
80+ description:
81+ name: leak_tracker
82+ sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
83+ url: "https://pub.dev"
84+ source: hosted
85+ version: "11.0.2"
86+ leak_tracker_flutter_testing:
87+ dependency: transitive
88+ description:
89+ name: leak_tracker_flutter_testing
90+ sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
91+ url: "https://pub.dev"
92+ source: hosted
93+ version: "3.0.10"
94+ leak_tracker_testing:
95+ dependency: transitive
96+ description:
97+ name: leak_tracker_testing
98+ sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
99+ url: "https://pub.dev"
100+ source: hosted
101+ version: "3.0.2"
102+ lints:
103+ dependency: transitive
104+ description:
105+ name: lints
106+ sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
107+ url: "https://pub.dev"
108+ source: hosted
109+ version: "5.1.1"
110+ matcher:
111+ dependency: transitive
112+ description:
113+ name: matcher
114+ sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd"
115+ url: "https://pub.dev"
116+ source: hosted
117+ version: "0.12.20"
118+ material_color_utilities:
119+ dependency: transitive
120+ description:
121+ name: material_color_utilities
122+ sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
123+ url: "https://pub.dev"
124+ source: hosted
125+ version: "0.13.0"
126+ meta:
127+ dependency: transitive
128+ description:
129+ name: meta
130+ sha256: c82594181e3312f3d0695fc95aaaf7758d75b8d4ae2bbecf223b9fd5109a059d
131+ url: "https://pub.dev"
132+ source: hosted
133+ version: "1.18.3"
134+ path:
135+ dependency: transitive
136+ description:
137+ name: path
138+ sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
139+ url: "https://pub.dev"
140+ source: hosted
141+ version: "1.9.1"
142+ sky_engine:
143+ dependency: transitive
144+ description: flutter
145+ source: sdk
146+ version: "0.0.0"
147+ source_span:
148+ dependency: transitive
149+ description:
150+ name: source_span
151+ sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab"
152+ url: "https://pub.dev"
153+ source: hosted
154+ version: "1.10.2"
155+ stack_trace:
156+ dependency: transitive
157+ description:
158+ name: stack_trace
159+ sha256: "277654b3034d17ac6f9f1cb5595db011b1d5d41e8806866db28e0abaa101c490"
160+ url: "https://pub.dev"
161+ source: hosted
162+ version: "1.12.2"
163+ stream_channel:
164+ dependency: transitive
165+ description:
166+ name: stream_channel
167+ sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
168+ url: "https://pub.dev"
169+ source: hosted
170+ version: "2.1.4"
171+ string_scanner:
172+ dependency: transitive
173+ description:
174+ name: string_scanner
175+ sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
176+ url: "https://pub.dev"
177+ source: hosted
178+ version: "1.4.1"
179+ term_glyph:
180+ dependency: transitive
181+ description:
182+ name: term_glyph
183+ sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
184+ url: "https://pub.dev"
185+ source: hosted
186+ version: "1.2.2"
187+ test_api:
188+ dependency: transitive
189+ description:
190+ name: test_api
191+ sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11"
192+ url: "https://pub.dev"
193+ source: hosted
194+ version: "0.7.12"
195+ vector_math:
196+ dependency: transitive
197+ description:
198+ name: vector_math
199+ sha256: "1d774bbdf6b72a0b12122fc1560c9c2d2a67db5a4a4cc2bd8a5c990ab20e3188"
200+ url: "https://pub.dev"
201+ source: hosted
202+ version: "2.4.0"
203+ vflutter_ffi:
204+ dependency: "direct main"
205+ description:
206+ path: ".."
207+ relative: true
208+ source: path
209+ version: "0.1.0"
210+ vm_service:
211+ dependency: transitive
212+ description:
213+ name: vm_service
214+ sha256: "5f37239c4851efcef929cea7824e76df7f2f0970aef85d66bbc430afa40e72f0"
215+ url: "https://pub.dev"
216+ source: hosted
217+ version: "15.3.0"
218+sdks:
219+ dart: ">=3.11.0-0 <4.0.0"
220+ flutter: ">=3.18.0-18.0.pre.54"
added example/pubspec.yaml +21 -0
new file mode 100644
@@ -0,0 +1,21 @@
1+name: vflutter_ffi_example
2+description: Demonstrates calling V from Flutter over dart:ffi.
3+publish_to: 'none'
4+version: 0.1.0
5+
6+environment:
7+ sdk: '>=3.3.0 <4.0.0'
8+
9+dependencies:
10+ flutter:
11+ sdk: flutter
12+ vflutter_ffi:
13+ path: ../
14+
15+dev_dependencies:
16+ flutter_test:
17+ sdk: flutter
18+ flutter_lints: ^5.0.0
19+
20+flutter:
21+ uses-material-design: true
new file mode 100644
@@ -0,0 +1,21 @@
1+name: vflutter_ffi_example
2+description: Demonstrates calling V from Flutter over dart:ffi.
3+publish_to: 'none'
4+version: 0.1.0
5+
6+environment:
7+ sdk: '>=3.3.0 <4.0.0'
8+
9+dependencies:
10+ flutter:
11+ sdk: flutter
12+ vflutter_ffi:
13+ path: ../
14+
15+dev_dependencies:
16+ flutter_test:
17+ sdk: flutter
18+ flutter_lints: ^5.0.0
19+
20+flutter:
21+ uses-material-design: true
added example/test/explorer_test.dart +71 -0
new file mode 100644
@@ -0,0 +1,71 @@
1+// Widget-level checks on the explorer. These need the native library on the
2+// loader path:
3+//
4+// cd example && LD_LIBRARY_PATH=../build flutter test
5+import 'package:flutter/material.dart';
6+import 'package:flutter_test/flutter_test.dart';
7+import 'package:vflutter_ffi_example/main.dart';
8+
9+/// pumpAndSettle cannot be used here: the in-flight-render spinner animates
10+/// indefinitely, and rendering runs on real isolates outside the fake clock.
11+Future<void> settle(WidgetTester tester) async {
12+ for (var i = 0; i < 20; i++) {
13+ await tester.pump(const Duration(milliseconds: 50));
14+ }
15+}
16+
17+void main() {
18+ /// The side panel only exists in the wide layout, so size the surface like a
19+ /// desktop window rather than the 800x600 test default.
20+ Future<void> pumpWide(WidgetTester tester) async {
21+ tester.view.physicalSize = const Size(1400, 900);
22+ tester.view.devicePixelRatio = 1.0;
23+ addTearDown(tester.view.reset);
24+ await tester.pumpWidget(const ExampleApp());
25+ await tester.pump(const Duration(milliseconds: 100));
26+ }
27+
28+ testWidgets('starts at the documented defaults, not the slider maxima',
29+ (tester) async {
30+ await pumpWide(tester);
31+
32+ final sliders = tester.widgetList<Slider>(find.byType(Slider)).toList();
33+ expect(sliders, hasLength(2));
34+ expect(sliders[0].value, 400, reason: 'iterations should default to 400');
35+ expect(sliders[1].value, 4, reason: 'isolates should default to 4');
36+ });
37+
38+ testWidgets('reset restores the framing without touching iterations',
39+ (tester) async {
40+ await pumpWide(tester);
41+
42+ // Move the iteration slider off its default, then reset the view.
43+ await tester.drag(find.byType(Slider).first, const Offset(200, 0));
44+ await settle(tester);
45+ final changed =
46+ tester.widgetList<Slider>(find.byType(Slider)).first.value;
47+ expect(changed, greaterThan(400),
48+ reason: 'the drag should have raised the iteration count');
49+
50+ await tester.tap(find.text('Reset view'));
51+ await settle(tester);
52+
53+ // Reset owns pan/zoom only: the iteration setting must survive it.
54+ expect(tester.widgetList<Slider>(find.byType(Slider)).first.value, changed);
55+ expect(find.textContaining('zoom 1.0x'), findsOneWidget);
56+ });
57+
58+ testWidgets('narrow layout lays out without overflowing', (tester) async {
59+ // Regression guard: the controls used to be a ListView nested inside the
60+ // page's ListView, which threw "Vertical viewport was given unbounded
61+ // height" and broke the whole mobile layout.
62+ tester.view.physicalSize = const Size(420, 900);
63+ tester.view.devicePixelRatio = 1.0;
64+ addTearDown(tester.view.reset);
65+
66+ await tester.pumpWidget(const ExampleApp());
67+ await tester.pump(const Duration(milliseconds: 100));
68+
69+ expect(tester.takeException(), isNull);
70+ });
71+}
new file mode 100644
@@ -0,0 +1,71 @@
1+// Widget-level checks on the explorer. These need the native library on the
2+// loader path:
3+//
4+// cd example && LD_LIBRARY_PATH=../build flutter test
5+import 'package:flutter/material.dart';
6+import 'package:flutter_test/flutter_test.dart';
7+import 'package:vflutter_ffi_example/main.dart';
8+
9+/// pumpAndSettle cannot be used here: the in-flight-render spinner animates
10+/// indefinitely, and rendering runs on real isolates outside the fake clock.
11+Future<void> settle(WidgetTester tester) async {
12+ for (var i = 0; i < 20; i++) {
13+ await tester.pump(const Duration(milliseconds: 50));
14+ }
15+}
16+
17+void main() {
18+ /// The side panel only exists in the wide layout, so size the surface like a
19+ /// desktop window rather than the 800x600 test default.
20+ Future<void> pumpWide(WidgetTester tester) async {
21+ tester.view.physicalSize = const Size(1400, 900);
22+ tester.view.devicePixelRatio = 1.0;
23+ addTearDown(tester.view.reset);
24+ await tester.pumpWidget(const ExampleApp());
25+ await tester.pump(const Duration(milliseconds: 100));
26+ }
27+
28+ testWidgets('starts at the documented defaults, not the slider maxima',
29+ (tester) async {
30+ await pumpWide(tester);
31+
32+ final sliders = tester.widgetList<Slider>(find.byType(Slider)).toList();
33+ expect(sliders, hasLength(2));
34+ expect(sliders[0].value, 400, reason: 'iterations should default to 400');
35+ expect(sliders[1].value, 4, reason: 'isolates should default to 4');
36+ });
37+
38+ testWidgets('reset restores the framing without touching iterations',
39+ (tester) async {
40+ await pumpWide(tester);
41+
42+ // Move the iteration slider off its default, then reset the view.
43+ await tester.drag(find.byType(Slider).first, const Offset(200, 0));
44+ await settle(tester);
45+ final changed =
46+ tester.widgetList<Slider>(find.byType(Slider)).first.value;
47+ expect(changed, greaterThan(400),
48+ reason: 'the drag should have raised the iteration count');
49+
50+ await tester.tap(find.text('Reset view'));
51+ await settle(tester);
52+
53+ // Reset owns pan/zoom only: the iteration setting must survive it.
54+ expect(tester.widgetList<Slider>(find.byType(Slider)).first.value, changed);
55+ expect(find.textContaining('zoom 1.0x'), findsOneWidget);
56+ });
57+
58+ testWidgets('narrow layout lays out without overflowing', (tester) async {
59+ // Regression guard: the controls used to be a ListView nested inside the
60+ // page's ListView, which threw "Vertical viewport was given unbounded
61+ // height" and broke the whole mobile layout.
62+ tester.view.physicalSize = const Size(420, 900);
63+ tester.view.devicePixelRatio = 1.0;
64+ addTearDown(tester.view.reset);
65+
66+ await tester.pumpWidget(const ExampleApp());
67+ await tester.pump(const Duration(milliseconds: 100));
68+
69+ expect(tester.takeException(), isNull);
70+ });
71+}
added example/test/widget_test.dart +83 -0
new file mode 100644
@@ -0,0 +1,83 @@
1+// Runs against the real V library, so it needs the native build on the loader
2+// path — `flutter test` runs on the host VM, not in the app bundle:
3+//
4+// ./tool/build.sh
5+// cd example && LD_LIBRARY_PATH=../build flutter test
6+//
7+// This is a smoke test of the bridge as the app uses it, not of the widgets.
8+import 'package:flutter/material.dart';
9+import 'package:flutter_test/flutter_test.dart';
10+import 'package:vflutter_ffi/vflutter_ffi.dart' as v;
11+import 'package:vflutter_ffi_example/mandelbrot_dart.dart';
12+
13+void main() {
14+ _zoomTests();
15+
16+ const view = v.FractalView(width: 64, height: 48, maxIter: 80);
17+
18+ test('V fills the caller-owned buffer', () {
19+ final pixels = v.render(view);
20+ expect(pixels.length, view.width * view.height * 4);
21+ // Alpha is written for every pixel, inside the set and out.
22+ for (var i = 3; i < pixels.length; i += 4) {
23+ expect(pixels[i], 255);
24+ }
25+ // The frame is not uniform — it actually contains a fractal.
26+ expect(pixels.toSet().length, greaterThan(8));
27+ });
28+
29+ test('band split matches a single-shot render', () async {
30+ final whole = v.render(view);
31+ final tiled = await v.renderParallel(view, tiles: 4);
32+ expect(tiled, equals(whole));
33+ });
34+
35+ test('the V and Dart kernels agree pixel-for-pixel', () {
36+ expect(v.render(view), equals(renderDart(view)));
37+ });
38+
39+ testWidgets('renders a frame computed in V', (tester) async {
40+ await tester.pumpWidget(const MaterialApp(home: SizedBox()));
41+ // The explorer renders asynchronously; just assert the bridge is usable
42+ // from the test binding, which is where FFI setup usually breaks.
43+ expect(v.add(20, 22), 42);
44+ expect(v.greet('Flutter'), 'Hello, Flutter, from V!');
45+ });
46+}
47+
48+void _zoomTests() {
49+ group('zoomedAt', () {
50+ const view = v.FractalView(width: 800, height: 600);
51+
52+ test('keeps the anchor point fixed in the complex plane', () {
53+ // The plane coordinate under a given viewport fraction must be the same
54+ // before and after the zoom. This is the property that broke when the
55+ // maths lived inline in the widget.
56+ double planeX(v.FractalView f, double fx) =>
57+ f.centerX + (fx - 0.5) * f.scale * (f.width / f.height);
58+ double planeY(v.FractalView f, double fy) =>
59+ f.centerY + (fy - 0.5) * f.scale;
60+
61+ for (final p in [0.0, 0.25, 0.5, 0.73, 1.0]) {
62+ final zoomed = view.zoomedAt(p, p, 0.5);
63+ expect(planeX(zoomed, p), closeTo(planeX(view, p), 1e-12));
64+ expect(planeY(zoomed, p), closeTo(planeY(view, p), 1e-12));
65+ }
66+ });
67+
68+ test('one tap is exactly one zoom level', () {
69+ expect(view.zoomedAt(0.5, 0.5, 0.5).scale, closeTo(view.scale / 2, 1e-12));
70+ expect(
71+ view.zoomedAt(0.5, 0.5, 0.5).zoomedAt(0.5, 0.5, 0.5).scale,
72+ closeTo(view.scale / 4, 1e-12),
73+ );
74+ });
75+
76+ test('zooming in then out returns to the starting view', () {
77+ final round = view.zoomedAt(0.3, 0.8, 0.5).zoomedAt(0.3, 0.8, 2.0);
78+ expect(round.scale, closeTo(view.scale, 1e-12));
79+ expect(round.centerX, closeTo(view.centerX, 1e-12));
80+ expect(round.centerY, closeTo(view.centerY, 1e-12));
81+ });
82+ });
83+}
new file mode 100644
@@ -0,0 +1,83 @@
1+// Runs against the real V library, so it needs the native build on the loader
2+// path — `flutter test` runs on the host VM, not in the app bundle:
3+//
4+// ./tool/build.sh
5+// cd example && LD_LIBRARY_PATH=../build flutter test
6+//
7+// This is a smoke test of the bridge as the app uses it, not of the widgets.
8+import 'package:flutter/material.dart';
9+import 'package:flutter_test/flutter_test.dart';
10+import 'package:vflutter_ffi/vflutter_ffi.dart' as v;
11+import 'package:vflutter_ffi_example/mandelbrot_dart.dart';
12+
13+void main() {
14+ _zoomTests();
15+
16+ const view = v.FractalView(width: 64, height: 48, maxIter: 80);
17+
18+ test('V fills the caller-owned buffer', () {
19+ final pixels = v.render(view);
20+ expect(pixels.length, view.width * view.height * 4);
21+ // Alpha is written for every pixel, inside the set and out.
22+ for (var i = 3; i < pixels.length; i += 4) {
23+ expect(pixels[i], 255);
24+ }
25+ // The frame is not uniform — it actually contains a fractal.
26+ expect(pixels.toSet().length, greaterThan(8));
27+ });
28+
29+ test('band split matches a single-shot render', () async {
30+ final whole = v.render(view);
31+ final tiled = await v.renderParallel(view, tiles: 4);
32+ expect(tiled, equals(whole));
33+ });
34+
35+ test('the V and Dart kernels agree pixel-for-pixel', () {
36+ expect(v.render(view), equals(renderDart(view)));
37+ });
38+
39+ testWidgets('renders a frame computed in V', (tester) async {
40+ await tester.pumpWidget(const MaterialApp(home: SizedBox()));
41+ // The explorer renders asynchronously; just assert the bridge is usable
42+ // from the test binding, which is where FFI setup usually breaks.
43+ expect(v.add(20, 22), 42);
44+ expect(v.greet('Flutter'), 'Hello, Flutter, from V!');
45+ });
46+}
47+
48+void _zoomTests() {
49+ group('zoomedAt', () {
50+ const view = v.FractalView(width: 800, height: 600);
51+
52+ test('keeps the anchor point fixed in the complex plane', () {
53+ // The plane coordinate under a given viewport fraction must be the same
54+ // before and after the zoom. This is the property that broke when the
55+ // maths lived inline in the widget.
56+ double planeX(v.FractalView f, double fx) =>
57+ f.centerX + (fx - 0.5) * f.scale * (f.width / f.height);
58+ double planeY(v.FractalView f, double fy) =>
59+ f.centerY + (fy - 0.5) * f.scale;
60+
61+ for (final p in [0.0, 0.25, 0.5, 0.73, 1.0]) {
62+ final zoomed = view.zoomedAt(p, p, 0.5);
63+ expect(planeX(zoomed, p), closeTo(planeX(view, p), 1e-12));
64+ expect(planeY(zoomed, p), closeTo(planeY(view, p), 1e-12));
65+ }
66+ });
67+
68+ test('one tap is exactly one zoom level', () {
69+ expect(view.zoomedAt(0.5, 0.5, 0.5).scale, closeTo(view.scale / 2, 1e-12));
70+ expect(
71+ view.zoomedAt(0.5, 0.5, 0.5).zoomedAt(0.5, 0.5, 0.5).scale,
72+ closeTo(view.scale / 4, 1e-12),
73+ );
74+ });
75+
76+ test('zooming in then out returns to the starting view', () {
77+ final round = view.zoomedAt(0.3, 0.8, 0.5).zoomedAt(0.3, 0.8, 2.0);
78+ expect(round.scale, closeTo(view.scale, 1e-12));
79+ expect(round.centerX, closeTo(view.centerX, 1e-12));
80+ expect(round.centerY, closeTo(view.centerY, 1e-12));
81+ });
82+ });
83+}
modified ios/Classes/vflutter.gen.c +2692 -329
@@ -7,8 +7,9 @@
77
88 // V comptime_definitions:
99 // V compile time defines by -d or -define flags:
10-// All custom defines : linux
11-// Turned ON custom defines: linux
10+// All custom defines : no_backtrace,linux
11+// Turned ON custom defines: no_backtrace,linux
12+#define CUSTOM_DEFINE_no_backtrace
1213 #define CUSTOM_DEFINE_linux
1314
1415
@@ -20,6 +21,7 @@ typedef struct none none;
2021 typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11;
2122 typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11;
2223 typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128;
24+typedef struct _v_Array_fixed_f64_4 _v_Array_fixed_f64_4;
2325 typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32;
2426 typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64;
2527 typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5;
@@ -40,8 +42,6 @@ typedef struct _v_Array_fixed_u64_47 _v_Array_fixed_u64_47;
4042 typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31;
4143 typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64;
4244 typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64;
43-typedef struct _v_Array_fixed_voidptr_100 _v_Array_fixed_voidptr_100;
44-typedef struct _v_Array_fixed_u8_1000 _v_Array_fixed_u8_1000;
4545 typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17;
4646 typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264;
4747 typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10;
@@ -60,8 +60,10 @@ typedef struct multi_return_u64_int multi_return_u64_int;
6060 typedef struct multi_return_i64_int multi_return_i64_int;
6161 typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool;
6262 typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool;
63-typedef struct multi_return_u64_u64 multi_return_u64_u64;
6463 typedef struct multi_return_f64_int multi_return_f64_int;
64+typedef struct multi_return_i64_i64_i64 multi_return_i64_i64_i64;
65+typedef struct multi_return_f64_f64 multi_return_f64_f64;
66+typedef struct multi_return_u64_u64 multi_return_u64_u64;
6567 // END_multi_return_typedefs
6668
6769 typedef struct strings__IndentParam strings__IndentParam;
@@ -106,6 +108,12 @@ typedef struct RunesIterator RunesIterator;
106108 typedef union StrIntpMem StrIntpMem;
107109 typedef struct StrIntpData StrIntpData;
108110 typedef struct ToWideConfig ToWideConfig;
111+typedef struct math__BezierPoint math__BezierPoint;
112+typedef struct math__DigitParams math__DigitParams;
113+typedef struct math__DivResult math__DivResult;
114+typedef struct math__ChebSeries math__ChebSeries;
115+typedef union math__U32_F32 math__U32_F32;
116+typedef union math__U64_F64 math__U64_F64;
109117 typedef struct _result_int _result_int;
110118 typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr;
111119 typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken;
@@ -124,9 +132,9 @@ typedef struct _result_rune _result_rune;
124132 typedef struct _result_string _result_string;
125133 typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo;
126134 typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr;
127-typedef struct _option_int _option_int;
128135 typedef struct _option_rune _option_rune;
129136 typedef struct _option_multi_return_string_string _option_multi_return_string_string;
137+typedef struct _option_int _option_int;
130138 typedef struct _option_u8 _option_u8;
131139
132140 // V preincludes:
@@ -1479,6 +1487,23 @@ V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) {
14791487 #endif
14801488 #endif
14811489
1490+
1491+// added by module `math`, file: math.c.v:6:
1492+
1493+#ifdef __TINYC__
1494+#include <math.h>
1495+#else
1496+#if defined(__has_include)
1497+#if __has_include(<math.h>)
1498+#include <math.h>
1499+#else
1500+#error VERROR_MESSAGE Header file <math.h>, needed for module `math` was not found. Please install the corresponding development headers.
1501+#endif
1502+#else
1503+#include <math.h>
1504+#endif
1505+#endif
1506+
14821507 #if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool)
14831508 #ifdef bool
14841509 #undef bool
@@ -1516,9 +1541,20 @@ typedef u8 bool;
15161541 #define _const_rune_maps_utl -2
15171542 #define _const_degree 6
15181543 #define _const_mid_index 5
1519-#define _const_max_len 11
15201544 #define _const_replace_stack_buffer_size 10
15211545 #define _const_kmp_stack_buffer_size 20
1546+#define _const_math__internal__max_int_fact_arg 170
1547+#define _const_math__shift 52
1548+#define _const_math__bias 1023
1549+#define _const_math__pi_2 1.5707963267948966
1550+#define _const_math__pi_4 0.7853981633974483
1551+#define _const_math__one_over_tau 0.15915494309189535
1552+#define _const_math__one_over_pi 0.3183098861837907
1553+#define _const_math__tau_over2 3.141592653589793
1554+#define _const_math__tau_over4 1.5707963267948966
1555+#define _const_math__tau_over8 0.7853981633974483
1556+#define _const_math__log2_e 1.4426950408889634
1557+#define _const_math__log10_e 0.43429448190325176
15221558
15231559 // Enum definitions:
15241560
@@ -1722,6 +1758,9 @@ typedef array Array_builtin__closure__ClosureLifetimeFrame;
17221758 typedef map Map_voidptr_builtin__closure__ClosureLiveInfo;
17231759 typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr;
17241760 typedef u8 Array_fixed_u8_128 [128];
1761+typedef array Array_f64;
1762+typedef array Array_math__BezierPoint;
1763+typedef f64 Array_fixed_f64_4 [4];
17251764 typedef u8 Array_fixed_u8_32 [32];
17261765 typedef u8 Array_fixed_u8_64 [64];
17271766 typedef u8 Array_fixed_u8_5 [5];
@@ -1742,8 +1781,6 @@ typedef u64 Array_fixed_u64_47 [47];
17421781 typedef u64 Array_fixed_u64_31 [31];
17431782 typedef int Array_fixed_int_64 [64];
17441783 typedef voidptr Array_fixed_voidptr_64 [64];
1745-typedef voidptr Array_fixed_voidptr_100 [100];
1746-typedef u8 Array_fixed_u8_1000 [1000];
17471784 typedef array Array_GraphemeBreakProperty;
17481785 typedef u8 Array_fixed_u8_17 [17];
17491786 typedef i32 Array_fixed_i32_1264 [1264];
@@ -1964,6 +2001,33 @@ struct builtin__closure__FrameToken {
19642001 u64 generation;
19652002 };
19662003
2004+struct math__BezierPoint {
2005+ f64 x;
2006+ f64 y;
2007+};
2008+
2009+struct math__DigitParams {
2010+ int base;
2011+ bool reverse;
2012+};
2013+
2014+struct math__ChebSeries {
2015+ Array_f64 c;
2016+ int order;
2017+ f64 a;
2018+ f64 b;
2019+};
2020+
2021+union math__U32_F32 {
2022+ u32 u;
2023+ f32 f;
2024+};
2025+
2026+union math__U64_F64 {
2027+ u64 u;
2028+ f64 f;
2029+};
2030+
19672031 struct mapnode {
19682032 voidptr* children;
19692033 int len;
@@ -2011,6 +2075,9 @@ struct _v_Array_fixed_voidptr_11 {
20112075 struct _v_Array_fixed_u8_128 {
20122076 u8 ret_arr[128];
20132077 };
2078+struct _v_Array_fixed_f64_4 {
2079+ f64 ret_arr[4];
2080+};
20142081 struct _v_Array_fixed_u8_32 {
20152082 u8 ret_arr[32];
20162083 };
@@ -2071,12 +2138,6 @@ struct _v_Array_fixed_int_64 {
20712138 struct _v_Array_fixed_voidptr_64 {
20722139 voidptr ret_arr[64];
20732140 };
2074-struct _v_Array_fixed_voidptr_100 {
2075- voidptr ret_arr[100];
2076-};
2077-struct _v_Array_fixed_u8_1000 {
2078- u8 ret_arr[1000];
2079-};
20802141 struct _v_Array_fixed_u8_17 {
20812142 u8 ret_arr[17];
20822143 };
@@ -2144,16 +2205,27 @@ struct multi_return_strconv__Dec64_bool {
21442205 bool arg1;
21452206 };
21462207
2147-struct multi_return_u64_u64 {
2148- u64 arg0;
2149- u64 arg1;
2150-};
2151-
21522208 struct multi_return_f64_int {
21532209 f64 arg0;
21542210 int arg1;
21552211 };
21562212
2213+struct multi_return_i64_i64_i64 {
2214+ i64 arg0;
2215+ i64 arg1;
2216+ i64 arg2;
2217+};
2218+
2219+struct multi_return_f64_f64 {
2220+ f64 arg0;
2221+ f64 arg1;
2222+};
2223+
2224+struct multi_return_u64_u64 {
2225+ u64 arg0;
2226+ u64 arg1;
2227+};
2228+
21572229 // END_multi_return_structs
21582230
21592231 static bool Array_u8_contains(Array_u8 a, u8 v);
@@ -2171,12 +2243,6 @@ struct _option_builtin__closure__ClosureLifetimeState_ptr {
21712243 byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1];
21722244 };
21732245
2174-struct _option_int {
2175- byte state;
2176- IError err;
2177- byte data[sizeof(int) > 1 ? sizeof(int) : 1];
2178-};
2179-
21802246 struct _option_rune {
21812247 byte state;
21822248 IError err;
@@ -2189,6 +2255,12 @@ struct _option_multi_return_string_string {
21892255 byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1];
21902256 };
21912257
2258+struct _option_int {
2259+ byte state;
2260+ IError err;
2261+ byte data[sizeof(int) > 1 ? sizeof(int) : 1];
2262+};
2263+
21922264 struct _option_u8 {
21932265 byte state;
21942266 IError err;
@@ -2660,15 +2732,7 @@ VV_LOC void builtin__autostr_addr_push(voidptr addr);
26602732 VV_LOC void builtin__autostr_addr_pop(void);
26612733 VV_LOC string builtin__autostr_array_circular(int len);
26622734 void builtin__print_backtrace(void);
2663-VV_LOC string builtin__demangle_v_symbol(string cname);
2664-VV_LOC Array_string builtin__split_generic_params(string s);
2665-VV_LOC string builtin__demangle_backtrace_sym(string s);
2666-VV_LOC void builtin__eprint_space_padding(string output, int max_len);
26672735 bool builtin__print_backtrace_skipping_top_frames(int xskipframes);
2668-VV_LOC string builtin__backtrace_current_executable_name(void);
2669-VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name);
2670-VV_LOC string builtin__backtrace_shell_quote(string s);
2671-VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes);
26722736 void builtin___v_exit(int code);
26732737 _result_void builtin__at_exit(void (*cb)());
26742738 VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number);
@@ -3113,6 +3177,134 @@ void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_);
31133177 void builtin__ArrayFlags_clear_all(ArrayFlags* e);
31143178 void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_);
31153179 ArrayFlags builtin__ArrayFlags__static__zero(void);
3180+f64 math__inf(int sign);
3181+f64 math__nan(void);
3182+bool math__is_nan(f64 f);
3183+bool math__is_inf(f64 f, int sign);
3184+bool math__is_finite(f64 f);
3185+multi_return_f64_int math__normalize(f64 x);
3186+f64 math__cbrt(f64 a);
3187+f64 math__mod(f64 x, f64 y);
3188+f64 math__fmod(f64 x, f64 y);
3189+i64 math__gcd(i64 a_, i64 b_);
3190+multi_return_i64_i64_i64 math__egcd(i64 a, i64 b);
3191+i64 math__lcm(i64 a, i64 b);
3192+f64 math__erf(f64 a);
3193+f64 math__erfc(f64 a);
3194+f64 math__exp(f64 x);
3195+f64 math__exp2(f64 x);
3196+f64 math__ldexp(f64 frac, int exp);
3197+f64 math__pure_v_but_overridden_by_c_exp(f64 x);
3198+f64 math__pure_v_but_overridden_by_c_exp2(f64 x);
3199+f64 math__pure_v_but_overridden_by_c_ldexp(f64 frac, int exp);
3200+multi_return_f64_int math__frexp(f64 x);
3201+f64 math__expm1(f64 x);
3202+VV_LOC f64 math__expmulti(f64 hi, f64 lo, int k);
3203+f64 math__factorial(f64 n);
3204+f64 math__log_factorial(f64 n);
3205+VV_LOC f64 math__log_factorial_asymptotic_expansion(int n);
3206+i64 math__factoriali(int n);
3207+f64 math__floor(f64 x);
3208+f32 math__floorf(f32 x);
3209+f64 math__ceil(f64 x);
3210+f64 math__trunc(f64 x);
3211+f64 math__round(f64 x);
3212+f64 math__round_sig(f64 x, int sig_digits);
3213+f64 math__round_to_even(f64 x);
3214+VV_LOC u64 math__safe_shift(u64 value, u64 shift);
3215+VV_LOC bool math__is_neg_int(f64 x);
3216+VV_LOC multi_return_f64_f64 math__stirling(f64 x);
3217+f64 math__gamma(f64 a);
3218+VV_LOC f64 math__gamma_too_small(f64 x, f64 z);
3219+f64 math__log_gamma(f64 x);
3220+multi_return_f64_int math__log_gamma_sign(f64 a);
3221+VV_LOC f64 math__sin_pi(f64 x_);
3222+f64 math__hypot(f64 x, f64 y);
3223+math__BezierPoint math__cubic_bezier(f64 t, Array_math__BezierPoint p);
3224+math__BezierPoint math__cubic_bezier_a(f64 t, Array_f64 x, Array_f64 y);
3225+math__BezierPoint math__cubic_bezier_fa(f64 t, Array_fixed_f64_4 x, Array_fixed_f64_4 y);
3226+math__BezierPoint math__cubic_bezier_coords(f64 t, f64 x0, f64 x1, f64 x2, f64 x3, f64 y0, f64 y1, f64 y2, f64 y3);
3227+f64 math__acosh(f64 x);
3228+f64 math__asinh(f64 x);
3229+f64 math__atanh(f64 x);
3230+VV_LOC f64 math__xatan(f64 x);
3231+VV_LOC f64 math__satan(f64 x);
3232+f64 math__atan(f64 x);
3233+f64 math__atan2(f64 y, f64 x);
3234+f64 math__asin(f64 x_);
3235+f64 math__acos(f64 x);
3236+f64 math__log(f64 x);
3237+f64 math__log2(f64 x);
3238+f64 math__log10(f64 x);
3239+f64 math__log1p(f64 x);
3240+f64 math__log_b(f64 x);
3241+f32 math__logf(f32 x);
3242+f64 math__log_n(f64 x, f64 b);
3243+f64 math__pure_v_but_overridden_by_c_log10(f64 x);
3244+f64 math__pure_v_but_overridden_by_c_log2(f64 x);
3245+f64 math__pure_v_but_overridden_by_c_log1p(f64 x);
3246+f64 math__pure_v_but_overridden_by_c_log_b(f64 x);
3247+int math__ilog_b(f64 x);
3248+VV_LOC int math__ilog_b_(f64 x_);
3249+f64 math__pure_v_but_overridden_by_c_log(f64 a);
3250+f64 math__aprox_sin(f64 a);
3251+f64 math__aprox_cos(f64 a);
3252+f64 math__copysign(f64 x, f64 y);
3253+f64 math__degrees(f64 radians);
3254+f64 math__radians(f64 degrees);
3255+f64 math__angle_diff(f64 radian_a, f64 radian_b);
3256+Array_int math__digits(i64 num, math__DigitParams params);
3257+int math__count_digits(i64 number);
3258+multi_return_f64_f64 math__minmax(f64 a, f64 b);
3259+f64 math__clamp(f64 x, f64 a, f64 b);
3260+f64 math__sign(f64 n);
3261+int math__signi(f64 n);
3262+bool math__signbit(f64 x);
3263+bool math__tolerance(f64 actual, f64 expected, f64 tol);
3264+bool math__close(f64 actual, f64 expected);
3265+bool math__veryclose(f64 actual, f64 expected);
3266+bool math__alike(f64 a, f64 b);
3267+multi_return_f64_f64 math__modf(f64 f);
3268+f32 math__nextafter32(f32 x, f32 y);
3269+f64 math__nextafter(f64 x, f64 y);
3270+VV_LOC multi_return_f64_f64 math__ChebSeries_eval_e(math__ChebSeries cs, f64 x);
3271+f64 math__pow(f64 x, f64 y);
3272+f32 math__powf(f32 a, f32 b);
3273+f32 math__pure_v_but_overridden_by_c_powf(f32 a, f32 b);
3274+f64 math__pow10(int n);
3275+i64 math__powi(i64 a, i64 b);
3276+VV_LOC bool math__is_odd_int(f64 x);
3277+f64 math__pure_v_but_overridden_by_c_pow(f64 x, f64 y);
3278+f64 math__q_rsqrt(f64 x);
3279+f64 math__scalbn(f64 x, int n_);
3280+f64 math__cos(f64 a);
3281+f64 math__sin(f64 a);
3282+f32 math__cosf(f32 a);
3283+f32 math__sinf(f32 a);
3284+f64 math__pure_v_but_overridden_by_c_sin(f64 x);
3285+f64 math__pure_v_but_overridden_by_c_cos(f64 x);
3286+f32 math__pure_v_but_overridden_by_c_cosf(f32 a);
3287+f32 math__pure_v_but_overridden_by_c_sinf(f32 a);
3288+multi_return_f64_f64 math__sincos(f64 x);
3289+f64 math__sinh(f64 x_);
3290+f64 math__cosh(f64 x);
3291+f64 math__sqrt(f64 a);
3292+f32 math__sqrtf(f32 a);
3293+f64 math__pure_v_but_overridden_by_c_sqrt(f64 a);
3294+f32 math__pure_v_but_overridden_by_c_sqrtf(f32 a);
3295+i64 math__sqrti(i64 a);
3296+f32 math__tanf(f32 a);
3297+f64 math__tan(f64 a);
3298+f32 math__pure_v_but_overridden_by_c_tanf(f32 a);
3299+f64 math__cot(f64 a);
3300+f64 math__tanh(f64 x);
3301+u32 math__f32_bits(f32 f);
3302+f32 math__f32_from_bits(u32 b);
3303+u64 math__f64_bits(f64 f);
3304+f64 math__f64_from_bits(u64 b);
3305+f64 math__with_set_low_word(f64 f, u32 lo);
3306+f64 math__with_set_high_word(f64 f, u32 hi);
3307+u32 math__get_high_word(f64 f);
31163308 VV_LOC void main__vf_init(void);
31173309 VV_EXP void vf_init(void); // exported fn main.vf_init
31183310 VV_LOC int main__vf_add(int a, int b);
@@ -3121,7 +3313,10 @@ VV_LOC char* main__vf_greet(char* name);
31213313 VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet
31223314 VV_LOC void main__vf_free(voidptr p);
31233315 VV_EXP void vf_free(voidptr p); // exported fn main.vf_free
3316+VV_LOC void main__vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1);
3317+VV_EXP void vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1); // exported fn main.vf_mandelbrot
31243318 VV_LOC void main__main(void);
3319+f64 math__abs_T_f64(f64 a);
31253320 static bool Array_rune_arr_eq(Array_rune a, Array_rune b);
31263321 static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b);
31273322 static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b);
@@ -3489,11 +3684,182 @@ static Array_fixed_i32_1264 _const_rune_maps = {((i32)(0xB5)), 0xB5, 743, 0, 0xC
34893684 static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed2
34903685 static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed2
34913686 static rune _const_utf8_replacement_rune; // inited later
3687+static const f64 _const_math__internal__f64_epsilon = 2.220446049250313e-16; // precomputed2
3688+static const f64 _const_math__internal__sqrt_f64_epsilon = 1.4901161193847656e-08; // precomputed2
3689+static const f64 _const_math__internal__root3_f64_epsilon = 6.055454452393343e-06; // precomputed2
3690+static const f64 _const_math__internal__root4_f64_epsilon = 0.0001220703125; // precomputed2
3691+static const f64 _const_math__internal__root5_f64_epsilon = 0.000740095979741405; // precomputed2
3692+static const f64 _const_math__internal__root6_f64_epsilon = 0.002460783300575925; // precomputed2
3693+static const f64 _const_math__internal__log_f64_epsilon = -36.04365338911715; // precomputed2
3694+static const f64 _const_math__internal__f64_min = 2.2250738585072014e-308; // precomputed2
3695+static const f64 _const_math__internal__sqrt_f64_min = 1.4916681462400413e-154; // precomputed2
3696+static const f64 _const_math__internal__root3_f64_min = 2.8126442852362996e-103; // precomputed2
3697+static const f64 _const_math__internal__root4_f64_min = 1.221338669755462e-77; // precomputed2
3698+static const f64 _const_math__internal__root5_f64_min = 2.9476022969691763e-62; // precomputed2
3699+static const f64 _const_math__internal__root6_f64_min = 5.303436890579822e-52; // precomputed2
3700+static const f64 _const_math__internal__log_f64_min = -708.3964185322641; // precomputed2
3701+static const f64 _const_math__internal__f64_max = 1.7976931348623157e+308; // precomputed2
3702+static const f64 _const_math__internal__sqrt_f64_max = 1.3407807929942596e+154; // precomputed2
3703+static const f64 _const_math__internal__root3_f64_max = 5.64380309412229e+102; // precomputed2
3704+static const f64 _const_math__internal__root4_f64_max = 1.157920892373162e+77; // precomputed2
3705+static const f64 _const_math__internal__root5_f64_max = 4.4765466227572707e+61; // precomputed2
3706+static const f64 _const_math__internal__root6_f64_max = 2.3756689782295612e+51; // precomputed2
3707+static const f64 _const_math__internal__log_f64_max = 709.782712893384; // precomputed2
3708+static const f64 _const_math__internal__f32_epsilon = 1.1920928955078125e-07; // precomputed2
3709+static const f64 _const_math__internal__sqrt_f32_epsilon = 0.00034526698300124393; // precomputed2
3710+static const f64 _const_math__internal__root3_f32_epsilon = 0.00492156660115185; // precomputed2
3711+static const f64 _const_math__internal__root4_f32_epsilon = 0.018581361171917516; // precomputed2
3712+static const f64 _const_math__internal__root5_f32_epsilon = 0.04123462221165294; // precomputed2
3713+static const f64 _const_math__internal__root6_f32_epsilon = 0.07015387801933583; // precomputed2
3714+static const f64 _const_math__internal__log_f32_epsilon = -15.942385152878742; // precomputed2
3715+static const f64 _const_math__internal__f32_min = 1.1754943508222875e-38; // precomputed2
3716+static const f64 _const_math__internal__sqrt_f32_min = 1.0842021724855044e-19; // precomputed2
3717+static const f64 _const_math__internal__root3_f32_min = 2.273736754432324e-13; // precomputed2
3718+static const f64 _const_math__internal__root4_f32_min = 3.2927225399135965e-10; // precomputed2
3719+static const f64 _const_math__internal__root5_f32_min = 2.5944428542140822e-08; // precomputed2
3720+static const f64 _const_math__internal__root6_f32_min = 4.768371582031254e-07; // precomputed2
3721+static const f64 _const_math__internal__log_f32_min = -87.3365447505531; // precomputed2
3722+static const f64 _const_math__internal__f32_max = 3.4028234663852886e+38; // precomputed2
3723+static const f64 _const_math__internal__sqrt_f32_max = 1.844674352395373e+19; // precomputed2
3724+static const f64 _const_math__internal__root3_f32_max = 6.981463519622324e+12; // precomputed2
3725+static const f64 _const_math__internal__root4_f32_max = 4.2949672319999986e+09; // precomputed2
3726+static const f64 _const_math__internal__root5_f32_max = 5.085900785596004e+07; // precomputed2
3727+static const f64 _const_math__internal__root6_f32_max = 2.642245923380775e+06; // precomputed2
3728+static const f64 _const_math__internal__log_f32_max = 88.72283905206835; // precomputed2
3729+static const f64 _const_math__internal__sflt_epsilon = 0.00048828125; // precomputed2
3730+static const f64 _const_math__internal__sqrt_sflt_epsilon = 0.02209708691207961; // precomputed2
3731+static const f64 _const_math__internal__root3_sflt_epsilon = 0.07874506561842959; // precomputed2
3732+static const f64 _const_math__internal__root4_sflt_epsilon = 0.14865088937534013; // precomputed2
3733+static const f64 _const_math__internal__root5_sflt_epsilon = 0.217637640824031; // precomputed2
3734+static const f64 _const_math__internal__root6_sflt_epsilon = 0.28061551207734325; // precomputed2
3735+static const f64 _const_math__internal__log_sflt_epsilon = -7.6246189861593985; // precomputed2
3736+static const f64 _const_math__internal__max_f64_fact_arg = 171.0; // precomputed2
3737+static const f64 _const_math__internal__max_long_f64_fact_arg = 1755.5; // precomputed2
3738+static const u64 _const_math__uvnan = 9221120237041090561U; // precomputed2
3739+static const u64 _const_math__uvinf = 9218868437227405312U; // precomputed2
3740+static const u64 _const_math__uvneginf = 18442240474082181120U; // precomputed2
3741+static const u64 _const_math__uvone = 4607182418800017408U; // precomputed2
3742+static const u64 _const_math__normalize_smallest_mask = 4503599627370496U; // precomputed2
3743+static const u64 _const_math__sign_mask = 9223372036854775808U; // precomputed2
3744+static const u64 _const_math__frac_mask = 4503599627370495U; // precomputed2
3745+static const f64 _const_math__epsilon = 2.220446049250313e-16; // precomputed2
3746+static const f64 _const_math__e = 2.718281828459045; // precomputed2
3747+static const f64 _const_math__pi = 3.141592653589793; // precomputed2
3748+static const f64 _const_math__phi = 1.618033988749895; // precomputed2
3749+static const f64 _const_math__tau = 6.283185307179586; // precomputed2
3750+static const f64 _const_math__sqrt2 = 1.4142135623730951; // precomputed2
3751+static const f64 _const_math__sqrt_3 = 1.7320508075688772; // precomputed2
3752+static const f64 _const_math__sqrt_5 = 2.23606797749979; // precomputed2
3753+static const f64 _const_math__sqrt_e = 1.6487212707001282; // precomputed2
3754+static const f64 _const_math__sqrt_pi = 1.772453850905516; // precomputed2
3755+static const f64 _const_math__sqrt_tau = 2.5066282746310007; // precomputed2
3756+static const f64 _const_math__sqrt_phi = 1.272019649514069; // precomputed2
3757+static const f64 _const_math__ln2 = 0.6931471805599453; // precomputed2
3758+static const f64 _const_math__ln10 = 2.302585092994046; // precomputed2
3759+static const f64 _const_math__two_thirds = 0.6666666666666666; // precomputed2
3760+static const f64 _const_math__max_f32 = 3.4028234663852886e+38; // precomputed2
3761+static const f64 _const_math__smallest_non_zero_f32 = 1.401298464324817e-45; // precomputed2
3762+static const f64 _const_math__max_f64 = 1.7976931348623157e+308; // precomputed2
3763+static const f64 _const_math__smallest_non_zero_f64 = 0.0; // precomputed2
3764+static const f64 _const_math__erx = 0.8450629115104675; // precomputed2
3765+static const f64 _const_math__efx = 0.1283791670955126; // precomputed2
3766+static const f64 _const_math__efx8 = 1.0270333367641007; // precomputed2
3767+static const f64 _const_math__pp0 = 0.12837916709551256; // precomputed2
3768+static const f64 _const_math__pp1 = -0.3250421072470015; // precomputed2
3769+static const f64 _const_math__pp2 = -0.02848174957559851; // precomputed2
3770+static const f64 _const_math__pp3 = -0.005770270296489442; // precomputed2
3771+static const f64 _const_math__pp4 = -2.3763016656650163e-05; // precomputed2
3772+static const f64 _const_math__qq1 = 0.39791722395915535; // precomputed2
3773+static const f64 _const_math__qq2 = 0.0650222499887673; // precomputed2
3774+static const f64 _const_math__qq3 = 0.005081306281875766; // precomputed2
3775+static const f64 _const_math__qq4 = 0.00013249473800432164; // precomputed2
3776+static const f64 _const_math__qq5 = -3.960228278775368e-06; // precomputed2
3777+static const f64 _const_math__pa0 = -0.0023621185607526594; // precomputed2
3778+static const f64 _const_math__pa1 = 0.41485611868374833; // precomputed2
3779+static const f64 _const_math__pa2 = -0.3722078760357013; // precomputed2
3780+static const f64 _const_math__pa3 = 0.31834661990116175; // precomputed2
3781+static const f64 _const_math__pa4 = -0.11089469428239668; // precomputed2
3782+static const f64 _const_math__pa5 = 0.035478304325618236; // precomputed2
3783+static const f64 _const_math__pa6 = -0.002166375594868791; // precomputed2
3784+static const f64 _const_math__qa1 = 0.10642088040084423; // precomputed2
3785+static const f64 _const_math__qa2 = 0.540397917702171; // precomputed2
3786+static const f64 _const_math__qa3 = 0.07182865441419627; // precomputed2
3787+static const f64 _const_math__qa4 = 0.12617121980876164; // precomputed2
3788+static const f64 _const_math__qa5 = 0.01363708391202905; // precomputed2
3789+static const f64 _const_math__qa6 = 0.011984499846799107; // precomputed2
3790+static const f64 _const_math__ra0 = -0.009864944034847148; // precomputed2
3791+static const f64 _const_math__ra1 = -0.6938585727071818; // precomputed2
3792+static const f64 _const_math__ra2 = -10.558626225323291; // precomputed2
3793+static const f64 _const_math__ra3 = -62.375332450326006; // precomputed2
3794+static const f64 _const_math__ra4 = -162.39666946257347; // precomputed2
3795+static const f64 _const_math__ra5 = -184.60509290671104; // precomputed2
3796+static const f64 _const_math__ra6 = -81.2874355063066; // precomputed2
3797+static const f64 _const_math__ra7 = -9.814329344169145; // precomputed2
3798+static const f64 _const_math__sa1 = 19.651271667439257; // precomputed2
3799+static const f64 _const_math__sa2 = 137.65775414351904; // precomputed2
3800+static const f64 _const_math__sa3 = 434.56587747522923; // precomputed2
3801+static const f64 _const_math__sa4 = 645.3872717332679; // precomputed2
3802+static const f64 _const_math__sa5 = 429.00814002756783; // precomputed2
3803+static const f64 _const_math__sa6 = 108.63500554177944; // precomputed2
3804+static const f64 _const_math__sa7 = 6.570249770319282; // precomputed2
3805+static const f64 _const_math__sa8 = -0.0604244152148581; // precomputed2
3806+static const f64 _const_math__rb0 = -0.0098649429247001; // precomputed2
3807+static const f64 _const_math__rb1 = -0.799283237680523; // precomputed2
3808+static const f64 _const_math__rb2 = -17.757954917754752; // precomputed2
3809+static const f64 _const_math__rb3 = -160.63638485582192; // precomputed2
3810+static const f64 _const_math__rb4 = -637.5664433683896; // precomputed2
3811+static const f64 _const_math__rb5 = -1025.0951316110772; // precomputed2
3812+static const f64 _const_math__rb6 = -483.5191916086514; // precomputed2
3813+static const f64 _const_math__sb1 = 30.33806074348246; // precomputed2
3814+static const f64 _const_math__sb2 = 325.7925129965739; // precomputed2
3815+static const f64 _const_math__sb3 = 1536.729586084437; // precomputed2
3816+static const f64 _const_math__sb4 = 3199.8582195085955; // precomputed2
3817+static const f64 _const_math__sb5 = 2553.0504064331644; // precomputed2
3818+static const f64 _const_math__sb6 = 474.52854120695537; // precomputed2
3819+static const f64 _const_math__sb7 = -22.44095244658582; // precomputed2
3820+static const f64 _const_math__ln2hi = 0.6931471803691238; // precomputed2
3821+static const f64 _const_math__ln2lo = 1.9082149292705877e-10; // precomputed2
3822+static const f64 _const_math__log_sqrt_2pi = 0.9189385332046728; // precomputed2
3823+static Array_f64 _const_math__bernoulli; // inited later
3824+static Array_f64 _const_math__factorials_table; // inited later
3825+static Array_f64 _const_math__log_factorials_table; // inited later
3826+static Array_f64 _const_math__gamma_p; // inited later
3827+static Array_f64 _const_math__gamma_q; // inited later
3828+static Array_f64 _const_math__gamma_s; // inited later
3829+static Array_f64 _const_math__lgamma_a; // inited later
3830+static Array_f64 _const_math__lgamma_r; // inited later
3831+static Array_f64 _const_math__lgamma_s; // inited later
3832+static Array_f64 _const_math__lgamma_t; // inited later
3833+static Array_f64 _const_math__lgamma_u; // inited later
3834+static Array_f64 _const_math__lgamma_v; // inited later
3835+static Array_f64 _const_math__lgamma_w; // inited later
3836+static const f64 _const_math__morebits = 6.123233995736766e-17; // precomputed2
3837+static const f64 _const_math__tan3pio8 = 2.414213562373095; // precomputed2
3838+static const f64 _const_math__two54 = 1.8014398509481984e+16; // precomputed2
3839+static const f64 _const_math__ivln10 = 0.4342944819032518; // precomputed2
3840+static const f64 _const_math__log10_2hi = 0.30102999566361177; // precomputed2
3841+static const f64 _const_math__log10_2lo = 3.694239077158931e-13; // precomputed2
3842+static const f64 _const_math__modf_maxpowtwo = 4.503599627370496e+15; // precomputed2
3843+static Array_f64 _const_math__pow10tab; // inited later
3844+static Array_f64 _const_math__pow10postab32; // inited later
3845+static Array_f64 _const_math__pow10negtab32; // inited later
3846+static Array_f64 _const_math__sin_data; // inited later
3847+static Array_f64 _const_math__cos_data; // inited later
3848+static Array_f64 _const_math__tan_p; // inited later
3849+static Array_f64 _const_math__tan_q; // inited later
3850+static const f64 _const_math__tan_dp1 = 0.7853981554508209; // precomputed2
3851+static const f64 _const_math__tan_dp2 = 7.946627356147928e-09; // precomputed2
3852+static const f64 _const_math__tan_dp3 = 3.061616997868383e-17; // precomputed2
3853+static const f64 _const_math__tan_lossth = 1.073741824e+09; // precomputed2
3854+static Array_f64 _const_math__tanh_p; // inited later
3855+static Array_f64 _const_math__tanh_q; // inited later
34923856 static u32 _const_builtin__closure__closure_size_1; // inited later
34933857 Array_fixed_int_64 g_autostr_type_stack = {0}; // global 6
34943858
34953859 Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 6
34963860
3861+static math__ChebSeries _const_math__sin_cs; // inited later
3862+static math__ChebSeries _const_math__cos_cs; // inited later
34973863 static int _const_builtin__closure__closure_size; // inited later
34983864
34993865 // V interface table:
@@ -5044,7 +5410,6 @@ inline int math__bits__leading_zeros_8(u8 x) {
50445410 }
50455411 #elif !defined(__TINYC__)
50465412 {
5047- return __builtin_clz(((u32)(x))) - 24;
50485413 }
50495414 #endif
50505415 return math__bits__leading_zeros_8_default(x);
@@ -5058,7 +5423,6 @@ inline int math__bits__leading_zeros_16(u16 x) {
50585423 }
50595424 #elif !defined(__TINYC__)
50605425 {
5061- return __builtin_clz(((u32)(x))) - 16;
50625426 }
50635427 #endif
50645428 return math__bits__leading_zeros_16_default(x);
@@ -5072,7 +5436,6 @@ inline int math__bits__leading_zeros_32(u32 x) {
50725436 }
50735437 #elif !defined(__TINYC__)
50745438 {
5075- return __builtin_clz(x);
50765439 }
50775440 #endif
50785441 return math__bits__leading_zeros_32_default(x);
@@ -5086,7 +5449,6 @@ inline int math__bits__leading_zeros_64(u64 x) {
50865449 }
50875450 #elif !defined(__TINYC__)
50885451 {
5089- return __builtin_clzll(x);
50905452 }
50915453 #endif
50925454 return math__bits__leading_zeros_64_default(x);
@@ -5100,7 +5462,6 @@ inline int math__bits__trailing_zeros_8(u8 x) {
51005462 }
51015463 #elif !defined(__TINYC__)
51025464 {
5103- return __builtin_ctz(((u32)(x)));
51045465 }
51055466 #endif
51065467 return math__bits__trailing_zeros_8_default(x);
@@ -5114,7 +5475,6 @@ inline int math__bits__trailing_zeros_16(u16 x) {
51145475 }
51155476 #elif !defined(__TINYC__)
51165477 {
5117- return __builtin_ctz(((u32)(x)));
51185478 }
51195479 #endif
51205480 return math__bits__trailing_zeros_16_default(x);
@@ -5128,7 +5488,6 @@ inline int math__bits__trailing_zeros_32(u32 x) {
51285488 }
51295489 #elif !defined(__TINYC__)
51305490 {
5131- return __builtin_ctz(x);
51325491 }
51335492 #endif
51345493 return math__bits__trailing_zeros_32_default(x);
@@ -5142,7 +5501,6 @@ inline int math__bits__trailing_zeros_64(u64 x) {
51425501 }
51435502 #elif !defined(__TINYC__)
51445503 {
5145- return __builtin_ctzll(x);
51465504 }
51475505 #endif
51485506 return math__bits__trailing_zeros_64_default(x);
@@ -5153,7 +5511,6 @@ inline int math__bits__ones_count_8(u8 x) {
51535511 }
51545512 #elif !defined(__TINYC__)
51555513 {
5156- return __builtin_popcount(((u32)(x)));
51575514 }
51585515 #endif
51595516 return math__bits__ones_count_8_default(x);
@@ -5164,7 +5521,6 @@ inline int math__bits__ones_count_16(u16 x) {
51645521 }
51655522 #elif !defined(__TINYC__)
51665523 {
5167- return __builtin_popcount(((u32)(x)));
51685524 }
51695525 #endif
51705526 return math__bits__ones_count_16_default(x);
@@ -5175,7 +5531,6 @@ inline int math__bits__ones_count_32(u32 x) {
51755531 }
51765532 #elif !defined(__TINYC__)
51775533 {
5178- return __builtin_popcount(x);
51795534 }
51805535 #endif
51815536 return math__bits__ones_count_32_default(x);
@@ -5186,7 +5541,6 @@ inline int math__bits__ones_count_64(u64 x) {
51865541 }
51875542 #elif !defined(__TINYC__)
51885543 {
5189- return __builtin_popcountll(x);
51905544 }
51915545 #endif
51925546 return math__bits__ones_count_64_default(x);
@@ -10152,226 +10506,18 @@ VV_LOC string builtin__autostr_array_circular(int len) {
1015210506 return res;
1015310507 }
1015410508 void builtin__print_backtrace(void) {
10155- #if !defined(CUSTOM_DEFINE_no_backtrace)
10156- {
10157- #if 0
10158- {
10159- }
10160- #elif defined(__TINYC__)
10161- {
10162- }
10163- #elif defined(CUSTOM_DEFINE_use_libbacktrace)
10164- {
10165- }
10166- #else
10167- {
10168- builtin__print_backtrace_skipping_top_frames(2);
10169- }
10170- #endif
10171- }
10172- #endif
10173-}
10174-VV_LOC string builtin__demangle_v_symbol(string cname) {
10175- string name = cname;
10176- if (builtin__string_starts_with(name, _S("builtin__"))) {
10177- name = builtin__string_substr(name, 9, 2147483647);
10178- }
10179- name = builtin__string_replace(name, _S("__ptr__"), _S("&"));
10180- _option_int _t1 = builtin__string_index(name, _S("_T_"));
10181- if (_t1.state != 0) {
10182- *(int*) _t1.data = -1;
10183- }
10184-
10185- int t_pos = (*(int*)_t1.data);
10186- if (t_pos >= 0) {
10187- string base = builtin__string_replace(builtin__string_substr(name, 0, t_pos), _S("__"), _S("."));
10188- string generic_suffix = builtin__string_substr(name, t_pos + 3, 2147483647);
10189- Array_string params = builtin__split_generic_params(generic_suffix);
10190- Array_string demangled_params = builtin____new_array_with_default(0, params.len, sizeof(string), 0);
10191- for (int _t2 = 0; _t2 < params.len; ++_t2) {
10192- string param = ((string*)params.data)[_t2];
10193- builtin__array_push((array*)&demangled_params, _MOV((string[]){ builtin__string_replace(param, _S("__"), _S(".")) }));
10194- }
10195- return builtin__string_plus_many(4, _MOV((string[4]){base, _S("["), Array_string_join(demangled_params, _S(", ")), _S("]")}));
10196- }
10197- name = builtin__string_replace(name, _S("__"), _S("."));
10198- if (_SLIT_EQ(name.str, name.len, "main.main")) {
10199- return _S("main");
10200- }
10201- return name;
10202-}
10203-VV_LOC Array_string builtin__split_generic_params(string s) {
10204- Array_string params = builtin____new_array_with_default(0, 0, sizeof(string), 0);
10205- int start = 0;
10206- int i = 0;
10207- for (;;) {
10208- if (!(i < s.len)) break;
10209- if (s.str[ i] == '_') {
10210- if (i + 1 < s.len && s.str[ i + 1] == '_') {
10211- i += 2;
10212- } else {
10213- if (i > start) {
10214- builtin__array_push((array*)&params, _MOV((string[]){ builtin__string_substr(s, start, i) }));
10215- }
10216- i++;
10217- start = i;
10218- }
10219- } else {
10220- i++;
10221- }
10222- }
10223- if (start < s.len) {
10224- builtin__array_push((array*)&params, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) }));
10225- }
10226- return params;
10227-}
10228-VV_LOC string builtin__demangle_backtrace_sym(string s) {
10229- _option_int _t1 = builtin__string_index(s, _S("("));
10230- if (_t1.state != 0) {
10231- return s;
10232- }
10233-
10234- int paren_start = (*(int*)_t1.data);
10235- int plus_pos = builtin__string_index_after_(s, _S("+"), paren_start);
10236- if (plus_pos < 0) {
10237- return s;
10238- }
10239- string symbol = builtin__string_substr(s, paren_start + 1, plus_pos);
10240- if (symbol.len == 0) {
10241- return s;
10242- }
10243- return builtin__string_plus_many(3, _MOV((string[3]){builtin__string_substr(s, 0, paren_start + 1), builtin__demangle_v_symbol(symbol), builtin__string_substr(s, plus_pos, 2147483647)}));
10244-}
10245-VV_LOC void builtin__eprint_space_padding(string output, int max_len) {
10246- int padding_len = max_len - output.len;
10247- if (padding_len > 0) {
10248- for (int _t1 = 0; _t1 < padding_len; ++_t1) {
10249- builtin__eprint(_S(" "));
10250- }
10251- }
1025210509 }
1025310510 bool builtin__print_backtrace_skipping_top_frames(int xskipframes) {
1025410511 #if defined(CUSTOM_DEFINE_no_backtrace)
1025510512 {
10513+ return false;
1025610514 }
1025710515 #else
1025810516 {
10259- int skipframes = xskipframes + 2;
10260- #if 0
10261- {
10262- }
10263- #elif 1
10264- {
10265- return builtin__print_backtrace_skipping_top_frames_linux(skipframes);
10266- }
10267- #else
10268- {
10269- }
10270- #endif
1027110517 }
1027210518 #endif
1027310519 return false;
1027410520 }
10275-VV_LOC string builtin__backtrace_current_executable_name(void) {
10276- Array_string args = builtin__arguments();
10277- if (args.len == 0) {
10278- return _S("");
10279- }
10280- return (*(string*)builtin__array_get(args, 0));
10281-}
10282-VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name) {
10283- if (executable.len == 0) {
10284- return _S("/proc/self/exe");
10285- }
10286- if (builtin__string_contains(executable, _S("/"))) {
10287- return executable;
10288- }
10289- if (current_executable_name.len > 0 && builtin__string__eq(builtin__string_all_after_last(executable, _S("/")), builtin__string_all_after_last(current_executable_name, _S("/")))) {
10290- return _S("/proc/self/exe");
10291- }
10292- return executable;
10293-}
10294-VV_LOC string builtin__backtrace_shell_quote(string s) {
10295- string quoted = _S("'");
10296- for (int i = 0; i < s.len; ++i) {
10297- if (builtin__string_at(s, i) == '\'') {
10298- quoted = builtin__string__plus(quoted, _S("'\\''"));
10299- } else {
10300- quoted = builtin__string__plus(quoted, builtin__u8_ascii_str(builtin__string_at(s, i)));
10301- }
10302- }
10303- return builtin__string__plus(quoted, _S("'"));
10304-}
10305-VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes) {
10306- #if defined(CUSTOM_DEFINE_no_backtrace)
10307- {
10308- }
10309- #else
10310- {
10311- #if 1
10312- {
10313- #if 0
10314- {
10315- }
10316- #else
10317- {
10318- string current_executable_name = builtin__backtrace_current_executable_name();
10319- Array_fixed_voidptr_100 buffer = {0};
10320- i32 nr_ptrs = backtrace(&buffer[0], 100);
10321- if (nr_ptrs < 2) {
10322- builtin__eprintln(_S("C.backtrace returned less than 2 frames"));
10323- return false;
10324- }
10325- int nr_actual_frames = (int)(nr_ptrs - skipframes);
10326- char** csymbols = backtrace_symbols(((voidptr)(&buffer[skipframes])), nr_actual_frames);
10327- for (int i = 0; i < nr_actual_frames; ++i) {
10328- string sframe = builtin__tos2(((u8*)(csymbols[i])));
10329- string executable = builtin__string_all_before(sframe, _S("("));
10330- string addr2line_executable = builtin__backtrace_addr2line_executable(executable, current_executable_name);
10331- string addr = builtin__string_all_before(builtin__string_all_after(sframe, _S("[")), _S("]"));
10332- string beforeaddr = builtin__string_all_before(sframe, _S("["));
10333- string cmd = builtin__string_plus_many(4, _MOV((string[4]){_S("addr2line -e "), builtin__backtrace_shell_quote(addr2line_executable), _S(" "), builtin__backtrace_shell_quote(addr)}));
10334- voidptr f = popen(((char*)(cmd.str)), "r");
10335- if (f == ((void*)0)) {
10336- builtin__eprintln(sframe);
10337- continue;
10338- }
10339- Array_fixed_u8_1000 buf = {0};
10340- string output = _S("");
10341- { // Unsafe block
10342- u8* bp = ((u8*)(&buf[0]));
10343- for (;;) {
10344- if (!(fgets(((char*)(bp)), 1000, f) != 0)) break;
10345- output = builtin__string__plus(output, builtin__tos(bp, builtin__vstrlen(bp)));
10346- }
10347- }
10348- output = builtin__string__plus(builtin__string_trim_chars(output, _S(" \t\n"), TrimMode__trim_both), _S(":"));
10349- if (pclose(f) != 0) {
10350- builtin__eprintln(sframe);
10351- continue;
10352- }
10353- if (_SLIT_EQ(output.str, output.len, "??:0:") || _SLIT_EQ(output.str, output.len, "??:?:")) {
10354- output = _S("");
10355- }
10356- output = builtin__string_replace(output, _S(" (discriminator"), _S(": (d."));
10357- builtin__eprint(output);
10358- builtin__eprint_space_padding(output, 55);
10359- builtin__eprint(_S(" | "));
10360- builtin__eprint(addr);
10361- builtin__eprint(_S(" | "));
10362- builtin__eprintln(builtin__demangle_backtrace_sym(beforeaddr));
10363- }
10364- if (nr_actual_frames > 0) {
10365- free(csymbols);
10366- }
10367- }
10368- #endif
10369- }
10370- #endif
10371- }
10372- #endif
10373- return true;
10374-}
1037510521 VNORETURN void builtin___v_exit(int code) {
1037610522 exit(code);
1037710523 VUNREACHABLE();
@@ -10410,12 +10556,12 @@ VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number) {
1041010556 #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)
1041110557 {
1041210558 }
10413- #elif 0
10559+ #elif 1
1041410560 {
10561+ builtin__print_backtrace_skipping_top_frames(1);
1041510562 }
1041610563 #else
1041710564 {
10418- builtin__print_backtrace();
1041910565 }
1042010566 #endif
1042110567 builtin___v_exit(128 + signal_number);
@@ -10489,7 +10635,7 @@ Array_string builtin__arguments(void) {
1048910635 return res;
1049010636 }
1049110637 string builtin__vcurrent_hash(void) {
10492- return _S("");
10638+ return _S("7647ce1");
1049310639 }
1049410640 u64 builtin__v_getpid(void) {
1049510641 #if defined(CUSTOM_DEFINE_no_getpid)
@@ -12451,22 +12597,14 @@ VNORETURN void builtin___v_panic(string s) {
1245112597 }
1245212598 #elif defined(CUSTOM_DEFINE_no_backtrace)
1245312599 {
12600+ exit(1);
12601+ VUNREACHABLE();
1245412602 }
1245512603 #elif 0
1245612604 {
1245712605 }
1245812606 #else
1245912607 {
12460- #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)
12461- {
12462- }
12463- #else
12464- {
12465- builtin__print_backtrace_skipping_top_frames(1);
12466- }
12467- #endif
12468- exit(1);
12469- VUNREACHABLE();
1247012608 }
1247112609 #endif
1247212610 }
@@ -16443,78 +16581,2188 @@ inline void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_) {
1644316581 inline ArrayFlags builtin__ArrayFlags__static__zero(void) {
1644416582 return ((ArrayFlags)(0));
1644516583 }
16446-VV_LOC void main__vf_init(void) {
16447- string probe = _S("vf");
16448- {int _ = probe.len;}
16449- ;
16450-}
16451-// export alias: vf_init -> main__vf_init
16452-void vf_init(void) {
16453- return main__vf_init();
16584+f64 math__inf(int sign) {
16585+ u64 v = (sign >= 0 ? (_const_math__uvinf) : (_const_math__uvneginf));
16586+ return math__f64_from_bits(v);
1645416587 }
16455-VV_LOC int main__vf_add(int a, int b) {
16456- return a + b;
16588+f64 math__nan(void) {
16589+ return math__f64_from_bits(_const_math__uvnan);
1645716590 }
16458-// export alias: vf_add -> main__vf_add
16459-int vf_add(int a, int b) {
16460- return main__vf_add(a, b);
16591+bool math__is_nan(f64 f) {
16592+ return f != f;
1646116593 }
16462-VV_LOC char* main__vf_greet(char* name) {
16463- string n = builtin__cstring_to_vstring(name);
16464- string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")}));
16465- u8* out = res.str;
16466- builtin__string_free(&n);
16467- return out;
16594+bool math__is_inf(f64 f, int sign) {
16595+ return (sign >= 0 && f > ((f64)(_const_math__max_f64))) || (sign <= 0 && f < ((f64)(-_const_math__max_f64)));
1646816596 }
16469-// export alias: vf_greet -> main__vf_greet
16470-char* vf_greet(char* name) {
16471- return main__vf_greet(name);
16597+bool math__is_finite(f64 f) {
16598+ return !math__is_nan(f) && !math__is_inf(f, 0);
1647216599 }
16473-VV_LOC void main__vf_free(voidptr p) {
16474- builtin___v_free(p);
16600+multi_return_f64_int math__normalize(f64 x) {
16601+ f64 smallest_normal = 2.2250738585072014e-308;
16602+ if (math__abs_T_f64(x) < smallest_normal) {
16603+ return (multi_return_f64_int){.arg0=(f64)(x * _const_math__normalize_smallest_mask), .arg1=-52};
16604+ }
16605+ return (multi_return_f64_int){.arg0=x, .arg1=0};
1647516606 }
16476-// export alias: vf_free -> main__vf_free
16477-void vf_free(voidptr p) {
16478- return main__vf_free(p);
16607+f64 math__cbrt(f64 a) {
16608+ f64 x = a;
16609+ int b1 = 715094163;
16610+ int b2 = 696219795;
16611+ f64 c = 5.42857142857142815906e-01;
16612+ f64 d = -7.05306122448979611050e-01;
16613+ f64 e_ = 1.41428571428571436819e+00;
16614+ f64 f = 1.60714285714285720630e+00;
16615+ f64 g = 3.57142857142857150787e-01;
16616+ f64 smallest_normal = 2.22507385850720138309e-308;
16617+ if (x == ((f64)(0.0)) || math__is_nan(x) || math__is_inf(x, 0)) {
16618+ return x;
16619+ }
16620+ bool neg = false;
16621+ if (x < 0) {
16622+ x = -x;
16623+ neg = true;
16624+ }
16625+ f64 t = math__f64_from_bits(VSAFE_DIV_u64(math__f64_bits(x) , ((u64)(3))) + (v__lshift_u64(((u64)(b1)), (u64)32)));
16626+ if (x < smallest_normal) {
16627+ t = ((f64)(v__lshift_u64(((u64)(1)), (u64)54)));
16628+ t *= x;
16629+ t = math__f64_from_bits(VSAFE_DIV_u64(math__f64_bits(t) , ((u64)(3))) + (v__lshift_u64(((u64)(b2)), (u64)32)));
16630+ }
16631+ f64 r = t * t / x;
16632+ f64 s = c + r * t;
16633+ t *= g + f / (s + e_ + d / s);
16634+ t = math__f64_from_bits((math__f64_bits(t) & (v__lshift_u64(((u64)(0xffffffffcLL)), (u64)28))) + (v__lshift_u64(((u64)(1)), (u64)30)));
16635+ s = t * t;
16636+ r = x / s;
16637+ f64 w = t + t;
16638+ r = (r - t) / (w + r);
16639+ t = t + t * r;
16640+ if (neg) {
16641+ t = -t;
16642+ }
16643+ return t;
1647916644 }
16480-VV_LOC void main__main(void) {
16645+f64 math__mod(f64 x, f64 y) {
16646+ return math__fmod(x, y);
1648116647 }
16482-void _vinit(int ___argc, voidptr ___argv) {
16483- static bool once = false; if (once) {return;} once = true;
16484- // Initializations of consts for module builtin.closure
16485- g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3
16486-{
16487-{
16488-Array_fixed_u8_15 _t1;
16489-#if defined(__V_ppc64le)
16490-#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
16491-#elif defined(__V_amd64)
16492- { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ;
16493- memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15));
16648+f64 math__fmod(f64 x, f64 y) {
16649+ if (y == 0 || math__is_inf(x, 0) || math__is_nan(x) || math__is_nan(y)) {
16650+ return math__nan();
1649416651 }
16495- ;
16496-#elif defined(__V_x86)
16497-#elif defined(__V_arm64)
16498-#elif defined(__V_arm32)
16499-#elif defined(__V_rv64)
16500-#elif defined(__V_rv32)
16501-#elif defined(__V_s390x)
16502-#elif defined(__V_loongarch64)
16503-#elif defined(__V_sparc64)
16504-#elif 0
16505-#else
16506-#endif
16507- memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15));
16652+ f64 abs_y = math__abs_T_f64(y);
16653+ multi_return_f64_int mr_594 = math__frexp(abs_y);
16654+ f64 abs_y_fr = mr_594.arg0;
16655+ int abs_y_exp = mr_594.arg1;
16656+ f64 r = x;
16657+ if (x < 0) {
16658+ r = -x;
16659+ }
16660+ for (;;) {
16661+ if (!(r >= abs_y)) break;
16662+ multi_return_f64_int mr_680 = math__frexp(r);
16663+ f64 rfr = mr_680.arg0;
16664+ int rexp = mr_680.arg1;
16665+ if (rfr < abs_y_fr) {
16666+ rexp = rexp - 1;
16667+ }
16668+ r = r - math__ldexp(abs_y, rexp - abs_y_exp);
16669+ }
16670+ if (x < 0) {
16671+ r = -r;
16672+ }
16673+ return r;
1650816674 }
16675+i64 math__gcd(i64 a_, i64 b_) {
16676+ i64 a = a_;
16677+ i64 b = b_;
16678+ if (a < 0) {
16679+ a = -a;
16680+ }
16681+ if (b < 0) {
16682+ b = -b;
16683+ }
16684+ for (;;) {
16685+ if (!(b != 0)) break;
16686+ a = VSAFE_MOD_i64(a,b);
16687+ if (a == 0) {
16688+ return b;
16689+ }
16690+ b = VSAFE_MOD_i64(b,a);
16691+ }
16692+ return a;
1650916693 }
16510-{
16511-{
16512-Array_fixed_u8_6 _t3;
16513-#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
16514-#elif defined(__V_arm32)
16515-#elif defined(__V_amd64)
16516- { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ;
16517- memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6));
16694+multi_return_i64_i64_i64 math__egcd(i64 a, i64 b) {
16695+ i64 old_r = a;
16696+ i64 r = b;
16697+ i64 old_s = ((i64)(1));
16698+ i64 s = ((i64)(0));
16699+ i64 old_t = ((i64)(0));
16700+ i64 t = ((i64)(1));
16701+ for (;;) {
16702+ if (!(r != 0)) break;
16703+ i64 quot = VSAFE_DIV_i64(old_r , r);
16704+ i64 _var_1339 = old_r;
16705+ i64 _var_1346 = r;
16706+ old_r = _var_1346;
16707+ r = _var_1339%_var_1346;
16708+ i64 _var_1365 = old_s;
16709+ i64 _var_1372 = s;
16710+ old_s = _var_1372;
16711+ s = _var_1365-quot*_var_1372;
16712+ i64 _var_1398 = old_t;
16713+ i64 _var_1405 = t;
16714+ old_t = _var_1405;
16715+ t = _var_1398-quot*_var_1405;
16716+ }
16717+ return (multi_return_i64_i64_i64){.arg0=(old_r < 0 ? (-old_r) : (old_r)), .arg1=old_s, .arg2=old_t};
16718+}
16719+i64 math__lcm(i64 a, i64 b) {
16720+ if (a == 0) {
16721+ return a;
16722+ }
16723+ i64 res = a * (VSAFE_DIV_i64(b , math__gcd(b, a)));
16724+ if (res < 0) {
16725+ return -res;
16726+ }
16727+ return res;
16728+}
16729+f64 math__erf(f64 a) {
16730+ f64 x = a;
16731+ f64 very_tiny = 2.848094538889218e-306;
16732+ f64 small_ = ((f64)(1.0)) / ((f64)(v__lshift_u64(((u64)(1)), (u64)28)));
16733+ if (math__is_nan(x)) {
16734+ return math__nan();
16735+ }
16736+ if (math__is_inf(x, 1)) {
16737+ return 1.0;
16738+ }
16739+ if (math__is_inf(x, -1)) {
16740+ return ((f64)(-1));
16741+ }
16742+ bool neg = false;
16743+ if (x < 0) {
16744+ x = -x;
16745+ neg = true;
16746+ }
16747+ if (x < ((f64)(0.84375))) {
16748+ f64 temp = 0.0;
16749+ if (x < small_) {
16750+ if (x < very_tiny) {
16751+ temp = ((f64)(0.125)) * (((f64)(8.0)) * x + ((f64)(_const_math__efx8)) * x);
16752+ } else {
16753+ temp = x + ((f64)(_const_math__efx)) * x;
16754+ }
16755+ } else {
16756+ f64 z = x * x;
16757+ f64 r = ((f64)(_const_math__pp0)) + z * (((f64)(_const_math__pp1)) + z * (((f64)(_const_math__pp2)) + z * (((f64)(_const_math__pp3)) + z * ((f64)(_const_math__pp4)))));
16758+ f64 s_ = ((f64)(1.0)) + z * (((f64)(_const_math__qq1)) + z * (((f64)(_const_math__qq2)) + z * (((f64)(_const_math__qq3)) + z * (((f64)(_const_math__qq4)) + z * ((f64)(_const_math__qq5))))));
16759+ f64 y = r / s_;
16760+ temp = x + x * y;
16761+ }
16762+ if (neg) {
16763+ return -temp;
16764+ }
16765+ return temp;
16766+ }
16767+ if (x < ((f64)(1.25))) {
16768+ f64 s_ = x - 1;
16769+ f64 p = ((f64)(_const_math__pa0)) + s_ * (((f64)(_const_math__pa1)) + s_ * (((f64)(_const_math__pa2)) + s_ * (((f64)(_const_math__pa3)) + s_ * (((f64)(_const_math__pa4)) + s_ * (((f64)(_const_math__pa5)) + s_ * ((f64)(_const_math__pa6)))))));
16770+ f64 q = ((f64)(1.0)) + s_ * (((f64)(_const_math__qa1)) + s_ * (((f64)(_const_math__qa2)) + s_ * (((f64)(_const_math__qa3)) + s_ * (((f64)(_const_math__qa4)) + s_ * (((f64)(_const_math__qa5)) + s_ * ((f64)(_const_math__qa6)))))));
16771+ if (neg) {
16772+ return ((f64)(-_const_math__erx)) - p / q;
16773+ }
16774+ return ((f64)(_const_math__erx)) + p / q;
16775+ }
16776+ if (x >= 6) {
16777+ if (neg) {
16778+ return -1;
16779+ }
16780+ return 1.0;
16781+ }
16782+ f64 s_ = ((f64)(1.0)) / (x * x);
16783+ f64 r = 0.0;
16784+ f64 s = 0.0;
16785+ if (x < ((f64)(2.857142857142857))) {
16786+ f64 tmp41 = s_ * (((f64)(_const_math__ra5)) + s_ * (((f64)(_const_math__ra6)) + s_ * ((f64)(_const_math__ra7))));
16787+ r = ((f64)(_const_math__ra0)) + s_ * (((f64)(_const_math__ra1)) + s_ * (((f64)(_const_math__ra2)) + s_ * (((f64)(_const_math__ra3)) + s_ * (((f64)(_const_math__ra4)) + tmp41))));
16788+ f64 tmp42 = s_ * (((f64)(_const_math__sa5)) + s_ * (((f64)(_const_math__sa6)) + s_ * (((f64)(_const_math__sa7)) + s_ * ((f64)(_const_math__sa8)))));
16789+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sa1)) + s_ * (((f64)(_const_math__sa2)) + s_ * (((f64)(_const_math__sa3)) + s_ * (((f64)(_const_math__sa4)) + tmp42))));
16790+ } else {
16791+ f64 tmp31 = ((f64)(_const_math__rb4)) + s_ * (((f64)(_const_math__rb5)) + s_ * ((f64)(_const_math__rb6)));
16792+ r = ((f64)(_const_math__rb0)) + s_ * (((f64)(_const_math__rb1)) + s_ * (((f64)(_const_math__rb2)) + s_ * (((f64)(_const_math__rb3)) + s_ * tmp31)));
16793+ f64 tmp32 = ((f64)(_const_math__sb4)) + s_ * (((f64)(_const_math__sb5)) + s_ * (((f64)(_const_math__sb6)) + s_ * ((f64)(_const_math__sb7))));
16794+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sb1)) + s_ * (((f64)(_const_math__sb2)) + s_ * (((f64)(_const_math__sb3)) + s_ * tmp32)));
16795+ }
16796+ f64 z = math__f64_from_bits((math__f64_bits(x) & 0xffffffff00000000ULL));
16797+ f64 r_ = math__exp(-z * z - ((f64)(0.5625))) * math__exp((z - x) * (z + x) + r / s);
16798+ if (neg) {
16799+ return r_ / x - ((f64)(1.0));
16800+ }
16801+ return ((f64)(1.0)) - r_ / x;
16802+}
16803+f64 math__erfc(f64 a) {
16804+ f64 x = a;
16805+ f64 tiny = ((f64)(1.0)) / ((f64)(v__lshift_u64(((u64)(1)), (u64)56)));
16806+ if (math__is_nan(x)) {
16807+ return math__nan();
16808+ }
16809+ if (math__is_inf(x, 1)) {
16810+ return 0.0;
16811+ }
16812+ if (math__is_inf(x, -1)) {
16813+ return 2.0;
16814+ }
16815+ bool neg = false;
16816+ if (x < 0) {
16817+ x = -x;
16818+ neg = true;
16819+ }
16820+ if (x < ((f64)(0.84375))) {
16821+ f64 temp = 0.0;
16822+ if (x < tiny) {
16823+ temp = x;
16824+ } else {
16825+ f64 z = x * x;
16826+ f64 r = ((f64)(_const_math__pp0)) + z * (((f64)(_const_math__pp1)) + z * (((f64)(_const_math__pp2)) + z * (((f64)(_const_math__pp3)) + z * ((f64)(_const_math__pp4)))));
16827+ f64 s_ = ((f64)(1.0)) + z * (((f64)(_const_math__qq1)) + z * (((f64)(_const_math__qq2)) + z * (((f64)(_const_math__qq3)) + z * (((f64)(_const_math__qq4)) + z * ((f64)(_const_math__qq5))))));
16828+ f64 y = r / s_;
16829+ if (x < ((f64)(0.25))) {
16830+ temp = x + x * y;
16831+ } else {
16832+ temp = ((f64)(0.5)) + (x * y + (x - ((f64)(0.5))));
16833+ }
16834+ }
16835+ if (neg) {
16836+ return ((f64)(1.0)) + temp;
16837+ }
16838+ return ((f64)(1.0)) - temp;
16839+ }
16840+ if (x < ((f64)(1.25))) {
16841+ f64 s_ = x - 1;
16842+ f64 p = ((f64)(_const_math__pa0)) + s_ * (((f64)(_const_math__pa1)) + s_ * (((f64)(_const_math__pa2)) + s_ * (((f64)(_const_math__pa3)) + s_ * (((f64)(_const_math__pa4)) + s_ * (((f64)(_const_math__pa5)) + s_ * ((f64)(_const_math__pa6)))))));
16843+ f64 q = ((f64)(1.0)) + s_ * (((f64)(_const_math__qa1)) + s_ * (((f64)(_const_math__qa2)) + s_ * (((f64)(_const_math__qa3)) + s_ * (((f64)(_const_math__qa4)) + s_ * (((f64)(_const_math__qa5)) + s_ * ((f64)(_const_math__qa6)))))));
16844+ if (neg) {
16845+ return ((f64)(1.8450629115104675)) + p / q;
16846+ }
16847+ return ((f64)(0.15493708848953247)) - p / q;
16848+ }
16849+ if (x < 28) {
16850+ f64 s_ = ((f64)(1.0)) / (x * x);
16851+ f64 r = 0.0;
16852+ f64 s = 0.0;
16853+ if (x < ((f64)(2.857142857142857))) {
16854+ f64 tmp281 = ((f64)(_const_math__ra4)) + s_ * (((f64)(_const_math__ra5)) + s_ * (((f64)(_const_math__ra6)) + s_ * ((f64)(_const_math__ra7))));
16855+ r = ((f64)(_const_math__ra0)) + s_ * (((f64)(_const_math__ra1)) + s_ * (((f64)(_const_math__ra2)) + s_ * (((f64)(_const_math__ra3)) + s_ * tmp281)));
16856+ f64 tmp282 = ((f64)(_const_math__sa4)) + s_ * (((f64)(_const_math__sa5)) + s_ * (((f64)(_const_math__sa6)) + s_ * (((f64)(_const_math__sa7)) + s_ * ((f64)(_const_math__sa8)))));
16857+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sa1)) + s_ * (((f64)(_const_math__sa2)) + s_ * (((f64)(_const_math__sa3)) + s_ * tmp282)));
16858+ } else {
16859+ if (neg && x > 6) {
16860+ return 2.0;
16861+ }
16862+ f64 tmp291 = ((f64)(_const_math__rb3)) + s_ * (((f64)(_const_math__rb4)) + s_ * (((f64)(_const_math__rb5)) + s_ * ((f64)(_const_math__rb6))));
16863+ r = ((f64)(_const_math__rb0)) + s_ * (((f64)(_const_math__rb1)) + s_ * (((f64)(_const_math__rb2)) + s_ * tmp291));
16864+ f64 tmp292 = ((f64)(_const_math__sb3)) + s_ * (((f64)(_const_math__sb4)) + s_ * (((f64)(_const_math__sb5)) + s_ * (((f64)(_const_math__sb6)) + s_ * ((f64)(_const_math__sb7)))));
16865+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sb1)) + s_ * (((f64)(_const_math__sb2)) + s_ * tmp292));
16866+ }
16867+ f64 z = math__f64_from_bits((math__f64_bits(x) & 0xffffffff00000000ULL));
16868+ f64 r_ = math__exp(-z * z - ((f64)(0.5625))) * math__exp((z - x) * (z + x) + r / s);
16869+ if (neg) {
16870+ return ((f64)(2.0)) - r_ / x;
16871+ }
16872+ return r_ / x;
16873+ }
16874+ if (neg) {
16875+ return 2.0;
16876+ }
16877+ return 0.0;
16878+}
16879+inline f64 math__exp(f64 x) {
16880+ return exp(x);
16881+}
16882+inline f64 math__exp2(f64 x) {
16883+ return exp2(x);
16884+}
16885+inline f64 math__ldexp(f64 frac, int exp) {
16886+ return ldexp(frac, exp);
16887+}
16888+f64 math__pure_v_but_overridden_by_c_exp(f64 x) {
16889+ f64 log2e = 1.44269504088896338700e+00;
16890+ f64 overflow = 7.09782712893383973096e+02;
16891+ f64 underflow = -7.45133219101941108420e+02;
16892+ float_literal near_zero = (float_literal)(1.0 / 268435456);
16893+ if (math__is_nan(x) || math__is_inf(x, 1)) {
16894+ return x;
16895+ }
16896+ if (math__is_inf(x, -1)) {
16897+ return 0.0;
16898+ }
16899+ if (x > overflow) {
16900+ return math__inf(1);
16901+ }
16902+ if (x < underflow) {
16903+ return 0.0;
16904+ }
16905+ if (-near_zero < x && x < near_zero) {
16906+ return ((f64)(1.0)) + x;
16907+ }
16908+ int k = 0;
16909+ if (x < 0) {
16910+ k = ((int)(log2e * x - ((f64)(0.5))));
16911+ }
16912+ if (x > 0) {
16913+ k = ((int)(log2e * x + ((f64)(0.5))));
16914+ }
16915+ f64 hi = x - ((f64)(k)) * ((f64)(_const_math__ln2hi));
16916+ f64 lo = ((f64)(k)) * ((f64)(_const_math__ln2lo));
16917+ return math__expmulti(hi, lo, k);
16918+}
16919+f64 math__pure_v_but_overridden_by_c_exp2(f64 x) {
16920+ f64 overflow = 1.0239999999999999e+03;
16921+ f64 underflow = -1.0740e+03;
16922+ if (math__is_nan(x) || math__is_inf(x, 1)) {
16923+ return x;
16924+ }
16925+ if (math__is_inf(x, -1)) {
16926+ return 0;
16927+ }
16928+ if (x > overflow) {
16929+ return math__inf(1);
16930+ }
16931+ if (x < underflow) {
16932+ return 0;
16933+ }
16934+ int k = 0;
16935+ if (x > 0) {
16936+ k = ((int)(x + ((f64)(0.5))));
16937+ }
16938+ if (x < 0) {
16939+ k = ((int)(x - ((f64)(0.5))));
16940+ }
16941+ f64 t = x - ((f64)(k));
16942+ f64 hi = t * ((f64)(_const_math__ln2hi));
16943+ f64 lo = -t * ((f64)(_const_math__ln2lo));
16944+ return math__expmulti(hi, lo, k);
16945+}
16946+f64 math__pure_v_but_overridden_by_c_ldexp(f64 frac, int exp) {
16947+ return math__scalbn(frac, exp);
16948+}
16949+multi_return_f64_int math__frexp(f64 x) {
16950+ u64 y = math__f64_bits(x);
16951+ int ee = ((int)(((v__rshift_u64(y, (u64)52)) & 0x7ff)));
16952+ if (ee == 0) {
16953+ if (x != ((f64)(0.0))) {
16954+ f64 x1p64 = math__f64_from_bits(((u64)(0x43f0000000000000LL)));
16955+ multi_return_f64_int mr_3373 = math__frexp(x * x1p64);
16956+ f64 z = mr_3373.arg0;
16957+ int e_ = mr_3373.arg1;
16958+ return (multi_return_f64_int){.arg0=z, .arg1=e_ - 64};
16959+ }
16960+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16961+ } else if (ee == 0x7ff) {
16962+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16963+ }
16964+ int e_ = ee - 0x3fe;
16965+ y &= ((u64)(0x800fffffffffffffULL));
16966+ y |= ((u64)(0x3fe0000000000000LL));
16967+ return (multi_return_f64_int){.arg0=math__f64_from_bits(y), .arg1=e_};
16968+}
16969+f64 math__expm1(f64 x) {
16970+ if (math__is_inf(x, 1) || math__is_nan(x)) {
16971+ return x;
16972+ }
16973+ if (math__is_inf(x, -1)) {
16974+ return ((f64)(-1));
16975+ }
16976+ if (math__abs_T_f64(x) < ((f64)(_const_math__ln2))) {
16977+ f64 i = 1.0;
16978+ f64 sum = x;
16979+ f64 term = x / ((f64)(1.0));
16980+ i++;
16981+ term *= x / ((f64)(i));
16982+ sum += term;
16983+ for (;;) {
16984+ if (!(math__abs_T_f64(term) > math__abs_T_f64(sum) * ((f64)(_const_math__internal__f64_epsilon)))) break;
16985+ i++;
16986+ term *= x / ((f64)(i));
16987+ sum += term;
16988+ }
16989+ return sum;
16990+ } else {
16991+ return math__exp(x) - 1;
16992+ }
16993+ return 0;
16994+}
16995+VV_LOC f64 math__expmulti(f64 hi, f64 lo, int k) {
16996+ f64 exp_p1 = 1.66666666666666657415e-01;
16997+ f64 exp_p2 = -2.77777777770155933842e-03;
16998+ f64 exp_p3 = 6.61375632143793436117e-05;
16999+ f64 exp_p4 = -1.65339022054652515390e-06;
17000+ f64 exp_p5 = 4.13813679705723846039e-08;
17001+ f64 r = hi - lo;
17002+ f64 t = r * r;
17003+ f64 c = r - t * (exp_p1 + t * (exp_p2 + t * (exp_p3 + t * (exp_p4 + t * exp_p5))));
17004+ f64 y = 1 - ((lo - (r * c) / (2 - c)) - hi);
17005+ return math__ldexp(y, k);
17006+}
17007+f64 math__factorial(f64 n) {
17008+ if (n >= _const_math__factorials_table.len) {
17009+ return _const_math__max_f64;
17010+ }
17011+ if (n == ((f64)(((i64)(n)))) && n >= ((f64)(0.0))) {
17012+ return (*(f64*)builtin__array_get(_const_math__factorials_table, ((int)(n))));
17013+ }
17014+ return math__gamma(n + ((f64)(1.0)));
17015+}
17016+f64 math__log_factorial(f64 n) {
17017+ if (n < 0) {
17018+ return -_const_math__max_f64;
17019+ }
17020+ if (n != ((f64)(((i64)(n))))) {
17021+ return math__log_gamma(n + 1);
17022+ } else if (n < _const_math__log_factorials_table.len) {
17023+ return (*(f64*)builtin__array_get(_const_math__log_factorials_table, ((int)(n))));
17024+ }
17025+ return math__log_factorial_asymptotic_expansion(((int)(n)));
17026+}
17027+VV_LOC f64 math__log_factorial_asymptotic_expansion(int n) {
17028+ int m = 6;
17029+ Array_f64 term = builtin____new_array_with_default(0, 0, sizeof(f64), 0);
17030+ f64 xx = ((f64)((n + 1) * (n + 1)));
17031+ f64 xj = ((f64)(n + 1));
17032+ f64 log_fact = ((f64)(_const_math__log_sqrt_2pi)) - xj + (xj - ((f64)(0.5))) * math__log(xj);
17033+ int i = 0;
17034+ for (i = 0; i < m; i++) {
17035+ builtin__array_push((array*)&term, _MOV((f64[]){ (*(f64*)builtin__array_get(_const_math__bernoulli, i)) / xj }));
17036+ xj *= xx;
17037+ }
17038+ f64 sum = (*(f64*)builtin__array_get(term, m - 1));
17039+ for (i = m - 2; i >= 0; i--) {
17040+ if (math__abs_T_f64(sum) <= math__abs_T_f64((*(f64*)builtin__array_get(term, i)))) {
17041+ break;
17042+ }
17043+ sum = (*(f64*)builtin__array_get(term, i));
17044+ }
17045+ for (;;) {
17046+ if (!(i >= 0)) break;
17047+ sum += (*(f64*)builtin__array_get(term, i));
17048+ i--;
17049+ }
17050+ return log_fact + sum;
17051+}
17052+i64 math__factoriali(int n) {
17053+ if (n <= 0) {
17054+ return ((i64)(1));
17055+ }
17056+ if (n < 21) {
17057+ return ((i64)((*(f64*)builtin__array_get(_const_math__factorials_table, n))));
17058+ }
17059+ return ((i64)(-1));
17060+}
17061+f64 math__floor(f64 x) {
17062+ if (x == 0 || math__is_nan(x) || math__is_inf(x, 0)) {
17063+ return x;
17064+ }
17065+ if (x < 0) {
17066+ multi_return_f64_f64 mr_280 = math__modf(-x);
17067+ f64 d = mr_280.arg0;
17068+ f64 fract = mr_280.arg1;
17069+ if (fract != ((f64)(0.0))) {
17070+ d = d + 1;
17071+ }
17072+ return -d;
17073+ }
17074+ multi_return_f64_f64 mr_350 = math__modf(x);
17075+ f64 d = mr_350.arg0;
17076+ return d;
17077+}
17078+f32 math__floorf(f32 x) {
17079+ return ((f32)(math__floor(((f64)(x)))));
17080+}
17081+f64 math__ceil(f64 x) {
17082+ return -math__floor(-x);
17083+}
17084+f64 math__trunc(f64 x) {
17085+ if (x == 0 || math__is_nan(x) || math__is_inf(x, 0)) {
17086+ return x;
17087+ }
17088+ multi_return_f64_f64 mr_1200 = math__modf(x);
17089+ f64 d = mr_1200.arg0;
17090+ return d;
17091+}
17092+f64 math__round(f64 x) {
17093+ u64 bits = math__f64_bits(x);
17094+ u64 e_ = ((v__rshift_u64(bits, (u64)52)) & 0x7FF);
17095+ if (e_ < 1023) {
17096+ bits &= _const_math__sign_mask;
17097+ if (e_ == 1022) {
17098+ bits |= _const_math__uvone;
17099+ }
17100+ } else if (e_ < 1075) {
17101+ u64 half = v__lshift_u64(((u64)(1)), (u64)51);
17102+ e_ -= _const_math__bias;
17103+ bits += v__rshift_u64(half, (u64)e_);
17104+ bits &= ~(v__rshift_u64(_const_math__frac_mask, (u64)e_));
17105+ }
17106+ return math__f64_from_bits(bits);
17107+}
17108+f64 math__round_sig(f64 x, int sig_digits) {
17109+ string ret_str = builtin__f64_str(x);
17110+ switch (sig_digits) {
17111+ case 0: {
17112+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000000d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17113+ break;
17114+ }
17115+ case 1: {
17116+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000020d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17117+ break;
17118+ }
17119+ case 2: {
17120+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000040d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17121+ break;
17122+ }
17123+ case 3: {
17124+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000060d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17125+ break;
17126+ }
17127+ case 4: {
17128+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000080d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17129+ break;
17130+ }
17131+ case 5: {
17132+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000a0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17133+ break;
17134+ }
17135+ case 6: {
17136+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000c0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17137+ break;
17138+ }
17139+ case 7: {
17140+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000e0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17141+ break;
17142+ }
17143+ case 8: {
17144+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000100d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17145+ break;
17146+ }
17147+ case 9: {
17148+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000120d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17149+ break;
17150+ }
17151+ case 10: {
17152+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000140d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17153+ break;
17154+ }
17155+ case 11: {
17156+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000160d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17157+ break;
17158+ }
17159+ case 12: {
17160+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000180d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17161+ break;
17162+ }
17163+ case 13: {
17164+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001a0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17165+ break;
17166+ }
17167+ case 14: {
17168+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001c0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17169+ break;
17170+ }
17171+ case 15: {
17172+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001e0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17173+ break;
17174+ }
17175+ case 16: {
17176+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000200d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17177+ break;
17178+ }
17179+ default: {
17180+ {
17181+ ret_str = builtin__f64_str(x);
17182+ break;
17183+ }
17184+ }
17185+ }
17186+
17187+ return builtin__string_f64(ret_str);
17188+}
17189+f64 math__round_to_even(f64 x) {
17190+ u64 bits = math__f64_bits(x);
17191+ u64 e_ = ((v__rshift_u64(bits, (u64)52)) & 0x7FF);
17192+ if (e_ >= 1023) {
17193+ u64 half_minus_ulp = ((u64)(v__lshift_u64(((u64)(1)), (u64)51))) - 1;
17194+ e_ -= ((u64)(_const_math__bias));
17195+ bits += math__safe_shift(half_minus_ulp + (math__safe_shift(bits, 52 - e_) & 1), e_);
17196+ bits &= ~math__safe_shift(_const_math__frac_mask, e_);
17197+ } else if (e_ == 1022 && (bits & _const_math__frac_mask) != 0) {
17198+ bits = ((bits & _const_math__sign_mask) | _const_math__uvone);
17199+ } else {
17200+ bits &= _const_math__sign_mask;
17201+ }
17202+ return math__f64_from_bits(bits);
17203+}
17204+inline VV_LOC u64 math__safe_shift(u64 value, u64 shift) {
17205+ return (shift > ((u64)(63)) ? (((u64)(0))) : (v__rshift_u64(value, (u64)shift)));
17206+}
17207+VV_LOC bool math__is_neg_int(f64 x) {
17208+ if (x < 0) {
17209+ multi_return_f64_f64 mr_61 = math__modf(x);
17210+ f64 xf = mr_61.arg1;
17211+ return xf == 0;
17212+ }
17213+ return false;
17214+}
17215+VV_LOC multi_return_f64_f64 math__stirling(f64 x) {
17216+ if (x > 200) {
17217+ return (multi_return_f64_f64){.arg0=math__inf(1), .arg1=1.0};
17218+ }
17219+ f64 w = ((f64)(1.0)) / x;
17220+ w = ((f64)(1.0)) + w * (((((*(f64*)builtin__array_get(_const_math__gamma_s, 0)) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 1))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 2))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 3))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 4)));
17221+ f64 y1 = math__exp(x);
17222+ f64 y2 = 1.0;
17223+ if (x > ((f64)(143.01608))) {
17224+ f64 v = math__pow(x, ((f64)(0.5)) * x - ((f64)(0.25)));
17225+ f64 y1_ = y1;
17226+ y1 = v;
17227+ y2 = v / y1_;
17228+ } else {
17229+ y1 = math__pow(x, x - ((f64)(0.5))) / y1;
17230+ }
17231+ return (multi_return_f64_f64){.arg0=y1, .arg1=((f64)(2.506628274631000502417)) * w * y2};
17232+}
17233+f64 math__gamma(f64 a) {
17234+ f64 x = a;
17235+ if (math__is_neg_int(x) || math__is_inf(x, -1) || math__is_nan(x)) {
17236+ return math__nan();
17237+ }
17238+ if (math__is_inf(x, 1)) {
17239+ return math__inf(1);
17240+ }
17241+ if (x == ((f64)(0.0))) {
17242+ return math__copysign(math__inf(1), x);
17243+ }
17244+ f64 q = math__abs_T_f64(x);
17245+ f64 p = math__floor(q);
17246+ if (q > 33) {
17247+ if (x >= 0) {
17248+ multi_return_f64_f64 mr_1507 = math__stirling(x);
17249+ f64 y1 = mr_1507.arg0;
17250+ f64 y2 = mr_1507.arg1;
17251+ return y1 * y2;
17252+ }
17253+ int signgam = 1;
17254+ i64 ip = ((i64)(p));
17255+ if (((ip & 1)) == 0) {
17256+ signgam = -1;
17257+ }
17258+ f64 z = q - p;
17259+ if (z > ((f64)(0.5))) {
17260+ p = p + 1;
17261+ z = q - p;
17262+ }
17263+ z = q * math__sin(((f64)(_const_math__pi)) * z);
17264+ if (z == 0) {
17265+ return math__inf(signgam);
17266+ }
17267+ multi_return_f64_f64 mr_1952 = math__stirling(q);
17268+ f64 sq1 = mr_1952.arg0;
17269+ f64 sq2 = mr_1952.arg1;
17270+ f64 absz = math__abs_T_f64(z);
17271+ f64 d = absz * sq1 * sq2;
17272+ if (math__is_inf(d, 0)) {
17273+ z = ((f64)(_const_math__pi)) / absz / sq1 / sq2;
17274+ } else {
17275+ z = ((f64)(_const_math__pi)) / d;
17276+ }
17277+ return ((f64)(signgam)) * z;
17278+ }
17279+ f64 z = 1.0;
17280+ for (;;) {
17281+ if (!(x >= 3)) break;
17282+ x = x - 1;
17283+ z = z * x;
17284+ }
17285+ for (;;) {
17286+ if (!(x < 0)) break;
17287+ if (x > ((f64)(-1e-09))) {
17288+ return math__gamma_too_small(x, z);
17289+ }
17290+ z = z / x;
17291+ x = x + 1;
17292+ }
17293+ for (;;) {
17294+ if (!(x < 2)) break;
17295+ if (x < ((f64)(1e-09))) {
17296+ return math__gamma_too_small(x, z);
17297+ }
17298+ z = z / x;
17299+ x = x + 1;
17300+ }
17301+ if (x == 2) {
17302+ return z;
17303+ }
17304+ x = x - 2;
17305+ p = (((((x * (*(f64*)builtin__array_get(_const_math__gamma_p, 0)) + (*(f64*)builtin__array_get(_const_math__gamma_p, 1))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 2))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 3))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 4))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 5))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 6));
17306+ q = ((((((x * (*(f64*)builtin__array_get(_const_math__gamma_q, 0)) + (*(f64*)builtin__array_get(_const_math__gamma_q, 1))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 2))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 3))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 4))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 5))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 6))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 7));
17307+ return z * p / q;
17308+}
17309+VV_LOC f64 math__gamma_too_small(f64 x, f64 z) {
17310+ if (x == 0) {
17311+ return math__inf(1);
17312+ }
17313+ f64 euler = 0.57721566490153286060651209008240243104215933593992;
17314+ return z / ((((f64)(1.0)) + euler * x) * x);
17315+}
17316+f64 math__log_gamma(f64 x) {
17317+ multi_return_f64_int mr_3163 = math__log_gamma_sign(x);
17318+ f64 y = mr_3163.arg0;
17319+ return y;
17320+}
17321+multi_return_f64_int math__log_gamma_sign(f64 a) {
17322+ f64 x = a;
17323+ int sgn = 1;
17324+ if (math__is_nan(x)) {
17325+ return (multi_return_f64_int){.arg0=x, .arg1=sgn};
17326+ }
17327+ if (math__is_inf(x, 1)) {
17328+ return (multi_return_f64_int){.arg0=x, .arg1=sgn};
17329+ }
17330+ if (x == ((f64)(0.0))) {
17331+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17332+ }
17333+ bool neg = false;
17334+ if (x < 0) {
17335+ x = -x;
17336+ neg = true;
17337+ }
17338+ if (x < math__exp2(-70)) {
17339+ if (neg) {
17340+ sgn = -1;
17341+ }
17342+ return (multi_return_f64_int){.arg0=-math__log(x), .arg1=sgn};
17343+ }
17344+ f64 nadj = 0.0;
17345+ if (neg) {
17346+ if (x >= math__exp2(52)) {
17347+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17348+ }
17349+ f64 t = math__sin_pi(x);
17350+ if (t == 0) {
17351+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17352+ }
17353+ nadj = math__log(((f64)(_const_math__pi)) / math__abs_T_f64(t * x));
17354+ if (t < 0) {
17355+ sgn = -1;
17356+ }
17357+ }
17358+ f64 lgamma = 0.0;
17359+ if (x == 1 || x == 2) {
17360+ return (multi_return_f64_int){.arg0=0.0, .arg1=sgn};
17361+ } else if (x < 2) {
17362+ f64 ymin = 1.461632144968362245;
17363+ f64 tc = 1.46163214496836224576e+00;
17364+ f64 y = 0.0;
17365+ int i = 0;
17366+ if (x <= ((f64)(0.9))) {
17367+ lgamma = -math__log(x);
17368+ if (x >= (ymin - 1 + ((f64)(0.27)))) {
17369+ y = ((f64)(1.0)) - x;
17370+ i = 0;
17371+ } else if (x >= (ymin - 1 - ((f64)(0.27)))) {
17372+ y = x - (tc - 1);
17373+ i = 1;
17374+ } else {
17375+ y = x;
17376+ i = 2;
17377+ }
17378+ } else {
17379+ lgamma = 0;
17380+ if (x >= (ymin + ((f64)(0.27)))) {
17381+ y = ((f64)(2)) - x;
17382+ i = 0;
17383+ } else if (x >= (ymin - ((f64)(0.27)))) {
17384+ y = x - tc;
17385+ i = 1;
17386+ } else {
17387+ y = x - 1;
17388+ i = 2;
17389+ }
17390+ }
17391+ if (i == 0) {
17392+ f64 z = y * y;
17393+ f64 gamma_p1 = (*(f64*)builtin__array_get(_const_math__lgamma_a, 0)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 2)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 4)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 6)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 8)) + z * (*(f64*)builtin__array_get(_const_math__lgamma_a, 10))))));
17394+ f64 gamma_p2 = z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 1)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 3)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 5)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 7)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 9)) + z * (*(f64*)builtin__array_get(_const_math__lgamma_a, 11)))))));
17395+ f64 p = y * gamma_p1 + gamma_p2;
17396+ lgamma += (p - ((f64)(0.5)) * y);
17397+ } else if (i == 1) {
17398+ f64 z = y * y;
17399+ f64 w = z * y;
17400+ f64 gamma_p1 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 0)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 3)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 6)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 9)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 12)))));
17401+ f64 gamma_p2 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 1)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 4)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 7)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 10)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 13)))));
17402+ f64 gamma_p3 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 2)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 5)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 8)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 11)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 14)))));
17403+ f64 tf = -1.21486290535849611461e-01;
17404+ f64 tt = -3.63867699703950536541e-18;
17405+ f64 p = z * gamma_p1 - (tt - w * (gamma_p2 + y * gamma_p3));
17406+ lgamma += (tf + p);
17407+ } else if (i == 2) {
17408+ f64 gamma_p1 = y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 4)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_u, 5)))))));
17409+ f64 gamma_p2 = ((f64)(1.0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 4)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_v, 5))))));
17410+ lgamma += (((f64)(-0.5)) * y + gamma_p1 / gamma_p2);
17411+ }
17412+ } else if (x < 8) {
17413+ int i = ((int)(x));
17414+ f64 y = x - ((f64)(i));
17415+ f64 tmp23456 = (*(f64*)builtin__array_get(_const_math__lgamma_s, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_s, 6)))));
17416+ f64 p = y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 1)) + y * tmp23456));
17417+ f64 tmpr23456 = (*(f64*)builtin__array_get(_const_math__lgamma_r, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_r, 6)))));
17418+ f64 q = ((f64)(1.0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 1)) + y * tmpr23456);
17419+ lgamma = ((f64)(0.5)) * y + p / q;
17420+ f64 z = 1.0;
17421+ if (i == 7) {
17422+ z *= (y + 6);
17423+ z *= (y + 5);
17424+ z *= (y + 4);
17425+ z *= (y + 3);
17426+ z *= (y + 2);
17427+ lgamma += math__log(z);
17428+ } else if (i == 6) {
17429+ z *= (y + 5);
17430+ z *= (y + 4);
17431+ z *= (y + 3);
17432+ z *= (y + 2);
17433+ lgamma += math__log(z);
17434+ } else if (i == 5) {
17435+ z *= (y + 4);
17436+ z *= (y + 3);
17437+ z *= (y + 2);
17438+ lgamma += math__log(z);
17439+ } else if (i == 4) {
17440+ z *= (y + 3);
17441+ z *= (y + 2);
17442+ lgamma += math__log(z);
17443+ } else if (i == 3) {
17444+ z *= (y + 2);
17445+ lgamma += math__log(z);
17446+ }
17447+ } else if (x < math__exp2(58)) {
17448+ f64 t = math__log(x);
17449+ f64 z = ((f64)(1.0)) / x;
17450+ f64 y = z * z;
17451+ f64 w = (*(f64*)builtin__array_get(_const_math__lgamma_w, 0)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_w, 6)))))));
17452+ lgamma = (x - ((f64)(0.5))) * (t - ((f64)(1.0))) + w;
17453+ } else {
17454+ lgamma = x * (math__log(x) - ((f64)(1.0)));
17455+ }
17456+ if (neg) {
17457+ lgamma = nadj - lgamma;
17458+ }
17459+ return (multi_return_f64_int){.arg0=lgamma, .arg1=sgn};
17460+}
17461+VV_LOC f64 math__sin_pi(f64 x_) {
17462+ f64 x = x_;
17463+ if (x < ((f64)(0.25))) {
17464+ return -math__sin(((f64)(_const_math__pi)) * x);
17465+ }
17466+ f64 z = math__floor(x);
17467+ int n = 0;
17468+ if (z != x) {
17469+ x = math__mod(x, 2);
17470+ n = ((int)(x * 4));
17471+ } else {
17472+ if (x >= math__exp2(53)) {
17473+ x = 0;
17474+ n = 0;
17475+ } else {
17476+ f64 two52 = math__exp2(52);
17477+ if (x < two52) {
17478+ z = x + two52;
17479+ }
17480+ n = (1 & ((int)(math__f64_bits(z))));
17481+ x = ((f64)(n));
17482+ n = v__lshift_int(n, (u64)2);
17483+ }
17484+ }
17485+ if (n == 0) {
17486+ x = math__sin(((f64)(_const_math__pi)) * x);
17487+ } else if (n == 1 || n == 2) {
17488+ x = math__cos(((f64)(_const_math__pi)) * (((f64)(0.5)) - x));
17489+ } else if (n == 3 || n == 4) {
17490+ x = math__sin(((f64)(_const_math__pi)) * (((f64)(1.0)) - x));
17491+ } else if (n == 5 || n == 6) {
17492+ x = -math__cos(((f64)(_const_math__pi)) * (x - ((f64)(1.5))));
17493+ } else {
17494+ x = math__sin(((f64)(_const_math__pi)) * (x - 2));
17495+ }
17496+ return -x;
17497+}
17498+f64 math__hypot(f64 x, f64 y) {
17499+ f64 p = math__abs_T_f64(x);
17500+ f64 q = math__abs_T_f64(y);
17501+ if (math__is_inf(p, 1) || math__is_inf(q, 1)) {
17502+ return math__inf(1);
17503+ }
17504+ if (math__is_nan(p) || math__is_nan(q)) {
17505+ return math__nan();
17506+ }
17507+ if (p < q) {
17508+ f64 _var_382 = p;
17509+ f64 _var_385 = q;
17510+ p = _var_385;
17511+ q = _var_382;
17512+ }
17513+ if (p == ((f64)(0.0))) {
17514+ return 0.0;
17515+ }
17516+ q = q / p;
17517+ return p * math__sqrt(1 + q * q);
17518+}
17519+inline math__BezierPoint math__cubic_bezier(f64 t, Array_math__BezierPoint p) {
17520+ if (p.len != 4) {
17521+ builtin___v_panic(_S("invalid p.len"));
17522+ VUNREACHABLE();
17523+ }
17524+ return math__cubic_bezier_coords(t, ((math__BezierPoint*)p.data)[0].x, ((math__BezierPoint*)p.data)[1].x, ((math__BezierPoint*)p.data)[2].x, ((math__BezierPoint*)p.data)[3].x, ((math__BezierPoint*)p.data)[0].y, ((math__BezierPoint*)p.data)[1].y, ((math__BezierPoint*)p.data)[2].y, ((math__BezierPoint*)p.data)[3].y);
17525+}
17526+inline math__BezierPoint math__cubic_bezier_a(f64 t, Array_f64 x, Array_f64 y) {
17527+ if (x.len != 4) {
17528+ builtin___v_panic(_S("invalid x.len"));
17529+ VUNREACHABLE();
17530+ }
17531+ if (y.len != 4) {
17532+ builtin___v_panic(_S("invalid y.len"));
17533+ VUNREACHABLE();
17534+ }
17535+ return math__cubic_bezier_coords(t, ((f64*)x.data)[0], ((f64*)x.data)[1], ((f64*)x.data)[2], ((f64*)x.data)[3], ((f64*)y.data)[0], ((f64*)y.data)[1], ((f64*)y.data)[2], ((f64*)y.data)[3]);
17536+}
17537+inline math__BezierPoint math__cubic_bezier_fa(f64 t, Array_fixed_f64_4 x, Array_fixed_f64_4 y) {
17538+ return math__cubic_bezier_coords(t, x[0], x[1], x[2], x[3], y[0], y[1], y[2], y[3]);
17539+}
17540+inline math__BezierPoint math__cubic_bezier_coords(f64 t, f64 x0, f64 x1, f64 x2, f64 x3, f64 y0, f64 y1, f64 y2, f64 y3) {
17541+ f64 p0 = math__pow(1 - t, 3);
17542+ f64 p1 = 3 * t * math__pow(1 - t, 2);
17543+ f64 p2 = 3 * (1 - t) * math__pow(t, 2);
17544+ f64 p3 = math__pow(t, 3);
17545+ f64 xt = p0 * x0 + p1 * x1 + p2 * x2 + p3 * x3;
17546+ f64 yt = p0 * y0 + p1 * y1 + p2 * y2 + p3 * y3;
17547+ return ((math__BezierPoint){.x = xt,.y = yt,});
17548+}
17549+f64 math__acosh(f64 x) {
17550+ if (x > ((f64)(6.7108864e+07))) {
17551+ return math__log(x) + ((f64)(_const_math__ln2));
17552+ } else if (x > ((f64)(2.0))) {
17553+ return math__log(((f64)(2.0)) * x - ((f64)(1.0)) / (math__sqrt(x * x - ((f64)(1.0))) + x));
17554+ } else if (x > ((f64)(1.0))) {
17555+ f64 t = x - ((f64)(1.0));
17556+ return math__log1p(t + math__sqrt(((f64)(2.0)) * t + t * t));
17557+ } else if (x == ((f64)(1.0))) {
17558+ return 0.0;
17559+ } else {
17560+ return math__nan();
17561+ }
17562+ return 0;
17563+}
17564+f64 math__asinh(f64 x) {
17565+ f64 a = math__abs_T_f64(x);
17566+ f64 s = (x < 0 ? (-1.0) : (1.0));
17567+ if (a > ((f64)(6.7108864e+07))) {
17568+ return s * (math__log(a) + ((f64)(_const_math__ln2)));
17569+ } else if (a > ((f64)(2.0))) {
17570+ return s * math__log(((f64)(2.0)) * a + ((f64)(1.0)) / (a + math__sqrt(a * a + ((f64)(1.0)))));
17571+ } else if (a > ((f64)(_const_math__internal__sqrt_f64_epsilon))) {
17572+ f64 a2 = a * a;
17573+ return s * math__log1p(a + a2 / (((f64)(1.0)) + math__sqrt(((f64)(1.0)) + a2)));
17574+ } else {
17575+ return x;
17576+ }
17577+ return 0;
17578+}
17579+f64 math__atanh(f64 x) {
17580+ f64 a = math__abs_T_f64(x);
17581+ f64 s = (x < 0 ? (-1.0) : (1.0));
17582+ if (a > ((f64)(1.0))) {
17583+ return math__nan();
17584+ } else if (a == ((f64)(1.0))) {
17585+ return (x < 0 ? (math__inf(-1)) : (math__inf(1)));
17586+ } else if (a >= ((f64)(0.5))) {
17587+ return s * ((f64)(0.5)) * math__log1p(((f64)(2.0)) * a / (((f64)(1.0)) - a));
17588+ } else if (a > ((f64)(_const_math__internal__f64_epsilon))) {
17589+ return s * ((f64)(0.5)) * math__log1p(((f64)(2.0)) * a + ((f64)(2.0)) * a * a / (((f64)(1.0)) - a));
17590+ } else {
17591+ return x;
17592+ }
17593+ return 0;
17594+}
17595+inline VV_LOC f64 math__xatan(f64 x) {
17596+ f64 xatan_p0 = -8.750608600031904122785e-01;
17597+ f64 xatan_p1 = -1.615753718733365076637e+01;
17598+ f64 xatan_p2 = -7.500855792314704667340e+01;
17599+ f64 xatan_p3 = -1.228866684490136173410e+02;
17600+ f64 xatan_p4 = -6.485021904942025371773e+01;
17601+ f64 xatan_q0 = 2.485846490142306297962e+01;
17602+ f64 xatan_q1 = 1.650270098316988542046e+02;
17603+ f64 xatan_q2 = 4.328810604912902668951e+02;
17604+ f64 xatan_q3 = 4.853903996359136964868e+02;
17605+ f64 xatan_q4 = 1.945506571482613964425e+02;
17606+ f64 z = x * x;
17607+ z = z * ((((xatan_p0 * z + xatan_p1) * z + xatan_p2) * z + xatan_p3) * z + xatan_p4) / (((((z + xatan_q0) * z + xatan_q1) * z + xatan_q2) * z + xatan_q3) * z + xatan_q4);
17608+ z = x * z + x;
17609+ return z;
17610+}
17611+inline VV_LOC f64 math__satan(f64 x) {
17612+ if (x <= ((f64)(0.66))) {
17613+ return math__xatan(x);
17614+ }
17615+ if (x > ((f64)(_const_math__tan3pio8))) {
17616+ return ((f64)(1.5707963267948966)) - math__xatan(((f64)(1.0)) / x) + ((f64)(_const_math__morebits));
17617+ }
17618+ return ((f64)((float_literal)(3.14159265358979323846264338327950288419716939937510582097494459 / 4))) + math__xatan((x - ((f64)(1.0))) / (x + ((f64)(1.0)))) + ((f64)(0.5)) * ((f64)(_const_math__morebits));
17619+}
17620+f64 math__atan(f64 x) {
17621+ if (x == 0) {
17622+ return x;
17623+ }
17624+ if (x > 0) {
17625+ return math__satan(x);
17626+ }
17627+ return -math__satan(-x);
17628+}
17629+f64 math__atan2(f64 y, f64 x) {
17630+ if (math__is_nan(y) || math__is_nan(x)) {
17631+ return math__nan();
17632+ }
17633+ if (y == ((f64)(0.0))) {
17634+ if (x >= 0 && !math__signbit(x)) {
17635+ return math__copysign(0, y);
17636+ }
17637+ return math__copysign(_const_math__pi, y);
17638+ }
17639+ if (x == ((f64)(0.0))) {
17640+ return math__copysign(1.5707963267948966, y);
17641+ }
17642+ if (math__is_inf(x, 0)) {
17643+ if (math__is_inf(x, 1)) {
17644+ if (math__is_inf(y, 0)) {
17645+ return math__copysign((float_literal)(3.14159265358979323846264338327950288419716939937510582097494459 / 4), y);
17646+ }
17647+ return math__copysign(0, y);
17648+ }
17649+ if (math__is_inf(y, 0)) {
17650+ return math__copysign(2.356194490192345, y);
17651+ }
17652+ return math__copysign(_const_math__pi, y);
17653+ }
17654+ if (math__is_inf(y, 0)) {
17655+ return math__copysign(1.5707963267948966, y);
17656+ }
17657+ f64 q = math__atan(y / x);
17658+ if (x < 0) {
17659+ if (q <= 0) {
17660+ return q + ((f64)(_const_math__pi));
17661+ }
17662+ return q - ((f64)(_const_math__pi));
17663+ }
17664+ return q;
17665+}
17666+f64 math__asin(f64 x_) {
17667+ f64 x = x_;
17668+ if (x == ((f64)(0.0))) {
17669+ return x;
17670+ }
17671+ bool neg = false;
17672+ if (x < ((f64)(0.0))) {
17673+ x = -x;
17674+ neg = true;
17675+ }
17676+ if (x > ((f64)(1.0))) {
17677+ return math__nan();
17678+ }
17679+ f64 temp = math__sqrt(((f64)(1.0)) - x * x);
17680+ if (x > ((f64)(0.7))) {
17681+ temp = ((f64)(1.5707963267948966)) - math__satan(temp / x);
17682+ } else {
17683+ temp = math__satan(x / temp);
17684+ }
17685+ if (neg) {
17686+ temp = -temp;
17687+ }
17688+ return temp;
17689+}
17690+inline f64 math__acos(f64 x) {
17691+ if (x < ((f64)(-1.0)) || x > ((f64)(1.0))) {
17692+ return math__nan();
17693+ }
17694+ if (x > ((f64)(0.5))) {
17695+ return ((f64)(2.0)) * math__asin(math__sqrt(((f64)(0.5)) - ((f64)(0.5)) * x));
17696+ }
17697+ f64 z = ((f64)(_const_math__pi)) / ((f64)(4.0)) - math__asin(x);
17698+ z = z + ((f64)(_const_math__morebits));
17699+ z = z + ((f64)(_const_math__pi)) / ((f64)(4.0));
17700+ return z;
17701+}
17702+inline f64 math__log(f64 x) {
17703+ return log(x);
17704+}
17705+inline f64 math__log2(f64 x) {
17706+ return log2(x);
17707+}
17708+inline f64 math__log10(f64 x) {
17709+ return log10(x);
17710+}
17711+inline f64 math__log1p(f64 x) {
17712+ return log1p(x);
17713+}
17714+f64 math__log_b(f64 x) {
17715+ return logb(x);
17716+}
17717+inline f32 math__logf(f32 x) {
17718+ return logf(x);
17719+}
17720+f64 math__log_n(f64 x, f64 b) {
17721+ f64 y = math__log(x);
17722+ f64 z = math__log(b);
17723+ return y / z;
17724+}
17725+f64 math__pure_v_but_overridden_by_c_log10(f64 x) {
17726+ f64 x_ = x;
17727+ i64 hx = ((i64)(math__f64_bits(x_)));
17728+ i32 k = ((i32)(0));
17729+ if (hx < ((i64)(0x0010000000000000LL))) {
17730+ if ((hx & 0x7fffffffffffffffLL) == 0) {
17731+ return math__inf(-1);
17732+ }
17733+ if (hx < 0) {
17734+ return (x_ - x_) / (x_ - x_);
17735+ }
17736+ k = k - 54;
17737+ x_ *= _const_math__two54;
17738+ hx = ((i64)(math__f64_bits(x_)));
17739+ }
17740+ if (_us64_le(((u64)(0x7ff0000000000000LL)),hx)) {
17741+ return x_ + x_;
17742+ }
17743+ k = k + ((i32)((((u64)((v__rshift_i64(hx, (u64)52)) - 1023)))));
17744+ i32 i = ((i32)(v__rshift_u64(((((u64)(k)) & 0x8000000000000000ULL)), (u64)63)));
17745+ hx = (((hx & 0x000fffffffffffffLL)) | (v__lshift_u64(((u64)(0x3ff - i)), (u64)52)));
17746+ f64 y = ((f64)(k + i));
17747+ x_ = math__f64_from_bits(((u64)(hx)));
17748+ f64 z = y * _const_math__log10_2lo + _const_math__ivln10 * math__log(x_);
17749+ return z + y * _const_math__log10_2hi;
17750+}
17751+f64 math__pure_v_but_overridden_by_c_log2(f64 x) {
17752+ multi_return_f64_int mr_1442 = math__frexp(x);
17753+ f64 frac = mr_1442.arg0;
17754+ int expn = mr_1442.arg1;
17755+ if (frac == ((f64)(0.5))) {
17756+ return ((f64)(expn - 1));
17757+ }
17758+ return math__log(frac) * ((f64)(1.4426950408889634)) + ((f64)(expn));
17759+}
17760+f64 math__pure_v_but_overridden_by_c_log1p(f64 x) {
17761+ f64 y = ((f64)(1.0)) + x;
17762+ f64 z = y - ((f64)(1.0));
17763+ return math__log(y) - (z - x) / y;
17764+}
17765+f64 math__pure_v_but_overridden_by_c_log_b(f64 x) {
17766+ if (x == 0) {
17767+ return math__inf(-1);
17768+ }
17769+ if (math__is_inf(x, 0)) {
17770+ return math__inf(1);
17771+ }
17772+ if (math__is_nan(x)) {
17773+ return x;
17774+ }
17775+ return ((f64)(math__ilog_b_(x)));
17776+}
17777+int math__ilog_b(f64 x) {
17778+ if (x == 0) {
17779+ return ((int)(_const_min_i32));
17780+ }
17781+ if (math__is_nan(x)) {
17782+ return ((int)(_const_max_i32));
17783+ }
17784+ if (math__is_inf(x, 0)) {
17785+ return ((int)(_const_max_i32));
17786+ }
17787+ return math__ilog_b_(x);
17788+}
17789+VV_LOC int math__ilog_b_(f64 x_) {
17790+ multi_return_f64_int mr_2548 = math__normalize(x_);
17791+ f64 x = mr_2548.arg0;
17792+ int expn = mr_2548.arg1;
17793+ return ((int)(((v__rshift_u64(math__f64_bits(x), (u64)52)) & 0x7FF))) - 1023 + expn;
17794+}
17795+f64 math__pure_v_but_overridden_by_c_log(f64 a) {
17796+ f64 ln2_hi = 6.93147180369123816490e-01;
17797+ f64 ln2_lo = 1.90821492927058770002e-10;
17798+ f64 l1 = 6.666666666666735130e-01;
17799+ f64 l2 = 3.999999999940941908e-01;
17800+ f64 l3 = 2.857142874366239149e-01;
17801+ f64 l4 = 2.222219843214978396e-01;
17802+ f64 l5 = 1.818357216161805012e-01;
17803+ f64 l6 = 1.531383769920937332e-01;
17804+ f64 l7 = 1.479819860511658591e-01;
17805+ f64 x = a;
17806+ if (math__is_nan(x) || math__is_inf(x, 1)) {
17807+ return x;
17808+ } else if (x < 0) {
17809+ return math__nan();
17810+ } else if (x == 0) {
17811+ return math__inf(-1);
17812+ }
17813+ multi_return_f64_int mr_5139 = math__frexp(x);
17814+ f64 f1 = mr_5139.arg0;
17815+ int ki = mr_5139.arg1;
17816+ if (f1 < ((f64)((float_literal)(1.41421356237309504880168872420969807856967187537694807317667974 / 2)))) {
17817+ f1 *= 2;
17818+ ki--;
17819+ }
17820+ f64 f = f1 - 1;
17821+ f64 k = ((f64)(ki));
17822+ f64 s = f / (2 + f);
17823+ f64 s2 = s * s;
17824+ f64 s4 = s2 * s2;
17825+ f64 t1 = s2 * (l1 + s4 * (l3 + s4 * (l5 + s4 * l7)));
17826+ f64 t2 = s4 * (l2 + s4 * (l4 + s4 * l6));
17827+ f64 r = t1 + t2;
17828+ f64 hfsq = ((f64)(0.5)) * f * f;
17829+ return k * ln2_hi - ((hfsq - (s * (hfsq + r) + k * ln2_lo)) - f);
17830+}
17831+#if 0
17832+#else
17833+#endif
17834+f64 math__aprox_sin(f64 a) {
17835+ f64 a0 = 1.91059300966915117e-31;
17836+ f64 a1 = 1.00086760103908896;
17837+ f64 a2 = -1.21276126894734565e-2;
17838+ f64 a3 = -1.38078780785773762e-1;
17839+ f64 a4 = -2.67353392911981221e-2;
17840+ f64 a5 = 2.08026600266304389e-2;
17841+ f64 a6 = -3.03996055049204407e-3;
17842+ f64 a7 = 1.38235642404333740e-4;
17843+ f64 tmp = a4 + a * (a5 + a * (a6 + a * a7));
17844+ return a0 + a * (a1 + a * (a2 + a * (a3 + a * tmp)));
17845+}
17846+f64 math__aprox_cos(f64 a) {
17847+ f64 a0 = 9.9995999154986614e-1;
17848+ f64 a1 = 1.2548995793001028e-3;
17849+ f64 a2 = -5.0648546280678015e-1;
17850+ f64 a3 = 1.2942246466519995e-2;
17851+ f64 a4 = 2.8668384702547972e-2;
17852+ f64 a5 = 7.3726485210586547e-3;
17853+ f64 a6 = -3.8510875386947414e-3;
17854+ f64 a7 = 4.7196604604366623e-4;
17855+ f64 a8 = -1.8776444013090451e-5;
17856+ f64 tmp = a4 + a * (a5 + a * (a6 + a * (a7 + a * a8)));
17857+ return a0 + a * (a1 + a * (a2 + a * (a3 + a * tmp)));
17858+}
17859+inline f64 math__copysign(f64 x, f64 y) {
17860+ return math__f64_from_bits((((math__f64_bits(x) & ~_const_math__sign_mask)) | ((math__f64_bits(y) & _const_math__sign_mask))));
17861+}
17862+inline f64 math__degrees(f64 radians) {
17863+ return radians * ((f64)(57.29577951308232));
17864+}
17865+inline f64 math__radians(f64 degrees) {
17866+ return degrees * ((f64)(0.017453292519943295));
17867+}
17868+inline f64 math__angle_diff(f64 radian_a, f64 radian_b) {
17869+ f64 delta = math__fmod(radian_b - radian_a, _const_math__tau);
17870+ delta = math__fmod(delta + ((f64)(9.42477796076938)), _const_math__tau);
17871+ delta -= 3.141592653589793;
17872+ return delta;
17873+}
17874+Array_int math__digits(i64 num, math__DigitParams params) {
17875+ int b = params.base;
17876+ if (b < 2) {
17877+ builtin__panic_n(_S("digits: Cannot find digits of n with base:"), b);
17878+ VUNREACHABLE();
17879+ }
17880+ i64 n = num;
17881+ int sgn = 1;
17882+ if (n < 0) {
17883+ sgn = -1;
17884+ n = -n;
17885+ }
17886+ Array_int res = builtin____new_array_with_default(0, 0, sizeof(int), 0);
17887+ if (n == 0) {
17888+ builtin__array_push((array*)&res, _MOV((int[]){ 0 }));
17889+ return res;
17890+ }
17891+ for (;;) {
17892+ if (!(n != 0)) break;
17893+ i64 next_n = (i64)(VSAFE_DIV_i64(n , b));
17894+ builtin__array_push((array*)&res, _MOV((int[]){ ((int)(n - (i64)(next_n * b))) }));
17895+ n = next_n;
17896+ }
17897+ if (sgn == -1) {
17898+ (*(int*)builtin__array_get(res, res.len - 1)) *= sgn;
17899+ }
17900+ if (params.reverse) {
17901+ res = builtin__array_reverse(res);
17902+ }
17903+ return res;
17904+}
17905+int math__count_digits(i64 number) {
17906+ i64 n = number;
17907+ if (n == 0) {
17908+ return 1;
17909+ }
17910+ int c = 0;
17911+ for (;;) {
17912+ if (!(n != 0)) break;
17913+ n = VSAFE_DIV_i64(n , 10);
17914+ c++;
17915+ }
17916+ return c;
17917+}
17918+multi_return_f64_f64 math__minmax(f64 a, f64 b) {
17919+ if (a < b) {
17920+ return (multi_return_f64_f64){.arg0=a, .arg1=b};
17921+ }
17922+ return (multi_return_f64_f64){.arg0=b, .arg1=a};
17923+}
17924+inline f64 math__clamp(f64 x, f64 a, f64 b) {
17925+ if (x < a) {
17926+ return a;
17927+ }
17928+ if (x > b) {
17929+ return b;
17930+ }
17931+ return x;
17932+}
17933+inline f64 math__sign(f64 n) {
17934+ if (math__is_nan(n)) {
17935+ return math__nan();
17936+ }
17937+ return math__copysign(1.0, n);
17938+}
17939+inline int math__signi(f64 n) {
17940+ return ((int)(math__copysign(1.0, n)));
17941+}
17942+inline bool math__signbit(f64 x) {
17943+ return (math__f64_bits(x) & _const_math__sign_mask) != 0;
17944+}
17945+bool math__tolerance(f64 actual, f64 expected, f64 tol) {
17946+ if (actual == expected) {
17947+ return true;
17948+ }
17949+ f64 d = actual - expected;
17950+ if (d < 0) {
17951+ d = -d;
17952+ }
17953+ f64 ee = tol;
17954+ if (expected != 0) {
17955+ ee *= expected;
17956+ if (ee < 0) {
17957+ ee = -ee;
17958+ }
17959+ }
17960+ return d < ee;
17961+}
17962+bool math__close(f64 actual, f64 expected) {
17963+ return math__tolerance(actual, expected, 1e-14);
17964+}
17965+bool math__veryclose(f64 actual, f64 expected) {
17966+ return math__tolerance(actual, expected, 4e-16);
17967+}
17968+bool math__alike(f64 a, f64 b) {
17969+ if ((math__f64_bits(a) & 0xFFFFFFFFFFFFFFFCULL) == (math__f64_bits(b) & 0xFFFFFFFFFFFFFFFCULL)) {
17970+ return true;
17971+ }
17972+ if (a == -0LL && b == 0) {
17973+ return true;
17974+ }
17975+ if (a == 0 && b == -0LL) {
17976+ return true;
17977+ }
17978+ if (math__is_nan(a) && math__is_nan(b)) {
17979+ return true;
17980+ }
17981+ if (a == b) {
17982+ return math__signbit(a) == math__signbit(b);
17983+ }
17984+ return false;
17985+}
17986+multi_return_f64_f64 math__modf(f64 f) {
17987+ f64 abs_f = math__abs_T_f64(f);
17988+ f64 i = 0.0;
17989+ if (abs_f >= ((f64)(_const_math__modf_maxpowtwo))) {
17990+ i = f;
17991+ } else {
17992+ i = abs_f + ((f64)(_const_math__modf_maxpowtwo));
17993+ i -= _const_math__modf_maxpowtwo;
17994+ for (;;) {
17995+ if (!(i > abs_f)) break;
17996+ i -= 1.0;
17997+ }
17998+ if (f < ((f64)(0.0))) {
17999+ i = -i;
18000+ }
18001+ }
18002+ return (multi_return_f64_f64){.arg0=i, .arg1=f - i};
18003+}
18004+f32 math__nextafter32(f32 x, f32 y) {
18005+ f32 r = ((f32)(0.0));
18006+ if (math__is_nan(((f64)(x))) || math__is_nan(((f64)(y)))) {
18007+ r = ((f32)(math__nan()));
18008+ } else if (x == y) {
18009+ r = x;
18010+ } else if (x == 0) {
18011+ r = ((f32)(math__copysign(((f64)(math__f32_from_bits(1))), ((f64)(y)))));
18012+ } else if ((y > x) == (x > 0)) {
18013+ r = math__f32_from_bits(math__f32_bits(x) + 1);
18014+ } else {
18015+ r = math__f32_from_bits(math__f32_bits(x) - 1);
18016+ }
18017+ return r;
18018+}
18019+f64 math__nextafter(f64 x, f64 y) {
18020+ f64 r = 0.0;
18021+ if (math__is_nan(x) || math__is_nan(y)) {
18022+ r = math__nan();
18023+ } else if (x == y) {
18024+ r = x;
18025+ } else if (x == 0) {
18026+ r = math__copysign(math__f64_from_bits(1), y);
18027+ } else if ((y > x) == (x > 0)) {
18028+ r = math__f64_from_bits(math__f64_bits(x) + 1);
18029+ } else {
18030+ r = math__f64_from_bits(math__f64_bits(x) - 1);
18031+ }
18032+ return r;
18033+}
18034+VV_LOC multi_return_f64_f64 math__ChebSeries_eval_e(math__ChebSeries cs, f64 x) {
18035+ f64 d = 0.0;
18036+ f64 dd = 0.0;
18037+ f64 y = (((f64)(2.0)) * x - cs.a - cs.b) / (cs.b - cs.a);
18038+ f64 y2 = ((f64)(2.0)) * y;
18039+ f64 e_ = 0.0;
18040+ f64 temp = 0.0;
18041+ for (int j = cs.order; j >= 1; j--) {
18042+ temp = d;
18043+ d = y2 * d - dd + (*(f64*)builtin__array_get(cs.c, j));
18044+ e_ += math__abs_T_f64(y2 * temp) + math__abs_T_f64(dd) + math__abs_T_f64((*(f64*)builtin__array_get(cs.c, j)));
18045+ dd = temp;
18046+ }
18047+ temp = d;
18048+ d = y * d - dd + ((f64)(0.5)) * (*(f64*)builtin__array_get(cs.c, 0));
18049+ e_ += math__abs_T_f64(y * temp) + math__abs_T_f64(dd) + ((f64)(0.5)) * math__abs_T_f64((*(f64*)builtin__array_get(cs.c, 0)));
18050+ return (multi_return_f64_f64){.arg0=d, .arg1=((f64)(_const_math__internal__f64_epsilon)) * e_ + math__abs_T_f64((*(f64*)builtin__array_get(cs.c, cs.order)))};
18051+}
18052+inline f64 math__pow(f64 x, f64 y) {
18053+ return pow(x, y);
18054+}
18055+inline f32 math__powf(f32 a, f32 b) {
18056+ return powf(a, b);
18057+}
18058+inline f32 math__pure_v_but_overridden_by_c_powf(f32 a, f32 b) {
18059+ return ((f32)(math__pow(a, b)));
18060+}
18061+f64 math__pow10(int n) {
18062+ if (0 <= n && n <= 308) {
18063+ return (*(f64*)builtin__array_get(_const_math__pow10postab32, VSAFE_DIV_u32(((u32)(n)) , 32))) * (*(f64*)builtin__array_get(_const_math__pow10tab, VSAFE_MOD_u32(((u32)(n)) , 32)));
18064+ }
18065+ if (-323 <= n && n <= 0) {
18066+ return (*(f64*)builtin__array_get(_const_math__pow10negtab32, VSAFE_DIV_u32(((u32)(-n)) , 32))) / (*(f64*)builtin__array_get(_const_math__pow10tab, VSAFE_MOD_u32(((u32)(-n)) , 32)));
18067+ }
18068+ if (n > 0) {
18069+ return math__inf(1);
18070+ }
18071+ return 0.0;
18072+}
18073+i64 math__powi(i64 a, i64 b) {
18074+ i64 b_ = b;
18075+ i64 p = a;
18076+ i64 v = ((i64)(1));
18077+ if (b_ < 0) {
18078+ if (a == 0) {
18079+ return -1;
18080+ }
18081+ return (a * a != 1 ? (0) : ((((b_ & 1)) > 0 ? (a) : (1))));
18082+ }
18083+ for (; b_ > 0; ) {
18084+ if ((b_ & 1) > 0) {
18085+ v *= p;
18086+ }
18087+ p *= p;
18088+ b_ = v__rshift_i64(b_, (u64)1);
18089+ }
18090+ return v;
18091+}
18092+VV_LOC bool math__is_odd_int(f64 x) {
18093+ multi_return_f64_f64 mr_1555 = math__modf(x);
18094+ f64 xi = mr_1555.arg0;
18095+ f64 xf = mr_1555.arg1;
18096+ return xf == 0 && ((((i64)(xi)) & 1)) == 1;
18097+}
18098+f64 math__pure_v_but_overridden_by_c_pow(f64 x, f64 y) {
18099+ if (y == 0 || x == 1) {
18100+ return 1;
18101+ } else if (y == 1) {
18102+ return x;
18103+ } else if (math__is_nan(x) || math__is_nan(y)) {
18104+ return math__nan();
18105+ } else if (y == 2) {
18106+ return x * x;
18107+ } else if (y == 3) {
18108+ return x * x * x;
18109+ } else if (x == 0) {
18110+ if (y < 0) {
18111+ if (math__is_odd_int(y)) {
18112+ return math__copysign(math__inf(1), x);
18113+ }
18114+ return math__inf(1);
18115+ } else if (y > 0) {
18116+ if (math__is_odd_int(y)) {
18117+ return x;
18118+ }
18119+ return 0;
18120+ }
18121+ } else if (math__is_inf(y, 0)) {
18122+ if (x == -1) {
18123+ return 1;
18124+ } else if ((math__abs_T_f64(x) < 1) == math__is_inf(y, 1)) {
18125+ return 0;
18126+ } else {
18127+ return math__inf(1);
18128+ }
18129+ } else if (math__is_inf(x, 0)) {
18130+ if (math__is_inf(x, -1)) {
18131+ return math__pow(1 / x, -y);
18132+ }
18133+ if (y < 0) {
18134+ return 0;
18135+ } else if (y > 0) {
18136+ return math__inf(1);
18137+ }
18138+ } else if (y == ((f64)(0.5))) {
18139+ return math__sqrt(x);
18140+ } else if (y == ((f64)(-0.5))) {
18141+ return 1 / math__sqrt(x);
18142+ }
18143+ multi_return_f64_f64 mr_2579 = math__modf(math__abs_T_f64(y));
18144+ f64 yi = mr_2579.arg0;
18145+ f64 yf = mr_2579.arg1;
18146+ if (yf != 0 && x < 0) {
18147+ return math__nan();
18148+ }
18149+ if (yi >= (v__lshift_u64(((u64)(1)), (u64)63))) {
18150+ if (x == -1) {
18151+ return 1;
18152+ } else if ((math__abs_T_f64(x) < 1) == (y > 0)) {
18153+ return 0;
18154+ } else {
18155+ return math__inf(1);
18156+ }
18157+ }
18158+ if (yf == ((f64)(0.0))) {
18159+ f64 result = x;
18160+ for (i64 _t22 = 1; _t22 < ((i64)(yi)); ++_t22) {
18161+ result *= x;
18162+ }
18163+ if (y > 0) {
18164+ return result;
18165+ }
18166+ return 1 / result;
18167+ }
18168+ f64 a1 = 1.0;
18169+ int ae = 0;
18170+ if (yf != 0) {
18171+ if (yf > ((f64)(0.5))) {
18172+ yf--;
18173+ yi++;
18174+ }
18175+ a1 = math__exp(yf * math__log(x));
18176+ }
18177+ multi_return_f64_int mr_3354 = math__frexp(x);
18178+ f64 x1 = mr_3354.arg0;
18179+ int xe = mr_3354.arg1;
18180+ for (i64 i = ((i64)(yi)); i != 0; i = v__rshift_i64(i, (u64)1)) {
18181+ if (xe < ((int)(((u32)(v__lshift_u32(((u32)(-1)), (u64)12))))) || 4096 < xe) {
18182+ ae += xe;
18183+ break;
18184+ }
18185+ if ((i & 1) == 1) {
18186+ a1 *= x1;
18187+ ae += xe;
18188+ }
18189+ x1 *= x1;
18190+ xe = v__lshift_int(xe, (u64)1);
18191+ if (x1 < ((f64)(.5))) {
18192+ x1 += x1;
18193+ xe--;
18194+ }
18195+ }
18196+ if (y < 0) {
18197+ a1 = 1 / a1;
18198+ ae = -ae;
18199+ }
18200+ return math__ldexp(a1, ae);
18201+}
18202+inline f64 math__q_rsqrt(f64 x) {
18203+ f64 x_half = ((f64)(0.5)) * x;
18204+ i64 i = ((i64)(math__f64_bits(x)));
18205+ i = 0x5fe6eb50c7b537a9LL - (v__rshift_i64(i, (u64)1));
18206+ f64 j = math__f64_from_bits(((u64)(i)));
18207+ j *= (((f64)(1.5)) - x_half * j * j);
18208+ j *= (((f64)(1.5)) - x_half * j * j);
18209+ return j;
18210+}
18211+f64 math__scalbn(f64 x, int n_) {
18212+ int n = n_;
18213+ f64 x1p1023 = math__f64_from_bits(((u64)(0x7fe0000000000000LL)));
18214+ f64 x1p53 = math__f64_from_bits(((u64)(0x4340000000000000LL)));
18215+ f64 x1p_1022 = math__f64_from_bits(((u64)(0x0010000000000000LL)));
18216+ f64 y = x;
18217+ if (n > 1023) {
18218+ y *= x1p1023;
18219+ n -= 1023;
18220+ if (n > 1023) {
18221+ y *= x1p1023;
18222+ n -= 1023;
18223+ if (n > 1023) {
18224+ n = 1023;
18225+ }
18226+ }
18227+ } else if (n < -1022) {
18228+ y *= x1p_1022 * x1p53;
18229+ n += 969;
18230+ if (n < -1022) {
18231+ y *= x1p_1022 * x1p53;
18232+ n += 969;
18233+ if (n < -1022) {
18234+ n = -1022;
18235+ }
18236+ }
18237+ }
18238+ return y * math__f64_from_bits(v__lshift_u64(((u64)((0x3ff + n))), (u64)52));
18239+}
18240+inline f64 math__cos(f64 a) {
18241+ return cos(a);
18242+}
18243+inline f64 math__sin(f64 a) {
18244+ return sin(a);
18245+}
18246+inline f32 math__cosf(f32 a) {
18247+ return cosf(a);
18248+}
18249+inline f32 math__sinf(f32 a) {
18250+ return sinf(a);
18251+}
18252+f64 math__pure_v_but_overridden_by_c_sin(f64 x) {
18253+ f64 p1 = 7.85398125648498535156e-1;
18254+ f64 p2 = 3.77489470793079817668e-8;
18255+ f64 p3 = 2.69515142907905952645e-15;
18256+ int sgn_x = (x < 0 ? (-1) : (1));
18257+ f64 abs_x = math__abs_T_f64(x);
18258+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18259+ f64 x2 = x * x;
18260+ return x * (((f64)(1.0)) - x2 / ((f64)(6.0)));
18261+ } else {
18262+ int sgn_result = sgn_x;
18263+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18264+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18265+ if (((octant & 1)) == 1) {
18266+ octant++;
18267+ octant &= 7;
18268+ y += 1.0;
18269+ }
18270+ if (octant > 3) {
18271+ octant -= 4;
18272+ sgn_result = -sgn_result;
18273+ }
18274+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18275+ f64 result = 0.0;
18276+ if (octant == 0) {
18277+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18278+ multi_return_f64_f64 mr_1722 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18279+ f64 sin_cs_val = mr_1722.arg0;
18280+ result = z * (((f64)(1.0)) + z * z * sin_cs_val);
18281+ } else {
18282+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18283+ multi_return_f64_f64 mr_1845 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18284+ f64 cos_cs_val = mr_1845.arg0;
18285+ result = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18286+ }
18287+ result *= sgn_result;
18288+ return result;
18289+ }
18290+ return 0;
18291+}
18292+f64 math__pure_v_but_overridden_by_c_cos(f64 x) {
18293+ f64 p1 = 7.85398125648498535156e-1;
18294+ f64 p2 = 3.77489470793079817668e-8;
18295+ f64 p3 = 2.69515142907905952645e-15;
18296+ f64 abs_x = math__abs_T_f64(x);
18297+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18298+ f64 x2 = x * x;
18299+ return ((f64)(1.0)) - ((f64)(0.5)) * x2;
18300+ } else {
18301+ int sgn_result = 1;
18302+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18303+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18304+ if (((octant & 1)) == 1) {
18305+ octant++;
18306+ octant &= 7;
18307+ y += 1.0;
18308+ }
18309+ if (octant > 3) {
18310+ octant -= 4;
18311+ sgn_result = -sgn_result;
18312+ }
18313+ if (octant > 1) {
18314+ sgn_result = -sgn_result;
18315+ }
18316+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18317+ f64 result = 0.0;
18318+ if (octant == 0) {
18319+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18320+ multi_return_f64_f64 mr_2686 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18321+ f64 cos_cs_val = mr_2686.arg0;
18322+ result = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18323+ } else {
18324+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18325+ multi_return_f64_f64 mr_2825 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18326+ f64 sin_cs_val = mr_2825.arg0;
18327+ result = z * (((f64)(1.0)) + z * z * sin_cs_val);
18328+ }
18329+ result *= sgn_result;
18330+ return result;
18331+ }
18332+ return 0;
18333+}
18334+inline f32 math__pure_v_but_overridden_by_c_cosf(f32 a) {
18335+ return ((f32)(math__cos(a)));
18336+}
18337+inline f32 math__pure_v_but_overridden_by_c_sinf(f32 a) {
18338+ return ((f32)(math__sin(a)));
18339+}
18340+multi_return_f64_f64 math__sincos(f64 x) {
18341+ if (math__is_nan(x)) {
18342+ return (multi_return_f64_f64){.arg0=x, .arg1=x};
18343+ }
18344+ f64 p1 = 7.85398125648498535156e-1;
18345+ f64 p2 = 3.77489470793079817668e-8;
18346+ f64 p3 = 2.69515142907905952645e-15;
18347+ int sgn_x = (x < 0 ? (-1) : (1));
18348+ f64 abs_x = math__abs_T_f64(x);
18349+ if (math__is_inf(x, sgn_x)) {
18350+ return (multi_return_f64_f64){.arg0=math__nan(), .arg1=math__nan()};
18351+ }
18352+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18353+ f64 x2 = x * x;
18354+ return (multi_return_f64_f64){.arg0=x * (((f64)(1.0)) - x2 / ((f64)(6.0))), .arg1=((f64)(1.0)) - ((f64)(0.5)) * x2};
18355+ } else {
18356+ int sgn_result_sin = sgn_x;
18357+ int sgn_result_cos = 1;
18358+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18359+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18360+ if (((octant & 1)) == 1) {
18361+ octant++;
18362+ octant &= 7;
18363+ y += 1.0;
18364+ }
18365+ if (octant > 3) {
18366+ octant -= 4;
18367+ sgn_result_sin = -sgn_result_sin;
18368+ sgn_result_cos = -sgn_result_cos;
18369+ }
18370+ sgn_result_cos = (octant > 1 ? (-sgn_result_cos) : (sgn_result_cos));
18371+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18372+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18373+ multi_return_f64_f64 mr_4085 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18374+ f64 sin_cs_val = mr_4085.arg0;
18375+ multi_return_f64_f64 mr_4121 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18376+ f64 cos_cs_val = mr_4121.arg0;
18377+ f64 result_sin = 0.0;
18378+ f64 result_cos = 0.0;
18379+ if (octant == 0) {
18380+ result_sin = z * (((f64)(1.0)) + z * z * sin_cs_val);
18381+ result_cos = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18382+ } else {
18383+ result_sin = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18384+ result_cos = z * (((f64)(1.0)) + z * z * sin_cs_val);
18385+ }
18386+ result_sin *= sgn_result_sin;
18387+ result_cos *= sgn_result_cos;
18388+ return (multi_return_f64_f64){.arg0=result_sin, .arg1=result_cos};
18389+ }
18390+ return (multi_return_f64_f64){0};
18391+}
18392+f64 math__sinh(f64 x_) {
18393+ f64 x = x_;
18394+ f64 p0 = -0.6307673640497716991184787251e+6;
18395+ f64 p1 = -0.8991272022039509355398013511e+5;
18396+ f64 p2 = -0.2894211355989563807284660366e+4;
18397+ f64 p3 = -0.2630563213397497062819489e+2;
18398+ f64 q0 = -0.6307673640497716991212077277e+6;
18399+ f64 q1 = 0.1521517378790019070696485176e+5;
18400+ f64 q2 = -0.173678953558233699533450911e+3;
18401+ bool neg = false;
18402+ if (x < 0) {
18403+ x = -x;
18404+ neg = true;
18405+ }
18406+ f64 temp = 0.0;
18407+ if (x > 21) {
18408+ temp = math__exp(x) * ((f64)(0.5));
18409+ } else if (x > ((f64)(0.5))) {
18410+ f64 ex = math__exp(x);
18411+ temp = (ex - ((f64)(1.0)) / ex) * ((f64)(0.5));
18412+ } else {
18413+ f64 sq = x * x;
18414+ temp = (((p3 * sq + p2) * sq + p1) * sq + p0) * x;
18415+ temp = temp / (((sq + q2) * sq + q1) * sq + q0);
18416+ }
18417+ if (neg) {
18418+ temp = -temp;
18419+ }
18420+ return temp;
18421+}
18422+f64 math__cosh(f64 x) {
18423+ f64 abs_x = math__abs_T_f64(x);
18424+ if (abs_x > 21) {
18425+ return math__exp(abs_x) * ((f64)(0.5));
18426+ }
18427+ f64 ex = math__exp(abs_x);
18428+ return (ex + ((f64)(1.0)) / ex) * ((f64)(0.5));
18429+}
18430+inline f64 math__sqrt(f64 a) {
18431+ return sqrt(a);
18432+}
18433+inline f32 math__sqrtf(f32 a) {
18434+ return sqrtf(a);
18435+}
18436+inline f64 math__pure_v_but_overridden_by_c_sqrt(f64 a) {
18437+ f64 x = a;
18438+ if (x == ((f64)(0.0)) || math__is_nan(x) || math__is_inf(x, 1)) {
18439+ return x;
18440+ }
18441+ if (x < ((f64)(0.0))) {
18442+ return math__nan();
18443+ }
18444+ multi_return_f64_int mr_259 = math__frexp(x);
18445+ f64 z = mr_259.arg0;
18446+ int ex = mr_259.arg1;
18447+ f64 w = x;
18448+ x = ((f64)(4.173075996388649989089e-1)) + ((f64)(5.9016206709064458299663e-1)) * z;
18449+ if (((ex & 1)) != 0) {
18450+ x *= _const_math__sqrt2;
18451+ }
18452+ x = math__ldexp(x, v__rshift_int(ex, (u64)1));
18453+ x = ((f64)(0.5)) * (x + w / x);
18454+ x = ((f64)(0.5)) * (x + w / x);
18455+ x = ((f64)(0.5)) * (x + w / x);
18456+ return x;
18457+}
18458+inline f32 math__pure_v_but_overridden_by_c_sqrtf(f32 a) {
18459+ return ((f32)(math__sqrt(a)));
18460+}
18461+i64 math__sqrti(i64 a) {
18462+ i64 x = a;
18463+ i64 q = ((i64)(1));
18464+ i64 r = ((i64)(0));
18465+ for (; q <= x; ) {
18466+ q = v__lshift_i64(q, (u64)2);
18467+ }
18468+ for (; q > 1; ) {
18469+ q = v__rshift_i64(q, (u64)2);
18470+ i64 t = x - r - q;
18471+ r = v__rshift_i64(r, (u64)1);
18472+ if (t >= 0) {
18473+ x = t;
18474+ r += q;
18475+ }
18476+ }
18477+ return r;
18478+}
18479+inline f32 math__tanf(f32 a) {
18480+ return tanf(a);
18481+}
18482+f64 math__tan(f64 a) {
18483+ f64 x = a;
18484+ if (x == ((f64)(0.0)) || math__is_nan(x)) {
18485+ return x;
18486+ }
18487+ if (math__is_inf(x, 0)) {
18488+ return math__nan();
18489+ }
18490+ int sgn = 1;
18491+ if (x < 0) {
18492+ x = -x;
18493+ sgn = -1;
18494+ }
18495+ if (x > ((f64)(_const_math__tan_lossth))) {
18496+ return 0.0;
18497+ }
18498+ f64 y = math__floor(x * ((f64)(4.0)) / ((f64)(_const_math__pi)));
18499+ f64 z = math__ldexp(y, -3);
18500+ z = math__floor(z);
18501+ z = y - math__ldexp(z, 3);
18502+ int octant = ((int)(z));
18503+ if (((octant & 1)) == 1) {
18504+ octant++;
18505+ y += 1.0;
18506+ }
18507+ z = ((x - y * ((f64)(_const_math__tan_dp1))) - y * ((f64)(_const_math__tan_dp2))) - y * ((f64)(_const_math__tan_dp3));
18508+ f64 zz = z * z;
18509+ if (zz > ((f64)(1.0e-14))) {
18510+ y = z + z * (zz * ((((*(f64*)builtin__array_get(_const_math__tan_p, 0)) * zz) + (*(f64*)builtin__array_get(_const_math__tan_p, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_p, 2))) / ((((zz + (*(f64*)builtin__array_get(_const_math__tan_q, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 2))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 3))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 4))));
18511+ } else {
18512+ y = z;
18513+ }
18514+ if (((octant & 2)) == 2) {
18515+ y = ((f64)(-1.0)) / y;
18516+ }
18517+ if (sgn < 0) {
18518+ y = -y;
18519+ }
18520+ return y;
18521+}
18522+inline f32 math__pure_v_but_overridden_by_c_tanf(f32 a) {
18523+ return ((f32)(math__tan(a)));
18524+}
18525+f64 math__cot(f64 a) {
18526+ f64 x = a;
18527+ if (x == ((f64)(0.0))) {
18528+ return math__inf(1);
18529+ }
18530+ int sgn = 1;
18531+ if (x < 0) {
18532+ x = -x;
18533+ sgn = -1;
18534+ }
18535+ if (x > ((f64)(_const_math__tan_lossth))) {
18536+ return 0.0;
18537+ }
18538+ f64 y = math__floor(x * ((f64)(4.0)) / ((f64)(_const_math__pi)));
18539+ f64 z = math__ldexp(y, -3);
18540+ z = math__floor(z);
18541+ z = y - math__ldexp(z, 3);
18542+ int octant = ((int)(z));
18543+ if (((octant & 1)) == 1) {
18544+ octant++;
18545+ y += 1.0;
18546+ }
18547+ z = ((x - y * ((f64)(_const_math__tan_dp1))) - y * ((f64)(_const_math__tan_dp2))) - y * ((f64)(_const_math__tan_dp3));
18548+ f64 zz = z * z;
18549+ if (zz > ((f64)(1.0e-14))) {
18550+ y = z + z * (zz * ((((*(f64*)builtin__array_get(_const_math__tan_p, 0)) * zz) + (*(f64*)builtin__array_get(_const_math__tan_p, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_p, 2))) / ((((zz + (*(f64*)builtin__array_get(_const_math__tan_q, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 2))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 3))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 4))));
18551+ } else {
18552+ y = z;
18553+ }
18554+ if (((octant & 2)) == 2) {
18555+ y = -y;
18556+ } else {
18557+ y = ((f64)(1.0)) / y;
18558+ }
18559+ if (sgn < 0) {
18560+ y = -y;
18561+ }
18562+ return y;
18563+}
18564+f64 math__tanh(f64 x) {
18565+ f64 maxlog = 8.8029691931113054295988e+01;
18566+ f64 z = math__abs_T_f64(x);
18567+ if (z > ((f64)(0.5)) * maxlog) {
18568+ if (x < 0) {
18569+ return ((f64)(-1));
18570+ }
18571+ return 1.0;
18572+ } else if (z >= ((f64)(0.625))) {
18573+ f64 s = math__exp(((f64)(2.0)) * z);
18574+ z = ((f64)(1.0)) - ((f64)(2.0)) / (s + ((f64)(1.0)));
18575+ if (x < 0) {
18576+ z = -z;
18577+ }
18578+ } else {
18579+ if (x == 0) {
18580+ return x;
18581+ }
18582+ f64 s = x * x;
18583+ z = x + x * s * (((*(f64*)builtin__array_get(_const_math__tanh_p, 0)) * s + (*(f64*)builtin__array_get(_const_math__tanh_p, 1))) * s + (*(f64*)builtin__array_get(_const_math__tanh_p, 2))) / (((s + (*(f64*)builtin__array_get(_const_math__tanh_q, 0))) * s + (*(f64*)builtin__array_get(_const_math__tanh_q, 1))) * s + (*(f64*)builtin__array_get(_const_math__tanh_q, 2)));
18584+ }
18585+ return z;
18586+}
18587+inline u32 math__f32_bits(f32 f) {
18588+ #if defined(__TINYC__)
18589+ {
18590+ return *((u32*)(&f));
18591+ }
18592+ #endif
18593+ return ((math__U32_F32){.f = f,}).u;
18594+}
18595+inline f32 math__f32_from_bits(u32 b) {
18596+ #if defined(__TINYC__)
18597+ {
18598+ return *((f32*)(&b));
18599+ }
18600+ #endif
18601+ return ((math__U32_F32){.u = b,}).f;
18602+}
18603+inline u64 math__f64_bits(f64 f) {
18604+ #if defined(__TINYC__)
18605+ {
18606+ return *((u64*)(&f));
18607+ }
18608+ #endif
18609+ return ((math__U64_F64){.f = f,}).u;
18610+}
18611+inline f64 math__f64_from_bits(u64 b) {
18612+ #if defined(__TINYC__)
18613+ {
18614+ return *((f64*)(&b));
18615+ }
18616+ #endif
18617+ return ((math__U64_F64){.u = b,}).f;
18618+}
18619+inline f64 math__with_set_low_word(f64 f, u32 lo) {
18620+ u64 tmp = math__f64_bits(f);
18621+ tmp &= 0xffffffff00000000ULL;
18622+ tmp |= ((u64)(lo));
18623+ return math__f64_from_bits(tmp);
18624+}
18625+inline f64 math__with_set_high_word(f64 f, u32 hi) {
18626+ u64 tmp = math__f64_bits(f);
18627+ tmp &= 0x00000000ffffffffU;
18628+ tmp |= v__lshift_u64(((u64)(hi)), (u64)32);
18629+ return math__f64_from_bits(tmp);
18630+}
18631+inline u32 math__get_high_word(f64 f) {
18632+ return ((u32)(v__rshift_u64(math__f64_bits(f), (u64)32)));
18633+}
18634+VV_LOC void main__vf_init(void) {
18635+ string probe = _S("vf");
18636+ {int _ = probe.len;}
18637+ ;
18638+}
18639+// export alias: vf_init -> main__vf_init
18640+void vf_init(void) {
18641+ return main__vf_init();
18642+}
18643+VV_LOC int main__vf_add(int a, int b) {
18644+ return a + b;
18645+}
18646+// export alias: vf_add -> main__vf_add
18647+int vf_add(int a, int b) {
18648+ return main__vf_add(a, b);
18649+}
18650+VV_LOC char* main__vf_greet(char* name) {
18651+ string n = builtin__cstring_to_vstring(name);
18652+ string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")}));
18653+ u8* out = res.str;
18654+ builtin__string_free(&n);
18655+ return out;
18656+}
18657+// export alias: vf_greet -> main__vf_greet
18658+char* vf_greet(char* name) {
18659+ return main__vf_greet(name);
18660+}
18661+VV_LOC void main__vf_free(voidptr p) {
18662+ builtin___v_free(p);
18663+}
18664+// export alias: vf_free -> main__vf_free
18665+void vf_free(voidptr p) {
18666+ return main__vf_free(p);
18667+}
18668+VV_LOC void main__vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1) {
18669+ if (w <= 0 || h <= 0 || max_iter <= 0) {
18670+ return;
18671+ }
18672+ f64 aspect = ((f64)(w)) / ((f64)(h));
18673+ f64 inv_w = ((f64)(1.0)) / ((f64)(w));
18674+ f64 inv_h = ((f64)(1.0)) / ((f64)(h));
18675+ for (int y = y0; y < y1; y++) {
18676+ f64 im = cy + (((f64)(y)) * inv_h - ((f64)(0.5))) * scale;
18677+ int row = (y - y0) * w * 4;
18678+ for (int x = 0; x < w; x++) {
18679+ f64 re = cx + (((f64)(x)) * inv_w - ((f64)(0.5))) * scale * aspect;
18680+ f64 zr = 0.0;
18681+ f64 zi = 0.0;
18682+ f64 zr2 = 0.0;
18683+ f64 zi2 = 0.0;
18684+ int i = 0;
18685+ for (;;) {
18686+ if (!(i < max_iter)) break;
18687+ zr2 = zr * zr;
18688+ zi2 = zi * zi;
18689+ if (zr2 + zi2 > ((f64)(4.0))) {
18690+ break;
18691+ }
18692+ zi = ((f64)(2.0)) * zr * zi + im;
18693+ zr = zr2 - zi2 + re;
18694+ i++;
18695+ }
18696+ int idx = row + x * 4;
18697+ if (i >= max_iter) {
18698+ { // Unsafe block
18699+ buf[idx] = ((u8)(0));
18700+ buf[idx + 1] = ((u8)(0));
18701+ buf[idx + 2] = ((u8)(0));
18702+ buf[idx + 3] = ((u8)(255));
18703+ }
18704+ continue;
18705+ }
18706+ f64 mag = math__sqrt(zr2 + zi2);
18707+ f64 nu = ((f64)(i));
18708+ if (mag > ((f64)(1.0))) {
18709+ nu = ((f64)(i)) + ((f64)(1.0)) - math__log(math__log(mag) / math__log(2.0)) / math__log(2.0);
18710+ }
18711+ f64 t = nu / ((f64)(max_iter));
18712+ { // Unsafe block
18713+ buf[idx] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(3.0)) + t * ((f64)(18.0))))));
18714+ buf[idx + 1] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(3.6)) + t * ((f64)(18.0))))));
18715+ buf[idx + 2] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(4.2)) + t * ((f64)(18.0))))));
18716+ buf[idx + 3] = ((u8)(255));
18717+ }
18718+ }
18719+ }
18720+}
18721+// export alias: vf_mandelbrot -> main__vf_mandelbrot
18722+void vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1) {
18723+ return main__vf_mandelbrot(buf, w, h, cx, cy, scale, max_iter, y0, y1);
18724+}
18725+VV_LOC void main__main(void) {
18726+}
18727+inline f64 math__abs_T_f64(f64 a) {
18728+ return (a < 0 ? (-a) : (a));
18729+}
18730+void _vinit(int ___argc, voidptr ___argv) {
18731+ static bool once = false; if (once) {return;} once = true;
18732+ // Initializations of consts for module builtin.closure
18733+ g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3
18734+{
18735+{
18736+Array_fixed_u8_15 _t1;
18737+#if defined(__V_ppc64le)
18738+#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
18739+#elif defined(__V_amd64)
18740+ { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ;
18741+ memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15));
18742+ }
18743+ ;
18744+#elif defined(__V_x86)
18745+#elif defined(__V_arm64)
18746+#elif defined(__V_arm32)
18747+#elif defined(__V_rv64)
18748+#elif defined(__V_rv32)
18749+#elif defined(__V_s390x)
18750+#elif defined(__V_loongarch64)
18751+#elif defined(__V_sparc64)
18752+#elif 0
18753+#else
18754+#endif
18755+ memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15));
18756+}
18757+}
18758+{
18759+{
18760+Array_fixed_u8_6 _t3;
18761+#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
18762+#elif defined(__V_arm32)
18763+#elif defined(__V_amd64)
18764+ { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ;
18765+ memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6));
1651818766 }
1651918767 ;
1652018768 #elif defined(__V_x86)
@@ -16561,6 +18809,121 @@ Array_fixed_u8_6 _t3;
1656118809 _const_min_i64 = ((i64)(-9223372036854775807LL - 1));
1656218810 _const_max_i64 = ((i64)(9223372036854775807LL));
1656318811 _const_utf8_replacement_rune = ((rune)(0xfffd));
18812+ // Initializations of consts for module math
18813+{
18814+ _const_math__bernoulli = builtin__new_array_from_c_array(10, 10, sizeof(f64), _MOV((f64[10]){
18815+ 0.08333333333333333, -0.002777777777777778, 0.0007936507936507937, -0.0005952380952380953, 0.0008417508417508417, -0.0019175269175269176, 0.00641025641025641, -0.029550653594771242, 0.1800957401386015,
18816+ -1.3924322169059011}));
18817+}
18818+{
18819+ _const_math__factorials_table = builtin__new_array_from_c_array(171, 171, sizeof(f64), _MOV((f64[171]){
18820+ 1.000000000000000000000e+0, 1.000000000000000000000e+0, 2.000000000000000000000e+0, 6.000000000000000000000e+0, 2.400000000000000000000e+1, 1.200000000000000000000e+2, 7.200000000000000000000e+2, 5.040000000000000000000e+3, 4.032000000000000000000e+4,
18821+ 3.628800000000000000000e+5, 3.628800000000000000000e+6, 3.991680000000000000000e+7, 4.790016000000000000000e+8, 6.227020800000000000000e+9, 8.717829120000000000000e+10, 1.307674368000000000000e+12, 2.092278988800000000000e+13,
18822+ 3.556874280960000000000e+14, 6.402373705728000000000e+15, 1.216451004088320000000e+17, 2.432902008176640000000e+18, 5.109094217170944000000e+19, 1.124000727777607680000e+21, 2.585201673888497664000e+22, 6.204484017332394393600e+23,
18823+ 1.551121004333098598400e+25, 4.032914611266056355840e+26, 1.088886945041835216077e+28, 3.048883446117138605015e+29, 8.841761993739701954544e+30, 2.652528598121910586363e+32, 8.222838654177922817726e+33, 2.631308369336935301672e+35,
18824+ 8.683317618811886495518e+36, 2.952327990396041408476e+38, 1.033314796638614492967e+40, 3.719933267899012174680e+41, 1.376375309122634504632e+43, 5.230226174666011117600e+44, 2.039788208119744335864e+46, 8.159152832478977343456e+47,
18825+ 3.345252661316380710817e+49, 1.405006117752879898543e+51, 6.041526306337383563736e+52, 2.658271574788448768044e+54, 1.196222208654801945620e+56, 5.502622159812088949850e+57, 2.586232415111681806430e+59, 1.241391559253607267086e+61,
18826+ 6.082818640342675608723e+62, 3.041409320171337804361e+64, 1.551118753287382280224e+66, 8.065817517094387857166e+67, 4.274883284060025564298e+69, 2.308436973392413804721e+71, 1.269640335365827592597e+73, 7.109985878048634518540e+74,
18827+ 4.052691950487721675568e+76, 2.350561331282878571829e+78, 1.386831185456898357379e+80, 8.320987112741390144276e+81, 5.075802138772247988009e+83, 3.146997326038793752565e+85, 1.982608315404440064116e+87, 1.268869321858841641034e+89,
18828+ 8.247650592082470666723e+90, 5.443449390774430640037e+92, 3.647111091818868528825e+94, 2.480035542436830599601e+96, 1.711224524281413113725e+98, 1.197857166996989179607e+100, 8.504785885678623175212e+101, 6.123445837688608686152e+103,
18829+ 4.470115461512684340891e+105, 3.307885441519386412260e+107, 2.480914081139539809195e+109, 1.885494701666050254988e+111, 1.451830920282858696341e+113, 1.132428117820629783146e+115, 8.946182130782975286851e+116, 7.156945704626380229481e+118,
18830+ 5.797126020747367985880e+120, 4.753643337012841748421e+122, 3.945523969720658651190e+124, 3.314240134565353266999e+126, 2.817104114380550276949e+128, 2.422709538367273238177e+130, 2.107757298379527717214e+132, 1.854826422573984391148e+134,
18831+ 1.650795516090846108122e+136, 1.485715964481761497310e+138, 1.352001527678402962552e+140, 1.243841405464130725548e+142, 1.156772507081641574759e+144, 1.087366156656743080274e+146, 1.032997848823905926260e+148, 9.916779348709496892096e+149,
18832+ 9.619275968248211985333e+151, 9.426890448883247745626e+153, 9.332621544394415268170e+155, 9.332621544394415268170e+157, 9.425947759838359420852e+159, 9.614466715035126609269e+161, 9.902900716486180407547e+163, 1.029901674514562762385e+166,
18833+ 1.081396758240290900504e+168, 1.146280563734708354534e+170, 1.226520203196137939352e+172, 1.324641819451828974500e+174, 1.443859583202493582205e+176, 1.588245541522742940425e+178, 1.762952551090244663872e+180, 1.974506857221074023537e+182,
18834+ 2.231192748659813646597e+184, 2.543559733472187557120e+186, 2.925093693493015690688e+188, 3.393108684451898201198e+190, 3.969937160808720895402e+192, 4.684525849754290656574e+194, 5.574585761207605881323e+196, 6.689502913449127057588e+198,
18835+ 8.094298525273443739682e+200, 9.875044200833601362412e+202, 1.214630436702532967577e+205, 1.506141741511140879795e+207, 1.882677176888926099744e+209, 2.372173242880046885677e+211, 3.012660018457659544810e+213, 3.856204823625804217357e+215,
18836+ 4.974504222477287440390e+217, 6.466855489220473672507e+219, 8.471580690878820510985e+221, 1.118248651196004307450e+224, 1.487270706090685728908e+226, 1.992942746161518876737e+228, 2.690472707318050483595e+230, 3.659042881952548657690e+232,
18837+ 5.012888748274991661035e+234, 6.917786472619488492228e+236, 9.615723196941089004197e+238, 1.346201247571752460588e+241, 1.898143759076170969429e+243, 2.695364137888162776589e+245, 3.854370717180072770522e+247, 5.550293832739304789551e+249,
18838+ 8.047926057471991944849e+251, 1.174997204390910823948e+254, 1.727245890454638911203e+256, 2.556323917872865588581e+258, 3.808922637630569726986e+260, 5.713383956445854590479e+262, 8.627209774233240431623e+264, 1.311335885683452545607e+267,
18839+ 2.006343905095682394778e+269, 3.089769613847350887959e+271, 4.789142901463393876336e+273, 7.471062926282894447084e+275, 1.172956879426414428192e+278, 1.853271869493734796544e+280, 2.946702272495038326504e+282, 4.714723635992061322407e+284,
18840+ 7.590705053947218729075e+286, 1.229694218739449434110e+289, 2.004401576545302577600e+291, 3.287218585534296227263e+293, 5.423910666131588774984e+295, 9.003691705778437366474e+297, 1.503616514864999040201e+300, 2.526075744973198387538e+302,
18841+ 4.269068009004705274939e+304, 7.257415615307998967397e+306}));
18842+}
18843+{
18844+ _const_math__log_factorials_table = builtin__new_array_from_c_array(172, 172, sizeof(f64), _MOV((f64[172]){
18845+ 0.000000000000000000000e+0, 0.000000000000000000000e+0, 6.931471805599453094172e-1, 1.791759469228055000812e+0, 3.178053830347945619647e+0, 4.787491742782045994248e+0, 6.579251212010100995060e+0, 8.525161361065414300166e+0, 1.060460290274525022842e+1,
18846+ 1.280182748008146961121e+1, 1.510441257307551529523e+1, 1.750230784587388583929e+1, 1.998721449566188614952e+1, 2.255216385312342288557e+1, 2.519122118273868150009e+1, 2.789927138384089156609e+1, 3.067186010608067280376e+1,
18847+ 3.350507345013688888401e+1, 3.639544520803305357622e+1, 3.933988418719949403622e+1, 4.233561646075348502966e+1, 4.538013889847690802616e+1, 4.847118135183522387964e+1, 5.160667556776437357045e+1, 5.478472939811231919009e+1,
18848+ 5.800360522298051993929e+1, 6.126170176100200198477e+1, 6.455753862700633105895e+1, 6.788974313718153498289e+1, 7.125703896716800901007e+1, 7.465823634883016438549e+1, 7.809222355331531063142e+1, 8.155795945611503717850e+1,
18849+ 8.505446701758151741396e+1, 8.858082754219767880363e+1, 9.213617560368709248333e+1, 9.571969454214320248496e+1, 9.933061245478742692933e+1, 1.029681986145138126988e+2, 1.066317602606434591262e+2, 1.103206397147573954291e+2,
18850+ 1.140342117814617032329e+2, 1.177718813997450715388e+2, 1.215330815154386339623e+2, 1.253172711493568951252e+2, 1.291239336391272148826e+2, 1.329525750356163098828e+2, 1.368027226373263684696e+2, 1.406739236482342593987e+2,
18851+ 1.445657439463448860089e+2, 1.484777669517730320675e+2, 1.524095925844973578392e+2, 1.563608363030787851941e+2, 1.603311282166309070282e+2, 1.643201122631951814118e+2, 1.683274454484276523305e+2, 1.723527971391628015638e+2,
18852+ 1.763958484069973517152e+2, 1.804562914175437710518e+2, 1.845338288614494905025e+2, 1.886281734236715911873e+2, 1.927390472878449024360e+2, 1.968661816728899939914e+2, 2.010093163992815266793e+2, 2.051681994826411985358e+2,
18853+ 2.093425867525368356464e+2, 2.135322414945632611913e+2, 2.177369341139542272510e+2, 2.219564418191303339501e+2, 2.261905483237275933323e+2, 2.304390435657769523214e+2, 2.347017234428182677427e+2, 2.389783895618343230538e+2,
18854+ 2.432688490029827141829e+2, 2.475729140961868839366e+2, 2.518904022097231943772e+2, 2.562211355500095254561e+2, 2.605649409718632093053e+2, 2.649216497985528010421e+2, 2.692910976510198225363e+2, 2.736731242856937041486e+2,
18855+ 2.780675734403661429141e+2, 2.824742926876303960274e+2, 2.868931332954269939509e+2, 2.913239500942703075662e+2, 2.957666013507606240211e+2, 3.002209486470141317540e+2, 3.046868567656687154726e+2, 3.091641935801469219449e+2,
18856+ 3.136528299498790617832e+2, 3.181526396202093268500e+2, 3.226634991267261768912e+2, 3.271852877037752172008e+2, 3.317178871969284731381e+2, 3.362611819791984770344e+2, 3.408150588707990178690e+2, 3.453794070622668541074e+2,
18857+ 3.499541180407702369296e+2, 3.545390855194408088492e+2, 3.591342053695753987760e+2, 3.637393755555634901441e+2, 3.683544960724047495950e+2, 3.729794688856890206760e+2, 3.776141978739186564468e+2, 3.822585887730600291111e+2,
18858+ 3.869125491232175524822e+2, 3.915759882173296196258e+2, 3.962488170517915257991e+2, 4.009309482789157454921e+2, 4.056222961611448891925e+2, 4.103227765269373054205e+2, 4.150323067282496395563e+2, 4.197508055995447340991e+2,
18859+ 4.244781934182570746677e+2, 4.292143918666515701285e+2, 4.339593239950148201939e+2, 4.387129141861211848399e+2, 4.434750881209189409588e+2, 4.482457727453846057188e+2, 4.530248962384961351041e+2, 4.578123879812781810984e+2,
18860+ 4.626081785268749221865e+2, 4.674121995716081787447e+2, 4.722243839269805962399e+2, 4.770446654925856331047e+2, 4.818729792298879342285e+2, 4.867092611368394122258e+2, 4.915534482232980034989e+2, 4.964054784872176206648e+2,
18861+ 5.012652908915792927797e+2, 5.061328253420348751997e+2, 5.110080226652360267439e+2, 5.158908245878223975982e+2, 5.207811737160441513633e+2, 5.256790135159950627324e+2, 5.305842882944334921812e+2, 5.354969431801695441897e+2,
18862+ 5.404169241059976691050e+2, 5.453441777911548737966e+2, 5.502786517242855655538e+2, 5.552202941468948698523e+2, 5.601690540372730381305e+2, 5.651248810948742988613e+2, 5.700877257251342061414e+2, 5.750575390247102067619e+2,
18863+ 5.800342727671307811636e+2, 5.850178793888391176022e+2, 5.900083119756178539038e+2, 5.950055242493819689670e+2, 6.000094705553274281080e+2, 6.050201058494236838580e+2, 6.100373856862386081868e+2, 6.150612662070848845750e+2,
18864+ 6.200917041284773200381e+2, 6.251286567308909491967e+2, 6.301720818478101958172e+2, 6.352219378550597328635e+2, 6.402781836604080409209e+2, 6.453407786934350077245e+2, 6.504096828956552392500e+2, 6.554848567108890661717e+2,
18865+ 6.605662610758735291676e+2, 6.656538574111059132426e+2, 6.707476076119126755767e+2, 6.758474740397368739994e+2, 6.809534195136374546094e+2, 6.860654073019939978423e+2, 6.911834011144107529496e+2, 6.963073650938140118743e+2,
18866+ 7.014372638087370853465e+2, 7.065730622457873471107e+2, 7.117147258022900069535e+2}));
18867+}
18868+ _const_math__gamma_p = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){1.60119522476751861407e-04, 1.19135147006586384913e-03, 1.04213797561761569935e-02, 4.76367800457137231464e-02, 2.07448227648435975150e-01, 4.94214826801497100753e-01, 9.99999999999999996796e-01}));
18869+ _const_math__gamma_q = builtin__new_array_from_c_array(8, 8, sizeof(f64), _MOV((f64[8]){-2.31581873324120129819e-05, 5.39605580493303397842e-04, -4.45641913851797240494e-03, 1.18139785222060435552e-02, 3.58236398605498653373e-02, -2.34591795718243348568e-01, 7.14304917030273074085e-02, 1.00000000000000000320e+00}));
18870+ _const_math__gamma_s = builtin__new_array_from_c_array(5, 5, sizeof(f64), _MOV((f64[5]){7.87311395793093628397e-04, -2.29549961613378126380e-04, -2.68132617805781232825e-03, 3.47222221605458667310e-03, 8.33333333333482257126e-02}));
18871+{
18872+ _const_math__lgamma_a = builtin__new_array_from_c_array(12, 12, sizeof(f64), _MOV((f64[12]){
18873+ 7.72156649015328655494e-02, 3.22467033424113591611e-01, 6.73523010531292681824e-02, 2.05808084325167332806e-02, 7.38555086081402883957e-03, 2.89051383673415629091e-03, 1.19270763183362067845e-03, 5.10069792153511336608e-04, 2.20862790713908385557e-04,
18874+ 1.08011567247583939954e-04, 2.52144565451257326939e-05, 4.48640949618915160150e-05}));
18875+}
18876+ _const_math__lgamma_r = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){1.0, 1.39200533467621045958e+00, 7.21935547567138069525e-01, 1.71933865632803078993e-01, 1.86459191715652901344e-02, 7.77942496381893596434e-04, 7.32668430744625636189e-06}));
18877+ _const_math__lgamma_s = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){-7.72156649015328655494e-02, 2.14982415960608852501e-01, 3.25778796408930981787e-01, 1.46350472652464452805e-01, 2.66422703033638609560e-02, 1.84028451407337715652e-03, 3.19475326584100867617e-05}));
18878+{
18879+ _const_math__lgamma_t = builtin__new_array_from_c_array(15, 15, sizeof(f64), _MOV((f64[15]){
18880+ 4.83836122723810047042e-01, -1.47587722994593911752e-01, 6.46249402391333854778e-02, -3.27885410759859649565e-02, 1.79706750811820387126e-02, -1.03142241298341437450e-02, 6.10053870246291332635e-03, -3.68452016781138256760e-03, 2.25964780900612472250e-03,
18881+ -1.40346469989232843813e-03, 8.81081882437654011382e-04, -5.38595305356740546715e-04, 3.15632070903625950361e-04, -3.12754168375120860518e-04, 3.35529192635519073543e-04}));
18882+}
18883+ _const_math__lgamma_u = builtin__new_array_from_c_array(6, 6, sizeof(f64), _MOV((f64[6]){-7.72156649015328655494e-02, 6.32827064025093366517e-01, 1.45492250137234768737e+00, 9.77717527963372745603e-01, 2.28963728064692451092e-01, 1.33810918536787660377e-02}));
18884+ _const_math__lgamma_v = builtin__new_array_from_c_array(6, 6, sizeof(f64), _MOV((f64[6]){1.0, 2.45597793713041134822e+00, 2.12848976379893395361e+00, 7.69285150456672783825e-01, 1.04222645593369134254e-01, 3.21709242282423911810e-03}));
18885+ _const_math__lgamma_w = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){4.18938533204672725052e-01, 8.33333333333329678849e-02, -2.77777777728775536470e-03, 7.93650558643019558500e-04, -5.95187557450339963135e-04, 8.36339918996282139126e-04, -1.63092934096575273989e-03}));
18886+{
18887+ _const_math__pow10tab = builtin__new_array_from_c_array(32, 32, sizeof(f64), _MOV((f64[32]){
18888+ ((f64)(1e+00)), 1e+01, 1e+02, 1e+03, 1e+04, 1e+05, 1e+06, 1e+07, 1e+08,
18889+ 1e+09, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16,
18890+ 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24,
18891+ 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31}));
18892+}
18893+{
18894+ _const_math__pow10postab32 = builtin__new_array_from_c_array(10, 10, sizeof(f64), _MOV((f64[10]){
18895+ ((f64)(1e+00)), 1e+32, 1e+64, 1e+96, 1e+128, 1e+160, 1e+192, 1e+224, 1e+256,
18896+ 1e+288}));
18897+}
18898+{
18899+ _const_math__pow10negtab32 = builtin__new_array_from_c_array(11, 11, sizeof(f64), _MOV((f64[11]){
18900+ ((f64)(1e-00)), 1e-32, 1e-64, 1e-96, 1e-128, 1e-160, 1e-192, 1e-224, 1e-256,
18901+ 1e-288, 1e-320}));
18902+}
18903+{
18904+ _const_math__sin_data = builtin__new_array_from_c_array(12, 12, sizeof(f64), _MOV((f64[12]){
18905+ -0.3295190160663511504173, 0.0025374284671667991990, 0.0006261928782647355874, -4.6495547521854042157541e-06, -5.6917531549379706526677e-07, 3.7283335140973803627866e-09, 3.0267376484747473727186e-10, -1.7400875016436622322022e-12, -1.0554678305790849834462e-13,
18906+ 5.3701981409132410797062e-16, 2.5984137983099020336115e-17, -1.1821555255364833468288e-19}));
18907+}
18908+{
18909+ _const_math__cos_data = builtin__new_array_from_c_array(11, 11, sizeof(f64), _MOV((f64[11]){
18910+ 0.165391825637921473505668118136, -0.00084852883845000173671196530195, -0.000210086507222940730213625768083, 1.16582269619760204299639757584e-6, 1.43319375856259870334412701165e-7, -7.4770883429007141617951330184e-10, -6.0969994944584252706997438007e-11, 2.90748249201909353949854872638e-13, 1.77126739876261435667156490461e-14,
18911+ -7.6896421502815579078577263149e-17, -3.7363121133079412079201377318e-18}));
18912+}
18913+ _const_math__tan_p = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){-1.30936939181383777646e+4, 1.15351664838587416140e+6, -1.79565251976484877988e+7}));
18914+ _const_math__tan_q = builtin__new_array_from_c_array(5, 5, sizeof(f64), _MOV((f64[5]){1.00000000000000000000e+0, 1.36812963470692954678e+4, -1.32089234440210967447e+6, 2.50083801823357915839e+7, -5.38695755929454629881e+7}));
18915+ _const_math__tanh_p = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){-9.64399179425052238628e-1, -9.92877231001918586564e+1, -1.61468768441708447952e+3}));
18916+ _const_math__tanh_q = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){1.12811678491632931402e+2, 2.23548839060100448583e+3, 4.84406305325125486048e+3}));
18917+{
18918+{
18919+ _const_math__sin_cs = ((math__ChebSeries){.c = _const_math__sin_data,.order = 11,.a = -1,.b = 1,});
18920+}
18921+}
18922+{
18923+{
18924+ _const_math__cos_cs = ((math__ChebSeries){.c = _const_math__cos_data,.order = 10,.a = -1,.b = 1,});
18925+}
18926+}
1656418927 }
1656518928 void _vcleanup(void) {
1656618929 static bool once = false; if (once) {return;} once = true;
@@ -7,8 +7,9 @@
7 7
8 // V comptime_definitions:8 // V comptime_definitions:
9 // V compile time defines by -d or -define flags:9 // V compile time defines by -d or -define flags:
10-// All custom defines : linux10+// All custom defines : no_backtrace,linux
11-// Turned ON custom defines: linux11+// Turned ON custom defines: no_backtrace,linux
12+#define CUSTOM_DEFINE_no_backtrace
12 #define CUSTOM_DEFINE_linux13 #define CUSTOM_DEFINE_linux
13 14
14 15
@@ -20,6 +21,7 @@ typedef struct none none;
20 typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11;21 typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11;
21 typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11;22 typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11;
22 typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128;23 typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128;
24+typedef struct _v_Array_fixed_f64_4 _v_Array_fixed_f64_4;
23 typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32;25 typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32;
24 typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64;26 typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64;
25 typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5;27 typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5;
@@ -40,8 +42,6 @@ typedef struct _v_Array_fixed_u64_47 _v_Array_fixed_u64_47;
40 typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31;42 typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31;
41 typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64;43 typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64;
42 typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64;44 typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64;
43-typedef struct _v_Array_fixed_voidptr_100 _v_Array_fixed_voidptr_100;
44-typedef struct _v_Array_fixed_u8_1000 _v_Array_fixed_u8_1000;
45 typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17;45 typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17;
46 typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264;46 typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264;
47 typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10;47 typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10;
@@ -60,8 +60,10 @@ typedef struct multi_return_u64_int multi_return_u64_int;
60 typedef struct multi_return_i64_int multi_return_i64_int;60 typedef struct multi_return_i64_int multi_return_i64_int;
61 typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool;61 typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool;
62 typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool;62 typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool;
63-typedef struct multi_return_u64_u64 multi_return_u64_u64;
64 typedef struct multi_return_f64_int multi_return_f64_int;63 typedef struct multi_return_f64_int multi_return_f64_int;
64+typedef struct multi_return_i64_i64_i64 multi_return_i64_i64_i64;
65+typedef struct multi_return_f64_f64 multi_return_f64_f64;
66+typedef struct multi_return_u64_u64 multi_return_u64_u64;
65 // END_multi_return_typedefs67 // END_multi_return_typedefs
66 68
67 typedef struct strings__IndentParam strings__IndentParam;69 typedef struct strings__IndentParam strings__IndentParam;
@@ -106,6 +108,12 @@ typedef struct RunesIterator RunesIterator;
106 typedef union StrIntpMem StrIntpMem;108 typedef union StrIntpMem StrIntpMem;
107 typedef struct StrIntpData StrIntpData;109 typedef struct StrIntpData StrIntpData;
108 typedef struct ToWideConfig ToWideConfig;110 typedef struct ToWideConfig ToWideConfig;
111+typedef struct math__BezierPoint math__BezierPoint;
112+typedef struct math__DigitParams math__DigitParams;
113+typedef struct math__DivResult math__DivResult;
114+typedef struct math__ChebSeries math__ChebSeries;
115+typedef union math__U32_F32 math__U32_F32;
116+typedef union math__U64_F64 math__U64_F64;
109 typedef struct _result_int _result_int;117 typedef struct _result_int _result_int;
110 typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr;118 typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr;
111 typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken;119 typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken;
@@ -124,9 +132,9 @@ typedef struct _result_rune _result_rune;
124 typedef struct _result_string _result_string;132 typedef struct _result_string _result_string;
125 typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo;133 typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo;
126 typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr;134 typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr;
127-typedef struct _option_int _option_int;
128 typedef struct _option_rune _option_rune;135 typedef struct _option_rune _option_rune;
129 typedef struct _option_multi_return_string_string _option_multi_return_string_string;136 typedef struct _option_multi_return_string_string _option_multi_return_string_string;
137+typedef struct _option_int _option_int;
130 typedef struct _option_u8 _option_u8;138 typedef struct _option_u8 _option_u8;
131 139
132 // V preincludes:140 // V preincludes:
@@ -1479,6 +1487,23 @@ V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) {
1479 #endif1487 #endif
1480 #endif1488 #endif
1481 1489
1490+
1491+// added by module `math`, file: math.c.v:6:
1492+
1493+#ifdef __TINYC__
1494+#include <math.h>
1495+#else
1496+#if defined(__has_include)
1497+#if __has_include(<math.h>)
1498+#include <math.h>
1499+#else
1500+#error VERROR_MESSAGE Header file <math.h>, needed for module `math` was not found. Please install the corresponding development headers.
1501+#endif
1502+#else
1503+#include <math.h>
1504+#endif
1505+#endif
1506+
1482 #if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool)1507 #if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool)
1483 #ifdef bool1508 #ifdef bool
1484 #undef bool1509 #undef bool
@@ -1516,9 +1541,20 @@ typedef u8 bool;
1516 #define _const_rune_maps_utl -21541 #define _const_rune_maps_utl -2
1517 #define _const_degree 61542 #define _const_degree 6
1518 #define _const_mid_index 51543 #define _const_mid_index 5
1519-#define _const_max_len 11
1520 #define _const_replace_stack_buffer_size 101544 #define _const_replace_stack_buffer_size 10
1521 #define _const_kmp_stack_buffer_size 201545 #define _const_kmp_stack_buffer_size 20
1546+#define _const_math__internal__max_int_fact_arg 170
1547+#define _const_math__shift 52
1548+#define _const_math__bias 1023
1549+#define _const_math__pi_2 1.5707963267948966
1550+#define _const_math__pi_4 0.7853981633974483
1551+#define _const_math__one_over_tau 0.15915494309189535
1552+#define _const_math__one_over_pi 0.3183098861837907
1553+#define _const_math__tau_over2 3.141592653589793
1554+#define _const_math__tau_over4 1.5707963267948966
1555+#define _const_math__tau_over8 0.7853981633974483
1556+#define _const_math__log2_e 1.4426950408889634
1557+#define _const_math__log10_e 0.43429448190325176
1522 1558
1523 // Enum definitions:1559 // Enum definitions:
1524 1560
@@ -1722,6 +1758,9 @@ typedef array Array_builtin__closure__ClosureLifetimeFrame;
1722 typedef map Map_voidptr_builtin__closure__ClosureLiveInfo;1758 typedef map Map_voidptr_builtin__closure__ClosureLiveInfo;
1723 typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr;1759 typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr;
1724 typedef u8 Array_fixed_u8_128 [128];1760 typedef u8 Array_fixed_u8_128 [128];
1761+typedef array Array_f64;
1762+typedef array Array_math__BezierPoint;
1763+typedef f64 Array_fixed_f64_4 [4];
1725 typedef u8 Array_fixed_u8_32 [32];1764 typedef u8 Array_fixed_u8_32 [32];
1726 typedef u8 Array_fixed_u8_64 [64];1765 typedef u8 Array_fixed_u8_64 [64];
1727 typedef u8 Array_fixed_u8_5 [5];1766 typedef u8 Array_fixed_u8_5 [5];
@@ -1742,8 +1781,6 @@ typedef u64 Array_fixed_u64_47 [47];
1742 typedef u64 Array_fixed_u64_31 [31];1781 typedef u64 Array_fixed_u64_31 [31];
1743 typedef int Array_fixed_int_64 [64];1782 typedef int Array_fixed_int_64 [64];
1744 typedef voidptr Array_fixed_voidptr_64 [64];1783 typedef voidptr Array_fixed_voidptr_64 [64];
1745-typedef voidptr Array_fixed_voidptr_100 [100];
1746-typedef u8 Array_fixed_u8_1000 [1000];
1747 typedef array Array_GraphemeBreakProperty;1784 typedef array Array_GraphemeBreakProperty;
1748 typedef u8 Array_fixed_u8_17 [17];1785 typedef u8 Array_fixed_u8_17 [17];
1749 typedef i32 Array_fixed_i32_1264 [1264];1786 typedef i32 Array_fixed_i32_1264 [1264];
@@ -1964,6 +2001,33 @@ struct builtin__closure__FrameToken {
1964 u64 generation;2001 u64 generation;
1965 };2002 };
1966 2003
2004+struct math__BezierPoint {
2005+ f64 x;
2006+ f64 y;
2007+};
2008+
2009+struct math__DigitParams {
2010+ int base;
2011+ bool reverse;
2012+};
2013+
2014+struct math__ChebSeries {
2015+ Array_f64 c;
2016+ int order;
2017+ f64 a;
2018+ f64 b;
2019+};
2020+
2021+union math__U32_F32 {
2022+ u32 u;
2023+ f32 f;
2024+};
2025+
2026+union math__U64_F64 {
2027+ u64 u;
2028+ f64 f;
2029+};
2030+
1967 struct mapnode {2031 struct mapnode {
1968 voidptr* children;2032 voidptr* children;
1969 int len;2033 int len;
@@ -2011,6 +2075,9 @@ struct _v_Array_fixed_voidptr_11 {
2011 struct _v_Array_fixed_u8_128 {2075 struct _v_Array_fixed_u8_128 {
2012 u8 ret_arr[128];2076 u8 ret_arr[128];
2013 };2077 };
2078+struct _v_Array_fixed_f64_4 {
2079+ f64 ret_arr[4];
2080+};
2014 struct _v_Array_fixed_u8_32 {2081 struct _v_Array_fixed_u8_32 {
2015 u8 ret_arr[32];2082 u8 ret_arr[32];
2016 };2083 };
@@ -2071,12 +2138,6 @@ struct _v_Array_fixed_int_64 {
2071 struct _v_Array_fixed_voidptr_64 {2138 struct _v_Array_fixed_voidptr_64 {
2072 voidptr ret_arr[64];2139 voidptr ret_arr[64];
2073 };2140 };
2074-struct _v_Array_fixed_voidptr_100 {
2075- voidptr ret_arr[100];
2076-};
2077-struct _v_Array_fixed_u8_1000 {
2078- u8 ret_arr[1000];
2079-};
2080 struct _v_Array_fixed_u8_17 {2141 struct _v_Array_fixed_u8_17 {
2081 u8 ret_arr[17];2142 u8 ret_arr[17];
2082 };2143 };
@@ -2144,16 +2205,27 @@ struct multi_return_strconv__Dec64_bool {
2144 bool arg1;2205 bool arg1;
2145 };2206 };
2146 2207
2147-struct multi_return_u64_u64 {
2148- u64 arg0;
2149- u64 arg1;
2150-};
2151-
2152 struct multi_return_f64_int {2208 struct multi_return_f64_int {
2153 f64 arg0;2209 f64 arg0;
2154 int arg1;2210 int arg1;
2155 };2211 };
2156 2212
2213+struct multi_return_i64_i64_i64 {
2214+ i64 arg0;
2215+ i64 arg1;
2216+ i64 arg2;
2217+};
2218+
2219+struct multi_return_f64_f64 {
2220+ f64 arg0;
2221+ f64 arg1;
2222+};
2223+
2224+struct multi_return_u64_u64 {
2225+ u64 arg0;
2226+ u64 arg1;
2227+};
2228+
2157 // END_multi_return_structs2229 // END_multi_return_structs
2158 2230
2159 static bool Array_u8_contains(Array_u8 a, u8 v);2231 static bool Array_u8_contains(Array_u8 a, u8 v);
@@ -2171,12 +2243,6 @@ struct _option_builtin__closure__ClosureLifetimeState_ptr {
2171 byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1];2243 byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1];
2172 };2244 };
2173 2245
2174-struct _option_int {
2175- byte state;
2176- IError err;
2177- byte data[sizeof(int) > 1 ? sizeof(int) : 1];
2178-};
2179-
2180 struct _option_rune {2246 struct _option_rune {
2181 byte state;2247 byte state;
2182 IError err;2248 IError err;
@@ -2189,6 +2255,12 @@ struct _option_multi_return_string_string {
2189 byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1];2255 byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1];
2190 };2256 };
2191 2257
2258+struct _option_int {
2259+ byte state;
2260+ IError err;
2261+ byte data[sizeof(int) > 1 ? sizeof(int) : 1];
2262+};
2263+
2192 struct _option_u8 {2264 struct _option_u8 {
2193 byte state;2265 byte state;
2194 IError err;2266 IError err;
@@ -2660,15 +2732,7 @@ VV_LOC void builtin__autostr_addr_push(voidptr addr);
2660 VV_LOC void builtin__autostr_addr_pop(void);2732 VV_LOC void builtin__autostr_addr_pop(void);
2661 VV_LOC string builtin__autostr_array_circular(int len);2733 VV_LOC string builtin__autostr_array_circular(int len);
2662 void builtin__print_backtrace(void);2734 void builtin__print_backtrace(void);
2663-VV_LOC string builtin__demangle_v_symbol(string cname);
2664-VV_LOC Array_string builtin__split_generic_params(string s);
2665-VV_LOC string builtin__demangle_backtrace_sym(string s);
2666-VV_LOC void builtin__eprint_space_padding(string output, int max_len);
2667 bool builtin__print_backtrace_skipping_top_frames(int xskipframes);2735 bool builtin__print_backtrace_skipping_top_frames(int xskipframes);
2668-VV_LOC string builtin__backtrace_current_executable_name(void);
2669-VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name);
2670-VV_LOC string builtin__backtrace_shell_quote(string s);
2671-VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes);
2672 void builtin___v_exit(int code);2736 void builtin___v_exit(int code);
2673 _result_void builtin__at_exit(void (*cb)());2737 _result_void builtin__at_exit(void (*cb)());
2674 VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number);2738 VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number);
@@ -3113,6 +3177,134 @@ void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_);
3113 void builtin__ArrayFlags_clear_all(ArrayFlags* e);3177 void builtin__ArrayFlags_clear_all(ArrayFlags* e);
3114 void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_);3178 void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_);
3115 ArrayFlags builtin__ArrayFlags__static__zero(void);3179 ArrayFlags builtin__ArrayFlags__static__zero(void);
3180+f64 math__inf(int sign);
3181+f64 math__nan(void);
3182+bool math__is_nan(f64 f);
3183+bool math__is_inf(f64 f, int sign);
3184+bool math__is_finite(f64 f);
3185+multi_return_f64_int math__normalize(f64 x);
3186+f64 math__cbrt(f64 a);
3187+f64 math__mod(f64 x, f64 y);
3188+f64 math__fmod(f64 x, f64 y);
3189+i64 math__gcd(i64 a_, i64 b_);
3190+multi_return_i64_i64_i64 math__egcd(i64 a, i64 b);
3191+i64 math__lcm(i64 a, i64 b);
3192+f64 math__erf(f64 a);
3193+f64 math__erfc(f64 a);
3194+f64 math__exp(f64 x);
3195+f64 math__exp2(f64 x);
3196+f64 math__ldexp(f64 frac, int exp);
3197+f64 math__pure_v_but_overridden_by_c_exp(f64 x);
3198+f64 math__pure_v_but_overridden_by_c_exp2(f64 x);
3199+f64 math__pure_v_but_overridden_by_c_ldexp(f64 frac, int exp);
3200+multi_return_f64_int math__frexp(f64 x);
3201+f64 math__expm1(f64 x);
3202+VV_LOC f64 math__expmulti(f64 hi, f64 lo, int k);
3203+f64 math__factorial(f64 n);
3204+f64 math__log_factorial(f64 n);
3205+VV_LOC f64 math__log_factorial_asymptotic_expansion(int n);
3206+i64 math__factoriali(int n);
3207+f64 math__floor(f64 x);
3208+f32 math__floorf(f32 x);
3209+f64 math__ceil(f64 x);
3210+f64 math__trunc(f64 x);
3211+f64 math__round(f64 x);
3212+f64 math__round_sig(f64 x, int sig_digits);
3213+f64 math__round_to_even(f64 x);
3214+VV_LOC u64 math__safe_shift(u64 value, u64 shift);
3215+VV_LOC bool math__is_neg_int(f64 x);
3216+VV_LOC multi_return_f64_f64 math__stirling(f64 x);
3217+f64 math__gamma(f64 a);
3218+VV_LOC f64 math__gamma_too_small(f64 x, f64 z);
3219+f64 math__log_gamma(f64 x);
3220+multi_return_f64_int math__log_gamma_sign(f64 a);
3221+VV_LOC f64 math__sin_pi(f64 x_);
3222+f64 math__hypot(f64 x, f64 y);
3223+math__BezierPoint math__cubic_bezier(f64 t, Array_math__BezierPoint p);
3224+math__BezierPoint math__cubic_bezier_a(f64 t, Array_f64 x, Array_f64 y);
3225+math__BezierPoint math__cubic_bezier_fa(f64 t, Array_fixed_f64_4 x, Array_fixed_f64_4 y);
3226+math__BezierPoint math__cubic_bezier_coords(f64 t, f64 x0, f64 x1, f64 x2, f64 x3, f64 y0, f64 y1, f64 y2, f64 y3);
3227+f64 math__acosh(f64 x);
3228+f64 math__asinh(f64 x);
3229+f64 math__atanh(f64 x);
3230+VV_LOC f64 math__xatan(f64 x);
3231+VV_LOC f64 math__satan(f64 x);
3232+f64 math__atan(f64 x);
3233+f64 math__atan2(f64 y, f64 x);
3234+f64 math__asin(f64 x_);
3235+f64 math__acos(f64 x);
3236+f64 math__log(f64 x);
3237+f64 math__log2(f64 x);
3238+f64 math__log10(f64 x);
3239+f64 math__log1p(f64 x);
3240+f64 math__log_b(f64 x);
3241+f32 math__logf(f32 x);
3242+f64 math__log_n(f64 x, f64 b);
3243+f64 math__pure_v_but_overridden_by_c_log10(f64 x);
3244+f64 math__pure_v_but_overridden_by_c_log2(f64 x);
3245+f64 math__pure_v_but_overridden_by_c_log1p(f64 x);
3246+f64 math__pure_v_but_overridden_by_c_log_b(f64 x);
3247+int math__ilog_b(f64 x);
3248+VV_LOC int math__ilog_b_(f64 x_);
3249+f64 math__pure_v_but_overridden_by_c_log(f64 a);
3250+f64 math__aprox_sin(f64 a);
3251+f64 math__aprox_cos(f64 a);
3252+f64 math__copysign(f64 x, f64 y);
3253+f64 math__degrees(f64 radians);
3254+f64 math__radians(f64 degrees);
3255+f64 math__angle_diff(f64 radian_a, f64 radian_b);
3256+Array_int math__digits(i64 num, math__DigitParams params);
3257+int math__count_digits(i64 number);
3258+multi_return_f64_f64 math__minmax(f64 a, f64 b);
3259+f64 math__clamp(f64 x, f64 a, f64 b);
3260+f64 math__sign(f64 n);
3261+int math__signi(f64 n);
3262+bool math__signbit(f64 x);
3263+bool math__tolerance(f64 actual, f64 expected, f64 tol);
3264+bool math__close(f64 actual, f64 expected);
3265+bool math__veryclose(f64 actual, f64 expected);
3266+bool math__alike(f64 a, f64 b);
3267+multi_return_f64_f64 math__modf(f64 f);
3268+f32 math__nextafter32(f32 x, f32 y);
3269+f64 math__nextafter(f64 x, f64 y);
3270+VV_LOC multi_return_f64_f64 math__ChebSeries_eval_e(math__ChebSeries cs, f64 x);
3271+f64 math__pow(f64 x, f64 y);
3272+f32 math__powf(f32 a, f32 b);
3273+f32 math__pure_v_but_overridden_by_c_powf(f32 a, f32 b);
3274+f64 math__pow10(int n);
3275+i64 math__powi(i64 a, i64 b);
3276+VV_LOC bool math__is_odd_int(f64 x);
3277+f64 math__pure_v_but_overridden_by_c_pow(f64 x, f64 y);
3278+f64 math__q_rsqrt(f64 x);
3279+f64 math__scalbn(f64 x, int n_);
3280+f64 math__cos(f64 a);
3281+f64 math__sin(f64 a);
3282+f32 math__cosf(f32 a);
3283+f32 math__sinf(f32 a);
3284+f64 math__pure_v_but_overridden_by_c_sin(f64 x);
3285+f64 math__pure_v_but_overridden_by_c_cos(f64 x);
3286+f32 math__pure_v_but_overridden_by_c_cosf(f32 a);
3287+f32 math__pure_v_but_overridden_by_c_sinf(f32 a);
3288+multi_return_f64_f64 math__sincos(f64 x);
3289+f64 math__sinh(f64 x_);
3290+f64 math__cosh(f64 x);
3291+f64 math__sqrt(f64 a);
3292+f32 math__sqrtf(f32 a);
3293+f64 math__pure_v_but_overridden_by_c_sqrt(f64 a);
3294+f32 math__pure_v_but_overridden_by_c_sqrtf(f32 a);
3295+i64 math__sqrti(i64 a);
3296+f32 math__tanf(f32 a);
3297+f64 math__tan(f64 a);
3298+f32 math__pure_v_but_overridden_by_c_tanf(f32 a);
3299+f64 math__cot(f64 a);
3300+f64 math__tanh(f64 x);
3301+u32 math__f32_bits(f32 f);
3302+f32 math__f32_from_bits(u32 b);
3303+u64 math__f64_bits(f64 f);
3304+f64 math__f64_from_bits(u64 b);
3305+f64 math__with_set_low_word(f64 f, u32 lo);
3306+f64 math__with_set_high_word(f64 f, u32 hi);
3307+u32 math__get_high_word(f64 f);
3116 VV_LOC void main__vf_init(void);3308 VV_LOC void main__vf_init(void);
3117 VV_EXP void vf_init(void); // exported fn main.vf_init3309 VV_EXP void vf_init(void); // exported fn main.vf_init
3118 VV_LOC int main__vf_add(int a, int b);3310 VV_LOC int main__vf_add(int a, int b);
@@ -3121,7 +3313,10 @@ VV_LOC char* main__vf_greet(char* name);
3121 VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet3313 VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet
3122 VV_LOC void main__vf_free(voidptr p);3314 VV_LOC void main__vf_free(voidptr p);
3123 VV_EXP void vf_free(voidptr p); // exported fn main.vf_free3315 VV_EXP void vf_free(voidptr p); // exported fn main.vf_free
3316+VV_LOC void main__vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1);
3317+VV_EXP void vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1); // exported fn main.vf_mandelbrot
3124 VV_LOC void main__main(void);3318 VV_LOC void main__main(void);
3319+f64 math__abs_T_f64(f64 a);
3125 static bool Array_rune_arr_eq(Array_rune a, Array_rune b);3320 static bool Array_rune_arr_eq(Array_rune a, Array_rune b);
3126 static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b);3321 static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b);
3127 static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b);3322 static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b);
@@ -3489,11 +3684,182 @@ static Array_fixed_i32_1264 _const_rune_maps = {((i32)(0xB5)), 0xB5, 743, 0, 0xC
3489 static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed23684 static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed2
3490 static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed23685 static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed2
3491 static rune _const_utf8_replacement_rune; // inited later3686 static rune _const_utf8_replacement_rune; // inited later
3687+static const f64 _const_math__internal__f64_epsilon = 2.220446049250313e-16; // precomputed2
3688+static const f64 _const_math__internal__sqrt_f64_epsilon = 1.4901161193847656e-08; // precomputed2
3689+static const f64 _const_math__internal__root3_f64_epsilon = 6.055454452393343e-06; // precomputed2
3690+static const f64 _const_math__internal__root4_f64_epsilon = 0.0001220703125; // precomputed2
3691+static const f64 _const_math__internal__root5_f64_epsilon = 0.000740095979741405; // precomputed2
3692+static const f64 _const_math__internal__root6_f64_epsilon = 0.002460783300575925; // precomputed2
3693+static const f64 _const_math__internal__log_f64_epsilon = -36.04365338911715; // precomputed2
3694+static const f64 _const_math__internal__f64_min = 2.2250738585072014e-308; // precomputed2
3695+static const f64 _const_math__internal__sqrt_f64_min = 1.4916681462400413e-154; // precomputed2
3696+static const f64 _const_math__internal__root3_f64_min = 2.8126442852362996e-103; // precomputed2
3697+static const f64 _const_math__internal__root4_f64_min = 1.221338669755462e-77; // precomputed2
3698+static const f64 _const_math__internal__root5_f64_min = 2.9476022969691763e-62; // precomputed2
3699+static const f64 _const_math__internal__root6_f64_min = 5.303436890579822e-52; // precomputed2
3700+static const f64 _const_math__internal__log_f64_min = -708.3964185322641; // precomputed2
3701+static const f64 _const_math__internal__f64_max = 1.7976931348623157e+308; // precomputed2
3702+static const f64 _const_math__internal__sqrt_f64_max = 1.3407807929942596e+154; // precomputed2
3703+static const f64 _const_math__internal__root3_f64_max = 5.64380309412229e+102; // precomputed2
3704+static const f64 _const_math__internal__root4_f64_max = 1.157920892373162e+77; // precomputed2
3705+static const f64 _const_math__internal__root5_f64_max = 4.4765466227572707e+61; // precomputed2
3706+static const f64 _const_math__internal__root6_f64_max = 2.3756689782295612e+51; // precomputed2
3707+static const f64 _const_math__internal__log_f64_max = 709.782712893384; // precomputed2
3708+static const f64 _const_math__internal__f32_epsilon = 1.1920928955078125e-07; // precomputed2
3709+static const f64 _const_math__internal__sqrt_f32_epsilon = 0.00034526698300124393; // precomputed2
3710+static const f64 _const_math__internal__root3_f32_epsilon = 0.00492156660115185; // precomputed2
3711+static const f64 _const_math__internal__root4_f32_epsilon = 0.018581361171917516; // precomputed2
3712+static const f64 _const_math__internal__root5_f32_epsilon = 0.04123462221165294; // precomputed2
3713+static const f64 _const_math__internal__root6_f32_epsilon = 0.07015387801933583; // precomputed2
3714+static const f64 _const_math__internal__log_f32_epsilon = -15.942385152878742; // precomputed2
3715+static const f64 _const_math__internal__f32_min = 1.1754943508222875e-38; // precomputed2
3716+static const f64 _const_math__internal__sqrt_f32_min = 1.0842021724855044e-19; // precomputed2
3717+static const f64 _const_math__internal__root3_f32_min = 2.273736754432324e-13; // precomputed2
3718+static const f64 _const_math__internal__root4_f32_min = 3.2927225399135965e-10; // precomputed2
3719+static const f64 _const_math__internal__root5_f32_min = 2.5944428542140822e-08; // precomputed2
3720+static const f64 _const_math__internal__root6_f32_min = 4.768371582031254e-07; // precomputed2
3721+static const f64 _const_math__internal__log_f32_min = -87.3365447505531; // precomputed2
3722+static const f64 _const_math__internal__f32_max = 3.4028234663852886e+38; // precomputed2
3723+static const f64 _const_math__internal__sqrt_f32_max = 1.844674352395373e+19; // precomputed2
3724+static const f64 _const_math__internal__root3_f32_max = 6.981463519622324e+12; // precomputed2
3725+static const f64 _const_math__internal__root4_f32_max = 4.2949672319999986e+09; // precomputed2
3726+static const f64 _const_math__internal__root5_f32_max = 5.085900785596004e+07; // precomputed2
3727+static const f64 _const_math__internal__root6_f32_max = 2.642245923380775e+06; // precomputed2
3728+static const f64 _const_math__internal__log_f32_max = 88.72283905206835; // precomputed2
3729+static const f64 _const_math__internal__sflt_epsilon = 0.00048828125; // precomputed2
3730+static const f64 _const_math__internal__sqrt_sflt_epsilon = 0.02209708691207961; // precomputed2
3731+static const f64 _const_math__internal__root3_sflt_epsilon = 0.07874506561842959; // precomputed2
3732+static const f64 _const_math__internal__root4_sflt_epsilon = 0.14865088937534013; // precomputed2
3733+static const f64 _const_math__internal__root5_sflt_epsilon = 0.217637640824031; // precomputed2
3734+static const f64 _const_math__internal__root6_sflt_epsilon = 0.28061551207734325; // precomputed2
3735+static const f64 _const_math__internal__log_sflt_epsilon = -7.6246189861593985; // precomputed2
3736+static const f64 _const_math__internal__max_f64_fact_arg = 171.0; // precomputed2
3737+static const f64 _const_math__internal__max_long_f64_fact_arg = 1755.5; // precomputed2
3738+static const u64 _const_math__uvnan = 9221120237041090561U; // precomputed2
3739+static const u64 _const_math__uvinf = 9218868437227405312U; // precomputed2
3740+static const u64 _const_math__uvneginf = 18442240474082181120U; // precomputed2
3741+static const u64 _const_math__uvone = 4607182418800017408U; // precomputed2
3742+static const u64 _const_math__normalize_smallest_mask = 4503599627370496U; // precomputed2
3743+static const u64 _const_math__sign_mask = 9223372036854775808U; // precomputed2
3744+static const u64 _const_math__frac_mask = 4503599627370495U; // precomputed2
3745+static const f64 _const_math__epsilon = 2.220446049250313e-16; // precomputed2
3746+static const f64 _const_math__e = 2.718281828459045; // precomputed2
3747+static const f64 _const_math__pi = 3.141592653589793; // precomputed2
3748+static const f64 _const_math__phi = 1.618033988749895; // precomputed2
3749+static const f64 _const_math__tau = 6.283185307179586; // precomputed2
3750+static const f64 _const_math__sqrt2 = 1.4142135623730951; // precomputed2
3751+static const f64 _const_math__sqrt_3 = 1.7320508075688772; // precomputed2
3752+static const f64 _const_math__sqrt_5 = 2.23606797749979; // precomputed2
3753+static const f64 _const_math__sqrt_e = 1.6487212707001282; // precomputed2
3754+static const f64 _const_math__sqrt_pi = 1.772453850905516; // precomputed2
3755+static const f64 _const_math__sqrt_tau = 2.5066282746310007; // precomputed2
3756+static const f64 _const_math__sqrt_phi = 1.272019649514069; // precomputed2
3757+static const f64 _const_math__ln2 = 0.6931471805599453; // precomputed2
3758+static const f64 _const_math__ln10 = 2.302585092994046; // precomputed2
3759+static const f64 _const_math__two_thirds = 0.6666666666666666; // precomputed2
3760+static const f64 _const_math__max_f32 = 3.4028234663852886e+38; // precomputed2
3761+static const f64 _const_math__smallest_non_zero_f32 = 1.401298464324817e-45; // precomputed2
3762+static const f64 _const_math__max_f64 = 1.7976931348623157e+308; // precomputed2
3763+static const f64 _const_math__smallest_non_zero_f64 = 0.0; // precomputed2
3764+static const f64 _const_math__erx = 0.8450629115104675; // precomputed2
3765+static const f64 _const_math__efx = 0.1283791670955126; // precomputed2
3766+static const f64 _const_math__efx8 = 1.0270333367641007; // precomputed2
3767+static const f64 _const_math__pp0 = 0.12837916709551256; // precomputed2
3768+static const f64 _const_math__pp1 = -0.3250421072470015; // precomputed2
3769+static const f64 _const_math__pp2 = -0.02848174957559851; // precomputed2
3770+static const f64 _const_math__pp3 = -0.005770270296489442; // precomputed2
3771+static const f64 _const_math__pp4 = -2.3763016656650163e-05; // precomputed2
3772+static const f64 _const_math__qq1 = 0.39791722395915535; // precomputed2
3773+static const f64 _const_math__qq2 = 0.0650222499887673; // precomputed2
3774+static const f64 _const_math__qq3 = 0.005081306281875766; // precomputed2
3775+static const f64 _const_math__qq4 = 0.00013249473800432164; // precomputed2
3776+static const f64 _const_math__qq5 = -3.960228278775368e-06; // precomputed2
3777+static const f64 _const_math__pa0 = -0.0023621185607526594; // precomputed2
3778+static const f64 _const_math__pa1 = 0.41485611868374833; // precomputed2
3779+static const f64 _const_math__pa2 = -0.3722078760357013; // precomputed2
3780+static const f64 _const_math__pa3 = 0.31834661990116175; // precomputed2
3781+static const f64 _const_math__pa4 = -0.11089469428239668; // precomputed2
3782+static const f64 _const_math__pa5 = 0.035478304325618236; // precomputed2
3783+static const f64 _const_math__pa6 = -0.002166375594868791; // precomputed2
3784+static const f64 _const_math__qa1 = 0.10642088040084423; // precomputed2
3785+static const f64 _const_math__qa2 = 0.540397917702171; // precomputed2
3786+static const f64 _const_math__qa3 = 0.07182865441419627; // precomputed2
3787+static const f64 _const_math__qa4 = 0.12617121980876164; // precomputed2
3788+static const f64 _const_math__qa5 = 0.01363708391202905; // precomputed2
3789+static const f64 _const_math__qa6 = 0.011984499846799107; // precomputed2
3790+static const f64 _const_math__ra0 = -0.009864944034847148; // precomputed2
3791+static const f64 _const_math__ra1 = -0.6938585727071818; // precomputed2
3792+static const f64 _const_math__ra2 = -10.558626225323291; // precomputed2
3793+static const f64 _const_math__ra3 = -62.375332450326006; // precomputed2
3794+static const f64 _const_math__ra4 = -162.39666946257347; // precomputed2
3795+static const f64 _const_math__ra5 = -184.60509290671104; // precomputed2
3796+static const f64 _const_math__ra6 = -81.2874355063066; // precomputed2
3797+static const f64 _const_math__ra7 = -9.814329344169145; // precomputed2
3798+static const f64 _const_math__sa1 = 19.651271667439257; // precomputed2
3799+static const f64 _const_math__sa2 = 137.65775414351904; // precomputed2
3800+static const f64 _const_math__sa3 = 434.56587747522923; // precomputed2
3801+static const f64 _const_math__sa4 = 645.3872717332679; // precomputed2
3802+static const f64 _const_math__sa5 = 429.00814002756783; // precomputed2
3803+static const f64 _const_math__sa6 = 108.63500554177944; // precomputed2
3804+static const f64 _const_math__sa7 = 6.570249770319282; // precomputed2
3805+static const f64 _const_math__sa8 = -0.0604244152148581; // precomputed2
3806+static const f64 _const_math__rb0 = -0.0098649429247001; // precomputed2
3807+static const f64 _const_math__rb1 = -0.799283237680523; // precomputed2
3808+static const f64 _const_math__rb2 = -17.757954917754752; // precomputed2
3809+static const f64 _const_math__rb3 = -160.63638485582192; // precomputed2
3810+static const f64 _const_math__rb4 = -637.5664433683896; // precomputed2
3811+static const f64 _const_math__rb5 = -1025.0951316110772; // precomputed2
3812+static const f64 _const_math__rb6 = -483.5191916086514; // precomputed2
3813+static const f64 _const_math__sb1 = 30.33806074348246; // precomputed2
3814+static const f64 _const_math__sb2 = 325.7925129965739; // precomputed2
3815+static const f64 _const_math__sb3 = 1536.729586084437; // precomputed2
3816+static const f64 _const_math__sb4 = 3199.8582195085955; // precomputed2
3817+static const f64 _const_math__sb5 = 2553.0504064331644; // precomputed2
3818+static const f64 _const_math__sb6 = 474.52854120695537; // precomputed2
3819+static const f64 _const_math__sb7 = -22.44095244658582; // precomputed2
3820+static const f64 _const_math__ln2hi = 0.6931471803691238; // precomputed2
3821+static const f64 _const_math__ln2lo = 1.9082149292705877e-10; // precomputed2
3822+static const f64 _const_math__log_sqrt_2pi = 0.9189385332046728; // precomputed2
3823+static Array_f64 _const_math__bernoulli; // inited later
3824+static Array_f64 _const_math__factorials_table; // inited later
3825+static Array_f64 _const_math__log_factorials_table; // inited later
3826+static Array_f64 _const_math__gamma_p; // inited later
3827+static Array_f64 _const_math__gamma_q; // inited later
3828+static Array_f64 _const_math__gamma_s; // inited later
3829+static Array_f64 _const_math__lgamma_a; // inited later
3830+static Array_f64 _const_math__lgamma_r; // inited later
3831+static Array_f64 _const_math__lgamma_s; // inited later
3832+static Array_f64 _const_math__lgamma_t; // inited later
3833+static Array_f64 _const_math__lgamma_u; // inited later
3834+static Array_f64 _const_math__lgamma_v; // inited later
3835+static Array_f64 _const_math__lgamma_w; // inited later
3836+static const f64 _const_math__morebits = 6.123233995736766e-17; // precomputed2
3837+static const f64 _const_math__tan3pio8 = 2.414213562373095; // precomputed2
3838+static const f64 _const_math__two54 = 1.8014398509481984e+16; // precomputed2
3839+static const f64 _const_math__ivln10 = 0.4342944819032518; // precomputed2
3840+static const f64 _const_math__log10_2hi = 0.30102999566361177; // precomputed2
3841+static const f64 _const_math__log10_2lo = 3.694239077158931e-13; // precomputed2
3842+static const f64 _const_math__modf_maxpowtwo = 4.503599627370496e+15; // precomputed2
3843+static Array_f64 _const_math__pow10tab; // inited later
3844+static Array_f64 _const_math__pow10postab32; // inited later
3845+static Array_f64 _const_math__pow10negtab32; // inited later
3846+static Array_f64 _const_math__sin_data; // inited later
3847+static Array_f64 _const_math__cos_data; // inited later
3848+static Array_f64 _const_math__tan_p; // inited later
3849+static Array_f64 _const_math__tan_q; // inited later
3850+static const f64 _const_math__tan_dp1 = 0.7853981554508209; // precomputed2
3851+static const f64 _const_math__tan_dp2 = 7.946627356147928e-09; // precomputed2
3852+static const f64 _const_math__tan_dp3 = 3.061616997868383e-17; // precomputed2
3853+static const f64 _const_math__tan_lossth = 1.073741824e+09; // precomputed2
3854+static Array_f64 _const_math__tanh_p; // inited later
3855+static Array_f64 _const_math__tanh_q; // inited later
3492 static u32 _const_builtin__closure__closure_size_1; // inited later3856 static u32 _const_builtin__closure__closure_size_1; // inited later
3493 Array_fixed_int_64 g_autostr_type_stack = {0}; // global 63857 Array_fixed_int_64 g_autostr_type_stack = {0}; // global 6
3494 3858
3495 Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 63859 Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 6
3496 3860
3861+static math__ChebSeries _const_math__sin_cs; // inited later
3862+static math__ChebSeries _const_math__cos_cs; // inited later
3497 static int _const_builtin__closure__closure_size; // inited later3863 static int _const_builtin__closure__closure_size; // inited later
3498 3864
3499 // V interface table:3865 // V interface table:
@@ -5044,7 +5410,6 @@ inline int math__bits__leading_zeros_8(u8 x) {
5044 }5410 }
5045 #elif !defined(__TINYC__)5411 #elif !defined(__TINYC__)
5046 {5412 {
5047- return __builtin_clz(((u32)(x))) - 24;
5048 }5413 }
5049 #endif5414 #endif
5050 return math__bits__leading_zeros_8_default(x);5415 return math__bits__leading_zeros_8_default(x);
@@ -5058,7 +5423,6 @@ inline int math__bits__leading_zeros_16(u16 x) {
5058 }5423 }
5059 #elif !defined(__TINYC__)5424 #elif !defined(__TINYC__)
5060 {5425 {
5061- return __builtin_clz(((u32)(x))) - 16;
5062 }5426 }
5063 #endif5427 #endif
5064 return math__bits__leading_zeros_16_default(x);5428 return math__bits__leading_zeros_16_default(x);
@@ -5072,7 +5436,6 @@ inline int math__bits__leading_zeros_32(u32 x) {
5072 }5436 }
5073 #elif !defined(__TINYC__)5437 #elif !defined(__TINYC__)
5074 {5438 {
5075- return __builtin_clz(x);
5076 }5439 }
5077 #endif5440 #endif
5078 return math__bits__leading_zeros_32_default(x);5441 return math__bits__leading_zeros_32_default(x);
@@ -5086,7 +5449,6 @@ inline int math__bits__leading_zeros_64(u64 x) {
5086 }5449 }
5087 #elif !defined(__TINYC__)5450 #elif !defined(__TINYC__)
5088 {5451 {
5089- return __builtin_clzll(x);
5090 }5452 }
5091 #endif5453 #endif
5092 return math__bits__leading_zeros_64_default(x);5454 return math__bits__leading_zeros_64_default(x);
@@ -5100,7 +5462,6 @@ inline int math__bits__trailing_zeros_8(u8 x) {
5100 }5462 }
5101 #elif !defined(__TINYC__)5463 #elif !defined(__TINYC__)
5102 {5464 {
5103- return __builtin_ctz(((u32)(x)));
5104 }5465 }
5105 #endif5466 #endif
5106 return math__bits__trailing_zeros_8_default(x);5467 return math__bits__trailing_zeros_8_default(x);
@@ -5114,7 +5475,6 @@ inline int math__bits__trailing_zeros_16(u16 x) {
5114 }5475 }
5115 #elif !defined(__TINYC__)5476 #elif !defined(__TINYC__)
5116 {5477 {
5117- return __builtin_ctz(((u32)(x)));
5118 }5478 }
5119 #endif5479 #endif
5120 return math__bits__trailing_zeros_16_default(x);5480 return math__bits__trailing_zeros_16_default(x);
@@ -5128,7 +5488,6 @@ inline int math__bits__trailing_zeros_32(u32 x) {
5128 }5488 }
5129 #elif !defined(__TINYC__)5489 #elif !defined(__TINYC__)
5130 {5490 {
5131- return __builtin_ctz(x);
5132 }5491 }
5133 #endif5492 #endif
5134 return math__bits__trailing_zeros_32_default(x);5493 return math__bits__trailing_zeros_32_default(x);
@@ -5142,7 +5501,6 @@ inline int math__bits__trailing_zeros_64(u64 x) {
5142 }5501 }
5143 #elif !defined(__TINYC__)5502 #elif !defined(__TINYC__)
5144 {5503 {
5145- return __builtin_ctzll(x);
5146 }5504 }
5147 #endif5505 #endif
5148 return math__bits__trailing_zeros_64_default(x);5506 return math__bits__trailing_zeros_64_default(x);
@@ -5153,7 +5511,6 @@ inline int math__bits__ones_count_8(u8 x) {
5153 }5511 }
5154 #elif !defined(__TINYC__)5512 #elif !defined(__TINYC__)
5155 {5513 {
5156- return __builtin_popcount(((u32)(x)));
5157 }5514 }
5158 #endif5515 #endif
5159 return math__bits__ones_count_8_default(x);5516 return math__bits__ones_count_8_default(x);
@@ -5164,7 +5521,6 @@ inline int math__bits__ones_count_16(u16 x) {
5164 }5521 }
5165 #elif !defined(__TINYC__)5522 #elif !defined(__TINYC__)
5166 {5523 {
5167- return __builtin_popcount(((u32)(x)));
5168 }5524 }
5169 #endif5525 #endif
5170 return math__bits__ones_count_16_default(x);5526 return math__bits__ones_count_16_default(x);
@@ -5175,7 +5531,6 @@ inline int math__bits__ones_count_32(u32 x) {
5175 }5531 }
5176 #elif !defined(__TINYC__)5532 #elif !defined(__TINYC__)
5177 {5533 {
5178- return __builtin_popcount(x);
5179 }5534 }
5180 #endif5535 #endif
5181 return math__bits__ones_count_32_default(x);5536 return math__bits__ones_count_32_default(x);
@@ -5186,7 +5541,6 @@ inline int math__bits__ones_count_64(u64 x) {
5186 }5541 }
5187 #elif !defined(__TINYC__)5542 #elif !defined(__TINYC__)
5188 {5543 {
5189- return __builtin_popcountll(x);
5190 }5544 }
5191 #endif5545 #endif
5192 return math__bits__ones_count_64_default(x);5546 return math__bits__ones_count_64_default(x);
@@ -10152,226 +10506,18 @@ VV_LOC string builtin__autostr_array_circular(int len) {
10152 return res;10506 return res;
10153 }10507 }
10154 void builtin__print_backtrace(void) {10508 void builtin__print_backtrace(void) {
10155- #if !defined(CUSTOM_DEFINE_no_backtrace)
10156- {
10157- #if 0
10158- {
10159- }
10160- #elif defined(__TINYC__)
10161- {
10162- }
10163- #elif defined(CUSTOM_DEFINE_use_libbacktrace)
10164- {
10165- }
10166- #else
10167- {
10168- builtin__print_backtrace_skipping_top_frames(2);
10169- }
10170- #endif
10171- }
10172- #endif
10173-}
10174-VV_LOC string builtin__demangle_v_symbol(string cname) {
10175- string name = cname;
10176- if (builtin__string_starts_with(name, _S("builtin__"))) {
10177- name = builtin__string_substr(name, 9, 2147483647);
10178- }
10179- name = builtin__string_replace(name, _S("__ptr__"), _S("&"));
10180- _option_int _t1 = builtin__string_index(name, _S("_T_"));
10181- if (_t1.state != 0) {
10182- *(int*) _t1.data = -1;
10183- }
10184-
10185- int t_pos = (*(int*)_t1.data);
10186- if (t_pos >= 0) {
10187- string base = builtin__string_replace(builtin__string_substr(name, 0, t_pos), _S("__"), _S("."));
10188- string generic_suffix = builtin__string_substr(name, t_pos + 3, 2147483647);
10189- Array_string params = builtin__split_generic_params(generic_suffix);
10190- Array_string demangled_params = builtin____new_array_with_default(0, params.len, sizeof(string), 0);
10191- for (int _t2 = 0; _t2 < params.len; ++_t2) {
10192- string param = ((string*)params.data)[_t2];
10193- builtin__array_push((array*)&demangled_params, _MOV((string[]){ builtin__string_replace(param, _S("__"), _S(".")) }));
10194- }
10195- return builtin__string_plus_many(4, _MOV((string[4]){base, _S("["), Array_string_join(demangled_params, _S(", ")), _S("]")}));
10196- }
10197- name = builtin__string_replace(name, _S("__"), _S("."));
10198- if (_SLIT_EQ(name.str, name.len, "main.main")) {
10199- return _S("main");
10200- }
10201- return name;
10202-}
10203-VV_LOC Array_string builtin__split_generic_params(string s) {
10204- Array_string params = builtin____new_array_with_default(0, 0, sizeof(string), 0);
10205- int start = 0;
10206- int i = 0;
10207- for (;;) {
10208- if (!(i < s.len)) break;
10209- if (s.str[ i] == '_') {
10210- if (i + 1 < s.len && s.str[ i + 1] == '_') {
10211- i += 2;
10212- } else {
10213- if (i > start) {
10214- builtin__array_push((array*)&params, _MOV((string[]){ builtin__string_substr(s, start, i) }));
10215- }
10216- i++;
10217- start = i;
10218- }
10219- } else {
10220- i++;
10221- }
10222- }
10223- if (start < s.len) {
10224- builtin__array_push((array*)&params, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) }));
10225- }
10226- return params;
10227-}
10228-VV_LOC string builtin__demangle_backtrace_sym(string s) {
10229- _option_int _t1 = builtin__string_index(s, _S("("));
10230- if (_t1.state != 0) {
10231- return s;
10232- }
10233-
10234- int paren_start = (*(int*)_t1.data);
10235- int plus_pos = builtin__string_index_after_(s, _S("+"), paren_start);
10236- if (plus_pos < 0) {
10237- return s;
10238- }
10239- string symbol = builtin__string_substr(s, paren_start + 1, plus_pos);
10240- if (symbol.len == 0) {
10241- return s;
10242- }
10243- return builtin__string_plus_many(3, _MOV((string[3]){builtin__string_substr(s, 0, paren_start + 1), builtin__demangle_v_symbol(symbol), builtin__string_substr(s, plus_pos, 2147483647)}));
10244-}
10245-VV_LOC void builtin__eprint_space_padding(string output, int max_len) {
10246- int padding_len = max_len - output.len;
10247- if (padding_len > 0) {
10248- for (int _t1 = 0; _t1 < padding_len; ++_t1) {
10249- builtin__eprint(_S(" "));
10250- }
10251- }
10252 }10509 }
10253 bool builtin__print_backtrace_skipping_top_frames(int xskipframes) {10510 bool builtin__print_backtrace_skipping_top_frames(int xskipframes) {
10254 #if defined(CUSTOM_DEFINE_no_backtrace)10511 #if defined(CUSTOM_DEFINE_no_backtrace)
10255 {10512 {
10513+ return false;
10256 }10514 }
10257 #else10515 #else
10258 {10516 {
10259- int skipframes = xskipframes + 2;
10260- #if 0
10261- {
10262- }
10263- #elif 1
10264- {
10265- return builtin__print_backtrace_skipping_top_frames_linux(skipframes);
10266- }
10267- #else
10268- {
10269- }
10270- #endif
10271 }10517 }
10272 #endif10518 #endif
10273 return false;10519 return false;
10274 }10520 }
10275-VV_LOC string builtin__backtrace_current_executable_name(void) {
10276- Array_string args = builtin__arguments();
10277- if (args.len == 0) {
10278- return _S("");
10279- }
10280- return (*(string*)builtin__array_get(args, 0));
10281-}
10282-VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name) {
10283- if (executable.len == 0) {
10284- return _S("/proc/self/exe");
10285- }
10286- if (builtin__string_contains(executable, _S("/"))) {
10287- return executable;
10288- }
10289- if (current_executable_name.len > 0 && builtin__string__eq(builtin__string_all_after_last(executable, _S("/")), builtin__string_all_after_last(current_executable_name, _S("/")))) {
10290- return _S("/proc/self/exe");
10291- }
10292- return executable;
10293-}
10294-VV_LOC string builtin__backtrace_shell_quote(string s) {
10295- string quoted = _S("'");
10296- for (int i = 0; i < s.len; ++i) {
10297- if (builtin__string_at(s, i) == '\'') {
10298- quoted = builtin__string__plus(quoted, _S("'\\''"));
10299- } else {
10300- quoted = builtin__string__plus(quoted, builtin__u8_ascii_str(builtin__string_at(s, i)));
10301- }
10302- }
10303- return builtin__string__plus(quoted, _S("'"));
10304-}
10305-VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes) {
10306- #if defined(CUSTOM_DEFINE_no_backtrace)
10307- {
10308- }
10309- #else
10310- {
10311- #if 1
10312- {
10313- #if 0
10314- {
10315- }
10316- #else
10317- {
10318- string current_executable_name = builtin__backtrace_current_executable_name();
10319- Array_fixed_voidptr_100 buffer = {0};
10320- i32 nr_ptrs = backtrace(&buffer[0], 100);
10321- if (nr_ptrs < 2) {
10322- builtin__eprintln(_S("C.backtrace returned less than 2 frames"));
10323- return false;
10324- }
10325- int nr_actual_frames = (int)(nr_ptrs - skipframes);
10326- char** csymbols = backtrace_symbols(((voidptr)(&buffer[skipframes])), nr_actual_frames);
10327- for (int i = 0; i < nr_actual_frames; ++i) {
10328- string sframe = builtin__tos2(((u8*)(csymbols[i])));
10329- string executable = builtin__string_all_before(sframe, _S("("));
10330- string addr2line_executable = builtin__backtrace_addr2line_executable(executable, current_executable_name);
10331- string addr = builtin__string_all_before(builtin__string_all_after(sframe, _S("[")), _S("]"));
10332- string beforeaddr = builtin__string_all_before(sframe, _S("["));
10333- string cmd = builtin__string_plus_many(4, _MOV((string[4]){_S("addr2line -e "), builtin__backtrace_shell_quote(addr2line_executable), _S(" "), builtin__backtrace_shell_quote(addr)}));
10334- voidptr f = popen(((char*)(cmd.str)), "r");
10335- if (f == ((void*)0)) {
10336- builtin__eprintln(sframe);
10337- continue;
10338- }
10339- Array_fixed_u8_1000 buf = {0};
10340- string output = _S("");
10341- { // Unsafe block
10342- u8* bp = ((u8*)(&buf[0]));
10343- for (;;) {
10344- if (!(fgets(((char*)(bp)), 1000, f) != 0)) break;
10345- output = builtin__string__plus(output, builtin__tos(bp, builtin__vstrlen(bp)));
10346- }
10347- }
10348- output = builtin__string__plus(builtin__string_trim_chars(output, _S(" \t\n"), TrimMode__trim_both), _S(":"));
10349- if (pclose(f) != 0) {
10350- builtin__eprintln(sframe);
10351- continue;
10352- }
10353- if (_SLIT_EQ(output.str, output.len, "??:0:") || _SLIT_EQ(output.str, output.len, "??:?:")) {
10354- output = _S("");
10355- }
10356- output = builtin__string_replace(output, _S(" (discriminator"), _S(": (d."));
10357- builtin__eprint(output);
10358- builtin__eprint_space_padding(output, 55);
10359- builtin__eprint(_S(" | "));
10360- builtin__eprint(addr);
10361- builtin__eprint(_S(" | "));
10362- builtin__eprintln(builtin__demangle_backtrace_sym(beforeaddr));
10363- }
10364- if (nr_actual_frames > 0) {
10365- free(csymbols);
10366- }
10367- }
10368- #endif
10369- }
10370- #endif
10371- }
10372- #endif
10373- return true;
10374-}
10375 VNORETURN void builtin___v_exit(int code) {10521 VNORETURN void builtin___v_exit(int code) {
10376 exit(code);10522 exit(code);
10377 VUNREACHABLE();10523 VUNREACHABLE();
@@ -10410,12 +10556,12 @@ VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number) {
10410 #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)10556 #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)
10411 {10557 {
10412 }10558 }
10413- #elif 010559+ #elif 1
10414 {10560 {
10561+ builtin__print_backtrace_skipping_top_frames(1);
10415 }10562 }
10416 #else10563 #else
10417 {10564 {
10418- builtin__print_backtrace();
10419 }10565 }
10420 #endif10566 #endif
10421 builtin___v_exit(128 + signal_number);10567 builtin___v_exit(128 + signal_number);
@@ -10489,7 +10635,7 @@ Array_string builtin__arguments(void) {
10489 return res;10635 return res;
10490 }10636 }
10491 string builtin__vcurrent_hash(void) {10637 string builtin__vcurrent_hash(void) {
10492- return _S("");10638+ return _S("7647ce1");
10493 }10639 }
10494 u64 builtin__v_getpid(void) {10640 u64 builtin__v_getpid(void) {
10495 #if defined(CUSTOM_DEFINE_no_getpid)10641 #if defined(CUSTOM_DEFINE_no_getpid)
@@ -12451,22 +12597,14 @@ VNORETURN void builtin___v_panic(string s) {
12451 }12597 }
12452 #elif defined(CUSTOM_DEFINE_no_backtrace)12598 #elif defined(CUSTOM_DEFINE_no_backtrace)
12453 {12599 {
12600+ exit(1);
12601+ VUNREACHABLE();
12454 }12602 }
12455 #elif 012603 #elif 0
12456 {12604 {
12457 }12605 }
12458 #else12606 #else
12459 {12607 {
12460- #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)
12461- {
12462- }
12463- #else
12464- {
12465- builtin__print_backtrace_skipping_top_frames(1);
12466- }
12467- #endif
12468- exit(1);
12469- VUNREACHABLE();
12470 }12608 }
12471 #endif12609 #endif
12472 }12610 }
@@ -16443,78 +16581,2188 @@ inline void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_) {
16443 inline ArrayFlags builtin__ArrayFlags__static__zero(void) {16581 inline ArrayFlags builtin__ArrayFlags__static__zero(void) {
16444 return ((ArrayFlags)(0));16582 return ((ArrayFlags)(0));
16445 }16583 }
16446-VV_LOC void main__vf_init(void) {16584+f64 math__inf(int sign) {
16447- string probe = _S("vf");16585+ u64 v = (sign >= 0 ? (_const_math__uvinf) : (_const_math__uvneginf));
16448- {int _ = probe.len;}16586+ return math__f64_from_bits(v);
16449- ;
16450-}
16451-// export alias: vf_init -> main__vf_init
16452-void vf_init(void) {
16453- return main__vf_init();
16454 }16587 }
16455-VV_LOC int main__vf_add(int a, int b) {16588+f64 math__nan(void) {
16456- return a + b;16589+ return math__f64_from_bits(_const_math__uvnan);
16457 }16590 }
16458-// export alias: vf_add -> main__vf_add16591+bool math__is_nan(f64 f) {
16459-int vf_add(int a, int b) {16592+ return f != f;
16460- return main__vf_add(a, b);
16461 }16593 }
16462-VV_LOC char* main__vf_greet(char* name) {16594+bool math__is_inf(f64 f, int sign) {
16463- string n = builtin__cstring_to_vstring(name);16595+ return (sign >= 0 && f > ((f64)(_const_math__max_f64))) || (sign <= 0 && f < ((f64)(-_const_math__max_f64)));
16464- string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")}));
16465- u8* out = res.str;
16466- builtin__string_free(&n);
16467- return out;
16468 }16596 }
16469-// export alias: vf_greet -> main__vf_greet16597+bool math__is_finite(f64 f) {
16470-char* vf_greet(char* name) {16598+ return !math__is_nan(f) && !math__is_inf(f, 0);
16471- return main__vf_greet(name);
16472 }16599 }
16473-VV_LOC void main__vf_free(voidptr p) {16600+multi_return_f64_int math__normalize(f64 x) {
16474- builtin___v_free(p);16601+ f64 smallest_normal = 2.2250738585072014e-308;
16602+ if (math__abs_T_f64(x) < smallest_normal) {
16603+ return (multi_return_f64_int){.arg0=(f64)(x * _const_math__normalize_smallest_mask), .arg1=-52};
16604+ }
16605+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16475 }16606 }
16476-// export alias: vf_free -> main__vf_free16607+f64 math__cbrt(f64 a) {
16477-void vf_free(voidptr p) {16608+ f64 x = a;
16478- return main__vf_free(p);16609+ int b1 = 715094163;
16610+ int b2 = 696219795;
16611+ f64 c = 5.42857142857142815906e-01;
16612+ f64 d = -7.05306122448979611050e-01;
16613+ f64 e_ = 1.41428571428571436819e+00;
16614+ f64 f = 1.60714285714285720630e+00;
16615+ f64 g = 3.57142857142857150787e-01;
16616+ f64 smallest_normal = 2.22507385850720138309e-308;
16617+ if (x == ((f64)(0.0)) || math__is_nan(x) || math__is_inf(x, 0)) {
16618+ return x;
16619+ }
16620+ bool neg = false;
16621+ if (x < 0) {
16622+ x = -x;
16623+ neg = true;
16624+ }
16625+ f64 t = math__f64_from_bits(VSAFE_DIV_u64(math__f64_bits(x) , ((u64)(3))) + (v__lshift_u64(((u64)(b1)), (u64)32)));
16626+ if (x < smallest_normal) {
16627+ t = ((f64)(v__lshift_u64(((u64)(1)), (u64)54)));
16628+ t *= x;
16629+ t = math__f64_from_bits(VSAFE_DIV_u64(math__f64_bits(t) , ((u64)(3))) + (v__lshift_u64(((u64)(b2)), (u64)32)));
16630+ }
16631+ f64 r = t * t / x;
16632+ f64 s = c + r * t;
16633+ t *= g + f / (s + e_ + d / s);
16634+ t = math__f64_from_bits((math__f64_bits(t) & (v__lshift_u64(((u64)(0xffffffffcLL)), (u64)28))) + (v__lshift_u64(((u64)(1)), (u64)30)));
16635+ s = t * t;
16636+ r = x / s;
16637+ f64 w = t + t;
16638+ r = (r - t) / (w + r);
16639+ t = t + t * r;
16640+ if (neg) {
16641+ t = -t;
16642+ }
16643+ return t;
16479 }16644 }
16480-VV_LOC void main__main(void) {16645+f64 math__mod(f64 x, f64 y) {
16646+ return math__fmod(x, y);
16481 }16647 }
16482-void _vinit(int ___argc, voidptr ___argv) {16648+f64 math__fmod(f64 x, f64 y) {
16483- static bool once = false; if (once) {return;} once = true;16649+ if (y == 0 || math__is_inf(x, 0) || math__is_nan(x) || math__is_nan(y)) {
16484- // Initializations of consts for module builtin.closure16650+ return math__nan();
16485- g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3
16486-{
16487-{
16488-Array_fixed_u8_15 _t1;
16489-#if defined(__V_ppc64le)
16490-#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
16491-#elif defined(__V_amd64)
16492- { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ;
16493- memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15));
16494 }16651 }
16495- ;16652+ f64 abs_y = math__abs_T_f64(y);
16496-#elif defined(__V_x86)16653+ multi_return_f64_int mr_594 = math__frexp(abs_y);
16497-#elif defined(__V_arm64)16654+ f64 abs_y_fr = mr_594.arg0;
16498-#elif defined(__V_arm32)16655+ int abs_y_exp = mr_594.arg1;
16499-#elif defined(__V_rv64)16656+ f64 r = x;
16500-#elif defined(__V_rv32)16657+ if (x < 0) {
16501-#elif defined(__V_s390x)16658+ r = -x;
16502-#elif defined(__V_loongarch64)16659+ }
16503-#elif defined(__V_sparc64)16660+ for (;;) {
16504-#elif 016661+ if (!(r >= abs_y)) break;
16505-#else16662+ multi_return_f64_int mr_680 = math__frexp(r);
16506-#endif16663+ f64 rfr = mr_680.arg0;
16507- memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15));16664+ int rexp = mr_680.arg1;
16665+ if (rfr < abs_y_fr) {
16666+ rexp = rexp - 1;
16667+ }
16668+ r = r - math__ldexp(abs_y, rexp - abs_y_exp);
16669+ }
16670+ if (x < 0) {
16671+ r = -r;
16672+ }
16673+ return r;
16508 }16674 }
16675+i64 math__gcd(i64 a_, i64 b_) {
16676+ i64 a = a_;
16677+ i64 b = b_;
16678+ if (a < 0) {
16679+ a = -a;
16680+ }
16681+ if (b < 0) {
16682+ b = -b;
16683+ }
16684+ for (;;) {
16685+ if (!(b != 0)) break;
16686+ a = VSAFE_MOD_i64(a,b);
16687+ if (a == 0) {
16688+ return b;
16689+ }
16690+ b = VSAFE_MOD_i64(b,a);
16691+ }
16692+ return a;
16509 }16693 }
16510-{16694+multi_return_i64_i64_i64 math__egcd(i64 a, i64 b) {
16511-{16695+ i64 old_r = a;
16512-Array_fixed_u8_6 _t3;16696+ i64 r = b;
16513-#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)16697+ i64 old_s = ((i64)(1));
16514-#elif defined(__V_arm32)16698+ i64 s = ((i64)(0));
16515-#elif defined(__V_amd64)16699+ i64 old_t = ((i64)(0));
16516- { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ;16700+ i64 t = ((i64)(1));
16517- memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6));16701+ for (;;) {
16702+ if (!(r != 0)) break;
16703+ i64 quot = VSAFE_DIV_i64(old_r , r);
16704+ i64 _var_1339 = old_r;
16705+ i64 _var_1346 = r;
16706+ old_r = _var_1346;
16707+ r = _var_1339%_var_1346;
16708+ i64 _var_1365 = old_s;
16709+ i64 _var_1372 = s;
16710+ old_s = _var_1372;
16711+ s = _var_1365-quot*_var_1372;
16712+ i64 _var_1398 = old_t;
16713+ i64 _var_1405 = t;
16714+ old_t = _var_1405;
16715+ t = _var_1398-quot*_var_1405;
16716+ }
16717+ return (multi_return_i64_i64_i64){.arg0=(old_r < 0 ? (-old_r) : (old_r)), .arg1=old_s, .arg2=old_t};
16718+}
16719+i64 math__lcm(i64 a, i64 b) {
16720+ if (a == 0) {
16721+ return a;
16722+ }
16723+ i64 res = a * (VSAFE_DIV_i64(b , math__gcd(b, a)));
16724+ if (res < 0) {
16725+ return -res;
16726+ }
16727+ return res;
16728+}
16729+f64 math__erf(f64 a) {
16730+ f64 x = a;
16731+ f64 very_tiny = 2.848094538889218e-306;
16732+ f64 small_ = ((f64)(1.0)) / ((f64)(v__lshift_u64(((u64)(1)), (u64)28)));
16733+ if (math__is_nan(x)) {
16734+ return math__nan();
16735+ }
16736+ if (math__is_inf(x, 1)) {
16737+ return 1.0;
16738+ }
16739+ if (math__is_inf(x, -1)) {
16740+ return ((f64)(-1));
16741+ }
16742+ bool neg = false;
16743+ if (x < 0) {
16744+ x = -x;
16745+ neg = true;
16746+ }
16747+ if (x < ((f64)(0.84375))) {
16748+ f64 temp = 0.0;
16749+ if (x < small_) {
16750+ if (x < very_tiny) {
16751+ temp = ((f64)(0.125)) * (((f64)(8.0)) * x + ((f64)(_const_math__efx8)) * x);
16752+ } else {
16753+ temp = x + ((f64)(_const_math__efx)) * x;
16754+ }
16755+ } else {
16756+ f64 z = x * x;
16757+ f64 r = ((f64)(_const_math__pp0)) + z * (((f64)(_const_math__pp1)) + z * (((f64)(_const_math__pp2)) + z * (((f64)(_const_math__pp3)) + z * ((f64)(_const_math__pp4)))));
16758+ f64 s_ = ((f64)(1.0)) + z * (((f64)(_const_math__qq1)) + z * (((f64)(_const_math__qq2)) + z * (((f64)(_const_math__qq3)) + z * (((f64)(_const_math__qq4)) + z * ((f64)(_const_math__qq5))))));
16759+ f64 y = r / s_;
16760+ temp = x + x * y;
16761+ }
16762+ if (neg) {
16763+ return -temp;
16764+ }
16765+ return temp;
16766+ }
16767+ if (x < ((f64)(1.25))) {
16768+ f64 s_ = x - 1;
16769+ f64 p = ((f64)(_const_math__pa0)) + s_ * (((f64)(_const_math__pa1)) + s_ * (((f64)(_const_math__pa2)) + s_ * (((f64)(_const_math__pa3)) + s_ * (((f64)(_const_math__pa4)) + s_ * (((f64)(_const_math__pa5)) + s_ * ((f64)(_const_math__pa6)))))));
16770+ f64 q = ((f64)(1.0)) + s_ * (((f64)(_const_math__qa1)) + s_ * (((f64)(_const_math__qa2)) + s_ * (((f64)(_const_math__qa3)) + s_ * (((f64)(_const_math__qa4)) + s_ * (((f64)(_const_math__qa5)) + s_ * ((f64)(_const_math__qa6)))))));
16771+ if (neg) {
16772+ return ((f64)(-_const_math__erx)) - p / q;
16773+ }
16774+ return ((f64)(_const_math__erx)) + p / q;
16775+ }
16776+ if (x >= 6) {
16777+ if (neg) {
16778+ return -1;
16779+ }
16780+ return 1.0;
16781+ }
16782+ f64 s_ = ((f64)(1.0)) / (x * x);
16783+ f64 r = 0.0;
16784+ f64 s = 0.0;
16785+ if (x < ((f64)(2.857142857142857))) {
16786+ f64 tmp41 = s_ * (((f64)(_const_math__ra5)) + s_ * (((f64)(_const_math__ra6)) + s_ * ((f64)(_const_math__ra7))));
16787+ r = ((f64)(_const_math__ra0)) + s_ * (((f64)(_const_math__ra1)) + s_ * (((f64)(_const_math__ra2)) + s_ * (((f64)(_const_math__ra3)) + s_ * (((f64)(_const_math__ra4)) + tmp41))));
16788+ f64 tmp42 = s_ * (((f64)(_const_math__sa5)) + s_ * (((f64)(_const_math__sa6)) + s_ * (((f64)(_const_math__sa7)) + s_ * ((f64)(_const_math__sa8)))));
16789+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sa1)) + s_ * (((f64)(_const_math__sa2)) + s_ * (((f64)(_const_math__sa3)) + s_ * (((f64)(_const_math__sa4)) + tmp42))));
16790+ } else {
16791+ f64 tmp31 = ((f64)(_const_math__rb4)) + s_ * (((f64)(_const_math__rb5)) + s_ * ((f64)(_const_math__rb6)));
16792+ r = ((f64)(_const_math__rb0)) + s_ * (((f64)(_const_math__rb1)) + s_ * (((f64)(_const_math__rb2)) + s_ * (((f64)(_const_math__rb3)) + s_ * tmp31)));
16793+ f64 tmp32 = ((f64)(_const_math__sb4)) + s_ * (((f64)(_const_math__sb5)) + s_ * (((f64)(_const_math__sb6)) + s_ * ((f64)(_const_math__sb7))));
16794+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sb1)) + s_ * (((f64)(_const_math__sb2)) + s_ * (((f64)(_const_math__sb3)) + s_ * tmp32)));
16795+ }
16796+ f64 z = math__f64_from_bits((math__f64_bits(x) & 0xffffffff00000000ULL));
16797+ f64 r_ = math__exp(-z * z - ((f64)(0.5625))) * math__exp((z - x) * (z + x) + r / s);
16798+ if (neg) {
16799+ return r_ / x - ((f64)(1.0));
16800+ }
16801+ return ((f64)(1.0)) - r_ / x;
16802+}
16803+f64 math__erfc(f64 a) {
16804+ f64 x = a;
16805+ f64 tiny = ((f64)(1.0)) / ((f64)(v__lshift_u64(((u64)(1)), (u64)56)));
16806+ if (math__is_nan(x)) {
16807+ return math__nan();
16808+ }
16809+ if (math__is_inf(x, 1)) {
16810+ return 0.0;
16811+ }
16812+ if (math__is_inf(x, -1)) {
16813+ return 2.0;
16814+ }
16815+ bool neg = false;
16816+ if (x < 0) {
16817+ x = -x;
16818+ neg = true;
16819+ }
16820+ if (x < ((f64)(0.84375))) {
16821+ f64 temp = 0.0;
16822+ if (x < tiny) {
16823+ temp = x;
16824+ } else {
16825+ f64 z = x * x;
16826+ f64 r = ((f64)(_const_math__pp0)) + z * (((f64)(_const_math__pp1)) + z * (((f64)(_const_math__pp2)) + z * (((f64)(_const_math__pp3)) + z * ((f64)(_const_math__pp4)))));
16827+ f64 s_ = ((f64)(1.0)) + z * (((f64)(_const_math__qq1)) + z * (((f64)(_const_math__qq2)) + z * (((f64)(_const_math__qq3)) + z * (((f64)(_const_math__qq4)) + z * ((f64)(_const_math__qq5))))));
16828+ f64 y = r / s_;
16829+ if (x < ((f64)(0.25))) {
16830+ temp = x + x * y;
16831+ } else {
16832+ temp = ((f64)(0.5)) + (x * y + (x - ((f64)(0.5))));
16833+ }
16834+ }
16835+ if (neg) {
16836+ return ((f64)(1.0)) + temp;
16837+ }
16838+ return ((f64)(1.0)) - temp;
16839+ }
16840+ if (x < ((f64)(1.25))) {
16841+ f64 s_ = x - 1;
16842+ f64 p = ((f64)(_const_math__pa0)) + s_ * (((f64)(_const_math__pa1)) + s_ * (((f64)(_const_math__pa2)) + s_ * (((f64)(_const_math__pa3)) + s_ * (((f64)(_const_math__pa4)) + s_ * (((f64)(_const_math__pa5)) + s_ * ((f64)(_const_math__pa6)))))));
16843+ f64 q = ((f64)(1.0)) + s_ * (((f64)(_const_math__qa1)) + s_ * (((f64)(_const_math__qa2)) + s_ * (((f64)(_const_math__qa3)) + s_ * (((f64)(_const_math__qa4)) + s_ * (((f64)(_const_math__qa5)) + s_ * ((f64)(_const_math__qa6)))))));
16844+ if (neg) {
16845+ return ((f64)(1.8450629115104675)) + p / q;
16846+ }
16847+ return ((f64)(0.15493708848953247)) - p / q;
16848+ }
16849+ if (x < 28) {
16850+ f64 s_ = ((f64)(1.0)) / (x * x);
16851+ f64 r = 0.0;
16852+ f64 s = 0.0;
16853+ if (x < ((f64)(2.857142857142857))) {
16854+ f64 tmp281 = ((f64)(_const_math__ra4)) + s_ * (((f64)(_const_math__ra5)) + s_ * (((f64)(_const_math__ra6)) + s_ * ((f64)(_const_math__ra7))));
16855+ r = ((f64)(_const_math__ra0)) + s_ * (((f64)(_const_math__ra1)) + s_ * (((f64)(_const_math__ra2)) + s_ * (((f64)(_const_math__ra3)) + s_ * tmp281)));
16856+ f64 tmp282 = ((f64)(_const_math__sa4)) + s_ * (((f64)(_const_math__sa5)) + s_ * (((f64)(_const_math__sa6)) + s_ * (((f64)(_const_math__sa7)) + s_ * ((f64)(_const_math__sa8)))));
16857+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sa1)) + s_ * (((f64)(_const_math__sa2)) + s_ * (((f64)(_const_math__sa3)) + s_ * tmp282)));
16858+ } else {
16859+ if (neg && x > 6) {
16860+ return 2.0;
16861+ }
16862+ f64 tmp291 = ((f64)(_const_math__rb3)) + s_ * (((f64)(_const_math__rb4)) + s_ * (((f64)(_const_math__rb5)) + s_ * ((f64)(_const_math__rb6))));
16863+ r = ((f64)(_const_math__rb0)) + s_ * (((f64)(_const_math__rb1)) + s_ * (((f64)(_const_math__rb2)) + s_ * tmp291));
16864+ f64 tmp292 = ((f64)(_const_math__sb3)) + s_ * (((f64)(_const_math__sb4)) + s_ * (((f64)(_const_math__sb5)) + s_ * (((f64)(_const_math__sb6)) + s_ * ((f64)(_const_math__sb7)))));
16865+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sb1)) + s_ * (((f64)(_const_math__sb2)) + s_ * tmp292));
16866+ }
16867+ f64 z = math__f64_from_bits((math__f64_bits(x) & 0xffffffff00000000ULL));
16868+ f64 r_ = math__exp(-z * z - ((f64)(0.5625))) * math__exp((z - x) * (z + x) + r / s);
16869+ if (neg) {
16870+ return ((f64)(2.0)) - r_ / x;
16871+ }
16872+ return r_ / x;
16873+ }
16874+ if (neg) {
16875+ return 2.0;
16876+ }
16877+ return 0.0;
16878+}
16879+inline f64 math__exp(f64 x) {
16880+ return exp(x);
16881+}
16882+inline f64 math__exp2(f64 x) {
16883+ return exp2(x);
16884+}
16885+inline f64 math__ldexp(f64 frac, int exp) {
16886+ return ldexp(frac, exp);
16887+}
16888+f64 math__pure_v_but_overridden_by_c_exp(f64 x) {
16889+ f64 log2e = 1.44269504088896338700e+00;
16890+ f64 overflow = 7.09782712893383973096e+02;
16891+ f64 underflow = -7.45133219101941108420e+02;
16892+ float_literal near_zero = (float_literal)(1.0 / 268435456);
16893+ if (math__is_nan(x) || math__is_inf(x, 1)) {
16894+ return x;
16895+ }
16896+ if (math__is_inf(x, -1)) {
16897+ return 0.0;
16898+ }
16899+ if (x > overflow) {
16900+ return math__inf(1);
16901+ }
16902+ if (x < underflow) {
16903+ return 0.0;
16904+ }
16905+ if (-near_zero < x && x < near_zero) {
16906+ return ((f64)(1.0)) + x;
16907+ }
16908+ int k = 0;
16909+ if (x < 0) {
16910+ k = ((int)(log2e * x - ((f64)(0.5))));
16911+ }
16912+ if (x > 0) {
16913+ k = ((int)(log2e * x + ((f64)(0.5))));
16914+ }
16915+ f64 hi = x - ((f64)(k)) * ((f64)(_const_math__ln2hi));
16916+ f64 lo = ((f64)(k)) * ((f64)(_const_math__ln2lo));
16917+ return math__expmulti(hi, lo, k);
16918+}
16919+f64 math__pure_v_but_overridden_by_c_exp2(f64 x) {
16920+ f64 overflow = 1.0239999999999999e+03;
16921+ f64 underflow = -1.0740e+03;
16922+ if (math__is_nan(x) || math__is_inf(x, 1)) {
16923+ return x;
16924+ }
16925+ if (math__is_inf(x, -1)) {
16926+ return 0;
16927+ }
16928+ if (x > overflow) {
16929+ return math__inf(1);
16930+ }
16931+ if (x < underflow) {
16932+ return 0;
16933+ }
16934+ int k = 0;
16935+ if (x > 0) {
16936+ k = ((int)(x + ((f64)(0.5))));
16937+ }
16938+ if (x < 0) {
16939+ k = ((int)(x - ((f64)(0.5))));
16940+ }
16941+ f64 t = x - ((f64)(k));
16942+ f64 hi = t * ((f64)(_const_math__ln2hi));
16943+ f64 lo = -t * ((f64)(_const_math__ln2lo));
16944+ return math__expmulti(hi, lo, k);
16945+}
16946+f64 math__pure_v_but_overridden_by_c_ldexp(f64 frac, int exp) {
16947+ return math__scalbn(frac, exp);
16948+}
16949+multi_return_f64_int math__frexp(f64 x) {
16950+ u64 y = math__f64_bits(x);
16951+ int ee = ((int)(((v__rshift_u64(y, (u64)52)) & 0x7ff)));
16952+ if (ee == 0) {
16953+ if (x != ((f64)(0.0))) {
16954+ f64 x1p64 = math__f64_from_bits(((u64)(0x43f0000000000000LL)));
16955+ multi_return_f64_int mr_3373 = math__frexp(x * x1p64);
16956+ f64 z = mr_3373.arg0;
16957+ int e_ = mr_3373.arg1;
16958+ return (multi_return_f64_int){.arg0=z, .arg1=e_ - 64};
16959+ }
16960+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16961+ } else if (ee == 0x7ff) {
16962+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16963+ }
16964+ int e_ = ee - 0x3fe;
16965+ y &= ((u64)(0x800fffffffffffffULL));
16966+ y |= ((u64)(0x3fe0000000000000LL));
16967+ return (multi_return_f64_int){.arg0=math__f64_from_bits(y), .arg1=e_};
16968+}
16969+f64 math__expm1(f64 x) {
16970+ if (math__is_inf(x, 1) || math__is_nan(x)) {
16971+ return x;
16972+ }
16973+ if (math__is_inf(x, -1)) {
16974+ return ((f64)(-1));
16975+ }
16976+ if (math__abs_T_f64(x) < ((f64)(_const_math__ln2))) {
16977+ f64 i = 1.0;
16978+ f64 sum = x;
16979+ f64 term = x / ((f64)(1.0));
16980+ i++;
16981+ term *= x / ((f64)(i));
16982+ sum += term;
16983+ for (;;) {
16984+ if (!(math__abs_T_f64(term) > math__abs_T_f64(sum) * ((f64)(_const_math__internal__f64_epsilon)))) break;
16985+ i++;
16986+ term *= x / ((f64)(i));
16987+ sum += term;
16988+ }
16989+ return sum;
16990+ } else {
16991+ return math__exp(x) - 1;
16992+ }
16993+ return 0;
16994+}
16995+VV_LOC f64 math__expmulti(f64 hi, f64 lo, int k) {
16996+ f64 exp_p1 = 1.66666666666666657415e-01;
16997+ f64 exp_p2 = -2.77777777770155933842e-03;
16998+ f64 exp_p3 = 6.61375632143793436117e-05;
16999+ f64 exp_p4 = -1.65339022054652515390e-06;
17000+ f64 exp_p5 = 4.13813679705723846039e-08;
17001+ f64 r = hi - lo;
17002+ f64 t = r * r;
17003+ f64 c = r - t * (exp_p1 + t * (exp_p2 + t * (exp_p3 + t * (exp_p4 + t * exp_p5))));
17004+ f64 y = 1 - ((lo - (r * c) / (2 - c)) - hi);
17005+ return math__ldexp(y, k);
17006+}
17007+f64 math__factorial(f64 n) {
17008+ if (n >= _const_math__factorials_table.len) {
17009+ return _const_math__max_f64;
17010+ }
17011+ if (n == ((f64)(((i64)(n)))) && n >= ((f64)(0.0))) {
17012+ return (*(f64*)builtin__array_get(_const_math__factorials_table, ((int)(n))));
17013+ }
17014+ return math__gamma(n + ((f64)(1.0)));
17015+}
17016+f64 math__log_factorial(f64 n) {
17017+ if (n < 0) {
17018+ return -_const_math__max_f64;
17019+ }
17020+ if (n != ((f64)(((i64)(n))))) {
17021+ return math__log_gamma(n + 1);
17022+ } else if (n < _const_math__log_factorials_table.len) {
17023+ return (*(f64*)builtin__array_get(_const_math__log_factorials_table, ((int)(n))));
17024+ }
17025+ return math__log_factorial_asymptotic_expansion(((int)(n)));
17026+}
17027+VV_LOC f64 math__log_factorial_asymptotic_expansion(int n) {
17028+ int m = 6;
17029+ Array_f64 term = builtin____new_array_with_default(0, 0, sizeof(f64), 0);
17030+ f64 xx = ((f64)((n + 1) * (n + 1)));
17031+ f64 xj = ((f64)(n + 1));
17032+ f64 log_fact = ((f64)(_const_math__log_sqrt_2pi)) - xj + (xj - ((f64)(0.5))) * math__log(xj);
17033+ int i = 0;
17034+ for (i = 0; i < m; i++) {
17035+ builtin__array_push((array*)&term, _MOV((f64[]){ (*(f64*)builtin__array_get(_const_math__bernoulli, i)) / xj }));
17036+ xj *= xx;
17037+ }
17038+ f64 sum = (*(f64*)builtin__array_get(term, m - 1));
17039+ for (i = m - 2; i >= 0; i--) {
17040+ if (math__abs_T_f64(sum) <= math__abs_T_f64((*(f64*)builtin__array_get(term, i)))) {
17041+ break;
17042+ }
17043+ sum = (*(f64*)builtin__array_get(term, i));
17044+ }
17045+ for (;;) {
17046+ if (!(i >= 0)) break;
17047+ sum += (*(f64*)builtin__array_get(term, i));
17048+ i--;
17049+ }
17050+ return log_fact + sum;
17051+}
17052+i64 math__factoriali(int n) {
17053+ if (n <= 0) {
17054+ return ((i64)(1));
17055+ }
17056+ if (n < 21) {
17057+ return ((i64)((*(f64*)builtin__array_get(_const_math__factorials_table, n))));
17058+ }
17059+ return ((i64)(-1));
17060+}
17061+f64 math__floor(f64 x) {
17062+ if (x == 0 || math__is_nan(x) || math__is_inf(x, 0)) {
17063+ return x;
17064+ }
17065+ if (x < 0) {
17066+ multi_return_f64_f64 mr_280 = math__modf(-x);
17067+ f64 d = mr_280.arg0;
17068+ f64 fract = mr_280.arg1;
17069+ if (fract != ((f64)(0.0))) {
17070+ d = d + 1;
17071+ }
17072+ return -d;
17073+ }
17074+ multi_return_f64_f64 mr_350 = math__modf(x);
17075+ f64 d = mr_350.arg0;
17076+ return d;
17077+}
17078+f32 math__floorf(f32 x) {
17079+ return ((f32)(math__floor(((f64)(x)))));
17080+}
17081+f64 math__ceil(f64 x) {
17082+ return -math__floor(-x);
17083+}
17084+f64 math__trunc(f64 x) {
17085+ if (x == 0 || math__is_nan(x) || math__is_inf(x, 0)) {
17086+ return x;
17087+ }
17088+ multi_return_f64_f64 mr_1200 = math__modf(x);
17089+ f64 d = mr_1200.arg0;
17090+ return d;
17091+}
17092+f64 math__round(f64 x) {
17093+ u64 bits = math__f64_bits(x);
17094+ u64 e_ = ((v__rshift_u64(bits, (u64)52)) & 0x7FF);
17095+ if (e_ < 1023) {
17096+ bits &= _const_math__sign_mask;
17097+ if (e_ == 1022) {
17098+ bits |= _const_math__uvone;
17099+ }
17100+ } else if (e_ < 1075) {
17101+ u64 half = v__lshift_u64(((u64)(1)), (u64)51);
17102+ e_ -= _const_math__bias;
17103+ bits += v__rshift_u64(half, (u64)e_);
17104+ bits &= ~(v__rshift_u64(_const_math__frac_mask, (u64)e_));
17105+ }
17106+ return math__f64_from_bits(bits);
17107+}
17108+f64 math__round_sig(f64 x, int sig_digits) {
17109+ string ret_str = builtin__f64_str(x);
17110+ switch (sig_digits) {
17111+ case 0: {
17112+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000000d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17113+ break;
17114+ }
17115+ case 1: {
17116+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000020d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17117+ break;
17118+ }
17119+ case 2: {
17120+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000040d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17121+ break;
17122+ }
17123+ case 3: {
17124+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000060d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17125+ break;
17126+ }
17127+ case 4: {
17128+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000080d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17129+ break;
17130+ }
17131+ case 5: {
17132+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000a0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17133+ break;
17134+ }
17135+ case 6: {
17136+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000c0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17137+ break;
17138+ }
17139+ case 7: {
17140+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000e0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17141+ break;
17142+ }
17143+ case 8: {
17144+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000100d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17145+ break;
17146+ }
17147+ case 9: {
17148+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000120d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17149+ break;
17150+ }
17151+ case 10: {
17152+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000140d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17153+ break;
17154+ }
17155+ case 11: {
17156+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000160d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17157+ break;
17158+ }
17159+ case 12: {
17160+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000180d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17161+ break;
17162+ }
17163+ case 13: {
17164+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001a0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17165+ break;
17166+ }
17167+ case 14: {
17168+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001c0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17169+ break;
17170+ }
17171+ case 15: {
17172+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001e0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17173+ break;
17174+ }
17175+ case 16: {
17176+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000200d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17177+ break;
17178+ }
17179+ default: {
17180+ {
17181+ ret_str = builtin__f64_str(x);
17182+ break;
17183+ }
17184+ }
17185+ }
17186+
17187+ return builtin__string_f64(ret_str);
17188+}
17189+f64 math__round_to_even(f64 x) {
17190+ u64 bits = math__f64_bits(x);
17191+ u64 e_ = ((v__rshift_u64(bits, (u64)52)) & 0x7FF);
17192+ if (e_ >= 1023) {
17193+ u64 half_minus_ulp = ((u64)(v__lshift_u64(((u64)(1)), (u64)51))) - 1;
17194+ e_ -= ((u64)(_const_math__bias));
17195+ bits += math__safe_shift(half_minus_ulp + (math__safe_shift(bits, 52 - e_) & 1), e_);
17196+ bits &= ~math__safe_shift(_const_math__frac_mask, e_);
17197+ } else if (e_ == 1022 && (bits & _const_math__frac_mask) != 0) {
17198+ bits = ((bits & _const_math__sign_mask) | _const_math__uvone);
17199+ } else {
17200+ bits &= _const_math__sign_mask;
17201+ }
17202+ return math__f64_from_bits(bits);
17203+}
17204+inline VV_LOC u64 math__safe_shift(u64 value, u64 shift) {
17205+ return (shift > ((u64)(63)) ? (((u64)(0))) : (v__rshift_u64(value, (u64)shift)));
17206+}
17207+VV_LOC bool math__is_neg_int(f64 x) {
17208+ if (x < 0) {
17209+ multi_return_f64_f64 mr_61 = math__modf(x);
17210+ f64 xf = mr_61.arg1;
17211+ return xf == 0;
17212+ }
17213+ return false;
17214+}
17215+VV_LOC multi_return_f64_f64 math__stirling(f64 x) {
17216+ if (x > 200) {
17217+ return (multi_return_f64_f64){.arg0=math__inf(1), .arg1=1.0};
17218+ }
17219+ f64 w = ((f64)(1.0)) / x;
17220+ w = ((f64)(1.0)) + w * (((((*(f64*)builtin__array_get(_const_math__gamma_s, 0)) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 1))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 2))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 3))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 4)));
17221+ f64 y1 = math__exp(x);
17222+ f64 y2 = 1.0;
17223+ if (x > ((f64)(143.01608))) {
17224+ f64 v = math__pow(x, ((f64)(0.5)) * x - ((f64)(0.25)));
17225+ f64 y1_ = y1;
17226+ y1 = v;
17227+ y2 = v / y1_;
17228+ } else {
17229+ y1 = math__pow(x, x - ((f64)(0.5))) / y1;
17230+ }
17231+ return (multi_return_f64_f64){.arg0=y1, .arg1=((f64)(2.506628274631000502417)) * w * y2};
17232+}
17233+f64 math__gamma(f64 a) {
17234+ f64 x = a;
17235+ if (math__is_neg_int(x) || math__is_inf(x, -1) || math__is_nan(x)) {
17236+ return math__nan();
17237+ }
17238+ if (math__is_inf(x, 1)) {
17239+ return math__inf(1);
17240+ }
17241+ if (x == ((f64)(0.0))) {
17242+ return math__copysign(math__inf(1), x);
17243+ }
17244+ f64 q = math__abs_T_f64(x);
17245+ f64 p = math__floor(q);
17246+ if (q > 33) {
17247+ if (x >= 0) {
17248+ multi_return_f64_f64 mr_1507 = math__stirling(x);
17249+ f64 y1 = mr_1507.arg0;
17250+ f64 y2 = mr_1507.arg1;
17251+ return y1 * y2;
17252+ }
17253+ int signgam = 1;
17254+ i64 ip = ((i64)(p));
17255+ if (((ip & 1)) == 0) {
17256+ signgam = -1;
17257+ }
17258+ f64 z = q - p;
17259+ if (z > ((f64)(0.5))) {
17260+ p = p + 1;
17261+ z = q - p;
17262+ }
17263+ z = q * math__sin(((f64)(_const_math__pi)) * z);
17264+ if (z == 0) {
17265+ return math__inf(signgam);
17266+ }
17267+ multi_return_f64_f64 mr_1952 = math__stirling(q);
17268+ f64 sq1 = mr_1952.arg0;
17269+ f64 sq2 = mr_1952.arg1;
17270+ f64 absz = math__abs_T_f64(z);
17271+ f64 d = absz * sq1 * sq2;
17272+ if (math__is_inf(d, 0)) {
17273+ z = ((f64)(_const_math__pi)) / absz / sq1 / sq2;
17274+ } else {
17275+ z = ((f64)(_const_math__pi)) / d;
17276+ }
17277+ return ((f64)(signgam)) * z;
17278+ }
17279+ f64 z = 1.0;
17280+ for (;;) {
17281+ if (!(x >= 3)) break;
17282+ x = x - 1;
17283+ z = z * x;
17284+ }
17285+ for (;;) {
17286+ if (!(x < 0)) break;
17287+ if (x > ((f64)(-1e-09))) {
17288+ return math__gamma_too_small(x, z);
17289+ }
17290+ z = z / x;
17291+ x = x + 1;
17292+ }
17293+ for (;;) {
17294+ if (!(x < 2)) break;
17295+ if (x < ((f64)(1e-09))) {
17296+ return math__gamma_too_small(x, z);
17297+ }
17298+ z = z / x;
17299+ x = x + 1;
17300+ }
17301+ if (x == 2) {
17302+ return z;
17303+ }
17304+ x = x - 2;
17305+ p = (((((x * (*(f64*)builtin__array_get(_const_math__gamma_p, 0)) + (*(f64*)builtin__array_get(_const_math__gamma_p, 1))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 2))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 3))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 4))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 5))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 6));
17306+ q = ((((((x * (*(f64*)builtin__array_get(_const_math__gamma_q, 0)) + (*(f64*)builtin__array_get(_const_math__gamma_q, 1))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 2))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 3))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 4))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 5))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 6))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 7));
17307+ return z * p / q;
17308+}
17309+VV_LOC f64 math__gamma_too_small(f64 x, f64 z) {
17310+ if (x == 0) {
17311+ return math__inf(1);
17312+ }
17313+ f64 euler = 0.57721566490153286060651209008240243104215933593992;
17314+ return z / ((((f64)(1.0)) + euler * x) * x);
17315+}
17316+f64 math__log_gamma(f64 x) {
17317+ multi_return_f64_int mr_3163 = math__log_gamma_sign(x);
17318+ f64 y = mr_3163.arg0;
17319+ return y;
17320+}
17321+multi_return_f64_int math__log_gamma_sign(f64 a) {
17322+ f64 x = a;
17323+ int sgn = 1;
17324+ if (math__is_nan(x)) {
17325+ return (multi_return_f64_int){.arg0=x, .arg1=sgn};
17326+ }
17327+ if (math__is_inf(x, 1)) {
17328+ return (multi_return_f64_int){.arg0=x, .arg1=sgn};
17329+ }
17330+ if (x == ((f64)(0.0))) {
17331+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17332+ }
17333+ bool neg = false;
17334+ if (x < 0) {
17335+ x = -x;
17336+ neg = true;
17337+ }
17338+ if (x < math__exp2(-70)) {
17339+ if (neg) {
17340+ sgn = -1;
17341+ }
17342+ return (multi_return_f64_int){.arg0=-math__log(x), .arg1=sgn};
17343+ }
17344+ f64 nadj = 0.0;
17345+ if (neg) {
17346+ if (x >= math__exp2(52)) {
17347+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17348+ }
17349+ f64 t = math__sin_pi(x);
17350+ if (t == 0) {
17351+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17352+ }
17353+ nadj = math__log(((f64)(_const_math__pi)) / math__abs_T_f64(t * x));
17354+ if (t < 0) {
17355+ sgn = -1;
17356+ }
17357+ }
17358+ f64 lgamma = 0.0;
17359+ if (x == 1 || x == 2) {
17360+ return (multi_return_f64_int){.arg0=0.0, .arg1=sgn};
17361+ } else if (x < 2) {
17362+ f64 ymin = 1.461632144968362245;
17363+ f64 tc = 1.46163214496836224576e+00;
17364+ f64 y = 0.0;
17365+ int i = 0;
17366+ if (x <= ((f64)(0.9))) {
17367+ lgamma = -math__log(x);
17368+ if (x >= (ymin - 1 + ((f64)(0.27)))) {
17369+ y = ((f64)(1.0)) - x;
17370+ i = 0;
17371+ } else if (x >= (ymin - 1 - ((f64)(0.27)))) {
17372+ y = x - (tc - 1);
17373+ i = 1;
17374+ } else {
17375+ y = x;
17376+ i = 2;
17377+ }
17378+ } else {
17379+ lgamma = 0;
17380+ if (x >= (ymin + ((f64)(0.27)))) {
17381+ y = ((f64)(2)) - x;
17382+ i = 0;
17383+ } else if (x >= (ymin - ((f64)(0.27)))) {
17384+ y = x - tc;
17385+ i = 1;
17386+ } else {
17387+ y = x - 1;
17388+ i = 2;
17389+ }
17390+ }
17391+ if (i == 0) {
17392+ f64 z = y * y;
17393+ f64 gamma_p1 = (*(f64*)builtin__array_get(_const_math__lgamma_a, 0)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 2)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 4)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 6)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 8)) + z * (*(f64*)builtin__array_get(_const_math__lgamma_a, 10))))));
17394+ f64 gamma_p2 = z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 1)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 3)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 5)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 7)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 9)) + z * (*(f64*)builtin__array_get(_const_math__lgamma_a, 11)))))));
17395+ f64 p = y * gamma_p1 + gamma_p2;
17396+ lgamma += (p - ((f64)(0.5)) * y);
17397+ } else if (i == 1) {
17398+ f64 z = y * y;
17399+ f64 w = z * y;
17400+ f64 gamma_p1 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 0)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 3)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 6)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 9)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 12)))));
17401+ f64 gamma_p2 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 1)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 4)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 7)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 10)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 13)))));
17402+ f64 gamma_p3 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 2)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 5)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 8)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 11)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 14)))));
17403+ f64 tf = -1.21486290535849611461e-01;
17404+ f64 tt = -3.63867699703950536541e-18;
17405+ f64 p = z * gamma_p1 - (tt - w * (gamma_p2 + y * gamma_p3));
17406+ lgamma += (tf + p);
17407+ } else if (i == 2) {
17408+ f64 gamma_p1 = y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 4)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_u, 5)))))));
17409+ f64 gamma_p2 = ((f64)(1.0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 4)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_v, 5))))));
17410+ lgamma += (((f64)(-0.5)) * y + gamma_p1 / gamma_p2);
17411+ }
17412+ } else if (x < 8) {
17413+ int i = ((int)(x));
17414+ f64 y = x - ((f64)(i));
17415+ f64 tmp23456 = (*(f64*)builtin__array_get(_const_math__lgamma_s, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_s, 6)))));
17416+ f64 p = y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 1)) + y * tmp23456));
17417+ f64 tmpr23456 = (*(f64*)builtin__array_get(_const_math__lgamma_r, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_r, 6)))));
17418+ f64 q = ((f64)(1.0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 1)) + y * tmpr23456);
17419+ lgamma = ((f64)(0.5)) * y + p / q;
17420+ f64 z = 1.0;
17421+ if (i == 7) {
17422+ z *= (y + 6);
17423+ z *= (y + 5);
17424+ z *= (y + 4);
17425+ z *= (y + 3);
17426+ z *= (y + 2);
17427+ lgamma += math__log(z);
17428+ } else if (i == 6) {
17429+ z *= (y + 5);
17430+ z *= (y + 4);
17431+ z *= (y + 3);
17432+ z *= (y + 2);
17433+ lgamma += math__log(z);
17434+ } else if (i == 5) {
17435+ z *= (y + 4);
17436+ z *= (y + 3);
17437+ z *= (y + 2);
17438+ lgamma += math__log(z);
17439+ } else if (i == 4) {
17440+ z *= (y + 3);
17441+ z *= (y + 2);
17442+ lgamma += math__log(z);
17443+ } else if (i == 3) {
17444+ z *= (y + 2);
17445+ lgamma += math__log(z);
17446+ }
17447+ } else if (x < math__exp2(58)) {
17448+ f64 t = math__log(x);
17449+ f64 z = ((f64)(1.0)) / x;
17450+ f64 y = z * z;
17451+ f64 w = (*(f64*)builtin__array_get(_const_math__lgamma_w, 0)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_w, 6)))))));
17452+ lgamma = (x - ((f64)(0.5))) * (t - ((f64)(1.0))) + w;
17453+ } else {
17454+ lgamma = x * (math__log(x) - ((f64)(1.0)));
17455+ }
17456+ if (neg) {
17457+ lgamma = nadj - lgamma;
17458+ }
17459+ return (multi_return_f64_int){.arg0=lgamma, .arg1=sgn};
17460+}
17461+VV_LOC f64 math__sin_pi(f64 x_) {
17462+ f64 x = x_;
17463+ if (x < ((f64)(0.25))) {
17464+ return -math__sin(((f64)(_const_math__pi)) * x);
17465+ }
17466+ f64 z = math__floor(x);
17467+ int n = 0;
17468+ if (z != x) {
17469+ x = math__mod(x, 2);
17470+ n = ((int)(x * 4));
17471+ } else {
17472+ if (x >= math__exp2(53)) {
17473+ x = 0;
17474+ n = 0;
17475+ } else {
17476+ f64 two52 = math__exp2(52);
17477+ if (x < two52) {
17478+ z = x + two52;
17479+ }
17480+ n = (1 & ((int)(math__f64_bits(z))));
17481+ x = ((f64)(n));
17482+ n = v__lshift_int(n, (u64)2);
17483+ }
17484+ }
17485+ if (n == 0) {
17486+ x = math__sin(((f64)(_const_math__pi)) * x);
17487+ } else if (n == 1 || n == 2) {
17488+ x = math__cos(((f64)(_const_math__pi)) * (((f64)(0.5)) - x));
17489+ } else if (n == 3 || n == 4) {
17490+ x = math__sin(((f64)(_const_math__pi)) * (((f64)(1.0)) - x));
17491+ } else if (n == 5 || n == 6) {
17492+ x = -math__cos(((f64)(_const_math__pi)) * (x - ((f64)(1.5))));
17493+ } else {
17494+ x = math__sin(((f64)(_const_math__pi)) * (x - 2));
17495+ }
17496+ return -x;
17497+}
17498+f64 math__hypot(f64 x, f64 y) {
17499+ f64 p = math__abs_T_f64(x);
17500+ f64 q = math__abs_T_f64(y);
17501+ if (math__is_inf(p, 1) || math__is_inf(q, 1)) {
17502+ return math__inf(1);
17503+ }
17504+ if (math__is_nan(p) || math__is_nan(q)) {
17505+ return math__nan();
17506+ }
17507+ if (p < q) {
17508+ f64 _var_382 = p;
17509+ f64 _var_385 = q;
17510+ p = _var_385;
17511+ q = _var_382;
17512+ }
17513+ if (p == ((f64)(0.0))) {
17514+ return 0.0;
17515+ }
17516+ q = q / p;
17517+ return p * math__sqrt(1 + q * q);
17518+}
17519+inline math__BezierPoint math__cubic_bezier(f64 t, Array_math__BezierPoint p) {
17520+ if (p.len != 4) {
17521+ builtin___v_panic(_S("invalid p.len"));
17522+ VUNREACHABLE();
17523+ }
17524+ return math__cubic_bezier_coords(t, ((math__BezierPoint*)p.data)[0].x, ((math__BezierPoint*)p.data)[1].x, ((math__BezierPoint*)p.data)[2].x, ((math__BezierPoint*)p.data)[3].x, ((math__BezierPoint*)p.data)[0].y, ((math__BezierPoint*)p.data)[1].y, ((math__BezierPoint*)p.data)[2].y, ((math__BezierPoint*)p.data)[3].y);
17525+}
17526+inline math__BezierPoint math__cubic_bezier_a(f64 t, Array_f64 x, Array_f64 y) {
17527+ if (x.len != 4) {
17528+ builtin___v_panic(_S("invalid x.len"));
17529+ VUNREACHABLE();
17530+ }
17531+ if (y.len != 4) {
17532+ builtin___v_panic(_S("invalid y.len"));
17533+ VUNREACHABLE();
17534+ }
17535+ return math__cubic_bezier_coords(t, ((f64*)x.data)[0], ((f64*)x.data)[1], ((f64*)x.data)[2], ((f64*)x.data)[3], ((f64*)y.data)[0], ((f64*)y.data)[1], ((f64*)y.data)[2], ((f64*)y.data)[3]);
17536+}
17537+inline math__BezierPoint math__cubic_bezier_fa(f64 t, Array_fixed_f64_4 x, Array_fixed_f64_4 y) {
17538+ return math__cubic_bezier_coords(t, x[0], x[1], x[2], x[3], y[0], y[1], y[2], y[3]);
17539+}
17540+inline math__BezierPoint math__cubic_bezier_coords(f64 t, f64 x0, f64 x1, f64 x2, f64 x3, f64 y0, f64 y1, f64 y2, f64 y3) {
17541+ f64 p0 = math__pow(1 - t, 3);
17542+ f64 p1 = 3 * t * math__pow(1 - t, 2);
17543+ f64 p2 = 3 * (1 - t) * math__pow(t, 2);
17544+ f64 p3 = math__pow(t, 3);
17545+ f64 xt = p0 * x0 + p1 * x1 + p2 * x2 + p3 * x3;
17546+ f64 yt = p0 * y0 + p1 * y1 + p2 * y2 + p3 * y3;
17547+ return ((math__BezierPoint){.x = xt,.y = yt,});
17548+}
17549+f64 math__acosh(f64 x) {
17550+ if (x > ((f64)(6.7108864e+07))) {
17551+ return math__log(x) + ((f64)(_const_math__ln2));
17552+ } else if (x > ((f64)(2.0))) {
17553+ return math__log(((f64)(2.0)) * x - ((f64)(1.0)) / (math__sqrt(x * x - ((f64)(1.0))) + x));
17554+ } else if (x > ((f64)(1.0))) {
17555+ f64 t = x - ((f64)(1.0));
17556+ return math__log1p(t + math__sqrt(((f64)(2.0)) * t + t * t));
17557+ } else if (x == ((f64)(1.0))) {
17558+ return 0.0;
17559+ } else {
17560+ return math__nan();
17561+ }
17562+ return 0;
17563+}
17564+f64 math__asinh(f64 x) {
17565+ f64 a = math__abs_T_f64(x);
17566+ f64 s = (x < 0 ? (-1.0) : (1.0));
17567+ if (a > ((f64)(6.7108864e+07))) {
17568+ return s * (math__log(a) + ((f64)(_const_math__ln2)));
17569+ } else if (a > ((f64)(2.0))) {
17570+ return s * math__log(((f64)(2.0)) * a + ((f64)(1.0)) / (a + math__sqrt(a * a + ((f64)(1.0)))));
17571+ } else if (a > ((f64)(_const_math__internal__sqrt_f64_epsilon))) {
17572+ f64 a2 = a * a;
17573+ return s * math__log1p(a + a2 / (((f64)(1.0)) + math__sqrt(((f64)(1.0)) + a2)));
17574+ } else {
17575+ return x;
17576+ }
17577+ return 0;
17578+}
17579+f64 math__atanh(f64 x) {
17580+ f64 a = math__abs_T_f64(x);
17581+ f64 s = (x < 0 ? (-1.0) : (1.0));
17582+ if (a > ((f64)(1.0))) {
17583+ return math__nan();
17584+ } else if (a == ((f64)(1.0))) {
17585+ return (x < 0 ? (math__inf(-1)) : (math__inf(1)));
17586+ } else if (a >= ((f64)(0.5))) {
17587+ return s * ((f64)(0.5)) * math__log1p(((f64)(2.0)) * a / (((f64)(1.0)) - a));
17588+ } else if (a > ((f64)(_const_math__internal__f64_epsilon))) {
17589+ return s * ((f64)(0.5)) * math__log1p(((f64)(2.0)) * a + ((f64)(2.0)) * a * a / (((f64)(1.0)) - a));
17590+ } else {
17591+ return x;
17592+ }
17593+ return 0;
17594+}
17595+inline VV_LOC f64 math__xatan(f64 x) {
17596+ f64 xatan_p0 = -8.750608600031904122785e-01;
17597+ f64 xatan_p1 = -1.615753718733365076637e+01;
17598+ f64 xatan_p2 = -7.500855792314704667340e+01;
17599+ f64 xatan_p3 = -1.228866684490136173410e+02;
17600+ f64 xatan_p4 = -6.485021904942025371773e+01;
17601+ f64 xatan_q0 = 2.485846490142306297962e+01;
17602+ f64 xatan_q1 = 1.650270098316988542046e+02;
17603+ f64 xatan_q2 = 4.328810604912902668951e+02;
17604+ f64 xatan_q3 = 4.853903996359136964868e+02;
17605+ f64 xatan_q4 = 1.945506571482613964425e+02;
17606+ f64 z = x * x;
17607+ z = z * ((((xatan_p0 * z + xatan_p1) * z + xatan_p2) * z + xatan_p3) * z + xatan_p4) / (((((z + xatan_q0) * z + xatan_q1) * z + xatan_q2) * z + xatan_q3) * z + xatan_q4);
17608+ z = x * z + x;
17609+ return z;
17610+}
17611+inline VV_LOC f64 math__satan(f64 x) {
17612+ if (x <= ((f64)(0.66))) {
17613+ return math__xatan(x);
17614+ }
17615+ if (x > ((f64)(_const_math__tan3pio8))) {
17616+ return ((f64)(1.5707963267948966)) - math__xatan(((f64)(1.0)) / x) + ((f64)(_const_math__morebits));
17617+ }
17618+ return ((f64)((float_literal)(3.14159265358979323846264338327950288419716939937510582097494459 / 4))) + math__xatan((x - ((f64)(1.0))) / (x + ((f64)(1.0)))) + ((f64)(0.5)) * ((f64)(_const_math__morebits));
17619+}
17620+f64 math__atan(f64 x) {
17621+ if (x == 0) {
17622+ return x;
17623+ }
17624+ if (x > 0) {
17625+ return math__satan(x);
17626+ }
17627+ return -math__satan(-x);
17628+}
17629+f64 math__atan2(f64 y, f64 x) {
17630+ if (math__is_nan(y) || math__is_nan(x)) {
17631+ return math__nan();
17632+ }
17633+ if (y == ((f64)(0.0))) {
17634+ if (x >= 0 && !math__signbit(x)) {
17635+ return math__copysign(0, y);
17636+ }
17637+ return math__copysign(_const_math__pi, y);
17638+ }
17639+ if (x == ((f64)(0.0))) {
17640+ return math__copysign(1.5707963267948966, y);
17641+ }
17642+ if (math__is_inf(x, 0)) {
17643+ if (math__is_inf(x, 1)) {
17644+ if (math__is_inf(y, 0)) {
17645+ return math__copysign((float_literal)(3.14159265358979323846264338327950288419716939937510582097494459 / 4), y);
17646+ }
17647+ return math__copysign(0, y);
17648+ }
17649+ if (math__is_inf(y, 0)) {
17650+ return math__copysign(2.356194490192345, y);
17651+ }
17652+ return math__copysign(_const_math__pi, y);
17653+ }
17654+ if (math__is_inf(y, 0)) {
17655+ return math__copysign(1.5707963267948966, y);
17656+ }
17657+ f64 q = math__atan(y / x);
17658+ if (x < 0) {
17659+ if (q <= 0) {
17660+ return q + ((f64)(_const_math__pi));
17661+ }
17662+ return q - ((f64)(_const_math__pi));
17663+ }
17664+ return q;
17665+}
17666+f64 math__asin(f64 x_) {
17667+ f64 x = x_;
17668+ if (x == ((f64)(0.0))) {
17669+ return x;
17670+ }
17671+ bool neg = false;
17672+ if (x < ((f64)(0.0))) {
17673+ x = -x;
17674+ neg = true;
17675+ }
17676+ if (x > ((f64)(1.0))) {
17677+ return math__nan();
17678+ }
17679+ f64 temp = math__sqrt(((f64)(1.0)) - x * x);
17680+ if (x > ((f64)(0.7))) {
17681+ temp = ((f64)(1.5707963267948966)) - math__satan(temp / x);
17682+ } else {
17683+ temp = math__satan(x / temp);
17684+ }
17685+ if (neg) {
17686+ temp = -temp;
17687+ }
17688+ return temp;
17689+}
17690+inline f64 math__acos(f64 x) {
17691+ if (x < ((f64)(-1.0)) || x > ((f64)(1.0))) {
17692+ return math__nan();
17693+ }
17694+ if (x > ((f64)(0.5))) {
17695+ return ((f64)(2.0)) * math__asin(math__sqrt(((f64)(0.5)) - ((f64)(0.5)) * x));
17696+ }
17697+ f64 z = ((f64)(_const_math__pi)) / ((f64)(4.0)) - math__asin(x);
17698+ z = z + ((f64)(_const_math__morebits));
17699+ z = z + ((f64)(_const_math__pi)) / ((f64)(4.0));
17700+ return z;
17701+}
17702+inline f64 math__log(f64 x) {
17703+ return log(x);
17704+}
17705+inline f64 math__log2(f64 x) {
17706+ return log2(x);
17707+}
17708+inline f64 math__log10(f64 x) {
17709+ return log10(x);
17710+}
17711+inline f64 math__log1p(f64 x) {
17712+ return log1p(x);
17713+}
17714+f64 math__log_b(f64 x) {
17715+ return logb(x);
17716+}
17717+inline f32 math__logf(f32 x) {
17718+ return logf(x);
17719+}
17720+f64 math__log_n(f64 x, f64 b) {
17721+ f64 y = math__log(x);
17722+ f64 z = math__log(b);
17723+ return y / z;
17724+}
17725+f64 math__pure_v_but_overridden_by_c_log10(f64 x) {
17726+ f64 x_ = x;
17727+ i64 hx = ((i64)(math__f64_bits(x_)));
17728+ i32 k = ((i32)(0));
17729+ if (hx < ((i64)(0x0010000000000000LL))) {
17730+ if ((hx & 0x7fffffffffffffffLL) == 0) {
17731+ return math__inf(-1);
17732+ }
17733+ if (hx < 0) {
17734+ return (x_ - x_) / (x_ - x_);
17735+ }
17736+ k = k - 54;
17737+ x_ *= _const_math__two54;
17738+ hx = ((i64)(math__f64_bits(x_)));
17739+ }
17740+ if (_us64_le(((u64)(0x7ff0000000000000LL)),hx)) {
17741+ return x_ + x_;
17742+ }
17743+ k = k + ((i32)((((u64)((v__rshift_i64(hx, (u64)52)) - 1023)))));
17744+ i32 i = ((i32)(v__rshift_u64(((((u64)(k)) & 0x8000000000000000ULL)), (u64)63)));
17745+ hx = (((hx & 0x000fffffffffffffLL)) | (v__lshift_u64(((u64)(0x3ff - i)), (u64)52)));
17746+ f64 y = ((f64)(k + i));
17747+ x_ = math__f64_from_bits(((u64)(hx)));
17748+ f64 z = y * _const_math__log10_2lo + _const_math__ivln10 * math__log(x_);
17749+ return z + y * _const_math__log10_2hi;
17750+}
17751+f64 math__pure_v_but_overridden_by_c_log2(f64 x) {
17752+ multi_return_f64_int mr_1442 = math__frexp(x);
17753+ f64 frac = mr_1442.arg0;
17754+ int expn = mr_1442.arg1;
17755+ if (frac == ((f64)(0.5))) {
17756+ return ((f64)(expn - 1));
17757+ }
17758+ return math__log(frac) * ((f64)(1.4426950408889634)) + ((f64)(expn));
17759+}
17760+f64 math__pure_v_but_overridden_by_c_log1p(f64 x) {
17761+ f64 y = ((f64)(1.0)) + x;
17762+ f64 z = y - ((f64)(1.0));
17763+ return math__log(y) - (z - x) / y;
17764+}
17765+f64 math__pure_v_but_overridden_by_c_log_b(f64 x) {
17766+ if (x == 0) {
17767+ return math__inf(-1);
17768+ }
17769+ if (math__is_inf(x, 0)) {
17770+ return math__inf(1);
17771+ }
17772+ if (math__is_nan(x)) {
17773+ return x;
17774+ }
17775+ return ((f64)(math__ilog_b_(x)));
17776+}
17777+int math__ilog_b(f64 x) {
17778+ if (x == 0) {
17779+ return ((int)(_const_min_i32));
17780+ }
17781+ if (math__is_nan(x)) {
17782+ return ((int)(_const_max_i32));
17783+ }
17784+ if (math__is_inf(x, 0)) {
17785+ return ((int)(_const_max_i32));
17786+ }
17787+ return math__ilog_b_(x);
17788+}
17789+VV_LOC int math__ilog_b_(f64 x_) {
17790+ multi_return_f64_int mr_2548 = math__normalize(x_);
17791+ f64 x = mr_2548.arg0;
17792+ int expn = mr_2548.arg1;
17793+ return ((int)(((v__rshift_u64(math__f64_bits(x), (u64)52)) & 0x7FF))) - 1023 + expn;
17794+}
17795+f64 math__pure_v_but_overridden_by_c_log(f64 a) {
17796+ f64 ln2_hi = 6.93147180369123816490e-01;
17797+ f64 ln2_lo = 1.90821492927058770002e-10;
17798+ f64 l1 = 6.666666666666735130e-01;
17799+ f64 l2 = 3.999999999940941908e-01;
17800+ f64 l3 = 2.857142874366239149e-01;
17801+ f64 l4 = 2.222219843214978396e-01;
17802+ f64 l5 = 1.818357216161805012e-01;
17803+ f64 l6 = 1.531383769920937332e-01;
17804+ f64 l7 = 1.479819860511658591e-01;
17805+ f64 x = a;
17806+ if (math__is_nan(x) || math__is_inf(x, 1)) {
17807+ return x;
17808+ } else if (x < 0) {
17809+ return math__nan();
17810+ } else if (x == 0) {
17811+ return math__inf(-1);
17812+ }
17813+ multi_return_f64_int mr_5139 = math__frexp(x);
17814+ f64 f1 = mr_5139.arg0;
17815+ int ki = mr_5139.arg1;
17816+ if (f1 < ((f64)((float_literal)(1.41421356237309504880168872420969807856967187537694807317667974 / 2)))) {
17817+ f1 *= 2;
17818+ ki--;
17819+ }
17820+ f64 f = f1 - 1;
17821+ f64 k = ((f64)(ki));
17822+ f64 s = f / (2 + f);
17823+ f64 s2 = s * s;
17824+ f64 s4 = s2 * s2;
17825+ f64 t1 = s2 * (l1 + s4 * (l3 + s4 * (l5 + s4 * l7)));
17826+ f64 t2 = s4 * (l2 + s4 * (l4 + s4 * l6));
17827+ f64 r = t1 + t2;
17828+ f64 hfsq = ((f64)(0.5)) * f * f;
17829+ return k * ln2_hi - ((hfsq - (s * (hfsq + r) + k * ln2_lo)) - f);
17830+}
17831+#if 0
17832+#else
17833+#endif
17834+f64 math__aprox_sin(f64 a) {
17835+ f64 a0 = 1.91059300966915117e-31;
17836+ f64 a1 = 1.00086760103908896;
17837+ f64 a2 = -1.21276126894734565e-2;
17838+ f64 a3 = -1.38078780785773762e-1;
17839+ f64 a4 = -2.67353392911981221e-2;
17840+ f64 a5 = 2.08026600266304389e-2;
17841+ f64 a6 = -3.03996055049204407e-3;
17842+ f64 a7 = 1.38235642404333740e-4;
17843+ f64 tmp = a4 + a * (a5 + a * (a6 + a * a7));
17844+ return a0 + a * (a1 + a * (a2 + a * (a3 + a * tmp)));
17845+}
17846+f64 math__aprox_cos(f64 a) {
17847+ f64 a0 = 9.9995999154986614e-1;
17848+ f64 a1 = 1.2548995793001028e-3;
17849+ f64 a2 = -5.0648546280678015e-1;
17850+ f64 a3 = 1.2942246466519995e-2;
17851+ f64 a4 = 2.8668384702547972e-2;
17852+ f64 a5 = 7.3726485210586547e-3;
17853+ f64 a6 = -3.8510875386947414e-3;
17854+ f64 a7 = 4.7196604604366623e-4;
17855+ f64 a8 = -1.8776444013090451e-5;
17856+ f64 tmp = a4 + a * (a5 + a * (a6 + a * (a7 + a * a8)));
17857+ return a0 + a * (a1 + a * (a2 + a * (a3 + a * tmp)));
17858+}
17859+inline f64 math__copysign(f64 x, f64 y) {
17860+ return math__f64_from_bits((((math__f64_bits(x) & ~_const_math__sign_mask)) | ((math__f64_bits(y) & _const_math__sign_mask))));
17861+}
17862+inline f64 math__degrees(f64 radians) {
17863+ return radians * ((f64)(57.29577951308232));
17864+}
17865+inline f64 math__radians(f64 degrees) {
17866+ return degrees * ((f64)(0.017453292519943295));
17867+}
17868+inline f64 math__angle_diff(f64 radian_a, f64 radian_b) {
17869+ f64 delta = math__fmod(radian_b - radian_a, _const_math__tau);
17870+ delta = math__fmod(delta + ((f64)(9.42477796076938)), _const_math__tau);
17871+ delta -= 3.141592653589793;
17872+ return delta;
17873+}
17874+Array_int math__digits(i64 num, math__DigitParams params) {
17875+ int b = params.base;
17876+ if (b < 2) {
17877+ builtin__panic_n(_S("digits: Cannot find digits of n with base:"), b);
17878+ VUNREACHABLE();
17879+ }
17880+ i64 n = num;
17881+ int sgn = 1;
17882+ if (n < 0) {
17883+ sgn = -1;
17884+ n = -n;
17885+ }
17886+ Array_int res = builtin____new_array_with_default(0, 0, sizeof(int), 0);
17887+ if (n == 0) {
17888+ builtin__array_push((array*)&res, _MOV((int[]){ 0 }));
17889+ return res;
17890+ }
17891+ for (;;) {
17892+ if (!(n != 0)) break;
17893+ i64 next_n = (i64)(VSAFE_DIV_i64(n , b));
17894+ builtin__array_push((array*)&res, _MOV((int[]){ ((int)(n - (i64)(next_n * b))) }));
17895+ n = next_n;
17896+ }
17897+ if (sgn == -1) {
17898+ (*(int*)builtin__array_get(res, res.len - 1)) *= sgn;
17899+ }
17900+ if (params.reverse) {
17901+ res = builtin__array_reverse(res);
17902+ }
17903+ return res;
17904+}
17905+int math__count_digits(i64 number) {
17906+ i64 n = number;
17907+ if (n == 0) {
17908+ return 1;
17909+ }
17910+ int c = 0;
17911+ for (;;) {
17912+ if (!(n != 0)) break;
17913+ n = VSAFE_DIV_i64(n , 10);
17914+ c++;
17915+ }
17916+ return c;
17917+}
17918+multi_return_f64_f64 math__minmax(f64 a, f64 b) {
17919+ if (a < b) {
17920+ return (multi_return_f64_f64){.arg0=a, .arg1=b};
17921+ }
17922+ return (multi_return_f64_f64){.arg0=b, .arg1=a};
17923+}
17924+inline f64 math__clamp(f64 x, f64 a, f64 b) {
17925+ if (x < a) {
17926+ return a;
17927+ }
17928+ if (x > b) {
17929+ return b;
17930+ }
17931+ return x;
17932+}
17933+inline f64 math__sign(f64 n) {
17934+ if (math__is_nan(n)) {
17935+ return math__nan();
17936+ }
17937+ return math__copysign(1.0, n);
17938+}
17939+inline int math__signi(f64 n) {
17940+ return ((int)(math__copysign(1.0, n)));
17941+}
17942+inline bool math__signbit(f64 x) {
17943+ return (math__f64_bits(x) & _const_math__sign_mask) != 0;
17944+}
17945+bool math__tolerance(f64 actual, f64 expected, f64 tol) {
17946+ if (actual == expected) {
17947+ return true;
17948+ }
17949+ f64 d = actual - expected;
17950+ if (d < 0) {
17951+ d = -d;
17952+ }
17953+ f64 ee = tol;
17954+ if (expected != 0) {
17955+ ee *= expected;
17956+ if (ee < 0) {
17957+ ee = -ee;
17958+ }
17959+ }
17960+ return d < ee;
17961+}
17962+bool math__close(f64 actual, f64 expected) {
17963+ return math__tolerance(actual, expected, 1e-14);
17964+}
17965+bool math__veryclose(f64 actual, f64 expected) {
17966+ return math__tolerance(actual, expected, 4e-16);
17967+}
17968+bool math__alike(f64 a, f64 b) {
17969+ if ((math__f64_bits(a) & 0xFFFFFFFFFFFFFFFCULL) == (math__f64_bits(b) & 0xFFFFFFFFFFFFFFFCULL)) {
17970+ return true;
17971+ }
17972+ if (a == -0LL && b == 0) {
17973+ return true;
17974+ }
17975+ if (a == 0 && b == -0LL) {
17976+ return true;
17977+ }
17978+ if (math__is_nan(a) && math__is_nan(b)) {
17979+ return true;
17980+ }
17981+ if (a == b) {
17982+ return math__signbit(a) == math__signbit(b);
17983+ }
17984+ return false;
17985+}
17986+multi_return_f64_f64 math__modf(f64 f) {
17987+ f64 abs_f = math__abs_T_f64(f);
17988+ f64 i = 0.0;
17989+ if (abs_f >= ((f64)(_const_math__modf_maxpowtwo))) {
17990+ i = f;
17991+ } else {
17992+ i = abs_f + ((f64)(_const_math__modf_maxpowtwo));
17993+ i -= _const_math__modf_maxpowtwo;
17994+ for (;;) {
17995+ if (!(i > abs_f)) break;
17996+ i -= 1.0;
17997+ }
17998+ if (f < ((f64)(0.0))) {
17999+ i = -i;
18000+ }
18001+ }
18002+ return (multi_return_f64_f64){.arg0=i, .arg1=f - i};
18003+}
18004+f32 math__nextafter32(f32 x, f32 y) {
18005+ f32 r = ((f32)(0.0));
18006+ if (math__is_nan(((f64)(x))) || math__is_nan(((f64)(y)))) {
18007+ r = ((f32)(math__nan()));
18008+ } else if (x == y) {
18009+ r = x;
18010+ } else if (x == 0) {
18011+ r = ((f32)(math__copysign(((f64)(math__f32_from_bits(1))), ((f64)(y)))));
18012+ } else if ((y > x) == (x > 0)) {
18013+ r = math__f32_from_bits(math__f32_bits(x) + 1);
18014+ } else {
18015+ r = math__f32_from_bits(math__f32_bits(x) - 1);
18016+ }
18017+ return r;
18018+}
18019+f64 math__nextafter(f64 x, f64 y) {
18020+ f64 r = 0.0;
18021+ if (math__is_nan(x) || math__is_nan(y)) {
18022+ r = math__nan();
18023+ } else if (x == y) {
18024+ r = x;
18025+ } else if (x == 0) {
18026+ r = math__copysign(math__f64_from_bits(1), y);
18027+ } else if ((y > x) == (x > 0)) {
18028+ r = math__f64_from_bits(math__f64_bits(x) + 1);
18029+ } else {
18030+ r = math__f64_from_bits(math__f64_bits(x) - 1);
18031+ }
18032+ return r;
18033+}
18034+VV_LOC multi_return_f64_f64 math__ChebSeries_eval_e(math__ChebSeries cs, f64 x) {
18035+ f64 d = 0.0;
18036+ f64 dd = 0.0;
18037+ f64 y = (((f64)(2.0)) * x - cs.a - cs.b) / (cs.b - cs.a);
18038+ f64 y2 = ((f64)(2.0)) * y;
18039+ f64 e_ = 0.0;
18040+ f64 temp = 0.0;
18041+ for (int j = cs.order; j >= 1; j--) {
18042+ temp = d;
18043+ d = y2 * d - dd + (*(f64*)builtin__array_get(cs.c, j));
18044+ e_ += math__abs_T_f64(y2 * temp) + math__abs_T_f64(dd) + math__abs_T_f64((*(f64*)builtin__array_get(cs.c, j)));
18045+ dd = temp;
18046+ }
18047+ temp = d;
18048+ d = y * d - dd + ((f64)(0.5)) * (*(f64*)builtin__array_get(cs.c, 0));
18049+ e_ += math__abs_T_f64(y * temp) + math__abs_T_f64(dd) + ((f64)(0.5)) * math__abs_T_f64((*(f64*)builtin__array_get(cs.c, 0)));
18050+ return (multi_return_f64_f64){.arg0=d, .arg1=((f64)(_const_math__internal__f64_epsilon)) * e_ + math__abs_T_f64((*(f64*)builtin__array_get(cs.c, cs.order)))};
18051+}
18052+inline f64 math__pow(f64 x, f64 y) {
18053+ return pow(x, y);
18054+}
18055+inline f32 math__powf(f32 a, f32 b) {
18056+ return powf(a, b);
18057+}
18058+inline f32 math__pure_v_but_overridden_by_c_powf(f32 a, f32 b) {
18059+ return ((f32)(math__pow(a, b)));
18060+}
18061+f64 math__pow10(int n) {
18062+ if (0 <= n && n <= 308) {
18063+ return (*(f64*)builtin__array_get(_const_math__pow10postab32, VSAFE_DIV_u32(((u32)(n)) , 32))) * (*(f64*)builtin__array_get(_const_math__pow10tab, VSAFE_MOD_u32(((u32)(n)) , 32)));
18064+ }
18065+ if (-323 <= n && n <= 0) {
18066+ return (*(f64*)builtin__array_get(_const_math__pow10negtab32, VSAFE_DIV_u32(((u32)(-n)) , 32))) / (*(f64*)builtin__array_get(_const_math__pow10tab, VSAFE_MOD_u32(((u32)(-n)) , 32)));
18067+ }
18068+ if (n > 0) {
18069+ return math__inf(1);
18070+ }
18071+ return 0.0;
18072+}
18073+i64 math__powi(i64 a, i64 b) {
18074+ i64 b_ = b;
18075+ i64 p = a;
18076+ i64 v = ((i64)(1));
18077+ if (b_ < 0) {
18078+ if (a == 0) {
18079+ return -1;
18080+ }
18081+ return (a * a != 1 ? (0) : ((((b_ & 1)) > 0 ? (a) : (1))));
18082+ }
18083+ for (; b_ > 0; ) {
18084+ if ((b_ & 1) > 0) {
18085+ v *= p;
18086+ }
18087+ p *= p;
18088+ b_ = v__rshift_i64(b_, (u64)1);
18089+ }
18090+ return v;
18091+}
18092+VV_LOC bool math__is_odd_int(f64 x) {
18093+ multi_return_f64_f64 mr_1555 = math__modf(x);
18094+ f64 xi = mr_1555.arg0;
18095+ f64 xf = mr_1555.arg1;
18096+ return xf == 0 && ((((i64)(xi)) & 1)) == 1;
18097+}
18098+f64 math__pure_v_but_overridden_by_c_pow(f64 x, f64 y) {
18099+ if (y == 0 || x == 1) {
18100+ return 1;
18101+ } else if (y == 1) {
18102+ return x;
18103+ } else if (math__is_nan(x) || math__is_nan(y)) {
18104+ return math__nan();
18105+ } else if (y == 2) {
18106+ return x * x;
18107+ } else if (y == 3) {
18108+ return x * x * x;
18109+ } else if (x == 0) {
18110+ if (y < 0) {
18111+ if (math__is_odd_int(y)) {
18112+ return math__copysign(math__inf(1), x);
18113+ }
18114+ return math__inf(1);
18115+ } else if (y > 0) {
18116+ if (math__is_odd_int(y)) {
18117+ return x;
18118+ }
18119+ return 0;
18120+ }
18121+ } else if (math__is_inf(y, 0)) {
18122+ if (x == -1) {
18123+ return 1;
18124+ } else if ((math__abs_T_f64(x) < 1) == math__is_inf(y, 1)) {
18125+ return 0;
18126+ } else {
18127+ return math__inf(1);
18128+ }
18129+ } else if (math__is_inf(x, 0)) {
18130+ if (math__is_inf(x, -1)) {
18131+ return math__pow(1 / x, -y);
18132+ }
18133+ if (y < 0) {
18134+ return 0;
18135+ } else if (y > 0) {
18136+ return math__inf(1);
18137+ }
18138+ } else if (y == ((f64)(0.5))) {
18139+ return math__sqrt(x);
18140+ } else if (y == ((f64)(-0.5))) {
18141+ return 1 / math__sqrt(x);
18142+ }
18143+ multi_return_f64_f64 mr_2579 = math__modf(math__abs_T_f64(y));
18144+ f64 yi = mr_2579.arg0;
18145+ f64 yf = mr_2579.arg1;
18146+ if (yf != 0 && x < 0) {
18147+ return math__nan();
18148+ }
18149+ if (yi >= (v__lshift_u64(((u64)(1)), (u64)63))) {
18150+ if (x == -1) {
18151+ return 1;
18152+ } else if ((math__abs_T_f64(x) < 1) == (y > 0)) {
18153+ return 0;
18154+ } else {
18155+ return math__inf(1);
18156+ }
18157+ }
18158+ if (yf == ((f64)(0.0))) {
18159+ f64 result = x;
18160+ for (i64 _t22 = 1; _t22 < ((i64)(yi)); ++_t22) {
18161+ result *= x;
18162+ }
18163+ if (y > 0) {
18164+ return result;
18165+ }
18166+ return 1 / result;
18167+ }
18168+ f64 a1 = 1.0;
18169+ int ae = 0;
18170+ if (yf != 0) {
18171+ if (yf > ((f64)(0.5))) {
18172+ yf--;
18173+ yi++;
18174+ }
18175+ a1 = math__exp(yf * math__log(x));
18176+ }
18177+ multi_return_f64_int mr_3354 = math__frexp(x);
18178+ f64 x1 = mr_3354.arg0;
18179+ int xe = mr_3354.arg1;
18180+ for (i64 i = ((i64)(yi)); i != 0; i = v__rshift_i64(i, (u64)1)) {
18181+ if (xe < ((int)(((u32)(v__lshift_u32(((u32)(-1)), (u64)12))))) || 4096 < xe) {
18182+ ae += xe;
18183+ break;
18184+ }
18185+ if ((i & 1) == 1) {
18186+ a1 *= x1;
18187+ ae += xe;
18188+ }
18189+ x1 *= x1;
18190+ xe = v__lshift_int(xe, (u64)1);
18191+ if (x1 < ((f64)(.5))) {
18192+ x1 += x1;
18193+ xe--;
18194+ }
18195+ }
18196+ if (y < 0) {
18197+ a1 = 1 / a1;
18198+ ae = -ae;
18199+ }
18200+ return math__ldexp(a1, ae);
18201+}
18202+inline f64 math__q_rsqrt(f64 x) {
18203+ f64 x_half = ((f64)(0.5)) * x;
18204+ i64 i = ((i64)(math__f64_bits(x)));
18205+ i = 0x5fe6eb50c7b537a9LL - (v__rshift_i64(i, (u64)1));
18206+ f64 j = math__f64_from_bits(((u64)(i)));
18207+ j *= (((f64)(1.5)) - x_half * j * j);
18208+ j *= (((f64)(1.5)) - x_half * j * j);
18209+ return j;
18210+}
18211+f64 math__scalbn(f64 x, int n_) {
18212+ int n = n_;
18213+ f64 x1p1023 = math__f64_from_bits(((u64)(0x7fe0000000000000LL)));
18214+ f64 x1p53 = math__f64_from_bits(((u64)(0x4340000000000000LL)));
18215+ f64 x1p_1022 = math__f64_from_bits(((u64)(0x0010000000000000LL)));
18216+ f64 y = x;
18217+ if (n > 1023) {
18218+ y *= x1p1023;
18219+ n -= 1023;
18220+ if (n > 1023) {
18221+ y *= x1p1023;
18222+ n -= 1023;
18223+ if (n > 1023) {
18224+ n = 1023;
18225+ }
18226+ }
18227+ } else if (n < -1022) {
18228+ y *= x1p_1022 * x1p53;
18229+ n += 969;
18230+ if (n < -1022) {
18231+ y *= x1p_1022 * x1p53;
18232+ n += 969;
18233+ if (n < -1022) {
18234+ n = -1022;
18235+ }
18236+ }
18237+ }
18238+ return y * math__f64_from_bits(v__lshift_u64(((u64)((0x3ff + n))), (u64)52));
18239+}
18240+inline f64 math__cos(f64 a) {
18241+ return cos(a);
18242+}
18243+inline f64 math__sin(f64 a) {
18244+ return sin(a);
18245+}
18246+inline f32 math__cosf(f32 a) {
18247+ return cosf(a);
18248+}
18249+inline f32 math__sinf(f32 a) {
18250+ return sinf(a);
18251+}
18252+f64 math__pure_v_but_overridden_by_c_sin(f64 x) {
18253+ f64 p1 = 7.85398125648498535156e-1;
18254+ f64 p2 = 3.77489470793079817668e-8;
18255+ f64 p3 = 2.69515142907905952645e-15;
18256+ int sgn_x = (x < 0 ? (-1) : (1));
18257+ f64 abs_x = math__abs_T_f64(x);
18258+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18259+ f64 x2 = x * x;
18260+ return x * (((f64)(1.0)) - x2 / ((f64)(6.0)));
18261+ } else {
18262+ int sgn_result = sgn_x;
18263+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18264+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18265+ if (((octant & 1)) == 1) {
18266+ octant++;
18267+ octant &= 7;
18268+ y += 1.0;
18269+ }
18270+ if (octant > 3) {
18271+ octant -= 4;
18272+ sgn_result = -sgn_result;
18273+ }
18274+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18275+ f64 result = 0.0;
18276+ if (octant == 0) {
18277+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18278+ multi_return_f64_f64 mr_1722 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18279+ f64 sin_cs_val = mr_1722.arg0;
18280+ result = z * (((f64)(1.0)) + z * z * sin_cs_val);
18281+ } else {
18282+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18283+ multi_return_f64_f64 mr_1845 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18284+ f64 cos_cs_val = mr_1845.arg0;
18285+ result = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18286+ }
18287+ result *= sgn_result;
18288+ return result;
18289+ }
18290+ return 0;
18291+}
18292+f64 math__pure_v_but_overridden_by_c_cos(f64 x) {
18293+ f64 p1 = 7.85398125648498535156e-1;
18294+ f64 p2 = 3.77489470793079817668e-8;
18295+ f64 p3 = 2.69515142907905952645e-15;
18296+ f64 abs_x = math__abs_T_f64(x);
18297+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18298+ f64 x2 = x * x;
18299+ return ((f64)(1.0)) - ((f64)(0.5)) * x2;
18300+ } else {
18301+ int sgn_result = 1;
18302+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18303+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18304+ if (((octant & 1)) == 1) {
18305+ octant++;
18306+ octant &= 7;
18307+ y += 1.0;
18308+ }
18309+ if (octant > 3) {
18310+ octant -= 4;
18311+ sgn_result = -sgn_result;
18312+ }
18313+ if (octant > 1) {
18314+ sgn_result = -sgn_result;
18315+ }
18316+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18317+ f64 result = 0.0;
18318+ if (octant == 0) {
18319+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18320+ multi_return_f64_f64 mr_2686 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18321+ f64 cos_cs_val = mr_2686.arg0;
18322+ result = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18323+ } else {
18324+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18325+ multi_return_f64_f64 mr_2825 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18326+ f64 sin_cs_val = mr_2825.arg0;
18327+ result = z * (((f64)(1.0)) + z * z * sin_cs_val);
18328+ }
18329+ result *= sgn_result;
18330+ return result;
18331+ }
18332+ return 0;
18333+}
18334+inline f32 math__pure_v_but_overridden_by_c_cosf(f32 a) {
18335+ return ((f32)(math__cos(a)));
18336+}
18337+inline f32 math__pure_v_but_overridden_by_c_sinf(f32 a) {
18338+ return ((f32)(math__sin(a)));
18339+}
18340+multi_return_f64_f64 math__sincos(f64 x) {
18341+ if (math__is_nan(x)) {
18342+ return (multi_return_f64_f64){.arg0=x, .arg1=x};
18343+ }
18344+ f64 p1 = 7.85398125648498535156e-1;
18345+ f64 p2 = 3.77489470793079817668e-8;
18346+ f64 p3 = 2.69515142907905952645e-15;
18347+ int sgn_x = (x < 0 ? (-1) : (1));
18348+ f64 abs_x = math__abs_T_f64(x);
18349+ if (math__is_inf(x, sgn_x)) {
18350+ return (multi_return_f64_f64){.arg0=math__nan(), .arg1=math__nan()};
18351+ }
18352+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18353+ f64 x2 = x * x;
18354+ return (multi_return_f64_f64){.arg0=x * (((f64)(1.0)) - x2 / ((f64)(6.0))), .arg1=((f64)(1.0)) - ((f64)(0.5)) * x2};
18355+ } else {
18356+ int sgn_result_sin = sgn_x;
18357+ int sgn_result_cos = 1;
18358+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18359+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18360+ if (((octant & 1)) == 1) {
18361+ octant++;
18362+ octant &= 7;
18363+ y += 1.0;
18364+ }
18365+ if (octant > 3) {
18366+ octant -= 4;
18367+ sgn_result_sin = -sgn_result_sin;
18368+ sgn_result_cos = -sgn_result_cos;
18369+ }
18370+ sgn_result_cos = (octant > 1 ? (-sgn_result_cos) : (sgn_result_cos));
18371+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18372+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18373+ multi_return_f64_f64 mr_4085 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18374+ f64 sin_cs_val = mr_4085.arg0;
18375+ multi_return_f64_f64 mr_4121 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18376+ f64 cos_cs_val = mr_4121.arg0;
18377+ f64 result_sin = 0.0;
18378+ f64 result_cos = 0.0;
18379+ if (octant == 0) {
18380+ result_sin = z * (((f64)(1.0)) + z * z * sin_cs_val);
18381+ result_cos = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18382+ } else {
18383+ result_sin = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18384+ result_cos = z * (((f64)(1.0)) + z * z * sin_cs_val);
18385+ }
18386+ result_sin *= sgn_result_sin;
18387+ result_cos *= sgn_result_cos;
18388+ return (multi_return_f64_f64){.arg0=result_sin, .arg1=result_cos};
18389+ }
18390+ return (multi_return_f64_f64){0};
18391+}
18392+f64 math__sinh(f64 x_) {
18393+ f64 x = x_;
18394+ f64 p0 = -0.6307673640497716991184787251e+6;
18395+ f64 p1 = -0.8991272022039509355398013511e+5;
18396+ f64 p2 = -0.2894211355989563807284660366e+4;
18397+ f64 p3 = -0.2630563213397497062819489e+2;
18398+ f64 q0 = -0.6307673640497716991212077277e+6;
18399+ f64 q1 = 0.1521517378790019070696485176e+5;
18400+ f64 q2 = -0.173678953558233699533450911e+3;
18401+ bool neg = false;
18402+ if (x < 0) {
18403+ x = -x;
18404+ neg = true;
18405+ }
18406+ f64 temp = 0.0;
18407+ if (x > 21) {
18408+ temp = math__exp(x) * ((f64)(0.5));
18409+ } else if (x > ((f64)(0.5))) {
18410+ f64 ex = math__exp(x);
18411+ temp = (ex - ((f64)(1.0)) / ex) * ((f64)(0.5));
18412+ } else {
18413+ f64 sq = x * x;
18414+ temp = (((p3 * sq + p2) * sq + p1) * sq + p0) * x;
18415+ temp = temp / (((sq + q2) * sq + q1) * sq + q0);
18416+ }
18417+ if (neg) {
18418+ temp = -temp;
18419+ }
18420+ return temp;
18421+}
18422+f64 math__cosh(f64 x) {
18423+ f64 abs_x = math__abs_T_f64(x);
18424+ if (abs_x > 21) {
18425+ return math__exp(abs_x) * ((f64)(0.5));
18426+ }
18427+ f64 ex = math__exp(abs_x);
18428+ return (ex + ((f64)(1.0)) / ex) * ((f64)(0.5));
18429+}
18430+inline f64 math__sqrt(f64 a) {
18431+ return sqrt(a);
18432+}
18433+inline f32 math__sqrtf(f32 a) {
18434+ return sqrtf(a);
18435+}
18436+inline f64 math__pure_v_but_overridden_by_c_sqrt(f64 a) {
18437+ f64 x = a;
18438+ if (x == ((f64)(0.0)) || math__is_nan(x) || math__is_inf(x, 1)) {
18439+ return x;
18440+ }
18441+ if (x < ((f64)(0.0))) {
18442+ return math__nan();
18443+ }
18444+ multi_return_f64_int mr_259 = math__frexp(x);
18445+ f64 z = mr_259.arg0;
18446+ int ex = mr_259.arg1;
18447+ f64 w = x;
18448+ x = ((f64)(4.173075996388649989089e-1)) + ((f64)(5.9016206709064458299663e-1)) * z;
18449+ if (((ex & 1)) != 0) {
18450+ x *= _const_math__sqrt2;
18451+ }
18452+ x = math__ldexp(x, v__rshift_int(ex, (u64)1));
18453+ x = ((f64)(0.5)) * (x + w / x);
18454+ x = ((f64)(0.5)) * (x + w / x);
18455+ x = ((f64)(0.5)) * (x + w / x);
18456+ return x;
18457+}
18458+inline f32 math__pure_v_but_overridden_by_c_sqrtf(f32 a) {
18459+ return ((f32)(math__sqrt(a)));
18460+}
18461+i64 math__sqrti(i64 a) {
18462+ i64 x = a;
18463+ i64 q = ((i64)(1));
18464+ i64 r = ((i64)(0));
18465+ for (; q <= x; ) {
18466+ q = v__lshift_i64(q, (u64)2);
18467+ }
18468+ for (; q > 1; ) {
18469+ q = v__rshift_i64(q, (u64)2);
18470+ i64 t = x - r - q;
18471+ r = v__rshift_i64(r, (u64)1);
18472+ if (t >= 0) {
18473+ x = t;
18474+ r += q;
18475+ }
18476+ }
18477+ return r;
18478+}
18479+inline f32 math__tanf(f32 a) {
18480+ return tanf(a);
18481+}
18482+f64 math__tan(f64 a) {
18483+ f64 x = a;
18484+ if (x == ((f64)(0.0)) || math__is_nan(x)) {
18485+ return x;
18486+ }
18487+ if (math__is_inf(x, 0)) {
18488+ return math__nan();
18489+ }
18490+ int sgn = 1;
18491+ if (x < 0) {
18492+ x = -x;
18493+ sgn = -1;
18494+ }
18495+ if (x > ((f64)(_const_math__tan_lossth))) {
18496+ return 0.0;
18497+ }
18498+ f64 y = math__floor(x * ((f64)(4.0)) / ((f64)(_const_math__pi)));
18499+ f64 z = math__ldexp(y, -3);
18500+ z = math__floor(z);
18501+ z = y - math__ldexp(z, 3);
18502+ int octant = ((int)(z));
18503+ if (((octant & 1)) == 1) {
18504+ octant++;
18505+ y += 1.0;
18506+ }
18507+ z = ((x - y * ((f64)(_const_math__tan_dp1))) - y * ((f64)(_const_math__tan_dp2))) - y * ((f64)(_const_math__tan_dp3));
18508+ f64 zz = z * z;
18509+ if (zz > ((f64)(1.0e-14))) {
18510+ y = z + z * (zz * ((((*(f64*)builtin__array_get(_const_math__tan_p, 0)) * zz) + (*(f64*)builtin__array_get(_const_math__tan_p, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_p, 2))) / ((((zz + (*(f64*)builtin__array_get(_const_math__tan_q, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 2))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 3))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 4))));
18511+ } else {
18512+ y = z;
18513+ }
18514+ if (((octant & 2)) == 2) {
18515+ y = ((f64)(-1.0)) / y;
18516+ }
18517+ if (sgn < 0) {
18518+ y = -y;
18519+ }
18520+ return y;
18521+}
18522+inline f32 math__pure_v_but_overridden_by_c_tanf(f32 a) {
18523+ return ((f32)(math__tan(a)));
18524+}
18525+f64 math__cot(f64 a) {
18526+ f64 x = a;
18527+ if (x == ((f64)(0.0))) {
18528+ return math__inf(1);
18529+ }
18530+ int sgn = 1;
18531+ if (x < 0) {
18532+ x = -x;
18533+ sgn = -1;
18534+ }
18535+ if (x > ((f64)(_const_math__tan_lossth))) {
18536+ return 0.0;
18537+ }
18538+ f64 y = math__floor(x * ((f64)(4.0)) / ((f64)(_const_math__pi)));
18539+ f64 z = math__ldexp(y, -3);
18540+ z = math__floor(z);
18541+ z = y - math__ldexp(z, 3);
18542+ int octant = ((int)(z));
18543+ if (((octant & 1)) == 1) {
18544+ octant++;
18545+ y += 1.0;
18546+ }
18547+ z = ((x - y * ((f64)(_const_math__tan_dp1))) - y * ((f64)(_const_math__tan_dp2))) - y * ((f64)(_const_math__tan_dp3));
18548+ f64 zz = z * z;
18549+ if (zz > ((f64)(1.0e-14))) {
18550+ y = z + z * (zz * ((((*(f64*)builtin__array_get(_const_math__tan_p, 0)) * zz) + (*(f64*)builtin__array_get(_const_math__tan_p, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_p, 2))) / ((((zz + (*(f64*)builtin__array_get(_const_math__tan_q, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 2))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 3))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 4))));
18551+ } else {
18552+ y = z;
18553+ }
18554+ if (((octant & 2)) == 2) {
18555+ y = -y;
18556+ } else {
18557+ y = ((f64)(1.0)) / y;
18558+ }
18559+ if (sgn < 0) {
18560+ y = -y;
18561+ }
18562+ return y;
18563+}
18564+f64 math__tanh(f64 x) {
18565+ f64 maxlog = 8.8029691931113054295988e+01;
18566+ f64 z = math__abs_T_f64(x);
18567+ if (z > ((f64)(0.5)) * maxlog) {
18568+ if (x < 0) {
18569+ return ((f64)(-1));
18570+ }
18571+ return 1.0;
18572+ } else if (z >= ((f64)(0.625))) {
18573+ f64 s = math__exp(((f64)(2.0)) * z);
18574+ z = ((f64)(1.0)) - ((f64)(2.0)) / (s + ((f64)(1.0)));
18575+ if (x < 0) {
18576+ z = -z;
18577+ }
18578+ } else {
18579+ if (x == 0) {
18580+ return x;
18581+ }
18582+ f64 s = x * x;
18583+ z = x + x * s * (((*(f64*)builtin__array_get(_const_math__tanh_p, 0)) * s + (*(f64*)builtin__array_get(_const_math__tanh_p, 1))) * s + (*(f64*)builtin__array_get(_const_math__tanh_p, 2))) / (((s + (*(f64*)builtin__array_get(_const_math__tanh_q, 0))) * s + (*(f64*)builtin__array_get(_const_math__tanh_q, 1))) * s + (*(f64*)builtin__array_get(_const_math__tanh_q, 2)));
18584+ }
18585+ return z;
18586+}
18587+inline u32 math__f32_bits(f32 f) {
18588+ #if defined(__TINYC__)
18589+ {
18590+ return *((u32*)(&f));
18591+ }
18592+ #endif
18593+ return ((math__U32_F32){.f = f,}).u;
18594+}
18595+inline f32 math__f32_from_bits(u32 b) {
18596+ #if defined(__TINYC__)
18597+ {
18598+ return *((f32*)(&b));
18599+ }
18600+ #endif
18601+ return ((math__U32_F32){.u = b,}).f;
18602+}
18603+inline u64 math__f64_bits(f64 f) {
18604+ #if defined(__TINYC__)
18605+ {
18606+ return *((u64*)(&f));
18607+ }
18608+ #endif
18609+ return ((math__U64_F64){.f = f,}).u;
18610+}
18611+inline f64 math__f64_from_bits(u64 b) {
18612+ #if defined(__TINYC__)
18613+ {
18614+ return *((f64*)(&b));
18615+ }
18616+ #endif
18617+ return ((math__U64_F64){.u = b,}).f;
18618+}
18619+inline f64 math__with_set_low_word(f64 f, u32 lo) {
18620+ u64 tmp = math__f64_bits(f);
18621+ tmp &= 0xffffffff00000000ULL;
18622+ tmp |= ((u64)(lo));
18623+ return math__f64_from_bits(tmp);
18624+}
18625+inline f64 math__with_set_high_word(f64 f, u32 hi) {
18626+ u64 tmp = math__f64_bits(f);
18627+ tmp &= 0x00000000ffffffffU;
18628+ tmp |= v__lshift_u64(((u64)(hi)), (u64)32);
18629+ return math__f64_from_bits(tmp);
18630+}
18631+inline u32 math__get_high_word(f64 f) {
18632+ return ((u32)(v__rshift_u64(math__f64_bits(f), (u64)32)));
18633+}
18634+VV_LOC void main__vf_init(void) {
18635+ string probe = _S("vf");
18636+ {int _ = probe.len;}
18637+ ;
18638+}
18639+// export alias: vf_init -> main__vf_init
18640+void vf_init(void) {
18641+ return main__vf_init();
18642+}
18643+VV_LOC int main__vf_add(int a, int b) {
18644+ return a + b;
18645+}
18646+// export alias: vf_add -> main__vf_add
18647+int vf_add(int a, int b) {
18648+ return main__vf_add(a, b);
18649+}
18650+VV_LOC char* main__vf_greet(char* name) {
18651+ string n = builtin__cstring_to_vstring(name);
18652+ string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")}));
18653+ u8* out = res.str;
18654+ builtin__string_free(&n);
18655+ return out;
18656+}
18657+// export alias: vf_greet -> main__vf_greet
18658+char* vf_greet(char* name) {
18659+ return main__vf_greet(name);
18660+}
18661+VV_LOC void main__vf_free(voidptr p) {
18662+ builtin___v_free(p);
18663+}
18664+// export alias: vf_free -> main__vf_free
18665+void vf_free(voidptr p) {
18666+ return main__vf_free(p);
18667+}
18668+VV_LOC void main__vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1) {
18669+ if (w <= 0 || h <= 0 || max_iter <= 0) {
18670+ return;
18671+ }
18672+ f64 aspect = ((f64)(w)) / ((f64)(h));
18673+ f64 inv_w = ((f64)(1.0)) / ((f64)(w));
18674+ f64 inv_h = ((f64)(1.0)) / ((f64)(h));
18675+ for (int y = y0; y < y1; y++) {
18676+ f64 im = cy + (((f64)(y)) * inv_h - ((f64)(0.5))) * scale;
18677+ int row = (y - y0) * w * 4;
18678+ for (int x = 0; x < w; x++) {
18679+ f64 re = cx + (((f64)(x)) * inv_w - ((f64)(0.5))) * scale * aspect;
18680+ f64 zr = 0.0;
18681+ f64 zi = 0.0;
18682+ f64 zr2 = 0.0;
18683+ f64 zi2 = 0.0;
18684+ int i = 0;
18685+ for (;;) {
18686+ if (!(i < max_iter)) break;
18687+ zr2 = zr * zr;
18688+ zi2 = zi * zi;
18689+ if (zr2 + zi2 > ((f64)(4.0))) {
18690+ break;
18691+ }
18692+ zi = ((f64)(2.0)) * zr * zi + im;
18693+ zr = zr2 - zi2 + re;
18694+ i++;
18695+ }
18696+ int idx = row + x * 4;
18697+ if (i >= max_iter) {
18698+ { // Unsafe block
18699+ buf[idx] = ((u8)(0));
18700+ buf[idx + 1] = ((u8)(0));
18701+ buf[idx + 2] = ((u8)(0));
18702+ buf[idx + 3] = ((u8)(255));
18703+ }
18704+ continue;
18705+ }
18706+ f64 mag = math__sqrt(zr2 + zi2);
18707+ f64 nu = ((f64)(i));
18708+ if (mag > ((f64)(1.0))) {
18709+ nu = ((f64)(i)) + ((f64)(1.0)) - math__log(math__log(mag) / math__log(2.0)) / math__log(2.0);
18710+ }
18711+ f64 t = nu / ((f64)(max_iter));
18712+ { // Unsafe block
18713+ buf[idx] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(3.0)) + t * ((f64)(18.0))))));
18714+ buf[idx + 1] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(3.6)) + t * ((f64)(18.0))))));
18715+ buf[idx + 2] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(4.2)) + t * ((f64)(18.0))))));
18716+ buf[idx + 3] = ((u8)(255));
18717+ }
18718+ }
18719+ }
18720+}
18721+// export alias: vf_mandelbrot -> main__vf_mandelbrot
18722+void vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1) {
18723+ return main__vf_mandelbrot(buf, w, h, cx, cy, scale, max_iter, y0, y1);
18724+}
18725+VV_LOC void main__main(void) {
18726+}
18727+inline f64 math__abs_T_f64(f64 a) {
18728+ return (a < 0 ? (-a) : (a));
18729+}
18730+void _vinit(int ___argc, voidptr ___argv) {
18731+ static bool once = false; if (once) {return;} once = true;
18732+ // Initializations of consts for module builtin.closure
18733+ g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3
18734+{
18735+{
18736+Array_fixed_u8_15 _t1;
18737+#if defined(__V_ppc64le)
18738+#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
18739+#elif defined(__V_amd64)
18740+ { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ;
18741+ memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15));
18742+ }
18743+ ;
18744+#elif defined(__V_x86)
18745+#elif defined(__V_arm64)
18746+#elif defined(__V_arm32)
18747+#elif defined(__V_rv64)
18748+#elif defined(__V_rv32)
18749+#elif defined(__V_s390x)
18750+#elif defined(__V_loongarch64)
18751+#elif defined(__V_sparc64)
18752+#elif 0
18753+#else
18754+#endif
18755+ memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15));
18756+}
18757+}
18758+{
18759+{
18760+Array_fixed_u8_6 _t3;
18761+#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
18762+#elif defined(__V_arm32)
18763+#elif defined(__V_amd64)
18764+ { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ;
18765+ memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6));
16518 }18766 }
16519 ;18767 ;
16520 #elif defined(__V_x86)18768 #elif defined(__V_x86)
@@ -16561,6 +18809,121 @@ Array_fixed_u8_6 _t3;
16561 _const_min_i64 = ((i64)(-9223372036854775807LL - 1));18809 _const_min_i64 = ((i64)(-9223372036854775807LL - 1));
16562 _const_max_i64 = ((i64)(9223372036854775807LL));18810 _const_max_i64 = ((i64)(9223372036854775807LL));
16563 _const_utf8_replacement_rune = ((rune)(0xfffd));18811 _const_utf8_replacement_rune = ((rune)(0xfffd));
18812+ // Initializations of consts for module math
18813+{
18814+ _const_math__bernoulli = builtin__new_array_from_c_array(10, 10, sizeof(f64), _MOV((f64[10]){
18815+ 0.08333333333333333, -0.002777777777777778, 0.0007936507936507937, -0.0005952380952380953, 0.0008417508417508417, -0.0019175269175269176, 0.00641025641025641, -0.029550653594771242, 0.1800957401386015,
18816+ -1.3924322169059011}));
18817+}
18818+{
18819+ _const_math__factorials_table = builtin__new_array_from_c_array(171, 171, sizeof(f64), _MOV((f64[171]){
18820+ 1.000000000000000000000e+0, 1.000000000000000000000e+0, 2.000000000000000000000e+0, 6.000000000000000000000e+0, 2.400000000000000000000e+1, 1.200000000000000000000e+2, 7.200000000000000000000e+2, 5.040000000000000000000e+3, 4.032000000000000000000e+4,
18821+ 3.628800000000000000000e+5, 3.628800000000000000000e+6, 3.991680000000000000000e+7, 4.790016000000000000000e+8, 6.227020800000000000000e+9, 8.717829120000000000000e+10, 1.307674368000000000000e+12, 2.092278988800000000000e+13,
18822+ 3.556874280960000000000e+14, 6.402373705728000000000e+15, 1.216451004088320000000e+17, 2.432902008176640000000e+18, 5.109094217170944000000e+19, 1.124000727777607680000e+21, 2.585201673888497664000e+22, 6.204484017332394393600e+23,
18823+ 1.551121004333098598400e+25, 4.032914611266056355840e+26, 1.088886945041835216077e+28, 3.048883446117138605015e+29, 8.841761993739701954544e+30, 2.652528598121910586363e+32, 8.222838654177922817726e+33, 2.631308369336935301672e+35,
18824+ 8.683317618811886495518e+36, 2.952327990396041408476e+38, 1.033314796638614492967e+40, 3.719933267899012174680e+41, 1.376375309122634504632e+43, 5.230226174666011117600e+44, 2.039788208119744335864e+46, 8.159152832478977343456e+47,
18825+ 3.345252661316380710817e+49, 1.405006117752879898543e+51, 6.041526306337383563736e+52, 2.658271574788448768044e+54, 1.196222208654801945620e+56, 5.502622159812088949850e+57, 2.586232415111681806430e+59, 1.241391559253607267086e+61,
18826+ 6.082818640342675608723e+62, 3.041409320171337804361e+64, 1.551118753287382280224e+66, 8.065817517094387857166e+67, 4.274883284060025564298e+69, 2.308436973392413804721e+71, 1.269640335365827592597e+73, 7.109985878048634518540e+74,
18827+ 4.052691950487721675568e+76, 2.350561331282878571829e+78, 1.386831185456898357379e+80, 8.320987112741390144276e+81, 5.075802138772247988009e+83, 3.146997326038793752565e+85, 1.982608315404440064116e+87, 1.268869321858841641034e+89,
18828+ 8.247650592082470666723e+90, 5.443449390774430640037e+92, 3.647111091818868528825e+94, 2.480035542436830599601e+96, 1.711224524281413113725e+98, 1.197857166996989179607e+100, 8.504785885678623175212e+101, 6.123445837688608686152e+103,
18829+ 4.470115461512684340891e+105, 3.307885441519386412260e+107, 2.480914081139539809195e+109, 1.885494701666050254988e+111, 1.451830920282858696341e+113, 1.132428117820629783146e+115, 8.946182130782975286851e+116, 7.156945704626380229481e+118,
18830+ 5.797126020747367985880e+120, 4.753643337012841748421e+122, 3.945523969720658651190e+124, 3.314240134565353266999e+126, 2.817104114380550276949e+128, 2.422709538367273238177e+130, 2.107757298379527717214e+132, 1.854826422573984391148e+134,
18831+ 1.650795516090846108122e+136, 1.485715964481761497310e+138, 1.352001527678402962552e+140, 1.243841405464130725548e+142, 1.156772507081641574759e+144, 1.087366156656743080274e+146, 1.032997848823905926260e+148, 9.916779348709496892096e+149,
18832+ 9.619275968248211985333e+151, 9.426890448883247745626e+153, 9.332621544394415268170e+155, 9.332621544394415268170e+157, 9.425947759838359420852e+159, 9.614466715035126609269e+161, 9.902900716486180407547e+163, 1.029901674514562762385e+166,
18833+ 1.081396758240290900504e+168, 1.146280563734708354534e+170, 1.226520203196137939352e+172, 1.324641819451828974500e+174, 1.443859583202493582205e+176, 1.588245541522742940425e+178, 1.762952551090244663872e+180, 1.974506857221074023537e+182,
18834+ 2.231192748659813646597e+184, 2.543559733472187557120e+186, 2.925093693493015690688e+188, 3.393108684451898201198e+190, 3.969937160808720895402e+192, 4.684525849754290656574e+194, 5.574585761207605881323e+196, 6.689502913449127057588e+198,
18835+ 8.094298525273443739682e+200, 9.875044200833601362412e+202, 1.214630436702532967577e+205, 1.506141741511140879795e+207, 1.882677176888926099744e+209, 2.372173242880046885677e+211, 3.012660018457659544810e+213, 3.856204823625804217357e+215,
18836+ 4.974504222477287440390e+217, 6.466855489220473672507e+219, 8.471580690878820510985e+221, 1.118248651196004307450e+224, 1.487270706090685728908e+226, 1.992942746161518876737e+228, 2.690472707318050483595e+230, 3.659042881952548657690e+232,
18837+ 5.012888748274991661035e+234, 6.917786472619488492228e+236, 9.615723196941089004197e+238, 1.346201247571752460588e+241, 1.898143759076170969429e+243, 2.695364137888162776589e+245, 3.854370717180072770522e+247, 5.550293832739304789551e+249,
18838+ 8.047926057471991944849e+251, 1.174997204390910823948e+254, 1.727245890454638911203e+256, 2.556323917872865588581e+258, 3.808922637630569726986e+260, 5.713383956445854590479e+262, 8.627209774233240431623e+264, 1.311335885683452545607e+267,
18839+ 2.006343905095682394778e+269, 3.089769613847350887959e+271, 4.789142901463393876336e+273, 7.471062926282894447084e+275, 1.172956879426414428192e+278, 1.853271869493734796544e+280, 2.946702272495038326504e+282, 4.714723635992061322407e+284,
18840+ 7.590705053947218729075e+286, 1.229694218739449434110e+289, 2.004401576545302577600e+291, 3.287218585534296227263e+293, 5.423910666131588774984e+295, 9.003691705778437366474e+297, 1.503616514864999040201e+300, 2.526075744973198387538e+302,
18841+ 4.269068009004705274939e+304, 7.257415615307998967397e+306}));
18842+}
18843+{
18844+ _const_math__log_factorials_table = builtin__new_array_from_c_array(172, 172, sizeof(f64), _MOV((f64[172]){
18845+ 0.000000000000000000000e+0, 0.000000000000000000000e+0, 6.931471805599453094172e-1, 1.791759469228055000812e+0, 3.178053830347945619647e+0, 4.787491742782045994248e+0, 6.579251212010100995060e+0, 8.525161361065414300166e+0, 1.060460290274525022842e+1,
18846+ 1.280182748008146961121e+1, 1.510441257307551529523e+1, 1.750230784587388583929e+1, 1.998721449566188614952e+1, 2.255216385312342288557e+1, 2.519122118273868150009e+1, 2.789927138384089156609e+1, 3.067186010608067280376e+1,
18847+ 3.350507345013688888401e+1, 3.639544520803305357622e+1, 3.933988418719949403622e+1, 4.233561646075348502966e+1, 4.538013889847690802616e+1, 4.847118135183522387964e+1, 5.160667556776437357045e+1, 5.478472939811231919009e+1,
18848+ 5.800360522298051993929e+1, 6.126170176100200198477e+1, 6.455753862700633105895e+1, 6.788974313718153498289e+1, 7.125703896716800901007e+1, 7.465823634883016438549e+1, 7.809222355331531063142e+1, 8.155795945611503717850e+1,
18849+ 8.505446701758151741396e+1, 8.858082754219767880363e+1, 9.213617560368709248333e+1, 9.571969454214320248496e+1, 9.933061245478742692933e+1, 1.029681986145138126988e+2, 1.066317602606434591262e+2, 1.103206397147573954291e+2,
18850+ 1.140342117814617032329e+2, 1.177718813997450715388e+2, 1.215330815154386339623e+2, 1.253172711493568951252e+2, 1.291239336391272148826e+2, 1.329525750356163098828e+2, 1.368027226373263684696e+2, 1.406739236482342593987e+2,
18851+ 1.445657439463448860089e+2, 1.484777669517730320675e+2, 1.524095925844973578392e+2, 1.563608363030787851941e+2, 1.603311282166309070282e+2, 1.643201122631951814118e+2, 1.683274454484276523305e+2, 1.723527971391628015638e+2,
18852+ 1.763958484069973517152e+2, 1.804562914175437710518e+2, 1.845338288614494905025e+2, 1.886281734236715911873e+2, 1.927390472878449024360e+2, 1.968661816728899939914e+2, 2.010093163992815266793e+2, 2.051681994826411985358e+2,
18853+ 2.093425867525368356464e+2, 2.135322414945632611913e+2, 2.177369341139542272510e+2, 2.219564418191303339501e+2, 2.261905483237275933323e+2, 2.304390435657769523214e+2, 2.347017234428182677427e+2, 2.389783895618343230538e+2,
18854+ 2.432688490029827141829e+2, 2.475729140961868839366e+2, 2.518904022097231943772e+2, 2.562211355500095254561e+2, 2.605649409718632093053e+2, 2.649216497985528010421e+2, 2.692910976510198225363e+2, 2.736731242856937041486e+2,
18855+ 2.780675734403661429141e+2, 2.824742926876303960274e+2, 2.868931332954269939509e+2, 2.913239500942703075662e+2, 2.957666013507606240211e+2, 3.002209486470141317540e+2, 3.046868567656687154726e+2, 3.091641935801469219449e+2,
18856+ 3.136528299498790617832e+2, 3.181526396202093268500e+2, 3.226634991267261768912e+2, 3.271852877037752172008e+2, 3.317178871969284731381e+2, 3.362611819791984770344e+2, 3.408150588707990178690e+2, 3.453794070622668541074e+2,
18857+ 3.499541180407702369296e+2, 3.545390855194408088492e+2, 3.591342053695753987760e+2, 3.637393755555634901441e+2, 3.683544960724047495950e+2, 3.729794688856890206760e+2, 3.776141978739186564468e+2, 3.822585887730600291111e+2,
18858+ 3.869125491232175524822e+2, 3.915759882173296196258e+2, 3.962488170517915257991e+2, 4.009309482789157454921e+2, 4.056222961611448891925e+2, 4.103227765269373054205e+2, 4.150323067282496395563e+2, 4.197508055995447340991e+2,
18859+ 4.244781934182570746677e+2, 4.292143918666515701285e+2, 4.339593239950148201939e+2, 4.387129141861211848399e+2, 4.434750881209189409588e+2, 4.482457727453846057188e+2, 4.530248962384961351041e+2, 4.578123879812781810984e+2,
18860+ 4.626081785268749221865e+2, 4.674121995716081787447e+2, 4.722243839269805962399e+2, 4.770446654925856331047e+2, 4.818729792298879342285e+2, 4.867092611368394122258e+2, 4.915534482232980034989e+2, 4.964054784872176206648e+2,
18861+ 5.012652908915792927797e+2, 5.061328253420348751997e+2, 5.110080226652360267439e+2, 5.158908245878223975982e+2, 5.207811737160441513633e+2, 5.256790135159950627324e+2, 5.305842882944334921812e+2, 5.354969431801695441897e+2,
18862+ 5.404169241059976691050e+2, 5.453441777911548737966e+2, 5.502786517242855655538e+2, 5.552202941468948698523e+2, 5.601690540372730381305e+2, 5.651248810948742988613e+2, 5.700877257251342061414e+2, 5.750575390247102067619e+2,
18863+ 5.800342727671307811636e+2, 5.850178793888391176022e+2, 5.900083119756178539038e+2, 5.950055242493819689670e+2, 6.000094705553274281080e+2, 6.050201058494236838580e+2, 6.100373856862386081868e+2, 6.150612662070848845750e+2,
18864+ 6.200917041284773200381e+2, 6.251286567308909491967e+2, 6.301720818478101958172e+2, 6.352219378550597328635e+2, 6.402781836604080409209e+2, 6.453407786934350077245e+2, 6.504096828956552392500e+2, 6.554848567108890661717e+2,
18865+ 6.605662610758735291676e+2, 6.656538574111059132426e+2, 6.707476076119126755767e+2, 6.758474740397368739994e+2, 6.809534195136374546094e+2, 6.860654073019939978423e+2, 6.911834011144107529496e+2, 6.963073650938140118743e+2,
18866+ 7.014372638087370853465e+2, 7.065730622457873471107e+2, 7.117147258022900069535e+2}));
18867+}
18868+ _const_math__gamma_p = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){1.60119522476751861407e-04, 1.19135147006586384913e-03, 1.04213797561761569935e-02, 4.76367800457137231464e-02, 2.07448227648435975150e-01, 4.94214826801497100753e-01, 9.99999999999999996796e-01}));
18869+ _const_math__gamma_q = builtin__new_array_from_c_array(8, 8, sizeof(f64), _MOV((f64[8]){-2.31581873324120129819e-05, 5.39605580493303397842e-04, -4.45641913851797240494e-03, 1.18139785222060435552e-02, 3.58236398605498653373e-02, -2.34591795718243348568e-01, 7.14304917030273074085e-02, 1.00000000000000000320e+00}));
18870+ _const_math__gamma_s = builtin__new_array_from_c_array(5, 5, sizeof(f64), _MOV((f64[5]){7.87311395793093628397e-04, -2.29549961613378126380e-04, -2.68132617805781232825e-03, 3.47222221605458667310e-03, 8.33333333333482257126e-02}));
18871+{
18872+ _const_math__lgamma_a = builtin__new_array_from_c_array(12, 12, sizeof(f64), _MOV((f64[12]){
18873+ 7.72156649015328655494e-02, 3.22467033424113591611e-01, 6.73523010531292681824e-02, 2.05808084325167332806e-02, 7.38555086081402883957e-03, 2.89051383673415629091e-03, 1.19270763183362067845e-03, 5.10069792153511336608e-04, 2.20862790713908385557e-04,
18874+ 1.08011567247583939954e-04, 2.52144565451257326939e-05, 4.48640949618915160150e-05}));
18875+}
18876+ _const_math__lgamma_r = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){1.0, 1.39200533467621045958e+00, 7.21935547567138069525e-01, 1.71933865632803078993e-01, 1.86459191715652901344e-02, 7.77942496381893596434e-04, 7.32668430744625636189e-06}));
18877+ _const_math__lgamma_s = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){-7.72156649015328655494e-02, 2.14982415960608852501e-01, 3.25778796408930981787e-01, 1.46350472652464452805e-01, 2.66422703033638609560e-02, 1.84028451407337715652e-03, 3.19475326584100867617e-05}));
18878+{
18879+ _const_math__lgamma_t = builtin__new_array_from_c_array(15, 15, sizeof(f64), _MOV((f64[15]){
18880+ 4.83836122723810047042e-01, -1.47587722994593911752e-01, 6.46249402391333854778e-02, -3.27885410759859649565e-02, 1.79706750811820387126e-02, -1.03142241298341437450e-02, 6.10053870246291332635e-03, -3.68452016781138256760e-03, 2.25964780900612472250e-03,
18881+ -1.40346469989232843813e-03, 8.81081882437654011382e-04, -5.38595305356740546715e-04, 3.15632070903625950361e-04, -3.12754168375120860518e-04, 3.35529192635519073543e-04}));
18882+}
18883+ _const_math__lgamma_u = builtin__new_array_from_c_array(6, 6, sizeof(f64), _MOV((f64[6]){-7.72156649015328655494e-02, 6.32827064025093366517e-01, 1.45492250137234768737e+00, 9.77717527963372745603e-01, 2.28963728064692451092e-01, 1.33810918536787660377e-02}));
18884+ _const_math__lgamma_v = builtin__new_array_from_c_array(6, 6, sizeof(f64), _MOV((f64[6]){1.0, 2.45597793713041134822e+00, 2.12848976379893395361e+00, 7.69285150456672783825e-01, 1.04222645593369134254e-01, 3.21709242282423911810e-03}));
18885+ _const_math__lgamma_w = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){4.18938533204672725052e-01, 8.33333333333329678849e-02, -2.77777777728775536470e-03, 7.93650558643019558500e-04, -5.95187557450339963135e-04, 8.36339918996282139126e-04, -1.63092934096575273989e-03}));
18886+{
18887+ _const_math__pow10tab = builtin__new_array_from_c_array(32, 32, sizeof(f64), _MOV((f64[32]){
18888+ ((f64)(1e+00)), 1e+01, 1e+02, 1e+03, 1e+04, 1e+05, 1e+06, 1e+07, 1e+08,
18889+ 1e+09, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16,
18890+ 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24,
18891+ 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31}));
18892+}
18893+{
18894+ _const_math__pow10postab32 = builtin__new_array_from_c_array(10, 10, sizeof(f64), _MOV((f64[10]){
18895+ ((f64)(1e+00)), 1e+32, 1e+64, 1e+96, 1e+128, 1e+160, 1e+192, 1e+224, 1e+256,
18896+ 1e+288}));
18897+}
18898+{
18899+ _const_math__pow10negtab32 = builtin__new_array_from_c_array(11, 11, sizeof(f64), _MOV((f64[11]){
18900+ ((f64)(1e-00)), 1e-32, 1e-64, 1e-96, 1e-128, 1e-160, 1e-192, 1e-224, 1e-256,
18901+ 1e-288, 1e-320}));
18902+}
18903+{
18904+ _const_math__sin_data = builtin__new_array_from_c_array(12, 12, sizeof(f64), _MOV((f64[12]){
18905+ -0.3295190160663511504173, 0.0025374284671667991990, 0.0006261928782647355874, -4.6495547521854042157541e-06, -5.6917531549379706526677e-07, 3.7283335140973803627866e-09, 3.0267376484747473727186e-10, -1.7400875016436622322022e-12, -1.0554678305790849834462e-13,
18906+ 5.3701981409132410797062e-16, 2.5984137983099020336115e-17, -1.1821555255364833468288e-19}));
18907+}
18908+{
18909+ _const_math__cos_data = builtin__new_array_from_c_array(11, 11, sizeof(f64), _MOV((f64[11]){
18910+ 0.165391825637921473505668118136, -0.00084852883845000173671196530195, -0.000210086507222940730213625768083, 1.16582269619760204299639757584e-6, 1.43319375856259870334412701165e-7, -7.4770883429007141617951330184e-10, -6.0969994944584252706997438007e-11, 2.90748249201909353949854872638e-13, 1.77126739876261435667156490461e-14,
18911+ -7.6896421502815579078577263149e-17, -3.7363121133079412079201377318e-18}));
18912+}
18913+ _const_math__tan_p = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){-1.30936939181383777646e+4, 1.15351664838587416140e+6, -1.79565251976484877988e+7}));
18914+ _const_math__tan_q = builtin__new_array_from_c_array(5, 5, sizeof(f64), _MOV((f64[5]){1.00000000000000000000e+0, 1.36812963470692954678e+4, -1.32089234440210967447e+6, 2.50083801823357915839e+7, -5.38695755929454629881e+7}));
18915+ _const_math__tanh_p = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){-9.64399179425052238628e-1, -9.92877231001918586564e+1, -1.61468768441708447952e+3}));
18916+ _const_math__tanh_q = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){1.12811678491632931402e+2, 2.23548839060100448583e+3, 4.84406305325125486048e+3}));
18917+{
18918+{
18919+ _const_math__sin_cs = ((math__ChebSeries){.c = _const_math__sin_data,.order = 11,.a = -1,.b = 1,});
18920+}
18921+}
18922+{
18923+{
18924+ _const_math__cos_cs = ((math__ChebSeries){.c = _const_math__cos_data,.order = 10,.a = -1,.b = 1,});
18925+}
18926+}
16564 }18927 }
16565 void _vcleanup(void) {18928 void _vcleanup(void) {
16566 static bool once = false; if (once) {return;} once = true;18929 static bool once = false; if (once) {return;} once = true;
modified ios/Classes/vflutter.h +10 -0
@@ -24,6 +24,16 @@ VF_API char *vf_greet(const char *name);
2424
2525 VF_API void vf_free(void *p);
2626
27+// Fills rows [y0, y1) of a w x h Mandelbrot image as RGBA8888, packed from
28+// the start of `buf`. The buffer is owned by the CALLER: V allocates nothing
29+// here and there is nothing to vf_free. Bands are independent, so separate
30+// calls may run concurrently on different threads/isolates.
31+//
32+// `buf` must hold at least (y1 - y0) * w * 4 bytes.
33+VF_API void vf_mandelbrot(unsigned char *buf, int w, int h, double cx,
34+ double cy, double scale, int max_iter, int y0,
35+ int y1);
36+
2737 #ifdef __cplusplus
2838 }
2939 #endif
@@ -24,6 +24,16 @@ VF_API char *vf_greet(const char *name);
24 24
25 VF_API void vf_free(void *p);25 VF_API void vf_free(void *p);
26 26
27+// Fills rows [y0, y1) of a w x h Mandelbrot image as RGBA8888, packed from
28+// the start of `buf`. The buffer is owned by the CALLER: V allocates nothing
29+// here and there is nothing to vf_free. Bands are independent, so separate
30+// calls may run concurrently on different threads/isolates.
31+//
32+// `buf` must hold at least (y1 - y0) * w * 4 bytes.
33+VF_API void vf_mandelbrot(unsigned char *buf, int w, int h, double cx,
34+ double cy, double scale, int max_iter, int y0,
35+ int y1);
36+
27 #ifdef __cplusplus37 #ifdef __cplusplus
28 }38 }
29 #endif39 #endif
modified lib/vflutter_ffi.dart +130 -0
@@ -8,6 +8,7 @@ library vflutter_ffi;
88 import 'dart:ffi';
99 import 'dart:io';
1010 import 'dart:isolate';
11+import 'dart:typed_data';
1112 import 'package:ffi/ffi.dart';
1213
1314 const String _libName = 'vflutter';
@@ -86,3 +87,132 @@ String greet(String name) {
8687 /// enough to jank a frame.
8788 Future<String> greetAsync(String name) =>
8889 Isolate.run(() => greet(name));
90+
91+// ---------------------------------------------------------------------------
92+// Mandelbrot
93+// ---------------------------------------------------------------------------
94+
95+final void Function(Pointer<Uint8>, int, int, double, double, double, int, int,
96+ int) _vfMandelbrot = _lib.lookupFunction<
97+ Void Function(Pointer<Uint8>, Int32, Int32, Double, Double, Double,
98+ Int32, Int32, Int32),
99+ void Function(Pointer<Uint8>, int, int, double, double, double, int,
100+ int, int)>('vf_mandelbrot');
101+
102+/// Where to look in the complex plane, and how hard to look.
103+class FractalView {
104+ const FractalView({
105+ required this.width,
106+ required this.height,
107+ this.centerX = -0.5,
108+ this.centerY = 0.0,
109+ this.scale = 3.0,
110+ this.maxIter = 500,
111+ });
112+
113+ final int width;
114+ final int height;
115+
116+ /// Centre of the viewport in the complex plane.
117+ final double centerX;
118+ final double centerY;
119+
120+ /// Width of the viewport in the complex plane. Smaller = deeper zoom.
121+ final double scale;
122+
123+ /// Escape-time iteration cap. The cost of a frame scales with this.
124+ final int maxIter;
125+
126+ /// Returns this view zoomed by [factor] about a point given in *fractional*
127+ /// viewport coordinates — (0,0) top-left, (1,1) bottom-right.
128+ ///
129+ /// The point under the cursor stays under the cursor: that is the whole
130+ /// contract, and it is what makes click-to-zoom feel anchored rather than
131+ /// drifting. `factor < 1` zooms in.
132+ FractalView zoomedAt(double fx, double fy, double factor) {
133+ final aspect = width / height;
134+ final ox = fx - 0.5;
135+ final oy = fy - 0.5;
136+
137+ // The complex-plane point currently under (fx, fy).
138+ final targetX = centerX + ox * scale * aspect;
139+ final targetY = centerY + oy * scale;
140+
141+ final newScale = scale * factor;
142+ return copyWith(
143+ scale: newScale,
144+ centerX: targetX - ox * newScale * aspect,
145+ centerY: targetY - oy * newScale,
146+ );
147+ }
148+
149+ FractalView copyWith({
150+ int? width,
151+ int? height,
152+ double? centerX,
153+ double? centerY,
154+ double? scale,
155+ int? maxIter,
156+ }) =>
157+ FractalView(
158+ width: width ?? this.width,
159+ height: height ?? this.height,
160+ centerX: centerX ?? this.centerX,
161+ centerY: centerY ?? this.centerY,
162+ scale: scale ?? this.scale,
163+ maxIter: maxIter ?? this.maxIter,
164+ );
165+}
166+
167+/// Renders rows [y0, y1) of [view] into a fresh RGBA byte buffer.
168+///
169+/// The buffer is allocated on the Dart side and filled in place by V, so no V
170+/// memory is created and nothing needs freeing on the V side. The native
171+/// allocation is released before returning; callers get a plain [Uint8List].
172+Uint8List renderBand(FractalView view, int y0, int y1) {
173+ ensureInitialized();
174+ final rows = y1 - y0;
175+ if (rows <= 0) return Uint8List(0);
176+
177+ final bytes = rows * view.width * 4;
178+ final buf = calloc<Uint8>(bytes);
179+ try {
180+ _vfMandelbrot(buf, view.width, view.height, view.centerX, view.centerY,
181+ view.scale, view.maxIter, y0, y1);
182+ // Copy out of native memory before it is freed.
183+ return Uint8List.fromList(buf.asTypedList(bytes));
184+ } finally {
185+ calloc.free(buf);
186+ }
187+}
188+
189+/// Renders the whole of [view] on the calling isolate.
190+Uint8List render(FractalView view) => renderBand(view, 0, view.height);
191+
192+/// Renders [view] as [tiles] horizontal bands computed in parallel.
193+///
194+/// Bands are independent by construction — each call writes only its own rows
195+/// — so this is real parallelism across isolates, not interleaving. `-gc none`
196+/// means there is no stop-the-world phase to serialise them.
197+Future<Uint8List> renderParallel(FractalView view, {int tiles = 4}) async {
198+ ensureInitialized();
199+ final count = tiles.clamp(1, view.height);
200+ final rowsPer = (view.height / count).ceil();
201+
202+ final futures = <Future<Uint8List>>[];
203+ for (var t = 0; t < count; t++) {
204+ final y0 = t * rowsPer;
205+ final y1 = ((t + 1) * rowsPer).clamp(0, view.height);
206+ if (y0 >= y1) break;
207+ futures.add(Isolate.run(() => renderBand(view, y0, y1)));
208+ }
209+
210+ final bands = await Future.wait(futures);
211+ final out = Uint8List(view.width * view.height * 4);
212+ var offset = 0;
213+ for (final band in bands) {
214+ out.setRange(offset, offset + band.length, band);
215+ offset += band.length;
216+ }
217+ return out;
218+}
@@ -8,6 +8,7 @@ library vflutter_ffi;
8 import 'dart:ffi';8 import 'dart:ffi';
9 import 'dart:io';9 import 'dart:io';
10 import 'dart:isolate';10 import 'dart:isolate';
11+import 'dart:typed_data';
11 import 'package:ffi/ffi.dart';12 import 'package:ffi/ffi.dart';
12 13
13 const String _libName = 'vflutter';14 const String _libName = 'vflutter';
@@ -86,3 +87,132 @@ String greet(String name) {
86 /// enough to jank a frame.87 /// enough to jank a frame.
87 Future<String> greetAsync(String name) =>88 Future<String> greetAsync(String name) =>
88 Isolate.run(() => greet(name));89 Isolate.run(() => greet(name));
90+
91+// ---------------------------------------------------------------------------
92+// Mandelbrot
93+// ---------------------------------------------------------------------------
94+
95+final void Function(Pointer<Uint8>, int, int, double, double, double, int, int,
96+ int) _vfMandelbrot = _lib.lookupFunction<
97+ Void Function(Pointer<Uint8>, Int32, Int32, Double, Double, Double,
98+ Int32, Int32, Int32),
99+ void Function(Pointer<Uint8>, int, int, double, double, double, int,
100+ int, int)>('vf_mandelbrot');
101+
102+/// Where to look in the complex plane, and how hard to look.
103+class FractalView {
104+ const FractalView({
105+ required this.width,
106+ required this.height,
107+ this.centerX = -0.5,
108+ this.centerY = 0.0,
109+ this.scale = 3.0,
110+ this.maxIter = 500,
111+ });
112+
113+ final int width;
114+ final int height;
115+
116+ /// Centre of the viewport in the complex plane.
117+ final double centerX;
118+ final double centerY;
119+
120+ /// Width of the viewport in the complex plane. Smaller = deeper zoom.
121+ final double scale;
122+
123+ /// Escape-time iteration cap. The cost of a frame scales with this.
124+ final int maxIter;
125+
126+ /// Returns this view zoomed by [factor] about a point given in *fractional*
127+ /// viewport coordinates — (0,0) top-left, (1,1) bottom-right.
128+ ///
129+ /// The point under the cursor stays under the cursor: that is the whole
130+ /// contract, and it is what makes click-to-zoom feel anchored rather than
131+ /// drifting. `factor < 1` zooms in.
132+ FractalView zoomedAt(double fx, double fy, double factor) {
133+ final aspect = width / height;
134+ final ox = fx - 0.5;
135+ final oy = fy - 0.5;
136+
137+ // The complex-plane point currently under (fx, fy).
138+ final targetX = centerX + ox * scale * aspect;
139+ final targetY = centerY + oy * scale;
140+
141+ final newScale = scale * factor;
142+ return copyWith(
143+ scale: newScale,
144+ centerX: targetX - ox * newScale * aspect,
145+ centerY: targetY - oy * newScale,
146+ );
147+ }
148+
149+ FractalView copyWith({
150+ int? width,
151+ int? height,
152+ double? centerX,
153+ double? centerY,
154+ double? scale,
155+ int? maxIter,
156+ }) =>
157+ FractalView(
158+ width: width ?? this.width,
159+ height: height ?? this.height,
160+ centerX: centerX ?? this.centerX,
161+ centerY: centerY ?? this.centerY,
162+ scale: scale ?? this.scale,
163+ maxIter: maxIter ?? this.maxIter,
164+ );
165+}
166+
167+/// Renders rows [y0, y1) of [view] into a fresh RGBA byte buffer.
168+///
169+/// The buffer is allocated on the Dart side and filled in place by V, so no V
170+/// memory is created and nothing needs freeing on the V side. The native
171+/// allocation is released before returning; callers get a plain [Uint8List].
172+Uint8List renderBand(FractalView view, int y0, int y1) {
173+ ensureInitialized();
174+ final rows = y1 - y0;
175+ if (rows <= 0) return Uint8List(0);
176+
177+ final bytes = rows * view.width * 4;
178+ final buf = calloc<Uint8>(bytes);
179+ try {
180+ _vfMandelbrot(buf, view.width, view.height, view.centerX, view.centerY,
181+ view.scale, view.maxIter, y0, y1);
182+ // Copy out of native memory before it is freed.
183+ return Uint8List.fromList(buf.asTypedList(bytes));
184+ } finally {
185+ calloc.free(buf);
186+ }
187+}
188+
189+/// Renders the whole of [view] on the calling isolate.
190+Uint8List render(FractalView view) => renderBand(view, 0, view.height);
191+
192+/// Renders [view] as [tiles] horizontal bands computed in parallel.
193+///
194+/// Bands are independent by construction — each call writes only its own rows
195+/// — so this is real parallelism across isolates, not interleaving. `-gc none`
196+/// means there is no stop-the-world phase to serialise them.
197+Future<Uint8List> renderParallel(FractalView view, {int tiles = 4}) async {
198+ ensureInitialized();
199+ final count = tiles.clamp(1, view.height);
200+ final rowsPer = (view.height / count).ceil();
201+
202+ final futures = <Future<Uint8List>>[];
203+ for (var t = 0; t < count; t++) {
204+ final y0 = t * rowsPer;
205+ final y1 = ((t + 1) * rowsPer).clamp(0, view.height);
206+ if (y0 >= y1) break;
207+ futures.add(Isolate.run(() => renderBand(view, y0, y1)));
208+ }
209+
210+ final bands = await Future.wait(futures);
211+ final out = Uint8List(view.width * view.height * 4);
212+ var offset = 0;
213+ for (final band in bands) {
214+ out.setRange(offset, offset + band.length, band);
215+ offset += band.length;
216+ }
217+ return out;
218+}
modified macos/Classes/vflutter.gen.c +2692 -329
@@ -7,8 +7,9 @@
77
88 // V comptime_definitions:
99 // V compile time defines by -d or -define flags:
10-// All custom defines : linux
11-// Turned ON custom defines: linux
10+// All custom defines : no_backtrace,linux
11+// Turned ON custom defines: no_backtrace,linux
12+#define CUSTOM_DEFINE_no_backtrace
1213 #define CUSTOM_DEFINE_linux
1314
1415
@@ -20,6 +21,7 @@ typedef struct none none;
2021 typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11;
2122 typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11;
2223 typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128;
24+typedef struct _v_Array_fixed_f64_4 _v_Array_fixed_f64_4;
2325 typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32;
2426 typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64;
2527 typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5;
@@ -40,8 +42,6 @@ typedef struct _v_Array_fixed_u64_47 _v_Array_fixed_u64_47;
4042 typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31;
4143 typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64;
4244 typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64;
43-typedef struct _v_Array_fixed_voidptr_100 _v_Array_fixed_voidptr_100;
44-typedef struct _v_Array_fixed_u8_1000 _v_Array_fixed_u8_1000;
4545 typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17;
4646 typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264;
4747 typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10;
@@ -60,8 +60,10 @@ typedef struct multi_return_u64_int multi_return_u64_int;
6060 typedef struct multi_return_i64_int multi_return_i64_int;
6161 typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool;
6262 typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool;
63-typedef struct multi_return_u64_u64 multi_return_u64_u64;
6463 typedef struct multi_return_f64_int multi_return_f64_int;
64+typedef struct multi_return_i64_i64_i64 multi_return_i64_i64_i64;
65+typedef struct multi_return_f64_f64 multi_return_f64_f64;
66+typedef struct multi_return_u64_u64 multi_return_u64_u64;
6567 // END_multi_return_typedefs
6668
6769 typedef struct strings__IndentParam strings__IndentParam;
@@ -106,6 +108,12 @@ typedef struct RunesIterator RunesIterator;
106108 typedef union StrIntpMem StrIntpMem;
107109 typedef struct StrIntpData StrIntpData;
108110 typedef struct ToWideConfig ToWideConfig;
111+typedef struct math__BezierPoint math__BezierPoint;
112+typedef struct math__DigitParams math__DigitParams;
113+typedef struct math__DivResult math__DivResult;
114+typedef struct math__ChebSeries math__ChebSeries;
115+typedef union math__U32_F32 math__U32_F32;
116+typedef union math__U64_F64 math__U64_F64;
109117 typedef struct _result_int _result_int;
110118 typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr;
111119 typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken;
@@ -124,9 +132,9 @@ typedef struct _result_rune _result_rune;
124132 typedef struct _result_string _result_string;
125133 typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo;
126134 typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr;
127-typedef struct _option_int _option_int;
128135 typedef struct _option_rune _option_rune;
129136 typedef struct _option_multi_return_string_string _option_multi_return_string_string;
137+typedef struct _option_int _option_int;
130138 typedef struct _option_u8 _option_u8;
131139
132140 // V preincludes:
@@ -1479,6 +1487,23 @@ V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) {
14791487 #endif
14801488 #endif
14811489
1490+
1491+// added by module `math`, file: math.c.v:6:
1492+
1493+#ifdef __TINYC__
1494+#include <math.h>
1495+#else
1496+#if defined(__has_include)
1497+#if __has_include(<math.h>)
1498+#include <math.h>
1499+#else
1500+#error VERROR_MESSAGE Header file <math.h>, needed for module `math` was not found. Please install the corresponding development headers.
1501+#endif
1502+#else
1503+#include <math.h>
1504+#endif
1505+#endif
1506+
14821507 #if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool)
14831508 #ifdef bool
14841509 #undef bool
@@ -1516,9 +1541,20 @@ typedef u8 bool;
15161541 #define _const_rune_maps_utl -2
15171542 #define _const_degree 6
15181543 #define _const_mid_index 5
1519-#define _const_max_len 11
15201544 #define _const_replace_stack_buffer_size 10
15211545 #define _const_kmp_stack_buffer_size 20
1546+#define _const_math__internal__max_int_fact_arg 170
1547+#define _const_math__shift 52
1548+#define _const_math__bias 1023
1549+#define _const_math__pi_2 1.5707963267948966
1550+#define _const_math__pi_4 0.7853981633974483
1551+#define _const_math__one_over_tau 0.15915494309189535
1552+#define _const_math__one_over_pi 0.3183098861837907
1553+#define _const_math__tau_over2 3.141592653589793
1554+#define _const_math__tau_over4 1.5707963267948966
1555+#define _const_math__tau_over8 0.7853981633974483
1556+#define _const_math__log2_e 1.4426950408889634
1557+#define _const_math__log10_e 0.43429448190325176
15221558
15231559 // Enum definitions:
15241560
@@ -1722,6 +1758,9 @@ typedef array Array_builtin__closure__ClosureLifetimeFrame;
17221758 typedef map Map_voidptr_builtin__closure__ClosureLiveInfo;
17231759 typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr;
17241760 typedef u8 Array_fixed_u8_128 [128];
1761+typedef array Array_f64;
1762+typedef array Array_math__BezierPoint;
1763+typedef f64 Array_fixed_f64_4 [4];
17251764 typedef u8 Array_fixed_u8_32 [32];
17261765 typedef u8 Array_fixed_u8_64 [64];
17271766 typedef u8 Array_fixed_u8_5 [5];
@@ -1742,8 +1781,6 @@ typedef u64 Array_fixed_u64_47 [47];
17421781 typedef u64 Array_fixed_u64_31 [31];
17431782 typedef int Array_fixed_int_64 [64];
17441783 typedef voidptr Array_fixed_voidptr_64 [64];
1745-typedef voidptr Array_fixed_voidptr_100 [100];
1746-typedef u8 Array_fixed_u8_1000 [1000];
17471784 typedef array Array_GraphemeBreakProperty;
17481785 typedef u8 Array_fixed_u8_17 [17];
17491786 typedef i32 Array_fixed_i32_1264 [1264];
@@ -1964,6 +2001,33 @@ struct builtin__closure__FrameToken {
19642001 u64 generation;
19652002 };
19662003
2004+struct math__BezierPoint {
2005+ f64 x;
2006+ f64 y;
2007+};
2008+
2009+struct math__DigitParams {
2010+ int base;
2011+ bool reverse;
2012+};
2013+
2014+struct math__ChebSeries {
2015+ Array_f64 c;
2016+ int order;
2017+ f64 a;
2018+ f64 b;
2019+};
2020+
2021+union math__U32_F32 {
2022+ u32 u;
2023+ f32 f;
2024+};
2025+
2026+union math__U64_F64 {
2027+ u64 u;
2028+ f64 f;
2029+};
2030+
19672031 struct mapnode {
19682032 voidptr* children;
19692033 int len;
@@ -2011,6 +2075,9 @@ struct _v_Array_fixed_voidptr_11 {
20112075 struct _v_Array_fixed_u8_128 {
20122076 u8 ret_arr[128];
20132077 };
2078+struct _v_Array_fixed_f64_4 {
2079+ f64 ret_arr[4];
2080+};
20142081 struct _v_Array_fixed_u8_32 {
20152082 u8 ret_arr[32];
20162083 };
@@ -2071,12 +2138,6 @@ struct _v_Array_fixed_int_64 {
20712138 struct _v_Array_fixed_voidptr_64 {
20722139 voidptr ret_arr[64];
20732140 };
2074-struct _v_Array_fixed_voidptr_100 {
2075- voidptr ret_arr[100];
2076-};
2077-struct _v_Array_fixed_u8_1000 {
2078- u8 ret_arr[1000];
2079-};
20802141 struct _v_Array_fixed_u8_17 {
20812142 u8 ret_arr[17];
20822143 };
@@ -2144,16 +2205,27 @@ struct multi_return_strconv__Dec64_bool {
21442205 bool arg1;
21452206 };
21462207
2147-struct multi_return_u64_u64 {
2148- u64 arg0;
2149- u64 arg1;
2150-};
2151-
21522208 struct multi_return_f64_int {
21532209 f64 arg0;
21542210 int arg1;
21552211 };
21562212
2213+struct multi_return_i64_i64_i64 {
2214+ i64 arg0;
2215+ i64 arg1;
2216+ i64 arg2;
2217+};
2218+
2219+struct multi_return_f64_f64 {
2220+ f64 arg0;
2221+ f64 arg1;
2222+};
2223+
2224+struct multi_return_u64_u64 {
2225+ u64 arg0;
2226+ u64 arg1;
2227+};
2228+
21572229 // END_multi_return_structs
21582230
21592231 static bool Array_u8_contains(Array_u8 a, u8 v);
@@ -2171,12 +2243,6 @@ struct _option_builtin__closure__ClosureLifetimeState_ptr {
21712243 byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1];
21722244 };
21732245
2174-struct _option_int {
2175- byte state;
2176- IError err;
2177- byte data[sizeof(int) > 1 ? sizeof(int) : 1];
2178-};
2179-
21802246 struct _option_rune {
21812247 byte state;
21822248 IError err;
@@ -2189,6 +2255,12 @@ struct _option_multi_return_string_string {
21892255 byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1];
21902256 };
21912257
2258+struct _option_int {
2259+ byte state;
2260+ IError err;
2261+ byte data[sizeof(int) > 1 ? sizeof(int) : 1];
2262+};
2263+
21922264 struct _option_u8 {
21932265 byte state;
21942266 IError err;
@@ -2660,15 +2732,7 @@ VV_LOC void builtin__autostr_addr_push(voidptr addr);
26602732 VV_LOC void builtin__autostr_addr_pop(void);
26612733 VV_LOC string builtin__autostr_array_circular(int len);
26622734 void builtin__print_backtrace(void);
2663-VV_LOC string builtin__demangle_v_symbol(string cname);
2664-VV_LOC Array_string builtin__split_generic_params(string s);
2665-VV_LOC string builtin__demangle_backtrace_sym(string s);
2666-VV_LOC void builtin__eprint_space_padding(string output, int max_len);
26672735 bool builtin__print_backtrace_skipping_top_frames(int xskipframes);
2668-VV_LOC string builtin__backtrace_current_executable_name(void);
2669-VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name);
2670-VV_LOC string builtin__backtrace_shell_quote(string s);
2671-VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes);
26722736 void builtin___v_exit(int code);
26732737 _result_void builtin__at_exit(void (*cb)());
26742738 VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number);
@@ -3113,6 +3177,134 @@ void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_);
31133177 void builtin__ArrayFlags_clear_all(ArrayFlags* e);
31143178 void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_);
31153179 ArrayFlags builtin__ArrayFlags__static__zero(void);
3180+f64 math__inf(int sign);
3181+f64 math__nan(void);
3182+bool math__is_nan(f64 f);
3183+bool math__is_inf(f64 f, int sign);
3184+bool math__is_finite(f64 f);
3185+multi_return_f64_int math__normalize(f64 x);
3186+f64 math__cbrt(f64 a);
3187+f64 math__mod(f64 x, f64 y);
3188+f64 math__fmod(f64 x, f64 y);
3189+i64 math__gcd(i64 a_, i64 b_);
3190+multi_return_i64_i64_i64 math__egcd(i64 a, i64 b);
3191+i64 math__lcm(i64 a, i64 b);
3192+f64 math__erf(f64 a);
3193+f64 math__erfc(f64 a);
3194+f64 math__exp(f64 x);
3195+f64 math__exp2(f64 x);
3196+f64 math__ldexp(f64 frac, int exp);
3197+f64 math__pure_v_but_overridden_by_c_exp(f64 x);
3198+f64 math__pure_v_but_overridden_by_c_exp2(f64 x);
3199+f64 math__pure_v_but_overridden_by_c_ldexp(f64 frac, int exp);
3200+multi_return_f64_int math__frexp(f64 x);
3201+f64 math__expm1(f64 x);
3202+VV_LOC f64 math__expmulti(f64 hi, f64 lo, int k);
3203+f64 math__factorial(f64 n);
3204+f64 math__log_factorial(f64 n);
3205+VV_LOC f64 math__log_factorial_asymptotic_expansion(int n);
3206+i64 math__factoriali(int n);
3207+f64 math__floor(f64 x);
3208+f32 math__floorf(f32 x);
3209+f64 math__ceil(f64 x);
3210+f64 math__trunc(f64 x);
3211+f64 math__round(f64 x);
3212+f64 math__round_sig(f64 x, int sig_digits);
3213+f64 math__round_to_even(f64 x);
3214+VV_LOC u64 math__safe_shift(u64 value, u64 shift);
3215+VV_LOC bool math__is_neg_int(f64 x);
3216+VV_LOC multi_return_f64_f64 math__stirling(f64 x);
3217+f64 math__gamma(f64 a);
3218+VV_LOC f64 math__gamma_too_small(f64 x, f64 z);
3219+f64 math__log_gamma(f64 x);
3220+multi_return_f64_int math__log_gamma_sign(f64 a);
3221+VV_LOC f64 math__sin_pi(f64 x_);
3222+f64 math__hypot(f64 x, f64 y);
3223+math__BezierPoint math__cubic_bezier(f64 t, Array_math__BezierPoint p);
3224+math__BezierPoint math__cubic_bezier_a(f64 t, Array_f64 x, Array_f64 y);
3225+math__BezierPoint math__cubic_bezier_fa(f64 t, Array_fixed_f64_4 x, Array_fixed_f64_4 y);
3226+math__BezierPoint math__cubic_bezier_coords(f64 t, f64 x0, f64 x1, f64 x2, f64 x3, f64 y0, f64 y1, f64 y2, f64 y3);
3227+f64 math__acosh(f64 x);
3228+f64 math__asinh(f64 x);
3229+f64 math__atanh(f64 x);
3230+VV_LOC f64 math__xatan(f64 x);
3231+VV_LOC f64 math__satan(f64 x);
3232+f64 math__atan(f64 x);
3233+f64 math__atan2(f64 y, f64 x);
3234+f64 math__asin(f64 x_);
3235+f64 math__acos(f64 x);
3236+f64 math__log(f64 x);
3237+f64 math__log2(f64 x);
3238+f64 math__log10(f64 x);
3239+f64 math__log1p(f64 x);
3240+f64 math__log_b(f64 x);
3241+f32 math__logf(f32 x);
3242+f64 math__log_n(f64 x, f64 b);
3243+f64 math__pure_v_but_overridden_by_c_log10(f64 x);
3244+f64 math__pure_v_but_overridden_by_c_log2(f64 x);
3245+f64 math__pure_v_but_overridden_by_c_log1p(f64 x);
3246+f64 math__pure_v_but_overridden_by_c_log_b(f64 x);
3247+int math__ilog_b(f64 x);
3248+VV_LOC int math__ilog_b_(f64 x_);
3249+f64 math__pure_v_but_overridden_by_c_log(f64 a);
3250+f64 math__aprox_sin(f64 a);
3251+f64 math__aprox_cos(f64 a);
3252+f64 math__copysign(f64 x, f64 y);
3253+f64 math__degrees(f64 radians);
3254+f64 math__radians(f64 degrees);
3255+f64 math__angle_diff(f64 radian_a, f64 radian_b);
3256+Array_int math__digits(i64 num, math__DigitParams params);
3257+int math__count_digits(i64 number);
3258+multi_return_f64_f64 math__minmax(f64 a, f64 b);
3259+f64 math__clamp(f64 x, f64 a, f64 b);
3260+f64 math__sign(f64 n);
3261+int math__signi(f64 n);
3262+bool math__signbit(f64 x);
3263+bool math__tolerance(f64 actual, f64 expected, f64 tol);
3264+bool math__close(f64 actual, f64 expected);
3265+bool math__veryclose(f64 actual, f64 expected);
3266+bool math__alike(f64 a, f64 b);
3267+multi_return_f64_f64 math__modf(f64 f);
3268+f32 math__nextafter32(f32 x, f32 y);
3269+f64 math__nextafter(f64 x, f64 y);
3270+VV_LOC multi_return_f64_f64 math__ChebSeries_eval_e(math__ChebSeries cs, f64 x);
3271+f64 math__pow(f64 x, f64 y);
3272+f32 math__powf(f32 a, f32 b);
3273+f32 math__pure_v_but_overridden_by_c_powf(f32 a, f32 b);
3274+f64 math__pow10(int n);
3275+i64 math__powi(i64 a, i64 b);
3276+VV_LOC bool math__is_odd_int(f64 x);
3277+f64 math__pure_v_but_overridden_by_c_pow(f64 x, f64 y);
3278+f64 math__q_rsqrt(f64 x);
3279+f64 math__scalbn(f64 x, int n_);
3280+f64 math__cos(f64 a);
3281+f64 math__sin(f64 a);
3282+f32 math__cosf(f32 a);
3283+f32 math__sinf(f32 a);
3284+f64 math__pure_v_but_overridden_by_c_sin(f64 x);
3285+f64 math__pure_v_but_overridden_by_c_cos(f64 x);
3286+f32 math__pure_v_but_overridden_by_c_cosf(f32 a);
3287+f32 math__pure_v_but_overridden_by_c_sinf(f32 a);
3288+multi_return_f64_f64 math__sincos(f64 x);
3289+f64 math__sinh(f64 x_);
3290+f64 math__cosh(f64 x);
3291+f64 math__sqrt(f64 a);
3292+f32 math__sqrtf(f32 a);
3293+f64 math__pure_v_but_overridden_by_c_sqrt(f64 a);
3294+f32 math__pure_v_but_overridden_by_c_sqrtf(f32 a);
3295+i64 math__sqrti(i64 a);
3296+f32 math__tanf(f32 a);
3297+f64 math__tan(f64 a);
3298+f32 math__pure_v_but_overridden_by_c_tanf(f32 a);
3299+f64 math__cot(f64 a);
3300+f64 math__tanh(f64 x);
3301+u32 math__f32_bits(f32 f);
3302+f32 math__f32_from_bits(u32 b);
3303+u64 math__f64_bits(f64 f);
3304+f64 math__f64_from_bits(u64 b);
3305+f64 math__with_set_low_word(f64 f, u32 lo);
3306+f64 math__with_set_high_word(f64 f, u32 hi);
3307+u32 math__get_high_word(f64 f);
31163308 VV_LOC void main__vf_init(void);
31173309 VV_EXP void vf_init(void); // exported fn main.vf_init
31183310 VV_LOC int main__vf_add(int a, int b);
@@ -3121,7 +3313,10 @@ VV_LOC char* main__vf_greet(char* name);
31213313 VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet
31223314 VV_LOC void main__vf_free(voidptr p);
31233315 VV_EXP void vf_free(voidptr p); // exported fn main.vf_free
3316+VV_LOC void main__vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1);
3317+VV_EXP void vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1); // exported fn main.vf_mandelbrot
31243318 VV_LOC void main__main(void);
3319+f64 math__abs_T_f64(f64 a);
31253320 static bool Array_rune_arr_eq(Array_rune a, Array_rune b);
31263321 static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b);
31273322 static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b);
@@ -3489,11 +3684,182 @@ static Array_fixed_i32_1264 _const_rune_maps = {((i32)(0xB5)), 0xB5, 743, 0, 0xC
34893684 static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed2
34903685 static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed2
34913686 static rune _const_utf8_replacement_rune; // inited later
3687+static const f64 _const_math__internal__f64_epsilon = 2.220446049250313e-16; // precomputed2
3688+static const f64 _const_math__internal__sqrt_f64_epsilon = 1.4901161193847656e-08; // precomputed2
3689+static const f64 _const_math__internal__root3_f64_epsilon = 6.055454452393343e-06; // precomputed2
3690+static const f64 _const_math__internal__root4_f64_epsilon = 0.0001220703125; // precomputed2
3691+static const f64 _const_math__internal__root5_f64_epsilon = 0.000740095979741405; // precomputed2
3692+static const f64 _const_math__internal__root6_f64_epsilon = 0.002460783300575925; // precomputed2
3693+static const f64 _const_math__internal__log_f64_epsilon = -36.04365338911715; // precomputed2
3694+static const f64 _const_math__internal__f64_min = 2.2250738585072014e-308; // precomputed2
3695+static const f64 _const_math__internal__sqrt_f64_min = 1.4916681462400413e-154; // precomputed2
3696+static const f64 _const_math__internal__root3_f64_min = 2.8126442852362996e-103; // precomputed2
3697+static const f64 _const_math__internal__root4_f64_min = 1.221338669755462e-77; // precomputed2
3698+static const f64 _const_math__internal__root5_f64_min = 2.9476022969691763e-62; // precomputed2
3699+static const f64 _const_math__internal__root6_f64_min = 5.303436890579822e-52; // precomputed2
3700+static const f64 _const_math__internal__log_f64_min = -708.3964185322641; // precomputed2
3701+static const f64 _const_math__internal__f64_max = 1.7976931348623157e+308; // precomputed2
3702+static const f64 _const_math__internal__sqrt_f64_max = 1.3407807929942596e+154; // precomputed2
3703+static const f64 _const_math__internal__root3_f64_max = 5.64380309412229e+102; // precomputed2
3704+static const f64 _const_math__internal__root4_f64_max = 1.157920892373162e+77; // precomputed2
3705+static const f64 _const_math__internal__root5_f64_max = 4.4765466227572707e+61; // precomputed2
3706+static const f64 _const_math__internal__root6_f64_max = 2.3756689782295612e+51; // precomputed2
3707+static const f64 _const_math__internal__log_f64_max = 709.782712893384; // precomputed2
3708+static const f64 _const_math__internal__f32_epsilon = 1.1920928955078125e-07; // precomputed2
3709+static const f64 _const_math__internal__sqrt_f32_epsilon = 0.00034526698300124393; // precomputed2
3710+static const f64 _const_math__internal__root3_f32_epsilon = 0.00492156660115185; // precomputed2
3711+static const f64 _const_math__internal__root4_f32_epsilon = 0.018581361171917516; // precomputed2
3712+static const f64 _const_math__internal__root5_f32_epsilon = 0.04123462221165294; // precomputed2
3713+static const f64 _const_math__internal__root6_f32_epsilon = 0.07015387801933583; // precomputed2
3714+static const f64 _const_math__internal__log_f32_epsilon = -15.942385152878742; // precomputed2
3715+static const f64 _const_math__internal__f32_min = 1.1754943508222875e-38; // precomputed2
3716+static const f64 _const_math__internal__sqrt_f32_min = 1.0842021724855044e-19; // precomputed2
3717+static const f64 _const_math__internal__root3_f32_min = 2.273736754432324e-13; // precomputed2
3718+static const f64 _const_math__internal__root4_f32_min = 3.2927225399135965e-10; // precomputed2
3719+static const f64 _const_math__internal__root5_f32_min = 2.5944428542140822e-08; // precomputed2
3720+static const f64 _const_math__internal__root6_f32_min = 4.768371582031254e-07; // precomputed2
3721+static const f64 _const_math__internal__log_f32_min = -87.3365447505531; // precomputed2
3722+static const f64 _const_math__internal__f32_max = 3.4028234663852886e+38; // precomputed2
3723+static const f64 _const_math__internal__sqrt_f32_max = 1.844674352395373e+19; // precomputed2
3724+static const f64 _const_math__internal__root3_f32_max = 6.981463519622324e+12; // precomputed2
3725+static const f64 _const_math__internal__root4_f32_max = 4.2949672319999986e+09; // precomputed2
3726+static const f64 _const_math__internal__root5_f32_max = 5.085900785596004e+07; // precomputed2
3727+static const f64 _const_math__internal__root6_f32_max = 2.642245923380775e+06; // precomputed2
3728+static const f64 _const_math__internal__log_f32_max = 88.72283905206835; // precomputed2
3729+static const f64 _const_math__internal__sflt_epsilon = 0.00048828125; // precomputed2
3730+static const f64 _const_math__internal__sqrt_sflt_epsilon = 0.02209708691207961; // precomputed2
3731+static const f64 _const_math__internal__root3_sflt_epsilon = 0.07874506561842959; // precomputed2
3732+static const f64 _const_math__internal__root4_sflt_epsilon = 0.14865088937534013; // precomputed2
3733+static const f64 _const_math__internal__root5_sflt_epsilon = 0.217637640824031; // precomputed2
3734+static const f64 _const_math__internal__root6_sflt_epsilon = 0.28061551207734325; // precomputed2
3735+static const f64 _const_math__internal__log_sflt_epsilon = -7.6246189861593985; // precomputed2
3736+static const f64 _const_math__internal__max_f64_fact_arg = 171.0; // precomputed2
3737+static const f64 _const_math__internal__max_long_f64_fact_arg = 1755.5; // precomputed2
3738+static const u64 _const_math__uvnan = 9221120237041090561U; // precomputed2
3739+static const u64 _const_math__uvinf = 9218868437227405312U; // precomputed2
3740+static const u64 _const_math__uvneginf = 18442240474082181120U; // precomputed2
3741+static const u64 _const_math__uvone = 4607182418800017408U; // precomputed2
3742+static const u64 _const_math__normalize_smallest_mask = 4503599627370496U; // precomputed2
3743+static const u64 _const_math__sign_mask = 9223372036854775808U; // precomputed2
3744+static const u64 _const_math__frac_mask = 4503599627370495U; // precomputed2
3745+static const f64 _const_math__epsilon = 2.220446049250313e-16; // precomputed2
3746+static const f64 _const_math__e = 2.718281828459045; // precomputed2
3747+static const f64 _const_math__pi = 3.141592653589793; // precomputed2
3748+static const f64 _const_math__phi = 1.618033988749895; // precomputed2
3749+static const f64 _const_math__tau = 6.283185307179586; // precomputed2
3750+static const f64 _const_math__sqrt2 = 1.4142135623730951; // precomputed2
3751+static const f64 _const_math__sqrt_3 = 1.7320508075688772; // precomputed2
3752+static const f64 _const_math__sqrt_5 = 2.23606797749979; // precomputed2
3753+static const f64 _const_math__sqrt_e = 1.6487212707001282; // precomputed2
3754+static const f64 _const_math__sqrt_pi = 1.772453850905516; // precomputed2
3755+static const f64 _const_math__sqrt_tau = 2.5066282746310007; // precomputed2
3756+static const f64 _const_math__sqrt_phi = 1.272019649514069; // precomputed2
3757+static const f64 _const_math__ln2 = 0.6931471805599453; // precomputed2
3758+static const f64 _const_math__ln10 = 2.302585092994046; // precomputed2
3759+static const f64 _const_math__two_thirds = 0.6666666666666666; // precomputed2
3760+static const f64 _const_math__max_f32 = 3.4028234663852886e+38; // precomputed2
3761+static const f64 _const_math__smallest_non_zero_f32 = 1.401298464324817e-45; // precomputed2
3762+static const f64 _const_math__max_f64 = 1.7976931348623157e+308; // precomputed2
3763+static const f64 _const_math__smallest_non_zero_f64 = 0.0; // precomputed2
3764+static const f64 _const_math__erx = 0.8450629115104675; // precomputed2
3765+static const f64 _const_math__efx = 0.1283791670955126; // precomputed2
3766+static const f64 _const_math__efx8 = 1.0270333367641007; // precomputed2
3767+static const f64 _const_math__pp0 = 0.12837916709551256; // precomputed2
3768+static const f64 _const_math__pp1 = -0.3250421072470015; // precomputed2
3769+static const f64 _const_math__pp2 = -0.02848174957559851; // precomputed2
3770+static const f64 _const_math__pp3 = -0.005770270296489442; // precomputed2
3771+static const f64 _const_math__pp4 = -2.3763016656650163e-05; // precomputed2
3772+static const f64 _const_math__qq1 = 0.39791722395915535; // precomputed2
3773+static const f64 _const_math__qq2 = 0.0650222499887673; // precomputed2
3774+static const f64 _const_math__qq3 = 0.005081306281875766; // precomputed2
3775+static const f64 _const_math__qq4 = 0.00013249473800432164; // precomputed2
3776+static const f64 _const_math__qq5 = -3.960228278775368e-06; // precomputed2
3777+static const f64 _const_math__pa0 = -0.0023621185607526594; // precomputed2
3778+static const f64 _const_math__pa1 = 0.41485611868374833; // precomputed2
3779+static const f64 _const_math__pa2 = -0.3722078760357013; // precomputed2
3780+static const f64 _const_math__pa3 = 0.31834661990116175; // precomputed2
3781+static const f64 _const_math__pa4 = -0.11089469428239668; // precomputed2
3782+static const f64 _const_math__pa5 = 0.035478304325618236; // precomputed2
3783+static const f64 _const_math__pa6 = -0.002166375594868791; // precomputed2
3784+static const f64 _const_math__qa1 = 0.10642088040084423; // precomputed2
3785+static const f64 _const_math__qa2 = 0.540397917702171; // precomputed2
3786+static const f64 _const_math__qa3 = 0.07182865441419627; // precomputed2
3787+static const f64 _const_math__qa4 = 0.12617121980876164; // precomputed2
3788+static const f64 _const_math__qa5 = 0.01363708391202905; // precomputed2
3789+static const f64 _const_math__qa6 = 0.011984499846799107; // precomputed2
3790+static const f64 _const_math__ra0 = -0.009864944034847148; // precomputed2
3791+static const f64 _const_math__ra1 = -0.6938585727071818; // precomputed2
3792+static const f64 _const_math__ra2 = -10.558626225323291; // precomputed2
3793+static const f64 _const_math__ra3 = -62.375332450326006; // precomputed2
3794+static const f64 _const_math__ra4 = -162.39666946257347; // precomputed2
3795+static const f64 _const_math__ra5 = -184.60509290671104; // precomputed2
3796+static const f64 _const_math__ra6 = -81.2874355063066; // precomputed2
3797+static const f64 _const_math__ra7 = -9.814329344169145; // precomputed2
3798+static const f64 _const_math__sa1 = 19.651271667439257; // precomputed2
3799+static const f64 _const_math__sa2 = 137.65775414351904; // precomputed2
3800+static const f64 _const_math__sa3 = 434.56587747522923; // precomputed2
3801+static const f64 _const_math__sa4 = 645.3872717332679; // precomputed2
3802+static const f64 _const_math__sa5 = 429.00814002756783; // precomputed2
3803+static const f64 _const_math__sa6 = 108.63500554177944; // precomputed2
3804+static const f64 _const_math__sa7 = 6.570249770319282; // precomputed2
3805+static const f64 _const_math__sa8 = -0.0604244152148581; // precomputed2
3806+static const f64 _const_math__rb0 = -0.0098649429247001; // precomputed2
3807+static const f64 _const_math__rb1 = -0.799283237680523; // precomputed2
3808+static const f64 _const_math__rb2 = -17.757954917754752; // precomputed2
3809+static const f64 _const_math__rb3 = -160.63638485582192; // precomputed2
3810+static const f64 _const_math__rb4 = -637.5664433683896; // precomputed2
3811+static const f64 _const_math__rb5 = -1025.0951316110772; // precomputed2
3812+static const f64 _const_math__rb6 = -483.5191916086514; // precomputed2
3813+static const f64 _const_math__sb1 = 30.33806074348246; // precomputed2
3814+static const f64 _const_math__sb2 = 325.7925129965739; // precomputed2
3815+static const f64 _const_math__sb3 = 1536.729586084437; // precomputed2
3816+static const f64 _const_math__sb4 = 3199.8582195085955; // precomputed2
3817+static const f64 _const_math__sb5 = 2553.0504064331644; // precomputed2
3818+static const f64 _const_math__sb6 = 474.52854120695537; // precomputed2
3819+static const f64 _const_math__sb7 = -22.44095244658582; // precomputed2
3820+static const f64 _const_math__ln2hi = 0.6931471803691238; // precomputed2
3821+static const f64 _const_math__ln2lo = 1.9082149292705877e-10; // precomputed2
3822+static const f64 _const_math__log_sqrt_2pi = 0.9189385332046728; // precomputed2
3823+static Array_f64 _const_math__bernoulli; // inited later
3824+static Array_f64 _const_math__factorials_table; // inited later
3825+static Array_f64 _const_math__log_factorials_table; // inited later
3826+static Array_f64 _const_math__gamma_p; // inited later
3827+static Array_f64 _const_math__gamma_q; // inited later
3828+static Array_f64 _const_math__gamma_s; // inited later
3829+static Array_f64 _const_math__lgamma_a; // inited later
3830+static Array_f64 _const_math__lgamma_r; // inited later
3831+static Array_f64 _const_math__lgamma_s; // inited later
3832+static Array_f64 _const_math__lgamma_t; // inited later
3833+static Array_f64 _const_math__lgamma_u; // inited later
3834+static Array_f64 _const_math__lgamma_v; // inited later
3835+static Array_f64 _const_math__lgamma_w; // inited later
3836+static const f64 _const_math__morebits = 6.123233995736766e-17; // precomputed2
3837+static const f64 _const_math__tan3pio8 = 2.414213562373095; // precomputed2
3838+static const f64 _const_math__two54 = 1.8014398509481984e+16; // precomputed2
3839+static const f64 _const_math__ivln10 = 0.4342944819032518; // precomputed2
3840+static const f64 _const_math__log10_2hi = 0.30102999566361177; // precomputed2
3841+static const f64 _const_math__log10_2lo = 3.694239077158931e-13; // precomputed2
3842+static const f64 _const_math__modf_maxpowtwo = 4.503599627370496e+15; // precomputed2
3843+static Array_f64 _const_math__pow10tab; // inited later
3844+static Array_f64 _const_math__pow10postab32; // inited later
3845+static Array_f64 _const_math__pow10negtab32; // inited later
3846+static Array_f64 _const_math__sin_data; // inited later
3847+static Array_f64 _const_math__cos_data; // inited later
3848+static Array_f64 _const_math__tan_p; // inited later
3849+static Array_f64 _const_math__tan_q; // inited later
3850+static const f64 _const_math__tan_dp1 = 0.7853981554508209; // precomputed2
3851+static const f64 _const_math__tan_dp2 = 7.946627356147928e-09; // precomputed2
3852+static const f64 _const_math__tan_dp3 = 3.061616997868383e-17; // precomputed2
3853+static const f64 _const_math__tan_lossth = 1.073741824e+09; // precomputed2
3854+static Array_f64 _const_math__tanh_p; // inited later
3855+static Array_f64 _const_math__tanh_q; // inited later
34923856 static u32 _const_builtin__closure__closure_size_1; // inited later
34933857 Array_fixed_int_64 g_autostr_type_stack = {0}; // global 6
34943858
34953859 Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 6
34963860
3861+static math__ChebSeries _const_math__sin_cs; // inited later
3862+static math__ChebSeries _const_math__cos_cs; // inited later
34973863 static int _const_builtin__closure__closure_size; // inited later
34983864
34993865 // V interface table:
@@ -5044,7 +5410,6 @@ inline int math__bits__leading_zeros_8(u8 x) {
50445410 }
50455411 #elif !defined(__TINYC__)
50465412 {
5047- return __builtin_clz(((u32)(x))) - 24;
50485413 }
50495414 #endif
50505415 return math__bits__leading_zeros_8_default(x);
@@ -5058,7 +5423,6 @@ inline int math__bits__leading_zeros_16(u16 x) {
50585423 }
50595424 #elif !defined(__TINYC__)
50605425 {
5061- return __builtin_clz(((u32)(x))) - 16;
50625426 }
50635427 #endif
50645428 return math__bits__leading_zeros_16_default(x);
@@ -5072,7 +5436,6 @@ inline int math__bits__leading_zeros_32(u32 x) {
50725436 }
50735437 #elif !defined(__TINYC__)
50745438 {
5075- return __builtin_clz(x);
50765439 }
50775440 #endif
50785441 return math__bits__leading_zeros_32_default(x);
@@ -5086,7 +5449,6 @@ inline int math__bits__leading_zeros_64(u64 x) {
50865449 }
50875450 #elif !defined(__TINYC__)
50885451 {
5089- return __builtin_clzll(x);
50905452 }
50915453 #endif
50925454 return math__bits__leading_zeros_64_default(x);
@@ -5100,7 +5462,6 @@ inline int math__bits__trailing_zeros_8(u8 x) {
51005462 }
51015463 #elif !defined(__TINYC__)
51025464 {
5103- return __builtin_ctz(((u32)(x)));
51045465 }
51055466 #endif
51065467 return math__bits__trailing_zeros_8_default(x);
@@ -5114,7 +5475,6 @@ inline int math__bits__trailing_zeros_16(u16 x) {
51145475 }
51155476 #elif !defined(__TINYC__)
51165477 {
5117- return __builtin_ctz(((u32)(x)));
51185478 }
51195479 #endif
51205480 return math__bits__trailing_zeros_16_default(x);
@@ -5128,7 +5488,6 @@ inline int math__bits__trailing_zeros_32(u32 x) {
51285488 }
51295489 #elif !defined(__TINYC__)
51305490 {
5131- return __builtin_ctz(x);
51325491 }
51335492 #endif
51345493 return math__bits__trailing_zeros_32_default(x);
@@ -5142,7 +5501,6 @@ inline int math__bits__trailing_zeros_64(u64 x) {
51425501 }
51435502 #elif !defined(__TINYC__)
51445503 {
5145- return __builtin_ctzll(x);
51465504 }
51475505 #endif
51485506 return math__bits__trailing_zeros_64_default(x);
@@ -5153,7 +5511,6 @@ inline int math__bits__ones_count_8(u8 x) {
51535511 }
51545512 #elif !defined(__TINYC__)
51555513 {
5156- return __builtin_popcount(((u32)(x)));
51575514 }
51585515 #endif
51595516 return math__bits__ones_count_8_default(x);
@@ -5164,7 +5521,6 @@ inline int math__bits__ones_count_16(u16 x) {
51645521 }
51655522 #elif !defined(__TINYC__)
51665523 {
5167- return __builtin_popcount(((u32)(x)));
51685524 }
51695525 #endif
51705526 return math__bits__ones_count_16_default(x);
@@ -5175,7 +5531,6 @@ inline int math__bits__ones_count_32(u32 x) {
51755531 }
51765532 #elif !defined(__TINYC__)
51775533 {
5178- return __builtin_popcount(x);
51795534 }
51805535 #endif
51815536 return math__bits__ones_count_32_default(x);
@@ -5186,7 +5541,6 @@ inline int math__bits__ones_count_64(u64 x) {
51865541 }
51875542 #elif !defined(__TINYC__)
51885543 {
5189- return __builtin_popcountll(x);
51905544 }
51915545 #endif
51925546 return math__bits__ones_count_64_default(x);
@@ -10152,226 +10506,18 @@ VV_LOC string builtin__autostr_array_circular(int len) {
1015210506 return res;
1015310507 }
1015410508 void builtin__print_backtrace(void) {
10155- #if !defined(CUSTOM_DEFINE_no_backtrace)
10156- {
10157- #if 0
10158- {
10159- }
10160- #elif defined(__TINYC__)
10161- {
10162- }
10163- #elif defined(CUSTOM_DEFINE_use_libbacktrace)
10164- {
10165- }
10166- #else
10167- {
10168- builtin__print_backtrace_skipping_top_frames(2);
10169- }
10170- #endif
10171- }
10172- #endif
10173-}
10174-VV_LOC string builtin__demangle_v_symbol(string cname) {
10175- string name = cname;
10176- if (builtin__string_starts_with(name, _S("builtin__"))) {
10177- name = builtin__string_substr(name, 9, 2147483647);
10178- }
10179- name = builtin__string_replace(name, _S("__ptr__"), _S("&"));
10180- _option_int _t1 = builtin__string_index(name, _S("_T_"));
10181- if (_t1.state != 0) {
10182- *(int*) _t1.data = -1;
10183- }
10184-
10185- int t_pos = (*(int*)_t1.data);
10186- if (t_pos >= 0) {
10187- string base = builtin__string_replace(builtin__string_substr(name, 0, t_pos), _S("__"), _S("."));
10188- string generic_suffix = builtin__string_substr(name, t_pos + 3, 2147483647);
10189- Array_string params = builtin__split_generic_params(generic_suffix);
10190- Array_string demangled_params = builtin____new_array_with_default(0, params.len, sizeof(string), 0);
10191- for (int _t2 = 0; _t2 < params.len; ++_t2) {
10192- string param = ((string*)params.data)[_t2];
10193- builtin__array_push((array*)&demangled_params, _MOV((string[]){ builtin__string_replace(param, _S("__"), _S(".")) }));
10194- }
10195- return builtin__string_plus_many(4, _MOV((string[4]){base, _S("["), Array_string_join(demangled_params, _S(", ")), _S("]")}));
10196- }
10197- name = builtin__string_replace(name, _S("__"), _S("."));
10198- if (_SLIT_EQ(name.str, name.len, "main.main")) {
10199- return _S("main");
10200- }
10201- return name;
10202-}
10203-VV_LOC Array_string builtin__split_generic_params(string s) {
10204- Array_string params = builtin____new_array_with_default(0, 0, sizeof(string), 0);
10205- int start = 0;
10206- int i = 0;
10207- for (;;) {
10208- if (!(i < s.len)) break;
10209- if (s.str[ i] == '_') {
10210- if (i + 1 < s.len && s.str[ i + 1] == '_') {
10211- i += 2;
10212- } else {
10213- if (i > start) {
10214- builtin__array_push((array*)&params, _MOV((string[]){ builtin__string_substr(s, start, i) }));
10215- }
10216- i++;
10217- start = i;
10218- }
10219- } else {
10220- i++;
10221- }
10222- }
10223- if (start < s.len) {
10224- builtin__array_push((array*)&params, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) }));
10225- }
10226- return params;
10227-}
10228-VV_LOC string builtin__demangle_backtrace_sym(string s) {
10229- _option_int _t1 = builtin__string_index(s, _S("("));
10230- if (_t1.state != 0) {
10231- return s;
10232- }
10233-
10234- int paren_start = (*(int*)_t1.data);
10235- int plus_pos = builtin__string_index_after_(s, _S("+"), paren_start);
10236- if (plus_pos < 0) {
10237- return s;
10238- }
10239- string symbol = builtin__string_substr(s, paren_start + 1, plus_pos);
10240- if (symbol.len == 0) {
10241- return s;
10242- }
10243- return builtin__string_plus_many(3, _MOV((string[3]){builtin__string_substr(s, 0, paren_start + 1), builtin__demangle_v_symbol(symbol), builtin__string_substr(s, plus_pos, 2147483647)}));
10244-}
10245-VV_LOC void builtin__eprint_space_padding(string output, int max_len) {
10246- int padding_len = max_len - output.len;
10247- if (padding_len > 0) {
10248- for (int _t1 = 0; _t1 < padding_len; ++_t1) {
10249- builtin__eprint(_S(" "));
10250- }
10251- }
1025210509 }
1025310510 bool builtin__print_backtrace_skipping_top_frames(int xskipframes) {
1025410511 #if defined(CUSTOM_DEFINE_no_backtrace)
1025510512 {
10513+ return false;
1025610514 }
1025710515 #else
1025810516 {
10259- int skipframes = xskipframes + 2;
10260- #if 0
10261- {
10262- }
10263- #elif 1
10264- {
10265- return builtin__print_backtrace_skipping_top_frames_linux(skipframes);
10266- }
10267- #else
10268- {
10269- }
10270- #endif
1027110517 }
1027210518 #endif
1027310519 return false;
1027410520 }
10275-VV_LOC string builtin__backtrace_current_executable_name(void) {
10276- Array_string args = builtin__arguments();
10277- if (args.len == 0) {
10278- return _S("");
10279- }
10280- return (*(string*)builtin__array_get(args, 0));
10281-}
10282-VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name) {
10283- if (executable.len == 0) {
10284- return _S("/proc/self/exe");
10285- }
10286- if (builtin__string_contains(executable, _S("/"))) {
10287- return executable;
10288- }
10289- if (current_executable_name.len > 0 && builtin__string__eq(builtin__string_all_after_last(executable, _S("/")), builtin__string_all_after_last(current_executable_name, _S("/")))) {
10290- return _S("/proc/self/exe");
10291- }
10292- return executable;
10293-}
10294-VV_LOC string builtin__backtrace_shell_quote(string s) {
10295- string quoted = _S("'");
10296- for (int i = 0; i < s.len; ++i) {
10297- if (builtin__string_at(s, i) == '\'') {
10298- quoted = builtin__string__plus(quoted, _S("'\\''"));
10299- } else {
10300- quoted = builtin__string__plus(quoted, builtin__u8_ascii_str(builtin__string_at(s, i)));
10301- }
10302- }
10303- return builtin__string__plus(quoted, _S("'"));
10304-}
10305-VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes) {
10306- #if defined(CUSTOM_DEFINE_no_backtrace)
10307- {
10308- }
10309- #else
10310- {
10311- #if 1
10312- {
10313- #if 0
10314- {
10315- }
10316- #else
10317- {
10318- string current_executable_name = builtin__backtrace_current_executable_name();
10319- Array_fixed_voidptr_100 buffer = {0};
10320- i32 nr_ptrs = backtrace(&buffer[0], 100);
10321- if (nr_ptrs < 2) {
10322- builtin__eprintln(_S("C.backtrace returned less than 2 frames"));
10323- return false;
10324- }
10325- int nr_actual_frames = (int)(nr_ptrs - skipframes);
10326- char** csymbols = backtrace_symbols(((voidptr)(&buffer[skipframes])), nr_actual_frames);
10327- for (int i = 0; i < nr_actual_frames; ++i) {
10328- string sframe = builtin__tos2(((u8*)(csymbols[i])));
10329- string executable = builtin__string_all_before(sframe, _S("("));
10330- string addr2line_executable = builtin__backtrace_addr2line_executable(executable, current_executable_name);
10331- string addr = builtin__string_all_before(builtin__string_all_after(sframe, _S("[")), _S("]"));
10332- string beforeaddr = builtin__string_all_before(sframe, _S("["));
10333- string cmd = builtin__string_plus_many(4, _MOV((string[4]){_S("addr2line -e "), builtin__backtrace_shell_quote(addr2line_executable), _S(" "), builtin__backtrace_shell_quote(addr)}));
10334- voidptr f = popen(((char*)(cmd.str)), "r");
10335- if (f == ((void*)0)) {
10336- builtin__eprintln(sframe);
10337- continue;
10338- }
10339- Array_fixed_u8_1000 buf = {0};
10340- string output = _S("");
10341- { // Unsafe block
10342- u8* bp = ((u8*)(&buf[0]));
10343- for (;;) {
10344- if (!(fgets(((char*)(bp)), 1000, f) != 0)) break;
10345- output = builtin__string__plus(output, builtin__tos(bp, builtin__vstrlen(bp)));
10346- }
10347- }
10348- output = builtin__string__plus(builtin__string_trim_chars(output, _S(" \t\n"), TrimMode__trim_both), _S(":"));
10349- if (pclose(f) != 0) {
10350- builtin__eprintln(sframe);
10351- continue;
10352- }
10353- if (_SLIT_EQ(output.str, output.len, "??:0:") || _SLIT_EQ(output.str, output.len, "??:?:")) {
10354- output = _S("");
10355- }
10356- output = builtin__string_replace(output, _S(" (discriminator"), _S(": (d."));
10357- builtin__eprint(output);
10358- builtin__eprint_space_padding(output, 55);
10359- builtin__eprint(_S(" | "));
10360- builtin__eprint(addr);
10361- builtin__eprint(_S(" | "));
10362- builtin__eprintln(builtin__demangle_backtrace_sym(beforeaddr));
10363- }
10364- if (nr_actual_frames > 0) {
10365- free(csymbols);
10366- }
10367- }
10368- #endif
10369- }
10370- #endif
10371- }
10372- #endif
10373- return true;
10374-}
1037510521 VNORETURN void builtin___v_exit(int code) {
1037610522 exit(code);
1037710523 VUNREACHABLE();
@@ -10410,12 +10556,12 @@ VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number) {
1041010556 #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)
1041110557 {
1041210558 }
10413- #elif 0
10559+ #elif 1
1041410560 {
10561+ builtin__print_backtrace_skipping_top_frames(1);
1041510562 }
1041610563 #else
1041710564 {
10418- builtin__print_backtrace();
1041910565 }
1042010566 #endif
1042110567 builtin___v_exit(128 + signal_number);
@@ -10489,7 +10635,7 @@ Array_string builtin__arguments(void) {
1048910635 return res;
1049010636 }
1049110637 string builtin__vcurrent_hash(void) {
10492- return _S("");
10638+ return _S("7647ce1");
1049310639 }
1049410640 u64 builtin__v_getpid(void) {
1049510641 #if defined(CUSTOM_DEFINE_no_getpid)
@@ -12451,22 +12597,14 @@ VNORETURN void builtin___v_panic(string s) {
1245112597 }
1245212598 #elif defined(CUSTOM_DEFINE_no_backtrace)
1245312599 {
12600+ exit(1);
12601+ VUNREACHABLE();
1245412602 }
1245512603 #elif 0
1245612604 {
1245712605 }
1245812606 #else
1245912607 {
12460- #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)
12461- {
12462- }
12463- #else
12464- {
12465- builtin__print_backtrace_skipping_top_frames(1);
12466- }
12467- #endif
12468- exit(1);
12469- VUNREACHABLE();
1247012608 }
1247112609 #endif
1247212610 }
@@ -16443,78 +16581,2188 @@ inline void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_) {
1644316581 inline ArrayFlags builtin__ArrayFlags__static__zero(void) {
1644416582 return ((ArrayFlags)(0));
1644516583 }
16446-VV_LOC void main__vf_init(void) {
16447- string probe = _S("vf");
16448- {int _ = probe.len;}
16449- ;
16450-}
16451-// export alias: vf_init -> main__vf_init
16452-void vf_init(void) {
16453- return main__vf_init();
16584+f64 math__inf(int sign) {
16585+ u64 v = (sign >= 0 ? (_const_math__uvinf) : (_const_math__uvneginf));
16586+ return math__f64_from_bits(v);
1645416587 }
16455-VV_LOC int main__vf_add(int a, int b) {
16456- return a + b;
16588+f64 math__nan(void) {
16589+ return math__f64_from_bits(_const_math__uvnan);
1645716590 }
16458-// export alias: vf_add -> main__vf_add
16459-int vf_add(int a, int b) {
16460- return main__vf_add(a, b);
16591+bool math__is_nan(f64 f) {
16592+ return f != f;
1646116593 }
16462-VV_LOC char* main__vf_greet(char* name) {
16463- string n = builtin__cstring_to_vstring(name);
16464- string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")}));
16465- u8* out = res.str;
16466- builtin__string_free(&n);
16467- return out;
16594+bool math__is_inf(f64 f, int sign) {
16595+ return (sign >= 0 && f > ((f64)(_const_math__max_f64))) || (sign <= 0 && f < ((f64)(-_const_math__max_f64)));
1646816596 }
16469-// export alias: vf_greet -> main__vf_greet
16470-char* vf_greet(char* name) {
16471- return main__vf_greet(name);
16597+bool math__is_finite(f64 f) {
16598+ return !math__is_nan(f) && !math__is_inf(f, 0);
1647216599 }
16473-VV_LOC void main__vf_free(voidptr p) {
16474- builtin___v_free(p);
16600+multi_return_f64_int math__normalize(f64 x) {
16601+ f64 smallest_normal = 2.2250738585072014e-308;
16602+ if (math__abs_T_f64(x) < smallest_normal) {
16603+ return (multi_return_f64_int){.arg0=(f64)(x * _const_math__normalize_smallest_mask), .arg1=-52};
16604+ }
16605+ return (multi_return_f64_int){.arg0=x, .arg1=0};
1647516606 }
16476-// export alias: vf_free -> main__vf_free
16477-void vf_free(voidptr p) {
16478- return main__vf_free(p);
16607+f64 math__cbrt(f64 a) {
16608+ f64 x = a;
16609+ int b1 = 715094163;
16610+ int b2 = 696219795;
16611+ f64 c = 5.42857142857142815906e-01;
16612+ f64 d = -7.05306122448979611050e-01;
16613+ f64 e_ = 1.41428571428571436819e+00;
16614+ f64 f = 1.60714285714285720630e+00;
16615+ f64 g = 3.57142857142857150787e-01;
16616+ f64 smallest_normal = 2.22507385850720138309e-308;
16617+ if (x == ((f64)(0.0)) || math__is_nan(x) || math__is_inf(x, 0)) {
16618+ return x;
16619+ }
16620+ bool neg = false;
16621+ if (x < 0) {
16622+ x = -x;
16623+ neg = true;
16624+ }
16625+ f64 t = math__f64_from_bits(VSAFE_DIV_u64(math__f64_bits(x) , ((u64)(3))) + (v__lshift_u64(((u64)(b1)), (u64)32)));
16626+ if (x < smallest_normal) {
16627+ t = ((f64)(v__lshift_u64(((u64)(1)), (u64)54)));
16628+ t *= x;
16629+ t = math__f64_from_bits(VSAFE_DIV_u64(math__f64_bits(t) , ((u64)(3))) + (v__lshift_u64(((u64)(b2)), (u64)32)));
16630+ }
16631+ f64 r = t * t / x;
16632+ f64 s = c + r * t;
16633+ t *= g + f / (s + e_ + d / s);
16634+ t = math__f64_from_bits((math__f64_bits(t) & (v__lshift_u64(((u64)(0xffffffffcLL)), (u64)28))) + (v__lshift_u64(((u64)(1)), (u64)30)));
16635+ s = t * t;
16636+ r = x / s;
16637+ f64 w = t + t;
16638+ r = (r - t) / (w + r);
16639+ t = t + t * r;
16640+ if (neg) {
16641+ t = -t;
16642+ }
16643+ return t;
1647916644 }
16480-VV_LOC void main__main(void) {
16645+f64 math__mod(f64 x, f64 y) {
16646+ return math__fmod(x, y);
1648116647 }
16482-void _vinit(int ___argc, voidptr ___argv) {
16483- static bool once = false; if (once) {return;} once = true;
16484- // Initializations of consts for module builtin.closure
16485- g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3
16486-{
16487-{
16488-Array_fixed_u8_15 _t1;
16489-#if defined(__V_ppc64le)
16490-#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
16491-#elif defined(__V_amd64)
16492- { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ;
16493- memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15));
16648+f64 math__fmod(f64 x, f64 y) {
16649+ if (y == 0 || math__is_inf(x, 0) || math__is_nan(x) || math__is_nan(y)) {
16650+ return math__nan();
1649416651 }
16495- ;
16496-#elif defined(__V_x86)
16497-#elif defined(__V_arm64)
16498-#elif defined(__V_arm32)
16499-#elif defined(__V_rv64)
16500-#elif defined(__V_rv32)
16501-#elif defined(__V_s390x)
16502-#elif defined(__V_loongarch64)
16503-#elif defined(__V_sparc64)
16504-#elif 0
16505-#else
16506-#endif
16507- memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15));
16652+ f64 abs_y = math__abs_T_f64(y);
16653+ multi_return_f64_int mr_594 = math__frexp(abs_y);
16654+ f64 abs_y_fr = mr_594.arg0;
16655+ int abs_y_exp = mr_594.arg1;
16656+ f64 r = x;
16657+ if (x < 0) {
16658+ r = -x;
16659+ }
16660+ for (;;) {
16661+ if (!(r >= abs_y)) break;
16662+ multi_return_f64_int mr_680 = math__frexp(r);
16663+ f64 rfr = mr_680.arg0;
16664+ int rexp = mr_680.arg1;
16665+ if (rfr < abs_y_fr) {
16666+ rexp = rexp - 1;
16667+ }
16668+ r = r - math__ldexp(abs_y, rexp - abs_y_exp);
16669+ }
16670+ if (x < 0) {
16671+ r = -r;
16672+ }
16673+ return r;
1650816674 }
16675+i64 math__gcd(i64 a_, i64 b_) {
16676+ i64 a = a_;
16677+ i64 b = b_;
16678+ if (a < 0) {
16679+ a = -a;
16680+ }
16681+ if (b < 0) {
16682+ b = -b;
16683+ }
16684+ for (;;) {
16685+ if (!(b != 0)) break;
16686+ a = VSAFE_MOD_i64(a,b);
16687+ if (a == 0) {
16688+ return b;
16689+ }
16690+ b = VSAFE_MOD_i64(b,a);
16691+ }
16692+ return a;
1650916693 }
16510-{
16511-{
16512-Array_fixed_u8_6 _t3;
16513-#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
16514-#elif defined(__V_arm32)
16515-#elif defined(__V_amd64)
16516- { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ;
16517- memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6));
16694+multi_return_i64_i64_i64 math__egcd(i64 a, i64 b) {
16695+ i64 old_r = a;
16696+ i64 r = b;
16697+ i64 old_s = ((i64)(1));
16698+ i64 s = ((i64)(0));
16699+ i64 old_t = ((i64)(0));
16700+ i64 t = ((i64)(1));
16701+ for (;;) {
16702+ if (!(r != 0)) break;
16703+ i64 quot = VSAFE_DIV_i64(old_r , r);
16704+ i64 _var_1339 = old_r;
16705+ i64 _var_1346 = r;
16706+ old_r = _var_1346;
16707+ r = _var_1339%_var_1346;
16708+ i64 _var_1365 = old_s;
16709+ i64 _var_1372 = s;
16710+ old_s = _var_1372;
16711+ s = _var_1365-quot*_var_1372;
16712+ i64 _var_1398 = old_t;
16713+ i64 _var_1405 = t;
16714+ old_t = _var_1405;
16715+ t = _var_1398-quot*_var_1405;
16716+ }
16717+ return (multi_return_i64_i64_i64){.arg0=(old_r < 0 ? (-old_r) : (old_r)), .arg1=old_s, .arg2=old_t};
16718+}
16719+i64 math__lcm(i64 a, i64 b) {
16720+ if (a == 0) {
16721+ return a;
16722+ }
16723+ i64 res = a * (VSAFE_DIV_i64(b , math__gcd(b, a)));
16724+ if (res < 0) {
16725+ return -res;
16726+ }
16727+ return res;
16728+}
16729+f64 math__erf(f64 a) {
16730+ f64 x = a;
16731+ f64 very_tiny = 2.848094538889218e-306;
16732+ f64 small_ = ((f64)(1.0)) / ((f64)(v__lshift_u64(((u64)(1)), (u64)28)));
16733+ if (math__is_nan(x)) {
16734+ return math__nan();
16735+ }
16736+ if (math__is_inf(x, 1)) {
16737+ return 1.0;
16738+ }
16739+ if (math__is_inf(x, -1)) {
16740+ return ((f64)(-1));
16741+ }
16742+ bool neg = false;
16743+ if (x < 0) {
16744+ x = -x;
16745+ neg = true;
16746+ }
16747+ if (x < ((f64)(0.84375))) {
16748+ f64 temp = 0.0;
16749+ if (x < small_) {
16750+ if (x < very_tiny) {
16751+ temp = ((f64)(0.125)) * (((f64)(8.0)) * x + ((f64)(_const_math__efx8)) * x);
16752+ } else {
16753+ temp = x + ((f64)(_const_math__efx)) * x;
16754+ }
16755+ } else {
16756+ f64 z = x * x;
16757+ f64 r = ((f64)(_const_math__pp0)) + z * (((f64)(_const_math__pp1)) + z * (((f64)(_const_math__pp2)) + z * (((f64)(_const_math__pp3)) + z * ((f64)(_const_math__pp4)))));
16758+ f64 s_ = ((f64)(1.0)) + z * (((f64)(_const_math__qq1)) + z * (((f64)(_const_math__qq2)) + z * (((f64)(_const_math__qq3)) + z * (((f64)(_const_math__qq4)) + z * ((f64)(_const_math__qq5))))));
16759+ f64 y = r / s_;
16760+ temp = x + x * y;
16761+ }
16762+ if (neg) {
16763+ return -temp;
16764+ }
16765+ return temp;
16766+ }
16767+ if (x < ((f64)(1.25))) {
16768+ f64 s_ = x - 1;
16769+ f64 p = ((f64)(_const_math__pa0)) + s_ * (((f64)(_const_math__pa1)) + s_ * (((f64)(_const_math__pa2)) + s_ * (((f64)(_const_math__pa3)) + s_ * (((f64)(_const_math__pa4)) + s_ * (((f64)(_const_math__pa5)) + s_ * ((f64)(_const_math__pa6)))))));
16770+ f64 q = ((f64)(1.0)) + s_ * (((f64)(_const_math__qa1)) + s_ * (((f64)(_const_math__qa2)) + s_ * (((f64)(_const_math__qa3)) + s_ * (((f64)(_const_math__qa4)) + s_ * (((f64)(_const_math__qa5)) + s_ * ((f64)(_const_math__qa6)))))));
16771+ if (neg) {
16772+ return ((f64)(-_const_math__erx)) - p / q;
16773+ }
16774+ return ((f64)(_const_math__erx)) + p / q;
16775+ }
16776+ if (x >= 6) {
16777+ if (neg) {
16778+ return -1;
16779+ }
16780+ return 1.0;
16781+ }
16782+ f64 s_ = ((f64)(1.0)) / (x * x);
16783+ f64 r = 0.0;
16784+ f64 s = 0.0;
16785+ if (x < ((f64)(2.857142857142857))) {
16786+ f64 tmp41 = s_ * (((f64)(_const_math__ra5)) + s_ * (((f64)(_const_math__ra6)) + s_ * ((f64)(_const_math__ra7))));
16787+ r = ((f64)(_const_math__ra0)) + s_ * (((f64)(_const_math__ra1)) + s_ * (((f64)(_const_math__ra2)) + s_ * (((f64)(_const_math__ra3)) + s_ * (((f64)(_const_math__ra4)) + tmp41))));
16788+ f64 tmp42 = s_ * (((f64)(_const_math__sa5)) + s_ * (((f64)(_const_math__sa6)) + s_ * (((f64)(_const_math__sa7)) + s_ * ((f64)(_const_math__sa8)))));
16789+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sa1)) + s_ * (((f64)(_const_math__sa2)) + s_ * (((f64)(_const_math__sa3)) + s_ * (((f64)(_const_math__sa4)) + tmp42))));
16790+ } else {
16791+ f64 tmp31 = ((f64)(_const_math__rb4)) + s_ * (((f64)(_const_math__rb5)) + s_ * ((f64)(_const_math__rb6)));
16792+ r = ((f64)(_const_math__rb0)) + s_ * (((f64)(_const_math__rb1)) + s_ * (((f64)(_const_math__rb2)) + s_ * (((f64)(_const_math__rb3)) + s_ * tmp31)));
16793+ f64 tmp32 = ((f64)(_const_math__sb4)) + s_ * (((f64)(_const_math__sb5)) + s_ * (((f64)(_const_math__sb6)) + s_ * ((f64)(_const_math__sb7))));
16794+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sb1)) + s_ * (((f64)(_const_math__sb2)) + s_ * (((f64)(_const_math__sb3)) + s_ * tmp32)));
16795+ }
16796+ f64 z = math__f64_from_bits((math__f64_bits(x) & 0xffffffff00000000ULL));
16797+ f64 r_ = math__exp(-z * z - ((f64)(0.5625))) * math__exp((z - x) * (z + x) + r / s);
16798+ if (neg) {
16799+ return r_ / x - ((f64)(1.0));
16800+ }
16801+ return ((f64)(1.0)) - r_ / x;
16802+}
16803+f64 math__erfc(f64 a) {
16804+ f64 x = a;
16805+ f64 tiny = ((f64)(1.0)) / ((f64)(v__lshift_u64(((u64)(1)), (u64)56)));
16806+ if (math__is_nan(x)) {
16807+ return math__nan();
16808+ }
16809+ if (math__is_inf(x, 1)) {
16810+ return 0.0;
16811+ }
16812+ if (math__is_inf(x, -1)) {
16813+ return 2.0;
16814+ }
16815+ bool neg = false;
16816+ if (x < 0) {
16817+ x = -x;
16818+ neg = true;
16819+ }
16820+ if (x < ((f64)(0.84375))) {
16821+ f64 temp = 0.0;
16822+ if (x < tiny) {
16823+ temp = x;
16824+ } else {
16825+ f64 z = x * x;
16826+ f64 r = ((f64)(_const_math__pp0)) + z * (((f64)(_const_math__pp1)) + z * (((f64)(_const_math__pp2)) + z * (((f64)(_const_math__pp3)) + z * ((f64)(_const_math__pp4)))));
16827+ f64 s_ = ((f64)(1.0)) + z * (((f64)(_const_math__qq1)) + z * (((f64)(_const_math__qq2)) + z * (((f64)(_const_math__qq3)) + z * (((f64)(_const_math__qq4)) + z * ((f64)(_const_math__qq5))))));
16828+ f64 y = r / s_;
16829+ if (x < ((f64)(0.25))) {
16830+ temp = x + x * y;
16831+ } else {
16832+ temp = ((f64)(0.5)) + (x * y + (x - ((f64)(0.5))));
16833+ }
16834+ }
16835+ if (neg) {
16836+ return ((f64)(1.0)) + temp;
16837+ }
16838+ return ((f64)(1.0)) - temp;
16839+ }
16840+ if (x < ((f64)(1.25))) {
16841+ f64 s_ = x - 1;
16842+ f64 p = ((f64)(_const_math__pa0)) + s_ * (((f64)(_const_math__pa1)) + s_ * (((f64)(_const_math__pa2)) + s_ * (((f64)(_const_math__pa3)) + s_ * (((f64)(_const_math__pa4)) + s_ * (((f64)(_const_math__pa5)) + s_ * ((f64)(_const_math__pa6)))))));
16843+ f64 q = ((f64)(1.0)) + s_ * (((f64)(_const_math__qa1)) + s_ * (((f64)(_const_math__qa2)) + s_ * (((f64)(_const_math__qa3)) + s_ * (((f64)(_const_math__qa4)) + s_ * (((f64)(_const_math__qa5)) + s_ * ((f64)(_const_math__qa6)))))));
16844+ if (neg) {
16845+ return ((f64)(1.8450629115104675)) + p / q;
16846+ }
16847+ return ((f64)(0.15493708848953247)) - p / q;
16848+ }
16849+ if (x < 28) {
16850+ f64 s_ = ((f64)(1.0)) / (x * x);
16851+ f64 r = 0.0;
16852+ f64 s = 0.0;
16853+ if (x < ((f64)(2.857142857142857))) {
16854+ f64 tmp281 = ((f64)(_const_math__ra4)) + s_ * (((f64)(_const_math__ra5)) + s_ * (((f64)(_const_math__ra6)) + s_ * ((f64)(_const_math__ra7))));
16855+ r = ((f64)(_const_math__ra0)) + s_ * (((f64)(_const_math__ra1)) + s_ * (((f64)(_const_math__ra2)) + s_ * (((f64)(_const_math__ra3)) + s_ * tmp281)));
16856+ f64 tmp282 = ((f64)(_const_math__sa4)) + s_ * (((f64)(_const_math__sa5)) + s_ * (((f64)(_const_math__sa6)) + s_ * (((f64)(_const_math__sa7)) + s_ * ((f64)(_const_math__sa8)))));
16857+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sa1)) + s_ * (((f64)(_const_math__sa2)) + s_ * (((f64)(_const_math__sa3)) + s_ * tmp282)));
16858+ } else {
16859+ if (neg && x > 6) {
16860+ return 2.0;
16861+ }
16862+ f64 tmp291 = ((f64)(_const_math__rb3)) + s_ * (((f64)(_const_math__rb4)) + s_ * (((f64)(_const_math__rb5)) + s_ * ((f64)(_const_math__rb6))));
16863+ r = ((f64)(_const_math__rb0)) + s_ * (((f64)(_const_math__rb1)) + s_ * (((f64)(_const_math__rb2)) + s_ * tmp291));
16864+ f64 tmp292 = ((f64)(_const_math__sb3)) + s_ * (((f64)(_const_math__sb4)) + s_ * (((f64)(_const_math__sb5)) + s_ * (((f64)(_const_math__sb6)) + s_ * ((f64)(_const_math__sb7)))));
16865+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sb1)) + s_ * (((f64)(_const_math__sb2)) + s_ * tmp292));
16866+ }
16867+ f64 z = math__f64_from_bits((math__f64_bits(x) & 0xffffffff00000000ULL));
16868+ f64 r_ = math__exp(-z * z - ((f64)(0.5625))) * math__exp((z - x) * (z + x) + r / s);
16869+ if (neg) {
16870+ return ((f64)(2.0)) - r_ / x;
16871+ }
16872+ return r_ / x;
16873+ }
16874+ if (neg) {
16875+ return 2.0;
16876+ }
16877+ return 0.0;
16878+}
16879+inline f64 math__exp(f64 x) {
16880+ return exp(x);
16881+}
16882+inline f64 math__exp2(f64 x) {
16883+ return exp2(x);
16884+}
16885+inline f64 math__ldexp(f64 frac, int exp) {
16886+ return ldexp(frac, exp);
16887+}
16888+f64 math__pure_v_but_overridden_by_c_exp(f64 x) {
16889+ f64 log2e = 1.44269504088896338700e+00;
16890+ f64 overflow = 7.09782712893383973096e+02;
16891+ f64 underflow = -7.45133219101941108420e+02;
16892+ float_literal near_zero = (float_literal)(1.0 / 268435456);
16893+ if (math__is_nan(x) || math__is_inf(x, 1)) {
16894+ return x;
16895+ }
16896+ if (math__is_inf(x, -1)) {
16897+ return 0.0;
16898+ }
16899+ if (x > overflow) {
16900+ return math__inf(1);
16901+ }
16902+ if (x < underflow) {
16903+ return 0.0;
16904+ }
16905+ if (-near_zero < x && x < near_zero) {
16906+ return ((f64)(1.0)) + x;
16907+ }
16908+ int k = 0;
16909+ if (x < 0) {
16910+ k = ((int)(log2e * x - ((f64)(0.5))));
16911+ }
16912+ if (x > 0) {
16913+ k = ((int)(log2e * x + ((f64)(0.5))));
16914+ }
16915+ f64 hi = x - ((f64)(k)) * ((f64)(_const_math__ln2hi));
16916+ f64 lo = ((f64)(k)) * ((f64)(_const_math__ln2lo));
16917+ return math__expmulti(hi, lo, k);
16918+}
16919+f64 math__pure_v_but_overridden_by_c_exp2(f64 x) {
16920+ f64 overflow = 1.0239999999999999e+03;
16921+ f64 underflow = -1.0740e+03;
16922+ if (math__is_nan(x) || math__is_inf(x, 1)) {
16923+ return x;
16924+ }
16925+ if (math__is_inf(x, -1)) {
16926+ return 0;
16927+ }
16928+ if (x > overflow) {
16929+ return math__inf(1);
16930+ }
16931+ if (x < underflow) {
16932+ return 0;
16933+ }
16934+ int k = 0;
16935+ if (x > 0) {
16936+ k = ((int)(x + ((f64)(0.5))));
16937+ }
16938+ if (x < 0) {
16939+ k = ((int)(x - ((f64)(0.5))));
16940+ }
16941+ f64 t = x - ((f64)(k));
16942+ f64 hi = t * ((f64)(_const_math__ln2hi));
16943+ f64 lo = -t * ((f64)(_const_math__ln2lo));
16944+ return math__expmulti(hi, lo, k);
16945+}
16946+f64 math__pure_v_but_overridden_by_c_ldexp(f64 frac, int exp) {
16947+ return math__scalbn(frac, exp);
16948+}
16949+multi_return_f64_int math__frexp(f64 x) {
16950+ u64 y = math__f64_bits(x);
16951+ int ee = ((int)(((v__rshift_u64(y, (u64)52)) & 0x7ff)));
16952+ if (ee == 0) {
16953+ if (x != ((f64)(0.0))) {
16954+ f64 x1p64 = math__f64_from_bits(((u64)(0x43f0000000000000LL)));
16955+ multi_return_f64_int mr_3373 = math__frexp(x * x1p64);
16956+ f64 z = mr_3373.arg0;
16957+ int e_ = mr_3373.arg1;
16958+ return (multi_return_f64_int){.arg0=z, .arg1=e_ - 64};
16959+ }
16960+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16961+ } else if (ee == 0x7ff) {
16962+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16963+ }
16964+ int e_ = ee - 0x3fe;
16965+ y &= ((u64)(0x800fffffffffffffULL));
16966+ y |= ((u64)(0x3fe0000000000000LL));
16967+ return (multi_return_f64_int){.arg0=math__f64_from_bits(y), .arg1=e_};
16968+}
16969+f64 math__expm1(f64 x) {
16970+ if (math__is_inf(x, 1) || math__is_nan(x)) {
16971+ return x;
16972+ }
16973+ if (math__is_inf(x, -1)) {
16974+ return ((f64)(-1));
16975+ }
16976+ if (math__abs_T_f64(x) < ((f64)(_const_math__ln2))) {
16977+ f64 i = 1.0;
16978+ f64 sum = x;
16979+ f64 term = x / ((f64)(1.0));
16980+ i++;
16981+ term *= x / ((f64)(i));
16982+ sum += term;
16983+ for (;;) {
16984+ if (!(math__abs_T_f64(term) > math__abs_T_f64(sum) * ((f64)(_const_math__internal__f64_epsilon)))) break;
16985+ i++;
16986+ term *= x / ((f64)(i));
16987+ sum += term;
16988+ }
16989+ return sum;
16990+ } else {
16991+ return math__exp(x) - 1;
16992+ }
16993+ return 0;
16994+}
16995+VV_LOC f64 math__expmulti(f64 hi, f64 lo, int k) {
16996+ f64 exp_p1 = 1.66666666666666657415e-01;
16997+ f64 exp_p2 = -2.77777777770155933842e-03;
16998+ f64 exp_p3 = 6.61375632143793436117e-05;
16999+ f64 exp_p4 = -1.65339022054652515390e-06;
17000+ f64 exp_p5 = 4.13813679705723846039e-08;
17001+ f64 r = hi - lo;
17002+ f64 t = r * r;
17003+ f64 c = r - t * (exp_p1 + t * (exp_p2 + t * (exp_p3 + t * (exp_p4 + t * exp_p5))));
17004+ f64 y = 1 - ((lo - (r * c) / (2 - c)) - hi);
17005+ return math__ldexp(y, k);
17006+}
17007+f64 math__factorial(f64 n) {
17008+ if (n >= _const_math__factorials_table.len) {
17009+ return _const_math__max_f64;
17010+ }
17011+ if (n == ((f64)(((i64)(n)))) && n >= ((f64)(0.0))) {
17012+ return (*(f64*)builtin__array_get(_const_math__factorials_table, ((int)(n))));
17013+ }
17014+ return math__gamma(n + ((f64)(1.0)));
17015+}
17016+f64 math__log_factorial(f64 n) {
17017+ if (n < 0) {
17018+ return -_const_math__max_f64;
17019+ }
17020+ if (n != ((f64)(((i64)(n))))) {
17021+ return math__log_gamma(n + 1);
17022+ } else if (n < _const_math__log_factorials_table.len) {
17023+ return (*(f64*)builtin__array_get(_const_math__log_factorials_table, ((int)(n))));
17024+ }
17025+ return math__log_factorial_asymptotic_expansion(((int)(n)));
17026+}
17027+VV_LOC f64 math__log_factorial_asymptotic_expansion(int n) {
17028+ int m = 6;
17029+ Array_f64 term = builtin____new_array_with_default(0, 0, sizeof(f64), 0);
17030+ f64 xx = ((f64)((n + 1) * (n + 1)));
17031+ f64 xj = ((f64)(n + 1));
17032+ f64 log_fact = ((f64)(_const_math__log_sqrt_2pi)) - xj + (xj - ((f64)(0.5))) * math__log(xj);
17033+ int i = 0;
17034+ for (i = 0; i < m; i++) {
17035+ builtin__array_push((array*)&term, _MOV((f64[]){ (*(f64*)builtin__array_get(_const_math__bernoulli, i)) / xj }));
17036+ xj *= xx;
17037+ }
17038+ f64 sum = (*(f64*)builtin__array_get(term, m - 1));
17039+ for (i = m - 2; i >= 0; i--) {
17040+ if (math__abs_T_f64(sum) <= math__abs_T_f64((*(f64*)builtin__array_get(term, i)))) {
17041+ break;
17042+ }
17043+ sum = (*(f64*)builtin__array_get(term, i));
17044+ }
17045+ for (;;) {
17046+ if (!(i >= 0)) break;
17047+ sum += (*(f64*)builtin__array_get(term, i));
17048+ i--;
17049+ }
17050+ return log_fact + sum;
17051+}
17052+i64 math__factoriali(int n) {
17053+ if (n <= 0) {
17054+ return ((i64)(1));
17055+ }
17056+ if (n < 21) {
17057+ return ((i64)((*(f64*)builtin__array_get(_const_math__factorials_table, n))));
17058+ }
17059+ return ((i64)(-1));
17060+}
17061+f64 math__floor(f64 x) {
17062+ if (x == 0 || math__is_nan(x) || math__is_inf(x, 0)) {
17063+ return x;
17064+ }
17065+ if (x < 0) {
17066+ multi_return_f64_f64 mr_280 = math__modf(-x);
17067+ f64 d = mr_280.arg0;
17068+ f64 fract = mr_280.arg1;
17069+ if (fract != ((f64)(0.0))) {
17070+ d = d + 1;
17071+ }
17072+ return -d;
17073+ }
17074+ multi_return_f64_f64 mr_350 = math__modf(x);
17075+ f64 d = mr_350.arg0;
17076+ return d;
17077+}
17078+f32 math__floorf(f32 x) {
17079+ return ((f32)(math__floor(((f64)(x)))));
17080+}
17081+f64 math__ceil(f64 x) {
17082+ return -math__floor(-x);
17083+}
17084+f64 math__trunc(f64 x) {
17085+ if (x == 0 || math__is_nan(x) || math__is_inf(x, 0)) {
17086+ return x;
17087+ }
17088+ multi_return_f64_f64 mr_1200 = math__modf(x);
17089+ f64 d = mr_1200.arg0;
17090+ return d;
17091+}
17092+f64 math__round(f64 x) {
17093+ u64 bits = math__f64_bits(x);
17094+ u64 e_ = ((v__rshift_u64(bits, (u64)52)) & 0x7FF);
17095+ if (e_ < 1023) {
17096+ bits &= _const_math__sign_mask;
17097+ if (e_ == 1022) {
17098+ bits |= _const_math__uvone;
17099+ }
17100+ } else if (e_ < 1075) {
17101+ u64 half = v__lshift_u64(((u64)(1)), (u64)51);
17102+ e_ -= _const_math__bias;
17103+ bits += v__rshift_u64(half, (u64)e_);
17104+ bits &= ~(v__rshift_u64(_const_math__frac_mask, (u64)e_));
17105+ }
17106+ return math__f64_from_bits(bits);
17107+}
17108+f64 math__round_sig(f64 x, int sig_digits) {
17109+ string ret_str = builtin__f64_str(x);
17110+ switch (sig_digits) {
17111+ case 0: {
17112+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000000d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17113+ break;
17114+ }
17115+ case 1: {
17116+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000020d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17117+ break;
17118+ }
17119+ case 2: {
17120+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000040d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17121+ break;
17122+ }
17123+ case 3: {
17124+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000060d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17125+ break;
17126+ }
17127+ case 4: {
17128+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000080d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17129+ break;
17130+ }
17131+ case 5: {
17132+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000a0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17133+ break;
17134+ }
17135+ case 6: {
17136+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000c0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17137+ break;
17138+ }
17139+ case 7: {
17140+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000e0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17141+ break;
17142+ }
17143+ case 8: {
17144+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000100d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17145+ break;
17146+ }
17147+ case 9: {
17148+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000120d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17149+ break;
17150+ }
17151+ case 10: {
17152+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000140d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17153+ break;
17154+ }
17155+ case 11: {
17156+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000160d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17157+ break;
17158+ }
17159+ case 12: {
17160+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000180d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17161+ break;
17162+ }
17163+ case 13: {
17164+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001a0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17165+ break;
17166+ }
17167+ case 14: {
17168+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001c0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17169+ break;
17170+ }
17171+ case 15: {
17172+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001e0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17173+ break;
17174+ }
17175+ case 16: {
17176+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000200d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17177+ break;
17178+ }
17179+ default: {
17180+ {
17181+ ret_str = builtin__f64_str(x);
17182+ break;
17183+ }
17184+ }
17185+ }
17186+
17187+ return builtin__string_f64(ret_str);
17188+}
17189+f64 math__round_to_even(f64 x) {
17190+ u64 bits = math__f64_bits(x);
17191+ u64 e_ = ((v__rshift_u64(bits, (u64)52)) & 0x7FF);
17192+ if (e_ >= 1023) {
17193+ u64 half_minus_ulp = ((u64)(v__lshift_u64(((u64)(1)), (u64)51))) - 1;
17194+ e_ -= ((u64)(_const_math__bias));
17195+ bits += math__safe_shift(half_minus_ulp + (math__safe_shift(bits, 52 - e_) & 1), e_);
17196+ bits &= ~math__safe_shift(_const_math__frac_mask, e_);
17197+ } else if (e_ == 1022 && (bits & _const_math__frac_mask) != 0) {
17198+ bits = ((bits & _const_math__sign_mask) | _const_math__uvone);
17199+ } else {
17200+ bits &= _const_math__sign_mask;
17201+ }
17202+ return math__f64_from_bits(bits);
17203+}
17204+inline VV_LOC u64 math__safe_shift(u64 value, u64 shift) {
17205+ return (shift > ((u64)(63)) ? (((u64)(0))) : (v__rshift_u64(value, (u64)shift)));
17206+}
17207+VV_LOC bool math__is_neg_int(f64 x) {
17208+ if (x < 0) {
17209+ multi_return_f64_f64 mr_61 = math__modf(x);
17210+ f64 xf = mr_61.arg1;
17211+ return xf == 0;
17212+ }
17213+ return false;
17214+}
17215+VV_LOC multi_return_f64_f64 math__stirling(f64 x) {
17216+ if (x > 200) {
17217+ return (multi_return_f64_f64){.arg0=math__inf(1), .arg1=1.0};
17218+ }
17219+ f64 w = ((f64)(1.0)) / x;
17220+ w = ((f64)(1.0)) + w * (((((*(f64*)builtin__array_get(_const_math__gamma_s, 0)) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 1))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 2))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 3))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 4)));
17221+ f64 y1 = math__exp(x);
17222+ f64 y2 = 1.0;
17223+ if (x > ((f64)(143.01608))) {
17224+ f64 v = math__pow(x, ((f64)(0.5)) * x - ((f64)(0.25)));
17225+ f64 y1_ = y1;
17226+ y1 = v;
17227+ y2 = v / y1_;
17228+ } else {
17229+ y1 = math__pow(x, x - ((f64)(0.5))) / y1;
17230+ }
17231+ return (multi_return_f64_f64){.arg0=y1, .arg1=((f64)(2.506628274631000502417)) * w * y2};
17232+}
17233+f64 math__gamma(f64 a) {
17234+ f64 x = a;
17235+ if (math__is_neg_int(x) || math__is_inf(x, -1) || math__is_nan(x)) {
17236+ return math__nan();
17237+ }
17238+ if (math__is_inf(x, 1)) {
17239+ return math__inf(1);
17240+ }
17241+ if (x == ((f64)(0.0))) {
17242+ return math__copysign(math__inf(1), x);
17243+ }
17244+ f64 q = math__abs_T_f64(x);
17245+ f64 p = math__floor(q);
17246+ if (q > 33) {
17247+ if (x >= 0) {
17248+ multi_return_f64_f64 mr_1507 = math__stirling(x);
17249+ f64 y1 = mr_1507.arg0;
17250+ f64 y2 = mr_1507.arg1;
17251+ return y1 * y2;
17252+ }
17253+ int signgam = 1;
17254+ i64 ip = ((i64)(p));
17255+ if (((ip & 1)) == 0) {
17256+ signgam = -1;
17257+ }
17258+ f64 z = q - p;
17259+ if (z > ((f64)(0.5))) {
17260+ p = p + 1;
17261+ z = q - p;
17262+ }
17263+ z = q * math__sin(((f64)(_const_math__pi)) * z);
17264+ if (z == 0) {
17265+ return math__inf(signgam);
17266+ }
17267+ multi_return_f64_f64 mr_1952 = math__stirling(q);
17268+ f64 sq1 = mr_1952.arg0;
17269+ f64 sq2 = mr_1952.arg1;
17270+ f64 absz = math__abs_T_f64(z);
17271+ f64 d = absz * sq1 * sq2;
17272+ if (math__is_inf(d, 0)) {
17273+ z = ((f64)(_const_math__pi)) / absz / sq1 / sq2;
17274+ } else {
17275+ z = ((f64)(_const_math__pi)) / d;
17276+ }
17277+ return ((f64)(signgam)) * z;
17278+ }
17279+ f64 z = 1.0;
17280+ for (;;) {
17281+ if (!(x >= 3)) break;
17282+ x = x - 1;
17283+ z = z * x;
17284+ }
17285+ for (;;) {
17286+ if (!(x < 0)) break;
17287+ if (x > ((f64)(-1e-09))) {
17288+ return math__gamma_too_small(x, z);
17289+ }
17290+ z = z / x;
17291+ x = x + 1;
17292+ }
17293+ for (;;) {
17294+ if (!(x < 2)) break;
17295+ if (x < ((f64)(1e-09))) {
17296+ return math__gamma_too_small(x, z);
17297+ }
17298+ z = z / x;
17299+ x = x + 1;
17300+ }
17301+ if (x == 2) {
17302+ return z;
17303+ }
17304+ x = x - 2;
17305+ p = (((((x * (*(f64*)builtin__array_get(_const_math__gamma_p, 0)) + (*(f64*)builtin__array_get(_const_math__gamma_p, 1))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 2))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 3))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 4))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 5))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 6));
17306+ q = ((((((x * (*(f64*)builtin__array_get(_const_math__gamma_q, 0)) + (*(f64*)builtin__array_get(_const_math__gamma_q, 1))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 2))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 3))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 4))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 5))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 6))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 7));
17307+ return z * p / q;
17308+}
17309+VV_LOC f64 math__gamma_too_small(f64 x, f64 z) {
17310+ if (x == 0) {
17311+ return math__inf(1);
17312+ }
17313+ f64 euler = 0.57721566490153286060651209008240243104215933593992;
17314+ return z / ((((f64)(1.0)) + euler * x) * x);
17315+}
17316+f64 math__log_gamma(f64 x) {
17317+ multi_return_f64_int mr_3163 = math__log_gamma_sign(x);
17318+ f64 y = mr_3163.arg0;
17319+ return y;
17320+}
17321+multi_return_f64_int math__log_gamma_sign(f64 a) {
17322+ f64 x = a;
17323+ int sgn = 1;
17324+ if (math__is_nan(x)) {
17325+ return (multi_return_f64_int){.arg0=x, .arg1=sgn};
17326+ }
17327+ if (math__is_inf(x, 1)) {
17328+ return (multi_return_f64_int){.arg0=x, .arg1=sgn};
17329+ }
17330+ if (x == ((f64)(0.0))) {
17331+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17332+ }
17333+ bool neg = false;
17334+ if (x < 0) {
17335+ x = -x;
17336+ neg = true;
17337+ }
17338+ if (x < math__exp2(-70)) {
17339+ if (neg) {
17340+ sgn = -1;
17341+ }
17342+ return (multi_return_f64_int){.arg0=-math__log(x), .arg1=sgn};
17343+ }
17344+ f64 nadj = 0.0;
17345+ if (neg) {
17346+ if (x >= math__exp2(52)) {
17347+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17348+ }
17349+ f64 t = math__sin_pi(x);
17350+ if (t == 0) {
17351+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17352+ }
17353+ nadj = math__log(((f64)(_const_math__pi)) / math__abs_T_f64(t * x));
17354+ if (t < 0) {
17355+ sgn = -1;
17356+ }
17357+ }
17358+ f64 lgamma = 0.0;
17359+ if (x == 1 || x == 2) {
17360+ return (multi_return_f64_int){.arg0=0.0, .arg1=sgn};
17361+ } else if (x < 2) {
17362+ f64 ymin = 1.461632144968362245;
17363+ f64 tc = 1.46163214496836224576e+00;
17364+ f64 y = 0.0;
17365+ int i = 0;
17366+ if (x <= ((f64)(0.9))) {
17367+ lgamma = -math__log(x);
17368+ if (x >= (ymin - 1 + ((f64)(0.27)))) {
17369+ y = ((f64)(1.0)) - x;
17370+ i = 0;
17371+ } else if (x >= (ymin - 1 - ((f64)(0.27)))) {
17372+ y = x - (tc - 1);
17373+ i = 1;
17374+ } else {
17375+ y = x;
17376+ i = 2;
17377+ }
17378+ } else {
17379+ lgamma = 0;
17380+ if (x >= (ymin + ((f64)(0.27)))) {
17381+ y = ((f64)(2)) - x;
17382+ i = 0;
17383+ } else if (x >= (ymin - ((f64)(0.27)))) {
17384+ y = x - tc;
17385+ i = 1;
17386+ } else {
17387+ y = x - 1;
17388+ i = 2;
17389+ }
17390+ }
17391+ if (i == 0) {
17392+ f64 z = y * y;
17393+ f64 gamma_p1 = (*(f64*)builtin__array_get(_const_math__lgamma_a, 0)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 2)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 4)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 6)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 8)) + z * (*(f64*)builtin__array_get(_const_math__lgamma_a, 10))))));
17394+ f64 gamma_p2 = z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 1)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 3)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 5)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 7)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 9)) + z * (*(f64*)builtin__array_get(_const_math__lgamma_a, 11)))))));
17395+ f64 p = y * gamma_p1 + gamma_p2;
17396+ lgamma += (p - ((f64)(0.5)) * y);
17397+ } else if (i == 1) {
17398+ f64 z = y * y;
17399+ f64 w = z * y;
17400+ f64 gamma_p1 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 0)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 3)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 6)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 9)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 12)))));
17401+ f64 gamma_p2 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 1)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 4)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 7)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 10)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 13)))));
17402+ f64 gamma_p3 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 2)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 5)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 8)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 11)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 14)))));
17403+ f64 tf = -1.21486290535849611461e-01;
17404+ f64 tt = -3.63867699703950536541e-18;
17405+ f64 p = z * gamma_p1 - (tt - w * (gamma_p2 + y * gamma_p3));
17406+ lgamma += (tf + p);
17407+ } else if (i == 2) {
17408+ f64 gamma_p1 = y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 4)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_u, 5)))))));
17409+ f64 gamma_p2 = ((f64)(1.0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 4)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_v, 5))))));
17410+ lgamma += (((f64)(-0.5)) * y + gamma_p1 / gamma_p2);
17411+ }
17412+ } else if (x < 8) {
17413+ int i = ((int)(x));
17414+ f64 y = x - ((f64)(i));
17415+ f64 tmp23456 = (*(f64*)builtin__array_get(_const_math__lgamma_s, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_s, 6)))));
17416+ f64 p = y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 1)) + y * tmp23456));
17417+ f64 tmpr23456 = (*(f64*)builtin__array_get(_const_math__lgamma_r, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_r, 6)))));
17418+ f64 q = ((f64)(1.0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 1)) + y * tmpr23456);
17419+ lgamma = ((f64)(0.5)) * y + p / q;
17420+ f64 z = 1.0;
17421+ if (i == 7) {
17422+ z *= (y + 6);
17423+ z *= (y + 5);
17424+ z *= (y + 4);
17425+ z *= (y + 3);
17426+ z *= (y + 2);
17427+ lgamma += math__log(z);
17428+ } else if (i == 6) {
17429+ z *= (y + 5);
17430+ z *= (y + 4);
17431+ z *= (y + 3);
17432+ z *= (y + 2);
17433+ lgamma += math__log(z);
17434+ } else if (i == 5) {
17435+ z *= (y + 4);
17436+ z *= (y + 3);
17437+ z *= (y + 2);
17438+ lgamma += math__log(z);
17439+ } else if (i == 4) {
17440+ z *= (y + 3);
17441+ z *= (y + 2);
17442+ lgamma += math__log(z);
17443+ } else if (i == 3) {
17444+ z *= (y + 2);
17445+ lgamma += math__log(z);
17446+ }
17447+ } else if (x < math__exp2(58)) {
17448+ f64 t = math__log(x);
17449+ f64 z = ((f64)(1.0)) / x;
17450+ f64 y = z * z;
17451+ f64 w = (*(f64*)builtin__array_get(_const_math__lgamma_w, 0)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_w, 6)))))));
17452+ lgamma = (x - ((f64)(0.5))) * (t - ((f64)(1.0))) + w;
17453+ } else {
17454+ lgamma = x * (math__log(x) - ((f64)(1.0)));
17455+ }
17456+ if (neg) {
17457+ lgamma = nadj - lgamma;
17458+ }
17459+ return (multi_return_f64_int){.arg0=lgamma, .arg1=sgn};
17460+}
17461+VV_LOC f64 math__sin_pi(f64 x_) {
17462+ f64 x = x_;
17463+ if (x < ((f64)(0.25))) {
17464+ return -math__sin(((f64)(_const_math__pi)) * x);
17465+ }
17466+ f64 z = math__floor(x);
17467+ int n = 0;
17468+ if (z != x) {
17469+ x = math__mod(x, 2);
17470+ n = ((int)(x * 4));
17471+ } else {
17472+ if (x >= math__exp2(53)) {
17473+ x = 0;
17474+ n = 0;
17475+ } else {
17476+ f64 two52 = math__exp2(52);
17477+ if (x < two52) {
17478+ z = x + two52;
17479+ }
17480+ n = (1 & ((int)(math__f64_bits(z))));
17481+ x = ((f64)(n));
17482+ n = v__lshift_int(n, (u64)2);
17483+ }
17484+ }
17485+ if (n == 0) {
17486+ x = math__sin(((f64)(_const_math__pi)) * x);
17487+ } else if (n == 1 || n == 2) {
17488+ x = math__cos(((f64)(_const_math__pi)) * (((f64)(0.5)) - x));
17489+ } else if (n == 3 || n == 4) {
17490+ x = math__sin(((f64)(_const_math__pi)) * (((f64)(1.0)) - x));
17491+ } else if (n == 5 || n == 6) {
17492+ x = -math__cos(((f64)(_const_math__pi)) * (x - ((f64)(1.5))));
17493+ } else {
17494+ x = math__sin(((f64)(_const_math__pi)) * (x - 2));
17495+ }
17496+ return -x;
17497+}
17498+f64 math__hypot(f64 x, f64 y) {
17499+ f64 p = math__abs_T_f64(x);
17500+ f64 q = math__abs_T_f64(y);
17501+ if (math__is_inf(p, 1) || math__is_inf(q, 1)) {
17502+ return math__inf(1);
17503+ }
17504+ if (math__is_nan(p) || math__is_nan(q)) {
17505+ return math__nan();
17506+ }
17507+ if (p < q) {
17508+ f64 _var_382 = p;
17509+ f64 _var_385 = q;
17510+ p = _var_385;
17511+ q = _var_382;
17512+ }
17513+ if (p == ((f64)(0.0))) {
17514+ return 0.0;
17515+ }
17516+ q = q / p;
17517+ return p * math__sqrt(1 + q * q);
17518+}
17519+inline math__BezierPoint math__cubic_bezier(f64 t, Array_math__BezierPoint p) {
17520+ if (p.len != 4) {
17521+ builtin___v_panic(_S("invalid p.len"));
17522+ VUNREACHABLE();
17523+ }
17524+ return math__cubic_bezier_coords(t, ((math__BezierPoint*)p.data)[0].x, ((math__BezierPoint*)p.data)[1].x, ((math__BezierPoint*)p.data)[2].x, ((math__BezierPoint*)p.data)[3].x, ((math__BezierPoint*)p.data)[0].y, ((math__BezierPoint*)p.data)[1].y, ((math__BezierPoint*)p.data)[2].y, ((math__BezierPoint*)p.data)[3].y);
17525+}
17526+inline math__BezierPoint math__cubic_bezier_a(f64 t, Array_f64 x, Array_f64 y) {
17527+ if (x.len != 4) {
17528+ builtin___v_panic(_S("invalid x.len"));
17529+ VUNREACHABLE();
17530+ }
17531+ if (y.len != 4) {
17532+ builtin___v_panic(_S("invalid y.len"));
17533+ VUNREACHABLE();
17534+ }
17535+ return math__cubic_bezier_coords(t, ((f64*)x.data)[0], ((f64*)x.data)[1], ((f64*)x.data)[2], ((f64*)x.data)[3], ((f64*)y.data)[0], ((f64*)y.data)[1], ((f64*)y.data)[2], ((f64*)y.data)[3]);
17536+}
17537+inline math__BezierPoint math__cubic_bezier_fa(f64 t, Array_fixed_f64_4 x, Array_fixed_f64_4 y) {
17538+ return math__cubic_bezier_coords(t, x[0], x[1], x[2], x[3], y[0], y[1], y[2], y[3]);
17539+}
17540+inline math__BezierPoint math__cubic_bezier_coords(f64 t, f64 x0, f64 x1, f64 x2, f64 x3, f64 y0, f64 y1, f64 y2, f64 y3) {
17541+ f64 p0 = math__pow(1 - t, 3);
17542+ f64 p1 = 3 * t * math__pow(1 - t, 2);
17543+ f64 p2 = 3 * (1 - t) * math__pow(t, 2);
17544+ f64 p3 = math__pow(t, 3);
17545+ f64 xt = p0 * x0 + p1 * x1 + p2 * x2 + p3 * x3;
17546+ f64 yt = p0 * y0 + p1 * y1 + p2 * y2 + p3 * y3;
17547+ return ((math__BezierPoint){.x = xt,.y = yt,});
17548+}
17549+f64 math__acosh(f64 x) {
17550+ if (x > ((f64)(6.7108864e+07))) {
17551+ return math__log(x) + ((f64)(_const_math__ln2));
17552+ } else if (x > ((f64)(2.0))) {
17553+ return math__log(((f64)(2.0)) * x - ((f64)(1.0)) / (math__sqrt(x * x - ((f64)(1.0))) + x));
17554+ } else if (x > ((f64)(1.0))) {
17555+ f64 t = x - ((f64)(1.0));
17556+ return math__log1p(t + math__sqrt(((f64)(2.0)) * t + t * t));
17557+ } else if (x == ((f64)(1.0))) {
17558+ return 0.0;
17559+ } else {
17560+ return math__nan();
17561+ }
17562+ return 0;
17563+}
17564+f64 math__asinh(f64 x) {
17565+ f64 a = math__abs_T_f64(x);
17566+ f64 s = (x < 0 ? (-1.0) : (1.0));
17567+ if (a > ((f64)(6.7108864e+07))) {
17568+ return s * (math__log(a) + ((f64)(_const_math__ln2)));
17569+ } else if (a > ((f64)(2.0))) {
17570+ return s * math__log(((f64)(2.0)) * a + ((f64)(1.0)) / (a + math__sqrt(a * a + ((f64)(1.0)))));
17571+ } else if (a > ((f64)(_const_math__internal__sqrt_f64_epsilon))) {
17572+ f64 a2 = a * a;
17573+ return s * math__log1p(a + a2 / (((f64)(1.0)) + math__sqrt(((f64)(1.0)) + a2)));
17574+ } else {
17575+ return x;
17576+ }
17577+ return 0;
17578+}
17579+f64 math__atanh(f64 x) {
17580+ f64 a = math__abs_T_f64(x);
17581+ f64 s = (x < 0 ? (-1.0) : (1.0));
17582+ if (a > ((f64)(1.0))) {
17583+ return math__nan();
17584+ } else if (a == ((f64)(1.0))) {
17585+ return (x < 0 ? (math__inf(-1)) : (math__inf(1)));
17586+ } else if (a >= ((f64)(0.5))) {
17587+ return s * ((f64)(0.5)) * math__log1p(((f64)(2.0)) * a / (((f64)(1.0)) - a));
17588+ } else if (a > ((f64)(_const_math__internal__f64_epsilon))) {
17589+ return s * ((f64)(0.5)) * math__log1p(((f64)(2.0)) * a + ((f64)(2.0)) * a * a / (((f64)(1.0)) - a));
17590+ } else {
17591+ return x;
17592+ }
17593+ return 0;
17594+}
17595+inline VV_LOC f64 math__xatan(f64 x) {
17596+ f64 xatan_p0 = -8.750608600031904122785e-01;
17597+ f64 xatan_p1 = -1.615753718733365076637e+01;
17598+ f64 xatan_p2 = -7.500855792314704667340e+01;
17599+ f64 xatan_p3 = -1.228866684490136173410e+02;
17600+ f64 xatan_p4 = -6.485021904942025371773e+01;
17601+ f64 xatan_q0 = 2.485846490142306297962e+01;
17602+ f64 xatan_q1 = 1.650270098316988542046e+02;
17603+ f64 xatan_q2 = 4.328810604912902668951e+02;
17604+ f64 xatan_q3 = 4.853903996359136964868e+02;
17605+ f64 xatan_q4 = 1.945506571482613964425e+02;
17606+ f64 z = x * x;
17607+ z = z * ((((xatan_p0 * z + xatan_p1) * z + xatan_p2) * z + xatan_p3) * z + xatan_p4) / (((((z + xatan_q0) * z + xatan_q1) * z + xatan_q2) * z + xatan_q3) * z + xatan_q4);
17608+ z = x * z + x;
17609+ return z;
17610+}
17611+inline VV_LOC f64 math__satan(f64 x) {
17612+ if (x <= ((f64)(0.66))) {
17613+ return math__xatan(x);
17614+ }
17615+ if (x > ((f64)(_const_math__tan3pio8))) {
17616+ return ((f64)(1.5707963267948966)) - math__xatan(((f64)(1.0)) / x) + ((f64)(_const_math__morebits));
17617+ }
17618+ return ((f64)((float_literal)(3.14159265358979323846264338327950288419716939937510582097494459 / 4))) + math__xatan((x - ((f64)(1.0))) / (x + ((f64)(1.0)))) + ((f64)(0.5)) * ((f64)(_const_math__morebits));
17619+}
17620+f64 math__atan(f64 x) {
17621+ if (x == 0) {
17622+ return x;
17623+ }
17624+ if (x > 0) {
17625+ return math__satan(x);
17626+ }
17627+ return -math__satan(-x);
17628+}
17629+f64 math__atan2(f64 y, f64 x) {
17630+ if (math__is_nan(y) || math__is_nan(x)) {
17631+ return math__nan();
17632+ }
17633+ if (y == ((f64)(0.0))) {
17634+ if (x >= 0 && !math__signbit(x)) {
17635+ return math__copysign(0, y);
17636+ }
17637+ return math__copysign(_const_math__pi, y);
17638+ }
17639+ if (x == ((f64)(0.0))) {
17640+ return math__copysign(1.5707963267948966, y);
17641+ }
17642+ if (math__is_inf(x, 0)) {
17643+ if (math__is_inf(x, 1)) {
17644+ if (math__is_inf(y, 0)) {
17645+ return math__copysign((float_literal)(3.14159265358979323846264338327950288419716939937510582097494459 / 4), y);
17646+ }
17647+ return math__copysign(0, y);
17648+ }
17649+ if (math__is_inf(y, 0)) {
17650+ return math__copysign(2.356194490192345, y);
17651+ }
17652+ return math__copysign(_const_math__pi, y);
17653+ }
17654+ if (math__is_inf(y, 0)) {
17655+ return math__copysign(1.5707963267948966, y);
17656+ }
17657+ f64 q = math__atan(y / x);
17658+ if (x < 0) {
17659+ if (q <= 0) {
17660+ return q + ((f64)(_const_math__pi));
17661+ }
17662+ return q - ((f64)(_const_math__pi));
17663+ }
17664+ return q;
17665+}
17666+f64 math__asin(f64 x_) {
17667+ f64 x = x_;
17668+ if (x == ((f64)(0.0))) {
17669+ return x;
17670+ }
17671+ bool neg = false;
17672+ if (x < ((f64)(0.0))) {
17673+ x = -x;
17674+ neg = true;
17675+ }
17676+ if (x > ((f64)(1.0))) {
17677+ return math__nan();
17678+ }
17679+ f64 temp = math__sqrt(((f64)(1.0)) - x * x);
17680+ if (x > ((f64)(0.7))) {
17681+ temp = ((f64)(1.5707963267948966)) - math__satan(temp / x);
17682+ } else {
17683+ temp = math__satan(x / temp);
17684+ }
17685+ if (neg) {
17686+ temp = -temp;
17687+ }
17688+ return temp;
17689+}
17690+inline f64 math__acos(f64 x) {
17691+ if (x < ((f64)(-1.0)) || x > ((f64)(1.0))) {
17692+ return math__nan();
17693+ }
17694+ if (x > ((f64)(0.5))) {
17695+ return ((f64)(2.0)) * math__asin(math__sqrt(((f64)(0.5)) - ((f64)(0.5)) * x));
17696+ }
17697+ f64 z = ((f64)(_const_math__pi)) / ((f64)(4.0)) - math__asin(x);
17698+ z = z + ((f64)(_const_math__morebits));
17699+ z = z + ((f64)(_const_math__pi)) / ((f64)(4.0));
17700+ return z;
17701+}
17702+inline f64 math__log(f64 x) {
17703+ return log(x);
17704+}
17705+inline f64 math__log2(f64 x) {
17706+ return log2(x);
17707+}
17708+inline f64 math__log10(f64 x) {
17709+ return log10(x);
17710+}
17711+inline f64 math__log1p(f64 x) {
17712+ return log1p(x);
17713+}
17714+f64 math__log_b(f64 x) {
17715+ return logb(x);
17716+}
17717+inline f32 math__logf(f32 x) {
17718+ return logf(x);
17719+}
17720+f64 math__log_n(f64 x, f64 b) {
17721+ f64 y = math__log(x);
17722+ f64 z = math__log(b);
17723+ return y / z;
17724+}
17725+f64 math__pure_v_but_overridden_by_c_log10(f64 x) {
17726+ f64 x_ = x;
17727+ i64 hx = ((i64)(math__f64_bits(x_)));
17728+ i32 k = ((i32)(0));
17729+ if (hx < ((i64)(0x0010000000000000LL))) {
17730+ if ((hx & 0x7fffffffffffffffLL) == 0) {
17731+ return math__inf(-1);
17732+ }
17733+ if (hx < 0) {
17734+ return (x_ - x_) / (x_ - x_);
17735+ }
17736+ k = k - 54;
17737+ x_ *= _const_math__two54;
17738+ hx = ((i64)(math__f64_bits(x_)));
17739+ }
17740+ if (_us64_le(((u64)(0x7ff0000000000000LL)),hx)) {
17741+ return x_ + x_;
17742+ }
17743+ k = k + ((i32)((((u64)((v__rshift_i64(hx, (u64)52)) - 1023)))));
17744+ i32 i = ((i32)(v__rshift_u64(((((u64)(k)) & 0x8000000000000000ULL)), (u64)63)));
17745+ hx = (((hx & 0x000fffffffffffffLL)) | (v__lshift_u64(((u64)(0x3ff - i)), (u64)52)));
17746+ f64 y = ((f64)(k + i));
17747+ x_ = math__f64_from_bits(((u64)(hx)));
17748+ f64 z = y * _const_math__log10_2lo + _const_math__ivln10 * math__log(x_);
17749+ return z + y * _const_math__log10_2hi;
17750+}
17751+f64 math__pure_v_but_overridden_by_c_log2(f64 x) {
17752+ multi_return_f64_int mr_1442 = math__frexp(x);
17753+ f64 frac = mr_1442.arg0;
17754+ int expn = mr_1442.arg1;
17755+ if (frac == ((f64)(0.5))) {
17756+ return ((f64)(expn - 1));
17757+ }
17758+ return math__log(frac) * ((f64)(1.4426950408889634)) + ((f64)(expn));
17759+}
17760+f64 math__pure_v_but_overridden_by_c_log1p(f64 x) {
17761+ f64 y = ((f64)(1.0)) + x;
17762+ f64 z = y - ((f64)(1.0));
17763+ return math__log(y) - (z - x) / y;
17764+}
17765+f64 math__pure_v_but_overridden_by_c_log_b(f64 x) {
17766+ if (x == 0) {
17767+ return math__inf(-1);
17768+ }
17769+ if (math__is_inf(x, 0)) {
17770+ return math__inf(1);
17771+ }
17772+ if (math__is_nan(x)) {
17773+ return x;
17774+ }
17775+ return ((f64)(math__ilog_b_(x)));
17776+}
17777+int math__ilog_b(f64 x) {
17778+ if (x == 0) {
17779+ return ((int)(_const_min_i32));
17780+ }
17781+ if (math__is_nan(x)) {
17782+ return ((int)(_const_max_i32));
17783+ }
17784+ if (math__is_inf(x, 0)) {
17785+ return ((int)(_const_max_i32));
17786+ }
17787+ return math__ilog_b_(x);
17788+}
17789+VV_LOC int math__ilog_b_(f64 x_) {
17790+ multi_return_f64_int mr_2548 = math__normalize(x_);
17791+ f64 x = mr_2548.arg0;
17792+ int expn = mr_2548.arg1;
17793+ return ((int)(((v__rshift_u64(math__f64_bits(x), (u64)52)) & 0x7FF))) - 1023 + expn;
17794+}
17795+f64 math__pure_v_but_overridden_by_c_log(f64 a) {
17796+ f64 ln2_hi = 6.93147180369123816490e-01;
17797+ f64 ln2_lo = 1.90821492927058770002e-10;
17798+ f64 l1 = 6.666666666666735130e-01;
17799+ f64 l2 = 3.999999999940941908e-01;
17800+ f64 l3 = 2.857142874366239149e-01;
17801+ f64 l4 = 2.222219843214978396e-01;
17802+ f64 l5 = 1.818357216161805012e-01;
17803+ f64 l6 = 1.531383769920937332e-01;
17804+ f64 l7 = 1.479819860511658591e-01;
17805+ f64 x = a;
17806+ if (math__is_nan(x) || math__is_inf(x, 1)) {
17807+ return x;
17808+ } else if (x < 0) {
17809+ return math__nan();
17810+ } else if (x == 0) {
17811+ return math__inf(-1);
17812+ }
17813+ multi_return_f64_int mr_5139 = math__frexp(x);
17814+ f64 f1 = mr_5139.arg0;
17815+ int ki = mr_5139.arg1;
17816+ if (f1 < ((f64)((float_literal)(1.41421356237309504880168872420969807856967187537694807317667974 / 2)))) {
17817+ f1 *= 2;
17818+ ki--;
17819+ }
17820+ f64 f = f1 - 1;
17821+ f64 k = ((f64)(ki));
17822+ f64 s = f / (2 + f);
17823+ f64 s2 = s * s;
17824+ f64 s4 = s2 * s2;
17825+ f64 t1 = s2 * (l1 + s4 * (l3 + s4 * (l5 + s4 * l7)));
17826+ f64 t2 = s4 * (l2 + s4 * (l4 + s4 * l6));
17827+ f64 r = t1 + t2;
17828+ f64 hfsq = ((f64)(0.5)) * f * f;
17829+ return k * ln2_hi - ((hfsq - (s * (hfsq + r) + k * ln2_lo)) - f);
17830+}
17831+#if 0
17832+#else
17833+#endif
17834+f64 math__aprox_sin(f64 a) {
17835+ f64 a0 = 1.91059300966915117e-31;
17836+ f64 a1 = 1.00086760103908896;
17837+ f64 a2 = -1.21276126894734565e-2;
17838+ f64 a3 = -1.38078780785773762e-1;
17839+ f64 a4 = -2.67353392911981221e-2;
17840+ f64 a5 = 2.08026600266304389e-2;
17841+ f64 a6 = -3.03996055049204407e-3;
17842+ f64 a7 = 1.38235642404333740e-4;
17843+ f64 tmp = a4 + a * (a5 + a * (a6 + a * a7));
17844+ return a0 + a * (a1 + a * (a2 + a * (a3 + a * tmp)));
17845+}
17846+f64 math__aprox_cos(f64 a) {
17847+ f64 a0 = 9.9995999154986614e-1;
17848+ f64 a1 = 1.2548995793001028e-3;
17849+ f64 a2 = -5.0648546280678015e-1;
17850+ f64 a3 = 1.2942246466519995e-2;
17851+ f64 a4 = 2.8668384702547972e-2;
17852+ f64 a5 = 7.3726485210586547e-3;
17853+ f64 a6 = -3.8510875386947414e-3;
17854+ f64 a7 = 4.7196604604366623e-4;
17855+ f64 a8 = -1.8776444013090451e-5;
17856+ f64 tmp = a4 + a * (a5 + a * (a6 + a * (a7 + a * a8)));
17857+ return a0 + a * (a1 + a * (a2 + a * (a3 + a * tmp)));
17858+}
17859+inline f64 math__copysign(f64 x, f64 y) {
17860+ return math__f64_from_bits((((math__f64_bits(x) & ~_const_math__sign_mask)) | ((math__f64_bits(y) & _const_math__sign_mask))));
17861+}
17862+inline f64 math__degrees(f64 radians) {
17863+ return radians * ((f64)(57.29577951308232));
17864+}
17865+inline f64 math__radians(f64 degrees) {
17866+ return degrees * ((f64)(0.017453292519943295));
17867+}
17868+inline f64 math__angle_diff(f64 radian_a, f64 radian_b) {
17869+ f64 delta = math__fmod(radian_b - radian_a, _const_math__tau);
17870+ delta = math__fmod(delta + ((f64)(9.42477796076938)), _const_math__tau);
17871+ delta -= 3.141592653589793;
17872+ return delta;
17873+}
17874+Array_int math__digits(i64 num, math__DigitParams params) {
17875+ int b = params.base;
17876+ if (b < 2) {
17877+ builtin__panic_n(_S("digits: Cannot find digits of n with base:"), b);
17878+ VUNREACHABLE();
17879+ }
17880+ i64 n = num;
17881+ int sgn = 1;
17882+ if (n < 0) {
17883+ sgn = -1;
17884+ n = -n;
17885+ }
17886+ Array_int res = builtin____new_array_with_default(0, 0, sizeof(int), 0);
17887+ if (n == 0) {
17888+ builtin__array_push((array*)&res, _MOV((int[]){ 0 }));
17889+ return res;
17890+ }
17891+ for (;;) {
17892+ if (!(n != 0)) break;
17893+ i64 next_n = (i64)(VSAFE_DIV_i64(n , b));
17894+ builtin__array_push((array*)&res, _MOV((int[]){ ((int)(n - (i64)(next_n * b))) }));
17895+ n = next_n;
17896+ }
17897+ if (sgn == -1) {
17898+ (*(int*)builtin__array_get(res, res.len - 1)) *= sgn;
17899+ }
17900+ if (params.reverse) {
17901+ res = builtin__array_reverse(res);
17902+ }
17903+ return res;
17904+}
17905+int math__count_digits(i64 number) {
17906+ i64 n = number;
17907+ if (n == 0) {
17908+ return 1;
17909+ }
17910+ int c = 0;
17911+ for (;;) {
17912+ if (!(n != 0)) break;
17913+ n = VSAFE_DIV_i64(n , 10);
17914+ c++;
17915+ }
17916+ return c;
17917+}
17918+multi_return_f64_f64 math__minmax(f64 a, f64 b) {
17919+ if (a < b) {
17920+ return (multi_return_f64_f64){.arg0=a, .arg1=b};
17921+ }
17922+ return (multi_return_f64_f64){.arg0=b, .arg1=a};
17923+}
17924+inline f64 math__clamp(f64 x, f64 a, f64 b) {
17925+ if (x < a) {
17926+ return a;
17927+ }
17928+ if (x > b) {
17929+ return b;
17930+ }
17931+ return x;
17932+}
17933+inline f64 math__sign(f64 n) {
17934+ if (math__is_nan(n)) {
17935+ return math__nan();
17936+ }
17937+ return math__copysign(1.0, n);
17938+}
17939+inline int math__signi(f64 n) {
17940+ return ((int)(math__copysign(1.0, n)));
17941+}
17942+inline bool math__signbit(f64 x) {
17943+ return (math__f64_bits(x) & _const_math__sign_mask) != 0;
17944+}
17945+bool math__tolerance(f64 actual, f64 expected, f64 tol) {
17946+ if (actual == expected) {
17947+ return true;
17948+ }
17949+ f64 d = actual - expected;
17950+ if (d < 0) {
17951+ d = -d;
17952+ }
17953+ f64 ee = tol;
17954+ if (expected != 0) {
17955+ ee *= expected;
17956+ if (ee < 0) {
17957+ ee = -ee;
17958+ }
17959+ }
17960+ return d < ee;
17961+}
17962+bool math__close(f64 actual, f64 expected) {
17963+ return math__tolerance(actual, expected, 1e-14);
17964+}
17965+bool math__veryclose(f64 actual, f64 expected) {
17966+ return math__tolerance(actual, expected, 4e-16);
17967+}
17968+bool math__alike(f64 a, f64 b) {
17969+ if ((math__f64_bits(a) & 0xFFFFFFFFFFFFFFFCULL) == (math__f64_bits(b) & 0xFFFFFFFFFFFFFFFCULL)) {
17970+ return true;
17971+ }
17972+ if (a == -0LL && b == 0) {
17973+ return true;
17974+ }
17975+ if (a == 0 && b == -0LL) {
17976+ return true;
17977+ }
17978+ if (math__is_nan(a) && math__is_nan(b)) {
17979+ return true;
17980+ }
17981+ if (a == b) {
17982+ return math__signbit(a) == math__signbit(b);
17983+ }
17984+ return false;
17985+}
17986+multi_return_f64_f64 math__modf(f64 f) {
17987+ f64 abs_f = math__abs_T_f64(f);
17988+ f64 i = 0.0;
17989+ if (abs_f >= ((f64)(_const_math__modf_maxpowtwo))) {
17990+ i = f;
17991+ } else {
17992+ i = abs_f + ((f64)(_const_math__modf_maxpowtwo));
17993+ i -= _const_math__modf_maxpowtwo;
17994+ for (;;) {
17995+ if (!(i > abs_f)) break;
17996+ i -= 1.0;
17997+ }
17998+ if (f < ((f64)(0.0))) {
17999+ i = -i;
18000+ }
18001+ }
18002+ return (multi_return_f64_f64){.arg0=i, .arg1=f - i};
18003+}
18004+f32 math__nextafter32(f32 x, f32 y) {
18005+ f32 r = ((f32)(0.0));
18006+ if (math__is_nan(((f64)(x))) || math__is_nan(((f64)(y)))) {
18007+ r = ((f32)(math__nan()));
18008+ } else if (x == y) {
18009+ r = x;
18010+ } else if (x == 0) {
18011+ r = ((f32)(math__copysign(((f64)(math__f32_from_bits(1))), ((f64)(y)))));
18012+ } else if ((y > x) == (x > 0)) {
18013+ r = math__f32_from_bits(math__f32_bits(x) + 1);
18014+ } else {
18015+ r = math__f32_from_bits(math__f32_bits(x) - 1);
18016+ }
18017+ return r;
18018+}
18019+f64 math__nextafter(f64 x, f64 y) {
18020+ f64 r = 0.0;
18021+ if (math__is_nan(x) || math__is_nan(y)) {
18022+ r = math__nan();
18023+ } else if (x == y) {
18024+ r = x;
18025+ } else if (x == 0) {
18026+ r = math__copysign(math__f64_from_bits(1), y);
18027+ } else if ((y > x) == (x > 0)) {
18028+ r = math__f64_from_bits(math__f64_bits(x) + 1);
18029+ } else {
18030+ r = math__f64_from_bits(math__f64_bits(x) - 1);
18031+ }
18032+ return r;
18033+}
18034+VV_LOC multi_return_f64_f64 math__ChebSeries_eval_e(math__ChebSeries cs, f64 x) {
18035+ f64 d = 0.0;
18036+ f64 dd = 0.0;
18037+ f64 y = (((f64)(2.0)) * x - cs.a - cs.b) / (cs.b - cs.a);
18038+ f64 y2 = ((f64)(2.0)) * y;
18039+ f64 e_ = 0.0;
18040+ f64 temp = 0.0;
18041+ for (int j = cs.order; j >= 1; j--) {
18042+ temp = d;
18043+ d = y2 * d - dd + (*(f64*)builtin__array_get(cs.c, j));
18044+ e_ += math__abs_T_f64(y2 * temp) + math__abs_T_f64(dd) + math__abs_T_f64((*(f64*)builtin__array_get(cs.c, j)));
18045+ dd = temp;
18046+ }
18047+ temp = d;
18048+ d = y * d - dd + ((f64)(0.5)) * (*(f64*)builtin__array_get(cs.c, 0));
18049+ e_ += math__abs_T_f64(y * temp) + math__abs_T_f64(dd) + ((f64)(0.5)) * math__abs_T_f64((*(f64*)builtin__array_get(cs.c, 0)));
18050+ return (multi_return_f64_f64){.arg0=d, .arg1=((f64)(_const_math__internal__f64_epsilon)) * e_ + math__abs_T_f64((*(f64*)builtin__array_get(cs.c, cs.order)))};
18051+}
18052+inline f64 math__pow(f64 x, f64 y) {
18053+ return pow(x, y);
18054+}
18055+inline f32 math__powf(f32 a, f32 b) {
18056+ return powf(a, b);
18057+}
18058+inline f32 math__pure_v_but_overridden_by_c_powf(f32 a, f32 b) {
18059+ return ((f32)(math__pow(a, b)));
18060+}
18061+f64 math__pow10(int n) {
18062+ if (0 <= n && n <= 308) {
18063+ return (*(f64*)builtin__array_get(_const_math__pow10postab32, VSAFE_DIV_u32(((u32)(n)) , 32))) * (*(f64*)builtin__array_get(_const_math__pow10tab, VSAFE_MOD_u32(((u32)(n)) , 32)));
18064+ }
18065+ if (-323 <= n && n <= 0) {
18066+ return (*(f64*)builtin__array_get(_const_math__pow10negtab32, VSAFE_DIV_u32(((u32)(-n)) , 32))) / (*(f64*)builtin__array_get(_const_math__pow10tab, VSAFE_MOD_u32(((u32)(-n)) , 32)));
18067+ }
18068+ if (n > 0) {
18069+ return math__inf(1);
18070+ }
18071+ return 0.0;
18072+}
18073+i64 math__powi(i64 a, i64 b) {
18074+ i64 b_ = b;
18075+ i64 p = a;
18076+ i64 v = ((i64)(1));
18077+ if (b_ < 0) {
18078+ if (a == 0) {
18079+ return -1;
18080+ }
18081+ return (a * a != 1 ? (0) : ((((b_ & 1)) > 0 ? (a) : (1))));
18082+ }
18083+ for (; b_ > 0; ) {
18084+ if ((b_ & 1) > 0) {
18085+ v *= p;
18086+ }
18087+ p *= p;
18088+ b_ = v__rshift_i64(b_, (u64)1);
18089+ }
18090+ return v;
18091+}
18092+VV_LOC bool math__is_odd_int(f64 x) {
18093+ multi_return_f64_f64 mr_1555 = math__modf(x);
18094+ f64 xi = mr_1555.arg0;
18095+ f64 xf = mr_1555.arg1;
18096+ return xf == 0 && ((((i64)(xi)) & 1)) == 1;
18097+}
18098+f64 math__pure_v_but_overridden_by_c_pow(f64 x, f64 y) {
18099+ if (y == 0 || x == 1) {
18100+ return 1;
18101+ } else if (y == 1) {
18102+ return x;
18103+ } else if (math__is_nan(x) || math__is_nan(y)) {
18104+ return math__nan();
18105+ } else if (y == 2) {
18106+ return x * x;
18107+ } else if (y == 3) {
18108+ return x * x * x;
18109+ } else if (x == 0) {
18110+ if (y < 0) {
18111+ if (math__is_odd_int(y)) {
18112+ return math__copysign(math__inf(1), x);
18113+ }
18114+ return math__inf(1);
18115+ } else if (y > 0) {
18116+ if (math__is_odd_int(y)) {
18117+ return x;
18118+ }
18119+ return 0;
18120+ }
18121+ } else if (math__is_inf(y, 0)) {
18122+ if (x == -1) {
18123+ return 1;
18124+ } else if ((math__abs_T_f64(x) < 1) == math__is_inf(y, 1)) {
18125+ return 0;
18126+ } else {
18127+ return math__inf(1);
18128+ }
18129+ } else if (math__is_inf(x, 0)) {
18130+ if (math__is_inf(x, -1)) {
18131+ return math__pow(1 / x, -y);
18132+ }
18133+ if (y < 0) {
18134+ return 0;
18135+ } else if (y > 0) {
18136+ return math__inf(1);
18137+ }
18138+ } else if (y == ((f64)(0.5))) {
18139+ return math__sqrt(x);
18140+ } else if (y == ((f64)(-0.5))) {
18141+ return 1 / math__sqrt(x);
18142+ }
18143+ multi_return_f64_f64 mr_2579 = math__modf(math__abs_T_f64(y));
18144+ f64 yi = mr_2579.arg0;
18145+ f64 yf = mr_2579.arg1;
18146+ if (yf != 0 && x < 0) {
18147+ return math__nan();
18148+ }
18149+ if (yi >= (v__lshift_u64(((u64)(1)), (u64)63))) {
18150+ if (x == -1) {
18151+ return 1;
18152+ } else if ((math__abs_T_f64(x) < 1) == (y > 0)) {
18153+ return 0;
18154+ } else {
18155+ return math__inf(1);
18156+ }
18157+ }
18158+ if (yf == ((f64)(0.0))) {
18159+ f64 result = x;
18160+ for (i64 _t22 = 1; _t22 < ((i64)(yi)); ++_t22) {
18161+ result *= x;
18162+ }
18163+ if (y > 0) {
18164+ return result;
18165+ }
18166+ return 1 / result;
18167+ }
18168+ f64 a1 = 1.0;
18169+ int ae = 0;
18170+ if (yf != 0) {
18171+ if (yf > ((f64)(0.5))) {
18172+ yf--;
18173+ yi++;
18174+ }
18175+ a1 = math__exp(yf * math__log(x));
18176+ }
18177+ multi_return_f64_int mr_3354 = math__frexp(x);
18178+ f64 x1 = mr_3354.arg0;
18179+ int xe = mr_3354.arg1;
18180+ for (i64 i = ((i64)(yi)); i != 0; i = v__rshift_i64(i, (u64)1)) {
18181+ if (xe < ((int)(((u32)(v__lshift_u32(((u32)(-1)), (u64)12))))) || 4096 < xe) {
18182+ ae += xe;
18183+ break;
18184+ }
18185+ if ((i & 1) == 1) {
18186+ a1 *= x1;
18187+ ae += xe;
18188+ }
18189+ x1 *= x1;
18190+ xe = v__lshift_int(xe, (u64)1);
18191+ if (x1 < ((f64)(.5))) {
18192+ x1 += x1;
18193+ xe--;
18194+ }
18195+ }
18196+ if (y < 0) {
18197+ a1 = 1 / a1;
18198+ ae = -ae;
18199+ }
18200+ return math__ldexp(a1, ae);
18201+}
18202+inline f64 math__q_rsqrt(f64 x) {
18203+ f64 x_half = ((f64)(0.5)) * x;
18204+ i64 i = ((i64)(math__f64_bits(x)));
18205+ i = 0x5fe6eb50c7b537a9LL - (v__rshift_i64(i, (u64)1));
18206+ f64 j = math__f64_from_bits(((u64)(i)));
18207+ j *= (((f64)(1.5)) - x_half * j * j);
18208+ j *= (((f64)(1.5)) - x_half * j * j);
18209+ return j;
18210+}
18211+f64 math__scalbn(f64 x, int n_) {
18212+ int n = n_;
18213+ f64 x1p1023 = math__f64_from_bits(((u64)(0x7fe0000000000000LL)));
18214+ f64 x1p53 = math__f64_from_bits(((u64)(0x4340000000000000LL)));
18215+ f64 x1p_1022 = math__f64_from_bits(((u64)(0x0010000000000000LL)));
18216+ f64 y = x;
18217+ if (n > 1023) {
18218+ y *= x1p1023;
18219+ n -= 1023;
18220+ if (n > 1023) {
18221+ y *= x1p1023;
18222+ n -= 1023;
18223+ if (n > 1023) {
18224+ n = 1023;
18225+ }
18226+ }
18227+ } else if (n < -1022) {
18228+ y *= x1p_1022 * x1p53;
18229+ n += 969;
18230+ if (n < -1022) {
18231+ y *= x1p_1022 * x1p53;
18232+ n += 969;
18233+ if (n < -1022) {
18234+ n = -1022;
18235+ }
18236+ }
18237+ }
18238+ return y * math__f64_from_bits(v__lshift_u64(((u64)((0x3ff + n))), (u64)52));
18239+}
18240+inline f64 math__cos(f64 a) {
18241+ return cos(a);
18242+}
18243+inline f64 math__sin(f64 a) {
18244+ return sin(a);
18245+}
18246+inline f32 math__cosf(f32 a) {
18247+ return cosf(a);
18248+}
18249+inline f32 math__sinf(f32 a) {
18250+ return sinf(a);
18251+}
18252+f64 math__pure_v_but_overridden_by_c_sin(f64 x) {
18253+ f64 p1 = 7.85398125648498535156e-1;
18254+ f64 p2 = 3.77489470793079817668e-8;
18255+ f64 p3 = 2.69515142907905952645e-15;
18256+ int sgn_x = (x < 0 ? (-1) : (1));
18257+ f64 abs_x = math__abs_T_f64(x);
18258+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18259+ f64 x2 = x * x;
18260+ return x * (((f64)(1.0)) - x2 / ((f64)(6.0)));
18261+ } else {
18262+ int sgn_result = sgn_x;
18263+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18264+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18265+ if (((octant & 1)) == 1) {
18266+ octant++;
18267+ octant &= 7;
18268+ y += 1.0;
18269+ }
18270+ if (octant > 3) {
18271+ octant -= 4;
18272+ sgn_result = -sgn_result;
18273+ }
18274+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18275+ f64 result = 0.0;
18276+ if (octant == 0) {
18277+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18278+ multi_return_f64_f64 mr_1722 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18279+ f64 sin_cs_val = mr_1722.arg0;
18280+ result = z * (((f64)(1.0)) + z * z * sin_cs_val);
18281+ } else {
18282+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18283+ multi_return_f64_f64 mr_1845 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18284+ f64 cos_cs_val = mr_1845.arg0;
18285+ result = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18286+ }
18287+ result *= sgn_result;
18288+ return result;
18289+ }
18290+ return 0;
18291+}
18292+f64 math__pure_v_but_overridden_by_c_cos(f64 x) {
18293+ f64 p1 = 7.85398125648498535156e-1;
18294+ f64 p2 = 3.77489470793079817668e-8;
18295+ f64 p3 = 2.69515142907905952645e-15;
18296+ f64 abs_x = math__abs_T_f64(x);
18297+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18298+ f64 x2 = x * x;
18299+ return ((f64)(1.0)) - ((f64)(0.5)) * x2;
18300+ } else {
18301+ int sgn_result = 1;
18302+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18303+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18304+ if (((octant & 1)) == 1) {
18305+ octant++;
18306+ octant &= 7;
18307+ y += 1.0;
18308+ }
18309+ if (octant > 3) {
18310+ octant -= 4;
18311+ sgn_result = -sgn_result;
18312+ }
18313+ if (octant > 1) {
18314+ sgn_result = -sgn_result;
18315+ }
18316+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18317+ f64 result = 0.0;
18318+ if (octant == 0) {
18319+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18320+ multi_return_f64_f64 mr_2686 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18321+ f64 cos_cs_val = mr_2686.arg0;
18322+ result = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18323+ } else {
18324+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18325+ multi_return_f64_f64 mr_2825 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18326+ f64 sin_cs_val = mr_2825.arg0;
18327+ result = z * (((f64)(1.0)) + z * z * sin_cs_val);
18328+ }
18329+ result *= sgn_result;
18330+ return result;
18331+ }
18332+ return 0;
18333+}
18334+inline f32 math__pure_v_but_overridden_by_c_cosf(f32 a) {
18335+ return ((f32)(math__cos(a)));
18336+}
18337+inline f32 math__pure_v_but_overridden_by_c_sinf(f32 a) {
18338+ return ((f32)(math__sin(a)));
18339+}
18340+multi_return_f64_f64 math__sincos(f64 x) {
18341+ if (math__is_nan(x)) {
18342+ return (multi_return_f64_f64){.arg0=x, .arg1=x};
18343+ }
18344+ f64 p1 = 7.85398125648498535156e-1;
18345+ f64 p2 = 3.77489470793079817668e-8;
18346+ f64 p3 = 2.69515142907905952645e-15;
18347+ int sgn_x = (x < 0 ? (-1) : (1));
18348+ f64 abs_x = math__abs_T_f64(x);
18349+ if (math__is_inf(x, sgn_x)) {
18350+ return (multi_return_f64_f64){.arg0=math__nan(), .arg1=math__nan()};
18351+ }
18352+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18353+ f64 x2 = x * x;
18354+ return (multi_return_f64_f64){.arg0=x * (((f64)(1.0)) - x2 / ((f64)(6.0))), .arg1=((f64)(1.0)) - ((f64)(0.5)) * x2};
18355+ } else {
18356+ int sgn_result_sin = sgn_x;
18357+ int sgn_result_cos = 1;
18358+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18359+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18360+ if (((octant & 1)) == 1) {
18361+ octant++;
18362+ octant &= 7;
18363+ y += 1.0;
18364+ }
18365+ if (octant > 3) {
18366+ octant -= 4;
18367+ sgn_result_sin = -sgn_result_sin;
18368+ sgn_result_cos = -sgn_result_cos;
18369+ }
18370+ sgn_result_cos = (octant > 1 ? (-sgn_result_cos) : (sgn_result_cos));
18371+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18372+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18373+ multi_return_f64_f64 mr_4085 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18374+ f64 sin_cs_val = mr_4085.arg0;
18375+ multi_return_f64_f64 mr_4121 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18376+ f64 cos_cs_val = mr_4121.arg0;
18377+ f64 result_sin = 0.0;
18378+ f64 result_cos = 0.0;
18379+ if (octant == 0) {
18380+ result_sin = z * (((f64)(1.0)) + z * z * sin_cs_val);
18381+ result_cos = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18382+ } else {
18383+ result_sin = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18384+ result_cos = z * (((f64)(1.0)) + z * z * sin_cs_val);
18385+ }
18386+ result_sin *= sgn_result_sin;
18387+ result_cos *= sgn_result_cos;
18388+ return (multi_return_f64_f64){.arg0=result_sin, .arg1=result_cos};
18389+ }
18390+ return (multi_return_f64_f64){0};
18391+}
18392+f64 math__sinh(f64 x_) {
18393+ f64 x = x_;
18394+ f64 p0 = -0.6307673640497716991184787251e+6;
18395+ f64 p1 = -0.8991272022039509355398013511e+5;
18396+ f64 p2 = -0.2894211355989563807284660366e+4;
18397+ f64 p3 = -0.2630563213397497062819489e+2;
18398+ f64 q0 = -0.6307673640497716991212077277e+6;
18399+ f64 q1 = 0.1521517378790019070696485176e+5;
18400+ f64 q2 = -0.173678953558233699533450911e+3;
18401+ bool neg = false;
18402+ if (x < 0) {
18403+ x = -x;
18404+ neg = true;
18405+ }
18406+ f64 temp = 0.0;
18407+ if (x > 21) {
18408+ temp = math__exp(x) * ((f64)(0.5));
18409+ } else if (x > ((f64)(0.5))) {
18410+ f64 ex = math__exp(x);
18411+ temp = (ex - ((f64)(1.0)) / ex) * ((f64)(0.5));
18412+ } else {
18413+ f64 sq = x * x;
18414+ temp = (((p3 * sq + p2) * sq + p1) * sq + p0) * x;
18415+ temp = temp / (((sq + q2) * sq + q1) * sq + q0);
18416+ }
18417+ if (neg) {
18418+ temp = -temp;
18419+ }
18420+ return temp;
18421+}
18422+f64 math__cosh(f64 x) {
18423+ f64 abs_x = math__abs_T_f64(x);
18424+ if (abs_x > 21) {
18425+ return math__exp(abs_x) * ((f64)(0.5));
18426+ }
18427+ f64 ex = math__exp(abs_x);
18428+ return (ex + ((f64)(1.0)) / ex) * ((f64)(0.5));
18429+}
18430+inline f64 math__sqrt(f64 a) {
18431+ return sqrt(a);
18432+}
18433+inline f32 math__sqrtf(f32 a) {
18434+ return sqrtf(a);
18435+}
18436+inline f64 math__pure_v_but_overridden_by_c_sqrt(f64 a) {
18437+ f64 x = a;
18438+ if (x == ((f64)(0.0)) || math__is_nan(x) || math__is_inf(x, 1)) {
18439+ return x;
18440+ }
18441+ if (x < ((f64)(0.0))) {
18442+ return math__nan();
18443+ }
18444+ multi_return_f64_int mr_259 = math__frexp(x);
18445+ f64 z = mr_259.arg0;
18446+ int ex = mr_259.arg1;
18447+ f64 w = x;
18448+ x = ((f64)(4.173075996388649989089e-1)) + ((f64)(5.9016206709064458299663e-1)) * z;
18449+ if (((ex & 1)) != 0) {
18450+ x *= _const_math__sqrt2;
18451+ }
18452+ x = math__ldexp(x, v__rshift_int(ex, (u64)1));
18453+ x = ((f64)(0.5)) * (x + w / x);
18454+ x = ((f64)(0.5)) * (x + w / x);
18455+ x = ((f64)(0.5)) * (x + w / x);
18456+ return x;
18457+}
18458+inline f32 math__pure_v_but_overridden_by_c_sqrtf(f32 a) {
18459+ return ((f32)(math__sqrt(a)));
18460+}
18461+i64 math__sqrti(i64 a) {
18462+ i64 x = a;
18463+ i64 q = ((i64)(1));
18464+ i64 r = ((i64)(0));
18465+ for (; q <= x; ) {
18466+ q = v__lshift_i64(q, (u64)2);
18467+ }
18468+ for (; q > 1; ) {
18469+ q = v__rshift_i64(q, (u64)2);
18470+ i64 t = x - r - q;
18471+ r = v__rshift_i64(r, (u64)1);
18472+ if (t >= 0) {
18473+ x = t;
18474+ r += q;
18475+ }
18476+ }
18477+ return r;
18478+}
18479+inline f32 math__tanf(f32 a) {
18480+ return tanf(a);
18481+}
18482+f64 math__tan(f64 a) {
18483+ f64 x = a;
18484+ if (x == ((f64)(0.0)) || math__is_nan(x)) {
18485+ return x;
18486+ }
18487+ if (math__is_inf(x, 0)) {
18488+ return math__nan();
18489+ }
18490+ int sgn = 1;
18491+ if (x < 0) {
18492+ x = -x;
18493+ sgn = -1;
18494+ }
18495+ if (x > ((f64)(_const_math__tan_lossth))) {
18496+ return 0.0;
18497+ }
18498+ f64 y = math__floor(x * ((f64)(4.0)) / ((f64)(_const_math__pi)));
18499+ f64 z = math__ldexp(y, -3);
18500+ z = math__floor(z);
18501+ z = y - math__ldexp(z, 3);
18502+ int octant = ((int)(z));
18503+ if (((octant & 1)) == 1) {
18504+ octant++;
18505+ y += 1.0;
18506+ }
18507+ z = ((x - y * ((f64)(_const_math__tan_dp1))) - y * ((f64)(_const_math__tan_dp2))) - y * ((f64)(_const_math__tan_dp3));
18508+ f64 zz = z * z;
18509+ if (zz > ((f64)(1.0e-14))) {
18510+ y = z + z * (zz * ((((*(f64*)builtin__array_get(_const_math__tan_p, 0)) * zz) + (*(f64*)builtin__array_get(_const_math__tan_p, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_p, 2))) / ((((zz + (*(f64*)builtin__array_get(_const_math__tan_q, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 2))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 3))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 4))));
18511+ } else {
18512+ y = z;
18513+ }
18514+ if (((octant & 2)) == 2) {
18515+ y = ((f64)(-1.0)) / y;
18516+ }
18517+ if (sgn < 0) {
18518+ y = -y;
18519+ }
18520+ return y;
18521+}
18522+inline f32 math__pure_v_but_overridden_by_c_tanf(f32 a) {
18523+ return ((f32)(math__tan(a)));
18524+}
18525+f64 math__cot(f64 a) {
18526+ f64 x = a;
18527+ if (x == ((f64)(0.0))) {
18528+ return math__inf(1);
18529+ }
18530+ int sgn = 1;
18531+ if (x < 0) {
18532+ x = -x;
18533+ sgn = -1;
18534+ }
18535+ if (x > ((f64)(_const_math__tan_lossth))) {
18536+ return 0.0;
18537+ }
18538+ f64 y = math__floor(x * ((f64)(4.0)) / ((f64)(_const_math__pi)));
18539+ f64 z = math__ldexp(y, -3);
18540+ z = math__floor(z);
18541+ z = y - math__ldexp(z, 3);
18542+ int octant = ((int)(z));
18543+ if (((octant & 1)) == 1) {
18544+ octant++;
18545+ y += 1.0;
18546+ }
18547+ z = ((x - y * ((f64)(_const_math__tan_dp1))) - y * ((f64)(_const_math__tan_dp2))) - y * ((f64)(_const_math__tan_dp3));
18548+ f64 zz = z * z;
18549+ if (zz > ((f64)(1.0e-14))) {
18550+ y = z + z * (zz * ((((*(f64*)builtin__array_get(_const_math__tan_p, 0)) * zz) + (*(f64*)builtin__array_get(_const_math__tan_p, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_p, 2))) / ((((zz + (*(f64*)builtin__array_get(_const_math__tan_q, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 2))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 3))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 4))));
18551+ } else {
18552+ y = z;
18553+ }
18554+ if (((octant & 2)) == 2) {
18555+ y = -y;
18556+ } else {
18557+ y = ((f64)(1.0)) / y;
18558+ }
18559+ if (sgn < 0) {
18560+ y = -y;
18561+ }
18562+ return y;
18563+}
18564+f64 math__tanh(f64 x) {
18565+ f64 maxlog = 8.8029691931113054295988e+01;
18566+ f64 z = math__abs_T_f64(x);
18567+ if (z > ((f64)(0.5)) * maxlog) {
18568+ if (x < 0) {
18569+ return ((f64)(-1));
18570+ }
18571+ return 1.0;
18572+ } else if (z >= ((f64)(0.625))) {
18573+ f64 s = math__exp(((f64)(2.0)) * z);
18574+ z = ((f64)(1.0)) - ((f64)(2.0)) / (s + ((f64)(1.0)));
18575+ if (x < 0) {
18576+ z = -z;
18577+ }
18578+ } else {
18579+ if (x == 0) {
18580+ return x;
18581+ }
18582+ f64 s = x * x;
18583+ z = x + x * s * (((*(f64*)builtin__array_get(_const_math__tanh_p, 0)) * s + (*(f64*)builtin__array_get(_const_math__tanh_p, 1))) * s + (*(f64*)builtin__array_get(_const_math__tanh_p, 2))) / (((s + (*(f64*)builtin__array_get(_const_math__tanh_q, 0))) * s + (*(f64*)builtin__array_get(_const_math__tanh_q, 1))) * s + (*(f64*)builtin__array_get(_const_math__tanh_q, 2)));
18584+ }
18585+ return z;
18586+}
18587+inline u32 math__f32_bits(f32 f) {
18588+ #if defined(__TINYC__)
18589+ {
18590+ return *((u32*)(&f));
18591+ }
18592+ #endif
18593+ return ((math__U32_F32){.f = f,}).u;
18594+}
18595+inline f32 math__f32_from_bits(u32 b) {
18596+ #if defined(__TINYC__)
18597+ {
18598+ return *((f32*)(&b));
18599+ }
18600+ #endif
18601+ return ((math__U32_F32){.u = b,}).f;
18602+}
18603+inline u64 math__f64_bits(f64 f) {
18604+ #if defined(__TINYC__)
18605+ {
18606+ return *((u64*)(&f));
18607+ }
18608+ #endif
18609+ return ((math__U64_F64){.f = f,}).u;
18610+}
18611+inline f64 math__f64_from_bits(u64 b) {
18612+ #if defined(__TINYC__)
18613+ {
18614+ return *((f64*)(&b));
18615+ }
18616+ #endif
18617+ return ((math__U64_F64){.u = b,}).f;
18618+}
18619+inline f64 math__with_set_low_word(f64 f, u32 lo) {
18620+ u64 tmp = math__f64_bits(f);
18621+ tmp &= 0xffffffff00000000ULL;
18622+ tmp |= ((u64)(lo));
18623+ return math__f64_from_bits(tmp);
18624+}
18625+inline f64 math__with_set_high_word(f64 f, u32 hi) {
18626+ u64 tmp = math__f64_bits(f);
18627+ tmp &= 0x00000000ffffffffU;
18628+ tmp |= v__lshift_u64(((u64)(hi)), (u64)32);
18629+ return math__f64_from_bits(tmp);
18630+}
18631+inline u32 math__get_high_word(f64 f) {
18632+ return ((u32)(v__rshift_u64(math__f64_bits(f), (u64)32)));
18633+}
18634+VV_LOC void main__vf_init(void) {
18635+ string probe = _S("vf");
18636+ {int _ = probe.len;}
18637+ ;
18638+}
18639+// export alias: vf_init -> main__vf_init
18640+void vf_init(void) {
18641+ return main__vf_init();
18642+}
18643+VV_LOC int main__vf_add(int a, int b) {
18644+ return a + b;
18645+}
18646+// export alias: vf_add -> main__vf_add
18647+int vf_add(int a, int b) {
18648+ return main__vf_add(a, b);
18649+}
18650+VV_LOC char* main__vf_greet(char* name) {
18651+ string n = builtin__cstring_to_vstring(name);
18652+ string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")}));
18653+ u8* out = res.str;
18654+ builtin__string_free(&n);
18655+ return out;
18656+}
18657+// export alias: vf_greet -> main__vf_greet
18658+char* vf_greet(char* name) {
18659+ return main__vf_greet(name);
18660+}
18661+VV_LOC void main__vf_free(voidptr p) {
18662+ builtin___v_free(p);
18663+}
18664+// export alias: vf_free -> main__vf_free
18665+void vf_free(voidptr p) {
18666+ return main__vf_free(p);
18667+}
18668+VV_LOC void main__vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1) {
18669+ if (w <= 0 || h <= 0 || max_iter <= 0) {
18670+ return;
18671+ }
18672+ f64 aspect = ((f64)(w)) / ((f64)(h));
18673+ f64 inv_w = ((f64)(1.0)) / ((f64)(w));
18674+ f64 inv_h = ((f64)(1.0)) / ((f64)(h));
18675+ for (int y = y0; y < y1; y++) {
18676+ f64 im = cy + (((f64)(y)) * inv_h - ((f64)(0.5))) * scale;
18677+ int row = (y - y0) * w * 4;
18678+ for (int x = 0; x < w; x++) {
18679+ f64 re = cx + (((f64)(x)) * inv_w - ((f64)(0.5))) * scale * aspect;
18680+ f64 zr = 0.0;
18681+ f64 zi = 0.0;
18682+ f64 zr2 = 0.0;
18683+ f64 zi2 = 0.0;
18684+ int i = 0;
18685+ for (;;) {
18686+ if (!(i < max_iter)) break;
18687+ zr2 = zr * zr;
18688+ zi2 = zi * zi;
18689+ if (zr2 + zi2 > ((f64)(4.0))) {
18690+ break;
18691+ }
18692+ zi = ((f64)(2.0)) * zr * zi + im;
18693+ zr = zr2 - zi2 + re;
18694+ i++;
18695+ }
18696+ int idx = row + x * 4;
18697+ if (i >= max_iter) {
18698+ { // Unsafe block
18699+ buf[idx] = ((u8)(0));
18700+ buf[idx + 1] = ((u8)(0));
18701+ buf[idx + 2] = ((u8)(0));
18702+ buf[idx + 3] = ((u8)(255));
18703+ }
18704+ continue;
18705+ }
18706+ f64 mag = math__sqrt(zr2 + zi2);
18707+ f64 nu = ((f64)(i));
18708+ if (mag > ((f64)(1.0))) {
18709+ nu = ((f64)(i)) + ((f64)(1.0)) - math__log(math__log(mag) / math__log(2.0)) / math__log(2.0);
18710+ }
18711+ f64 t = nu / ((f64)(max_iter));
18712+ { // Unsafe block
18713+ buf[idx] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(3.0)) + t * ((f64)(18.0))))));
18714+ buf[idx + 1] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(3.6)) + t * ((f64)(18.0))))));
18715+ buf[idx + 2] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(4.2)) + t * ((f64)(18.0))))));
18716+ buf[idx + 3] = ((u8)(255));
18717+ }
18718+ }
18719+ }
18720+}
18721+// export alias: vf_mandelbrot -> main__vf_mandelbrot
18722+void vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1) {
18723+ return main__vf_mandelbrot(buf, w, h, cx, cy, scale, max_iter, y0, y1);
18724+}
18725+VV_LOC void main__main(void) {
18726+}
18727+inline f64 math__abs_T_f64(f64 a) {
18728+ return (a < 0 ? (-a) : (a));
18729+}
18730+void _vinit(int ___argc, voidptr ___argv) {
18731+ static bool once = false; if (once) {return;} once = true;
18732+ // Initializations of consts for module builtin.closure
18733+ g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3
18734+{
18735+{
18736+Array_fixed_u8_15 _t1;
18737+#if defined(__V_ppc64le)
18738+#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
18739+#elif defined(__V_amd64)
18740+ { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ;
18741+ memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15));
18742+ }
18743+ ;
18744+#elif defined(__V_x86)
18745+#elif defined(__V_arm64)
18746+#elif defined(__V_arm32)
18747+#elif defined(__V_rv64)
18748+#elif defined(__V_rv32)
18749+#elif defined(__V_s390x)
18750+#elif defined(__V_loongarch64)
18751+#elif defined(__V_sparc64)
18752+#elif 0
18753+#else
18754+#endif
18755+ memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15));
18756+}
18757+}
18758+{
18759+{
18760+Array_fixed_u8_6 _t3;
18761+#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
18762+#elif defined(__V_arm32)
18763+#elif defined(__V_amd64)
18764+ { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ;
18765+ memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6));
1651818766 }
1651918767 ;
1652018768 #elif defined(__V_x86)
@@ -16561,6 +18809,121 @@ Array_fixed_u8_6 _t3;
1656118809 _const_min_i64 = ((i64)(-9223372036854775807LL - 1));
1656218810 _const_max_i64 = ((i64)(9223372036854775807LL));
1656318811 _const_utf8_replacement_rune = ((rune)(0xfffd));
18812+ // Initializations of consts for module math
18813+{
18814+ _const_math__bernoulli = builtin__new_array_from_c_array(10, 10, sizeof(f64), _MOV((f64[10]){
18815+ 0.08333333333333333, -0.002777777777777778, 0.0007936507936507937, -0.0005952380952380953, 0.0008417508417508417, -0.0019175269175269176, 0.00641025641025641, -0.029550653594771242, 0.1800957401386015,
18816+ -1.3924322169059011}));
18817+}
18818+{
18819+ _const_math__factorials_table = builtin__new_array_from_c_array(171, 171, sizeof(f64), _MOV((f64[171]){
18820+ 1.000000000000000000000e+0, 1.000000000000000000000e+0, 2.000000000000000000000e+0, 6.000000000000000000000e+0, 2.400000000000000000000e+1, 1.200000000000000000000e+2, 7.200000000000000000000e+2, 5.040000000000000000000e+3, 4.032000000000000000000e+4,
18821+ 3.628800000000000000000e+5, 3.628800000000000000000e+6, 3.991680000000000000000e+7, 4.790016000000000000000e+8, 6.227020800000000000000e+9, 8.717829120000000000000e+10, 1.307674368000000000000e+12, 2.092278988800000000000e+13,
18822+ 3.556874280960000000000e+14, 6.402373705728000000000e+15, 1.216451004088320000000e+17, 2.432902008176640000000e+18, 5.109094217170944000000e+19, 1.124000727777607680000e+21, 2.585201673888497664000e+22, 6.204484017332394393600e+23,
18823+ 1.551121004333098598400e+25, 4.032914611266056355840e+26, 1.088886945041835216077e+28, 3.048883446117138605015e+29, 8.841761993739701954544e+30, 2.652528598121910586363e+32, 8.222838654177922817726e+33, 2.631308369336935301672e+35,
18824+ 8.683317618811886495518e+36, 2.952327990396041408476e+38, 1.033314796638614492967e+40, 3.719933267899012174680e+41, 1.376375309122634504632e+43, 5.230226174666011117600e+44, 2.039788208119744335864e+46, 8.159152832478977343456e+47,
18825+ 3.345252661316380710817e+49, 1.405006117752879898543e+51, 6.041526306337383563736e+52, 2.658271574788448768044e+54, 1.196222208654801945620e+56, 5.502622159812088949850e+57, 2.586232415111681806430e+59, 1.241391559253607267086e+61,
18826+ 6.082818640342675608723e+62, 3.041409320171337804361e+64, 1.551118753287382280224e+66, 8.065817517094387857166e+67, 4.274883284060025564298e+69, 2.308436973392413804721e+71, 1.269640335365827592597e+73, 7.109985878048634518540e+74,
18827+ 4.052691950487721675568e+76, 2.350561331282878571829e+78, 1.386831185456898357379e+80, 8.320987112741390144276e+81, 5.075802138772247988009e+83, 3.146997326038793752565e+85, 1.982608315404440064116e+87, 1.268869321858841641034e+89,
18828+ 8.247650592082470666723e+90, 5.443449390774430640037e+92, 3.647111091818868528825e+94, 2.480035542436830599601e+96, 1.711224524281413113725e+98, 1.197857166996989179607e+100, 8.504785885678623175212e+101, 6.123445837688608686152e+103,
18829+ 4.470115461512684340891e+105, 3.307885441519386412260e+107, 2.480914081139539809195e+109, 1.885494701666050254988e+111, 1.451830920282858696341e+113, 1.132428117820629783146e+115, 8.946182130782975286851e+116, 7.156945704626380229481e+118,
18830+ 5.797126020747367985880e+120, 4.753643337012841748421e+122, 3.945523969720658651190e+124, 3.314240134565353266999e+126, 2.817104114380550276949e+128, 2.422709538367273238177e+130, 2.107757298379527717214e+132, 1.854826422573984391148e+134,
18831+ 1.650795516090846108122e+136, 1.485715964481761497310e+138, 1.352001527678402962552e+140, 1.243841405464130725548e+142, 1.156772507081641574759e+144, 1.087366156656743080274e+146, 1.032997848823905926260e+148, 9.916779348709496892096e+149,
18832+ 9.619275968248211985333e+151, 9.426890448883247745626e+153, 9.332621544394415268170e+155, 9.332621544394415268170e+157, 9.425947759838359420852e+159, 9.614466715035126609269e+161, 9.902900716486180407547e+163, 1.029901674514562762385e+166,
18833+ 1.081396758240290900504e+168, 1.146280563734708354534e+170, 1.226520203196137939352e+172, 1.324641819451828974500e+174, 1.443859583202493582205e+176, 1.588245541522742940425e+178, 1.762952551090244663872e+180, 1.974506857221074023537e+182,
18834+ 2.231192748659813646597e+184, 2.543559733472187557120e+186, 2.925093693493015690688e+188, 3.393108684451898201198e+190, 3.969937160808720895402e+192, 4.684525849754290656574e+194, 5.574585761207605881323e+196, 6.689502913449127057588e+198,
18835+ 8.094298525273443739682e+200, 9.875044200833601362412e+202, 1.214630436702532967577e+205, 1.506141741511140879795e+207, 1.882677176888926099744e+209, 2.372173242880046885677e+211, 3.012660018457659544810e+213, 3.856204823625804217357e+215,
18836+ 4.974504222477287440390e+217, 6.466855489220473672507e+219, 8.471580690878820510985e+221, 1.118248651196004307450e+224, 1.487270706090685728908e+226, 1.992942746161518876737e+228, 2.690472707318050483595e+230, 3.659042881952548657690e+232,
18837+ 5.012888748274991661035e+234, 6.917786472619488492228e+236, 9.615723196941089004197e+238, 1.346201247571752460588e+241, 1.898143759076170969429e+243, 2.695364137888162776589e+245, 3.854370717180072770522e+247, 5.550293832739304789551e+249,
18838+ 8.047926057471991944849e+251, 1.174997204390910823948e+254, 1.727245890454638911203e+256, 2.556323917872865588581e+258, 3.808922637630569726986e+260, 5.713383956445854590479e+262, 8.627209774233240431623e+264, 1.311335885683452545607e+267,
18839+ 2.006343905095682394778e+269, 3.089769613847350887959e+271, 4.789142901463393876336e+273, 7.471062926282894447084e+275, 1.172956879426414428192e+278, 1.853271869493734796544e+280, 2.946702272495038326504e+282, 4.714723635992061322407e+284,
18840+ 7.590705053947218729075e+286, 1.229694218739449434110e+289, 2.004401576545302577600e+291, 3.287218585534296227263e+293, 5.423910666131588774984e+295, 9.003691705778437366474e+297, 1.503616514864999040201e+300, 2.526075744973198387538e+302,
18841+ 4.269068009004705274939e+304, 7.257415615307998967397e+306}));
18842+}
18843+{
18844+ _const_math__log_factorials_table = builtin__new_array_from_c_array(172, 172, sizeof(f64), _MOV((f64[172]){
18845+ 0.000000000000000000000e+0, 0.000000000000000000000e+0, 6.931471805599453094172e-1, 1.791759469228055000812e+0, 3.178053830347945619647e+0, 4.787491742782045994248e+0, 6.579251212010100995060e+0, 8.525161361065414300166e+0, 1.060460290274525022842e+1,
18846+ 1.280182748008146961121e+1, 1.510441257307551529523e+1, 1.750230784587388583929e+1, 1.998721449566188614952e+1, 2.255216385312342288557e+1, 2.519122118273868150009e+1, 2.789927138384089156609e+1, 3.067186010608067280376e+1,
18847+ 3.350507345013688888401e+1, 3.639544520803305357622e+1, 3.933988418719949403622e+1, 4.233561646075348502966e+1, 4.538013889847690802616e+1, 4.847118135183522387964e+1, 5.160667556776437357045e+1, 5.478472939811231919009e+1,
18848+ 5.800360522298051993929e+1, 6.126170176100200198477e+1, 6.455753862700633105895e+1, 6.788974313718153498289e+1, 7.125703896716800901007e+1, 7.465823634883016438549e+1, 7.809222355331531063142e+1, 8.155795945611503717850e+1,
18849+ 8.505446701758151741396e+1, 8.858082754219767880363e+1, 9.213617560368709248333e+1, 9.571969454214320248496e+1, 9.933061245478742692933e+1, 1.029681986145138126988e+2, 1.066317602606434591262e+2, 1.103206397147573954291e+2,
18850+ 1.140342117814617032329e+2, 1.177718813997450715388e+2, 1.215330815154386339623e+2, 1.253172711493568951252e+2, 1.291239336391272148826e+2, 1.329525750356163098828e+2, 1.368027226373263684696e+2, 1.406739236482342593987e+2,
18851+ 1.445657439463448860089e+2, 1.484777669517730320675e+2, 1.524095925844973578392e+2, 1.563608363030787851941e+2, 1.603311282166309070282e+2, 1.643201122631951814118e+2, 1.683274454484276523305e+2, 1.723527971391628015638e+2,
18852+ 1.763958484069973517152e+2, 1.804562914175437710518e+2, 1.845338288614494905025e+2, 1.886281734236715911873e+2, 1.927390472878449024360e+2, 1.968661816728899939914e+2, 2.010093163992815266793e+2, 2.051681994826411985358e+2,
18853+ 2.093425867525368356464e+2, 2.135322414945632611913e+2, 2.177369341139542272510e+2, 2.219564418191303339501e+2, 2.261905483237275933323e+2, 2.304390435657769523214e+2, 2.347017234428182677427e+2, 2.389783895618343230538e+2,
18854+ 2.432688490029827141829e+2, 2.475729140961868839366e+2, 2.518904022097231943772e+2, 2.562211355500095254561e+2, 2.605649409718632093053e+2, 2.649216497985528010421e+2, 2.692910976510198225363e+2, 2.736731242856937041486e+2,
18855+ 2.780675734403661429141e+2, 2.824742926876303960274e+2, 2.868931332954269939509e+2, 2.913239500942703075662e+2, 2.957666013507606240211e+2, 3.002209486470141317540e+2, 3.046868567656687154726e+2, 3.091641935801469219449e+2,
18856+ 3.136528299498790617832e+2, 3.181526396202093268500e+2, 3.226634991267261768912e+2, 3.271852877037752172008e+2, 3.317178871969284731381e+2, 3.362611819791984770344e+2, 3.408150588707990178690e+2, 3.453794070622668541074e+2,
18857+ 3.499541180407702369296e+2, 3.545390855194408088492e+2, 3.591342053695753987760e+2, 3.637393755555634901441e+2, 3.683544960724047495950e+2, 3.729794688856890206760e+2, 3.776141978739186564468e+2, 3.822585887730600291111e+2,
18858+ 3.869125491232175524822e+2, 3.915759882173296196258e+2, 3.962488170517915257991e+2, 4.009309482789157454921e+2, 4.056222961611448891925e+2, 4.103227765269373054205e+2, 4.150323067282496395563e+2, 4.197508055995447340991e+2,
18859+ 4.244781934182570746677e+2, 4.292143918666515701285e+2, 4.339593239950148201939e+2, 4.387129141861211848399e+2, 4.434750881209189409588e+2, 4.482457727453846057188e+2, 4.530248962384961351041e+2, 4.578123879812781810984e+2,
18860+ 4.626081785268749221865e+2, 4.674121995716081787447e+2, 4.722243839269805962399e+2, 4.770446654925856331047e+2, 4.818729792298879342285e+2, 4.867092611368394122258e+2, 4.915534482232980034989e+2, 4.964054784872176206648e+2,
18861+ 5.012652908915792927797e+2, 5.061328253420348751997e+2, 5.110080226652360267439e+2, 5.158908245878223975982e+2, 5.207811737160441513633e+2, 5.256790135159950627324e+2, 5.305842882944334921812e+2, 5.354969431801695441897e+2,
18862+ 5.404169241059976691050e+2, 5.453441777911548737966e+2, 5.502786517242855655538e+2, 5.552202941468948698523e+2, 5.601690540372730381305e+2, 5.651248810948742988613e+2, 5.700877257251342061414e+2, 5.750575390247102067619e+2,
18863+ 5.800342727671307811636e+2, 5.850178793888391176022e+2, 5.900083119756178539038e+2, 5.950055242493819689670e+2, 6.000094705553274281080e+2, 6.050201058494236838580e+2, 6.100373856862386081868e+2, 6.150612662070848845750e+2,
18864+ 6.200917041284773200381e+2, 6.251286567308909491967e+2, 6.301720818478101958172e+2, 6.352219378550597328635e+2, 6.402781836604080409209e+2, 6.453407786934350077245e+2, 6.504096828956552392500e+2, 6.554848567108890661717e+2,
18865+ 6.605662610758735291676e+2, 6.656538574111059132426e+2, 6.707476076119126755767e+2, 6.758474740397368739994e+2, 6.809534195136374546094e+2, 6.860654073019939978423e+2, 6.911834011144107529496e+2, 6.963073650938140118743e+2,
18866+ 7.014372638087370853465e+2, 7.065730622457873471107e+2, 7.117147258022900069535e+2}));
18867+}
18868+ _const_math__gamma_p = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){1.60119522476751861407e-04, 1.19135147006586384913e-03, 1.04213797561761569935e-02, 4.76367800457137231464e-02, 2.07448227648435975150e-01, 4.94214826801497100753e-01, 9.99999999999999996796e-01}));
18869+ _const_math__gamma_q = builtin__new_array_from_c_array(8, 8, sizeof(f64), _MOV((f64[8]){-2.31581873324120129819e-05, 5.39605580493303397842e-04, -4.45641913851797240494e-03, 1.18139785222060435552e-02, 3.58236398605498653373e-02, -2.34591795718243348568e-01, 7.14304917030273074085e-02, 1.00000000000000000320e+00}));
18870+ _const_math__gamma_s = builtin__new_array_from_c_array(5, 5, sizeof(f64), _MOV((f64[5]){7.87311395793093628397e-04, -2.29549961613378126380e-04, -2.68132617805781232825e-03, 3.47222221605458667310e-03, 8.33333333333482257126e-02}));
18871+{
18872+ _const_math__lgamma_a = builtin__new_array_from_c_array(12, 12, sizeof(f64), _MOV((f64[12]){
18873+ 7.72156649015328655494e-02, 3.22467033424113591611e-01, 6.73523010531292681824e-02, 2.05808084325167332806e-02, 7.38555086081402883957e-03, 2.89051383673415629091e-03, 1.19270763183362067845e-03, 5.10069792153511336608e-04, 2.20862790713908385557e-04,
18874+ 1.08011567247583939954e-04, 2.52144565451257326939e-05, 4.48640949618915160150e-05}));
18875+}
18876+ _const_math__lgamma_r = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){1.0, 1.39200533467621045958e+00, 7.21935547567138069525e-01, 1.71933865632803078993e-01, 1.86459191715652901344e-02, 7.77942496381893596434e-04, 7.32668430744625636189e-06}));
18877+ _const_math__lgamma_s = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){-7.72156649015328655494e-02, 2.14982415960608852501e-01, 3.25778796408930981787e-01, 1.46350472652464452805e-01, 2.66422703033638609560e-02, 1.84028451407337715652e-03, 3.19475326584100867617e-05}));
18878+{
18879+ _const_math__lgamma_t = builtin__new_array_from_c_array(15, 15, sizeof(f64), _MOV((f64[15]){
18880+ 4.83836122723810047042e-01, -1.47587722994593911752e-01, 6.46249402391333854778e-02, -3.27885410759859649565e-02, 1.79706750811820387126e-02, -1.03142241298341437450e-02, 6.10053870246291332635e-03, -3.68452016781138256760e-03, 2.25964780900612472250e-03,
18881+ -1.40346469989232843813e-03, 8.81081882437654011382e-04, -5.38595305356740546715e-04, 3.15632070903625950361e-04, -3.12754168375120860518e-04, 3.35529192635519073543e-04}));
18882+}
18883+ _const_math__lgamma_u = builtin__new_array_from_c_array(6, 6, sizeof(f64), _MOV((f64[6]){-7.72156649015328655494e-02, 6.32827064025093366517e-01, 1.45492250137234768737e+00, 9.77717527963372745603e-01, 2.28963728064692451092e-01, 1.33810918536787660377e-02}));
18884+ _const_math__lgamma_v = builtin__new_array_from_c_array(6, 6, sizeof(f64), _MOV((f64[6]){1.0, 2.45597793713041134822e+00, 2.12848976379893395361e+00, 7.69285150456672783825e-01, 1.04222645593369134254e-01, 3.21709242282423911810e-03}));
18885+ _const_math__lgamma_w = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){4.18938533204672725052e-01, 8.33333333333329678849e-02, -2.77777777728775536470e-03, 7.93650558643019558500e-04, -5.95187557450339963135e-04, 8.36339918996282139126e-04, -1.63092934096575273989e-03}));
18886+{
18887+ _const_math__pow10tab = builtin__new_array_from_c_array(32, 32, sizeof(f64), _MOV((f64[32]){
18888+ ((f64)(1e+00)), 1e+01, 1e+02, 1e+03, 1e+04, 1e+05, 1e+06, 1e+07, 1e+08,
18889+ 1e+09, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16,
18890+ 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24,
18891+ 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31}));
18892+}
18893+{
18894+ _const_math__pow10postab32 = builtin__new_array_from_c_array(10, 10, sizeof(f64), _MOV((f64[10]){
18895+ ((f64)(1e+00)), 1e+32, 1e+64, 1e+96, 1e+128, 1e+160, 1e+192, 1e+224, 1e+256,
18896+ 1e+288}));
18897+}
18898+{
18899+ _const_math__pow10negtab32 = builtin__new_array_from_c_array(11, 11, sizeof(f64), _MOV((f64[11]){
18900+ ((f64)(1e-00)), 1e-32, 1e-64, 1e-96, 1e-128, 1e-160, 1e-192, 1e-224, 1e-256,
18901+ 1e-288, 1e-320}));
18902+}
18903+{
18904+ _const_math__sin_data = builtin__new_array_from_c_array(12, 12, sizeof(f64), _MOV((f64[12]){
18905+ -0.3295190160663511504173, 0.0025374284671667991990, 0.0006261928782647355874, -4.6495547521854042157541e-06, -5.6917531549379706526677e-07, 3.7283335140973803627866e-09, 3.0267376484747473727186e-10, -1.7400875016436622322022e-12, -1.0554678305790849834462e-13,
18906+ 5.3701981409132410797062e-16, 2.5984137983099020336115e-17, -1.1821555255364833468288e-19}));
18907+}
18908+{
18909+ _const_math__cos_data = builtin__new_array_from_c_array(11, 11, sizeof(f64), _MOV((f64[11]){
18910+ 0.165391825637921473505668118136, -0.00084852883845000173671196530195, -0.000210086507222940730213625768083, 1.16582269619760204299639757584e-6, 1.43319375856259870334412701165e-7, -7.4770883429007141617951330184e-10, -6.0969994944584252706997438007e-11, 2.90748249201909353949854872638e-13, 1.77126739876261435667156490461e-14,
18911+ -7.6896421502815579078577263149e-17, -3.7363121133079412079201377318e-18}));
18912+}
18913+ _const_math__tan_p = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){-1.30936939181383777646e+4, 1.15351664838587416140e+6, -1.79565251976484877988e+7}));
18914+ _const_math__tan_q = builtin__new_array_from_c_array(5, 5, sizeof(f64), _MOV((f64[5]){1.00000000000000000000e+0, 1.36812963470692954678e+4, -1.32089234440210967447e+6, 2.50083801823357915839e+7, -5.38695755929454629881e+7}));
18915+ _const_math__tanh_p = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){-9.64399179425052238628e-1, -9.92877231001918586564e+1, -1.61468768441708447952e+3}));
18916+ _const_math__tanh_q = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){1.12811678491632931402e+2, 2.23548839060100448583e+3, 4.84406305325125486048e+3}));
18917+{
18918+{
18919+ _const_math__sin_cs = ((math__ChebSeries){.c = _const_math__sin_data,.order = 11,.a = -1,.b = 1,});
18920+}
18921+}
18922+{
18923+{
18924+ _const_math__cos_cs = ((math__ChebSeries){.c = _const_math__cos_data,.order = 10,.a = -1,.b = 1,});
18925+}
18926+}
1656418927 }
1656518928 void _vcleanup(void) {
1656618929 static bool once = false; if (once) {return;} once = true;
@@ -7,8 +7,9 @@
7 7
8 // V comptime_definitions:8 // V comptime_definitions:
9 // V compile time defines by -d or -define flags:9 // V compile time defines by -d or -define flags:
10-// All custom defines : linux10+// All custom defines : no_backtrace,linux
11-// Turned ON custom defines: linux11+// Turned ON custom defines: no_backtrace,linux
12+#define CUSTOM_DEFINE_no_backtrace
12 #define CUSTOM_DEFINE_linux13 #define CUSTOM_DEFINE_linux
13 14
14 15
@@ -20,6 +21,7 @@ typedef struct none none;
20 typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11;21 typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11;
21 typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11;22 typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11;
22 typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128;23 typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128;
24+typedef struct _v_Array_fixed_f64_4 _v_Array_fixed_f64_4;
23 typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32;25 typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32;
24 typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64;26 typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64;
25 typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5;27 typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5;
@@ -40,8 +42,6 @@ typedef struct _v_Array_fixed_u64_47 _v_Array_fixed_u64_47;
40 typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31;42 typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31;
41 typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64;43 typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64;
42 typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64;44 typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64;
43-typedef struct _v_Array_fixed_voidptr_100 _v_Array_fixed_voidptr_100;
44-typedef struct _v_Array_fixed_u8_1000 _v_Array_fixed_u8_1000;
45 typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17;45 typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17;
46 typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264;46 typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264;
47 typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10;47 typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10;
@@ -60,8 +60,10 @@ typedef struct multi_return_u64_int multi_return_u64_int;
60 typedef struct multi_return_i64_int multi_return_i64_int;60 typedef struct multi_return_i64_int multi_return_i64_int;
61 typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool;61 typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool;
62 typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool;62 typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool;
63-typedef struct multi_return_u64_u64 multi_return_u64_u64;
64 typedef struct multi_return_f64_int multi_return_f64_int;63 typedef struct multi_return_f64_int multi_return_f64_int;
64+typedef struct multi_return_i64_i64_i64 multi_return_i64_i64_i64;
65+typedef struct multi_return_f64_f64 multi_return_f64_f64;
66+typedef struct multi_return_u64_u64 multi_return_u64_u64;
65 // END_multi_return_typedefs67 // END_multi_return_typedefs
66 68
67 typedef struct strings__IndentParam strings__IndentParam;69 typedef struct strings__IndentParam strings__IndentParam;
@@ -106,6 +108,12 @@ typedef struct RunesIterator RunesIterator;
106 typedef union StrIntpMem StrIntpMem;108 typedef union StrIntpMem StrIntpMem;
107 typedef struct StrIntpData StrIntpData;109 typedef struct StrIntpData StrIntpData;
108 typedef struct ToWideConfig ToWideConfig;110 typedef struct ToWideConfig ToWideConfig;
111+typedef struct math__BezierPoint math__BezierPoint;
112+typedef struct math__DigitParams math__DigitParams;
113+typedef struct math__DivResult math__DivResult;
114+typedef struct math__ChebSeries math__ChebSeries;
115+typedef union math__U32_F32 math__U32_F32;
116+typedef union math__U64_F64 math__U64_F64;
109 typedef struct _result_int _result_int;117 typedef struct _result_int _result_int;
110 typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr;118 typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr;
111 typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken;119 typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken;
@@ -124,9 +132,9 @@ typedef struct _result_rune _result_rune;
124 typedef struct _result_string _result_string;132 typedef struct _result_string _result_string;
125 typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo;133 typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo;
126 typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr;134 typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr;
127-typedef struct _option_int _option_int;
128 typedef struct _option_rune _option_rune;135 typedef struct _option_rune _option_rune;
129 typedef struct _option_multi_return_string_string _option_multi_return_string_string;136 typedef struct _option_multi_return_string_string _option_multi_return_string_string;
137+typedef struct _option_int _option_int;
130 typedef struct _option_u8 _option_u8;138 typedef struct _option_u8 _option_u8;
131 139
132 // V preincludes:140 // V preincludes:
@@ -1479,6 +1487,23 @@ V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) {
1479 #endif1487 #endif
1480 #endif1488 #endif
1481 1489
1490+
1491+// added by module `math`, file: math.c.v:6:
1492+
1493+#ifdef __TINYC__
1494+#include <math.h>
1495+#else
1496+#if defined(__has_include)
1497+#if __has_include(<math.h>)
1498+#include <math.h>
1499+#else
1500+#error VERROR_MESSAGE Header file <math.h>, needed for module `math` was not found. Please install the corresponding development headers.
1501+#endif
1502+#else
1503+#include <math.h>
1504+#endif
1505+#endif
1506+
1482 #if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool)1507 #if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool)
1483 #ifdef bool1508 #ifdef bool
1484 #undef bool1509 #undef bool
@@ -1516,9 +1541,20 @@ typedef u8 bool;
1516 #define _const_rune_maps_utl -21541 #define _const_rune_maps_utl -2
1517 #define _const_degree 61542 #define _const_degree 6
1518 #define _const_mid_index 51543 #define _const_mid_index 5
1519-#define _const_max_len 11
1520 #define _const_replace_stack_buffer_size 101544 #define _const_replace_stack_buffer_size 10
1521 #define _const_kmp_stack_buffer_size 201545 #define _const_kmp_stack_buffer_size 20
1546+#define _const_math__internal__max_int_fact_arg 170
1547+#define _const_math__shift 52
1548+#define _const_math__bias 1023
1549+#define _const_math__pi_2 1.5707963267948966
1550+#define _const_math__pi_4 0.7853981633974483
1551+#define _const_math__one_over_tau 0.15915494309189535
1552+#define _const_math__one_over_pi 0.3183098861837907
1553+#define _const_math__tau_over2 3.141592653589793
1554+#define _const_math__tau_over4 1.5707963267948966
1555+#define _const_math__tau_over8 0.7853981633974483
1556+#define _const_math__log2_e 1.4426950408889634
1557+#define _const_math__log10_e 0.43429448190325176
1522 1558
1523 // Enum definitions:1559 // Enum definitions:
1524 1560
@@ -1722,6 +1758,9 @@ typedef array Array_builtin__closure__ClosureLifetimeFrame;
1722 typedef map Map_voidptr_builtin__closure__ClosureLiveInfo;1758 typedef map Map_voidptr_builtin__closure__ClosureLiveInfo;
1723 typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr;1759 typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr;
1724 typedef u8 Array_fixed_u8_128 [128];1760 typedef u8 Array_fixed_u8_128 [128];
1761+typedef array Array_f64;
1762+typedef array Array_math__BezierPoint;
1763+typedef f64 Array_fixed_f64_4 [4];
1725 typedef u8 Array_fixed_u8_32 [32];1764 typedef u8 Array_fixed_u8_32 [32];
1726 typedef u8 Array_fixed_u8_64 [64];1765 typedef u8 Array_fixed_u8_64 [64];
1727 typedef u8 Array_fixed_u8_5 [5];1766 typedef u8 Array_fixed_u8_5 [5];
@@ -1742,8 +1781,6 @@ typedef u64 Array_fixed_u64_47 [47];
1742 typedef u64 Array_fixed_u64_31 [31];1781 typedef u64 Array_fixed_u64_31 [31];
1743 typedef int Array_fixed_int_64 [64];1782 typedef int Array_fixed_int_64 [64];
1744 typedef voidptr Array_fixed_voidptr_64 [64];1783 typedef voidptr Array_fixed_voidptr_64 [64];
1745-typedef voidptr Array_fixed_voidptr_100 [100];
1746-typedef u8 Array_fixed_u8_1000 [1000];
1747 typedef array Array_GraphemeBreakProperty;1784 typedef array Array_GraphemeBreakProperty;
1748 typedef u8 Array_fixed_u8_17 [17];1785 typedef u8 Array_fixed_u8_17 [17];
1749 typedef i32 Array_fixed_i32_1264 [1264];1786 typedef i32 Array_fixed_i32_1264 [1264];
@@ -1964,6 +2001,33 @@ struct builtin__closure__FrameToken {
1964 u64 generation;2001 u64 generation;
1965 };2002 };
1966 2003
2004+struct math__BezierPoint {
2005+ f64 x;
2006+ f64 y;
2007+};
2008+
2009+struct math__DigitParams {
2010+ int base;
2011+ bool reverse;
2012+};
2013+
2014+struct math__ChebSeries {
2015+ Array_f64 c;
2016+ int order;
2017+ f64 a;
2018+ f64 b;
2019+};
2020+
2021+union math__U32_F32 {
2022+ u32 u;
2023+ f32 f;
2024+};
2025+
2026+union math__U64_F64 {
2027+ u64 u;
2028+ f64 f;
2029+};
2030+
1967 struct mapnode {2031 struct mapnode {
1968 voidptr* children;2032 voidptr* children;
1969 int len;2033 int len;
@@ -2011,6 +2075,9 @@ struct _v_Array_fixed_voidptr_11 {
2011 struct _v_Array_fixed_u8_128 {2075 struct _v_Array_fixed_u8_128 {
2012 u8 ret_arr[128];2076 u8 ret_arr[128];
2013 };2077 };
2078+struct _v_Array_fixed_f64_4 {
2079+ f64 ret_arr[4];
2080+};
2014 struct _v_Array_fixed_u8_32 {2081 struct _v_Array_fixed_u8_32 {
2015 u8 ret_arr[32];2082 u8 ret_arr[32];
2016 };2083 };
@@ -2071,12 +2138,6 @@ struct _v_Array_fixed_int_64 {
2071 struct _v_Array_fixed_voidptr_64 {2138 struct _v_Array_fixed_voidptr_64 {
2072 voidptr ret_arr[64];2139 voidptr ret_arr[64];
2073 };2140 };
2074-struct _v_Array_fixed_voidptr_100 {
2075- voidptr ret_arr[100];
2076-};
2077-struct _v_Array_fixed_u8_1000 {
2078- u8 ret_arr[1000];
2079-};
2080 struct _v_Array_fixed_u8_17 {2141 struct _v_Array_fixed_u8_17 {
2081 u8 ret_arr[17];2142 u8 ret_arr[17];
2082 };2143 };
@@ -2144,16 +2205,27 @@ struct multi_return_strconv__Dec64_bool {
2144 bool arg1;2205 bool arg1;
2145 };2206 };
2146 2207
2147-struct multi_return_u64_u64 {
2148- u64 arg0;
2149- u64 arg1;
2150-};
2151-
2152 struct multi_return_f64_int {2208 struct multi_return_f64_int {
2153 f64 arg0;2209 f64 arg0;
2154 int arg1;2210 int arg1;
2155 };2211 };
2156 2212
2213+struct multi_return_i64_i64_i64 {
2214+ i64 arg0;
2215+ i64 arg1;
2216+ i64 arg2;
2217+};
2218+
2219+struct multi_return_f64_f64 {
2220+ f64 arg0;
2221+ f64 arg1;
2222+};
2223+
2224+struct multi_return_u64_u64 {
2225+ u64 arg0;
2226+ u64 arg1;
2227+};
2228+
2157 // END_multi_return_structs2229 // END_multi_return_structs
2158 2230
2159 static bool Array_u8_contains(Array_u8 a, u8 v);2231 static bool Array_u8_contains(Array_u8 a, u8 v);
@@ -2171,12 +2243,6 @@ struct _option_builtin__closure__ClosureLifetimeState_ptr {
2171 byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1];2243 byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1];
2172 };2244 };
2173 2245
2174-struct _option_int {
2175- byte state;
2176- IError err;
2177- byte data[sizeof(int) > 1 ? sizeof(int) : 1];
2178-};
2179-
2180 struct _option_rune {2246 struct _option_rune {
2181 byte state;2247 byte state;
2182 IError err;2248 IError err;
@@ -2189,6 +2255,12 @@ struct _option_multi_return_string_string {
2189 byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1];2255 byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1];
2190 };2256 };
2191 2257
2258+struct _option_int {
2259+ byte state;
2260+ IError err;
2261+ byte data[sizeof(int) > 1 ? sizeof(int) : 1];
2262+};
2263+
2192 struct _option_u8 {2264 struct _option_u8 {
2193 byte state;2265 byte state;
2194 IError err;2266 IError err;
@@ -2660,15 +2732,7 @@ VV_LOC void builtin__autostr_addr_push(voidptr addr);
2660 VV_LOC void builtin__autostr_addr_pop(void);2732 VV_LOC void builtin__autostr_addr_pop(void);
2661 VV_LOC string builtin__autostr_array_circular(int len);2733 VV_LOC string builtin__autostr_array_circular(int len);
2662 void builtin__print_backtrace(void);2734 void builtin__print_backtrace(void);
2663-VV_LOC string builtin__demangle_v_symbol(string cname);
2664-VV_LOC Array_string builtin__split_generic_params(string s);
2665-VV_LOC string builtin__demangle_backtrace_sym(string s);
2666-VV_LOC void builtin__eprint_space_padding(string output, int max_len);
2667 bool builtin__print_backtrace_skipping_top_frames(int xskipframes);2735 bool builtin__print_backtrace_skipping_top_frames(int xskipframes);
2668-VV_LOC string builtin__backtrace_current_executable_name(void);
2669-VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name);
2670-VV_LOC string builtin__backtrace_shell_quote(string s);
2671-VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes);
2672 void builtin___v_exit(int code);2736 void builtin___v_exit(int code);
2673 _result_void builtin__at_exit(void (*cb)());2737 _result_void builtin__at_exit(void (*cb)());
2674 VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number);2738 VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number);
@@ -3113,6 +3177,134 @@ void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_);
3113 void builtin__ArrayFlags_clear_all(ArrayFlags* e);3177 void builtin__ArrayFlags_clear_all(ArrayFlags* e);
3114 void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_);3178 void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_);
3115 ArrayFlags builtin__ArrayFlags__static__zero(void);3179 ArrayFlags builtin__ArrayFlags__static__zero(void);
3180+f64 math__inf(int sign);
3181+f64 math__nan(void);
3182+bool math__is_nan(f64 f);
3183+bool math__is_inf(f64 f, int sign);
3184+bool math__is_finite(f64 f);
3185+multi_return_f64_int math__normalize(f64 x);
3186+f64 math__cbrt(f64 a);
3187+f64 math__mod(f64 x, f64 y);
3188+f64 math__fmod(f64 x, f64 y);
3189+i64 math__gcd(i64 a_, i64 b_);
3190+multi_return_i64_i64_i64 math__egcd(i64 a, i64 b);
3191+i64 math__lcm(i64 a, i64 b);
3192+f64 math__erf(f64 a);
3193+f64 math__erfc(f64 a);
3194+f64 math__exp(f64 x);
3195+f64 math__exp2(f64 x);
3196+f64 math__ldexp(f64 frac, int exp);
3197+f64 math__pure_v_but_overridden_by_c_exp(f64 x);
3198+f64 math__pure_v_but_overridden_by_c_exp2(f64 x);
3199+f64 math__pure_v_but_overridden_by_c_ldexp(f64 frac, int exp);
3200+multi_return_f64_int math__frexp(f64 x);
3201+f64 math__expm1(f64 x);
3202+VV_LOC f64 math__expmulti(f64 hi, f64 lo, int k);
3203+f64 math__factorial(f64 n);
3204+f64 math__log_factorial(f64 n);
3205+VV_LOC f64 math__log_factorial_asymptotic_expansion(int n);
3206+i64 math__factoriali(int n);
3207+f64 math__floor(f64 x);
3208+f32 math__floorf(f32 x);
3209+f64 math__ceil(f64 x);
3210+f64 math__trunc(f64 x);
3211+f64 math__round(f64 x);
3212+f64 math__round_sig(f64 x, int sig_digits);
3213+f64 math__round_to_even(f64 x);
3214+VV_LOC u64 math__safe_shift(u64 value, u64 shift);
3215+VV_LOC bool math__is_neg_int(f64 x);
3216+VV_LOC multi_return_f64_f64 math__stirling(f64 x);
3217+f64 math__gamma(f64 a);
3218+VV_LOC f64 math__gamma_too_small(f64 x, f64 z);
3219+f64 math__log_gamma(f64 x);
3220+multi_return_f64_int math__log_gamma_sign(f64 a);
3221+VV_LOC f64 math__sin_pi(f64 x_);
3222+f64 math__hypot(f64 x, f64 y);
3223+math__BezierPoint math__cubic_bezier(f64 t, Array_math__BezierPoint p);
3224+math__BezierPoint math__cubic_bezier_a(f64 t, Array_f64 x, Array_f64 y);
3225+math__BezierPoint math__cubic_bezier_fa(f64 t, Array_fixed_f64_4 x, Array_fixed_f64_4 y);
3226+math__BezierPoint math__cubic_bezier_coords(f64 t, f64 x0, f64 x1, f64 x2, f64 x3, f64 y0, f64 y1, f64 y2, f64 y3);
3227+f64 math__acosh(f64 x);
3228+f64 math__asinh(f64 x);
3229+f64 math__atanh(f64 x);
3230+VV_LOC f64 math__xatan(f64 x);
3231+VV_LOC f64 math__satan(f64 x);
3232+f64 math__atan(f64 x);
3233+f64 math__atan2(f64 y, f64 x);
3234+f64 math__asin(f64 x_);
3235+f64 math__acos(f64 x);
3236+f64 math__log(f64 x);
3237+f64 math__log2(f64 x);
3238+f64 math__log10(f64 x);
3239+f64 math__log1p(f64 x);
3240+f64 math__log_b(f64 x);
3241+f32 math__logf(f32 x);
3242+f64 math__log_n(f64 x, f64 b);
3243+f64 math__pure_v_but_overridden_by_c_log10(f64 x);
3244+f64 math__pure_v_but_overridden_by_c_log2(f64 x);
3245+f64 math__pure_v_but_overridden_by_c_log1p(f64 x);
3246+f64 math__pure_v_but_overridden_by_c_log_b(f64 x);
3247+int math__ilog_b(f64 x);
3248+VV_LOC int math__ilog_b_(f64 x_);
3249+f64 math__pure_v_but_overridden_by_c_log(f64 a);
3250+f64 math__aprox_sin(f64 a);
3251+f64 math__aprox_cos(f64 a);
3252+f64 math__copysign(f64 x, f64 y);
3253+f64 math__degrees(f64 radians);
3254+f64 math__radians(f64 degrees);
3255+f64 math__angle_diff(f64 radian_a, f64 radian_b);
3256+Array_int math__digits(i64 num, math__DigitParams params);
3257+int math__count_digits(i64 number);
3258+multi_return_f64_f64 math__minmax(f64 a, f64 b);
3259+f64 math__clamp(f64 x, f64 a, f64 b);
3260+f64 math__sign(f64 n);
3261+int math__signi(f64 n);
3262+bool math__signbit(f64 x);
3263+bool math__tolerance(f64 actual, f64 expected, f64 tol);
3264+bool math__close(f64 actual, f64 expected);
3265+bool math__veryclose(f64 actual, f64 expected);
3266+bool math__alike(f64 a, f64 b);
3267+multi_return_f64_f64 math__modf(f64 f);
3268+f32 math__nextafter32(f32 x, f32 y);
3269+f64 math__nextafter(f64 x, f64 y);
3270+VV_LOC multi_return_f64_f64 math__ChebSeries_eval_e(math__ChebSeries cs, f64 x);
3271+f64 math__pow(f64 x, f64 y);
3272+f32 math__powf(f32 a, f32 b);
3273+f32 math__pure_v_but_overridden_by_c_powf(f32 a, f32 b);
3274+f64 math__pow10(int n);
3275+i64 math__powi(i64 a, i64 b);
3276+VV_LOC bool math__is_odd_int(f64 x);
3277+f64 math__pure_v_but_overridden_by_c_pow(f64 x, f64 y);
3278+f64 math__q_rsqrt(f64 x);
3279+f64 math__scalbn(f64 x, int n_);
3280+f64 math__cos(f64 a);
3281+f64 math__sin(f64 a);
3282+f32 math__cosf(f32 a);
3283+f32 math__sinf(f32 a);
3284+f64 math__pure_v_but_overridden_by_c_sin(f64 x);
3285+f64 math__pure_v_but_overridden_by_c_cos(f64 x);
3286+f32 math__pure_v_but_overridden_by_c_cosf(f32 a);
3287+f32 math__pure_v_but_overridden_by_c_sinf(f32 a);
3288+multi_return_f64_f64 math__sincos(f64 x);
3289+f64 math__sinh(f64 x_);
3290+f64 math__cosh(f64 x);
3291+f64 math__sqrt(f64 a);
3292+f32 math__sqrtf(f32 a);
3293+f64 math__pure_v_but_overridden_by_c_sqrt(f64 a);
3294+f32 math__pure_v_but_overridden_by_c_sqrtf(f32 a);
3295+i64 math__sqrti(i64 a);
3296+f32 math__tanf(f32 a);
3297+f64 math__tan(f64 a);
3298+f32 math__pure_v_but_overridden_by_c_tanf(f32 a);
3299+f64 math__cot(f64 a);
3300+f64 math__tanh(f64 x);
3301+u32 math__f32_bits(f32 f);
3302+f32 math__f32_from_bits(u32 b);
3303+u64 math__f64_bits(f64 f);
3304+f64 math__f64_from_bits(u64 b);
3305+f64 math__with_set_low_word(f64 f, u32 lo);
3306+f64 math__with_set_high_word(f64 f, u32 hi);
3307+u32 math__get_high_word(f64 f);
3116 VV_LOC void main__vf_init(void);3308 VV_LOC void main__vf_init(void);
3117 VV_EXP void vf_init(void); // exported fn main.vf_init3309 VV_EXP void vf_init(void); // exported fn main.vf_init
3118 VV_LOC int main__vf_add(int a, int b);3310 VV_LOC int main__vf_add(int a, int b);
@@ -3121,7 +3313,10 @@ VV_LOC char* main__vf_greet(char* name);
3121 VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet3313 VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet
3122 VV_LOC void main__vf_free(voidptr p);3314 VV_LOC void main__vf_free(voidptr p);
3123 VV_EXP void vf_free(voidptr p); // exported fn main.vf_free3315 VV_EXP void vf_free(voidptr p); // exported fn main.vf_free
3316+VV_LOC void main__vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1);
3317+VV_EXP void vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1); // exported fn main.vf_mandelbrot
3124 VV_LOC void main__main(void);3318 VV_LOC void main__main(void);
3319+f64 math__abs_T_f64(f64 a);
3125 static bool Array_rune_arr_eq(Array_rune a, Array_rune b);3320 static bool Array_rune_arr_eq(Array_rune a, Array_rune b);
3126 static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b);3321 static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b);
3127 static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b);3322 static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b);
@@ -3489,11 +3684,182 @@ static Array_fixed_i32_1264 _const_rune_maps = {((i32)(0xB5)), 0xB5, 743, 0, 0xC
3489 static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed23684 static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed2
3490 static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed23685 static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed2
3491 static rune _const_utf8_replacement_rune; // inited later3686 static rune _const_utf8_replacement_rune; // inited later
3687+static const f64 _const_math__internal__f64_epsilon = 2.220446049250313e-16; // precomputed2
3688+static const f64 _const_math__internal__sqrt_f64_epsilon = 1.4901161193847656e-08; // precomputed2
3689+static const f64 _const_math__internal__root3_f64_epsilon = 6.055454452393343e-06; // precomputed2
3690+static const f64 _const_math__internal__root4_f64_epsilon = 0.0001220703125; // precomputed2
3691+static const f64 _const_math__internal__root5_f64_epsilon = 0.000740095979741405; // precomputed2
3692+static const f64 _const_math__internal__root6_f64_epsilon = 0.002460783300575925; // precomputed2
3693+static const f64 _const_math__internal__log_f64_epsilon = -36.04365338911715; // precomputed2
3694+static const f64 _const_math__internal__f64_min = 2.2250738585072014e-308; // precomputed2
3695+static const f64 _const_math__internal__sqrt_f64_min = 1.4916681462400413e-154; // precomputed2
3696+static const f64 _const_math__internal__root3_f64_min = 2.8126442852362996e-103; // precomputed2
3697+static const f64 _const_math__internal__root4_f64_min = 1.221338669755462e-77; // precomputed2
3698+static const f64 _const_math__internal__root5_f64_min = 2.9476022969691763e-62; // precomputed2
3699+static const f64 _const_math__internal__root6_f64_min = 5.303436890579822e-52; // precomputed2
3700+static const f64 _const_math__internal__log_f64_min = -708.3964185322641; // precomputed2
3701+static const f64 _const_math__internal__f64_max = 1.7976931348623157e+308; // precomputed2
3702+static const f64 _const_math__internal__sqrt_f64_max = 1.3407807929942596e+154; // precomputed2
3703+static const f64 _const_math__internal__root3_f64_max = 5.64380309412229e+102; // precomputed2
3704+static const f64 _const_math__internal__root4_f64_max = 1.157920892373162e+77; // precomputed2
3705+static const f64 _const_math__internal__root5_f64_max = 4.4765466227572707e+61; // precomputed2
3706+static const f64 _const_math__internal__root6_f64_max = 2.3756689782295612e+51; // precomputed2
3707+static const f64 _const_math__internal__log_f64_max = 709.782712893384; // precomputed2
3708+static const f64 _const_math__internal__f32_epsilon = 1.1920928955078125e-07; // precomputed2
3709+static const f64 _const_math__internal__sqrt_f32_epsilon = 0.00034526698300124393; // precomputed2
3710+static const f64 _const_math__internal__root3_f32_epsilon = 0.00492156660115185; // precomputed2
3711+static const f64 _const_math__internal__root4_f32_epsilon = 0.018581361171917516; // precomputed2
3712+static const f64 _const_math__internal__root5_f32_epsilon = 0.04123462221165294; // precomputed2
3713+static const f64 _const_math__internal__root6_f32_epsilon = 0.07015387801933583; // precomputed2
3714+static const f64 _const_math__internal__log_f32_epsilon = -15.942385152878742; // precomputed2
3715+static const f64 _const_math__internal__f32_min = 1.1754943508222875e-38; // precomputed2
3716+static const f64 _const_math__internal__sqrt_f32_min = 1.0842021724855044e-19; // precomputed2
3717+static const f64 _const_math__internal__root3_f32_min = 2.273736754432324e-13; // precomputed2
3718+static const f64 _const_math__internal__root4_f32_min = 3.2927225399135965e-10; // precomputed2
3719+static const f64 _const_math__internal__root5_f32_min = 2.5944428542140822e-08; // precomputed2
3720+static const f64 _const_math__internal__root6_f32_min = 4.768371582031254e-07; // precomputed2
3721+static const f64 _const_math__internal__log_f32_min = -87.3365447505531; // precomputed2
3722+static const f64 _const_math__internal__f32_max = 3.4028234663852886e+38; // precomputed2
3723+static const f64 _const_math__internal__sqrt_f32_max = 1.844674352395373e+19; // precomputed2
3724+static const f64 _const_math__internal__root3_f32_max = 6.981463519622324e+12; // precomputed2
3725+static const f64 _const_math__internal__root4_f32_max = 4.2949672319999986e+09; // precomputed2
3726+static const f64 _const_math__internal__root5_f32_max = 5.085900785596004e+07; // precomputed2
3727+static const f64 _const_math__internal__root6_f32_max = 2.642245923380775e+06; // precomputed2
3728+static const f64 _const_math__internal__log_f32_max = 88.72283905206835; // precomputed2
3729+static const f64 _const_math__internal__sflt_epsilon = 0.00048828125; // precomputed2
3730+static const f64 _const_math__internal__sqrt_sflt_epsilon = 0.02209708691207961; // precomputed2
3731+static const f64 _const_math__internal__root3_sflt_epsilon = 0.07874506561842959; // precomputed2
3732+static const f64 _const_math__internal__root4_sflt_epsilon = 0.14865088937534013; // precomputed2
3733+static const f64 _const_math__internal__root5_sflt_epsilon = 0.217637640824031; // precomputed2
3734+static const f64 _const_math__internal__root6_sflt_epsilon = 0.28061551207734325; // precomputed2
3735+static const f64 _const_math__internal__log_sflt_epsilon = -7.6246189861593985; // precomputed2
3736+static const f64 _const_math__internal__max_f64_fact_arg = 171.0; // precomputed2
3737+static const f64 _const_math__internal__max_long_f64_fact_arg = 1755.5; // precomputed2
3738+static const u64 _const_math__uvnan = 9221120237041090561U; // precomputed2
3739+static const u64 _const_math__uvinf = 9218868437227405312U; // precomputed2
3740+static const u64 _const_math__uvneginf = 18442240474082181120U; // precomputed2
3741+static const u64 _const_math__uvone = 4607182418800017408U; // precomputed2
3742+static const u64 _const_math__normalize_smallest_mask = 4503599627370496U; // precomputed2
3743+static const u64 _const_math__sign_mask = 9223372036854775808U; // precomputed2
3744+static const u64 _const_math__frac_mask = 4503599627370495U; // precomputed2
3745+static const f64 _const_math__epsilon = 2.220446049250313e-16; // precomputed2
3746+static const f64 _const_math__e = 2.718281828459045; // precomputed2
3747+static const f64 _const_math__pi = 3.141592653589793; // precomputed2
3748+static const f64 _const_math__phi = 1.618033988749895; // precomputed2
3749+static const f64 _const_math__tau = 6.283185307179586; // precomputed2
3750+static const f64 _const_math__sqrt2 = 1.4142135623730951; // precomputed2
3751+static const f64 _const_math__sqrt_3 = 1.7320508075688772; // precomputed2
3752+static const f64 _const_math__sqrt_5 = 2.23606797749979; // precomputed2
3753+static const f64 _const_math__sqrt_e = 1.6487212707001282; // precomputed2
3754+static const f64 _const_math__sqrt_pi = 1.772453850905516; // precomputed2
3755+static const f64 _const_math__sqrt_tau = 2.5066282746310007; // precomputed2
3756+static const f64 _const_math__sqrt_phi = 1.272019649514069; // precomputed2
3757+static const f64 _const_math__ln2 = 0.6931471805599453; // precomputed2
3758+static const f64 _const_math__ln10 = 2.302585092994046; // precomputed2
3759+static const f64 _const_math__two_thirds = 0.6666666666666666; // precomputed2
3760+static const f64 _const_math__max_f32 = 3.4028234663852886e+38; // precomputed2
3761+static const f64 _const_math__smallest_non_zero_f32 = 1.401298464324817e-45; // precomputed2
3762+static const f64 _const_math__max_f64 = 1.7976931348623157e+308; // precomputed2
3763+static const f64 _const_math__smallest_non_zero_f64 = 0.0; // precomputed2
3764+static const f64 _const_math__erx = 0.8450629115104675; // precomputed2
3765+static const f64 _const_math__efx = 0.1283791670955126; // precomputed2
3766+static const f64 _const_math__efx8 = 1.0270333367641007; // precomputed2
3767+static const f64 _const_math__pp0 = 0.12837916709551256; // precomputed2
3768+static const f64 _const_math__pp1 = -0.3250421072470015; // precomputed2
3769+static const f64 _const_math__pp2 = -0.02848174957559851; // precomputed2
3770+static const f64 _const_math__pp3 = -0.005770270296489442; // precomputed2
3771+static const f64 _const_math__pp4 = -2.3763016656650163e-05; // precomputed2
3772+static const f64 _const_math__qq1 = 0.39791722395915535; // precomputed2
3773+static const f64 _const_math__qq2 = 0.0650222499887673; // precomputed2
3774+static const f64 _const_math__qq3 = 0.005081306281875766; // precomputed2
3775+static const f64 _const_math__qq4 = 0.00013249473800432164; // precomputed2
3776+static const f64 _const_math__qq5 = -3.960228278775368e-06; // precomputed2
3777+static const f64 _const_math__pa0 = -0.0023621185607526594; // precomputed2
3778+static const f64 _const_math__pa1 = 0.41485611868374833; // precomputed2
3779+static const f64 _const_math__pa2 = -0.3722078760357013; // precomputed2
3780+static const f64 _const_math__pa3 = 0.31834661990116175; // precomputed2
3781+static const f64 _const_math__pa4 = -0.11089469428239668; // precomputed2
3782+static const f64 _const_math__pa5 = 0.035478304325618236; // precomputed2
3783+static const f64 _const_math__pa6 = -0.002166375594868791; // precomputed2
3784+static const f64 _const_math__qa1 = 0.10642088040084423; // precomputed2
3785+static const f64 _const_math__qa2 = 0.540397917702171; // precomputed2
3786+static const f64 _const_math__qa3 = 0.07182865441419627; // precomputed2
3787+static const f64 _const_math__qa4 = 0.12617121980876164; // precomputed2
3788+static const f64 _const_math__qa5 = 0.01363708391202905; // precomputed2
3789+static const f64 _const_math__qa6 = 0.011984499846799107; // precomputed2
3790+static const f64 _const_math__ra0 = -0.009864944034847148; // precomputed2
3791+static const f64 _const_math__ra1 = -0.6938585727071818; // precomputed2
3792+static const f64 _const_math__ra2 = -10.558626225323291; // precomputed2
3793+static const f64 _const_math__ra3 = -62.375332450326006; // precomputed2
3794+static const f64 _const_math__ra4 = -162.39666946257347; // precomputed2
3795+static const f64 _const_math__ra5 = -184.60509290671104; // precomputed2
3796+static const f64 _const_math__ra6 = -81.2874355063066; // precomputed2
3797+static const f64 _const_math__ra7 = -9.814329344169145; // precomputed2
3798+static const f64 _const_math__sa1 = 19.651271667439257; // precomputed2
3799+static const f64 _const_math__sa2 = 137.65775414351904; // precomputed2
3800+static const f64 _const_math__sa3 = 434.56587747522923; // precomputed2
3801+static const f64 _const_math__sa4 = 645.3872717332679; // precomputed2
3802+static const f64 _const_math__sa5 = 429.00814002756783; // precomputed2
3803+static const f64 _const_math__sa6 = 108.63500554177944; // precomputed2
3804+static const f64 _const_math__sa7 = 6.570249770319282; // precomputed2
3805+static const f64 _const_math__sa8 = -0.0604244152148581; // precomputed2
3806+static const f64 _const_math__rb0 = -0.0098649429247001; // precomputed2
3807+static const f64 _const_math__rb1 = -0.799283237680523; // precomputed2
3808+static const f64 _const_math__rb2 = -17.757954917754752; // precomputed2
3809+static const f64 _const_math__rb3 = -160.63638485582192; // precomputed2
3810+static const f64 _const_math__rb4 = -637.5664433683896; // precomputed2
3811+static const f64 _const_math__rb5 = -1025.0951316110772; // precomputed2
3812+static const f64 _const_math__rb6 = -483.5191916086514; // precomputed2
3813+static const f64 _const_math__sb1 = 30.33806074348246; // precomputed2
3814+static const f64 _const_math__sb2 = 325.7925129965739; // precomputed2
3815+static const f64 _const_math__sb3 = 1536.729586084437; // precomputed2
3816+static const f64 _const_math__sb4 = 3199.8582195085955; // precomputed2
3817+static const f64 _const_math__sb5 = 2553.0504064331644; // precomputed2
3818+static const f64 _const_math__sb6 = 474.52854120695537; // precomputed2
3819+static const f64 _const_math__sb7 = -22.44095244658582; // precomputed2
3820+static const f64 _const_math__ln2hi = 0.6931471803691238; // precomputed2
3821+static const f64 _const_math__ln2lo = 1.9082149292705877e-10; // precomputed2
3822+static const f64 _const_math__log_sqrt_2pi = 0.9189385332046728; // precomputed2
3823+static Array_f64 _const_math__bernoulli; // inited later
3824+static Array_f64 _const_math__factorials_table; // inited later
3825+static Array_f64 _const_math__log_factorials_table; // inited later
3826+static Array_f64 _const_math__gamma_p; // inited later
3827+static Array_f64 _const_math__gamma_q; // inited later
3828+static Array_f64 _const_math__gamma_s; // inited later
3829+static Array_f64 _const_math__lgamma_a; // inited later
3830+static Array_f64 _const_math__lgamma_r; // inited later
3831+static Array_f64 _const_math__lgamma_s; // inited later
3832+static Array_f64 _const_math__lgamma_t; // inited later
3833+static Array_f64 _const_math__lgamma_u; // inited later
3834+static Array_f64 _const_math__lgamma_v; // inited later
3835+static Array_f64 _const_math__lgamma_w; // inited later
3836+static const f64 _const_math__morebits = 6.123233995736766e-17; // precomputed2
3837+static const f64 _const_math__tan3pio8 = 2.414213562373095; // precomputed2
3838+static const f64 _const_math__two54 = 1.8014398509481984e+16; // precomputed2
3839+static const f64 _const_math__ivln10 = 0.4342944819032518; // precomputed2
3840+static const f64 _const_math__log10_2hi = 0.30102999566361177; // precomputed2
3841+static const f64 _const_math__log10_2lo = 3.694239077158931e-13; // precomputed2
3842+static const f64 _const_math__modf_maxpowtwo = 4.503599627370496e+15; // precomputed2
3843+static Array_f64 _const_math__pow10tab; // inited later
3844+static Array_f64 _const_math__pow10postab32; // inited later
3845+static Array_f64 _const_math__pow10negtab32; // inited later
3846+static Array_f64 _const_math__sin_data; // inited later
3847+static Array_f64 _const_math__cos_data; // inited later
3848+static Array_f64 _const_math__tan_p; // inited later
3849+static Array_f64 _const_math__tan_q; // inited later
3850+static const f64 _const_math__tan_dp1 = 0.7853981554508209; // precomputed2
3851+static const f64 _const_math__tan_dp2 = 7.946627356147928e-09; // precomputed2
3852+static const f64 _const_math__tan_dp3 = 3.061616997868383e-17; // precomputed2
3853+static const f64 _const_math__tan_lossth = 1.073741824e+09; // precomputed2
3854+static Array_f64 _const_math__tanh_p; // inited later
3855+static Array_f64 _const_math__tanh_q; // inited later
3492 static u32 _const_builtin__closure__closure_size_1; // inited later3856 static u32 _const_builtin__closure__closure_size_1; // inited later
3493 Array_fixed_int_64 g_autostr_type_stack = {0}; // global 63857 Array_fixed_int_64 g_autostr_type_stack = {0}; // global 6
3494 3858
3495 Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 63859 Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 6
3496 3860
3861+static math__ChebSeries _const_math__sin_cs; // inited later
3862+static math__ChebSeries _const_math__cos_cs; // inited later
3497 static int _const_builtin__closure__closure_size; // inited later3863 static int _const_builtin__closure__closure_size; // inited later
3498 3864
3499 // V interface table:3865 // V interface table:
@@ -5044,7 +5410,6 @@ inline int math__bits__leading_zeros_8(u8 x) {
5044 }5410 }
5045 #elif !defined(__TINYC__)5411 #elif !defined(__TINYC__)
5046 {5412 {
5047- return __builtin_clz(((u32)(x))) - 24;
5048 }5413 }
5049 #endif5414 #endif
5050 return math__bits__leading_zeros_8_default(x);5415 return math__bits__leading_zeros_8_default(x);
@@ -5058,7 +5423,6 @@ inline int math__bits__leading_zeros_16(u16 x) {
5058 }5423 }
5059 #elif !defined(__TINYC__)5424 #elif !defined(__TINYC__)
5060 {5425 {
5061- return __builtin_clz(((u32)(x))) - 16;
5062 }5426 }
5063 #endif5427 #endif
5064 return math__bits__leading_zeros_16_default(x);5428 return math__bits__leading_zeros_16_default(x);
@@ -5072,7 +5436,6 @@ inline int math__bits__leading_zeros_32(u32 x) {
5072 }5436 }
5073 #elif !defined(__TINYC__)5437 #elif !defined(__TINYC__)
5074 {5438 {
5075- return __builtin_clz(x);
5076 }5439 }
5077 #endif5440 #endif
5078 return math__bits__leading_zeros_32_default(x);5441 return math__bits__leading_zeros_32_default(x);
@@ -5086,7 +5449,6 @@ inline int math__bits__leading_zeros_64(u64 x) {
5086 }5449 }
5087 #elif !defined(__TINYC__)5450 #elif !defined(__TINYC__)
5088 {5451 {
5089- return __builtin_clzll(x);
5090 }5452 }
5091 #endif5453 #endif
5092 return math__bits__leading_zeros_64_default(x);5454 return math__bits__leading_zeros_64_default(x);
@@ -5100,7 +5462,6 @@ inline int math__bits__trailing_zeros_8(u8 x) {
5100 }5462 }
5101 #elif !defined(__TINYC__)5463 #elif !defined(__TINYC__)
5102 {5464 {
5103- return __builtin_ctz(((u32)(x)));
5104 }5465 }
5105 #endif5466 #endif
5106 return math__bits__trailing_zeros_8_default(x);5467 return math__bits__trailing_zeros_8_default(x);
@@ -5114,7 +5475,6 @@ inline int math__bits__trailing_zeros_16(u16 x) {
5114 }5475 }
5115 #elif !defined(__TINYC__)5476 #elif !defined(__TINYC__)
5116 {5477 {
5117- return __builtin_ctz(((u32)(x)));
5118 }5478 }
5119 #endif5479 #endif
5120 return math__bits__trailing_zeros_16_default(x);5480 return math__bits__trailing_zeros_16_default(x);
@@ -5128,7 +5488,6 @@ inline int math__bits__trailing_zeros_32(u32 x) {
5128 }5488 }
5129 #elif !defined(__TINYC__)5489 #elif !defined(__TINYC__)
5130 {5490 {
5131- return __builtin_ctz(x);
5132 }5491 }
5133 #endif5492 #endif
5134 return math__bits__trailing_zeros_32_default(x);5493 return math__bits__trailing_zeros_32_default(x);
@@ -5142,7 +5501,6 @@ inline int math__bits__trailing_zeros_64(u64 x) {
5142 }5501 }
5143 #elif !defined(__TINYC__)5502 #elif !defined(__TINYC__)
5144 {5503 {
5145- return __builtin_ctzll(x);
5146 }5504 }
5147 #endif5505 #endif
5148 return math__bits__trailing_zeros_64_default(x);5506 return math__bits__trailing_zeros_64_default(x);
@@ -5153,7 +5511,6 @@ inline int math__bits__ones_count_8(u8 x) {
5153 }5511 }
5154 #elif !defined(__TINYC__)5512 #elif !defined(__TINYC__)
5155 {5513 {
5156- return __builtin_popcount(((u32)(x)));
5157 }5514 }
5158 #endif5515 #endif
5159 return math__bits__ones_count_8_default(x);5516 return math__bits__ones_count_8_default(x);
@@ -5164,7 +5521,6 @@ inline int math__bits__ones_count_16(u16 x) {
5164 }5521 }
5165 #elif !defined(__TINYC__)5522 #elif !defined(__TINYC__)
5166 {5523 {
5167- return __builtin_popcount(((u32)(x)));
5168 }5524 }
5169 #endif5525 #endif
5170 return math__bits__ones_count_16_default(x);5526 return math__bits__ones_count_16_default(x);
@@ -5175,7 +5531,6 @@ inline int math__bits__ones_count_32(u32 x) {
5175 }5531 }
5176 #elif !defined(__TINYC__)5532 #elif !defined(__TINYC__)
5177 {5533 {
5178- return __builtin_popcount(x);
5179 }5534 }
5180 #endif5535 #endif
5181 return math__bits__ones_count_32_default(x);5536 return math__bits__ones_count_32_default(x);
@@ -5186,7 +5541,6 @@ inline int math__bits__ones_count_64(u64 x) {
5186 }5541 }
5187 #elif !defined(__TINYC__)5542 #elif !defined(__TINYC__)
5188 {5543 {
5189- return __builtin_popcountll(x);
5190 }5544 }
5191 #endif5545 #endif
5192 return math__bits__ones_count_64_default(x);5546 return math__bits__ones_count_64_default(x);
@@ -10152,226 +10506,18 @@ VV_LOC string builtin__autostr_array_circular(int len) {
10152 return res;10506 return res;
10153 }10507 }
10154 void builtin__print_backtrace(void) {10508 void builtin__print_backtrace(void) {
10155- #if !defined(CUSTOM_DEFINE_no_backtrace)
10156- {
10157- #if 0
10158- {
10159- }
10160- #elif defined(__TINYC__)
10161- {
10162- }
10163- #elif defined(CUSTOM_DEFINE_use_libbacktrace)
10164- {
10165- }
10166- #else
10167- {
10168- builtin__print_backtrace_skipping_top_frames(2);
10169- }
10170- #endif
10171- }
10172- #endif
10173-}
10174-VV_LOC string builtin__demangle_v_symbol(string cname) {
10175- string name = cname;
10176- if (builtin__string_starts_with(name, _S("builtin__"))) {
10177- name = builtin__string_substr(name, 9, 2147483647);
10178- }
10179- name = builtin__string_replace(name, _S("__ptr__"), _S("&"));
10180- _option_int _t1 = builtin__string_index(name, _S("_T_"));
10181- if (_t1.state != 0) {
10182- *(int*) _t1.data = -1;
10183- }
10184-
10185- int t_pos = (*(int*)_t1.data);
10186- if (t_pos >= 0) {
10187- string base = builtin__string_replace(builtin__string_substr(name, 0, t_pos), _S("__"), _S("."));
10188- string generic_suffix = builtin__string_substr(name, t_pos + 3, 2147483647);
10189- Array_string params = builtin__split_generic_params(generic_suffix);
10190- Array_string demangled_params = builtin____new_array_with_default(0, params.len, sizeof(string), 0);
10191- for (int _t2 = 0; _t2 < params.len; ++_t2) {
10192- string param = ((string*)params.data)[_t2];
10193- builtin__array_push((array*)&demangled_params, _MOV((string[]){ builtin__string_replace(param, _S("__"), _S(".")) }));
10194- }
10195- return builtin__string_plus_many(4, _MOV((string[4]){base, _S("["), Array_string_join(demangled_params, _S(", ")), _S("]")}));
10196- }
10197- name = builtin__string_replace(name, _S("__"), _S("."));
10198- if (_SLIT_EQ(name.str, name.len, "main.main")) {
10199- return _S("main");
10200- }
10201- return name;
10202-}
10203-VV_LOC Array_string builtin__split_generic_params(string s) {
10204- Array_string params = builtin____new_array_with_default(0, 0, sizeof(string), 0);
10205- int start = 0;
10206- int i = 0;
10207- for (;;) {
10208- if (!(i < s.len)) break;
10209- if (s.str[ i] == '_') {
10210- if (i + 1 < s.len && s.str[ i + 1] == '_') {
10211- i += 2;
10212- } else {
10213- if (i > start) {
10214- builtin__array_push((array*)&params, _MOV((string[]){ builtin__string_substr(s, start, i) }));
10215- }
10216- i++;
10217- start = i;
10218- }
10219- } else {
10220- i++;
10221- }
10222- }
10223- if (start < s.len) {
10224- builtin__array_push((array*)&params, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) }));
10225- }
10226- return params;
10227-}
10228-VV_LOC string builtin__demangle_backtrace_sym(string s) {
10229- _option_int _t1 = builtin__string_index(s, _S("("));
10230- if (_t1.state != 0) {
10231- return s;
10232- }
10233-
10234- int paren_start = (*(int*)_t1.data);
10235- int plus_pos = builtin__string_index_after_(s, _S("+"), paren_start);
10236- if (plus_pos < 0) {
10237- return s;
10238- }
10239- string symbol = builtin__string_substr(s, paren_start + 1, plus_pos);
10240- if (symbol.len == 0) {
10241- return s;
10242- }
10243- return builtin__string_plus_many(3, _MOV((string[3]){builtin__string_substr(s, 0, paren_start + 1), builtin__demangle_v_symbol(symbol), builtin__string_substr(s, plus_pos, 2147483647)}));
10244-}
10245-VV_LOC void builtin__eprint_space_padding(string output, int max_len) {
10246- int padding_len = max_len - output.len;
10247- if (padding_len > 0) {
10248- for (int _t1 = 0; _t1 < padding_len; ++_t1) {
10249- builtin__eprint(_S(" "));
10250- }
10251- }
10252 }10509 }
10253 bool builtin__print_backtrace_skipping_top_frames(int xskipframes) {10510 bool builtin__print_backtrace_skipping_top_frames(int xskipframes) {
10254 #if defined(CUSTOM_DEFINE_no_backtrace)10511 #if defined(CUSTOM_DEFINE_no_backtrace)
10255 {10512 {
10513+ return false;
10256 }10514 }
10257 #else10515 #else
10258 {10516 {
10259- int skipframes = xskipframes + 2;
10260- #if 0
10261- {
10262- }
10263- #elif 1
10264- {
10265- return builtin__print_backtrace_skipping_top_frames_linux(skipframes);
10266- }
10267- #else
10268- {
10269- }
10270- #endif
10271 }10517 }
10272 #endif10518 #endif
10273 return false;10519 return false;
10274 }10520 }
10275-VV_LOC string builtin__backtrace_current_executable_name(void) {
10276- Array_string args = builtin__arguments();
10277- if (args.len == 0) {
10278- return _S("");
10279- }
10280- return (*(string*)builtin__array_get(args, 0));
10281-}
10282-VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name) {
10283- if (executable.len == 0) {
10284- return _S("/proc/self/exe");
10285- }
10286- if (builtin__string_contains(executable, _S("/"))) {
10287- return executable;
10288- }
10289- if (current_executable_name.len > 0 && builtin__string__eq(builtin__string_all_after_last(executable, _S("/")), builtin__string_all_after_last(current_executable_name, _S("/")))) {
10290- return _S("/proc/self/exe");
10291- }
10292- return executable;
10293-}
10294-VV_LOC string builtin__backtrace_shell_quote(string s) {
10295- string quoted = _S("'");
10296- for (int i = 0; i < s.len; ++i) {
10297- if (builtin__string_at(s, i) == '\'') {
10298- quoted = builtin__string__plus(quoted, _S("'\\''"));
10299- } else {
10300- quoted = builtin__string__plus(quoted, builtin__u8_ascii_str(builtin__string_at(s, i)));
10301- }
10302- }
10303- return builtin__string__plus(quoted, _S("'"));
10304-}
10305-VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes) {
10306- #if defined(CUSTOM_DEFINE_no_backtrace)
10307- {
10308- }
10309- #else
10310- {
10311- #if 1
10312- {
10313- #if 0
10314- {
10315- }
10316- #else
10317- {
10318- string current_executable_name = builtin__backtrace_current_executable_name();
10319- Array_fixed_voidptr_100 buffer = {0};
10320- i32 nr_ptrs = backtrace(&buffer[0], 100);
10321- if (nr_ptrs < 2) {
10322- builtin__eprintln(_S("C.backtrace returned less than 2 frames"));
10323- return false;
10324- }
10325- int nr_actual_frames = (int)(nr_ptrs - skipframes);
10326- char** csymbols = backtrace_symbols(((voidptr)(&buffer[skipframes])), nr_actual_frames);
10327- for (int i = 0; i < nr_actual_frames; ++i) {
10328- string sframe = builtin__tos2(((u8*)(csymbols[i])));
10329- string executable = builtin__string_all_before(sframe, _S("("));
10330- string addr2line_executable = builtin__backtrace_addr2line_executable(executable, current_executable_name);
10331- string addr = builtin__string_all_before(builtin__string_all_after(sframe, _S("[")), _S("]"));
10332- string beforeaddr = builtin__string_all_before(sframe, _S("["));
10333- string cmd = builtin__string_plus_many(4, _MOV((string[4]){_S("addr2line -e "), builtin__backtrace_shell_quote(addr2line_executable), _S(" "), builtin__backtrace_shell_quote(addr)}));
10334- voidptr f = popen(((char*)(cmd.str)), "r");
10335- if (f == ((void*)0)) {
10336- builtin__eprintln(sframe);
10337- continue;
10338- }
10339- Array_fixed_u8_1000 buf = {0};
10340- string output = _S("");
10341- { // Unsafe block
10342- u8* bp = ((u8*)(&buf[0]));
10343- for (;;) {
10344- if (!(fgets(((char*)(bp)), 1000, f) != 0)) break;
10345- output = builtin__string__plus(output, builtin__tos(bp, builtin__vstrlen(bp)));
10346- }
10347- }
10348- output = builtin__string__plus(builtin__string_trim_chars(output, _S(" \t\n"), TrimMode__trim_both), _S(":"));
10349- if (pclose(f) != 0) {
10350- builtin__eprintln(sframe);
10351- continue;
10352- }
10353- if (_SLIT_EQ(output.str, output.len, "??:0:") || _SLIT_EQ(output.str, output.len, "??:?:")) {
10354- output = _S("");
10355- }
10356- output = builtin__string_replace(output, _S(" (discriminator"), _S(": (d."));
10357- builtin__eprint(output);
10358- builtin__eprint_space_padding(output, 55);
10359- builtin__eprint(_S(" | "));
10360- builtin__eprint(addr);
10361- builtin__eprint(_S(" | "));
10362- builtin__eprintln(builtin__demangle_backtrace_sym(beforeaddr));
10363- }
10364- if (nr_actual_frames > 0) {
10365- free(csymbols);
10366- }
10367- }
10368- #endif
10369- }
10370- #endif
10371- }
10372- #endif
10373- return true;
10374-}
10375 VNORETURN void builtin___v_exit(int code) {10521 VNORETURN void builtin___v_exit(int code) {
10376 exit(code);10522 exit(code);
10377 VUNREACHABLE();10523 VUNREACHABLE();
@@ -10410,12 +10556,12 @@ VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number) {
10410 #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)10556 #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)
10411 {10557 {
10412 }10558 }
10413- #elif 010559+ #elif 1
10414 {10560 {
10561+ builtin__print_backtrace_skipping_top_frames(1);
10415 }10562 }
10416 #else10563 #else
10417 {10564 {
10418- builtin__print_backtrace();
10419 }10565 }
10420 #endif10566 #endif
10421 builtin___v_exit(128 + signal_number);10567 builtin___v_exit(128 + signal_number);
@@ -10489,7 +10635,7 @@ Array_string builtin__arguments(void) {
10489 return res;10635 return res;
10490 }10636 }
10491 string builtin__vcurrent_hash(void) {10637 string builtin__vcurrent_hash(void) {
10492- return _S("");10638+ return _S("7647ce1");
10493 }10639 }
10494 u64 builtin__v_getpid(void) {10640 u64 builtin__v_getpid(void) {
10495 #if defined(CUSTOM_DEFINE_no_getpid)10641 #if defined(CUSTOM_DEFINE_no_getpid)
@@ -12451,22 +12597,14 @@ VNORETURN void builtin___v_panic(string s) {
12451 }12597 }
12452 #elif defined(CUSTOM_DEFINE_no_backtrace)12598 #elif defined(CUSTOM_DEFINE_no_backtrace)
12453 {12599 {
12600+ exit(1);
12601+ VUNREACHABLE();
12454 }12602 }
12455 #elif 012603 #elif 0
12456 {12604 {
12457 }12605 }
12458 #else12606 #else
12459 {12607 {
12460- #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__)
12461- {
12462- }
12463- #else
12464- {
12465- builtin__print_backtrace_skipping_top_frames(1);
12466- }
12467- #endif
12468- exit(1);
12469- VUNREACHABLE();
12470 }12608 }
12471 #endif12609 #endif
12472 }12610 }
@@ -16443,78 +16581,2188 @@ inline void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_) {
16443 inline ArrayFlags builtin__ArrayFlags__static__zero(void) {16581 inline ArrayFlags builtin__ArrayFlags__static__zero(void) {
16444 return ((ArrayFlags)(0));16582 return ((ArrayFlags)(0));
16445 }16583 }
16446-VV_LOC void main__vf_init(void) {16584+f64 math__inf(int sign) {
16447- string probe = _S("vf");16585+ u64 v = (sign >= 0 ? (_const_math__uvinf) : (_const_math__uvneginf));
16448- {int _ = probe.len;}16586+ return math__f64_from_bits(v);
16449- ;
16450-}
16451-// export alias: vf_init -> main__vf_init
16452-void vf_init(void) {
16453- return main__vf_init();
16454 }16587 }
16455-VV_LOC int main__vf_add(int a, int b) {16588+f64 math__nan(void) {
16456- return a + b;16589+ return math__f64_from_bits(_const_math__uvnan);
16457 }16590 }
16458-// export alias: vf_add -> main__vf_add16591+bool math__is_nan(f64 f) {
16459-int vf_add(int a, int b) {16592+ return f != f;
16460- return main__vf_add(a, b);
16461 }16593 }
16462-VV_LOC char* main__vf_greet(char* name) {16594+bool math__is_inf(f64 f, int sign) {
16463- string n = builtin__cstring_to_vstring(name);16595+ return (sign >= 0 && f > ((f64)(_const_math__max_f64))) || (sign <= 0 && f < ((f64)(-_const_math__max_f64)));
16464- string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")}));
16465- u8* out = res.str;
16466- builtin__string_free(&n);
16467- return out;
16468 }16596 }
16469-// export alias: vf_greet -> main__vf_greet16597+bool math__is_finite(f64 f) {
16470-char* vf_greet(char* name) {16598+ return !math__is_nan(f) && !math__is_inf(f, 0);
16471- return main__vf_greet(name);
16472 }16599 }
16473-VV_LOC void main__vf_free(voidptr p) {16600+multi_return_f64_int math__normalize(f64 x) {
16474- builtin___v_free(p);16601+ f64 smallest_normal = 2.2250738585072014e-308;
16602+ if (math__abs_T_f64(x) < smallest_normal) {
16603+ return (multi_return_f64_int){.arg0=(f64)(x * _const_math__normalize_smallest_mask), .arg1=-52};
16604+ }
16605+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16475 }16606 }
16476-// export alias: vf_free -> main__vf_free16607+f64 math__cbrt(f64 a) {
16477-void vf_free(voidptr p) {16608+ f64 x = a;
16478- return main__vf_free(p);16609+ int b1 = 715094163;
16610+ int b2 = 696219795;
16611+ f64 c = 5.42857142857142815906e-01;
16612+ f64 d = -7.05306122448979611050e-01;
16613+ f64 e_ = 1.41428571428571436819e+00;
16614+ f64 f = 1.60714285714285720630e+00;
16615+ f64 g = 3.57142857142857150787e-01;
16616+ f64 smallest_normal = 2.22507385850720138309e-308;
16617+ if (x == ((f64)(0.0)) || math__is_nan(x) || math__is_inf(x, 0)) {
16618+ return x;
16619+ }
16620+ bool neg = false;
16621+ if (x < 0) {
16622+ x = -x;
16623+ neg = true;
16624+ }
16625+ f64 t = math__f64_from_bits(VSAFE_DIV_u64(math__f64_bits(x) , ((u64)(3))) + (v__lshift_u64(((u64)(b1)), (u64)32)));
16626+ if (x < smallest_normal) {
16627+ t = ((f64)(v__lshift_u64(((u64)(1)), (u64)54)));
16628+ t *= x;
16629+ t = math__f64_from_bits(VSAFE_DIV_u64(math__f64_bits(t) , ((u64)(3))) + (v__lshift_u64(((u64)(b2)), (u64)32)));
16630+ }
16631+ f64 r = t * t / x;
16632+ f64 s = c + r * t;
16633+ t *= g + f / (s + e_ + d / s);
16634+ t = math__f64_from_bits((math__f64_bits(t) & (v__lshift_u64(((u64)(0xffffffffcLL)), (u64)28))) + (v__lshift_u64(((u64)(1)), (u64)30)));
16635+ s = t * t;
16636+ r = x / s;
16637+ f64 w = t + t;
16638+ r = (r - t) / (w + r);
16639+ t = t + t * r;
16640+ if (neg) {
16641+ t = -t;
16642+ }
16643+ return t;
16479 }16644 }
16480-VV_LOC void main__main(void) {16645+f64 math__mod(f64 x, f64 y) {
16646+ return math__fmod(x, y);
16481 }16647 }
16482-void _vinit(int ___argc, voidptr ___argv) {16648+f64 math__fmod(f64 x, f64 y) {
16483- static bool once = false; if (once) {return;} once = true;16649+ if (y == 0 || math__is_inf(x, 0) || math__is_nan(x) || math__is_nan(y)) {
16484- // Initializations of consts for module builtin.closure16650+ return math__nan();
16485- g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3
16486-{
16487-{
16488-Array_fixed_u8_15 _t1;
16489-#if defined(__V_ppc64le)
16490-#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
16491-#elif defined(__V_amd64)
16492- { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ;
16493- memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15));
16494 }16651 }
16495- ;16652+ f64 abs_y = math__abs_T_f64(y);
16496-#elif defined(__V_x86)16653+ multi_return_f64_int mr_594 = math__frexp(abs_y);
16497-#elif defined(__V_arm64)16654+ f64 abs_y_fr = mr_594.arg0;
16498-#elif defined(__V_arm32)16655+ int abs_y_exp = mr_594.arg1;
16499-#elif defined(__V_rv64)16656+ f64 r = x;
16500-#elif defined(__V_rv32)16657+ if (x < 0) {
16501-#elif defined(__V_s390x)16658+ r = -x;
16502-#elif defined(__V_loongarch64)16659+ }
16503-#elif defined(__V_sparc64)16660+ for (;;) {
16504-#elif 016661+ if (!(r >= abs_y)) break;
16505-#else16662+ multi_return_f64_int mr_680 = math__frexp(r);
16506-#endif16663+ f64 rfr = mr_680.arg0;
16507- memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15));16664+ int rexp = mr_680.arg1;
16665+ if (rfr < abs_y_fr) {
16666+ rexp = rexp - 1;
16667+ }
16668+ r = r - math__ldexp(abs_y, rexp - abs_y_exp);
16669+ }
16670+ if (x < 0) {
16671+ r = -r;
16672+ }
16673+ return r;
16508 }16674 }
16675+i64 math__gcd(i64 a_, i64 b_) {
16676+ i64 a = a_;
16677+ i64 b = b_;
16678+ if (a < 0) {
16679+ a = -a;
16680+ }
16681+ if (b < 0) {
16682+ b = -b;
16683+ }
16684+ for (;;) {
16685+ if (!(b != 0)) break;
16686+ a = VSAFE_MOD_i64(a,b);
16687+ if (a == 0) {
16688+ return b;
16689+ }
16690+ b = VSAFE_MOD_i64(b,a);
16691+ }
16692+ return a;
16509 }16693 }
16510-{16694+multi_return_i64_i64_i64 math__egcd(i64 a, i64 b) {
16511-{16695+ i64 old_r = a;
16512-Array_fixed_u8_6 _t3;16696+ i64 r = b;
16513-#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)16697+ i64 old_s = ((i64)(1));
16514-#elif defined(__V_arm32)16698+ i64 s = ((i64)(0));
16515-#elif defined(__V_amd64)16699+ i64 old_t = ((i64)(0));
16516- { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ;16700+ i64 t = ((i64)(1));
16517- memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6));16701+ for (;;) {
16702+ if (!(r != 0)) break;
16703+ i64 quot = VSAFE_DIV_i64(old_r , r);
16704+ i64 _var_1339 = old_r;
16705+ i64 _var_1346 = r;
16706+ old_r = _var_1346;
16707+ r = _var_1339%_var_1346;
16708+ i64 _var_1365 = old_s;
16709+ i64 _var_1372 = s;
16710+ old_s = _var_1372;
16711+ s = _var_1365-quot*_var_1372;
16712+ i64 _var_1398 = old_t;
16713+ i64 _var_1405 = t;
16714+ old_t = _var_1405;
16715+ t = _var_1398-quot*_var_1405;
16716+ }
16717+ return (multi_return_i64_i64_i64){.arg0=(old_r < 0 ? (-old_r) : (old_r)), .arg1=old_s, .arg2=old_t};
16718+}
16719+i64 math__lcm(i64 a, i64 b) {
16720+ if (a == 0) {
16721+ return a;
16722+ }
16723+ i64 res = a * (VSAFE_DIV_i64(b , math__gcd(b, a)));
16724+ if (res < 0) {
16725+ return -res;
16726+ }
16727+ return res;
16728+}
16729+f64 math__erf(f64 a) {
16730+ f64 x = a;
16731+ f64 very_tiny = 2.848094538889218e-306;
16732+ f64 small_ = ((f64)(1.0)) / ((f64)(v__lshift_u64(((u64)(1)), (u64)28)));
16733+ if (math__is_nan(x)) {
16734+ return math__nan();
16735+ }
16736+ if (math__is_inf(x, 1)) {
16737+ return 1.0;
16738+ }
16739+ if (math__is_inf(x, -1)) {
16740+ return ((f64)(-1));
16741+ }
16742+ bool neg = false;
16743+ if (x < 0) {
16744+ x = -x;
16745+ neg = true;
16746+ }
16747+ if (x < ((f64)(0.84375))) {
16748+ f64 temp = 0.0;
16749+ if (x < small_) {
16750+ if (x < very_tiny) {
16751+ temp = ((f64)(0.125)) * (((f64)(8.0)) * x + ((f64)(_const_math__efx8)) * x);
16752+ } else {
16753+ temp = x + ((f64)(_const_math__efx)) * x;
16754+ }
16755+ } else {
16756+ f64 z = x * x;
16757+ f64 r = ((f64)(_const_math__pp0)) + z * (((f64)(_const_math__pp1)) + z * (((f64)(_const_math__pp2)) + z * (((f64)(_const_math__pp3)) + z * ((f64)(_const_math__pp4)))));
16758+ f64 s_ = ((f64)(1.0)) + z * (((f64)(_const_math__qq1)) + z * (((f64)(_const_math__qq2)) + z * (((f64)(_const_math__qq3)) + z * (((f64)(_const_math__qq4)) + z * ((f64)(_const_math__qq5))))));
16759+ f64 y = r / s_;
16760+ temp = x + x * y;
16761+ }
16762+ if (neg) {
16763+ return -temp;
16764+ }
16765+ return temp;
16766+ }
16767+ if (x < ((f64)(1.25))) {
16768+ f64 s_ = x - 1;
16769+ f64 p = ((f64)(_const_math__pa0)) + s_ * (((f64)(_const_math__pa1)) + s_ * (((f64)(_const_math__pa2)) + s_ * (((f64)(_const_math__pa3)) + s_ * (((f64)(_const_math__pa4)) + s_ * (((f64)(_const_math__pa5)) + s_ * ((f64)(_const_math__pa6)))))));
16770+ f64 q = ((f64)(1.0)) + s_ * (((f64)(_const_math__qa1)) + s_ * (((f64)(_const_math__qa2)) + s_ * (((f64)(_const_math__qa3)) + s_ * (((f64)(_const_math__qa4)) + s_ * (((f64)(_const_math__qa5)) + s_ * ((f64)(_const_math__qa6)))))));
16771+ if (neg) {
16772+ return ((f64)(-_const_math__erx)) - p / q;
16773+ }
16774+ return ((f64)(_const_math__erx)) + p / q;
16775+ }
16776+ if (x >= 6) {
16777+ if (neg) {
16778+ return -1;
16779+ }
16780+ return 1.0;
16781+ }
16782+ f64 s_ = ((f64)(1.0)) / (x * x);
16783+ f64 r = 0.0;
16784+ f64 s = 0.0;
16785+ if (x < ((f64)(2.857142857142857))) {
16786+ f64 tmp41 = s_ * (((f64)(_const_math__ra5)) + s_ * (((f64)(_const_math__ra6)) + s_ * ((f64)(_const_math__ra7))));
16787+ r = ((f64)(_const_math__ra0)) + s_ * (((f64)(_const_math__ra1)) + s_ * (((f64)(_const_math__ra2)) + s_ * (((f64)(_const_math__ra3)) + s_ * (((f64)(_const_math__ra4)) + tmp41))));
16788+ f64 tmp42 = s_ * (((f64)(_const_math__sa5)) + s_ * (((f64)(_const_math__sa6)) + s_ * (((f64)(_const_math__sa7)) + s_ * ((f64)(_const_math__sa8)))));
16789+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sa1)) + s_ * (((f64)(_const_math__sa2)) + s_ * (((f64)(_const_math__sa3)) + s_ * (((f64)(_const_math__sa4)) + tmp42))));
16790+ } else {
16791+ f64 tmp31 = ((f64)(_const_math__rb4)) + s_ * (((f64)(_const_math__rb5)) + s_ * ((f64)(_const_math__rb6)));
16792+ r = ((f64)(_const_math__rb0)) + s_ * (((f64)(_const_math__rb1)) + s_ * (((f64)(_const_math__rb2)) + s_ * (((f64)(_const_math__rb3)) + s_ * tmp31)));
16793+ f64 tmp32 = ((f64)(_const_math__sb4)) + s_ * (((f64)(_const_math__sb5)) + s_ * (((f64)(_const_math__sb6)) + s_ * ((f64)(_const_math__sb7))));
16794+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sb1)) + s_ * (((f64)(_const_math__sb2)) + s_ * (((f64)(_const_math__sb3)) + s_ * tmp32)));
16795+ }
16796+ f64 z = math__f64_from_bits((math__f64_bits(x) & 0xffffffff00000000ULL));
16797+ f64 r_ = math__exp(-z * z - ((f64)(0.5625))) * math__exp((z - x) * (z + x) + r / s);
16798+ if (neg) {
16799+ return r_ / x - ((f64)(1.0));
16800+ }
16801+ return ((f64)(1.0)) - r_ / x;
16802+}
16803+f64 math__erfc(f64 a) {
16804+ f64 x = a;
16805+ f64 tiny = ((f64)(1.0)) / ((f64)(v__lshift_u64(((u64)(1)), (u64)56)));
16806+ if (math__is_nan(x)) {
16807+ return math__nan();
16808+ }
16809+ if (math__is_inf(x, 1)) {
16810+ return 0.0;
16811+ }
16812+ if (math__is_inf(x, -1)) {
16813+ return 2.0;
16814+ }
16815+ bool neg = false;
16816+ if (x < 0) {
16817+ x = -x;
16818+ neg = true;
16819+ }
16820+ if (x < ((f64)(0.84375))) {
16821+ f64 temp = 0.0;
16822+ if (x < tiny) {
16823+ temp = x;
16824+ } else {
16825+ f64 z = x * x;
16826+ f64 r = ((f64)(_const_math__pp0)) + z * (((f64)(_const_math__pp1)) + z * (((f64)(_const_math__pp2)) + z * (((f64)(_const_math__pp3)) + z * ((f64)(_const_math__pp4)))));
16827+ f64 s_ = ((f64)(1.0)) + z * (((f64)(_const_math__qq1)) + z * (((f64)(_const_math__qq2)) + z * (((f64)(_const_math__qq3)) + z * (((f64)(_const_math__qq4)) + z * ((f64)(_const_math__qq5))))));
16828+ f64 y = r / s_;
16829+ if (x < ((f64)(0.25))) {
16830+ temp = x + x * y;
16831+ } else {
16832+ temp = ((f64)(0.5)) + (x * y + (x - ((f64)(0.5))));
16833+ }
16834+ }
16835+ if (neg) {
16836+ return ((f64)(1.0)) + temp;
16837+ }
16838+ return ((f64)(1.0)) - temp;
16839+ }
16840+ if (x < ((f64)(1.25))) {
16841+ f64 s_ = x - 1;
16842+ f64 p = ((f64)(_const_math__pa0)) + s_ * (((f64)(_const_math__pa1)) + s_ * (((f64)(_const_math__pa2)) + s_ * (((f64)(_const_math__pa3)) + s_ * (((f64)(_const_math__pa4)) + s_ * (((f64)(_const_math__pa5)) + s_ * ((f64)(_const_math__pa6)))))));
16843+ f64 q = ((f64)(1.0)) + s_ * (((f64)(_const_math__qa1)) + s_ * (((f64)(_const_math__qa2)) + s_ * (((f64)(_const_math__qa3)) + s_ * (((f64)(_const_math__qa4)) + s_ * (((f64)(_const_math__qa5)) + s_ * ((f64)(_const_math__qa6)))))));
16844+ if (neg) {
16845+ return ((f64)(1.8450629115104675)) + p / q;
16846+ }
16847+ return ((f64)(0.15493708848953247)) - p / q;
16848+ }
16849+ if (x < 28) {
16850+ f64 s_ = ((f64)(1.0)) / (x * x);
16851+ f64 r = 0.0;
16852+ f64 s = 0.0;
16853+ if (x < ((f64)(2.857142857142857))) {
16854+ f64 tmp281 = ((f64)(_const_math__ra4)) + s_ * (((f64)(_const_math__ra5)) + s_ * (((f64)(_const_math__ra6)) + s_ * ((f64)(_const_math__ra7))));
16855+ r = ((f64)(_const_math__ra0)) + s_ * (((f64)(_const_math__ra1)) + s_ * (((f64)(_const_math__ra2)) + s_ * (((f64)(_const_math__ra3)) + s_ * tmp281)));
16856+ f64 tmp282 = ((f64)(_const_math__sa4)) + s_ * (((f64)(_const_math__sa5)) + s_ * (((f64)(_const_math__sa6)) + s_ * (((f64)(_const_math__sa7)) + s_ * ((f64)(_const_math__sa8)))));
16857+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sa1)) + s_ * (((f64)(_const_math__sa2)) + s_ * (((f64)(_const_math__sa3)) + s_ * tmp282)));
16858+ } else {
16859+ if (neg && x > 6) {
16860+ return 2.0;
16861+ }
16862+ f64 tmp291 = ((f64)(_const_math__rb3)) + s_ * (((f64)(_const_math__rb4)) + s_ * (((f64)(_const_math__rb5)) + s_ * ((f64)(_const_math__rb6))));
16863+ r = ((f64)(_const_math__rb0)) + s_ * (((f64)(_const_math__rb1)) + s_ * (((f64)(_const_math__rb2)) + s_ * tmp291));
16864+ f64 tmp292 = ((f64)(_const_math__sb3)) + s_ * (((f64)(_const_math__sb4)) + s_ * (((f64)(_const_math__sb5)) + s_ * (((f64)(_const_math__sb6)) + s_ * ((f64)(_const_math__sb7)))));
16865+ s = ((f64)(1.0)) + s_ * (((f64)(_const_math__sb1)) + s_ * (((f64)(_const_math__sb2)) + s_ * tmp292));
16866+ }
16867+ f64 z = math__f64_from_bits((math__f64_bits(x) & 0xffffffff00000000ULL));
16868+ f64 r_ = math__exp(-z * z - ((f64)(0.5625))) * math__exp((z - x) * (z + x) + r / s);
16869+ if (neg) {
16870+ return ((f64)(2.0)) - r_ / x;
16871+ }
16872+ return r_ / x;
16873+ }
16874+ if (neg) {
16875+ return 2.0;
16876+ }
16877+ return 0.0;
16878+}
16879+inline f64 math__exp(f64 x) {
16880+ return exp(x);
16881+}
16882+inline f64 math__exp2(f64 x) {
16883+ return exp2(x);
16884+}
16885+inline f64 math__ldexp(f64 frac, int exp) {
16886+ return ldexp(frac, exp);
16887+}
16888+f64 math__pure_v_but_overridden_by_c_exp(f64 x) {
16889+ f64 log2e = 1.44269504088896338700e+00;
16890+ f64 overflow = 7.09782712893383973096e+02;
16891+ f64 underflow = -7.45133219101941108420e+02;
16892+ float_literal near_zero = (float_literal)(1.0 / 268435456);
16893+ if (math__is_nan(x) || math__is_inf(x, 1)) {
16894+ return x;
16895+ }
16896+ if (math__is_inf(x, -1)) {
16897+ return 0.0;
16898+ }
16899+ if (x > overflow) {
16900+ return math__inf(1);
16901+ }
16902+ if (x < underflow) {
16903+ return 0.0;
16904+ }
16905+ if (-near_zero < x && x < near_zero) {
16906+ return ((f64)(1.0)) + x;
16907+ }
16908+ int k = 0;
16909+ if (x < 0) {
16910+ k = ((int)(log2e * x - ((f64)(0.5))));
16911+ }
16912+ if (x > 0) {
16913+ k = ((int)(log2e * x + ((f64)(0.5))));
16914+ }
16915+ f64 hi = x - ((f64)(k)) * ((f64)(_const_math__ln2hi));
16916+ f64 lo = ((f64)(k)) * ((f64)(_const_math__ln2lo));
16917+ return math__expmulti(hi, lo, k);
16918+}
16919+f64 math__pure_v_but_overridden_by_c_exp2(f64 x) {
16920+ f64 overflow = 1.0239999999999999e+03;
16921+ f64 underflow = -1.0740e+03;
16922+ if (math__is_nan(x) || math__is_inf(x, 1)) {
16923+ return x;
16924+ }
16925+ if (math__is_inf(x, -1)) {
16926+ return 0;
16927+ }
16928+ if (x > overflow) {
16929+ return math__inf(1);
16930+ }
16931+ if (x < underflow) {
16932+ return 0;
16933+ }
16934+ int k = 0;
16935+ if (x > 0) {
16936+ k = ((int)(x + ((f64)(0.5))));
16937+ }
16938+ if (x < 0) {
16939+ k = ((int)(x - ((f64)(0.5))));
16940+ }
16941+ f64 t = x - ((f64)(k));
16942+ f64 hi = t * ((f64)(_const_math__ln2hi));
16943+ f64 lo = -t * ((f64)(_const_math__ln2lo));
16944+ return math__expmulti(hi, lo, k);
16945+}
16946+f64 math__pure_v_but_overridden_by_c_ldexp(f64 frac, int exp) {
16947+ return math__scalbn(frac, exp);
16948+}
16949+multi_return_f64_int math__frexp(f64 x) {
16950+ u64 y = math__f64_bits(x);
16951+ int ee = ((int)(((v__rshift_u64(y, (u64)52)) & 0x7ff)));
16952+ if (ee == 0) {
16953+ if (x != ((f64)(0.0))) {
16954+ f64 x1p64 = math__f64_from_bits(((u64)(0x43f0000000000000LL)));
16955+ multi_return_f64_int mr_3373 = math__frexp(x * x1p64);
16956+ f64 z = mr_3373.arg0;
16957+ int e_ = mr_3373.arg1;
16958+ return (multi_return_f64_int){.arg0=z, .arg1=e_ - 64};
16959+ }
16960+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16961+ } else if (ee == 0x7ff) {
16962+ return (multi_return_f64_int){.arg0=x, .arg1=0};
16963+ }
16964+ int e_ = ee - 0x3fe;
16965+ y &= ((u64)(0x800fffffffffffffULL));
16966+ y |= ((u64)(0x3fe0000000000000LL));
16967+ return (multi_return_f64_int){.arg0=math__f64_from_bits(y), .arg1=e_};
16968+}
16969+f64 math__expm1(f64 x) {
16970+ if (math__is_inf(x, 1) || math__is_nan(x)) {
16971+ return x;
16972+ }
16973+ if (math__is_inf(x, -1)) {
16974+ return ((f64)(-1));
16975+ }
16976+ if (math__abs_T_f64(x) < ((f64)(_const_math__ln2))) {
16977+ f64 i = 1.0;
16978+ f64 sum = x;
16979+ f64 term = x / ((f64)(1.0));
16980+ i++;
16981+ term *= x / ((f64)(i));
16982+ sum += term;
16983+ for (;;) {
16984+ if (!(math__abs_T_f64(term) > math__abs_T_f64(sum) * ((f64)(_const_math__internal__f64_epsilon)))) break;
16985+ i++;
16986+ term *= x / ((f64)(i));
16987+ sum += term;
16988+ }
16989+ return sum;
16990+ } else {
16991+ return math__exp(x) - 1;
16992+ }
16993+ return 0;
16994+}
16995+VV_LOC f64 math__expmulti(f64 hi, f64 lo, int k) {
16996+ f64 exp_p1 = 1.66666666666666657415e-01;
16997+ f64 exp_p2 = -2.77777777770155933842e-03;
16998+ f64 exp_p3 = 6.61375632143793436117e-05;
16999+ f64 exp_p4 = -1.65339022054652515390e-06;
17000+ f64 exp_p5 = 4.13813679705723846039e-08;
17001+ f64 r = hi - lo;
17002+ f64 t = r * r;
17003+ f64 c = r - t * (exp_p1 + t * (exp_p2 + t * (exp_p3 + t * (exp_p4 + t * exp_p5))));
17004+ f64 y = 1 - ((lo - (r * c) / (2 - c)) - hi);
17005+ return math__ldexp(y, k);
17006+}
17007+f64 math__factorial(f64 n) {
17008+ if (n >= _const_math__factorials_table.len) {
17009+ return _const_math__max_f64;
17010+ }
17011+ if (n == ((f64)(((i64)(n)))) && n >= ((f64)(0.0))) {
17012+ return (*(f64*)builtin__array_get(_const_math__factorials_table, ((int)(n))));
17013+ }
17014+ return math__gamma(n + ((f64)(1.0)));
17015+}
17016+f64 math__log_factorial(f64 n) {
17017+ if (n < 0) {
17018+ return -_const_math__max_f64;
17019+ }
17020+ if (n != ((f64)(((i64)(n))))) {
17021+ return math__log_gamma(n + 1);
17022+ } else if (n < _const_math__log_factorials_table.len) {
17023+ return (*(f64*)builtin__array_get(_const_math__log_factorials_table, ((int)(n))));
17024+ }
17025+ return math__log_factorial_asymptotic_expansion(((int)(n)));
17026+}
17027+VV_LOC f64 math__log_factorial_asymptotic_expansion(int n) {
17028+ int m = 6;
17029+ Array_f64 term = builtin____new_array_with_default(0, 0, sizeof(f64), 0);
17030+ f64 xx = ((f64)((n + 1) * (n + 1)));
17031+ f64 xj = ((f64)(n + 1));
17032+ f64 log_fact = ((f64)(_const_math__log_sqrt_2pi)) - xj + (xj - ((f64)(0.5))) * math__log(xj);
17033+ int i = 0;
17034+ for (i = 0; i < m; i++) {
17035+ builtin__array_push((array*)&term, _MOV((f64[]){ (*(f64*)builtin__array_get(_const_math__bernoulli, i)) / xj }));
17036+ xj *= xx;
17037+ }
17038+ f64 sum = (*(f64*)builtin__array_get(term, m - 1));
17039+ for (i = m - 2; i >= 0; i--) {
17040+ if (math__abs_T_f64(sum) <= math__abs_T_f64((*(f64*)builtin__array_get(term, i)))) {
17041+ break;
17042+ }
17043+ sum = (*(f64*)builtin__array_get(term, i));
17044+ }
17045+ for (;;) {
17046+ if (!(i >= 0)) break;
17047+ sum += (*(f64*)builtin__array_get(term, i));
17048+ i--;
17049+ }
17050+ return log_fact + sum;
17051+}
17052+i64 math__factoriali(int n) {
17053+ if (n <= 0) {
17054+ return ((i64)(1));
17055+ }
17056+ if (n < 21) {
17057+ return ((i64)((*(f64*)builtin__array_get(_const_math__factorials_table, n))));
17058+ }
17059+ return ((i64)(-1));
17060+}
17061+f64 math__floor(f64 x) {
17062+ if (x == 0 || math__is_nan(x) || math__is_inf(x, 0)) {
17063+ return x;
17064+ }
17065+ if (x < 0) {
17066+ multi_return_f64_f64 mr_280 = math__modf(-x);
17067+ f64 d = mr_280.arg0;
17068+ f64 fract = mr_280.arg1;
17069+ if (fract != ((f64)(0.0))) {
17070+ d = d + 1;
17071+ }
17072+ return -d;
17073+ }
17074+ multi_return_f64_f64 mr_350 = math__modf(x);
17075+ f64 d = mr_350.arg0;
17076+ return d;
17077+}
17078+f32 math__floorf(f32 x) {
17079+ return ((f32)(math__floor(((f64)(x)))));
17080+}
17081+f64 math__ceil(f64 x) {
17082+ return -math__floor(-x);
17083+}
17084+f64 math__trunc(f64 x) {
17085+ if (x == 0 || math__is_nan(x) || math__is_inf(x, 0)) {
17086+ return x;
17087+ }
17088+ multi_return_f64_f64 mr_1200 = math__modf(x);
17089+ f64 d = mr_1200.arg0;
17090+ return d;
17091+}
17092+f64 math__round(f64 x) {
17093+ u64 bits = math__f64_bits(x);
17094+ u64 e_ = ((v__rshift_u64(bits, (u64)52)) & 0x7FF);
17095+ if (e_ < 1023) {
17096+ bits &= _const_math__sign_mask;
17097+ if (e_ == 1022) {
17098+ bits |= _const_math__uvone;
17099+ }
17100+ } else if (e_ < 1075) {
17101+ u64 half = v__lshift_u64(((u64)(1)), (u64)51);
17102+ e_ -= _const_math__bias;
17103+ bits += v__rshift_u64(half, (u64)e_);
17104+ bits &= ~(v__rshift_u64(_const_math__frac_mask, (u64)e_));
17105+ }
17106+ return math__f64_from_bits(bits);
17107+}
17108+f64 math__round_sig(f64 x, int sig_digits) {
17109+ string ret_str = builtin__f64_str(x);
17110+ switch (sig_digits) {
17111+ case 0: {
17112+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000000d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17113+ break;
17114+ }
17115+ case 1: {
17116+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000020d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17117+ break;
17118+ }
17119+ case 2: {
17120+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000040d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17121+ break;
17122+ }
17123+ case 3: {
17124+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000060d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17125+ break;
17126+ }
17127+ case 4: {
17128+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000080d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17129+ break;
17130+ }
17131+ case 5: {
17132+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000a0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17133+ break;
17134+ }
17135+ case 6: {
17136+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000c0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17137+ break;
17138+ }
17139+ case 7: {
17140+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80000e0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17141+ break;
17142+ }
17143+ case 8: {
17144+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000100d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17145+ break;
17146+ }
17147+ case 9: {
17148+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000120d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17149+ break;
17150+ }
17151+ case 10: {
17152+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000140d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17153+ break;
17154+ }
17155+ case 11: {
17156+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000160d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17157+ break;
17158+ }
17159+ case 12: {
17160+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000180d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17161+ break;
17162+ }
17163+ case 13: {
17164+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001a0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17165+ break;
17166+ }
17167+ case 14: {
17168+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001c0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17169+ break;
17170+ }
17171+ case 15: {
17172+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x80001e0d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17173+ break;
17174+ }
17175+ case 16: {
17176+ ret_str = builtin__str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0x8000200d, {.d_f64 = x}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}));
17177+ break;
17178+ }
17179+ default: {
17180+ {
17181+ ret_str = builtin__f64_str(x);
17182+ break;
17183+ }
17184+ }
17185+ }
17186+
17187+ return builtin__string_f64(ret_str);
17188+}
17189+f64 math__round_to_even(f64 x) {
17190+ u64 bits = math__f64_bits(x);
17191+ u64 e_ = ((v__rshift_u64(bits, (u64)52)) & 0x7FF);
17192+ if (e_ >= 1023) {
17193+ u64 half_minus_ulp = ((u64)(v__lshift_u64(((u64)(1)), (u64)51))) - 1;
17194+ e_ -= ((u64)(_const_math__bias));
17195+ bits += math__safe_shift(half_minus_ulp + (math__safe_shift(bits, 52 - e_) & 1), e_);
17196+ bits &= ~math__safe_shift(_const_math__frac_mask, e_);
17197+ } else if (e_ == 1022 && (bits & _const_math__frac_mask) != 0) {
17198+ bits = ((bits & _const_math__sign_mask) | _const_math__uvone);
17199+ } else {
17200+ bits &= _const_math__sign_mask;
17201+ }
17202+ return math__f64_from_bits(bits);
17203+}
17204+inline VV_LOC u64 math__safe_shift(u64 value, u64 shift) {
17205+ return (shift > ((u64)(63)) ? (((u64)(0))) : (v__rshift_u64(value, (u64)shift)));
17206+}
17207+VV_LOC bool math__is_neg_int(f64 x) {
17208+ if (x < 0) {
17209+ multi_return_f64_f64 mr_61 = math__modf(x);
17210+ f64 xf = mr_61.arg1;
17211+ return xf == 0;
17212+ }
17213+ return false;
17214+}
17215+VV_LOC multi_return_f64_f64 math__stirling(f64 x) {
17216+ if (x > 200) {
17217+ return (multi_return_f64_f64){.arg0=math__inf(1), .arg1=1.0};
17218+ }
17219+ f64 w = ((f64)(1.0)) / x;
17220+ w = ((f64)(1.0)) + w * (((((*(f64*)builtin__array_get(_const_math__gamma_s, 0)) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 1))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 2))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 3))) * w + (*(f64*)builtin__array_get(_const_math__gamma_s, 4)));
17221+ f64 y1 = math__exp(x);
17222+ f64 y2 = 1.0;
17223+ if (x > ((f64)(143.01608))) {
17224+ f64 v = math__pow(x, ((f64)(0.5)) * x - ((f64)(0.25)));
17225+ f64 y1_ = y1;
17226+ y1 = v;
17227+ y2 = v / y1_;
17228+ } else {
17229+ y1 = math__pow(x, x - ((f64)(0.5))) / y1;
17230+ }
17231+ return (multi_return_f64_f64){.arg0=y1, .arg1=((f64)(2.506628274631000502417)) * w * y2};
17232+}
17233+f64 math__gamma(f64 a) {
17234+ f64 x = a;
17235+ if (math__is_neg_int(x) || math__is_inf(x, -1) || math__is_nan(x)) {
17236+ return math__nan();
17237+ }
17238+ if (math__is_inf(x, 1)) {
17239+ return math__inf(1);
17240+ }
17241+ if (x == ((f64)(0.0))) {
17242+ return math__copysign(math__inf(1), x);
17243+ }
17244+ f64 q = math__abs_T_f64(x);
17245+ f64 p = math__floor(q);
17246+ if (q > 33) {
17247+ if (x >= 0) {
17248+ multi_return_f64_f64 mr_1507 = math__stirling(x);
17249+ f64 y1 = mr_1507.arg0;
17250+ f64 y2 = mr_1507.arg1;
17251+ return y1 * y2;
17252+ }
17253+ int signgam = 1;
17254+ i64 ip = ((i64)(p));
17255+ if (((ip & 1)) == 0) {
17256+ signgam = -1;
17257+ }
17258+ f64 z = q - p;
17259+ if (z > ((f64)(0.5))) {
17260+ p = p + 1;
17261+ z = q - p;
17262+ }
17263+ z = q * math__sin(((f64)(_const_math__pi)) * z);
17264+ if (z == 0) {
17265+ return math__inf(signgam);
17266+ }
17267+ multi_return_f64_f64 mr_1952 = math__stirling(q);
17268+ f64 sq1 = mr_1952.arg0;
17269+ f64 sq2 = mr_1952.arg1;
17270+ f64 absz = math__abs_T_f64(z);
17271+ f64 d = absz * sq1 * sq2;
17272+ if (math__is_inf(d, 0)) {
17273+ z = ((f64)(_const_math__pi)) / absz / sq1 / sq2;
17274+ } else {
17275+ z = ((f64)(_const_math__pi)) / d;
17276+ }
17277+ return ((f64)(signgam)) * z;
17278+ }
17279+ f64 z = 1.0;
17280+ for (;;) {
17281+ if (!(x >= 3)) break;
17282+ x = x - 1;
17283+ z = z * x;
17284+ }
17285+ for (;;) {
17286+ if (!(x < 0)) break;
17287+ if (x > ((f64)(-1e-09))) {
17288+ return math__gamma_too_small(x, z);
17289+ }
17290+ z = z / x;
17291+ x = x + 1;
17292+ }
17293+ for (;;) {
17294+ if (!(x < 2)) break;
17295+ if (x < ((f64)(1e-09))) {
17296+ return math__gamma_too_small(x, z);
17297+ }
17298+ z = z / x;
17299+ x = x + 1;
17300+ }
17301+ if (x == 2) {
17302+ return z;
17303+ }
17304+ x = x - 2;
17305+ p = (((((x * (*(f64*)builtin__array_get(_const_math__gamma_p, 0)) + (*(f64*)builtin__array_get(_const_math__gamma_p, 1))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 2))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 3))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 4))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 5))) * x + (*(f64*)builtin__array_get(_const_math__gamma_p, 6));
17306+ q = ((((((x * (*(f64*)builtin__array_get(_const_math__gamma_q, 0)) + (*(f64*)builtin__array_get(_const_math__gamma_q, 1))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 2))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 3))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 4))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 5))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 6))) * x + (*(f64*)builtin__array_get(_const_math__gamma_q, 7));
17307+ return z * p / q;
17308+}
17309+VV_LOC f64 math__gamma_too_small(f64 x, f64 z) {
17310+ if (x == 0) {
17311+ return math__inf(1);
17312+ }
17313+ f64 euler = 0.57721566490153286060651209008240243104215933593992;
17314+ return z / ((((f64)(1.0)) + euler * x) * x);
17315+}
17316+f64 math__log_gamma(f64 x) {
17317+ multi_return_f64_int mr_3163 = math__log_gamma_sign(x);
17318+ f64 y = mr_3163.arg0;
17319+ return y;
17320+}
17321+multi_return_f64_int math__log_gamma_sign(f64 a) {
17322+ f64 x = a;
17323+ int sgn = 1;
17324+ if (math__is_nan(x)) {
17325+ return (multi_return_f64_int){.arg0=x, .arg1=sgn};
17326+ }
17327+ if (math__is_inf(x, 1)) {
17328+ return (multi_return_f64_int){.arg0=x, .arg1=sgn};
17329+ }
17330+ if (x == ((f64)(0.0))) {
17331+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17332+ }
17333+ bool neg = false;
17334+ if (x < 0) {
17335+ x = -x;
17336+ neg = true;
17337+ }
17338+ if (x < math__exp2(-70)) {
17339+ if (neg) {
17340+ sgn = -1;
17341+ }
17342+ return (multi_return_f64_int){.arg0=-math__log(x), .arg1=sgn};
17343+ }
17344+ f64 nadj = 0.0;
17345+ if (neg) {
17346+ if (x >= math__exp2(52)) {
17347+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17348+ }
17349+ f64 t = math__sin_pi(x);
17350+ if (t == 0) {
17351+ return (multi_return_f64_int){.arg0=math__inf(1), .arg1=sgn};
17352+ }
17353+ nadj = math__log(((f64)(_const_math__pi)) / math__abs_T_f64(t * x));
17354+ if (t < 0) {
17355+ sgn = -1;
17356+ }
17357+ }
17358+ f64 lgamma = 0.0;
17359+ if (x == 1 || x == 2) {
17360+ return (multi_return_f64_int){.arg0=0.0, .arg1=sgn};
17361+ } else if (x < 2) {
17362+ f64 ymin = 1.461632144968362245;
17363+ f64 tc = 1.46163214496836224576e+00;
17364+ f64 y = 0.0;
17365+ int i = 0;
17366+ if (x <= ((f64)(0.9))) {
17367+ lgamma = -math__log(x);
17368+ if (x >= (ymin - 1 + ((f64)(0.27)))) {
17369+ y = ((f64)(1.0)) - x;
17370+ i = 0;
17371+ } else if (x >= (ymin - 1 - ((f64)(0.27)))) {
17372+ y = x - (tc - 1);
17373+ i = 1;
17374+ } else {
17375+ y = x;
17376+ i = 2;
17377+ }
17378+ } else {
17379+ lgamma = 0;
17380+ if (x >= (ymin + ((f64)(0.27)))) {
17381+ y = ((f64)(2)) - x;
17382+ i = 0;
17383+ } else if (x >= (ymin - ((f64)(0.27)))) {
17384+ y = x - tc;
17385+ i = 1;
17386+ } else {
17387+ y = x - 1;
17388+ i = 2;
17389+ }
17390+ }
17391+ if (i == 0) {
17392+ f64 z = y * y;
17393+ f64 gamma_p1 = (*(f64*)builtin__array_get(_const_math__lgamma_a, 0)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 2)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 4)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 6)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 8)) + z * (*(f64*)builtin__array_get(_const_math__lgamma_a, 10))))));
17394+ f64 gamma_p2 = z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 1)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 3)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 5)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 7)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_a, 9)) + z * (*(f64*)builtin__array_get(_const_math__lgamma_a, 11)))))));
17395+ f64 p = y * gamma_p1 + gamma_p2;
17396+ lgamma += (p - ((f64)(0.5)) * y);
17397+ } else if (i == 1) {
17398+ f64 z = y * y;
17399+ f64 w = z * y;
17400+ f64 gamma_p1 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 0)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 3)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 6)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 9)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 12)))));
17401+ f64 gamma_p2 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 1)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 4)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 7)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 10)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 13)))));
17402+ f64 gamma_p3 = (*(f64*)builtin__array_get(_const_math__lgamma_t, 2)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 5)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 8)) + w * ((*(f64*)builtin__array_get(_const_math__lgamma_t, 11)) + w * (*(f64*)builtin__array_get(_const_math__lgamma_t, 14)))));
17403+ f64 tf = -1.21486290535849611461e-01;
17404+ f64 tt = -3.63867699703950536541e-18;
17405+ f64 p = z * gamma_p1 - (tt - w * (gamma_p2 + y * gamma_p3));
17406+ lgamma += (tf + p);
17407+ } else if (i == 2) {
17408+ f64 gamma_p1 = y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_u, 4)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_u, 5)))))));
17409+ f64 gamma_p2 = ((f64)(1.0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_v, 4)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_v, 5))))));
17410+ lgamma += (((f64)(-0.5)) * y + gamma_p1 / gamma_p2);
17411+ }
17412+ } else if (x < 8) {
17413+ int i = ((int)(x));
17414+ f64 y = x - ((f64)(i));
17415+ f64 tmp23456 = (*(f64*)builtin__array_get(_const_math__lgamma_s, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_s, 6)))));
17416+ f64 p = y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_s, 1)) + y * tmp23456));
17417+ f64 tmpr23456 = (*(f64*)builtin__array_get(_const_math__lgamma_r, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_r, 6)))));
17418+ f64 q = ((f64)(1.0)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_r, 1)) + y * tmpr23456);
17419+ lgamma = ((f64)(0.5)) * y + p / q;
17420+ f64 z = 1.0;
17421+ if (i == 7) {
17422+ z *= (y + 6);
17423+ z *= (y + 5);
17424+ z *= (y + 4);
17425+ z *= (y + 3);
17426+ z *= (y + 2);
17427+ lgamma += math__log(z);
17428+ } else if (i == 6) {
17429+ z *= (y + 5);
17430+ z *= (y + 4);
17431+ z *= (y + 3);
17432+ z *= (y + 2);
17433+ lgamma += math__log(z);
17434+ } else if (i == 5) {
17435+ z *= (y + 4);
17436+ z *= (y + 3);
17437+ z *= (y + 2);
17438+ lgamma += math__log(z);
17439+ } else if (i == 4) {
17440+ z *= (y + 3);
17441+ z *= (y + 2);
17442+ lgamma += math__log(z);
17443+ } else if (i == 3) {
17444+ z *= (y + 2);
17445+ lgamma += math__log(z);
17446+ }
17447+ } else if (x < math__exp2(58)) {
17448+ f64 t = math__log(x);
17449+ f64 z = ((f64)(1.0)) / x;
17450+ f64 y = z * z;
17451+ f64 w = (*(f64*)builtin__array_get(_const_math__lgamma_w, 0)) + z * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 1)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 2)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 3)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 4)) + y * ((*(f64*)builtin__array_get(_const_math__lgamma_w, 5)) + y * (*(f64*)builtin__array_get(_const_math__lgamma_w, 6)))))));
17452+ lgamma = (x - ((f64)(0.5))) * (t - ((f64)(1.0))) + w;
17453+ } else {
17454+ lgamma = x * (math__log(x) - ((f64)(1.0)));
17455+ }
17456+ if (neg) {
17457+ lgamma = nadj - lgamma;
17458+ }
17459+ return (multi_return_f64_int){.arg0=lgamma, .arg1=sgn};
17460+}
17461+VV_LOC f64 math__sin_pi(f64 x_) {
17462+ f64 x = x_;
17463+ if (x < ((f64)(0.25))) {
17464+ return -math__sin(((f64)(_const_math__pi)) * x);
17465+ }
17466+ f64 z = math__floor(x);
17467+ int n = 0;
17468+ if (z != x) {
17469+ x = math__mod(x, 2);
17470+ n = ((int)(x * 4));
17471+ } else {
17472+ if (x >= math__exp2(53)) {
17473+ x = 0;
17474+ n = 0;
17475+ } else {
17476+ f64 two52 = math__exp2(52);
17477+ if (x < two52) {
17478+ z = x + two52;
17479+ }
17480+ n = (1 & ((int)(math__f64_bits(z))));
17481+ x = ((f64)(n));
17482+ n = v__lshift_int(n, (u64)2);
17483+ }
17484+ }
17485+ if (n == 0) {
17486+ x = math__sin(((f64)(_const_math__pi)) * x);
17487+ } else if (n == 1 || n == 2) {
17488+ x = math__cos(((f64)(_const_math__pi)) * (((f64)(0.5)) - x));
17489+ } else if (n == 3 || n == 4) {
17490+ x = math__sin(((f64)(_const_math__pi)) * (((f64)(1.0)) - x));
17491+ } else if (n == 5 || n == 6) {
17492+ x = -math__cos(((f64)(_const_math__pi)) * (x - ((f64)(1.5))));
17493+ } else {
17494+ x = math__sin(((f64)(_const_math__pi)) * (x - 2));
17495+ }
17496+ return -x;
17497+}
17498+f64 math__hypot(f64 x, f64 y) {
17499+ f64 p = math__abs_T_f64(x);
17500+ f64 q = math__abs_T_f64(y);
17501+ if (math__is_inf(p, 1) || math__is_inf(q, 1)) {
17502+ return math__inf(1);
17503+ }
17504+ if (math__is_nan(p) || math__is_nan(q)) {
17505+ return math__nan();
17506+ }
17507+ if (p < q) {
17508+ f64 _var_382 = p;
17509+ f64 _var_385 = q;
17510+ p = _var_385;
17511+ q = _var_382;
17512+ }
17513+ if (p == ((f64)(0.0))) {
17514+ return 0.0;
17515+ }
17516+ q = q / p;
17517+ return p * math__sqrt(1 + q * q);
17518+}
17519+inline math__BezierPoint math__cubic_bezier(f64 t, Array_math__BezierPoint p) {
17520+ if (p.len != 4) {
17521+ builtin___v_panic(_S("invalid p.len"));
17522+ VUNREACHABLE();
17523+ }
17524+ return math__cubic_bezier_coords(t, ((math__BezierPoint*)p.data)[0].x, ((math__BezierPoint*)p.data)[1].x, ((math__BezierPoint*)p.data)[2].x, ((math__BezierPoint*)p.data)[3].x, ((math__BezierPoint*)p.data)[0].y, ((math__BezierPoint*)p.data)[1].y, ((math__BezierPoint*)p.data)[2].y, ((math__BezierPoint*)p.data)[3].y);
17525+}
17526+inline math__BezierPoint math__cubic_bezier_a(f64 t, Array_f64 x, Array_f64 y) {
17527+ if (x.len != 4) {
17528+ builtin___v_panic(_S("invalid x.len"));
17529+ VUNREACHABLE();
17530+ }
17531+ if (y.len != 4) {
17532+ builtin___v_panic(_S("invalid y.len"));
17533+ VUNREACHABLE();
17534+ }
17535+ return math__cubic_bezier_coords(t, ((f64*)x.data)[0], ((f64*)x.data)[1], ((f64*)x.data)[2], ((f64*)x.data)[3], ((f64*)y.data)[0], ((f64*)y.data)[1], ((f64*)y.data)[2], ((f64*)y.data)[3]);
17536+}
17537+inline math__BezierPoint math__cubic_bezier_fa(f64 t, Array_fixed_f64_4 x, Array_fixed_f64_4 y) {
17538+ return math__cubic_bezier_coords(t, x[0], x[1], x[2], x[3], y[0], y[1], y[2], y[3]);
17539+}
17540+inline math__BezierPoint math__cubic_bezier_coords(f64 t, f64 x0, f64 x1, f64 x2, f64 x3, f64 y0, f64 y1, f64 y2, f64 y3) {
17541+ f64 p0 = math__pow(1 - t, 3);
17542+ f64 p1 = 3 * t * math__pow(1 - t, 2);
17543+ f64 p2 = 3 * (1 - t) * math__pow(t, 2);
17544+ f64 p3 = math__pow(t, 3);
17545+ f64 xt = p0 * x0 + p1 * x1 + p2 * x2 + p3 * x3;
17546+ f64 yt = p0 * y0 + p1 * y1 + p2 * y2 + p3 * y3;
17547+ return ((math__BezierPoint){.x = xt,.y = yt,});
17548+}
17549+f64 math__acosh(f64 x) {
17550+ if (x > ((f64)(6.7108864e+07))) {
17551+ return math__log(x) + ((f64)(_const_math__ln2));
17552+ } else if (x > ((f64)(2.0))) {
17553+ return math__log(((f64)(2.0)) * x - ((f64)(1.0)) / (math__sqrt(x * x - ((f64)(1.0))) + x));
17554+ } else if (x > ((f64)(1.0))) {
17555+ f64 t = x - ((f64)(1.0));
17556+ return math__log1p(t + math__sqrt(((f64)(2.0)) * t + t * t));
17557+ } else if (x == ((f64)(1.0))) {
17558+ return 0.0;
17559+ } else {
17560+ return math__nan();
17561+ }
17562+ return 0;
17563+}
17564+f64 math__asinh(f64 x) {
17565+ f64 a = math__abs_T_f64(x);
17566+ f64 s = (x < 0 ? (-1.0) : (1.0));
17567+ if (a > ((f64)(6.7108864e+07))) {
17568+ return s * (math__log(a) + ((f64)(_const_math__ln2)));
17569+ } else if (a > ((f64)(2.0))) {
17570+ return s * math__log(((f64)(2.0)) * a + ((f64)(1.0)) / (a + math__sqrt(a * a + ((f64)(1.0)))));
17571+ } else if (a > ((f64)(_const_math__internal__sqrt_f64_epsilon))) {
17572+ f64 a2 = a * a;
17573+ return s * math__log1p(a + a2 / (((f64)(1.0)) + math__sqrt(((f64)(1.0)) + a2)));
17574+ } else {
17575+ return x;
17576+ }
17577+ return 0;
17578+}
17579+f64 math__atanh(f64 x) {
17580+ f64 a = math__abs_T_f64(x);
17581+ f64 s = (x < 0 ? (-1.0) : (1.0));
17582+ if (a > ((f64)(1.0))) {
17583+ return math__nan();
17584+ } else if (a == ((f64)(1.0))) {
17585+ return (x < 0 ? (math__inf(-1)) : (math__inf(1)));
17586+ } else if (a >= ((f64)(0.5))) {
17587+ return s * ((f64)(0.5)) * math__log1p(((f64)(2.0)) * a / (((f64)(1.0)) - a));
17588+ } else if (a > ((f64)(_const_math__internal__f64_epsilon))) {
17589+ return s * ((f64)(0.5)) * math__log1p(((f64)(2.0)) * a + ((f64)(2.0)) * a * a / (((f64)(1.0)) - a));
17590+ } else {
17591+ return x;
17592+ }
17593+ return 0;
17594+}
17595+inline VV_LOC f64 math__xatan(f64 x) {
17596+ f64 xatan_p0 = -8.750608600031904122785e-01;
17597+ f64 xatan_p1 = -1.615753718733365076637e+01;
17598+ f64 xatan_p2 = -7.500855792314704667340e+01;
17599+ f64 xatan_p3 = -1.228866684490136173410e+02;
17600+ f64 xatan_p4 = -6.485021904942025371773e+01;
17601+ f64 xatan_q0 = 2.485846490142306297962e+01;
17602+ f64 xatan_q1 = 1.650270098316988542046e+02;
17603+ f64 xatan_q2 = 4.328810604912902668951e+02;
17604+ f64 xatan_q3 = 4.853903996359136964868e+02;
17605+ f64 xatan_q4 = 1.945506571482613964425e+02;
17606+ f64 z = x * x;
17607+ z = z * ((((xatan_p0 * z + xatan_p1) * z + xatan_p2) * z + xatan_p3) * z + xatan_p4) / (((((z + xatan_q0) * z + xatan_q1) * z + xatan_q2) * z + xatan_q3) * z + xatan_q4);
17608+ z = x * z + x;
17609+ return z;
17610+}
17611+inline VV_LOC f64 math__satan(f64 x) {
17612+ if (x <= ((f64)(0.66))) {
17613+ return math__xatan(x);
17614+ }
17615+ if (x > ((f64)(_const_math__tan3pio8))) {
17616+ return ((f64)(1.5707963267948966)) - math__xatan(((f64)(1.0)) / x) + ((f64)(_const_math__morebits));
17617+ }
17618+ return ((f64)((float_literal)(3.14159265358979323846264338327950288419716939937510582097494459 / 4))) + math__xatan((x - ((f64)(1.0))) / (x + ((f64)(1.0)))) + ((f64)(0.5)) * ((f64)(_const_math__morebits));
17619+}
17620+f64 math__atan(f64 x) {
17621+ if (x == 0) {
17622+ return x;
17623+ }
17624+ if (x > 0) {
17625+ return math__satan(x);
17626+ }
17627+ return -math__satan(-x);
17628+}
17629+f64 math__atan2(f64 y, f64 x) {
17630+ if (math__is_nan(y) || math__is_nan(x)) {
17631+ return math__nan();
17632+ }
17633+ if (y == ((f64)(0.0))) {
17634+ if (x >= 0 && !math__signbit(x)) {
17635+ return math__copysign(0, y);
17636+ }
17637+ return math__copysign(_const_math__pi, y);
17638+ }
17639+ if (x == ((f64)(0.0))) {
17640+ return math__copysign(1.5707963267948966, y);
17641+ }
17642+ if (math__is_inf(x, 0)) {
17643+ if (math__is_inf(x, 1)) {
17644+ if (math__is_inf(y, 0)) {
17645+ return math__copysign((float_literal)(3.14159265358979323846264338327950288419716939937510582097494459 / 4), y);
17646+ }
17647+ return math__copysign(0, y);
17648+ }
17649+ if (math__is_inf(y, 0)) {
17650+ return math__copysign(2.356194490192345, y);
17651+ }
17652+ return math__copysign(_const_math__pi, y);
17653+ }
17654+ if (math__is_inf(y, 0)) {
17655+ return math__copysign(1.5707963267948966, y);
17656+ }
17657+ f64 q = math__atan(y / x);
17658+ if (x < 0) {
17659+ if (q <= 0) {
17660+ return q + ((f64)(_const_math__pi));
17661+ }
17662+ return q - ((f64)(_const_math__pi));
17663+ }
17664+ return q;
17665+}
17666+f64 math__asin(f64 x_) {
17667+ f64 x = x_;
17668+ if (x == ((f64)(0.0))) {
17669+ return x;
17670+ }
17671+ bool neg = false;
17672+ if (x < ((f64)(0.0))) {
17673+ x = -x;
17674+ neg = true;
17675+ }
17676+ if (x > ((f64)(1.0))) {
17677+ return math__nan();
17678+ }
17679+ f64 temp = math__sqrt(((f64)(1.0)) - x * x);
17680+ if (x > ((f64)(0.7))) {
17681+ temp = ((f64)(1.5707963267948966)) - math__satan(temp / x);
17682+ } else {
17683+ temp = math__satan(x / temp);
17684+ }
17685+ if (neg) {
17686+ temp = -temp;
17687+ }
17688+ return temp;
17689+}
17690+inline f64 math__acos(f64 x) {
17691+ if (x < ((f64)(-1.0)) || x > ((f64)(1.0))) {
17692+ return math__nan();
17693+ }
17694+ if (x > ((f64)(0.5))) {
17695+ return ((f64)(2.0)) * math__asin(math__sqrt(((f64)(0.5)) - ((f64)(0.5)) * x));
17696+ }
17697+ f64 z = ((f64)(_const_math__pi)) / ((f64)(4.0)) - math__asin(x);
17698+ z = z + ((f64)(_const_math__morebits));
17699+ z = z + ((f64)(_const_math__pi)) / ((f64)(4.0));
17700+ return z;
17701+}
17702+inline f64 math__log(f64 x) {
17703+ return log(x);
17704+}
17705+inline f64 math__log2(f64 x) {
17706+ return log2(x);
17707+}
17708+inline f64 math__log10(f64 x) {
17709+ return log10(x);
17710+}
17711+inline f64 math__log1p(f64 x) {
17712+ return log1p(x);
17713+}
17714+f64 math__log_b(f64 x) {
17715+ return logb(x);
17716+}
17717+inline f32 math__logf(f32 x) {
17718+ return logf(x);
17719+}
17720+f64 math__log_n(f64 x, f64 b) {
17721+ f64 y = math__log(x);
17722+ f64 z = math__log(b);
17723+ return y / z;
17724+}
17725+f64 math__pure_v_but_overridden_by_c_log10(f64 x) {
17726+ f64 x_ = x;
17727+ i64 hx = ((i64)(math__f64_bits(x_)));
17728+ i32 k = ((i32)(0));
17729+ if (hx < ((i64)(0x0010000000000000LL))) {
17730+ if ((hx & 0x7fffffffffffffffLL) == 0) {
17731+ return math__inf(-1);
17732+ }
17733+ if (hx < 0) {
17734+ return (x_ - x_) / (x_ - x_);
17735+ }
17736+ k = k - 54;
17737+ x_ *= _const_math__two54;
17738+ hx = ((i64)(math__f64_bits(x_)));
17739+ }
17740+ if (_us64_le(((u64)(0x7ff0000000000000LL)),hx)) {
17741+ return x_ + x_;
17742+ }
17743+ k = k + ((i32)((((u64)((v__rshift_i64(hx, (u64)52)) - 1023)))));
17744+ i32 i = ((i32)(v__rshift_u64(((((u64)(k)) & 0x8000000000000000ULL)), (u64)63)));
17745+ hx = (((hx & 0x000fffffffffffffLL)) | (v__lshift_u64(((u64)(0x3ff - i)), (u64)52)));
17746+ f64 y = ((f64)(k + i));
17747+ x_ = math__f64_from_bits(((u64)(hx)));
17748+ f64 z = y * _const_math__log10_2lo + _const_math__ivln10 * math__log(x_);
17749+ return z + y * _const_math__log10_2hi;
17750+}
17751+f64 math__pure_v_but_overridden_by_c_log2(f64 x) {
17752+ multi_return_f64_int mr_1442 = math__frexp(x);
17753+ f64 frac = mr_1442.arg0;
17754+ int expn = mr_1442.arg1;
17755+ if (frac == ((f64)(0.5))) {
17756+ return ((f64)(expn - 1));
17757+ }
17758+ return math__log(frac) * ((f64)(1.4426950408889634)) + ((f64)(expn));
17759+}
17760+f64 math__pure_v_but_overridden_by_c_log1p(f64 x) {
17761+ f64 y = ((f64)(1.0)) + x;
17762+ f64 z = y - ((f64)(1.0));
17763+ return math__log(y) - (z - x) / y;
17764+}
17765+f64 math__pure_v_but_overridden_by_c_log_b(f64 x) {
17766+ if (x == 0) {
17767+ return math__inf(-1);
17768+ }
17769+ if (math__is_inf(x, 0)) {
17770+ return math__inf(1);
17771+ }
17772+ if (math__is_nan(x)) {
17773+ return x;
17774+ }
17775+ return ((f64)(math__ilog_b_(x)));
17776+}
17777+int math__ilog_b(f64 x) {
17778+ if (x == 0) {
17779+ return ((int)(_const_min_i32));
17780+ }
17781+ if (math__is_nan(x)) {
17782+ return ((int)(_const_max_i32));
17783+ }
17784+ if (math__is_inf(x, 0)) {
17785+ return ((int)(_const_max_i32));
17786+ }
17787+ return math__ilog_b_(x);
17788+}
17789+VV_LOC int math__ilog_b_(f64 x_) {
17790+ multi_return_f64_int mr_2548 = math__normalize(x_);
17791+ f64 x = mr_2548.arg0;
17792+ int expn = mr_2548.arg1;
17793+ return ((int)(((v__rshift_u64(math__f64_bits(x), (u64)52)) & 0x7FF))) - 1023 + expn;
17794+}
17795+f64 math__pure_v_but_overridden_by_c_log(f64 a) {
17796+ f64 ln2_hi = 6.93147180369123816490e-01;
17797+ f64 ln2_lo = 1.90821492927058770002e-10;
17798+ f64 l1 = 6.666666666666735130e-01;
17799+ f64 l2 = 3.999999999940941908e-01;
17800+ f64 l3 = 2.857142874366239149e-01;
17801+ f64 l4 = 2.222219843214978396e-01;
17802+ f64 l5 = 1.818357216161805012e-01;
17803+ f64 l6 = 1.531383769920937332e-01;
17804+ f64 l7 = 1.479819860511658591e-01;
17805+ f64 x = a;
17806+ if (math__is_nan(x) || math__is_inf(x, 1)) {
17807+ return x;
17808+ } else if (x < 0) {
17809+ return math__nan();
17810+ } else if (x == 0) {
17811+ return math__inf(-1);
17812+ }
17813+ multi_return_f64_int mr_5139 = math__frexp(x);
17814+ f64 f1 = mr_5139.arg0;
17815+ int ki = mr_5139.arg1;
17816+ if (f1 < ((f64)((float_literal)(1.41421356237309504880168872420969807856967187537694807317667974 / 2)))) {
17817+ f1 *= 2;
17818+ ki--;
17819+ }
17820+ f64 f = f1 - 1;
17821+ f64 k = ((f64)(ki));
17822+ f64 s = f / (2 + f);
17823+ f64 s2 = s * s;
17824+ f64 s4 = s2 * s2;
17825+ f64 t1 = s2 * (l1 + s4 * (l3 + s4 * (l5 + s4 * l7)));
17826+ f64 t2 = s4 * (l2 + s4 * (l4 + s4 * l6));
17827+ f64 r = t1 + t2;
17828+ f64 hfsq = ((f64)(0.5)) * f * f;
17829+ return k * ln2_hi - ((hfsq - (s * (hfsq + r) + k * ln2_lo)) - f);
17830+}
17831+#if 0
17832+#else
17833+#endif
17834+f64 math__aprox_sin(f64 a) {
17835+ f64 a0 = 1.91059300966915117e-31;
17836+ f64 a1 = 1.00086760103908896;
17837+ f64 a2 = -1.21276126894734565e-2;
17838+ f64 a3 = -1.38078780785773762e-1;
17839+ f64 a4 = -2.67353392911981221e-2;
17840+ f64 a5 = 2.08026600266304389e-2;
17841+ f64 a6 = -3.03996055049204407e-3;
17842+ f64 a7 = 1.38235642404333740e-4;
17843+ f64 tmp = a4 + a * (a5 + a * (a6 + a * a7));
17844+ return a0 + a * (a1 + a * (a2 + a * (a3 + a * tmp)));
17845+}
17846+f64 math__aprox_cos(f64 a) {
17847+ f64 a0 = 9.9995999154986614e-1;
17848+ f64 a1 = 1.2548995793001028e-3;
17849+ f64 a2 = -5.0648546280678015e-1;
17850+ f64 a3 = 1.2942246466519995e-2;
17851+ f64 a4 = 2.8668384702547972e-2;
17852+ f64 a5 = 7.3726485210586547e-3;
17853+ f64 a6 = -3.8510875386947414e-3;
17854+ f64 a7 = 4.7196604604366623e-4;
17855+ f64 a8 = -1.8776444013090451e-5;
17856+ f64 tmp = a4 + a * (a5 + a * (a6 + a * (a7 + a * a8)));
17857+ return a0 + a * (a1 + a * (a2 + a * (a3 + a * tmp)));
17858+}
17859+inline f64 math__copysign(f64 x, f64 y) {
17860+ return math__f64_from_bits((((math__f64_bits(x) & ~_const_math__sign_mask)) | ((math__f64_bits(y) & _const_math__sign_mask))));
17861+}
17862+inline f64 math__degrees(f64 radians) {
17863+ return radians * ((f64)(57.29577951308232));
17864+}
17865+inline f64 math__radians(f64 degrees) {
17866+ return degrees * ((f64)(0.017453292519943295));
17867+}
17868+inline f64 math__angle_diff(f64 radian_a, f64 radian_b) {
17869+ f64 delta = math__fmod(radian_b - radian_a, _const_math__tau);
17870+ delta = math__fmod(delta + ((f64)(9.42477796076938)), _const_math__tau);
17871+ delta -= 3.141592653589793;
17872+ return delta;
17873+}
17874+Array_int math__digits(i64 num, math__DigitParams params) {
17875+ int b = params.base;
17876+ if (b < 2) {
17877+ builtin__panic_n(_S("digits: Cannot find digits of n with base:"), b);
17878+ VUNREACHABLE();
17879+ }
17880+ i64 n = num;
17881+ int sgn = 1;
17882+ if (n < 0) {
17883+ sgn = -1;
17884+ n = -n;
17885+ }
17886+ Array_int res = builtin____new_array_with_default(0, 0, sizeof(int), 0);
17887+ if (n == 0) {
17888+ builtin__array_push((array*)&res, _MOV((int[]){ 0 }));
17889+ return res;
17890+ }
17891+ for (;;) {
17892+ if (!(n != 0)) break;
17893+ i64 next_n = (i64)(VSAFE_DIV_i64(n , b));
17894+ builtin__array_push((array*)&res, _MOV((int[]){ ((int)(n - (i64)(next_n * b))) }));
17895+ n = next_n;
17896+ }
17897+ if (sgn == -1) {
17898+ (*(int*)builtin__array_get(res, res.len - 1)) *= sgn;
17899+ }
17900+ if (params.reverse) {
17901+ res = builtin__array_reverse(res);
17902+ }
17903+ return res;
17904+}
17905+int math__count_digits(i64 number) {
17906+ i64 n = number;
17907+ if (n == 0) {
17908+ return 1;
17909+ }
17910+ int c = 0;
17911+ for (;;) {
17912+ if (!(n != 0)) break;
17913+ n = VSAFE_DIV_i64(n , 10);
17914+ c++;
17915+ }
17916+ return c;
17917+}
17918+multi_return_f64_f64 math__minmax(f64 a, f64 b) {
17919+ if (a < b) {
17920+ return (multi_return_f64_f64){.arg0=a, .arg1=b};
17921+ }
17922+ return (multi_return_f64_f64){.arg0=b, .arg1=a};
17923+}
17924+inline f64 math__clamp(f64 x, f64 a, f64 b) {
17925+ if (x < a) {
17926+ return a;
17927+ }
17928+ if (x > b) {
17929+ return b;
17930+ }
17931+ return x;
17932+}
17933+inline f64 math__sign(f64 n) {
17934+ if (math__is_nan(n)) {
17935+ return math__nan();
17936+ }
17937+ return math__copysign(1.0, n);
17938+}
17939+inline int math__signi(f64 n) {
17940+ return ((int)(math__copysign(1.0, n)));
17941+}
17942+inline bool math__signbit(f64 x) {
17943+ return (math__f64_bits(x) & _const_math__sign_mask) != 0;
17944+}
17945+bool math__tolerance(f64 actual, f64 expected, f64 tol) {
17946+ if (actual == expected) {
17947+ return true;
17948+ }
17949+ f64 d = actual - expected;
17950+ if (d < 0) {
17951+ d = -d;
17952+ }
17953+ f64 ee = tol;
17954+ if (expected != 0) {
17955+ ee *= expected;
17956+ if (ee < 0) {
17957+ ee = -ee;
17958+ }
17959+ }
17960+ return d < ee;
17961+}
17962+bool math__close(f64 actual, f64 expected) {
17963+ return math__tolerance(actual, expected, 1e-14);
17964+}
17965+bool math__veryclose(f64 actual, f64 expected) {
17966+ return math__tolerance(actual, expected, 4e-16);
17967+}
17968+bool math__alike(f64 a, f64 b) {
17969+ if ((math__f64_bits(a) & 0xFFFFFFFFFFFFFFFCULL) == (math__f64_bits(b) & 0xFFFFFFFFFFFFFFFCULL)) {
17970+ return true;
17971+ }
17972+ if (a == -0LL && b == 0) {
17973+ return true;
17974+ }
17975+ if (a == 0 && b == -0LL) {
17976+ return true;
17977+ }
17978+ if (math__is_nan(a) && math__is_nan(b)) {
17979+ return true;
17980+ }
17981+ if (a == b) {
17982+ return math__signbit(a) == math__signbit(b);
17983+ }
17984+ return false;
17985+}
17986+multi_return_f64_f64 math__modf(f64 f) {
17987+ f64 abs_f = math__abs_T_f64(f);
17988+ f64 i = 0.0;
17989+ if (abs_f >= ((f64)(_const_math__modf_maxpowtwo))) {
17990+ i = f;
17991+ } else {
17992+ i = abs_f + ((f64)(_const_math__modf_maxpowtwo));
17993+ i -= _const_math__modf_maxpowtwo;
17994+ for (;;) {
17995+ if (!(i > abs_f)) break;
17996+ i -= 1.0;
17997+ }
17998+ if (f < ((f64)(0.0))) {
17999+ i = -i;
18000+ }
18001+ }
18002+ return (multi_return_f64_f64){.arg0=i, .arg1=f - i};
18003+}
18004+f32 math__nextafter32(f32 x, f32 y) {
18005+ f32 r = ((f32)(0.0));
18006+ if (math__is_nan(((f64)(x))) || math__is_nan(((f64)(y)))) {
18007+ r = ((f32)(math__nan()));
18008+ } else if (x == y) {
18009+ r = x;
18010+ } else if (x == 0) {
18011+ r = ((f32)(math__copysign(((f64)(math__f32_from_bits(1))), ((f64)(y)))));
18012+ } else if ((y > x) == (x > 0)) {
18013+ r = math__f32_from_bits(math__f32_bits(x) + 1);
18014+ } else {
18015+ r = math__f32_from_bits(math__f32_bits(x) - 1);
18016+ }
18017+ return r;
18018+}
18019+f64 math__nextafter(f64 x, f64 y) {
18020+ f64 r = 0.0;
18021+ if (math__is_nan(x) || math__is_nan(y)) {
18022+ r = math__nan();
18023+ } else if (x == y) {
18024+ r = x;
18025+ } else if (x == 0) {
18026+ r = math__copysign(math__f64_from_bits(1), y);
18027+ } else if ((y > x) == (x > 0)) {
18028+ r = math__f64_from_bits(math__f64_bits(x) + 1);
18029+ } else {
18030+ r = math__f64_from_bits(math__f64_bits(x) - 1);
18031+ }
18032+ return r;
18033+}
18034+VV_LOC multi_return_f64_f64 math__ChebSeries_eval_e(math__ChebSeries cs, f64 x) {
18035+ f64 d = 0.0;
18036+ f64 dd = 0.0;
18037+ f64 y = (((f64)(2.0)) * x - cs.a - cs.b) / (cs.b - cs.a);
18038+ f64 y2 = ((f64)(2.0)) * y;
18039+ f64 e_ = 0.0;
18040+ f64 temp = 0.0;
18041+ for (int j = cs.order; j >= 1; j--) {
18042+ temp = d;
18043+ d = y2 * d - dd + (*(f64*)builtin__array_get(cs.c, j));
18044+ e_ += math__abs_T_f64(y2 * temp) + math__abs_T_f64(dd) + math__abs_T_f64((*(f64*)builtin__array_get(cs.c, j)));
18045+ dd = temp;
18046+ }
18047+ temp = d;
18048+ d = y * d - dd + ((f64)(0.5)) * (*(f64*)builtin__array_get(cs.c, 0));
18049+ e_ += math__abs_T_f64(y * temp) + math__abs_T_f64(dd) + ((f64)(0.5)) * math__abs_T_f64((*(f64*)builtin__array_get(cs.c, 0)));
18050+ return (multi_return_f64_f64){.arg0=d, .arg1=((f64)(_const_math__internal__f64_epsilon)) * e_ + math__abs_T_f64((*(f64*)builtin__array_get(cs.c, cs.order)))};
18051+}
18052+inline f64 math__pow(f64 x, f64 y) {
18053+ return pow(x, y);
18054+}
18055+inline f32 math__powf(f32 a, f32 b) {
18056+ return powf(a, b);
18057+}
18058+inline f32 math__pure_v_but_overridden_by_c_powf(f32 a, f32 b) {
18059+ return ((f32)(math__pow(a, b)));
18060+}
18061+f64 math__pow10(int n) {
18062+ if (0 <= n && n <= 308) {
18063+ return (*(f64*)builtin__array_get(_const_math__pow10postab32, VSAFE_DIV_u32(((u32)(n)) , 32))) * (*(f64*)builtin__array_get(_const_math__pow10tab, VSAFE_MOD_u32(((u32)(n)) , 32)));
18064+ }
18065+ if (-323 <= n && n <= 0) {
18066+ return (*(f64*)builtin__array_get(_const_math__pow10negtab32, VSAFE_DIV_u32(((u32)(-n)) , 32))) / (*(f64*)builtin__array_get(_const_math__pow10tab, VSAFE_MOD_u32(((u32)(-n)) , 32)));
18067+ }
18068+ if (n > 0) {
18069+ return math__inf(1);
18070+ }
18071+ return 0.0;
18072+}
18073+i64 math__powi(i64 a, i64 b) {
18074+ i64 b_ = b;
18075+ i64 p = a;
18076+ i64 v = ((i64)(1));
18077+ if (b_ < 0) {
18078+ if (a == 0) {
18079+ return -1;
18080+ }
18081+ return (a * a != 1 ? (0) : ((((b_ & 1)) > 0 ? (a) : (1))));
18082+ }
18083+ for (; b_ > 0; ) {
18084+ if ((b_ & 1) > 0) {
18085+ v *= p;
18086+ }
18087+ p *= p;
18088+ b_ = v__rshift_i64(b_, (u64)1);
18089+ }
18090+ return v;
18091+}
18092+VV_LOC bool math__is_odd_int(f64 x) {
18093+ multi_return_f64_f64 mr_1555 = math__modf(x);
18094+ f64 xi = mr_1555.arg0;
18095+ f64 xf = mr_1555.arg1;
18096+ return xf == 0 && ((((i64)(xi)) & 1)) == 1;
18097+}
18098+f64 math__pure_v_but_overridden_by_c_pow(f64 x, f64 y) {
18099+ if (y == 0 || x == 1) {
18100+ return 1;
18101+ } else if (y == 1) {
18102+ return x;
18103+ } else if (math__is_nan(x) || math__is_nan(y)) {
18104+ return math__nan();
18105+ } else if (y == 2) {
18106+ return x * x;
18107+ } else if (y == 3) {
18108+ return x * x * x;
18109+ } else if (x == 0) {
18110+ if (y < 0) {
18111+ if (math__is_odd_int(y)) {
18112+ return math__copysign(math__inf(1), x);
18113+ }
18114+ return math__inf(1);
18115+ } else if (y > 0) {
18116+ if (math__is_odd_int(y)) {
18117+ return x;
18118+ }
18119+ return 0;
18120+ }
18121+ } else if (math__is_inf(y, 0)) {
18122+ if (x == -1) {
18123+ return 1;
18124+ } else if ((math__abs_T_f64(x) < 1) == math__is_inf(y, 1)) {
18125+ return 0;
18126+ } else {
18127+ return math__inf(1);
18128+ }
18129+ } else if (math__is_inf(x, 0)) {
18130+ if (math__is_inf(x, -1)) {
18131+ return math__pow(1 / x, -y);
18132+ }
18133+ if (y < 0) {
18134+ return 0;
18135+ } else if (y > 0) {
18136+ return math__inf(1);
18137+ }
18138+ } else if (y == ((f64)(0.5))) {
18139+ return math__sqrt(x);
18140+ } else if (y == ((f64)(-0.5))) {
18141+ return 1 / math__sqrt(x);
18142+ }
18143+ multi_return_f64_f64 mr_2579 = math__modf(math__abs_T_f64(y));
18144+ f64 yi = mr_2579.arg0;
18145+ f64 yf = mr_2579.arg1;
18146+ if (yf != 0 && x < 0) {
18147+ return math__nan();
18148+ }
18149+ if (yi >= (v__lshift_u64(((u64)(1)), (u64)63))) {
18150+ if (x == -1) {
18151+ return 1;
18152+ } else if ((math__abs_T_f64(x) < 1) == (y > 0)) {
18153+ return 0;
18154+ } else {
18155+ return math__inf(1);
18156+ }
18157+ }
18158+ if (yf == ((f64)(0.0))) {
18159+ f64 result = x;
18160+ for (i64 _t22 = 1; _t22 < ((i64)(yi)); ++_t22) {
18161+ result *= x;
18162+ }
18163+ if (y > 0) {
18164+ return result;
18165+ }
18166+ return 1 / result;
18167+ }
18168+ f64 a1 = 1.0;
18169+ int ae = 0;
18170+ if (yf != 0) {
18171+ if (yf > ((f64)(0.5))) {
18172+ yf--;
18173+ yi++;
18174+ }
18175+ a1 = math__exp(yf * math__log(x));
18176+ }
18177+ multi_return_f64_int mr_3354 = math__frexp(x);
18178+ f64 x1 = mr_3354.arg0;
18179+ int xe = mr_3354.arg1;
18180+ for (i64 i = ((i64)(yi)); i != 0; i = v__rshift_i64(i, (u64)1)) {
18181+ if (xe < ((int)(((u32)(v__lshift_u32(((u32)(-1)), (u64)12))))) || 4096 < xe) {
18182+ ae += xe;
18183+ break;
18184+ }
18185+ if ((i & 1) == 1) {
18186+ a1 *= x1;
18187+ ae += xe;
18188+ }
18189+ x1 *= x1;
18190+ xe = v__lshift_int(xe, (u64)1);
18191+ if (x1 < ((f64)(.5))) {
18192+ x1 += x1;
18193+ xe--;
18194+ }
18195+ }
18196+ if (y < 0) {
18197+ a1 = 1 / a1;
18198+ ae = -ae;
18199+ }
18200+ return math__ldexp(a1, ae);
18201+}
18202+inline f64 math__q_rsqrt(f64 x) {
18203+ f64 x_half = ((f64)(0.5)) * x;
18204+ i64 i = ((i64)(math__f64_bits(x)));
18205+ i = 0x5fe6eb50c7b537a9LL - (v__rshift_i64(i, (u64)1));
18206+ f64 j = math__f64_from_bits(((u64)(i)));
18207+ j *= (((f64)(1.5)) - x_half * j * j);
18208+ j *= (((f64)(1.5)) - x_half * j * j);
18209+ return j;
18210+}
18211+f64 math__scalbn(f64 x, int n_) {
18212+ int n = n_;
18213+ f64 x1p1023 = math__f64_from_bits(((u64)(0x7fe0000000000000LL)));
18214+ f64 x1p53 = math__f64_from_bits(((u64)(0x4340000000000000LL)));
18215+ f64 x1p_1022 = math__f64_from_bits(((u64)(0x0010000000000000LL)));
18216+ f64 y = x;
18217+ if (n > 1023) {
18218+ y *= x1p1023;
18219+ n -= 1023;
18220+ if (n > 1023) {
18221+ y *= x1p1023;
18222+ n -= 1023;
18223+ if (n > 1023) {
18224+ n = 1023;
18225+ }
18226+ }
18227+ } else if (n < -1022) {
18228+ y *= x1p_1022 * x1p53;
18229+ n += 969;
18230+ if (n < -1022) {
18231+ y *= x1p_1022 * x1p53;
18232+ n += 969;
18233+ if (n < -1022) {
18234+ n = -1022;
18235+ }
18236+ }
18237+ }
18238+ return y * math__f64_from_bits(v__lshift_u64(((u64)((0x3ff + n))), (u64)52));
18239+}
18240+inline f64 math__cos(f64 a) {
18241+ return cos(a);
18242+}
18243+inline f64 math__sin(f64 a) {
18244+ return sin(a);
18245+}
18246+inline f32 math__cosf(f32 a) {
18247+ return cosf(a);
18248+}
18249+inline f32 math__sinf(f32 a) {
18250+ return sinf(a);
18251+}
18252+f64 math__pure_v_but_overridden_by_c_sin(f64 x) {
18253+ f64 p1 = 7.85398125648498535156e-1;
18254+ f64 p2 = 3.77489470793079817668e-8;
18255+ f64 p3 = 2.69515142907905952645e-15;
18256+ int sgn_x = (x < 0 ? (-1) : (1));
18257+ f64 abs_x = math__abs_T_f64(x);
18258+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18259+ f64 x2 = x * x;
18260+ return x * (((f64)(1.0)) - x2 / ((f64)(6.0)));
18261+ } else {
18262+ int sgn_result = sgn_x;
18263+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18264+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18265+ if (((octant & 1)) == 1) {
18266+ octant++;
18267+ octant &= 7;
18268+ y += 1.0;
18269+ }
18270+ if (octant > 3) {
18271+ octant -= 4;
18272+ sgn_result = -sgn_result;
18273+ }
18274+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18275+ f64 result = 0.0;
18276+ if (octant == 0) {
18277+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18278+ multi_return_f64_f64 mr_1722 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18279+ f64 sin_cs_val = mr_1722.arg0;
18280+ result = z * (((f64)(1.0)) + z * z * sin_cs_val);
18281+ } else {
18282+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18283+ multi_return_f64_f64 mr_1845 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18284+ f64 cos_cs_val = mr_1845.arg0;
18285+ result = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18286+ }
18287+ result *= sgn_result;
18288+ return result;
18289+ }
18290+ return 0;
18291+}
18292+f64 math__pure_v_but_overridden_by_c_cos(f64 x) {
18293+ f64 p1 = 7.85398125648498535156e-1;
18294+ f64 p2 = 3.77489470793079817668e-8;
18295+ f64 p3 = 2.69515142907905952645e-15;
18296+ f64 abs_x = math__abs_T_f64(x);
18297+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18298+ f64 x2 = x * x;
18299+ return ((f64)(1.0)) - ((f64)(0.5)) * x2;
18300+ } else {
18301+ int sgn_result = 1;
18302+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18303+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18304+ if (((octant & 1)) == 1) {
18305+ octant++;
18306+ octant &= 7;
18307+ y += 1.0;
18308+ }
18309+ if (octant > 3) {
18310+ octant -= 4;
18311+ sgn_result = -sgn_result;
18312+ }
18313+ if (octant > 1) {
18314+ sgn_result = -sgn_result;
18315+ }
18316+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18317+ f64 result = 0.0;
18318+ if (octant == 0) {
18319+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18320+ multi_return_f64_f64 mr_2686 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18321+ f64 cos_cs_val = mr_2686.arg0;
18322+ result = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18323+ } else {
18324+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18325+ multi_return_f64_f64 mr_2825 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18326+ f64 sin_cs_val = mr_2825.arg0;
18327+ result = z * (((f64)(1.0)) + z * z * sin_cs_val);
18328+ }
18329+ result *= sgn_result;
18330+ return result;
18331+ }
18332+ return 0;
18333+}
18334+inline f32 math__pure_v_but_overridden_by_c_cosf(f32 a) {
18335+ return ((f32)(math__cos(a)));
18336+}
18337+inline f32 math__pure_v_but_overridden_by_c_sinf(f32 a) {
18338+ return ((f32)(math__sin(a)));
18339+}
18340+multi_return_f64_f64 math__sincos(f64 x) {
18341+ if (math__is_nan(x)) {
18342+ return (multi_return_f64_f64){.arg0=x, .arg1=x};
18343+ }
18344+ f64 p1 = 7.85398125648498535156e-1;
18345+ f64 p2 = 3.77489470793079817668e-8;
18346+ f64 p3 = 2.69515142907905952645e-15;
18347+ int sgn_x = (x < 0 ? (-1) : (1));
18348+ f64 abs_x = math__abs_T_f64(x);
18349+ if (math__is_inf(x, sgn_x)) {
18350+ return (multi_return_f64_f64){.arg0=math__nan(), .arg1=math__nan()};
18351+ }
18352+ if (abs_x < ((f64)(_const_math__internal__root4_f64_epsilon))) {
18353+ f64 x2 = x * x;
18354+ return (multi_return_f64_f64){.arg0=x * (((f64)(1.0)) - x2 / ((f64)(6.0))), .arg1=((f64)(1.0)) - ((f64)(0.5)) * x2};
18355+ } else {
18356+ int sgn_result_sin = sgn_x;
18357+ int sgn_result_cos = 1;
18358+ f64 y = math__floor(abs_x / ((f64)(0.7853981633974483)));
18359+ int octant = ((int)(y - math__ldexp(math__floor(math__ldexp(y, -3)), 3)));
18360+ if (((octant & 1)) == 1) {
18361+ octant++;
18362+ octant &= 7;
18363+ y += 1.0;
18364+ }
18365+ if (octant > 3) {
18366+ octant -= 4;
18367+ sgn_result_sin = -sgn_result_sin;
18368+ sgn_result_cos = -sgn_result_cos;
18369+ }
18370+ sgn_result_cos = (octant > 1 ? (-sgn_result_cos) : (sgn_result_cos));
18371+ f64 z = ((abs_x - y * p1) - y * p2) - y * p3;
18372+ f64 t = ((f64)(8.0)) * math__abs_T_f64(z) / ((f64)(_const_math__pi)) - ((f64)(1.0));
18373+ multi_return_f64_f64 mr_4085 = math__ChebSeries_eval_e(_const_math__sin_cs, t);
18374+ f64 sin_cs_val = mr_4085.arg0;
18375+ multi_return_f64_f64 mr_4121 = math__ChebSeries_eval_e(_const_math__cos_cs, t);
18376+ f64 cos_cs_val = mr_4121.arg0;
18377+ f64 result_sin = 0.0;
18378+ f64 result_cos = 0.0;
18379+ if (octant == 0) {
18380+ result_sin = z * (((f64)(1.0)) + z * z * sin_cs_val);
18381+ result_cos = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18382+ } else {
18383+ result_sin = ((f64)(1.0)) - ((f64)(0.5)) * z * z * (((f64)(1.0)) - z * z * cos_cs_val);
18384+ result_cos = z * (((f64)(1.0)) + z * z * sin_cs_val);
18385+ }
18386+ result_sin *= sgn_result_sin;
18387+ result_cos *= sgn_result_cos;
18388+ return (multi_return_f64_f64){.arg0=result_sin, .arg1=result_cos};
18389+ }
18390+ return (multi_return_f64_f64){0};
18391+}
18392+f64 math__sinh(f64 x_) {
18393+ f64 x = x_;
18394+ f64 p0 = -0.6307673640497716991184787251e+6;
18395+ f64 p1 = -0.8991272022039509355398013511e+5;
18396+ f64 p2 = -0.2894211355989563807284660366e+4;
18397+ f64 p3 = -0.2630563213397497062819489e+2;
18398+ f64 q0 = -0.6307673640497716991212077277e+6;
18399+ f64 q1 = 0.1521517378790019070696485176e+5;
18400+ f64 q2 = -0.173678953558233699533450911e+3;
18401+ bool neg = false;
18402+ if (x < 0) {
18403+ x = -x;
18404+ neg = true;
18405+ }
18406+ f64 temp = 0.0;
18407+ if (x > 21) {
18408+ temp = math__exp(x) * ((f64)(0.5));
18409+ } else if (x > ((f64)(0.5))) {
18410+ f64 ex = math__exp(x);
18411+ temp = (ex - ((f64)(1.0)) / ex) * ((f64)(0.5));
18412+ } else {
18413+ f64 sq = x * x;
18414+ temp = (((p3 * sq + p2) * sq + p1) * sq + p0) * x;
18415+ temp = temp / (((sq + q2) * sq + q1) * sq + q0);
18416+ }
18417+ if (neg) {
18418+ temp = -temp;
18419+ }
18420+ return temp;
18421+}
18422+f64 math__cosh(f64 x) {
18423+ f64 abs_x = math__abs_T_f64(x);
18424+ if (abs_x > 21) {
18425+ return math__exp(abs_x) * ((f64)(0.5));
18426+ }
18427+ f64 ex = math__exp(abs_x);
18428+ return (ex + ((f64)(1.0)) / ex) * ((f64)(0.5));
18429+}
18430+inline f64 math__sqrt(f64 a) {
18431+ return sqrt(a);
18432+}
18433+inline f32 math__sqrtf(f32 a) {
18434+ return sqrtf(a);
18435+}
18436+inline f64 math__pure_v_but_overridden_by_c_sqrt(f64 a) {
18437+ f64 x = a;
18438+ if (x == ((f64)(0.0)) || math__is_nan(x) || math__is_inf(x, 1)) {
18439+ return x;
18440+ }
18441+ if (x < ((f64)(0.0))) {
18442+ return math__nan();
18443+ }
18444+ multi_return_f64_int mr_259 = math__frexp(x);
18445+ f64 z = mr_259.arg0;
18446+ int ex = mr_259.arg1;
18447+ f64 w = x;
18448+ x = ((f64)(4.173075996388649989089e-1)) + ((f64)(5.9016206709064458299663e-1)) * z;
18449+ if (((ex & 1)) != 0) {
18450+ x *= _const_math__sqrt2;
18451+ }
18452+ x = math__ldexp(x, v__rshift_int(ex, (u64)1));
18453+ x = ((f64)(0.5)) * (x + w / x);
18454+ x = ((f64)(0.5)) * (x + w / x);
18455+ x = ((f64)(0.5)) * (x + w / x);
18456+ return x;
18457+}
18458+inline f32 math__pure_v_but_overridden_by_c_sqrtf(f32 a) {
18459+ return ((f32)(math__sqrt(a)));
18460+}
18461+i64 math__sqrti(i64 a) {
18462+ i64 x = a;
18463+ i64 q = ((i64)(1));
18464+ i64 r = ((i64)(0));
18465+ for (; q <= x; ) {
18466+ q = v__lshift_i64(q, (u64)2);
18467+ }
18468+ for (; q > 1; ) {
18469+ q = v__rshift_i64(q, (u64)2);
18470+ i64 t = x - r - q;
18471+ r = v__rshift_i64(r, (u64)1);
18472+ if (t >= 0) {
18473+ x = t;
18474+ r += q;
18475+ }
18476+ }
18477+ return r;
18478+}
18479+inline f32 math__tanf(f32 a) {
18480+ return tanf(a);
18481+}
18482+f64 math__tan(f64 a) {
18483+ f64 x = a;
18484+ if (x == ((f64)(0.0)) || math__is_nan(x)) {
18485+ return x;
18486+ }
18487+ if (math__is_inf(x, 0)) {
18488+ return math__nan();
18489+ }
18490+ int sgn = 1;
18491+ if (x < 0) {
18492+ x = -x;
18493+ sgn = -1;
18494+ }
18495+ if (x > ((f64)(_const_math__tan_lossth))) {
18496+ return 0.0;
18497+ }
18498+ f64 y = math__floor(x * ((f64)(4.0)) / ((f64)(_const_math__pi)));
18499+ f64 z = math__ldexp(y, -3);
18500+ z = math__floor(z);
18501+ z = y - math__ldexp(z, 3);
18502+ int octant = ((int)(z));
18503+ if (((octant & 1)) == 1) {
18504+ octant++;
18505+ y += 1.0;
18506+ }
18507+ z = ((x - y * ((f64)(_const_math__tan_dp1))) - y * ((f64)(_const_math__tan_dp2))) - y * ((f64)(_const_math__tan_dp3));
18508+ f64 zz = z * z;
18509+ if (zz > ((f64)(1.0e-14))) {
18510+ y = z + z * (zz * ((((*(f64*)builtin__array_get(_const_math__tan_p, 0)) * zz) + (*(f64*)builtin__array_get(_const_math__tan_p, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_p, 2))) / ((((zz + (*(f64*)builtin__array_get(_const_math__tan_q, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 2))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 3))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 4))));
18511+ } else {
18512+ y = z;
18513+ }
18514+ if (((octant & 2)) == 2) {
18515+ y = ((f64)(-1.0)) / y;
18516+ }
18517+ if (sgn < 0) {
18518+ y = -y;
18519+ }
18520+ return y;
18521+}
18522+inline f32 math__pure_v_but_overridden_by_c_tanf(f32 a) {
18523+ return ((f32)(math__tan(a)));
18524+}
18525+f64 math__cot(f64 a) {
18526+ f64 x = a;
18527+ if (x == ((f64)(0.0))) {
18528+ return math__inf(1);
18529+ }
18530+ int sgn = 1;
18531+ if (x < 0) {
18532+ x = -x;
18533+ sgn = -1;
18534+ }
18535+ if (x > ((f64)(_const_math__tan_lossth))) {
18536+ return 0.0;
18537+ }
18538+ f64 y = math__floor(x * ((f64)(4.0)) / ((f64)(_const_math__pi)));
18539+ f64 z = math__ldexp(y, -3);
18540+ z = math__floor(z);
18541+ z = y - math__ldexp(z, 3);
18542+ int octant = ((int)(z));
18543+ if (((octant & 1)) == 1) {
18544+ octant++;
18545+ y += 1.0;
18546+ }
18547+ z = ((x - y * ((f64)(_const_math__tan_dp1))) - y * ((f64)(_const_math__tan_dp2))) - y * ((f64)(_const_math__tan_dp3));
18548+ f64 zz = z * z;
18549+ if (zz > ((f64)(1.0e-14))) {
18550+ y = z + z * (zz * ((((*(f64*)builtin__array_get(_const_math__tan_p, 0)) * zz) + (*(f64*)builtin__array_get(_const_math__tan_p, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_p, 2))) / ((((zz + (*(f64*)builtin__array_get(_const_math__tan_q, 1))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 2))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 3))) * zz + (*(f64*)builtin__array_get(_const_math__tan_q, 4))));
18551+ } else {
18552+ y = z;
18553+ }
18554+ if (((octant & 2)) == 2) {
18555+ y = -y;
18556+ } else {
18557+ y = ((f64)(1.0)) / y;
18558+ }
18559+ if (sgn < 0) {
18560+ y = -y;
18561+ }
18562+ return y;
18563+}
18564+f64 math__tanh(f64 x) {
18565+ f64 maxlog = 8.8029691931113054295988e+01;
18566+ f64 z = math__abs_T_f64(x);
18567+ if (z > ((f64)(0.5)) * maxlog) {
18568+ if (x < 0) {
18569+ return ((f64)(-1));
18570+ }
18571+ return 1.0;
18572+ } else if (z >= ((f64)(0.625))) {
18573+ f64 s = math__exp(((f64)(2.0)) * z);
18574+ z = ((f64)(1.0)) - ((f64)(2.0)) / (s + ((f64)(1.0)));
18575+ if (x < 0) {
18576+ z = -z;
18577+ }
18578+ } else {
18579+ if (x == 0) {
18580+ return x;
18581+ }
18582+ f64 s = x * x;
18583+ z = x + x * s * (((*(f64*)builtin__array_get(_const_math__tanh_p, 0)) * s + (*(f64*)builtin__array_get(_const_math__tanh_p, 1))) * s + (*(f64*)builtin__array_get(_const_math__tanh_p, 2))) / (((s + (*(f64*)builtin__array_get(_const_math__tanh_q, 0))) * s + (*(f64*)builtin__array_get(_const_math__tanh_q, 1))) * s + (*(f64*)builtin__array_get(_const_math__tanh_q, 2)));
18584+ }
18585+ return z;
18586+}
18587+inline u32 math__f32_bits(f32 f) {
18588+ #if defined(__TINYC__)
18589+ {
18590+ return *((u32*)(&f));
18591+ }
18592+ #endif
18593+ return ((math__U32_F32){.f = f,}).u;
18594+}
18595+inline f32 math__f32_from_bits(u32 b) {
18596+ #if defined(__TINYC__)
18597+ {
18598+ return *((f32*)(&b));
18599+ }
18600+ #endif
18601+ return ((math__U32_F32){.u = b,}).f;
18602+}
18603+inline u64 math__f64_bits(f64 f) {
18604+ #if defined(__TINYC__)
18605+ {
18606+ return *((u64*)(&f));
18607+ }
18608+ #endif
18609+ return ((math__U64_F64){.f = f,}).u;
18610+}
18611+inline f64 math__f64_from_bits(u64 b) {
18612+ #if defined(__TINYC__)
18613+ {
18614+ return *((f64*)(&b));
18615+ }
18616+ #endif
18617+ return ((math__U64_F64){.u = b,}).f;
18618+}
18619+inline f64 math__with_set_low_word(f64 f, u32 lo) {
18620+ u64 tmp = math__f64_bits(f);
18621+ tmp &= 0xffffffff00000000ULL;
18622+ tmp |= ((u64)(lo));
18623+ return math__f64_from_bits(tmp);
18624+}
18625+inline f64 math__with_set_high_word(f64 f, u32 hi) {
18626+ u64 tmp = math__f64_bits(f);
18627+ tmp &= 0x00000000ffffffffU;
18628+ tmp |= v__lshift_u64(((u64)(hi)), (u64)32);
18629+ return math__f64_from_bits(tmp);
18630+}
18631+inline u32 math__get_high_word(f64 f) {
18632+ return ((u32)(v__rshift_u64(math__f64_bits(f), (u64)32)));
18633+}
18634+VV_LOC void main__vf_init(void) {
18635+ string probe = _S("vf");
18636+ {int _ = probe.len;}
18637+ ;
18638+}
18639+// export alias: vf_init -> main__vf_init
18640+void vf_init(void) {
18641+ return main__vf_init();
18642+}
18643+VV_LOC int main__vf_add(int a, int b) {
18644+ return a + b;
18645+}
18646+// export alias: vf_add -> main__vf_add
18647+int vf_add(int a, int b) {
18648+ return main__vf_add(a, b);
18649+}
18650+VV_LOC char* main__vf_greet(char* name) {
18651+ string n = builtin__cstring_to_vstring(name);
18652+ string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")}));
18653+ u8* out = res.str;
18654+ builtin__string_free(&n);
18655+ return out;
18656+}
18657+// export alias: vf_greet -> main__vf_greet
18658+char* vf_greet(char* name) {
18659+ return main__vf_greet(name);
18660+}
18661+VV_LOC void main__vf_free(voidptr p) {
18662+ builtin___v_free(p);
18663+}
18664+// export alias: vf_free -> main__vf_free
18665+void vf_free(voidptr p) {
18666+ return main__vf_free(p);
18667+}
18668+VV_LOC void main__vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1) {
18669+ if (w <= 0 || h <= 0 || max_iter <= 0) {
18670+ return;
18671+ }
18672+ f64 aspect = ((f64)(w)) / ((f64)(h));
18673+ f64 inv_w = ((f64)(1.0)) / ((f64)(w));
18674+ f64 inv_h = ((f64)(1.0)) / ((f64)(h));
18675+ for (int y = y0; y < y1; y++) {
18676+ f64 im = cy + (((f64)(y)) * inv_h - ((f64)(0.5))) * scale;
18677+ int row = (y - y0) * w * 4;
18678+ for (int x = 0; x < w; x++) {
18679+ f64 re = cx + (((f64)(x)) * inv_w - ((f64)(0.5))) * scale * aspect;
18680+ f64 zr = 0.0;
18681+ f64 zi = 0.0;
18682+ f64 zr2 = 0.0;
18683+ f64 zi2 = 0.0;
18684+ int i = 0;
18685+ for (;;) {
18686+ if (!(i < max_iter)) break;
18687+ zr2 = zr * zr;
18688+ zi2 = zi * zi;
18689+ if (zr2 + zi2 > ((f64)(4.0))) {
18690+ break;
18691+ }
18692+ zi = ((f64)(2.0)) * zr * zi + im;
18693+ zr = zr2 - zi2 + re;
18694+ i++;
18695+ }
18696+ int idx = row + x * 4;
18697+ if (i >= max_iter) {
18698+ { // Unsafe block
18699+ buf[idx] = ((u8)(0));
18700+ buf[idx + 1] = ((u8)(0));
18701+ buf[idx + 2] = ((u8)(0));
18702+ buf[idx + 3] = ((u8)(255));
18703+ }
18704+ continue;
18705+ }
18706+ f64 mag = math__sqrt(zr2 + zi2);
18707+ f64 nu = ((f64)(i));
18708+ if (mag > ((f64)(1.0))) {
18709+ nu = ((f64)(i)) + ((f64)(1.0)) - math__log(math__log(mag) / math__log(2.0)) / math__log(2.0);
18710+ }
18711+ f64 t = nu / ((f64)(max_iter));
18712+ { // Unsafe block
18713+ buf[idx] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(3.0)) + t * ((f64)(18.0))))));
18714+ buf[idx + 1] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(3.6)) + t * ((f64)(18.0))))));
18715+ buf[idx + 2] = ((u8)(((f64)(255.0)) * (((f64)(0.5)) + ((f64)(0.5)) * math__sin(((f64)(4.2)) + t * ((f64)(18.0))))));
18716+ buf[idx + 3] = ((u8)(255));
18717+ }
18718+ }
18719+ }
18720+}
18721+// export alias: vf_mandelbrot -> main__vf_mandelbrot
18722+void vf_mandelbrot(u8* buf, int w, int h, f64 cx, f64 cy, f64 scale, int max_iter, int y0, int y1) {
18723+ return main__vf_mandelbrot(buf, w, h, cx, cy, scale, max_iter, y0, y1);
18724+}
18725+VV_LOC void main__main(void) {
18726+}
18727+inline f64 math__abs_T_f64(f64 a) {
18728+ return (a < 0 ? (-a) : (a));
18729+}
18730+void _vinit(int ___argc, voidptr ___argv) {
18731+ static bool once = false; if (once) {return;} once = true;
18732+ // Initializations of consts for module builtin.closure
18733+ g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3
18734+{
18735+{
18736+Array_fixed_u8_15 _t1;
18737+#if defined(__V_ppc64le)
18738+#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
18739+#elif defined(__V_amd64)
18740+ { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ;
18741+ memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15));
18742+ }
18743+ ;
18744+#elif defined(__V_x86)
18745+#elif defined(__V_arm64)
18746+#elif defined(__V_arm32)
18747+#elif defined(__V_rv64)
18748+#elif defined(__V_rv32)
18749+#elif defined(__V_s390x)
18750+#elif defined(__V_loongarch64)
18751+#elif defined(__V_sparc64)
18752+#elif 0
18753+#else
18754+#endif
18755+ memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15));
18756+}
18757+}
18758+{
18759+{
18760+Array_fixed_u8_6 _t3;
18761+#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64)
18762+#elif defined(__V_arm32)
18763+#elif defined(__V_amd64)
18764+ { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ;
18765+ memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6));
16518 }18766 }
16519 ;18767 ;
16520 #elif defined(__V_x86)18768 #elif defined(__V_x86)
@@ -16561,6 +18809,121 @@ Array_fixed_u8_6 _t3;
16561 _const_min_i64 = ((i64)(-9223372036854775807LL - 1));18809 _const_min_i64 = ((i64)(-9223372036854775807LL - 1));
16562 _const_max_i64 = ((i64)(9223372036854775807LL));18810 _const_max_i64 = ((i64)(9223372036854775807LL));
16563 _const_utf8_replacement_rune = ((rune)(0xfffd));18811 _const_utf8_replacement_rune = ((rune)(0xfffd));
18812+ // Initializations of consts for module math
18813+{
18814+ _const_math__bernoulli = builtin__new_array_from_c_array(10, 10, sizeof(f64), _MOV((f64[10]){
18815+ 0.08333333333333333, -0.002777777777777778, 0.0007936507936507937, -0.0005952380952380953, 0.0008417508417508417, -0.0019175269175269176, 0.00641025641025641, -0.029550653594771242, 0.1800957401386015,
18816+ -1.3924322169059011}));
18817+}
18818+{
18819+ _const_math__factorials_table = builtin__new_array_from_c_array(171, 171, sizeof(f64), _MOV((f64[171]){
18820+ 1.000000000000000000000e+0, 1.000000000000000000000e+0, 2.000000000000000000000e+0, 6.000000000000000000000e+0, 2.400000000000000000000e+1, 1.200000000000000000000e+2, 7.200000000000000000000e+2, 5.040000000000000000000e+3, 4.032000000000000000000e+4,
18821+ 3.628800000000000000000e+5, 3.628800000000000000000e+6, 3.991680000000000000000e+7, 4.790016000000000000000e+8, 6.227020800000000000000e+9, 8.717829120000000000000e+10, 1.307674368000000000000e+12, 2.092278988800000000000e+13,
18822+ 3.556874280960000000000e+14, 6.402373705728000000000e+15, 1.216451004088320000000e+17, 2.432902008176640000000e+18, 5.109094217170944000000e+19, 1.124000727777607680000e+21, 2.585201673888497664000e+22, 6.204484017332394393600e+23,
18823+ 1.551121004333098598400e+25, 4.032914611266056355840e+26, 1.088886945041835216077e+28, 3.048883446117138605015e+29, 8.841761993739701954544e+30, 2.652528598121910586363e+32, 8.222838654177922817726e+33, 2.631308369336935301672e+35,
18824+ 8.683317618811886495518e+36, 2.952327990396041408476e+38, 1.033314796638614492967e+40, 3.719933267899012174680e+41, 1.376375309122634504632e+43, 5.230226174666011117600e+44, 2.039788208119744335864e+46, 8.159152832478977343456e+47,
18825+ 3.345252661316380710817e+49, 1.405006117752879898543e+51, 6.041526306337383563736e+52, 2.658271574788448768044e+54, 1.196222208654801945620e+56, 5.502622159812088949850e+57, 2.586232415111681806430e+59, 1.241391559253607267086e+61,
18826+ 6.082818640342675608723e+62, 3.041409320171337804361e+64, 1.551118753287382280224e+66, 8.065817517094387857166e+67, 4.274883284060025564298e+69, 2.308436973392413804721e+71, 1.269640335365827592597e+73, 7.109985878048634518540e+74,
18827+ 4.052691950487721675568e+76, 2.350561331282878571829e+78, 1.386831185456898357379e+80, 8.320987112741390144276e+81, 5.075802138772247988009e+83, 3.146997326038793752565e+85, 1.982608315404440064116e+87, 1.268869321858841641034e+89,
18828+ 8.247650592082470666723e+90, 5.443449390774430640037e+92, 3.647111091818868528825e+94, 2.480035542436830599601e+96, 1.711224524281413113725e+98, 1.197857166996989179607e+100, 8.504785885678623175212e+101, 6.123445837688608686152e+103,
18829+ 4.470115461512684340891e+105, 3.307885441519386412260e+107, 2.480914081139539809195e+109, 1.885494701666050254988e+111, 1.451830920282858696341e+113, 1.132428117820629783146e+115, 8.946182130782975286851e+116, 7.156945704626380229481e+118,
18830+ 5.797126020747367985880e+120, 4.753643337012841748421e+122, 3.945523969720658651190e+124, 3.314240134565353266999e+126, 2.817104114380550276949e+128, 2.422709538367273238177e+130, 2.107757298379527717214e+132, 1.854826422573984391148e+134,
18831+ 1.650795516090846108122e+136, 1.485715964481761497310e+138, 1.352001527678402962552e+140, 1.243841405464130725548e+142, 1.156772507081641574759e+144, 1.087366156656743080274e+146, 1.032997848823905926260e+148, 9.916779348709496892096e+149,
18832+ 9.619275968248211985333e+151, 9.426890448883247745626e+153, 9.332621544394415268170e+155, 9.332621544394415268170e+157, 9.425947759838359420852e+159, 9.614466715035126609269e+161, 9.902900716486180407547e+163, 1.029901674514562762385e+166,
18833+ 1.081396758240290900504e+168, 1.146280563734708354534e+170, 1.226520203196137939352e+172, 1.324641819451828974500e+174, 1.443859583202493582205e+176, 1.588245541522742940425e+178, 1.762952551090244663872e+180, 1.974506857221074023537e+182,
18834+ 2.231192748659813646597e+184, 2.543559733472187557120e+186, 2.925093693493015690688e+188, 3.393108684451898201198e+190, 3.969937160808720895402e+192, 4.684525849754290656574e+194, 5.574585761207605881323e+196, 6.689502913449127057588e+198,
18835+ 8.094298525273443739682e+200, 9.875044200833601362412e+202, 1.214630436702532967577e+205, 1.506141741511140879795e+207, 1.882677176888926099744e+209, 2.372173242880046885677e+211, 3.012660018457659544810e+213, 3.856204823625804217357e+215,
18836+ 4.974504222477287440390e+217, 6.466855489220473672507e+219, 8.471580690878820510985e+221, 1.118248651196004307450e+224, 1.487270706090685728908e+226, 1.992942746161518876737e+228, 2.690472707318050483595e+230, 3.659042881952548657690e+232,
18837+ 5.012888748274991661035e+234, 6.917786472619488492228e+236, 9.615723196941089004197e+238, 1.346201247571752460588e+241, 1.898143759076170969429e+243, 2.695364137888162776589e+245, 3.854370717180072770522e+247, 5.550293832739304789551e+249,
18838+ 8.047926057471991944849e+251, 1.174997204390910823948e+254, 1.727245890454638911203e+256, 2.556323917872865588581e+258, 3.808922637630569726986e+260, 5.713383956445854590479e+262, 8.627209774233240431623e+264, 1.311335885683452545607e+267,
18839+ 2.006343905095682394778e+269, 3.089769613847350887959e+271, 4.789142901463393876336e+273, 7.471062926282894447084e+275, 1.172956879426414428192e+278, 1.853271869493734796544e+280, 2.946702272495038326504e+282, 4.714723635992061322407e+284,
18840+ 7.590705053947218729075e+286, 1.229694218739449434110e+289, 2.004401576545302577600e+291, 3.287218585534296227263e+293, 5.423910666131588774984e+295, 9.003691705778437366474e+297, 1.503616514864999040201e+300, 2.526075744973198387538e+302,
18841+ 4.269068009004705274939e+304, 7.257415615307998967397e+306}));
18842+}
18843+{
18844+ _const_math__log_factorials_table = builtin__new_array_from_c_array(172, 172, sizeof(f64), _MOV((f64[172]){
18845+ 0.000000000000000000000e+0, 0.000000000000000000000e+0, 6.931471805599453094172e-1, 1.791759469228055000812e+0, 3.178053830347945619647e+0, 4.787491742782045994248e+0, 6.579251212010100995060e+0, 8.525161361065414300166e+0, 1.060460290274525022842e+1,
18846+ 1.280182748008146961121e+1, 1.510441257307551529523e+1, 1.750230784587388583929e+1, 1.998721449566188614952e+1, 2.255216385312342288557e+1, 2.519122118273868150009e+1, 2.789927138384089156609e+1, 3.067186010608067280376e+1,
18847+ 3.350507345013688888401e+1, 3.639544520803305357622e+1, 3.933988418719949403622e+1, 4.233561646075348502966e+1, 4.538013889847690802616e+1, 4.847118135183522387964e+1, 5.160667556776437357045e+1, 5.478472939811231919009e+1,
18848+ 5.800360522298051993929e+1, 6.126170176100200198477e+1, 6.455753862700633105895e+1, 6.788974313718153498289e+1, 7.125703896716800901007e+1, 7.465823634883016438549e+1, 7.809222355331531063142e+1, 8.155795945611503717850e+1,
18849+ 8.505446701758151741396e+1, 8.858082754219767880363e+1, 9.213617560368709248333e+1, 9.571969454214320248496e+1, 9.933061245478742692933e+1, 1.029681986145138126988e+2, 1.066317602606434591262e+2, 1.103206397147573954291e+2,
18850+ 1.140342117814617032329e+2, 1.177718813997450715388e+2, 1.215330815154386339623e+2, 1.253172711493568951252e+2, 1.291239336391272148826e+2, 1.329525750356163098828e+2, 1.368027226373263684696e+2, 1.406739236482342593987e+2,
18851+ 1.445657439463448860089e+2, 1.484777669517730320675e+2, 1.524095925844973578392e+2, 1.563608363030787851941e+2, 1.603311282166309070282e+2, 1.643201122631951814118e+2, 1.683274454484276523305e+2, 1.723527971391628015638e+2,
18852+ 1.763958484069973517152e+2, 1.804562914175437710518e+2, 1.845338288614494905025e+2, 1.886281734236715911873e+2, 1.927390472878449024360e+2, 1.968661816728899939914e+2, 2.010093163992815266793e+2, 2.051681994826411985358e+2,
18853+ 2.093425867525368356464e+2, 2.135322414945632611913e+2, 2.177369341139542272510e+2, 2.219564418191303339501e+2, 2.261905483237275933323e+2, 2.304390435657769523214e+2, 2.347017234428182677427e+2, 2.389783895618343230538e+2,
18854+ 2.432688490029827141829e+2, 2.475729140961868839366e+2, 2.518904022097231943772e+2, 2.562211355500095254561e+2, 2.605649409718632093053e+2, 2.649216497985528010421e+2, 2.692910976510198225363e+2, 2.736731242856937041486e+2,
18855+ 2.780675734403661429141e+2, 2.824742926876303960274e+2, 2.868931332954269939509e+2, 2.913239500942703075662e+2, 2.957666013507606240211e+2, 3.002209486470141317540e+2, 3.046868567656687154726e+2, 3.091641935801469219449e+2,
18856+ 3.136528299498790617832e+2, 3.181526396202093268500e+2, 3.226634991267261768912e+2, 3.271852877037752172008e+2, 3.317178871969284731381e+2, 3.362611819791984770344e+2, 3.408150588707990178690e+2, 3.453794070622668541074e+2,
18857+ 3.499541180407702369296e+2, 3.545390855194408088492e+2, 3.591342053695753987760e+2, 3.637393755555634901441e+2, 3.683544960724047495950e+2, 3.729794688856890206760e+2, 3.776141978739186564468e+2, 3.822585887730600291111e+2,
18858+ 3.869125491232175524822e+2, 3.915759882173296196258e+2, 3.962488170517915257991e+2, 4.009309482789157454921e+2, 4.056222961611448891925e+2, 4.103227765269373054205e+2, 4.150323067282496395563e+2, 4.197508055995447340991e+2,
18859+ 4.244781934182570746677e+2, 4.292143918666515701285e+2, 4.339593239950148201939e+2, 4.387129141861211848399e+2, 4.434750881209189409588e+2, 4.482457727453846057188e+2, 4.530248962384961351041e+2, 4.578123879812781810984e+2,
18860+ 4.626081785268749221865e+2, 4.674121995716081787447e+2, 4.722243839269805962399e+2, 4.770446654925856331047e+2, 4.818729792298879342285e+2, 4.867092611368394122258e+2, 4.915534482232980034989e+2, 4.964054784872176206648e+2,
18861+ 5.012652908915792927797e+2, 5.061328253420348751997e+2, 5.110080226652360267439e+2, 5.158908245878223975982e+2, 5.207811737160441513633e+2, 5.256790135159950627324e+2, 5.305842882944334921812e+2, 5.354969431801695441897e+2,
18862+ 5.404169241059976691050e+2, 5.453441777911548737966e+2, 5.502786517242855655538e+2, 5.552202941468948698523e+2, 5.601690540372730381305e+2, 5.651248810948742988613e+2, 5.700877257251342061414e+2, 5.750575390247102067619e+2,
18863+ 5.800342727671307811636e+2, 5.850178793888391176022e+2, 5.900083119756178539038e+2, 5.950055242493819689670e+2, 6.000094705553274281080e+2, 6.050201058494236838580e+2, 6.100373856862386081868e+2, 6.150612662070848845750e+2,
18864+ 6.200917041284773200381e+2, 6.251286567308909491967e+2, 6.301720818478101958172e+2, 6.352219378550597328635e+2, 6.402781836604080409209e+2, 6.453407786934350077245e+2, 6.504096828956552392500e+2, 6.554848567108890661717e+2,
18865+ 6.605662610758735291676e+2, 6.656538574111059132426e+2, 6.707476076119126755767e+2, 6.758474740397368739994e+2, 6.809534195136374546094e+2, 6.860654073019939978423e+2, 6.911834011144107529496e+2, 6.963073650938140118743e+2,
18866+ 7.014372638087370853465e+2, 7.065730622457873471107e+2, 7.117147258022900069535e+2}));
18867+}
18868+ _const_math__gamma_p = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){1.60119522476751861407e-04, 1.19135147006586384913e-03, 1.04213797561761569935e-02, 4.76367800457137231464e-02, 2.07448227648435975150e-01, 4.94214826801497100753e-01, 9.99999999999999996796e-01}));
18869+ _const_math__gamma_q = builtin__new_array_from_c_array(8, 8, sizeof(f64), _MOV((f64[8]){-2.31581873324120129819e-05, 5.39605580493303397842e-04, -4.45641913851797240494e-03, 1.18139785222060435552e-02, 3.58236398605498653373e-02, -2.34591795718243348568e-01, 7.14304917030273074085e-02, 1.00000000000000000320e+00}));
18870+ _const_math__gamma_s = builtin__new_array_from_c_array(5, 5, sizeof(f64), _MOV((f64[5]){7.87311395793093628397e-04, -2.29549961613378126380e-04, -2.68132617805781232825e-03, 3.47222221605458667310e-03, 8.33333333333482257126e-02}));
18871+{
18872+ _const_math__lgamma_a = builtin__new_array_from_c_array(12, 12, sizeof(f64), _MOV((f64[12]){
18873+ 7.72156649015328655494e-02, 3.22467033424113591611e-01, 6.73523010531292681824e-02, 2.05808084325167332806e-02, 7.38555086081402883957e-03, 2.89051383673415629091e-03, 1.19270763183362067845e-03, 5.10069792153511336608e-04, 2.20862790713908385557e-04,
18874+ 1.08011567247583939954e-04, 2.52144565451257326939e-05, 4.48640949618915160150e-05}));
18875+}
18876+ _const_math__lgamma_r = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){1.0, 1.39200533467621045958e+00, 7.21935547567138069525e-01, 1.71933865632803078993e-01, 1.86459191715652901344e-02, 7.77942496381893596434e-04, 7.32668430744625636189e-06}));
18877+ _const_math__lgamma_s = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){-7.72156649015328655494e-02, 2.14982415960608852501e-01, 3.25778796408930981787e-01, 1.46350472652464452805e-01, 2.66422703033638609560e-02, 1.84028451407337715652e-03, 3.19475326584100867617e-05}));
18878+{
18879+ _const_math__lgamma_t = builtin__new_array_from_c_array(15, 15, sizeof(f64), _MOV((f64[15]){
18880+ 4.83836122723810047042e-01, -1.47587722994593911752e-01, 6.46249402391333854778e-02, -3.27885410759859649565e-02, 1.79706750811820387126e-02, -1.03142241298341437450e-02, 6.10053870246291332635e-03, -3.68452016781138256760e-03, 2.25964780900612472250e-03,
18881+ -1.40346469989232843813e-03, 8.81081882437654011382e-04, -5.38595305356740546715e-04, 3.15632070903625950361e-04, -3.12754168375120860518e-04, 3.35529192635519073543e-04}));
18882+}
18883+ _const_math__lgamma_u = builtin__new_array_from_c_array(6, 6, sizeof(f64), _MOV((f64[6]){-7.72156649015328655494e-02, 6.32827064025093366517e-01, 1.45492250137234768737e+00, 9.77717527963372745603e-01, 2.28963728064692451092e-01, 1.33810918536787660377e-02}));
18884+ _const_math__lgamma_v = builtin__new_array_from_c_array(6, 6, sizeof(f64), _MOV((f64[6]){1.0, 2.45597793713041134822e+00, 2.12848976379893395361e+00, 7.69285150456672783825e-01, 1.04222645593369134254e-01, 3.21709242282423911810e-03}));
18885+ _const_math__lgamma_w = builtin__new_array_from_c_array(7, 7, sizeof(f64), _MOV((f64[7]){4.18938533204672725052e-01, 8.33333333333329678849e-02, -2.77777777728775536470e-03, 7.93650558643019558500e-04, -5.95187557450339963135e-04, 8.36339918996282139126e-04, -1.63092934096575273989e-03}));
18886+{
18887+ _const_math__pow10tab = builtin__new_array_from_c_array(32, 32, sizeof(f64), _MOV((f64[32]){
18888+ ((f64)(1e+00)), 1e+01, 1e+02, 1e+03, 1e+04, 1e+05, 1e+06, 1e+07, 1e+08,
18889+ 1e+09, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16,
18890+ 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24,
18891+ 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31}));
18892+}
18893+{
18894+ _const_math__pow10postab32 = builtin__new_array_from_c_array(10, 10, sizeof(f64), _MOV((f64[10]){
18895+ ((f64)(1e+00)), 1e+32, 1e+64, 1e+96, 1e+128, 1e+160, 1e+192, 1e+224, 1e+256,
18896+ 1e+288}));
18897+}
18898+{
18899+ _const_math__pow10negtab32 = builtin__new_array_from_c_array(11, 11, sizeof(f64), _MOV((f64[11]){
18900+ ((f64)(1e-00)), 1e-32, 1e-64, 1e-96, 1e-128, 1e-160, 1e-192, 1e-224, 1e-256,
18901+ 1e-288, 1e-320}));
18902+}
18903+{
18904+ _const_math__sin_data = builtin__new_array_from_c_array(12, 12, sizeof(f64), _MOV((f64[12]){
18905+ -0.3295190160663511504173, 0.0025374284671667991990, 0.0006261928782647355874, -4.6495547521854042157541e-06, -5.6917531549379706526677e-07, 3.7283335140973803627866e-09, 3.0267376484747473727186e-10, -1.7400875016436622322022e-12, -1.0554678305790849834462e-13,
18906+ 5.3701981409132410797062e-16, 2.5984137983099020336115e-17, -1.1821555255364833468288e-19}));
18907+}
18908+{
18909+ _const_math__cos_data = builtin__new_array_from_c_array(11, 11, sizeof(f64), _MOV((f64[11]){
18910+ 0.165391825637921473505668118136, -0.00084852883845000173671196530195, -0.000210086507222940730213625768083, 1.16582269619760204299639757584e-6, 1.43319375856259870334412701165e-7, -7.4770883429007141617951330184e-10, -6.0969994944584252706997438007e-11, 2.90748249201909353949854872638e-13, 1.77126739876261435667156490461e-14,
18911+ -7.6896421502815579078577263149e-17, -3.7363121133079412079201377318e-18}));
18912+}
18913+ _const_math__tan_p = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){-1.30936939181383777646e+4, 1.15351664838587416140e+6, -1.79565251976484877988e+7}));
18914+ _const_math__tan_q = builtin__new_array_from_c_array(5, 5, sizeof(f64), _MOV((f64[5]){1.00000000000000000000e+0, 1.36812963470692954678e+4, -1.32089234440210967447e+6, 2.50083801823357915839e+7, -5.38695755929454629881e+7}));
18915+ _const_math__tanh_p = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){-9.64399179425052238628e-1, -9.92877231001918586564e+1, -1.61468768441708447952e+3}));
18916+ _const_math__tanh_q = builtin__new_array_from_c_array(3, 3, sizeof(f64), _MOV((f64[3]){1.12811678491632931402e+2, 2.23548839060100448583e+3, 4.84406305325125486048e+3}));
18917+{
18918+{
18919+ _const_math__sin_cs = ((math__ChebSeries){.c = _const_math__sin_data,.order = 11,.a = -1,.b = 1,});
18920+}
18921+}
18922+{
18923+{
18924+ _const_math__cos_cs = ((math__ChebSeries){.c = _const_math__cos_data,.order = 10,.a = -1,.b = 1,});
18925+}
18926+}
16564 }18927 }
16565 void _vcleanup(void) {18928 void _vcleanup(void) {
16566 static bool once = false; if (once) {return;} once = true;18929 static bool once = false; if (once) {return;} once = true;
modified macos/Classes/vflutter.h +10 -0
@@ -24,6 +24,16 @@ VF_API char *vf_greet(const char *name);
2424
2525 VF_API void vf_free(void *p);
2626
27+// Fills rows [y0, y1) of a w x h Mandelbrot image as RGBA8888, packed from
28+// the start of `buf`. The buffer is owned by the CALLER: V allocates nothing
29+// here and there is nothing to vf_free. Bands are independent, so separate
30+// calls may run concurrently on different threads/isolates.
31+//
32+// `buf` must hold at least (y1 - y0) * w * 4 bytes.
33+VF_API void vf_mandelbrot(unsigned char *buf, int w, int h, double cx,
34+ double cy, double scale, int max_iter, int y0,
35+ int y1);
36+
2737 #ifdef __cplusplus
2838 }
2939 #endif
@@ -24,6 +24,16 @@ VF_API char *vf_greet(const char *name);
24 24
25 VF_API void vf_free(void *p);25 VF_API void vf_free(void *p);
26 26
27+// Fills rows [y0, y1) of a w x h Mandelbrot image as RGBA8888, packed from
28+// the start of `buf`. The buffer is owned by the CALLER: V allocates nothing
29+// here and there is nothing to vf_free. Bands are independent, so separate
30+// calls may run concurrently on different threads/isolates.
31+//
32+// `buf` must hold at least (y1 - y0) * w * 4 bytes.
33+VF_API void vf_mandelbrot(unsigned char *buf, int w, int h, double cx,
34+ double cy, double scale, int max_iter, int y0,
35+ int y1);
36+
27 #ifdef __cplusplus37 #ifdef __cplusplus
28 }38 }
29 #endif39 #endif
modified src/CMakeLists.txt +9 -2
@@ -25,9 +25,16 @@ add_library(vflutter SHARED "${VF_GENERATED_C}")
2525 target_include_directories(vflutter PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
2626
2727 # V's generated C is machine output: silence the noise, keep real errors.
28-if(NOT MSVC)
28+#
29+# -O2 is set unconditionally, including in Debug. This library is a numeric
30+# kernel with no Dart-visible debugger story of its own, and at -O0 the
31+# Mandelbrot path runs several times slower than the equivalent Dart — which
32+# makes a debug run of the example wildly misrepresent the bridge.
33+if(MSVC)
34+ target_compile_options(vflutter PRIVATE /O2)
35+else()
2936 target_compile_options(vflutter PRIVATE
30- -w -fPIC -Wno-int-conversion -Wno-incompatible-pointer-types)
37+ -O2 -w -fPIC -Wno-int-conversion -Wno-incompatible-pointer-types)
3138 endif()
3239
3340 # Boehm GC ships with V and is linked statically by the V toolchain on desktop;
@@ -25,9 +25,16 @@ add_library(vflutter SHARED "${VF_GENERATED_C}")
25 target_include_directories(vflutter PUBLIC "${CMAKE_CURRENT_LIST_DIR}")25 target_include_directories(vflutter PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
26 26
27 # V's generated C is machine output: silence the noise, keep real errors.27 # V's generated C is machine output: silence the noise, keep real errors.
28-if(NOT MSVC)28+#
29+# -O2 is set unconditionally, including in Debug. This library is a numeric
30+# kernel with no Dart-visible debugger story of its own, and at -O0 the
31+# Mandelbrot path runs several times slower than the equivalent Dart — which
32+# makes a debug run of the example wildly misrepresent the bridge.
33+if(MSVC)
34+ target_compile_options(vflutter PRIVATE /O2)
35+else()
29 target_compile_options(vflutter PRIVATE36 target_compile_options(vflutter PRIVATE
30- -w -fPIC -Wno-int-conversion -Wno-incompatible-pointer-types)37+ -O2 -w -fPIC -Wno-int-conversion -Wno-incompatible-pointer-types)
31 endif()38 endif()
32 39
33 # Boehm GC ships with V and is linked statically by the V toolchain on desktop;40 # Boehm GC ships with V and is linked statically by the V toolchain on desktop;
modified src/vflutter.h +10 -0
@@ -24,6 +24,16 @@ VF_API char *vf_greet(const char *name);
2424
2525 VF_API void vf_free(void *p);
2626
27+// Fills rows [y0, y1) of a w x h Mandelbrot image as RGBA8888, packed from
28+// the start of `buf`. The buffer is owned by the CALLER: V allocates nothing
29+// here and there is nothing to vf_free. Bands are independent, so separate
30+// calls may run concurrently on different threads/isolates.
31+//
32+// `buf` must hold at least (y1 - y0) * w * 4 bytes.
33+VF_API void vf_mandelbrot(unsigned char *buf, int w, int h, double cx,
34+ double cy, double scale, int max_iter, int y0,
35+ int y1);
36+
2737 #ifdef __cplusplus
2838 }
2939 #endif
@@ -24,6 +24,16 @@ VF_API char *vf_greet(const char *name);
24 24
25 VF_API void vf_free(void *p);25 VF_API void vf_free(void *p);
26 26
27+// Fills rows [y0, y1) of a w x h Mandelbrot image as RGBA8888, packed from
28+// the start of `buf`. The buffer is owned by the CALLER: V allocates nothing
29+// here and there is nothing to vf_free. Bands are independent, so separate
30+// calls may run concurrently on different threads/isolates.
31+//
32+// `buf` must hold at least (y1 - y0) * w * 4 bytes.
33+VF_API void vf_mandelbrot(unsigned char *buf, int w, int h, double cx,
34+ double cy, double scale, int max_iter, int y0,
35+ int y1);
36+
27 #ifdef __cplusplus37 #ifdef __cplusplus
28 }38 }
29 #endif39 #endif
modified src/vflutter.v +74 -0
@@ -1,5 +1,7 @@
11 module main
22
3+import math
4+
35 // ---------------------------------------------------------------------------
46 // C-ABI surface consumed by Dart FFI.
57 //
@@ -41,3 +43,75 @@ fn vf_greet(name &char) &char {
4143 fn vf_free(p voidptr) {
4244 unsafe { free(p) }
4345 }
46+
47+// ---------------------------------------------------------------------------
48+// Mandelbrot kernel.
49+//
50+// The buffer is allocated and owned by the *caller*: V only fills it. That
51+// sidesteps the -gc none ownership rules entirely for bulk data there is
52+// nothing to vf_free, and no allocation happens inside the hot loop.
53+//
54+// Rows [y0, y1) of a w x h image are written as RGBA8888, packed from the
55+// start of `buf`, so each call fills a self-contained horizontal band and
56+// several bands can be computed concurrently from different isolates.
57+// ---------------------------------------------------------------------------
58+@[export: 'vf_mandelbrot']
59+fn vf_mandelbrot(buf &u8, w int, h int, cx f64, cy f64, scale f64, max_iter int, y0 int, y1 int) {
60+ if w <= 0 || h <= 0 || max_iter <= 0 {
61+ return
62+ }
63+ aspect := f64(w) / f64(h)
64+ inv_w := 1.0 / f64(w)
65+ inv_h := 1.0 / f64(h)
66+
67+ for y := y0; y < y1; y++ {
68+ im := cy + (f64(y) * inv_h - 0.5) * scale
69+ row := (y - y0) * w * 4
70+ for x := 0; x < w; x++ {
71+ re := cx + (f64(x) * inv_w - 0.5) * scale * aspect
72+
73+ mut zr := 0.0
74+ mut zi := 0.0
75+ mut zr2 := 0.0
76+ mut zi2 := 0.0
77+ mut i := 0
78+ for i < max_iter {
79+ zr2 = zr * zr
80+ zi2 = zi * zi
81+ if zr2 + zi2 > 4.0 {
82+ break
83+ }
84+ zi = 2.0 * zr * zi + im
85+ zr = zr2 - zi2 + re
86+ i++
87+ }
88+
89+ idx := row + x * 4
90+ if i >= max_iter {
91+ // Inside the set.
92+ unsafe {
93+ buf[idx] = u8(0)
94+ buf[idx + 1] = u8(0)
95+ buf[idx + 2] = u8(0)
96+ buf[idx + 3] = u8(255)
97+ }
98+ continue
99+ }
100+
101+ // Smooth (fractional) escape count, so bands don't posterise.
102+ mag := math.sqrt(zr2 + zi2)
103+ mut nu := f64(i)
104+ if mag > 1.0 {
105+ nu = f64(i) + 1.0 - math.log(math.log(mag) / math.log(2.0)) / math.log(2.0)
106+ }
107+ t := nu / f64(max_iter)
108+
109+ unsafe {
110+ buf[idx] = u8(255.0 * (0.5 + 0.5 * math.sin(3.0 + t * 18.0)))
111+ buf[idx + 1] = u8(255.0 * (0.5 + 0.5 * math.sin(3.6 + t * 18.0)))
112+ buf[idx + 2] = u8(255.0 * (0.5 + 0.5 * math.sin(4.2 + t * 18.0)))
113+ buf[idx + 3] = u8(255)
114+ }
115+ }
116+ }
117+}
@@ -1,5 +1,7 @@
1 module main1 module main
2 2
3+import math
4+
3 // ---------------------------------------------------------------------------5 // ---------------------------------------------------------------------------
4 // C-ABI surface consumed by Dart FFI.6 // C-ABI surface consumed by Dart FFI.
5 //7 //
@@ -41,3 +43,75 @@ fn vf_greet(name &char) &char {
41 fn vf_free(p voidptr) {43 fn vf_free(p voidptr) {
42 unsafe { free(p) }44 unsafe { free(p) }
43 }45 }
46+
47+// ---------------------------------------------------------------------------
48+// Mandelbrot kernel.
49+//
50+// The buffer is allocated and owned by the *caller*: V only fills it. That
51+// sidesteps the -gc none ownership rules entirely for bulk data there is
52+// nothing to vf_free, and no allocation happens inside the hot loop.
53+//
54+// Rows [y0, y1) of a w x h image are written as RGBA8888, packed from the
55+// start of `buf`, so each call fills a self-contained horizontal band and
56+// several bands can be computed concurrently from different isolates.
57+// ---------------------------------------------------------------------------
58+@[export: 'vf_mandelbrot']
59+fn vf_mandelbrot(buf &u8, w int, h int, cx f64, cy f64, scale f64, max_iter int, y0 int, y1 int) {
60+ if w <= 0 || h <= 0 || max_iter <= 0 {
61+ return
62+ }
63+ aspect := f64(w) / f64(h)
64+ inv_w := 1.0 / f64(w)
65+ inv_h := 1.0 / f64(h)
66+
67+ for y := y0; y < y1; y++ {
68+ im := cy + (f64(y) * inv_h - 0.5) * scale
69+ row := (y - y0) * w * 4
70+ for x := 0; x < w; x++ {
71+ re := cx + (f64(x) * inv_w - 0.5) * scale * aspect
72+
73+ mut zr := 0.0
74+ mut zi := 0.0
75+ mut zr2 := 0.0
76+ mut zi2 := 0.0
77+ mut i := 0
78+ for i < max_iter {
79+ zr2 = zr * zr
80+ zi2 = zi * zi
81+ if zr2 + zi2 > 4.0 {
82+ break
83+ }
84+ zi = 2.0 * zr * zi + im
85+ zr = zr2 - zi2 + re
86+ i++
87+ }
88+
89+ idx := row + x * 4
90+ if i >= max_iter {
91+ // Inside the set.
92+ unsafe {
93+ buf[idx] = u8(0)
94+ buf[idx + 1] = u8(0)
95+ buf[idx + 2] = u8(0)
96+ buf[idx + 3] = u8(255)
97+ }
98+ continue
99+ }
100+
101+ // Smooth (fractional) escape count, so bands don't posterise.
102+ mag := math.sqrt(zr2 + zi2)
103+ mut nu := f64(i)
104+ if mag > 1.0 {
105+ nu = f64(i) + 1.0 - math.log(math.log(mag) / math.log(2.0)) / math.log(2.0)
106+ }
107+ t := nu / f64(max_iter)
108+
109+ unsafe {
110+ buf[idx] = u8(255.0 * (0.5 + 0.5 * math.sin(3.0 + t * 18.0)))
111+ buf[idx + 1] = u8(255.0 * (0.5 + 0.5 * math.sin(3.6 + t * 18.0)))
112+ buf[idx + 2] = u8(255.0 * (0.5 + 0.5 * math.sin(4.2 + t * 18.0)))
113+ buf[idx + 3] = u8(255)
114+ }
115+ }
116+ }
117+}
modified tool/build.sh +4 -1
@@ -4,6 +4,9 @@ set -euo pipefail
44 cd "$(dirname "$0")/.."
55 command -v v >/dev/null || { echo "V compiler not on PATH"; exit 1; }
66 mkdir -p build
7-v -shared -o build/libvflutter.so src/vflutter.v
7+# -gc none matches what the Flutter builds use (src/CMakeLists.txt), so the
8+# ownership rules exercised here are the real ones. -prod turns on the C
9+# optimiser; without it the numeric kernels are several times slower.
10+v -shared -gc none -prod -o build/libvflutter.so src/vflutter.v
811 echo "built: $(ls -la build/libvflutter.so | awk '{print $5}') bytes"
912 nm -D --defined-only build/libvflutter.so | grep ' vf_' || { echo "no vf_ exports!"; exit 1; }
@@ -4,6 +4,9 @@ set -euo pipefail
4 cd "$(dirname "$0")/.."4 cd "$(dirname "$0")/.."
5 command -v v >/dev/null || { echo "V compiler not on PATH"; exit 1; }5 command -v v >/dev/null || { echo "V compiler not on PATH"; exit 1; }
6 mkdir -p build6 mkdir -p build
7-v -shared -o build/libvflutter.so src/vflutter.v7+# -gc none matches what the Flutter builds use (src/CMakeLists.txt), so the
8+# ownership rules exercised here are the real ones. -prod turns on the C
9+# optimiser; without it the numeric kernels are several times slower.
10+v -shared -gc none -prod -o build/libvflutter.so src/vflutter.v
8 echo "built: $(ls -la build/libvflutter.so | awk '{print $5}') bytes"11 echo "built: $(ls -la build/libvflutter.so | awk '{print $5}') bytes"
9 nm -D --defined-only build/libvflutter.so | grep ' vf_' || { echo "no vf_ exports!"; exit 1; }12 nm -D --defined-only build/libvflutter.so | grep ' vf_' || { echo "no vf_ exports!"; exit 1; }