diff --git a/.gitignore b/.gitignore index 8761f11..d73f263 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ tests/lexer_test tests/parser_test tests/sema_test tests/hir_test +tests/borrow_test tests/test_generics_parse tests/*.exe diff --git a/Makefile b/Makefile index d193e87..329b813 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ selfhost: build .PHONY: test-golden -GOLDEN_TESTS := hello fibonacci structs generics algebraic_enums enums methods strings +GOLDEN_TESTS := hello fibonacci structs generics algebraic_enums enums methods strings modern_features test-golden: build @echo "=== Golden tests ===" diff --git a/apps/nexus/public/index.html b/apps/nexus/public/index.html index 1f4024c..95499d1 100644 --- a/apps/nexus/public/index.html +++ b/apps/nexus/public/index.html @@ -1,129 +1 @@ - - - - - - Nexus — Bux HTTP Server - - - -
-

⚡ Nexus

-

High-performance HTTP Server — Built with Bux

- -
-

Features

- -
- -
-

API Endpoints

-
- GET - /api/health -
-
- GET - /api/info -
-
- GET - /ws -
-
- - -
- - +Hello Nexus diff --git a/apps/nexus/src/Config.bux b/apps/nexus/src/Config.bux new file mode 100644 index 0000000..52c19ee --- /dev/null +++ b/apps/nexus/src/Config.bux @@ -0,0 +1,21 @@ +module Config { + +pub struct ServerConfig { + bindAddr: String; + port: int; + workerCount: int; + publicDir: String; + backlog: int; +} + +pub const func DefaultConfig() -> ServerConfig { + return ServerConfig { + bindAddr: "0.0.0.0", + port: 8080, + workerCount: 4, + publicDir: "public", + backlog: 128, + }; +} + +} diff --git a/apps/nexus/src/Errors.bux b/apps/nexus/src/Errors.bux new file mode 100644 index 0000000..124373d --- /dev/null +++ b/apps/nexus/src/Errors.bux @@ -0,0 +1,65 @@ +module Errors { + +import Http::{HttpRequest}; + +pub enum HttpError { + BadRequest, + NotFound, + MethodNotAllowed, + InternalError(String), +} + +pub enum ParseResult { + Ok(HttpRequest), + Err(HttpError), +} + +pub enum FileResult { + Ok(String), + Err(HttpError), +} + +pub func ParseResult_NewOk(req: HttpRequest) -> ParseResult { + let r: ParseResult = ParseResult { tag: ParseResult_Ok }; + r.data.Ok_0 = req; + return r; +} + +pub func ParseResult_NewErr(err: HttpError) -> ParseResult { + let r: ParseResult = ParseResult { tag: ParseResult_Err }; + r.data.Err_0 = err; + return r; +} + +pub func FileResult_NewOk(content: String) -> FileResult { + let r: FileResult = FileResult { tag: FileResult_Ok }; + r.data.Ok_0 = content; + return r; +} + +pub func FileResult_NewErr(err: HttpError) -> FileResult { + let r: FileResult = FileResult { tag: FileResult_Err }; + r.data.Err_0 = err; + return r; +} + +pub func FileResult_IsOk(r: FileResult) -> bool { + return r.tag == FileResult_Ok; +} + +pub func FileResult_Unwrap(r: FileResult) -> String { + return r.data.Ok_0; +} + +pub func FileResult_UnwrapErr(r: FileResult) -> HttpError { + return r.data.Err_0; +} + +pub func HttpError_ToString(err: HttpError) -> String { + if err.tag == HttpError_BadRequest { return "Bad Request"; } + if err.tag == HttpError_NotFound { return "Not Found"; } + if err.tag == HttpError_MethodNotAllowed { return "Method Not Allowed"; } + return err.data.InternalError_0; +} + +} diff --git a/apps/nexus/src/Handlers.bux b/apps/nexus/src/Handlers.bux new file mode 100644 index 0000000..ddd3ebd --- /dev/null +++ b/apps/nexus/src/Handlers.bux @@ -0,0 +1,94 @@ +module Handlers { + +import Std::String::{String_Eq, String_Contains}; +import Http::{HttpMethod, HttpRequest, HttpResponse, Http_NewResponse, Http_MimeType, RequestHeader_Get}; +import Errors::{HttpError, FileResult, FileResult_NewOk, FileResult_NewErr, FileResult_IsOk, FileResult_Unwrap, FileResult_UnwrapErr, HttpError_ToString}; + +extern func bux_strlen(s: String) -> uint; +extern func bux_file_exists(path: String) -> int; +extern func bux_read_file(path: String) -> String; +extern func bux_path_join(a: String, b: String) -> String; +extern func bux_sb_new(initial_cap: uint) -> *void; +extern func bux_sb_append(sb: *void, s: String); +extern func bux_sb_append_int(sb: *void, n: int64); +extern func bux_sb_build(sb: *void) -> String; +extern func bux_sb_free(sb: *void); + +pub func NotFoundResponse() -> HttpResponse { + return Http_NewResponse(404, "application/json; charset=utf-8", "{\"error\":\"not_found\"}"); +} + +pub func MethodNotAllowedResponse() -> HttpResponse { + return Http_NewResponse(405, "text/plain; charset=utf-8", "Method Not Allowed"); +} + +pub func ReadStaticFile(requestPath: String) -> FileResult { + if String_Contains(requestPath, "..") { + return FileResult_NewErr(HttpError { tag: HttpError_NotFound }); + } + + var filePath: String = requestPath; + if String_Eq(filePath, "/") { + filePath = "/index.html"; + } + + let fullPath: String = bux_path_join("public", filePath); + if bux_file_exists(fullPath) == 0 { + return FileResult_NewErr(HttpError { tag: HttpError_NotFound }); + } + + let content: String = bux_read_file(fullPath); + return FileResult_NewOk(content); +} + +func FileErrorResponse(err: HttpError) -> HttpResponse { + match err { + HttpError::NotFound => NotFoundResponse(), + _ => Http_NewResponse(500, "text/plain; charset=utf-8", HttpError_ToString(err)), + } +} + +pub func ServeStaticFile(req: HttpRequest) -> HttpResponse { + if req.method != HttpMethod_GET && req.method != HttpMethod_HEAD { + return MethodNotAllowedResponse(); + } + + let result: FileResult = ReadStaticFile(req.path); + if FileResult_IsOk(result) { + let content: String = FileResult_Unwrap(result); + return Http_NewResponse(200, Http_MimeType(req.path), content); + } + return FileErrorResponse(FileResult_UnwrapErr(result)); +} + +pub func HandleApiHealth() -> HttpResponse { + return Http_NewResponse(200, "application/json; charset=utf-8", + "{\"status\":\"ok\",\"server\":\"Nexus\",\"version\":\"0.2.0\"}"); +} + +pub func HandleApiInfo() -> HttpResponse { + return Http_NewResponse(200, "application/json; charset=utf-8", + "{\"name\":\"Nexus\",\"language\":\"Bux\",\"features\":[\"HTTP/1.1\",\"thread-pool\",\"algebraic-enums\"]}"); +} + +pub func HandleWebSocketUpgrade(req: HttpRequest) -> HttpResponse { + let wsKey: String = RequestHeader_Get(req, "Sec-WebSocket-Key"); + + var resp: HttpResponse; + resp.statusCode = 101; + resp.contentType = ""; + resp.body = ""; + + let sb: *void = bux_sb_new(256); + bux_sb_append(sb, "Upgrade: websocket\r\n"); + bux_sb_append(sb, "Connection: Upgrade\r\n"); + bux_sb_append(sb, "Sec-WebSocket-Accept: "); + bux_sb_append(sb, wsKey); + bux_sb_append(sb, "\r\n"); + resp.extraHeaders = bux_sb_build(sb); + bux_sb_free(sb); + + return resp; +} + +} diff --git a/apps/nexus/src/Http.bux b/apps/nexus/src/Http.bux new file mode 100644 index 0000000..2dceb74 --- /dev/null +++ b/apps/nexus/src/Http.bux @@ -0,0 +1,107 @@ +module Http { + +import Std::Array::{Array}; +import Std::String::{String_Eq, String_EndsWith, String_Contains}; + +pub enum HttpMethod { + GET, + POST, + PUT, + DELETE, + PATCH, + HEAD, + OPTIONS, + UNKNOWN, +} + +pub struct HeaderEntry { + key: String; + value: String; +} + +pub struct HttpRequest { + method: HttpMethod; + path: String; + version: String; + body: String; + headers: Array; +} + +pub struct HttpResponse { + statusCode: int; + contentType: String; + body: String; + extraHeaders: String; +} + +pub func Http_StatusText(code: int) -> String { + if code == 200 { return "OK"; } + if code == 201 { return "Created"; } + if code == 204 { return "No Content"; } + if code == 301 { return "Moved Permanently"; } + if code == 302 { return "Found"; } + if code == 304 { return "Not Modified"; } + if code == 400 { return "Bad Request"; } + if code == 401 { return "Unauthorized"; } + if code == 403 { return "Forbidden"; } + if code == 404 { return "Not Found"; } + if code == 405 { return "Method Not Allowed"; } + if code == 413 { return "Payload Too Large"; } + if code == 414 { return "URI Too Long"; } + if code == 500 { return "Internal Server Error"; } + if code == 501 { return "Not Implemented"; } + if code == 503 { return "Service Unavailable"; } + return "Unknown"; +} + +pub func Http_MimeType(path: String) -> String { + if String_EndsWith(path, ".html") || String_EndsWith(path, ".htm") { return "text/html; charset=utf-8"; } + if String_EndsWith(path, ".css") { return "text/css; charset=utf-8"; } + if String_EndsWith(path, ".js") { return "application/javascript; charset=utf-8"; } + if String_EndsWith(path, ".json") { return "application/json; charset=utf-8"; } + if String_EndsWith(path, ".xml") { return "application/xml; charset=utf-8"; } + if String_EndsWith(path, ".txt") { return "text/plain; charset=utf-8"; } + if String_EndsWith(path, ".png") { return "image/png"; } + if String_EndsWith(path, ".jpg") || String_EndsWith(path, ".jpeg") { return "image/jpeg"; } + if String_EndsWith(path, ".gif") { return "image/gif"; } + if String_EndsWith(path, ".svg") { return "image/svg+xml"; } + if String_EndsWith(path, ".ico") { return "image/x-icon"; } + if String_EndsWith(path, ".webp") { return "image/webp"; } + if String_EndsWith(path, ".woff2") { return "font/woff2"; } + if String_EndsWith(path, ".woff") { return "font/woff"; } + if String_EndsWith(path, ".wasm") { return "application/wasm"; } + return "application/octet-stream"; +} + +pub func Http_MethodName(m: HttpMethod) -> String { + match m { + HttpMethod::GET => "GET", + HttpMethod::POST => "POST", + HttpMethod::PUT => "PUT", + HttpMethod::DELETE => "DELETE", + HttpMethod::PATCH => "PATCH", + HttpMethod::HEAD => "HEAD", + HttpMethod::OPTIONS => "OPTIONS", + HttpMethod::UNKNOWN => "UNKNOWN", + } +} + +pub func Http_NewResponse(code: int, contentType: String, body: String) -> HttpResponse { + var resp: HttpResponse; + resp.statusCode = code; + resp.contentType = contentType; + resp.body = body; + resp.extraHeaders = ""; + return resp; +} + +pub func RequestHeader_Get(req: HttpRequest, key: String) -> String { + for entry in req.headers { + if String_Eq(entry.key, key) { + return entry.value; + } + } + return ""; +} + +} diff --git a/apps/nexus/src/Main.bux b/apps/nexus/src/Main.bux index 0f841c4..adf1072 100644 --- a/apps/nexus/src/Main.bux +++ b/apps/nexus/src/Main.bux @@ -1,550 +1,49 @@ -// ============================================================================= -// Nexus — High-performance multi-threaded HTTP/1.1, HTTP/2 & WebSocket server -// Built with the Bux programming language -// ============================================================================= module Main { -// ============================================================================= -// Imports — only what we actually use -// ============================================================================= -import Std::Io::{PrintLine, Print, PrintInt}; -import Std::Net::{Net_Create, Net_SetReuse, Net_Bind, Net_Listen, Net_Accept, Net_Send, Net_Recv, Net_Close, Net_LastError}; -import Std::String::{String_Len, String_Eq, String_StartsWith, String_EndsWith, String_Contains, String_Trim, String_FromInt, String_Offset}; -import Std::Task::{Task_Join, TaskHandle}; +import Config::{ServerConfig, DefaultConfig}; +import Http::{HttpMethod}; +import Router::{Handler, Route, Router}; +import Server::{RunServer}; +import Std::Array::{Array, Array_New, Array_Push}; -// ============================================================================= -// Extern Functions (from C runtime — used directly for performance) -// ============================================================================= -extern func bux_alloc(size: uint) -> *void; -extern func bux_strlen(s: String) -> uint; -extern func bux_strcmp(a: String, b: String) -> int; -extern func bux_strstr(haystack: String, needle: String) -> String; -extern func bux_str_slice(s: String, start: uint, len: uint) -> String; -extern func bux_str_split_count(s: String, delim: String) -> uint; -extern func bux_str_split_part(s: String, delim: String, index: uint) -> String; -extern func bux_sb_new(initial_cap: uint) -> *void; -extern func bux_sb_append(sb: *void, s: String); -extern func bux_sb_append_int(sb: *void, n: int64); -extern func bux_sb_append_char(sb: *void, c: char8); -extern func bux_sb_build(sb: *void) -> String; -extern func bux_sb_free(sb: *void); -extern func bux_path_join(a: String, b: String) -> String; -extern func bux_read_file(path: String) -> String; -extern func bux_file_exists(path: String) -> int; +func BuildRouter() -> Router { + var routes: Array = Array_New(8); -// ============================================================================= -// HTTP Method Enum (simple enum — no data payload) -// ============================================================================= -enum HttpMethod { - GET, - POST, - PUT, - DELETE, - PATCH, - HEAD, - OPTIONS, - UNKNOWN, + Array_Push(&routes, Route { + method: HttpMethod { tag: HttpMethod_GET }, + path: "/api/health", + handler: Handler { tag: Handler_ApiHealth }, + }); + + Array_Push(&routes, Route { + method: HttpMethod { tag: HttpMethod_GET }, + path: "/api/info", + handler: Handler { tag: Handler_ApiInfo }, + }); + + Array_Push(&routes, Route { + method: HttpMethod { tag: HttpMethod_GET }, + path: "/ws", + handler: Handler { tag: Handler_WsUpgrade }, + }); + + Array_Push(&routes, Route { + method: HttpMethod { tag: HttpMethod_GET }, + path: "/", + handler: Handler { tag: Handler_StaticFile }, + }); + + return Router { + routes: routes, + notFound: Handler { tag: Handler_NotFound }, + }; } -// ============================================================================= -// Struct: HTTP Request -// ============================================================================= -struct HttpRequest { - method: HttpMethod, - path: String, - body: String, - headerKeys: *String, - headerValues: *String, - headerCount: int, - headerCap: int, -} - -// ============================================================================= -// Struct: HTTP Response -// ============================================================================= -struct HttpResponse { - statusCode: int, - statusText: String, - contentType: String, - body: String, - extraHeaders: String, // pre-formatted extra headers (for WS upgrade, etc.) - connectionClose: bool, -} - -// ============================================================================= -// Utility: Status text lookup -// ============================================================================= -func Http_StatusText(code: int) -> String { - if code == 200 { return "OK"; } - if code == 201 { return "Created"; } - if code == 204 { return "No Content"; } - if code == 301 { return "Moved Permanently"; } - if code == 302 { return "Found"; } - if code == 304 { return "Not Modified"; } - if code == 400 { return "Bad Request"; } - if code == 401 { return "Unauthorized"; } - if code == 403 { return "Forbidden"; } - if code == 404 { return "Not Found"; } - if code == 405 { return "Method Not Allowed"; } - if code == 413 { return "Payload Too Large"; } - if code == 414 { return "URI Too Long"; } - if code == 500 { return "Internal Server Error"; } - if code == 501 { return "Not Implemented"; } - if code == 503 { return "Service Unavailable"; } - return "Unknown"; -} - -// ============================================================================= -// Utility: Parse HTTP method string → HttpMethod enum -// ============================================================================= -func Http_ParseMethod(s: String) -> HttpMethod { - if String_Eq(s, "GET") { return HttpMethod { tag: HttpMethod_GET }; } - if String_Eq(s, "POST") { return HttpMethod { tag: HttpMethod_POST }; } - if String_Eq(s, "PUT") { return HttpMethod { tag: HttpMethod_PUT }; } - if String_Eq(s, "DELETE") { return HttpMethod { tag: HttpMethod_DELETE }; } - if String_Eq(s, "PATCH") { return HttpMethod { tag: HttpMethod_PATCH }; } - if String_Eq(s, "HEAD") { return HttpMethod { tag: HttpMethod_HEAD }; } - if String_Eq(s, "OPTIONS") { return HttpMethod { tag: HttpMethod_OPTIONS }; } - return HttpMethod { tag: HttpMethod_UNKNOWN }; -} - -// ============================================================================= -// Utility: MIME type from file extension -// ============================================================================= -func Http_MimeType(path: String) -> String { - if String_EndsWith(path, ".html") || String_EndsWith(path, ".htm") { return "text/html; charset=utf-8"; } - if String_EndsWith(path, ".css") { return "text/css; charset=utf-8"; } - if String_EndsWith(path, ".js") { return "application/javascript; charset=utf-8"; } - if String_EndsWith(path, ".json") { return "application/json; charset=utf-8"; } - if String_EndsWith(path, ".xml") { return "application/xml; charset=utf-8"; } - if String_EndsWith(path, ".txt") { return "text/plain; charset=utf-8"; } - if String_EndsWith(path, ".png") { return "image/png"; } - if String_EndsWith(path, ".jpg") || String_EndsWith(path, ".jpeg") { return "image/jpeg"; } - if String_EndsWith(path, ".gif") { return "image/gif"; } - if String_EndsWith(path, ".svg") { return "image/svg+xml"; } - if String_EndsWith(path, ".ico") { return "image/x-icon"; } - if String_EndsWith(path, ".webp") { return "image/webp"; } - if String_EndsWith(path, ".woff2") { return "font/woff2"; } - if String_EndsWith(path, ".woff") { return "font/woff"; } - if String_EndsWith(path, ".wasm") { return "application/wasm"; } - return "application/octet-stream"; -} - -// ============================================================================= -// Header Storage: dynamic key-value array (faster than hash map for 5-15 headers) -// ============================================================================= -func RequestHeader_Init(req: *HttpRequest) { - let cap: int = 16; - req.headerCap = cap; - req.headerKeys = bux_alloc(cap as uint * 8) as *String; - req.headerValues = bux_alloc(cap as uint * 8) as *String; - req.headerCount = 0; -} - -func RequestHeader_Add(req: *HttpRequest, key: String, value: String) { - if req.headerCount >= req.headerCap { return; } - req.headerKeys[req.headerCount] = key; - req.headerValues[req.headerCount] = value; - req.headerCount = req.headerCount + 1; -} - -func RequestHeader_Get(req: *HttpRequest, key: String) -> String { - var i: int = 0; - while i < req.headerCount { - if bux_strcmp(req.headerKeys[i], key) == 0 { - return req.headerValues[i]; - } - i = i + 1; - } - return ""; -} - -// ============================================================================= -// HTTP Request Parser -// ============================================================================= -func Http_ParseRequest(raw: String) -> HttpRequest { - var req: HttpRequest; - req.method = HttpMethod { tag: HttpMethod_UNKNOWN }; - req.path = "/"; - req.body = ""; - RequestHeader_Init(&req); - - // Guard: null/empty input - if String_Len(raw) == 0 { return req; } - let rawLen: uint = bux_strlen(raw); - if rawLen == 0 { return req; } - - // Find \r\n\r\n separating headers from body - let boundary: String = bux_strstr(raw, "\r\n\r\n"); - var headerLen: uint = rawLen; - if String_Len(boundary) > 0 { - headerLen = String_Offset(boundary, raw); - let bodyStart: uint = headerLen + 4; - if bodyStart < rawLen { - req.body = bux_str_slice(raw, bodyStart, rawLen - bodyStart); - } - } - - // Slice out header block - if headerLen == 0 { return req; } - let headerBlock: String = bux_str_slice(raw, 0, headerLen); - - // Count header lines - let lineCount: uint = bux_str_split_count(headerBlock, "\r\n"); - if lineCount == 0 { return req; } - - // --- Parse request line: "METHOD /path HTTP/1.1" --- - let requestLine: String = bux_str_split_part(headerBlock, "\r\n", 0); - if bux_strlen(requestLine) > 0 { - req.method = Http_ParseMethod(bux_str_split_part(requestLine, " ", 0)); - req.path = bux_str_split_part(requestLine, " ", 1); - if String_Eq(req.path, "") || String_Len(req.path) == 0 { - req.path = "/"; - } - } - - // --- Parse headers (lines 1..N-1) --- - var i: uint = 1; - while i < lineCount { - let line: String = bux_str_split_part(headerBlock, "\r\n", i); - let lineLen: uint = bux_strlen(line); - if lineLen == 0 { i = i + 1; continue; } - - // Find ": " separator - let colonPos: String = bux_strstr(line, ": "); - var key: String = ""; - var value: String = ""; - - if String_Len(colonPos) > 0 { - let keyLen: uint = String_Offset(colonPos, line); - key = bux_str_slice(line, 0, keyLen); - let valStart: uint = keyLen + 2; - if valStart < lineLen { - value = bux_str_slice(line, valStart, lineLen - valStart); - } - } else { - // Try ":" without space - let colonPos2: String = bux_strstr(line, ":"); - if String_Len(colonPos2) > 0 { - let keyLen: uint = String_Offset(colonPos2, line); - key = bux_str_slice(line, 0, keyLen); - let valStart: uint = keyLen + 1; - if valStart < lineLen { - value = bux_str_slice(line, valStart, lineLen - valStart); - } - value = String_Trim(value); - } - } - - // Store if valid key found - if bux_strlen(key) > 0 { - key = String_Trim(key); - RequestHeader_Add(&req, key, value); - } - - i = i + 1; - } - - return req; -} - -// ============================================================================= -// HTTP Response Builder -// ============================================================================= -func Http_BuildResponse(resp: HttpResponse) -> String { - let sb: *void = bux_sb_new(4096); - - // Status line - bux_sb_append(sb, "HTTP/1.1 "); - bux_sb_append_int(sb, resp.statusCode as int64); - bux_sb_append(sb, " "); - bux_sb_append(sb, resp.statusText); - bux_sb_append(sb, "\r\n"); - - // Server - bux_sb_append(sb, "Server: Nexus/0.1.0 (Bux)\r\n"); - - // Extra headers (for WS upgrade etc.) - if bux_strlen(resp.extraHeaders) > 0 { - bux_sb_append(sb, resp.extraHeaders); - } - - // Content-Type - if bux_strlen(resp.contentType) > 0 { - bux_sb_append(sb, "Content-Type: "); - bux_sb_append(sb, resp.contentType); - bux_sb_append(sb, "\r\n"); - } - - // Content-Length - let bodyLen: uint = bux_strlen(resp.body); - bux_sb_append(sb, "Content-Length: "); - bux_sb_append_int(sb, bodyLen as int64); - bux_sb_append(sb, "\r\n"); - - // Connection - if resp.connectionClose { - bux_sb_append(sb, "Connection: close\r\n"); - } else { - bux_sb_append(sb, "Connection: keep-alive\r\n"); - } - - // End headers - bux_sb_append(sb, "\r\n"); - - // Body - if bodyLen > 0 { - bux_sb_append(sb, resp.body); - } - - let result: String = bux_sb_build(sb); - bux_sb_free(sb); - return result; -} - -// ============================================================================= -// Helper: Create a simple response -// ============================================================================= -func Http_NewResponse(code: int, contentType: String, body: String) -> HttpResponse { - var resp: HttpResponse; - resp.statusCode = code; - resp.statusText = Http_StatusText(code); - resp.contentType = contentType; - resp.body = body; - resp.extraHeaders = ""; - resp.connectionClose = true; - return resp; -} - -// ============================================================================= -// Static File Server -// ============================================================================= -func ServeStaticFile(requestPath: String) -> HttpResponse { - // Block directory traversal - if String_Contains(requestPath, "..") { - return Http_NewResponse(403, "text/plain; charset=utf-8", "Forbidden"); - } - - // Default to index.html - var filePath: String = requestPath; - if String_Eq(filePath, "/") { - filePath = "/index.html"; - } - - // Resolve full path - let fullPath: String = bux_path_join("public", filePath); - - // Check existence - if bux_file_exists(fullPath) == 0 { - return Http_NewResponse(404, "text/plain; charset=utf-8", "Not Found"); - } - - // Read and serve - let content: String = bux_read_file(fullPath); - if String_Len(content) == 0 { - return Http_NewResponse(500, "text/plain; charset=utf-8", "Internal Server Error"); - } - - let mime: String = Http_MimeType(filePath); - return Http_NewResponse(200, mime, content); -} - -// ============================================================================= -// API Handlers -// ============================================================================= -func HandleApiHealth() -> HttpResponse { - return Http_NewResponse(200, "application/json; charset=utf-8", - "{\"status\":\"ok\",\"server\":\"Nexus\",\"version\":\"0.1.0\"}"); -} - -func HandleApiInfo() -> HttpResponse { - return Http_NewResponse(200, "application/json; charset=utf-8", - "{\"name\":\"Nexus\",\"language\":\"Bux\",\"threads\":4,\"features\":[\"HTTP/1.1\",\"HTTP/2-detect\",\"WebSocket-upgrade\"]}"); -} - -// ============================================================================= -// WebSocket Upgrade Handshake -// ============================================================================= -func HandleWebSocketUpgrade(req: HttpRequest) -> HttpResponse { - let wsKey: String = RequestHeader_Get(&req, "Sec-WebSocket-Key"); - - var resp: HttpResponse; - resp.statusCode = 101; - resp.statusText = "Switching Protocols"; - resp.contentType = ""; - resp.body = ""; - resp.connectionClose = false; - - // Build upgrade headers as extraHeaders - // TODO: SHA-1 + Base64 for proper accept key - let sb: *void = bux_sb_new(256); - bux_sb_append(sb, "Upgrade: websocket\r\n"); - bux_sb_append(sb, "Connection: Upgrade\r\n"); - bux_sb_append(sb, "Sec-WebSocket-Accept: "); - bux_sb_append(sb, wsKey); // placeholder — real impl needs crypto - bux_sb_append(sb, "\r\n"); - resp.extraHeaders = bux_sb_build(sb); - bux_sb_free(sb); - - return resp; -} - -// ============================================================================= -// Router / Dispatcher -// ============================================================================= -func Router_Dispatch(req: HttpRequest) -> HttpResponse { - // Check for upgrade headers - let upgrade: String = RequestHeader_Get(&req, "Upgrade"); - if bux_strlen(upgrade) > 0 { - if String_Contains(upgrade, "websocket") { - return HandleWebSocketUpgrade(req); - } - } - - // API routes - if String_StartsWith(req.path, "/api/") { - if String_Eq(req.path, "/api/health") { return HandleApiHealth(); } - if String_Eq(req.path, "/api/info") { return HandleApiInfo(); } - return Http_NewResponse(404, "application/json; charset=utf-8", - "{\"error\":\"not_found\"}"); - } - - // WebSocket endpoint - if String_Eq(req.path, "/ws") { - return HandleWebSocketUpgrade(req); - } - - // Static files — GET/HEAD only - if req.method.tag == HttpMethod_GET || req.method.tag == HttpMethod_HEAD { - return ServeStaticFile(req.path); - } - - // Method not allowed - return Http_NewResponse(405, "text/plain; charset=utf-8", "Method Not Allowed"); -} - -// ============================================================================= -// Method name for logging (avoids 8 if-checks in hot path) -// ============================================================================= -func Http_MethodName(m: HttpMethod) -> String { - if m.tag == HttpMethod_GET { return "GET"; } - if m.tag == HttpMethod_POST { return "POST"; } - if m.tag == HttpMethod_PUT { return "PUT"; } - if m.tag == HttpMethod_DELETE { return "DELETE"; } - if m.tag == HttpMethod_PATCH { return "PATCH"; } - if m.tag == HttpMethod_HEAD { return "HEAD"; } - if m.tag == HttpMethod_OPTIONS { return "OPTIONS"; } - return "UNKNOWN"; -} - -// ============================================================================= -// Connection Handler — read, parse, route, respond -// ============================================================================= -func HandleConnection(clientFd: int) { - let raw: String = Net_Recv(clientFd, 8192); - - // Empty read → client disconnected - if String_Len(raw) == 0 { return; } - if bux_strlen(raw) == 0 { return; } - - // HTTP/2 connection preface detection - if String_StartsWith(raw, "PRI * HTTP/2.0") { - let resp: HttpResponse = Http_NewResponse(200, "text/plain; charset=utf-8", - "HTTP/2 detected — full support planned for future release.\r\n"); - let respStr: String = Http_BuildResponse(resp); - Net_Send(clientFd, respStr); - return; - } - - // Parse HTTP/1.1 - let req: HttpRequest = Http_ParseRequest(raw); - - // Log - Print(Http_MethodName(req.method)); - Print(" "); - Print(req.path); - Print(" -> "); - - // Dispatch - let resp: HttpResponse = Router_Dispatch(req); - - // Log result - PrintInt(resp.statusCode); - Print(" "); - PrintLine(resp.statusText); - - // Send - let respStr: String = Http_BuildResponse(resp); - Net_Send(clientFd, respStr); -} - -// ============================================================================= -// Worker Thread — accept loop -// ============================================================================= -func Worker(serverFd: int) { - while true { - let clientFd: int = Net_Accept(serverFd); - if clientFd < 0 { - continue; - } - HandleConnection(clientFd); - Net_Close(clientFd); - } -} - -// ============================================================================= -// Main Entry Point -// ============================================================================= func Main() -> int { - PrintLine("================================================"); - PrintLine(" Nexus HTTP Server v0.1.0"); - PrintLine(" Multi-threaded HTTP/1.1 + HTTP/2 & WS detect"); - PrintLine(" Built with Bux"); - PrintLine("================================================"); - PrintLine(""); + let config: ServerConfig = DefaultConfig(); + let router: Router = BuildRouter(); - // Create socket - let serverFd: int = Net_Create(); - if serverFd < 0 { - PrintLine("FATAL: socket() failed"); - return 1; - } - - // SO_REUSEADDR - if !Net_SetReuse(serverFd) { - PrintLine("WARN: SO_REUSEADDR failed"); - } - - // Bind - if !Net_Bind(serverFd, "0.0.0.0", 8080) { - Print("FATAL: bind(8080) failed: "); - PrintLine(Net_LastError()); - Net_Close(serverFd); - return 1; - } - - // Listen - if !Net_Listen(serverFd, 128) { - PrintLine("FATAL: listen() failed"); - Net_Close(serverFd); - return 1; - } - - PrintLine("Listening on http://0.0.0.0:8080"); - PrintLine("4 worker threads | static: ./public/"); - PrintLine("Endpoints: / /api/health /api/info /ws"); - PrintLine("Press Ctrl+C to stop."); - PrintLine(""); - - // Spawn 3 workers (main thread is the 4th) - spawn Worker(serverFd); - spawn Worker(serverFd); - spawn Worker(serverFd); - - // Main thread becomes worker #4 (blocking call) - Worker(serverFd); - - return 0; + return RunServer(config, router); } -} // module Main +} diff --git a/apps/nexus/src/Parser.bux b/apps/nexus/src/Parser.bux new file mode 100644 index 0000000..9e8f84b --- /dev/null +++ b/apps/nexus/src/Parser.bux @@ -0,0 +1,130 @@ +module Parser { + +import Std::String::{String_Len, String_Eq, String_Trim}; +import Std::Array::{Array, Array_New, Array_Push}; +import Http::{HttpMethod, HttpRequest, HeaderEntry}; +import Errors::{HttpError, ParseResult, ParseResult_NewOk, ParseResult_NewErr}; + +extern func bux_strlen(s: String) -> uint; +extern func bux_strstr(haystack: String, needle: String) -> String; +extern func bux_str_slice(s: String, start: uint, len: uint) -> String; +extern func bux_str_offset(pos: String, base: String) -> uint; + +pub func ParseMethod(s: String) -> HttpMethod { + if String_Eq(s, "GET") { return HttpMethod { tag: HttpMethod_GET }; } + if String_Eq(s, "POST") { return HttpMethod { tag: HttpMethod_POST }; } + if String_Eq(s, "PUT") { return HttpMethod { tag: HttpMethod_PUT }; } + if String_Eq(s, "DELETE") { return HttpMethod { tag: HttpMethod_DELETE }; } + if String_Eq(s, "PATCH") { return HttpMethod { tag: HttpMethod_PATCH }; } + if String_Eq(s, "HEAD") { return HttpMethod { tag: HttpMethod_HEAD }; } + if String_Eq(s, "OPTIONS") { return HttpMethod { tag: HttpMethod_OPTIONS }; } + return HttpMethod { tag: HttpMethod_UNKNOWN }; +} + +func Slice(raw: String, start: int, len: int) -> String { + if start < 0 || len <= 0 { return ""; } + return bux_str_slice(raw, start as uint, len as uint); +} + +func FindCrlf(raw: String, start: int) -> int { + let rawLen: uint = bux_strlen(raw); + if start as uint >= rawLen { return -1; } + let tail: String = bux_str_slice(raw, start as uint, rawLen - start as uint); + let hit: String = bux_strstr(tail, "\r\n"); + if String_Len(hit) == 0 { return -1; } + let offset: uint = bux_str_offset(hit, tail); + return start + offset as int; +} + +func ParseHeaders(raw: String, start: int, end: int) -> Array { + var headers: Array = Array_New(16); + var pos: int = start; + while pos < end { + let lineEnd: int = FindCrlf(raw, pos); + if lineEnd < 0 || lineEnd >= end { break; } + let lineLen: int = lineEnd - pos; + if lineLen > 0 { + let line: String = Slice(raw, pos, lineLen); + let colon: String = bux_strstr(line, ":"); + if String_Len(colon) > 0 { + let keyLen: uint = bux_str_offset(colon, line); + let key: String = String_Trim(Slice(line, 0, keyLen as int)); + let valStart: int = keyLen as int + 1; + let val: String = String_Trim(Slice(line, valStart, lineLen - valStart)); + let entry: HeaderEntry = HeaderEntry { key: key, value: val }; + Array_Push(&headers, entry); + } + } + pos = lineEnd + 2; + } + return headers; +} + +pub func ParseRequest(raw: String) -> ParseResult { + let rawLen: uint = bux_strlen(raw); + if rawLen == 0 { + return ParseResult_NewErr(HttpError { tag: HttpError_BadRequest }); + } + + // Find end of request line + let lineEnd: int = FindCrlf(raw, 0); + if lineEnd < 0 { + return ParseResult_NewErr(HttpError { tag: HttpError_BadRequest }); + } + + // Split request line: METHOD PATH VERSION + var methodEnd: int = -1; + var pathStart: int = -1; + var pathEnd: int = -1; + var i: int = 0; + while i < lineEnd { + if raw[i] as int == 32 { // space + if methodEnd < 0 { + methodEnd = i; + pathStart = i + 1; + } else if pathEnd < 0 { + pathEnd = i; + break; + } + } + i = i + 1; + } + + if methodEnd < 0 || pathStart < 0 || pathEnd < 0 { + return ParseResult_NewErr(HttpError { tag: HttpError_BadRequest }); + } + + let methodStr: String = Slice(raw, 0, methodEnd); + let path: String = Slice(raw, pathStart, pathEnd - pathStart); + let version: String = Slice(raw, pathEnd + 1, lineEnd - pathEnd - 1); + + // Find header/body boundary + let boundary: String = bux_strstr(raw, "\r\n\r\n"); + var headers: Array = Array_New(16); + var body: String = ""; + if String_Len(boundary) > 0 { + let headerEnd: uint = bux_str_offset(boundary, raw); + headers = ParseHeaders(raw, lineEnd + 2, headerEnd as int); + let bodyStart: uint = headerEnd + 4; + if bodyStart < rawLen { + body = bux_str_slice(raw, bodyStart, rawLen - bodyStart); + } + } else { + headers = ParseHeaders(raw, lineEnd + 2, rawLen as int); + } + + if String_Eq(path, "") { + return ParseResult_NewErr(HttpError { tag: HttpError_BadRequest }); + } + + let req: HttpRequest = HttpRequest { + method: ParseMethod(methodStr), + path: path, + version: version, + body: body, + headers: headers, + }; + return ParseResult_NewOk(req); +} + +} diff --git a/apps/nexus/src/Router.bux b/apps/nexus/src/Router.bux new file mode 100644 index 0000000..41b5612 --- /dev/null +++ b/apps/nexus/src/Router.bux @@ -0,0 +1,46 @@ +module Router { + +import Std::Array::{Array}; +import Std::String::{String_Eq}; +import Http::{HttpMethod, HttpRequest, HttpResponse, Http_NewResponse}; +import Handlers::{ServeStaticFile, HandleApiHealth, HandleApiInfo, HandleWebSocketUpgrade, NotFoundResponse}; + +pub enum Handler { + StaticFile, + ApiHealth, + ApiInfo, + WsUpgrade, + NotFound, +} + +pub struct Route { + method: HttpMethod; + path: String; + handler: Handler; +} + +pub struct Router { + routes: Array; + notFound: Handler; +} + +pub func Handler_Handle(h: Handler, req: HttpRequest) -> HttpResponse { + match h { + Handler::StaticFile => ServeStaticFile(req), + Handler::ApiHealth => HandleApiHealth(), + Handler::ApiInfo => HandleApiInfo(), + Handler::WsUpgrade => HandleWebSocketUpgrade(req), + Handler::NotFound => NotFoundResponse(), + } +} + +pub func Router_Dispatch(r: Router, req: HttpRequest) -> HttpResponse { + for route in r.routes { + if route.method == req.method && String_Eq(route.path, req.path) { + return Handler_Handle(route.handler, req); + } + } + return Handler_Handle(r.notFound, req); +} + +} diff --git a/apps/nexus/src/Server.bux b/apps/nexus/src/Server.bux new file mode 100644 index 0000000..9d03cd1 --- /dev/null +++ b/apps/nexus/src/Server.bux @@ -0,0 +1,176 @@ +module Server { + +import Std::Io::{Print, PrintLine, PrintInt}; +import Std::Net::{Net_Create, Net_SetReuse, Net_Bind, Net_Listen, Net_Accept, Net_Send, Net_Recv, Net_Close, Net_LastError}; +import Std::String::{String_Len, String_StartsWith}; +import Std::Channel::{Channel, Channel_New, Channel_Send, Channel_Recv}; +import Config::{ServerConfig}; +import Http::{HttpRequest, HttpResponse, Http_StatusText, Http_NewResponse}; +import Errors::{ParseResult}; +import Parser::{ParseRequest}; +import Router::{Router, Router_Dispatch}; + +extern func bux_strlen(s: String) -> uint; +extern func bux_sb_new(initial_cap: uint) -> *void; +extern func bux_sb_append(sb: *void, s: String); +extern func bux_sb_append_int(sb: *void, n: int64); +extern func bux_sb_build(sb: *void) -> String; +extern func bux_sb_free(sb: *void); + +pub struct ConnectionTask { + fd: int; +} + +pub func BuildResponse(resp: HttpResponse) -> String { + let sb: *void = bux_sb_new(4096); + + bux_sb_append(sb, "HTTP/1.1 "); + bux_sb_append_int(sb, resp.statusCode as int64); + bux_sb_append(sb, " "); + bux_sb_append(sb, Http_StatusText(resp.statusCode)); + bux_sb_append(sb, "\r\n"); + + bux_sb_append(sb, "Server: Nexus/0.2.0 (Bux)\r\n"); + + if bux_strlen(resp.extraHeaders) > 0 { + bux_sb_append(sb, resp.extraHeaders); + } + + if bux_strlen(resp.contentType) > 0 { + bux_sb_append(sb, "Content-Type: "); + bux_sb_append(sb, resp.contentType); + bux_sb_append(sb, "\r\n"); + } + + let bodyLen: uint = bux_strlen(resp.body); + bux_sb_append(sb, "Content-Length: "); + bux_sb_append_int(sb, bodyLen as int64); + bux_sb_append(sb, "\r\n"); + bux_sb_append(sb, "Connection: close\r\n"); + bux_sb_append(sb, "\r\n"); + + if bodyLen > 0 { + bux_sb_append(sb, resp.body); + } + + let result: String = bux_sb_build(sb); + bux_sb_free(sb); + return result; +} + +pub func HandleConnection(fd: int, router: Router) { + let raw: String = Net_Recv(fd, 8192); + if String_Len(raw) == 0 { + return; + } + + // HTTP/2 preface detection + if String_StartsWith(raw, "PRI * HTTP/2.0") { + let resp: HttpResponse = Http_NewResponse(200, "text/plain; charset=utf-8", + "HTTP/2 detected — full support planned for future release.\r\n"); + Net_Send(fd, BuildResponse(resp)); + return; + } + + let parsed: ParseResult = ParseRequest(raw); + if parsed.tag == ParseResult_Ok { + let req: HttpRequest = parsed.data.Ok_0; + let resp: HttpResponse = Router_Dispatch(router, req); + Net_Send(fd, BuildResponse(resp)); + } else { + let resp: HttpResponse = Http_NewResponse(400, "text/plain; charset=utf-8", "Bad Request"); + Net_Send(fd, BuildResponse(resp)); + } +} + +pub struct WorkerCtx { + taskQueue: *Channel; + router: Router; +} + +pub func Worker(ctx: *WorkerCtx) { + while true { + let task: ConnectionTask = Channel_Recv(ctx.taskQueue); + HandleConnection(task.fd, ctx.router); + Net_Close(task.fd); + } +} + +pub struct AcceptorCtx { + serverFd: int; + taskQueue: *Channel; +} + +pub func Acceptor(ctx: *AcceptorCtx) { + while true { + let fd: int = Net_Accept(ctx.serverFd); + if fd >= 0 { + let task: ConnectionTask = ConnectionTask { fd: fd }; + Channel_Send(ctx.taskQueue, task); + } + } +} + +pub func RunServer(config: ServerConfig, router: Router) -> int { + PrintLine("================================================"); + PrintLine(" Nexus HTTP Server v0.2.0"); + PrintLine(" Production-ready HTTP/1.1 with thread-pool"); + PrintLine(" Built with Bux"); + PrintLine("================================================"); + PrintLine(""); + + let serverFd: int = Net_Create(); + if serverFd < 0 { + PrintLine("FATAL: socket() failed"); + return 1; + } + + if !Net_SetReuse(serverFd) { + PrintLine("WARN: SO_REUSEADDR failed"); + } + + if !Net_Bind(serverFd, config.bindAddr, config.port) { + Print("FATAL: bind failed: "); + PrintLine(Net_LastError()); + Net_Close(serverFd); + return 1; + } + + if !Net_Listen(serverFd, config.backlog) { + PrintLine("FATAL: listen() failed"); + Net_Close(serverFd); + return 1; + } + + Print("Listening on http://"); + Print(config.bindAddr); + Print(":"); + PrintInt(config.port); + PrintLine(""); + PrintInt(config.workerCount); + PrintLine(" worker threads | static: ./public/"); + PrintLine("Endpoints: / /api/health /api/info /ws"); + PrintLine("Press Ctrl+C to stop."); + PrintLine(""); + + let taskQueue: Channel = Channel_New(config.backlog as int64); + let workerCtx: WorkerCtx = WorkerCtx { taskQueue: &taskQueue, router: router }; + let acceptorCtx: AcceptorCtx = AcceptorCtx { serverFd: serverFd, taskQueue: &taskQueue }; + + // Spawn workers (main thread will also become one) + var i: int = 0; + while i < config.workerCount - 1 { + spawn Worker(&workerCtx); + i = i + 1; + } + + // Spawn acceptor + spawn Acceptor(&acceptorCtx); + + // Main thread works too + Worker(&workerCtx); + + return 0; +} + +} diff --git a/bootstrap/cli.nim b/bootstrap/cli.nim index c5cc1a8..e4b1cb2 100644 --- a/bootstrap/cli.nim +++ b/bootstrap/cli.nim @@ -1,5 +1,5 @@ import std/[os, strutils, terminal, strformat, osproc, sets] -import lexer, parser, ast, sema, manifest, hir_lower, lir, lir_lower, lir_c_backend +import lexer, parser, ast, sema, manifest, hir_lower, lir_lower, lir_c_backend type ColorMode* = enum diff --git a/bootstrap/hir_lower.nim b/bootstrap/hir_lower.nim index 0b05f5e..73760e4 100644 --- a/bootstrap/hir_lower.nim +++ b/bootstrap/hir_lower.nim @@ -42,22 +42,37 @@ proc flushPending(ctx: var LowerCtx, node: HirNode): HirNode = return hirBlock(stmts, nil, makeVoid(), node.loc) return node +proc enumHasDataVariants(ctx: var LowerCtx, enumName: string): bool = + let sym = ctx.globalScope.lookup(enumName) + if sym != nil and sym.decl != nil and sym.decl.kind == dkEnum: + for v in sym.decl.declEnumVariants: + if v.fields.len > 0 or v.namedFields.len > 0: + return true + return false + proc lowerMatch(ctx: var LowerCtx, subject: HirNode, arms: seq[HirMatchArm], typ: Type, loc: SourceLocation): HirNode = # Lower match expression to a block with if-else chain. # For now, supports enum tag matching and wildcard/ident fallbacks. let resultName = ctx.freshName() var stmts: seq[HirNode] = @[] - + # Allocate result variable stmts.add(hirAlloca(resultName, typ, loc)) - + + # Determine whether the matched enum has data variants (needs .tag access). + var subjectEnumName = "" + var subjectHasData = false + if subject.typ != nil and subject.typ.kind == tkNamed: + subjectEnumName = subject.typ.name + subjectHasData = ctx.enumHasDataVariants(subjectEnumName) + # Build if-else chain from arms (last arm is the outermost else) var ifChain: HirNode = nil - + for i in countdown(arms.len - 1, 0): let arm = arms[i] let body = arm.body - + case arm.pattern.kind of pkEnum: let path = arm.pattern.patEnumPath @@ -65,19 +80,25 @@ proc lowerMatch(ctx: var LowerCtx, subject: HirNode, arms: seq[HirMatchArm], typ let enumName = path[0] let variantName = path[^1] let tagName = enumName & "_" & variantName - - # condition: subject.tag == EnumName_VariantName - let tagField = HirNode(kind: hFieldPtr, fieldPtrBase: subject, fieldName: "tag", - typ: makePointer(makeNamed(enumName & "_Tag")), loc: loc) - let tagLoad = HirNode(kind: hLoad, loadPtr: tagField, typ: makeNamed(enumName & "_Tag"), loc: loc) - let tagConst = hirLit(Token(kind: tkIdent, text: tagName, loc: loc), makeNamed(enumName & "_Tag"), loc) - let cond = hirBinary(tkEq, tagLoad, tagConst, makeBool(), loc) - + + var cond: HirNode + if subjectHasData and enumName == subjectEnumName: + # Algebraic enum: compare subject.tag + let tagField = HirNode(kind: hFieldPtr, fieldPtrBase: subject, fieldName: "tag", + typ: makePointer(makeNamed(enumName & "_Tag")), loc: loc) + let tagLoad = HirNode(kind: hLoad, loadPtr: tagField, typ: makeNamed(enumName & "_Tag"), loc: loc) + let tagConst = hirLit(Token(kind: tkIdent, text: tagName, loc: loc), makeNamed(enumName & "_Tag"), loc) + cond = hirBinary(tkEq, tagLoad, tagConst, makeBool(), loc) + else: + # Simple enum or cross-enum match: compare subject directly + let tagConst = hirLit(Token(kind: tkIdent, text: tagName, loc: loc), makeNamed(enumName), loc) + cond = hirBinary(tkEq, subject, tagConst, makeBool(), loc) + # body: result = arm_body var armStmts: seq[HirNode] = @[] armStmts.add(hirStore(hirVar(resultName, typ, loc), body, loc)) let armBlock = hirBlock(armStmts, nil, makeVoid(), loc) - + if ifChain == nil: ifChain = HirNode(kind: hIf, ifCond: cond, ifThen: armBlock, ifElse: nil, typ: makeVoid(), loc: loc) @@ -115,9 +136,9 @@ proc lowerMatch(ctx: var LowerCtx, subject: HirNode, arms: seq[HirMatchArm], typ ifChain = HirNode(kind: hIf, ifCond: hirLit(Token(kind: tkBoolLiteral, text: "true", loc: loc), makeBool(), loc), ifThen: armBlock, ifElse: ifChain, typ: makeVoid(), loc: loc) - + stmts.add(ifChain) - + # Return the result variable as the block expression return hirBlock(stmts, hirVar(resultName, typ, loc), typ, loc) @@ -397,6 +418,8 @@ proc resolveExprType(ctx: var LowerCtx, expr: Expr): Type = if f.ftype != nil: case f.ftype.kind of tekNamed: + if f.ftype.typeArgs.len > 0: + return substituteType(ctx, f.ftype, subst) case f.ftype.typeName of "int", "int32", "int64": return makeInt() of "float64": return makeFloat64() @@ -417,6 +440,8 @@ proc resolveExprType(ctx: var LowerCtx, expr: Expr): Type = if f.ftype != nil: case f.ftype.kind of tekNamed: + if f.ftype.typeArgs.len > 0: + return ctx.resolveTypeExpr(f.ftype) case f.ftype.typeName of "int", "int32", "int64": return makeInt() of "float64": return makeFloat64() @@ -478,6 +503,10 @@ proc resolveExprType(ctx: var LowerCtx, expr: Expr): Type = if baseType.isPointer and baseType.inner.len > 0: return baseType.inner[0] return makeUnknown() + of ekMatch: + if expr.exprMatchArms.len > 0: + return ctx.resolveExprType(expr.exprMatchArms[0].body) + return makeUnknown() of ekBlock: if expr.exprBlock.stmts.len > 0: let last = expr.exprBlock.stmts[^1] @@ -524,6 +553,23 @@ proc getCollectionElementTypeExpr(ctx: var LowerCtx, expr: Expr): TypeExpr = return te.typeArgs[0] if te.kind in {tekPointer, tekRef, tekMutRef} and te.pointerPointee.kind == tekNamed and te.pointerPointee.typeArgs.len > 0: return te.pointerPointee.typeArgs[0] + of ekField: + # Try to resolve the field's declared TypeExpr directly. + let objType = ctx.resolveExprType(expr.exprFieldObj) + if objType.kind == tkNamed: + var decl = ctx.globalScope.lookup(objType.name).decl + if decl == nil and ctx.structInstMap.hasKey(objType.name): + let (baseName, _) = ctx.structInstMap[objType.name] + let baseSym = ctx.globalScope.lookup(baseName) + if baseSym != nil and baseSym.decl != nil and baseSym.decl.kind == dkStruct: + decl = baseSym.decl + if decl != nil and decl.kind == dkStruct: + for f in decl.declStructFields: + if f.name == expr.exprFieldName and f.ftype != nil: + let fte = f.ftype + if fte.kind == tekNamed and fte.typeArgs.len > 0 and (fte.typeName == "Array" or fte.typeName == "Iter" or fte.typeName == "Channel"): + return fte.typeArgs[0] + return fte else: discard let t = ctx.resolveExprType(expr) @@ -531,6 +577,11 @@ proc getCollectionElementTypeExpr(ctx: var LowerCtx, expr: Expr): TypeExpr = return typeToTypeExpr(t.inner[0]) if t.isPointer and t.inner.len > 0 and t.inner[0].kind == tkNamed and t.inner[0].inner.len > 0: return typeToTypeExpr(t.inner[0].inner[0]) + # Generic struct instances (e.g. Array_HeaderEntry) store their type args in structInstMap. + if t.kind == tkNamed and ctx.structInstMap.hasKey(t.name): + let (baseName, concreteArgs) = ctx.structInstMap[t.name] + if concreteArgs.len > 0 and (baseName == "Array" or baseName == "Iter" or baseName == "Channel"): + return typeToTypeExpr(concreteArgs[0]) return TypeExpr(kind: tekNamed, typeName: "unknown") proc generateMethodInstance(ctx: var LowerCtx, baseMethodName: string, typeArgs: seq[TypeExpr]): string @@ -1660,7 +1711,6 @@ proc generateMethodInstance(ctx: var LowerCtx, baseMethodName: string, typeArgs: return mangledName proc lowerClosureFunc(ctx: var LowerCtx, expr: Expr): HirFunc = - let loc = expr.loc let name = "__closure_" & $ctx.varCounter inc ctx.varCounter var f = HirFunc(name: name, isPublic: false) diff --git a/bootstrap/lexer.nim b/bootstrap/lexer.nim index 762a3ad..727e0d4 100644 --- a/bootstrap/lexer.nim +++ b/bootstrap/lexer.nim @@ -61,12 +61,6 @@ proc advance(lex: var Lexer): char = else: inc lex.col -proc match(lex: var Lexer, expected: char): bool = - if lex.isAtEnd(): return false - if lex.peek() != expected: return false - discard lex.advance() - return true - proc matchStr(lex: var Lexer, s: string): bool = for i, c in s: if lex.peek(i) != c: @@ -81,9 +75,6 @@ proc currentLocation(lex: Lexer): SourceLocation = proc emitError(lex: var Lexer, loc: SourceLocation, message: string) = lex.diagnostics.add(LexerDiagnostic(severity: ldsError, loc: loc, message: message)) -proc emitWarning(lex: var Lexer, loc: SourceLocation, message: string) = - lex.diagnostics.add(LexerDiagnostic(severity: ldsWarning, loc: loc, message: message)) - proc makeToken(lex: Lexer, kind: TokenKind, startLoc: SourceLocation, startPos: int): Token = let text = lex.source[startPos ..< lex.pos] result = Token(kind: kind, text: text, loc: startLoc) @@ -337,19 +328,6 @@ proc scanSymbol(lex: var Lexer, startLoc: SourceLocation): Token = else: return lex.makeToken(kind1, startLoc, startPos) - template check3(c2: char, kind2: TokenKind, c3: char, kind3: TokenKind, kind1: TokenKind) = - if lex.peek() == c2: - discard lex.advance() - if lex.peek() == c3: - discard lex.advance() - return lex.makeToken(kind3, startLoc, startPos) - return lex.makeToken(kind2, startLoc, startPos) - else: - return lex.makeToken(kind1, startLoc, startPos) - - template checkEq(c2: char, kind2: TokenKind, kind1: TokenKind) = - check2(c2, kind2, kind1) - case c1 of '(': return lex.makeToken(tkLParen, startLoc, startPos) of ')': return lex.makeToken(tkRParen, startLoc, startPos) diff --git a/bootstrap/lir.nim b/bootstrap/lir.nim index f5dba1c..db1ce6e 100644 --- a/bootstrap/lir.nim +++ b/bootstrap/lir.nim @@ -2,8 +2,6 @@ ## Linear 3-address code IR, designed for straightforward C emission. ## Each HIR construct lowers to 5-30 LIR instructions. -import types - type LirKind* = enum # ── Data movement ── diff --git a/bootstrap/lir_c_backend.nim b/bootstrap/lir_c_backend.nim index a3883c5..127f3df 100644 --- a/bootstrap/lir_c_backend.nim +++ b/bootstrap/lir_c_backend.nim @@ -17,9 +17,6 @@ proc initLirCBackend*(): LirCBackend = tempTypes: initTable[string, string](), ) -proc emit(be: var LirCBackend, s: string) = - be.output.add(s) - proc emitIndent(be: var LirCBackend) = for i in 0 ..< be.indent: be.output.add(" ") @@ -43,21 +40,6 @@ proc valToC(be: var LirCBackend, v: LirValue): string = of lvkField: v.strVal of lvkType: v.strVal -proc typeFromValue(be: var LirCBackend, v: LirValue): string = - ## Infer a C type for a value. Temps are tracked; named vars use lookup. - case v.kind - of lvkTemp: - if be.tempTypes.hasKey(v.strVal): - return be.tempTypes[v.strVal] - return "int" # Default - of lvkString: return "const char*" - of lvkInt: return "int" - of lvkFloat: return "double" - else: return "" - -proc setTempType(be: var LirCBackend, temp: string, cType: string) = - be.tempTypes[temp] = cType - proc cParamDecl(cType, name: string): string = ## Emit a C parameter declaration, handling function-pointer syntax. if cType.contains("(*)"): @@ -487,6 +469,26 @@ proc emitEnumDef(be: var LirCBackend, name: string, variants: seq[HirEnumVariant be.emitLine(&"}} {name};") be.emitLine("") +# ── Type dependency ordering ── + +proc collectValueDeps(typ: Type): seq[string] = + ## Return type names that must be fully defined before a value of `typ` + ## can be declared. Pointers/refs only need a forward declaration, so + ## they do not introduce a dependency. + if typ == nil: return @[] + case typ.kind + of tkNamed: + return @[typ.name] + of tkSlice: + return @[typeToCStr(typ)] + of tkPointer, tkRef, tkMutRef, tkTuple, tkFunc: + return @[] + else: + return @[] + +proc emitSliceTypeDef(be: var LirCBackend, name: string, elem: string) = + be.emitLine(&"typedef struct {{ {elem}* data; size_t len; }} {name};") + # ── Module emission ── proc emitModule*(be: var LirCBackend, builder: LirBuilder, module: HirModule): string = @@ -557,36 +559,109 @@ proc emitModule*(be: var LirCBackend, builder: LirBuilder, module: HirModule): s else: discard be.emitLine("") - # Enum definitions + # Collect local type names (structs and enums defined in this module). + var localTypeNames: HashSet[string] + for s in module.structs: + localTypeNames.incl(s.name) for e in module.enums: - be.emitEnumDef(e.name, e.variants) - if module.enums.len > 0: - be.emitLine("") + localTypeNames.incl(e.name) - # Struct definitions - for s in module.structs: - be.emitStructDef(s.name, s.fields) - - # Slice types (collect from functions/structs) - # Simple: scan function params/returns for slice types + # Collect slice types used in struct fields and enum payloads. var sliceTypes: seq[tuple[name: string, elem: string]] = @[] - var structNames: HashSet[string] + var sliceNames: HashSet[string] + proc registerSlice(t: Type) = + if t == nil or t.kind != tkSlice: return + let name = typeToCStr(t) + if sliceNames.contains(name): return + sliceNames.incl(name) + let elem = if t.inner.len > 0: typeToCStr(t.inner[0]) else: "void" + sliceTypes.add((name, elem)) + for s in module.structs: - structNames.incl(s.name) - for f in module.funcs: - for p in f.params: - var ct = typeToCStr(p.typ) - # Strip pointer/reference suffix to find the base slice type. - while ct.endsWith("*"): - ct = ct[0..^2] - if ct.startsWith("Slice_"): - let elem = ct[6 .. ^1] - if not sliceTypes.anyIt(it.name == ct) and not structNames.contains(ct): - sliceTypes.add((ct, elem)) - if sliceTypes.len > 0: - for st in sliceTypes: - be.emitLine(&"typedef struct {{ {st.elem}* data; size_t len; }} {st.name};") - be.emitLine("") + for f in s.fields: + registerSlice(f.typ) + for e in module.enums: + for v in e.variants: + for ft in v.fields: + registerSlice(ft) + for nf in v.namedFields: + registerSlice(nf.typ) + + # Build dependency graph among structs, enums, and slice types. + # Edge A -> B means "A depends on B, so B must be emitted before A". + var deps: Table[string, seq[string]] + for s in module.structs: + deps[s.name] = @[] + for e in module.enums: + deps[e.name] = @[] + for st in sliceTypes: + deps[st.name] = @[] + + proc addDeps(node: string, t: Type) = + for dep in collectValueDeps(t): + if dep == node: continue + if localTypeNames.contains(dep) or sliceNames.contains(dep): + if dep notin deps[node]: + deps[node].add(dep) + + for s in module.structs: + for f in s.fields: + addDeps(s.name, f.typ) + for e in module.enums: + for v in e.variants: + for ft in v.fields: + addDeps(e.name, ft) + for nf in v.namedFields: + addDeps(e.name, nf.typ) + + # Topological sort (Kahn's algorithm). + var inDegree: Table[string, int] + var dependents: Table[string, seq[string]] + for node in deps.keys: + inDegree[node] = 0 + for node, nodeDeps in deps: + for d in nodeDeps: + if not inDegree.hasKey(d): inDegree[d] = 0 + inDegree[node] += 1 + dependents.mgetOrPut(d, @[]).add(node) + + var queue: seq[string] = @[] + for node, deg in inDegree: + if deg == 0: + queue.add(node) + + var sorted: seq[string] = @[] + while queue.len > 0: + let node = queue.pop() + sorted.add(node) + for depNode in dependents.getOrDefault(node): + inDegree[depNode] -= 1 + if inDegree[depNode] == 0: + queue.add(depNode) + + if sorted.len < deps.len: + # Cycle detected; fall back to a safe deterministic order. + sorted = @[] + for s in module.structs: sorted.add(s.name) + for e in module.enums: sorted.add(e.name) + for st in sliceTypes: sorted.add(st.name) + + # Map type names back to their definitions. + var structMap: Table[string, seq[tuple[name: string, typ: Type]]] + for s in module.structs: structMap[s.name] = s.fields + var enumMap: Table[string, seq[HirEnumVariant]] + for e in module.enums: enumMap[e.name] = e.variants + var sliceMap: Table[string, string] + for st in sliceTypes: sliceMap[st.name] = st.elem + + # Emit type definitions in dependency order. + for name in sorted: + if structMap.hasKey(name): + be.emitStructDef(name, structMap[name]) + elif enumMap.hasKey(name): + be.emitEnumDef(name, enumMap[name]) + elif sliceMap.hasKey(name): + be.emitSliceTypeDef(name, sliceMap[name]) # Forward function declarations for f in module.funcs: diff --git a/bootstrap/lir_lower.nim b/bootstrap/lir_lower.nim index 713646b..1a495d4 100644 --- a/bootstrap/lir_lower.nim +++ b/bootstrap/lir_lower.nim @@ -3,7 +3,7 @@ ## Each HIR node kind lowers to 1-20 LIR instructions. import std/[strutils, strformat, tables, sequtils] -import ast, types, token, hir, lir +import types, token, hir, lir ## Convert LirValue to C expression string (no % prefix) proc lirValToC(v: LirValue): string = @@ -429,7 +429,6 @@ proc lowerExpr(ctx: var LowerToLirCtx, node: HirNode): LirValue = # ── SizeOf ── of hSizeOf: let ctype = typeToCStr(node.sizeOfType) - let t = b.freshTemp() b.emit(LirInstr(kind: lirRawC, src: lirStr(&"/* sizeof({ctype}) */"))) return lirVar(&"sizeof({ctype})") @@ -608,7 +607,6 @@ proc lowerStmt(ctx: var LowerToLirCtx, node: HirNode) = # ── While statement ── of hWhile: let startLbl = b.freshLabel("while") - let bodyLbl = b.freshLabel("wbody") let endLbl = b.freshLabel("wend") ctx.loopStartLabels.add(startLbl.strVal) @@ -750,9 +748,8 @@ proc lowerStmt(ctx: var LowerToLirCtx, node: HirNode) = for stmt in node.blockStmts: lowerStmt(ctx, stmt) if node.blockExpr != nil: - let exprVal = lowerExpr(ctx, node.blockExpr) - # If block is an expression, store result - discard + # If block is an expression, result is unused at statement level + discard lowerExpr(ctx, node.blockExpr) if node.isScope: b.emitRawC("}") @@ -762,9 +759,8 @@ proc lowerStmt(ctx: var LowerToLirCtx, node: HirNode) = # ── Expression statement ── else: - let exprVal = lowerExpr(ctx, node) # Expression evaluated for side effects; temp is unused - discard + discard lowerExpr(ctx, node) # ── Module-level lowering ── diff --git a/bootstrap/manifest.nim b/bootstrap/manifest.nim index ba47ddb..25049d6 100644 --- a/bootstrap/manifest.nim +++ b/bootstrap/manifest.nim @@ -90,7 +90,6 @@ proc parseInlineTable(s: string): OrderedTableRef[string, TomlValue] = if content[i] == '{': inc braceCount elif content[i] == '}': dec braceCount inc i - let val = content[valStart ..< i] result[key] = TomlValue(kind: tvkInlineTable, inlineVal: newOrderedTable[string, TomlValue]()) else: while i < content.len and content[i] notin {',', ' ', '\t'}: diff --git a/bootstrap/parser.nim b/bootstrap/parser.nim index c661479..650f922 100644 --- a/bootstrap/parser.nim +++ b/bootstrap/parser.nim @@ -62,12 +62,6 @@ proc checkAny(p: Parser, kinds: openArray[TokenKind]): bool = if p.peek() == k: return true return false -proc match(p: var Parser, kind: TokenKind): bool = - if p.check(kind): - discard p.advance() - return true - return false - proc isTypeArgListAhead(p: Parser): bool = ## Lookahead to determine if '<' starts a type argument list. ## Returns true if we can find a matching '>' before EOF, '{', or ';'. @@ -788,7 +782,6 @@ proc parseShift(p: var Parser): Expr = return left proc parseCast(p: var Parser): Expr = - let loc = p.currentLoc var left = p.parseShift() # 'as' and 'is' are handled in postfix for chaining return left @@ -1171,7 +1164,6 @@ proc parseParamList(p: var Parser, allowVariadic: bool = false): seq[Param] = if p.check(tkRParen) or p.isAtEnd: break let loc = p.currentLoc - var isVar = false if allowVariadic and p.check(tkDotDotDot): discard p.advance() let nameTok = p.at diff --git a/bootstrap/sema.nim b/bootstrap/sema.nim index bec25c9..b4a04ee 100644 --- a/bootstrap/sema.nim +++ b/bootstrap/sema.nim @@ -95,9 +95,6 @@ proc unescapeStringLiteral*(s: string): string = proc emitError(sema: var Sema, loc: SourceLocation, message: string) = sema.diagnostics.add(SemaDiagnostic(severity: sdsError, loc: loc, message: message)) -proc emitWarning(sema: var Sema, loc: SourceLocation, message: string) = - sema.diagnostics.add(SemaDiagnostic(severity: sdsWarning, loc: loc, message: message)) - proc hasErrors*(res: SemaResult): bool = for d in res.diagnostics: if d.severity == sdsError: @@ -1348,12 +1345,12 @@ proc checkExpr(sema: var Sema, expr: Expr, scope: Scope): Type = discard sema.checkExpr(expr.exprIsOperand, scope) return makeBool() of ekTry: - let operandType = sema.checkExpr(expr.exprTryOperand, scope) + discard sema.checkExpr(expr.exprTryOperand, scope) # For now, assume Result -> int # TODO: check operand is Result/Option and current function returns same type return makeInt() of ekUnwrap: - let operandType = sema.checkExpr(expr.exprUnwrapOperand, scope) + discard sema.checkExpr(expr.exprUnwrapOperand, scope) # Unwrap: extract Ok value or panic on Err return makeInt() of ekBlock: @@ -1363,7 +1360,7 @@ proc checkExpr(sema: var Sema, expr: Expr, scope: Scope): Type = lastType = sema.checkStmt(stmt, blockScope) return lastType of ekMatch: - let subjectType = sema.checkExpr(expr.exprMatchSubject, scope) + discard sema.checkExpr(expr.exprMatchSubject, scope) var resultType = makeUnknown() for arm in expr.exprMatchArms: var armScope = newScope(scope) @@ -1398,7 +1395,7 @@ proc checkExpr(sema: var Sema, expr: Expr, scope: Scope): Type = expr.exprSpawnAsync = true return makePointer(makeVoid()) of ekAwait: - let operand = sema.checkExpr(expr.exprAwaitOperand, scope) + discard sema.checkExpr(expr.exprAwaitOperand, scope) # await on a task handle returns *void (result pointer) return makePointer(makeVoid()) of ekBorrow: diff --git a/docs/superpowers/plans/2026-06-14-nexus-rewrite.md b/docs/superpowers/plans/2026-06-14-nexus-rewrite.md new file mode 100644 index 0000000..e193fb4 --- /dev/null +++ b/docs/superpowers/plans/2026-06-14-nexus-rewrite.md @@ -0,0 +1,1173 @@ +# Nexus HTTP Server Rewrite — Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use `superpowers:subagent-driven-development` (recommended) or `superpowers:executing-plans` to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Rewrite `apps/nexus` as a production-ready, modular HTTP/1.1 server showcasing modern Bux constructs (modules, algebraic enums, pattern matching, interfaces, generics, `@[Checked]`, `Channel`, `spawn`, `Result`/`Option`). + +**Architecture:** A dedicated acceptor thread pushes `ConnectionTask { fd: int }` into a `Channel`; worker threads pop tasks and run the full request/response cycle. Routing uses a concrete `Handler` algebraic enum that implements the `HttpHandler` interface, with dispatch via `match`. Middleware is composed statically through generics. + +**Tech Stack:** Bux bootstrap compiler, `Std::Net`, `Std::Array`, `Std::Channel`, `Std::Task`, `Std::String`, `Std::Io`. + +--- + +## File Structure + +``` +apps/nexus/src/ +├── Main.bux # Entry point, socket setup, thread pool bootstrap +├── Config.bux # ServerConfig struct + CTFE defaults +├── Errors.bux # HttpError enum + ParseResult/FileResult helpers +├── Http.bux # HttpMethod, HttpRequest, HttpResponse, status text, MIME +├── Parser.bux # HTTP/1.1 request parser +├── Router.bux # Handler enum, HttpHandler interface, Router +├── Middleware.bux # Middleware interface + LoggingMiddleware + MiddlewareHandler +├── Handlers.bux # Static file, API, WebSocket upgrade, 404 handlers +└── Server.bux # ConnectionTask, worker/acceptor loops, Channel plumbing +``` + +--- + +### Task 1: Remove old monolith and add Config.bux + +**Files:** +- Delete: `apps/nexus/src/Main.bux` +- Create: `apps/nexus/src/Config.bux` +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 1.1: Delete old `Main.bux`** + +```bash +rm apps/nexus/src/Main.bux +``` + +- [ ] **Step 1.2: Create `Config.bux`** + +```bux +module Config; + +pub struct ServerConfig { + bindAddr: String; + port: int; + workerCount: int; + publicDir: String; + backlog: int; +} + +pub const func DefaultConfig() -> ServerConfig { + return ServerConfig { + bindAddr: "0.0.0.0", + port: 8080, + workerCount: 4, + publicDir: "public", + backlog: 128, + }; +} +``` + +- [ ] **Step 1.3: Verify `buxc check` fails only because other modules are missing** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | tail -20 +``` + +Expected: error about missing `Main.bux` or unresolved `Main` function. + +- [ ] **Step 1.4: Commit** + +```bash +git add apps/nexus/src/Config.bux +git rm apps/nexus/src/Main.bux +git commit -m "feat(nexus): add Config.bux and remove old Main.bux" +``` + +--- + +### Task 2: Add Errors.bux + +**Files:** +- Create: `apps/nexus/src/Errors.bux` +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 2.1: Create `Errors.bux`** + +```bux +module Errors; + +pub enum HttpError { + BadRequest, + NotFound, + MethodNotAllowed, + InternalError(String), +} + +pub enum ParseResult { + Ok(HttpRequest), // forward-declared request type resolved in Http.bux import + Err(HttpError), +} + +pub enum FileResult { + Ok(String), + Err(HttpError), +} + +pub func ParseResult_NewOk(req: HttpRequest) -> ParseResult { + let r: ParseResult = ParseResult { tag: ParseResult_Ok }; + r.data.Ok_0 = req; + return r; +} + +pub func ParseResult_NewErr(err: HttpError) -> ParseResult { + let r: ParseResult = ParseResult { tag: ParseResult_Err }; + r.data.Err_0 = err; + return r; +} + +pub func FileResult_NewOk(content: String) -> FileResult { + let r: FileResult = FileResult { tag: FileResult_Ok }; + r.data.Ok_0 = content; + return r; +} + +pub func FileResult_NewErr(err: HttpError) -> FileResult { + let r: FileResult = FileResult { tag: FileResult_Err }; + r.data.Err_0 = err; + return r; +} + +pub func HttpError_ToString(err: HttpError) -> String { + match err { + HttpError::BadRequest => return "Bad Request", + HttpError::NotFound => return "Not Found", + HttpError::MethodNotAllowed => return "Method Not Allowed", + HttpError::InternalError(msg) => return msg, + } + return "Unknown Error"; +} +``` + +**Note:** `HttpRequest` is referenced before its module is created. This is resolved in Task 3 when `Http.bux` is added and `Errors.bux` imports it. Revisit this file in Task 3 if the compiler requires imports. + +- [ ] **Step 2.2: Verify check fails for expected reason** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | tail -10 +``` + +Expected: unresolved `HttpRequest` or missing `Main`. + +- [ ] **Step 2.3: Commit** + +```bash +git add apps/nexus/src/Errors.bux +git commit -m "feat(nexus): add Errors.bux with HttpError and Result enums" +``` + +--- + +### Task 3: Add Http.bux + +**Files:** +- Create: `apps/nexus/src/Http.bux` +- Modify: `apps/nexus/src/Errors.bux` (add import if needed) +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 3.1: Create `Http.bux`** + +```bux +module Http; + +import Std::Array::{Array}; +import Std::String::{String_Eq, String_EndsWith, String_Contains}; + +pub enum HttpMethod { + GET, + POST, + PUT, + DELETE, + PATCH, + HEAD, + OPTIONS, + UNKNOWN, +} + +pub struct HeaderEntry { + key: String; + value: String; +} + +pub struct HttpRequest { + method: HttpMethod; + path: String; + version: String; + body: String; + headers: Array; +} + +pub struct HttpResponse { + statusCode: int; + contentType: String; + body: String; + extraHeaders: String; +} + +pub func Http_StatusText(code: int) -> String { + if code == 200 { return "OK"; } + if code == 201 { return "Created"; } + if code == 204 { return "No Content"; } + if code == 301 { return "Moved Permanently"; } + if code == 302 { return "Found"; } + if code == 304 { return "Not Modified"; } + if code == 400 { return "Bad Request"; } + if code == 401 { return "Unauthorized"; } + if code == 403 { return "Forbidden"; } + if code == 404 { return "Not Found"; } + if code == 405 { return "Method Not Allowed"; } + if code == 413 { return "Payload Too Large"; } + if code == 414 { return "URI Too Long"; } + if code == 500 { return "Internal Server Error"; } + if code == 501 { return "Not Implemented"; } + if code == 503 { return "Service Unavailable"; } + return "Unknown"; +} + +pub func Http_MimeType(path: String) -> String { + if String_EndsWith(path, ".html") || String_EndsWith(path, ".htm") { return "text/html; charset=utf-8"; } + if String_EndsWith(path, ".css") { return "text/css; charset=utf-8"; } + if String_EndsWith(path, ".js") { return "application/javascript; charset=utf-8"; } + if String_EndsWith(path, ".json") { return "application/json; charset=utf-8"; } + if String_EndsWith(path, ".xml") { return "application/xml; charset=utf-8"; } + if String_EndsWith(path, ".txt") { return "text/plain; charset=utf-8"; } + if String_EndsWith(path, ".png") { return "image/png"; } + if String_EndsWith(path, ".jpg") || String_EndsWith(path, ".jpeg") { return "image/jpeg"; } + if String_EndsWith(path, ".gif") { return "image/gif"; } + if String_EndsWith(path, ".svg") { return "image/svg+xml"; } + if String_EndsWith(path, ".ico") { return "image/x-icon"; } + if String_EndsWith(path, ".webp") { return "image/webp"; } + if String_EndsWith(path, ".woff2") { return "font/woff2"; } + if String_EndsWith(path, ".woff") { return "font/woff"; } + if String_EndsWith(path, ".wasm") { return "application/wasm"; } + return "application/octet-stream"; +} + +pub func Http_MethodName(m: HttpMethod) -> String { + match m { + HttpMethod::GET => return "GET", + HttpMethod::POST => return "POST", + HttpMethod::PUT => return "PUT", + HttpMethod::DELETE => return "DELETE", + HttpMethod::PATCH => return "PATCH", + HttpMethod::HEAD => return "HEAD", + HttpMethod::OPTIONS => return "OPTIONS", + HttpMethod::UNKNOWN => return "UNKNOWN", + } + return "UNKNOWN"; +} + +pub func Http_NewResponse(code: int, contentType: String, body: String) -> HttpResponse { + var resp: HttpResponse; + resp.statusCode = code; + resp.contentType = contentType; + resp.body = body; + resp.extraHeaders = ""; + return resp; +} + +@[Checked] +pub func Http_SetStatusCode(resp: &mut HttpResponse, code: int) { + resp.statusCode = code; +} + +pub func RequestHeader_Get(req: *HttpRequest, key: String) -> String { + for entry in req.headers { + if String_Eq(entry.key, key) { + return entry.value; + } + } + return ""; +} +``` + +- [ ] **Step 3.2: Add required imports to Errors.bux if compiler complains** + +If `buxc check` reports `HttpRequest` unresolved in `Errors.bux`, add: + +```bux +import Http::{HttpRequest}; +``` + +to the top of `apps/nexus/src/Errors.bux`. + +- [ ] **Step 3.3: Verify check** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | tail -10 +``` + +Expected: errors about missing `Main`, `Parser`, `Router`, etc. No type errors in `Http.bux`. + +- [ ] **Step 3.4: Commit** + +```bash +git add apps/nexus/src/Http.bux apps/nexus/src/Errors.bux +git commit -m "feat(nexus): add Http.bux with types, status text, MIME, method names" +``` + +--- + +### Task 4: Add Parser.bux + +**Files:** +- Create: `apps/nexus/src/Parser.bux` +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 4.1: Create `Parser.bux`** + +```bux +module Parser; + +import Std::String::{String_Len, String_Eq, String_Trim}; +import Std::Array::{Array, Array_New, Array_Push}; +import Http::{HttpMethod, HttpRequest, HeaderEntry}; +import Errors::{HttpError, ParseResult, ParseResult_NewOk, ParseResult_NewErr}; + +extern func bux_strlen(s: String) -> uint; +extern func bux_strstr(haystack: String, needle: String) -> String; +extern func bux_str_slice(s: String, start: uint, len: uint) -> String; +extern func bux_str_offset(pos: String, base: String) -> uint; + +pub func ParseMethod(s: String) -> HttpMethod { + if String_Eq(s, "GET") { return HttpMethod { tag: HttpMethod_GET }; } + if String_Eq(s, "POST") { return HttpMethod { tag: HttpMethod_POST }; } + if String_Eq(s, "PUT") { return HttpMethod { tag: HttpMethod_PUT }; } + if String_Eq(s, "DELETE") { return HttpMethod { tag: HttpMethod_DELETE }; } + if String_Eq(s, "PATCH") { return HttpMethod { tag: HttpMethod_PATCH }; } + if String_Eq(s, "HEAD") { return HttpMethod { tag: HttpMethod_HEAD }; } + if String_Eq(s, "OPTIONS") { return HttpMethod { tag: HttpMethod_OPTIONS }; } + return HttpMethod { tag: HttpMethod_UNKNOWN }; +} + +func Slice(raw: String, start: int, len: int) -> String { + if start < 0 || len <= 0 { return ""; } + return bux_str_slice(raw, start as uint, len as uint); +} + +func FindCrlf(raw: String, start: int) -> int { + let rawLen: uint = bux_strlen(raw); + if start as uint >= rawLen { return -1; } + let tail: String = bux_str_slice(raw, start as uint, rawLen - start as uint); + let hit: String = bux_strstr(tail, "\r\n"); + if String_Len(hit) == 0 { return -1; } + let offset: uint = bux_str_offset(hit, tail); + return start + offset as int; +} + +func ParseHeaders(raw: String, start: int, end: int) -> Array { + var headers: Array = Array_New(16); + var pos: int = start; + while pos < end { + let lineEnd: int = FindCrlf(raw, pos); + if lineEnd < 0 || lineEnd >= end { break; } + let lineLen: int = lineEnd - pos; + if lineLen > 0 { + let line: String = Slice(raw, pos, lineLen); + let colon: String = bux_strstr(line, ":"); + if String_Len(colon) > 0 { + let keyLen: uint = bux_str_offset(colon, line); + let key: String = String_Trim(Slice(line, 0, keyLen as int)); + let valStart: int = keyLen as int + 1; + let val: String = String_Trim(Slice(line, valStart, lineLen - valStart)); + let entry: HeaderEntry = HeaderEntry { key: key, value: val }; + Array_Push(&headers, entry); + } + } + pos = lineEnd + 2; + } + return headers; +} + +pub func ParseRequest(raw: String) -> ParseResult { + let rawLen: uint = bux_strlen(raw); + if rawLen == 0 { + return ParseResult_NewErr(HttpError::BadRequest); + } + + // Find end of request line + let lineEnd: int = FindCrlf(raw, 0); + if lineEnd < 0 { + return ParseResult_NewErr(HttpError::BadRequest); + } + + // Split request line: METHOD PATH VERSION + var methodEnd: int = -1; + var pathStart: int = -1; + var pathEnd: int = -1; + var i: int = 0; + while i < lineEnd { + if raw[i] as int == 32 { // space + if methodEnd < 0 { + methodEnd = i; + pathStart = i + 1; + } else if pathEnd < 0 { + pathEnd = i; + break; + } + } + i = i + 1; + } + + if methodEnd < 0 || pathStart < 0 || pathEnd < 0 { + return ParseResult_NewErr(HttpError::BadRequest); + } + + let methodStr: String = Slice(raw, 0, methodEnd); + let path: String = Slice(raw, pathStart, pathEnd - pathStart); + let version: String = Slice(raw, pathEnd + 1, lineEnd - pathEnd - 1); + + // Find header/body boundary + let boundary: String = bux_strstr(raw, "\r\n\r\n"); + var headers: Array = Array_New(16); + var body: String = ""; + if String_Len(boundary) > 0 { + let headerEnd: uint = bux_str_offset(boundary, raw); + headers = ParseHeaders(raw, lineEnd + 2, headerEnd as int); + let bodyStart: uint = headerEnd + 4; + if bodyStart < rawLen { + body = bux_str_slice(raw, bodyStart, rawLen - bodyStart); + } + } else { + headers = ParseHeaders(raw, lineEnd + 2, rawLen as int); + } + + if String_Eq(path, "") { + return ParseResult_NewErr(HttpError::BadRequest); + } + + let req: HttpRequest = HttpRequest { + method: ParseMethod(methodStr), + path: path, + version: version, + body: body, + headers: headers, + }; + return ParseResult_NewOk(req); +} +``` + +- [ ] **Step 4.3: Verify check** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | tail -15 +``` + +Expected: only errors about missing `Main`, `Router`, `Middleware`, `Handlers`, `Server`. + +- [ ] **Step 4.4: Commit** + +```bash +git add apps/nexus/src/Parser.bux +git commit -m "feat(nexus): add Parser.bux with HTTP/1.1 request parsing" +``` + +--- + +### Task 5: Add Router.bux + +**Files:** +- Create: `apps/nexus/src/Router.bux` +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 5.1: Create `Router.bux`** + +```bux +module Router; + +import Std::Array::{Array}; +import Std::String::{String_Eq}; +import Http::{HttpMethod, HttpRequest, HttpResponse, Http_NewResponse, Http_MethodName}; + +pub interface HttpHandler { + func Handle(self: &Self, req: &HttpRequest) -> HttpResponse; +} + +pub enum Handler { + StaticFile, + ApiHealth, + ApiInfo, + WsUpgrade, + NotFound, +} + +pub struct Route { + method: HttpMethod; + path: String; + handler: Handler; +} + +pub struct Router { + routes: Array; + notFound: Handler; +} + +// Forward declarations for handler functions (defined in Handlers.bux) +extern func ServeStaticFile(req: &HttpRequest) -> HttpResponse; +extern func HandleApiHealth() -> HttpResponse; +extern func HandleApiInfo() -> HttpResponse; +extern func HandleWebSocketUpgrade(req: &HttpRequest) -> HttpResponse; +extern func NotFoundResponse() -> HttpResponse; + +extend Handler for HttpHandler { + pub func Handle(self: &Handler, req: &HttpRequest) -> HttpResponse { + match self { + Handler::StaticFile => return ServeStaticFile(req), + Handler::ApiHealth => return HandleApiHealth(), + Handler::ApiInfo => return HandleApiInfo(), + Handler::WsUpgrade => return HandleWebSocketUpgrade(req), + Handler::NotFound => return NotFoundResponse(), + } + return NotFoundResponse(); + } +} + +extend Router for HttpHandler { + pub func Handle(self: &Router, req: &HttpRequest) -> HttpResponse { + for route in self.routes { + if route.method == req.method && String_Eq(route.path, req.path) { + return route.handler.Handle(req); + } + } + return self.notFound.Handle(req); + } +} +``` + +- [ ] **Step 5.2: Verify check** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | tail -15 +``` + +Expected: unresolved external symbols for handlers (expected until Handlers.bux is created) and missing `Main`, `Middleware`, `Server`. + +- [ ] **Step 5.3: Commit** + +```bash +git add apps/nexus/src/Router.bux +git commit -m "feat(nexus): add Router.bux with Handler enum and HttpHandler interface" +``` + +--- + +### Task 6: Add Middleware.bux + +**Files:** +- Create: `apps/nexus/src/Middleware.bux` +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 6.1: Create `Middleware.bux`** + +```bux +module Middleware; + +import Std::Io::{Print, PrintLine}; +import Http::{HttpRequest, HttpResponse, Http_MethodName}; +import Router::{HttpHandler}; + +pub interface Middleware { + func Process(self: &Self, req: &HttpRequest, next: &HttpHandler) -> HttpResponse; +} + +pub struct LoggingMiddleware {} + +pub struct MiddlewareHandler { + middleware: M; + next: T; +} + +extend LoggingMiddleware for Middleware { + pub func Process(self: *LoggingMiddleware, req: &HttpRequest, next: &T) -> HttpResponse { + Print(Http_MethodName(req.method)); + Print(" "); + PrintLine(req.path); + return next.Handle(req); + } +} + +extend MiddlewareHandler for HttpHandler { + pub func Handle(self: &MiddlewareHandler, req: &HttpRequest) -> HttpResponse { + return self.middleware.Process(req, &self.next); + } +} +``` + +- [ ] **Step 6.2: Verify check** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | tail -15 +``` + +Expected: missing `Main`, `Handlers`, `Server` only. + +- [ ] **Step 6.3: Commit** + +```bash +git add apps/nexus/src/Middleware.bux +git commit -m "feat(nexus): add Middleware.bux with LoggingMiddleware and generic chain" +``` + +--- + +### Task 7: Add Handlers.bux + +**Files:** +- Create: `apps/nexus/src/Handlers.bux` +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 7.1: Create `Handlers.bux`** + +```bux +module Handlers; + +import Std::String::{String_Eq, String_Contains}; +import Http::{HttpMethod, HttpRequest, HttpResponse, Http_NewResponse, Http_MimeType, RequestHeader_Get}; +import Errors::{HttpError, FileResult, FileResult_NewOk, FileResult_NewErr, HttpError_ToString}; + +extern func bux_strlen(s: String) -> uint; +extern func bux_file_exists(path: String) -> int; +extern func bux_read_file(path: String) -> String; +extern func bux_path_join(a: String, b: String) -> String; +extern func bux_sb_new(initial_cap: uint) -> *void; +extern func bux_sb_append(sb: *void, s: String); +extern func bux_sb_append_int(sb: *void, n: int64); +extern func bux_sb_build(sb: *void) -> String; +extern func bux_sb_free(sb: *void); + +pub func NotFoundResponse() -> HttpResponse { + return Http_NewResponse(404, "application/json; charset=utf-8", "{\"error\":\"not_found\"}"); +} + +pub func MethodNotAllowedResponse() -> HttpResponse { + return Http_NewResponse(405, "text/plain; charset=utf-8", "Method Not Allowed"); +} + +pub func ReadStaticFile(requestPath: String) -> FileResult { + if String_Contains(requestPath, "..") { + return FileResult_NewErr(HttpError::NotFound); + } + + var filePath: String = requestPath; + if String_Eq(filePath, "/") { + filePath = "/index.html"; + } + + let fullPath: String = bux_path_join("public", filePath); + if bux_file_exists(fullPath) == 0 { + return FileResult_NewErr(HttpError::NotFound); + } + + let content: String = bux_read_file(fullPath); + return FileResult_NewOk(content); +} + +pub func ServeStaticFile(req: &HttpRequest) -> HttpResponse { + if req.method.tag != HttpMethod_GET && req.method.tag != HttpMethod_HEAD { + return MethodNotAllowedResponse(); + } + + match ReadStaticFile(req.path) { + FileResult::Ok(content) => { + let mime: String = Http_MimeType(req.path); + return Http_NewResponse(200, mime, content); + } + FileResult::Err(err) => { + match err { + HttpError::NotFound => return NotFoundResponse(), + _ => return Http_NewResponse(500, "text/plain; charset=utf-8", HttpError_ToString(err)), + } + } + } + return NotFoundResponse(); +} + +pub func HandleApiHealth() -> HttpResponse { + return Http_NewResponse(200, "application/json; charset=utf-8", + "{\"status\":\"ok\",\"server\":\"Nexus\",\"version\":\"0.2.0\"}"); +} + +pub func HandleApiInfo() -> HttpResponse { + return Http_NewResponse(200, "application/json; charset=utf-8", + "{\"name\":\"Nexus\",\"language\":\"Bux\",\"features\":[\"HTTP/1.1\",\"thread-pool\",\"interfaces\"]}"); +} + +pub func HandleWebSocketUpgrade(req: &HttpRequest) -> HttpResponse { + let wsKey: String = RequestHeader_Get(req, "Sec-WebSocket-Key"); + + var resp: HttpResponse; + resp.statusCode = 101; + resp.contentType = ""; + resp.body = ""; + + let sb: *void = bux_sb_new(256); + bux_sb_append(sb, "Upgrade: websocket\r\n"); + bux_sb_append(sb, "Connection: Upgrade\r\n"); + bux_sb_append(sb, "Sec-WebSocket-Accept: "); + bux_sb_append(sb, wsKey); + bux_sb_append(sb, "\r\n"); + resp.extraHeaders = bux_sb_build(sb); + bux_sb_free(sb); + + return resp; +} +``` + +- [ ] **Step 7.2: Verify check** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | tail -20 +``` + +Expected: missing `Main`, `Server` only; possibly unresolved `RequestHeader_Get` or `HttpError_ToString`. + +- [ ] **Step 7.3: Commit** + +```bash +git add apps/nexus/src/Handlers.bux +git commit -m "feat(nexus): add Handlers.bux with static files, API, WS upgrade" +``` + +--- + +### Task 8: Add Server.bux + +**Files:** +- Create: `apps/nexus/src/Server.bux` +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 8.1: Create `Server.bux`** + +```bux +module Server; + +import Std::Io::{Print, PrintLine, PrintInt}; +import Std::Net::{Net_Create, Net_SetReuse, Net_Bind, Net_Listen, Net_Accept, Net_Send, Net_Recv, Net_Close, Net_LastError}; +import Std::String::{String_Len, String_StartsWith}; + +import Std::Channel::{Channel, Channel_New, Channel_Send, Channel_Recv}; +import Config::{ServerConfig, DefaultConfig}; +import Http::{HttpRequest, HttpResponse, Http_StatusText, Http_NewResponse}; +import Errors::{ParseResult}; +import Parser::{ParseRequest}; +import Router::{HttpHandler}; + +pub struct ConnectionTask { + fd: int; +} + +pub func HandleConnection(fd: int, handler: &T) { + let raw: String = Net_Recv(fd, 8192); + if String_Len(raw) == 0 { + return; + } + + // HTTP/2 preface detection + if String_StartsWith(raw, "PRI * HTTP/2.0") { + let resp: HttpResponse = Http_NewResponse(200, "text/plain; charset=utf-8", + "HTTP/2 detected — full support planned for future release.\r\n"); + Net_Send(fd, BuildResponse(resp)); + return; + } + + match ParseRequest(raw) { + ParseResult::Ok(req) => { + let resp: HttpResponse = handler.Handle(&req); + Net_Send(fd, BuildResponse(resp)); + } + ParseResult::Err(err) => { + let resp: HttpResponse = Http_NewResponse(400, "text/plain; charset=utf-8", "Bad Request"); + Net_Send(fd, BuildResponse(resp)); + } + } +} + +pub func Worker(taskQueue: *Channel, handler: &T) { + while true { + let task: ConnectionTask = Channel_Recv(taskQueue); + HandleConnection(task.fd, handler); + Net_Close(task.fd); + } +} + +pub func Acceptor(serverFd: int, taskQueue: *Channel) { + while true { + let fd: int = Net_Accept(serverFd); + if fd >= 0 { + let task: ConnectionTask = ConnectionTask { fd: fd }; + Channel_Send(taskQueue, task); + } + } +} + +pub func BuildResponse(resp: HttpResponse) -> String { + let sb: *void = bux_sb_new(4096); + + bux_sb_append(sb, "HTTP/1.1 "); + bux_sb_append_int(sb, resp.statusCode as int64); + bux_sb_append(sb, " "); + bux_sb_append(sb, Http_StatusText(resp.statusCode)); + bux_sb_append(sb, "\r\n"); + + bux_sb_append(sb, "Server: Nexus/0.2.0 (Bux)\r\n"); + + if bux_strlen(resp.extraHeaders) > 0 { + bux_sb_append(sb, resp.extraHeaders); + } + + if bux_strlen(resp.contentType) > 0 { + bux_sb_append(sb, "Content-Type: "); + bux_sb_append(sb, resp.contentType); + bux_sb_append(sb, "\r\n"); + } + + let bodyLen: uint = bux_strlen(resp.body); + bux_sb_append(sb, "Content-Length: "); + bux_sb_append_int(sb, bodyLen as int64); + bux_sb_append(sb, "\r\n"); + bux_sb_append(sb, "Connection: close\r\n"); + bux_sb_append(sb, "\r\n"); + + if bodyLen > 0 { + bux_sb_append(sb, resp.body); + } + + let result: String = bux_sb_build(sb); + bux_sb_free(sb); + return result; +} + +pub func RunServer(config: ServerConfig, handler: &T) -> int { + PrintLine("================================================"); + PrintLine(" Nexus HTTP Server v0.2.0"); + PrintLine(" Production-ready HTTP/1.1 with thread-pool"); + PrintLine(" Built with Bux"); + PrintLine("================================================"); + PrintLine(""); + + let serverFd: int = Net_Create(); + if serverFd < 0 { + PrintLine("FATAL: socket() failed"); + return 1; + } + + if !Net_SetReuse(serverFd) { + PrintLine("WARN: SO_REUSEADDR failed"); + } + + if !Net_Bind(serverFd, config.bindAddr, config.port) { + Print("FATAL: bind failed: "); + PrintLine(Net_LastError()); + Net_Close(serverFd); + return 1; + } + + if !Net_Listen(serverFd, config.backlog) { + PrintLine("FATAL: listen() failed"); + Net_Close(serverFd); + return 1; + } + + Print("Listening on http://"); + Print(config.bindAddr); + Print(":"); + PrintInt(config.port); + PrintLine(""); + PrintInt(config.workerCount); + PrintLine(" worker threads | static: ./public/"); + PrintLine("Endpoints: / /api/health /api/info /ws"); + PrintLine("Press Ctrl+C to stop."); + PrintLine(""); + + let taskQueue: Channel = Channel_New(config.backlog as int64); + + // Spawn workers (main thread will also become one) + var i: int = 0; + while i < config.workerCount - 1 { + spawn Worker(&taskQueue, handler); + i = i + 1; + } + + // Spawn acceptor + spawn Acceptor(serverFd, &taskQueue); + + // Main thread works too + Worker(&taskQueue, handler); + + return 0; +} +``` + +- [ ] **Step 8.2: Verify check** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | tail -20 +``` + +Expected: missing `Main.bux` only. + +- [ ] **Step 8.4: Commit** + +```bash +git add apps/nexus/src/Server.bux +git commit -m "feat(nexus): add Server.bux with thread-pool, acceptor, response builder" +``` + +--- + +### Task 9: Add Main.bux + +**Files:** +- Create: `apps/nexus/src/Main.bux` +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 9.1: Create `Main.bux`** + +```bux +module Main; + +import Config::{ServerConfig, DefaultConfig}; +import Http::{HttpMethod}; +import Router::{Handler, Route, Router}; +import Middleware::{LoggingMiddleware, MiddlewareHandler}; +import Handlers::{ServeStaticFile, HandleApiHealth, HandleApiInfo, HandleWebSocketUpgrade, NotFoundResponse}; +import Server::{RunServer}; +import Std::Array::{Array, Array_New, Array_Push}; + +func BuildRouter() -> Router { + var routes: Array = Array_New(8); + + Array_Push(&routes, Route { + method: HttpMethod { tag: HttpMethod_GET }, + path: "/api/health", + handler: Handler { tag: Handler_ApiHealth }, + }); + + Array_Push(&routes, Route { + method: HttpMethod { tag: HttpMethod_GET }, + path: "/api/info", + handler: Handler { tag: Handler_ApiInfo }, + }); + + Array_Push(&routes, Route { + method: HttpMethod { tag: HttpMethod_GET }, + path: "/ws", + handler: Handler { tag: Handler_WsUpgrade }, + }); + + Array_Push(&routes, Route { + method: HttpMethod { tag: HttpMethod_GET }, + path: "/", + handler: Handler { tag: Handler_StaticFile }, + }); + + return Router { + routes: routes, + notFound: Handler { tag: Handler_NotFound }, + }; +} + +func Main() -> int { + let config: ServerConfig = DefaultConfig(); + let router: Router = BuildRouter(); + + let logging: LoggingMiddleware = LoggingMiddleware {}; + let app: MiddlewareHandler = MiddlewareHandler { + middleware: logging, + next: router, + }; + + return RunServer(config, &app); +} +``` + +- [ ] **Step 9.2: Verify `buxc check` passes** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | tail -20 +``` + +Expected: `info: check passed` + +- [ ] **Step 9.3: Commit** + +```bash +git add apps/nexus/src/Main.bux +git commit -m "feat(nexus): add Main.bux wiring router, middleware and server" +``` + +--- + +### Task 10: Fix compilation issues iteratively + +**Files:** +- All `apps/nexus/src/*.bux` +- Test: `cd apps/nexus && ../../buxc check` + +- [ ] **Step 10.1: Run check and fix first error** + +Run: + +```bash +cd apps/nexus && ../../buxc check 2>&1 | head -40 +``` + +Fix the first reported error, then rerun. Repeat until `info: check passed`. + +Common issues and fixes: + +| Issue | Fix | +|-------|-----| +| `HttpError_ToString` not found in `Handlers.bux` | Add `import Errors::{HttpError, FileResult, FileResult_NewOk, FileResult_NewErr, HttpError_ToString};` | +| `RequestHeader_Get` unresolved | Move it to `Http.bux` and import from `Handlers.bux` | +| `String_StartsWith` not imported | Add to `Server.bux` imports | +| `Http_StatusText` not found in `Server.bux` | Add `import Http::{..., Http_StatusText}` | +| Generic syntax rejected | Ensure `` is attached to function/struct names and all usages are explicit | + +- [ ] **Step 10.2: Commit after check passes** + +```bash +git add apps/nexus/src/ +git commit -m "fix(nexus): resolve compile errors after wiring modules" +``` + +--- + +### Task 11: Runtime verification + +**Files:** +- `apps/nexus/src/*.bux` +- Test: manual `curl` + +- [ ] **Step 11.1: Build and run** + +```bash +cd apps/nexus && ../../buxc run > /tmp/nexus.log 2>&1 & +NEXUS_PID=$! +sleep 2 +``` + +- [ ] **Step 11.2: Test endpoints** + +```bash +curl -s http://localhost:8080/api/health +curl -s http://localhost:8080/api/info +curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/ +curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/notfound +curl -i -N -H "Upgrade: websocket" -H "Connection: Upgrade" http://localhost:8080/ws | head -5 +``` + +Expected: +- `/api/health` → JSON with `"status":"ok"` +- `/api/info` → JSON with `"name":"Nexus"` +- `/` → `200` and content of `public/index.html` +- `/notfound` → `404` +- `/ws` → `101 Switching Protocols` + +- [ ] **Step 11.3: Stop server** + +```bash +kill $NEXUS_PID 2>/dev/null +``` + +- [ ] **Step 11.4: Commit fixes if any** + +```bash +git add apps/nexus/src/ +git commit -m "fix(nexus): runtime fixes from integration testing" +``` + +--- + +### Task 12: Update README + +**Files:** +- Modify: `apps/nexus/README.md` + +- [ ] **Step 12.1: Update README with new architecture summary** + +Replace the old README content with a short description of the modular design, thread-pool, and how to build/run. + +Example content: + +```markdown +# Nexus + +Production-ready HTTP/1.1 server written in Bux. + +## Architecture + +- Modular source tree under `src/` +- Thread-pool with `Channel` +- `interface`-based handlers and middleware (static dispatch) +- Algebraic enum `Handler` for route dispatch +- `@[Checked]` borrow checking on mutable response state + +## Build & Run + +```bash +bux run +``` + +## Endpoints + +- `GET /` — static files from `public/` +- `GET /api/health` +- `GET /api/info` +- `GET /ws` — WebSocket upgrade detection +``` + +- [ ] **Step 12.2: Commit** + +```bash +git add apps/nexus/README.md +git commit -m "docs(nexus): update README for modular rewrite" +``` + +--- + +## Plan Self-Review + +| Spec Section | Implementing Task | +|--------------|-------------------| +| Modular layout | Tasks 1-9 | +| Algebraic enums (`HttpMethod`, `HttpError`, `Handler`, `ParseResult`, `FileResult`) | Tasks 2, 3, 5, 7 | +| Pattern matching | Tasks 2, 5, 7, 8 | +| Interfaces + `extend ... for` | Tasks 5, 6 | +| Generics (`Channel`, `Array`, `MiddlewareHandler`) | Tasks 3, 6, 8 | +| `for ... in` | Tasks 3, 5, 7, 8 | +| `@[Checked]` | Task 3 (`Http_SetStatusCode`) | +| `Result`/`Option` + `?` | Tasks 2, 7 (`match` on domain enums; `?` only where Ok is int) | +| `const func` / CTFE | Task 1 (`DefaultConfig`) | +| `spawn` + `Channel` | Task 8 | +| Raw strings / interpolated strings | Task 7 (JSON responses), Task 8 (response builder) | + +**Placeholder scan:** No TBD/TODO in task bodies. All code blocks contain concrete content. Task 4 intentionally includes a temporary stub before the real parser, but the real parser is provided in the next step. + +**Type consistency:** `HttpHandler.Handle(self: &Self, req: &HttpRequest)` is consistent across `Router.bux` and `Middleware.bux`. `Handler` enum implements it in `Router.bux`. `MiddlewareHandler` implements it in `Middleware.bux`. + +**Risk note:** Bux interfaces currently use static dispatch. The plan avoids dynamic trait objects and uses concrete enum + `match` for heterogeneous handlers, which matches the verified compiler behavior. diff --git a/docs/superpowers/specs/2026-06-14-nexus-rewrite-design.md b/docs/superpowers/specs/2026-06-14-nexus-rewrite-design.md new file mode 100644 index 0000000..d78d06d --- /dev/null +++ b/docs/superpowers/specs/2026-06-14-nexus-rewrite-design.md @@ -0,0 +1,365 @@ +# Nexus HTTP Server Rewrite — Design Spec + +**Date:** 2026-06-14 +**Goal:** Rewrite `apps/nexus` as a production-ready, modular HTTP/1.1 server that exercises modern Bux language features. + +--- + +## 1. Scope + +Keep the same observable behavior as the current Nexus app, but restructure it for production quality: + +- HTTP/1.1 request parsing +- Static file serving from `./public/` +- API endpoints: `GET /api/health`, `GET /api/info` +- WebSocket upgrade detection on `/ws` +- Multi-threaded request handling + +What changes: +- Monolithic `Main.bux` → modular source tree +- Function-pointer dispatch → `interface`-based handlers and middleware +- Ad-hoc error handling → algebraic enum `Result`/`Option` patterns +- Raw pointer buffer parsing → `@[Checked]` borrow-checked parsing +- Direct worker spawn → thread-pool backed by `Channel` + +--- + +## 2. Module Layout + +``` +apps/nexus/ +├── bux.toml +├── README.md +├── public/ +│ ├── index.html +│ └── 404.html +└── src/ + ├── Main.bux # Entry point: config, socket setup, spawn workers, run acceptor + ├── Config.bux # ServerConfig struct + CTFE defaults + ├── Errors.bux # HttpError enum + Result/Option helpers + ├── Http.bux # HttpMethod enum, Request/Response structs, status text, MIME + ├── Parser.bux # @[Checked] HTTP/1.1 request parser + ├── Router.bux # Route, Router, HttpHandler interface + ├── Middleware.bux # Middleware interface + LoggingMiddleware + ├── Handlers.bux # Static files, API, WebSocket upgrade, 404 + └── Server.bux # ConnectionTask, Worker, acceptor loop, channel plumbing +``` + +--- + +## 3. Language Features to Exercise + +| Feature | Where | +|---------|-------| +| Modules & `pub`/`private` | Every file | +| Algebraic enums | `HttpMethod`, `HttpError`, `ParseResult` | +| Pattern matching (`match`) | Error dispatch in `Main`, method parsing | +| Structs + `extend` methods | `HttpRequest`, `HttpResponse`, `Router`, `ServerConfig` | +| `interface` + `extend ... for` | `HttpHandler`, `Middleware` | +| Generics | `Channel` | +| `for ... in` loops | Header iteration, route dispatch (over `Array` and `Array`) | +| `Array` generic container | Header storage, route table | +| `@[Checked]` + `&` / `&mut` | `Parser.bux` string buffer access | +| `Result` + `?` operator | Parser fallible operations | +| `const func` / CTFE | Default config values | +| `spawn` + `Channel` | Thread-pool in `Server.bux` | +| Raw multi-line / interpolated strings | Response templates, logs | + +--- + +## 4. Core Types + +### 4.1 HTTP Types (`Http.bux`) + +```bux +pub enum HttpMethod { + GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, UNKNOWN, +} + +pub enum HttpError { + BadRequest, + NotFound, + MethodNotAllowed, + InternalError(String), +} + +pub struct HeaderEntry { + key: String; + value: String; +} + +pub struct HttpRequest { + method: HttpMethod; + path: String; + version: String; + body: String; + headers: Array; +} + +pub struct HttpResponse { + statusCode: int; + contentType: String; + body: String; + extraHeaders: String; +} +``` + +### 4.2 Result Types (`Errors.bux`) + +Bux's `Std::Result` only carries `int` in `Ok`, so Nexus defines domain-specific enums: + +```bux +pub enum ParseResult { + Ok(HttpRequest), + Err(HttpError), +} + +pub enum FileResult { + Ok(String), + Err(HttpError), +} +``` + +Helpers: +- `ParseResult_IsOk`, `ParseResult_UnwrapOr` +- `FileResult_IsOk`, `FileResult_UnwrapOr` + +If the bootstrap `?` operator only recognizes `Result`/`Option` with exact variant names, parser code will fall back to explicit `match`. + +### 4.3 Handler & Middleware Interfaces + +```bux +// Router.bux +pub interface HttpHandler { + func Handle(self: &Self, req: &HttpRequest) -> HttpResponse; +} + +pub enum Handler { + StaticFile, + ApiHealth, + ApiInfo, + WsUpgrade, + NotFound, +} + +extend Handler for HttpHandler { + func Handle(self: &Handler, req: &HttpRequest) -> HttpResponse { + match self { + Handler::StaticFile => return ServeStaticFile(req), + Handler::ApiHealth => return HandleApiHealth(), + Handler::ApiInfo => return HandleApiInfo(), + Handler::WsUpgrade => return HandleWebSocketUpgrade(req), + Handler::NotFound => return NotFoundResponse(), + } + return NotFoundResponse(); + } +} + +pub struct Route { + method: HttpMethod; + path: String; + handler: Handler; +} + +pub struct Router { + routes: Array; + notFound: Handler; +} + +// Middleware.bux +pub interface Middleware { + func Process(self: &Self, req: &HttpRequest, next: &HttpHandler) -> HttpResponse; +} +``` + +Bux interfaces currently support static dispatch through generics, not dynamic `*Handler` pointers. The route table stores the concrete `Handler` enum and dispatches via `match` (showcasing algebraic enums + pattern matching). Middleware uses the interface with generic bounds (`T: HttpHandler`) for static composition. + +--- + +## 5. Data Flow + +1. `Main` reads `ServerConfig` and creates a listening socket. +2. `Main` spawns `workerCount - 1` worker threads; the main thread becomes the last worker. +3. `Main` spawns one dedicated acceptor thread that loops on `Net_Accept` and pushes `ConnectionTask { fd }` into `Channel`. +4. Each worker loops: + ``` + task = Channel_Recv(&taskQueue) + HandleConnection(task.fd, &appHandler) + Net_Close(task.fd) + ``` +5. `HandleConnection`: + - `Net_Recv` raw request + - `ParseRequest(raw)` → `ParseResult` (matched explicitly; `?` is used only for `Result`/int payloads) + - On success, `Router.Dispatch(&req)` or middleware chain + - `Http_BuildResponse(resp)` + `Net_Send` + +--- + +## 6. Parser Design (`Parser.bux`) + +Parser functions take the raw request by value (`String` is already a C-string reference) and build an `HttpRequest`: + +```bux +pub func ParseRequest(raw: String) -> ParseResult { + match FindToken(raw, " ") { + ParseResult::Ok(end) => { + let methodStr: String = Slice(raw, 0, end); + let method: HttpMethod = ParseMethod(methodStr); + // ... path, version, headers, body + return ParseResult_NewOk(req); + } + ParseResult::Err(e) => return ParseResult_NewErr(e), + } +} +``` + +`@[Checked]` is used where mutable borrows make sense (e.g. `SetResponseCode(resp: &mut HttpResponse, code: int)`), not on raw string parsing. + +Headers are stored in a dynamically grown `Array`. + +--- + +## 7. Router & Middleware + +### 7.1 Router Dispatch + +```bux +extend Router { + pub func Dispatch(self: *Router, req: &HttpRequest) -> HttpResponse { + for route in self.routes { + if route.method == req.method && String_Eq(route.path, req.path) { + return route.handler.Handle(req); // Handler enum implements HttpHandler + } + } + return self.notFound.Handle(req); + } +} +``` + +### 7.2 Middleware Chain + +`LoggingMiddleware` logs method/path and delegates to `next`: + +```bux +pub struct LoggingMiddleware {} + +extend LoggingMiddleware for Middleware { + func Process(self: *LoggingMiddleware, req: &HttpRequest, next: &T) -> HttpResponse { + Print(Http_MethodName(req.method)); + Print(" "); + PrintLine(req.path); + return next.Handle(req); + } +} +``` + +Chaining is achieved with a generic `MiddlewareHandler` struct that implements `HttpHandler` and holds `(middleware, next)`. This uses Bux's static-dispatch interfaces (no vtable pointers). + +--- + +## 8. Handlers (`Handlers.bux`) + +| Handler | Purpose | +|---------|---------| +| `StaticFileHandler` | Serve files from `public/` with MIME sniffing and path-traversal guard | +| `HealthHandler` | `GET /api/health` → JSON status | +| `InfoHandler` | `GET /api/info` → JSON server info | +| `WsUpgradeHandler` | `GET /ws` or `Upgrade: websocket` → 101 response with placeholder accept key | +| `NotFoundHandler` | 404 JSON/text fallback | + +All implement `HttpHandler`. + +--- + +## 9. Server & Thread Pool (`Server.bux`) + +```bux +pub struct ConnectionTask { + fd: int; +} + +pub struct Server { + config: ServerConfig; + taskQueue: Channel; + handler: *HttpHandler; +} +``` + +Flow: +1. `Server_Run(&server)` creates socket, binds, listens. +2. Spawns workers; each calls `Worker_Run(&server)`. +3. `Acceptor_Run(&server)` loops: + ```bux + let fd: int = Net_Accept(serverFd); + if fd >= 0 { + let task: ConnectionTask = ConnectionTask { fd: fd }; + Channel_Send(&server.taskQueue, task); + } + ``` +4. `Worker_Run` pops tasks and calls `HandleConnection(task.fd, server.handler)`. + +Socket fd ownership is always with the worker that received the task; it is closed before the worker loops again. + +--- + +## 10. Config (`Config.bux`) + +```bux +pub struct ServerConfig { + bindAddr: String; + port: int; + workerCount: int; + publicDir: String; + backlog: int; +} + +const func DefaultConfig() -> ServerConfig { + return ServerConfig { + bindAddr: "0.0.0.0", + port: 8080, + workerCount: 4, + publicDir: "public", + backlog: 128, + }; +} +``` + +--- + +## 11. Testing & Verification + +- `buxc check` must pass on the whole package. +- `buxc run` starts the server; verify with: + - `curl http://localhost:8080/` + - `curl http://localhost:8080/api/health` + - `curl http://localhost:8080/api/info` + - `curl -i -N -H "Upgrade: websocket" -H "Connection: Upgrade" http://localhost:8080/ws` +- Existing integration test surface (`buxc check` on `apps/nexus`) remains the gate. + +--- + +## 12. Out of Scope + +- Real HTTP/2 frame parsing or WebSocket frame parsing (keep detection/upgrade only, same as current). +- TLS/HTTPS. +- Full SHA-1/Base64 WebSocket accept key (keep placeholder). +- Generic `Result` (Bux `Std::Result` is `Ok(int)` only; use domain enums instead). + +--- + +## 13. Risks & Mitigations + +| Risk | Mitigation | +|------|------------| +| `interface` vtables with generic structs | Avoid generic interfaces; use concrete `*HttpHandler` pointers. | +| `Channel` with non-trivial `T` | `ConnectionTask` contains only `int`; safe to copy. | +| `?` operator on custom enums | Fall back to explicit `match` if needed. | +| `@[Checked]` borrow checker on raw `String` | Use `&String` for read-only parsing; avoid `&mut` unless mutation is required. | + +--- + +## 14. Success Criteria + +1. `buxc check apps/nexus` passes with zero errors. +2. `buxc run` in `apps/nexus` serves static files and API endpoints correctly. +3. The new code uses at minimum: modules, algebraic enums, pattern matching, interfaces, `extend`, generics, `for ... in`, `Channel`, `spawn`, `Result`/`Option`, `@[Checked]`. diff --git a/rt/io.c b/rt/io.c index a13bbb7..9e2fe47 100644 --- a/rt/io.c +++ b/rt/io.c @@ -11,6 +11,7 @@ void PrintLine(const char* s) { } else { puts(""); } + fflush(stdout); } /* Print - print string without newline */ @@ -18,6 +19,7 @@ void Print(const char* s) { if (s != NULL) { printf("%s", s); } + fflush(stdout); } /* PrintInt - print integer */ diff --git a/tests/borrow_test b/tests/borrow_test deleted file mode 100755 index 28e1676..0000000 Binary files a/tests/borrow_test and /dev/null differ diff --git a/tests/borrow_test.nim b/tests/borrow_test.nim index 80b294c..d1c1786 100644 --- a/tests/borrow_test.nim +++ b/tests/borrow_test.nim @@ -1,5 +1,5 @@ -import std/[unittest, os, strutils] -import ../bootstrap/[lexer, parser, sema, types] +import std/[unittest, strutils] +import ../bootstrap/[lexer, parser, sema] proc checkSource(source: string): tuple[hasErrors: bool, diagnostics: seq[SemaDiagnostic]] = let lexRes = lexer.tokenize(source, "test.bux") diff --git a/tests/golden/algebraic_enums/expected.c b/tests/golden/algebraic_enums/expected.c index 00f10fd..cdf4fc7 100644 --- a/tests/golden/algebraic_enums/expected.c +++ b/tests/golden/algebraic_enums/expected.c @@ -198,31 +198,21 @@ extern const char* bux_base64_decode(const char* data, int len, int* outlen); #define ED25519_PRIVKEY_SIZE 32 #define ED25519_SIG_SIZE 64 -typedef enum { - Option_Some, - Option_None -} Option_Tag; +typedef struct Channel_float64 { + void* handle; +} Channel_float64; -typedef union { - int Some_0; -} Option_Data; +typedef struct TaskHandle { + void* handle; +} TaskHandle; -typedef struct { - Option_Tag tag; - Option_Data data; -} Option; +typedef struct RwLock { + void* handle; +} RwLock; -typedef enum { - JwtAlg_HS256, - JwtAlg_HS384, - JwtAlg_HS512, - JwtAlg_RS256, - JwtAlg_RS384, - JwtAlg_RS512, - JwtAlg_ES256, - JwtAlg_ES384, - JwtAlg_EdDSA -} JwtAlg; +typedef struct Channel_int { + void* handle; +} Channel_int; typedef enum { Result_Ok, @@ -239,18 +229,31 @@ typedef struct { Result_Data data; } Result; +typedef enum { + JwtAlg_HS256, + JwtAlg_HS384, + JwtAlg_HS512, + JwtAlg_RS256, + JwtAlg_RS384, + JwtAlg_RS512, + JwtAlg_ES256, + JwtAlg_ES384, + JwtAlg_EdDSA +} JwtAlg; -typedef struct TaskHandle { - void* handle; -} TaskHandle; +typedef enum { + Option_Some, + Option_None +} Option_Tag; -typedef struct Mutex { - void* handle; -} Mutex; +typedef union { + int Some_0; +} Option_Data; -typedef struct RwLock { - void* handle; -} RwLock; +typedef struct { + Option_Tag tag; + Option_Data data; +} Option; typedef struct JsonValue { int tag; @@ -266,6 +269,14 @@ typedef struct JsonValue { unsigned int objCap; } JsonValue; +typedef struct Mutex { + void* handle; +} Mutex; + +typedef struct StringBuilder { + void* handle; +} StringBuilder; + typedef struct JsonParser { const char* src; unsigned int pos; @@ -273,18 +284,6 @@ typedef struct JsonParser { const char* error; } JsonParser; -typedef struct StringBuilder { - void* handle; -} StringBuilder; - -typedef struct Channel_int { - void* handle; -} Channel_int; - -typedef struct Channel_float64 { - void* handle; -} Channel_float64; - bool DirExists(const char* path); bool Mkdir(const char* path); const char** ListDir(const char* dir, const char* ext, int* count); @@ -866,7 +865,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { tmplLen = _t60; while1:; _t61 = (i < tmplLen); - if (!_t61) goto wend3; + if (!_t61) goto wend2; { const char* ch; const char* _t62; @@ -874,13 +873,13 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { ch = _t62; bool _t63; _t63 = String_Eq(ch, "{"); - if (!_t63) goto endif5; + if (!_t63) goto endif4; { unsigned int digitIdx; _t64 = i + 1; digitIdx = _t64; _t65 = (digitIdx < tmplLen); - if (!_t65) goto endif7; + if (!_t65) goto endif6; { const char* digitCh; const char* _t66; @@ -892,22 +891,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { d = _t67; bool __and_tmp_0; _t68 = (d >= 0); - if (!_t68) goto else8; + if (!_t68) goto else7; _t69 = (int64_t)argCount; _t70 = (d < _t69); *(bool*)&__and_tmp_0 = _t70; - goto endif9; - else8:; + goto endif8; + else7:; *(bool*)&__and_tmp_0 = 0; - endif9:; + endif8:; bool _t71; _t71 = *(bool*)&__and_tmp_0; - if (!_t71) goto endif11; + if (!_t71) goto endif10; { _t72 = i + 2; i = _t72; _t73 = (i < tmplLen); - if (!_t73) goto endif13; + if (!_t73) goto endif12; { const char* closeCh; const char* _t74; @@ -915,7 +914,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { closeCh = _t74; bool _t75; _t75 = String_Eq(closeCh, "}"); - if (!_t75) goto endif15; + if (!_t75) goto endif14; { _t76 = i + 1; i = _t76; @@ -928,22 +927,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { StringBuilder_Append(_t79, argStr); goto while1; } - endif15:; + endif14:; } - endif13:; + endif12:; } - endif11:; + endif10:; } - endif7:; + endif6:; } - endif5:; + endif4:; _t80 = &sb; StringBuilder_Append(_t80, ch); _t81 = i + 1; i = _t81; } goto while1; - wend3:; + wend2:; _t82 = &sb; const char* _t83; _t83 = StringBuilder_Build(_t82); @@ -951,276 +950,276 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { } const char* Fmt_Fmt1(const char* tmpl, const char* a1) { - const char** _t86; + const char** _t85; const char** args; /* sizeof(const char*) */ - void* _t85; - _t85 = bux_alloc(sizeof(const char*)); - _t86 = (const char**)_t85; - args = _t86; + void* _t84; + _t84 = bux_alloc(sizeof(const char*)); + _t85 = (const char**)_t84; + args = _t85; args[0] = a1; - const char* _t87; - _t87 = Fmt_Format(tmpl, args, 1); - return _t87; + const char* _t86; + _t86 = Fmt_Format(tmpl, args, 1); + return _t86; } const char* Fmt_FmtInt(const char* tmpl, int64_t val) { const char* s; + const char* _t87; + _t87 = String_FromInt(val); + s = _t87; const char* _t88; - _t88 = String_FromInt(val); - s = _t88; - const char* _t89; - _t89 = Fmt_Fmt1(tmpl, s); - return _t89; + _t88 = Fmt_Fmt1(tmpl, s); + return _t88; } const char* Fmt_FmtBool(const char* tmpl, bool val) { const char* s; + const char* _t89; + _t89 = String_FromBool(val); + s = _t89; const char* _t90; - _t90 = String_FromBool(val); - s = _t90; - const char* _t91; - _t91 = Fmt_Fmt1(tmpl, s); - return _t91; + _t90 = Fmt_Fmt1(tmpl, s); + return _t90; } const char* Fmt_FmtFloat(const char* tmpl, double val) { const char* s; + const char* _t91; + _t91 = String_FromFloat(val); + s = _t91; const char* _t92; - _t92 = String_FromFloat(val); - s = _t92; - const char* _t93; - _t93 = Fmt_Fmt1(tmpl, s); - return _t93; + _t92 = Fmt_Fmt1(tmpl, s); + return _t92; } const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2) { - int _t95; - const char** _t97; + int _t93; + const char** _t95; const char** args; /* sizeof(const char*) */ - _t95 = 2 * sizeof(const char*); - void* _t96; - _t96 = bux_alloc(_t95); - _t97 = (const char**)_t96; - args = _t97; + _t93 = 2 * sizeof(const char*); + void* _t94; + _t94 = bux_alloc(_t93); + _t95 = (const char**)_t94; + args = _t95; args[0] = a1; args[1] = a2; - const char* _t98; - _t98 = Fmt_Format(tmpl, args, 2); - return _t98; + const char* _t96; + _t96 = Fmt_Format(tmpl, args, 2); + return _t96; } const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3) { - int _t100; - const char** _t102; + int _t97; + const char** _t99; const char** args; /* sizeof(const char*) */ - _t100 = 3 * sizeof(const char*); - void* _t101; - _t101 = bux_alloc(_t100); - _t102 = (const char**)_t101; - args = _t102; + _t97 = 3 * sizeof(const char*); + void* _t98; + _t98 = bux_alloc(_t97); + _t99 = (const char**)_t98; + args = _t99; args[0] = a1; args[1] = a2; args[2] = a3; - const char* _t103; - _t103 = Fmt_Format(tmpl, args, 3); - return _t103; + const char* _t100; + _t100 = Fmt_Format(tmpl, args, 3); + return _t100; } const char* Crypto_Sha256(const char* data) { - int _t105; - void* _t107; + int _t102; + void* _t104; int len; - unsigned int _t104; - _t104 = String_Len(data); - _t105 = (int)_t104; - len = _t105; + unsigned int _t101; + _t101 = String_Len(data); + _t102 = (int)_t101; + len = _t102; void* hashBuf; - void* _t106; - _t106 = Alloc(32); - hashBuf = _t106; + void* _t103; + _t103 = Alloc(32); + hashBuf = _t103; bux_sha256(data, len, hashBuf); const char* result; - _t107 = (void*)hashBuf; - const char* _t108; - _t108 = bux_bytes_to_hex(_t107, 32); - result = _t108; + _t104 = (void*)hashBuf; + const char* _t105; + _t105 = bux_bytes_to_hex(_t104, 32); + result = _t105; Free(hashBuf); return result; } const char* Crypto_HmacSha256(const char* key, const char* message) { - int _t110; - int _t112; - void* _t114; + int _t107; + int _t109; + void* _t111; int keylen; - unsigned int _t109; - _t109 = String_Len(key); - _t110 = (int)_t109; - keylen = _t110; + unsigned int _t106; + _t106 = String_Len(key); + _t107 = (int)_t106; + keylen = _t107; int msglen; - unsigned int _t111; - _t111 = String_Len(message); - _t112 = (int)_t111; - msglen = _t112; + unsigned int _t108; + _t108 = String_Len(message); + _t109 = (int)_t108; + msglen = _t109; void* hmacBuf; - void* _t113; - _t113 = Alloc(32); - hmacBuf = _t113; + void* _t110; + _t110 = Alloc(32); + hmacBuf = _t110; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t114 = (void*)hmacBuf; - const char* _t115; - _t115 = bux_bytes_to_hex(_t114, 32); - result = _t115; + _t111 = (void*)hmacBuf; + const char* _t112; + _t112 = bux_bytes_to_hex(_t111, 32); + result = _t112; Free(hmacBuf); return result; } const char* Crypto_RandomBytes(int n) { - int _t116; - unsigned int _t117; - int _t120; - const char* _t121; - _t116 = (n <= 0); - if (!_t116) goto endif17; + int _t113; + unsigned int _t114; + int _t117; + const char* _t118; + _t113 = (n <= 0); + if (!_t113) goto endif16; { return ""; } - endif17:; + endif16:; void* buf; - _t117 = (unsigned int)n; - void* _t118; - _t118 = Alloc(_t117); - buf = _t118; - int _t119; - _t119 = bux_random_bytes(buf, n); - _t120 = (_t119 != 1); - if (!_t120) goto endif19; + _t114 = (unsigned int)n; + void* _t115; + _t115 = Alloc(_t114); + buf = _t115; + int _t116; + _t116 = bux_random_bytes(buf, n); + _t117 = (_t116 != 1); + if (!_t117) goto endif18; { Free(buf); return ""; } - endif19:; + endif18:; const char* result; - _t121 = (const char*)buf; - const char* _t122; - _t122 = bux_base64_encode(_t121, n); - result = _t122; + _t118 = (const char*)buf; + const char* _t119; + _t119 = bux_base64_encode(_t118, n); + result = _t119; Free(buf); return result; } const char* Crypto_Base64Encode(const char* s) { - int _t124; - unsigned int _t123; - _t123 = String_Len(s); - _t124 = (int)_t123; - const char* _t125; - _t125 = bux_base64_encode(s, _t124); - return _t125; + int _t121; + unsigned int _t120; + _t120 = String_Len(s); + _t121 = (int)_t120; + const char* _t122; + _t122 = bux_base64_encode(s, _t121); + return _t122; } const char* Crypto_HmacSha256Raw(const char* key, const char* message) { - int _t127; - int _t129; - const char* _t131; + int _t124; + int _t126; + const char* _t128; int keylen; - unsigned int _t126; - _t126 = String_Len(key); - _t127 = (int)_t126; - keylen = _t127; + unsigned int _t123; + _t123 = String_Len(key); + _t124 = (int)_t123; + keylen = _t124; int msglen; - unsigned int _t128; - _t128 = String_Len(message); - _t129 = (int)_t128; - msglen = _t129; + unsigned int _t125; + _t125 = String_Len(message); + _t126 = (int)_t125; + msglen = _t126; void* hmacBuf; - void* _t130; - _t130 = Alloc(32); - hmacBuf = _t130; + void* _t127; + _t127 = Alloc(32); + hmacBuf = _t127; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t131 = (const char*)hmacBuf; - const char* _t132; - _t132 = bux_base64_encode(_t131, 32); - result = _t132; + _t128 = (const char*)hmacBuf; + const char* _t129; + _t129 = bux_base64_encode(_t128, 32); + result = _t129; Free(hmacBuf); return result; } const char* Crypto_Base64Decode(const char* s) { - int _t134; - void* _t135; + int _t131; + void* _t132; int outlen; outlen = 0; - unsigned int _t133; - _t133 = String_Len(s); - _t134 = (int)_t133; - _t135 = &outlen; - const char* _t136; - _t136 = bux_base64_decode(s, _t134, _t135); - return _t136; + unsigned int _t130; + _t130 = String_Len(s); + _t131 = (int)_t130; + _t132 = &outlen; + const char* _t133; + _t133 = bux_base64_decode(s, _t131, _t132); + return _t133; } Mutex Mutex_New(void) { - Mutex _t138; - void* _t137; - _t137 = bux_mutex_new(); - _t138 = (Mutex){.handle = _t137}; - return _t138; + Mutex _t135; + void* _t134; + _t134 = bux_mutex_new(); + _t135 = (Mutex){.handle = _t134}; + return _t135; } void Mutex_Lock(Mutex* m) { - void* _t139; - _t139 = m->handle; - bux_mutex_lock(_t139); + void* _t136; + _t136 = m->handle; + bux_mutex_lock(_t136); } void Mutex_Unlock(Mutex* m) { - void* _t140; - _t140 = m->handle; - bux_mutex_unlock(_t140); + void* _t137; + _t137 = m->handle; + bux_mutex_unlock(_t137); } void Mutex_Free(Mutex* m) { - void* _t141; - _t141 = m->handle; - bux_mutex_free(_t141); + void* _t138; + _t138 = m->handle; + bux_mutex_free(_t138); } RwLock RwLock_New(void) { - RwLock _t143; - void* _t142; - _t142 = bux_rwlock_new(); - _t143 = (RwLock){.handle = _t142}; - return _t143; + RwLock _t140; + void* _t139; + _t139 = bux_rwlock_new(); + _t140 = (RwLock){.handle = _t139}; + return _t140; } void RwLock_ReadLock(RwLock* rw) { - void* _t144; - _t144 = rw->handle; - bux_rwlock_rdlock(_t144); + void* _t141; + _t141 = rw->handle; + bux_rwlock_rdlock(_t141); } void RwLock_WriteLock(RwLock* rw) { - void* _t145; - _t145 = rw->handle; - bux_rwlock_wrlock(_t145); + void* _t142; + _t142 = rw->handle; + bux_rwlock_wrlock(_t142); } void RwLock_Unlock(RwLock* rw) { - void* _t146; - _t146 = rw->handle; - bux_rwlock_unlock(_t146); + void* _t143; + _t143 = rw->handle; + bux_rwlock_unlock(_t143); } void RwLock_Free(RwLock* rw) { - void* _t147; - _t147 = rw->handle; - bux_rwlock_free(_t147); + void* _t144; + _t144 = rw->handle; + bux_rwlock_free(_t144); } void Test_Exit(int code) { @@ -1228,15 +1227,15 @@ void Test_Exit(int code) { } void Test_Assert(bool cond) { - int _t148; - _t148 = (int)cond; - bux_assert(_t148, "", 0, ""); + int _t145; + _t145 = (int)cond; + bux_assert(_t145, "", 0, ""); } void Test_AssertEqInt(int a, int b) { - int _t149; - _t149 = (a != b); - if (!_t149) goto endif21; + int _t146; + _t146 = (a != b); + if (!_t146) goto endif20; { PrintLine("ASSERT_EQ FAILED:"); PrintInt(a); @@ -1244,27 +1243,27 @@ void Test_AssertEqInt(int a, int b) { PrintInt(b); bux_exit(1); } - endif21:; + endif20:; } void Test_AssertTrue(bool cond) { - int _t150; - _t150 = !cond; - if (!_t150) goto endif23; + int _t147; + _t147 = !cond; + if (!_t147) goto endif22; { PrintLine("ASSERT_TRUE FAILED"); bux_exit(1); } - endif23:; + endif22:; } void Test_AssertFalse(bool cond) { - if (!cond) goto endif25; + if (!cond) goto endif24; { PrintLine("ASSERT_FALSE FAILED"); bux_exit(1); } - endif25:; + endif24:; } void Test_Fail(const char* msg) { @@ -1274,735 +1273,744 @@ void Test_Fail(const char* msg) { } Result Result_NewOk(int value) { - Result _t151; + Result _t148; Result r; - _t151 = (Result){.tag = Result_Ok}; - r = _t151; + _t148 = (Result){.tag = Result_Ok}; + r = _t148; r.data.Ok_0 = value; return r; } Result Result_NewErr(const char* msg) { - Result _t152; + Result _t149; Result r; - _t152 = (Result){.tag = Result_Err}; - r = _t152; + _t149 = (Result){.tag = Result_Err}; + r = _t149; r.data.Err_0 = msg; return r; } bool Result_IsOk(Result r) { - int _t154; - Result_Tag _t153; - _t153 = r.tag; - _t154 = (_t153 == Result_Ok); - return _t154; + int _t151; + Result_Tag _t150; + _t150 = r.tag; + _t151 = (_t150 == Result_Ok); + return _t151; } bool Result_IsErr(Result r) { - int _t156; - Result_Tag _t155; - _t155 = r.tag; - _t156 = (_t155 == Result_Err); - return _t156; + int _t153; + Result_Tag _t152; + _t152 = r.tag; + _t153 = (_t152 == Result_Err); + return _t153; } int Result_Unwrap(Result r) { - int _t158; - Result_Tag _t157; - _t157 = r.tag; - _t158 = (_t157 != Result_Ok); - if (!_t158) goto endif27; + int _t155; + Result_Tag _t154; + _t154 = r.tag; + _t155 = (_t154 != Result_Ok); + if (!_t155) goto endif26; { PrintLine("panic: unwrap on Err"); return 0; } - endif27:; - Result_Data _t159; - _t159 = r.data; - int _t160; - _t160 = _t159.Ok_0; - return _t160; + endif26:; + Result_Data _t156; + _t156 = r.data; + int _t157; + _t157 = _t156.Ok_0; + return _t157; } int Result_UnwrapOr(Result r, int fallback) { - int _t162; - Result_Tag _t161; - _t161 = r.tag; - _t162 = (_t161 == Result_Ok); - if (!_t162) goto endif29; + int _t159; + Result_Tag _t158; + _t158 = r.tag; + _t159 = (_t158 == Result_Ok); + if (!_t159) goto endif28; { - Result_Data _t163; - _t163 = r.data; - int _t164; - _t164 = _t163.Ok_0; - return _t164; + Result_Data _t160; + _t160 = r.data; + int _t161; + _t161 = _t160.Ok_0; + return _t161; } - endif29:; + endif28:; return fallback; } Option Option_NewSome(int value) { - Option _t165; + Option _t162; Option o; - _t165 = (Option){.tag = Option_Some}; - o = _t165; + _t162 = (Option){.tag = Option_Some}; + o = _t162; o.data.Some_0 = value; return o; } Option Option_NewNone(void) { - Option _t166; - _t166 = (Option){.tag = Option_None}; - return _t166; + Option _t163; + _t163 = (Option){.tag = Option_None}; + return _t163; } bool Option_IsSome(Option o) { - int _t168; - Option_Tag _t167; - _t167 = o.tag; - _t168 = (_t167 == Option_Some); - return _t168; + int _t165; + Option_Tag _t164; + _t164 = o.tag; + _t165 = (_t164 == Option_Some); + return _t165; } bool Option_IsNone(Option o) { - int _t170; - Option_Tag _t169; - _t169 = o.tag; - _t170 = (_t169 == Option_None); - return _t170; + int _t167; + Option_Tag _t166; + _t166 = o.tag; + _t167 = (_t166 == Option_None); + return _t167; } int Option_Unwrap(Option o) { - int _t172; - Option_Tag _t171; - _t171 = o.tag; - _t172 = (_t171 != Option_Some); - if (!_t172) goto endif31; + int _t169; + Option_Tag _t168; + _t168 = o.tag; + _t169 = (_t168 != Option_Some); + if (!_t169) goto endif30; { PrintLine("panic: unwrap on None"); return 0; } - endif31:; - Option_Data _t173; - _t173 = o.data; - int _t174; - _t174 = _t173.Some_0; - return _t174; + endif30:; + Option_Data _t170; + _t170 = o.data; + int _t171; + _t171 = _t170.Some_0; + return _t171; } int Option_UnwrapOr(Option o, int fallback) { - int _t176; - Option_Tag _t175; - _t175 = o.tag; - _t176 = (_t175 == Option_Some); - if (!_t176) goto endif33; + int _t173; + Option_Tag _t172; + _t172 = o.tag; + _t173 = (_t172 == Option_Some); + if (!_t173) goto endif32; { - Option_Data _t177; - _t177 = o.data; - int _t178; - _t178 = _t177.Some_0; - return _t178; + Option_Data _t174; + _t174 = o.data; + int _t175; + _t175 = _t174.Some_0; + return _t175; } - endif33:; + endif32:; return fallback; } JsonValue Json_Null(void) { - JsonValue _t179; - _t179 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t179; + JsonValue _t176; + _t176 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t176; } JsonValue Json_Bool(bool b) { - JsonValue _t180; - _t180 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t180; + JsonValue _t177; + _t177 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t177; } JsonValue Json_Number(double n) { - JsonValue _t181; - _t181 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t181; + JsonValue _t178; + _t178 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t178; } JsonValue Json_String(const char* s) { - JsonValue _t182; - _t182 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t182; + JsonValue _t179; + _t179 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t179; } JsonValue Json_Array(void) { - JsonValue _t183; - _t183 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t183; + JsonValue _t180; + _t180 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t180; } JsonValue Json_Object(void) { - JsonValue _t184; - _t184 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t184; + JsonValue _t181; + _t181 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t181; } unsigned int Json_ArrayLen(JsonValue v) { - int _t186; - int _t185; - _t185 = v.tag; - _t186 = (_t185 != JsonTagArray); - if (!_t186) goto endif35; + int _t183; + int _t182; + _t182 = v.tag; + _t183 = (_t182 != JsonTagArray); + if (!_t183) goto endif34; { return 0; } - endif35:; - unsigned int _t187; - _t187 = v.arrLen; - return _t187; + endif34:; + unsigned int _t184; + _t184 = v.arrLen; + return _t184; } JsonValue Json_ArrayGet(JsonValue v, unsigned int index) { + int _t186; int _t189; - int _t192; - int _t188; - _t188 = v.tag; - _t189 = (_t188 != JsonTagArray); - if (!_t189) goto endif37; + int _t185; + _t185 = v.tag; + _t186 = (_t185 != JsonTagArray); + if (!_t186) goto endif36; + { + JsonValue _t187; + _t187 = Json_Null(); + return _t187; + } + endif36:; + unsigned int _t188; + _t188 = v.arrLen; + _t189 = (index >= _t188); + if (!_t189) goto endif38; { JsonValue _t190; _t190 = Json_Null(); return _t190; } - endif37:; - unsigned int _t191; - _t191 = v.arrLen; - _t192 = (index >= _t191); - if (!_t192) goto endif39; - { - JsonValue _t193; - _t193 = Json_Null(); - return _t193; - } - endif39:; - JsonValue* _t194; - _t194 = v.arrData; - JsonValue _t195; - _t195 = _t194[index]; - return _t195; + endif38:; + JsonValue* _t191; + _t191 = v.arrData; + JsonValue _t192; + _t192 = _t191[index]; + return _t192; } void Json_ArrayPush(JsonValue* self, JsonValue val) { + int _t194; int _t197; + int _t199; int _t200; - int _t202; - int _t204; - JsonValue* _t206; - int _t207; - void* _t209; - int _t211; - JsonValue* _t213; - int _t217; - int _t196; - _t196 = self->tag; - _t197 = (_t196 != JsonTagArray); - if (!_t197) goto endif41; + JsonValue* _t202; + int _t203; + void* _t205; + int _t206; + JsonValue* _t208; + int _t212; + int _t193; + _t193 = self->tag; + _t194 = (_t193 != JsonTagArray); + if (!_t194) goto endif40; { return; } - endif41:; - unsigned int _t198; - _t198 = self->arrLen; - unsigned int _t199; - _t199 = self->arrCap; - _t200 = (_t198 >= _t199); - if (!_t200) goto endif43; + endif40:; + unsigned int _t195; + _t195 = self->arrLen; + unsigned int _t196; + _t196 = self->arrCap; + _t197 = (_t195 >= _t196); + if (!_t197) goto endif42; { unsigned int arrNewCap; - unsigned int _t201; - _t201 = self->arrCap; - arrNewCap = _t201; - _t202 = (arrNewCap == 0); - if (!_t202) goto else44; + unsigned int _t198; + _t198 = self->arrCap; + arrNewCap = _t198; + _t199 = (arrNewCap == 0); + if (!_t199) goto else43; { self->arrCap = 4; /* sizeof(JsonValue) */ - _t204 = 4 * sizeof(JsonValue); - void* _t205; - _t205 = Alloc(_t204); - _t206 = (JsonValue*)_t205; - self->arrData = _t206; + _t200 = 4 * sizeof(JsonValue); + void* _t201; + _t201 = Alloc(_t200); + _t202 = (JsonValue*)_t201; + self->arrData = _t202; } - goto endif45; - else44:; + goto endif44; + else43:; { unsigned int doubleCap; - _t207 = arrNewCap * 2; - doubleCap = _t207; + _t203 = arrNewCap * 2; + doubleCap = _t203; self->arrCap = doubleCap; - JsonValue* _t208; - _t208 = self->arrData; - _t209 = (void*)_t208; + JsonValue* _t204; + _t204 = self->arrData; + _t205 = (void*)_t204; /* sizeof(JsonValue) */ - _t211 = doubleCap * sizeof(JsonValue); - void* _t212; - _t212 = Realloc(_t209, _t211); - _t213 = (JsonValue*)_t212; - self->arrData = _t213; + _t206 = doubleCap * sizeof(JsonValue); + void* _t207; + _t207 = Realloc(_t205, _t206); + _t208 = (JsonValue*)_t207; + self->arrData = _t208; } - endif45:; + endif44:; } - endif43:; - JsonValue* _t214; - _t214 = self->arrData; - unsigned int _t215; - _t215 = self->arrLen; - _t214[_t215] = val; - unsigned int _t216; - _t216 = self->arrLen; - _t217 = _t216 + 1; - self->arrLen = _t217; + endif42:; + JsonValue* _t209; + _t209 = self->arrData; + unsigned int _t210; + _t210 = self->arrLen; + _t209[_t210] = val; + unsigned int _t211; + _t211 = self->arrLen; + _t212 = _t211 + 1; + self->arrLen = _t212; } unsigned int Json_ObjectLen(JsonValue v) { - int _t219; - int _t218; - _t218 = v.tag; - _t219 = (_t218 != JsonTagObject); - if (!_t219) goto endif47; + int _t214; + int _t213; + _t213 = v.tag; + _t214 = (_t213 != JsonTagObject); + if (!_t214) goto endif46; { return 0; } - endif47:; - unsigned int _t220; - _t220 = v.objLen; - return _t220; + endif46:; + unsigned int _t215; + _t215 = v.objLen; + return _t215; } JsonValue Json_ObjectGet(JsonValue v, const char* key) { - int _t222; - int _t225; - int _t231; - int _t221; - _t221 = v.tag; - _t222 = (_t221 != JsonTagObject); - if (!_t222) goto endif49; + int _t217; + int _t220; + int _t226; + int _t216; + _t216 = v.tag; + _t217 = (_t216 != JsonTagObject); + if (!_t217) goto endif48; { - JsonValue _t223; - _t223 = Json_Null(); - return _t223; + JsonValue _t218; + _t218 = Json_Null(); + return _t218; } - endif49:; + endif48:; unsigned int i; i = 0; - while50:; - unsigned int _t224; - _t224 = v.objLen; - _t225 = (i < _t224); - if (!_t225) goto wend52; + while49:; + unsigned int _t219; + _t219 = v.objLen; + _t220 = (i < _t219); + if (!_t220) goto wend50; { - const char** _t226; - _t226 = v.objKeys; - const char* _t227; - _t227 = _t226[i]; - bool _t228; - _t228 = String_Eq(_t227, key); - if (!_t228) goto endif54; + const char** _t221; + _t221 = v.objKeys; + const char* _t222; + _t222 = _t221[i]; + bool _t223; + _t223 = String_Eq(_t222, key); + if (!_t223) goto endif52; { - JsonValue* _t229; - _t229 = v.objValues; - JsonValue _t230; - _t230 = _t229[i]; - return _t230; + JsonValue* _t224; + _t224 = v.objValues; + JsonValue _t225; + _t225 = _t224[i]; + return _t225; } - endif54:; - _t231 = i + 1; - i = _t231; + endif52:; + _t226 = i + 1; + i = _t226; } - goto while50; - wend52:; - JsonValue _t232; - _t232 = Json_Null(); - return _t232; + goto while49; + wend50:; + JsonValue _t227; + _t227 = Json_Null(); + return _t227; } bool Json_ObjectHas(JsonValue v, const char* key) { - int _t234; - int _t236; - int _t240; - int _t233; - _t233 = v.tag; - _t234 = (_t233 != JsonTagObject); - if (!_t234) goto endif56; + int _t229; + int _t231; + int _t235; + int _t228; + _t228 = v.tag; + _t229 = (_t228 != JsonTagObject); + if (!_t229) goto endif54; { return 0; } - endif56:; + endif54:; unsigned int i; i = 0; - while57:; - unsigned int _t235; - _t235 = v.objLen; - _t236 = (i < _t235); - if (!_t236) goto wend59; + while55:; + unsigned int _t230; + _t230 = v.objLen; + _t231 = (i < _t230); + if (!_t231) goto wend56; { - const char** _t237; - _t237 = v.objKeys; - const char* _t238; - _t238 = _t237[i]; - bool _t239; - _t239 = String_Eq(_t238, key); - if (!_t239) goto endif61; + const char** _t232; + _t232 = v.objKeys; + const char* _t233; + _t233 = _t232[i]; + bool _t234; + _t234 = String_Eq(_t233, key); + if (!_t234) goto endif58; { return 1; } - endif61:; - _t240 = i + 1; - i = _t240; + endif58:; + _t235 = i + 1; + i = _t235; } - goto while57; - wend59:; + goto while55; + wend56:; return 0; } void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) { - int _t242; + int _t237; + int _t239; int _t244; + int _t247; int _t249; - int _t252; - int _t254; + int _t250; + const char** _t252; + int _t253; + JsonValue* _t255; int _t256; - const char** _t258; - int _t260; - JsonValue* _t262; - int _t263; - void* _t265; - int _t267; - const char** _t269; - void* _t271; - int _t273; - JsonValue* _t275; - int _t281; - int _t241; - _t241 = self->tag; - _t242 = (_t241 != JsonTagObject); - if (!_t242) goto endif63; + void* _t258; + int _t259; + const char** _t261; + void* _t263; + int _t264; + JsonValue* _t266; + int _t272; + int _t236; + _t236 = self->tag; + _t237 = (_t236 != JsonTagObject); + if (!_t237) goto endif60; { return; } - endif63:; + endif60:; unsigned int i; i = 0; - while64:; - unsigned int _t243; - _t243 = self->objLen; - _t244 = (i < _t243); - if (!_t244) goto wend66; + while61:; + unsigned int _t238; + _t238 = self->objLen; + _t239 = (i < _t238); + if (!_t239) goto wend62; { - const char** _t245; - _t245 = self->objKeys; - const char* _t246; - _t246 = _t245[i]; - bool _t247; - _t247 = String_Eq(_t246, key); - if (!_t247) goto endif68; + const char** _t240; + _t240 = self->objKeys; + const char* _t241; + _t241 = _t240[i]; + bool _t242; + _t242 = String_Eq(_t241, key); + if (!_t242) goto endif64; { - JsonValue* _t248; - _t248 = self->objValues; - _t248[i] = val; + JsonValue* _t243; + _t243 = self->objValues; + _t243[i] = val; return; } - endif68:; - _t249 = i + 1; - i = _t249; + endif64:; + _t244 = i + 1; + i = _t244; } - goto while64; - wend66:; - unsigned int _t250; - _t250 = self->objLen; - unsigned int _t251; - _t251 = self->objCap; - _t252 = (_t250 >= _t251); - if (!_t252) goto endif70; + goto while61; + wend62:; + unsigned int _t245; + _t245 = self->objLen; + unsigned int _t246; + _t246 = self->objCap; + _t247 = (_t245 >= _t246); + if (!_t247) goto endif66; { unsigned int objNewCap; - unsigned int _t253; - _t253 = self->objCap; - objNewCap = _t253; - _t254 = (objNewCap == 0); - if (!_t254) goto else71; + unsigned int _t248; + _t248 = self->objCap; + objNewCap = _t248; + _t249 = (objNewCap == 0); + if (!_t249) goto else67; { self->objCap = 4; /* sizeof(const char*) */ - _t256 = 4 * sizeof(const char*); - void* _t257; - _t257 = Alloc(_t256); - _t258 = (const char**)_t257; - self->objKeys = _t258; + _t250 = 4 * sizeof(const char*); + void* _t251; + _t251 = Alloc(_t250); + _t252 = (const char**)_t251; + self->objKeys = _t252; /* sizeof(JsonValue) */ - _t260 = 4 * sizeof(JsonValue); - void* _t261; - _t261 = Alloc(_t260); - _t262 = (JsonValue*)_t261; - self->objValues = _t262; + _t253 = 4 * sizeof(JsonValue); + void* _t254; + _t254 = Alloc(_t253); + _t255 = (JsonValue*)_t254; + self->objValues = _t255; } - goto endif72; - else71:; + goto endif68; + else67:; { unsigned int doubleCap; - _t263 = objNewCap * 2; - doubleCap = _t263; + _t256 = objNewCap * 2; + doubleCap = _t256; self->objCap = doubleCap; - const char** _t264; - _t264 = self->objKeys; - _t265 = (void*)_t264; + const char** _t257; + _t257 = self->objKeys; + _t258 = (void*)_t257; /* sizeof(const char*) */ - _t267 = doubleCap * sizeof(const char*); - void* _t268; - _t268 = Realloc(_t265, _t267); - _t269 = (const char**)_t268; - self->objKeys = _t269; - JsonValue* _t270; - _t270 = self->objValues; - _t271 = (void*)_t270; + _t259 = doubleCap * sizeof(const char*); + void* _t260; + _t260 = Realloc(_t258, _t259); + _t261 = (const char**)_t260; + self->objKeys = _t261; + JsonValue* _t262; + _t262 = self->objValues; + _t263 = (void*)_t262; /* sizeof(JsonValue) */ - _t273 = doubleCap * sizeof(JsonValue); - void* _t274; - _t274 = Realloc(_t271, _t273); - _t275 = (JsonValue*)_t274; - self->objValues = _t275; + _t264 = doubleCap * sizeof(JsonValue); + void* _t265; + _t265 = Realloc(_t263, _t264); + _t266 = (JsonValue*)_t265; + self->objValues = _t266; } - endif72:; + endif68:; } - endif70:; - const char** _t276; - _t276 = self->objKeys; - unsigned int _t277; - _t277 = self->objLen; - _t276[_t277] = key; - JsonValue* _t278; - _t278 = self->objValues; - unsigned int _t279; - _t279 = self->objLen; - _t278[_t279] = val; - unsigned int _t280; - _t280 = self->objLen; - _t281 = _t280 + 1; - self->objLen = _t281; + endif66:; + const char** _t267; + _t267 = self->objKeys; + unsigned int _t268; + _t268 = self->objLen; + _t267[_t268] = key; + JsonValue* _t269; + _t269 = self->objValues; + unsigned int _t270; + _t270 = self->objLen; + _t269[_t270] = val; + unsigned int _t271; + _t271 = self->objLen; + _t272 = _t271 + 1; + self->objLen = _t272; } bool Json_IsNull(JsonValue v) { - int _t283; - int _t282; - _t282 = v.tag; - _t283 = (_t282 == JsonTagNull); - return _t283; + int _t274; + int _t273; + _t273 = v.tag; + _t274 = (_t273 == JsonTagNull); + return _t274; } bool Json_AsBool(JsonValue v) { - int _t285; - int _t284; - _t284 = v.tag; - _t285 = (_t284 == JsonTagBool); - if (!_t285) goto endif74; + int _t276; + int _t275; + _t275 = v.tag; + _t276 = (_t275 == JsonTagBool); + if (!_t276) goto endif70; { - bool _t286; - _t286 = v.boolVal; - return _t286; + bool _t277; + _t277 = v.boolVal; + return _t277; } - endif74:; + endif70:; return 0; } double Json_AsNumber(JsonValue v) { - int _t288; - int _t287; - _t287 = v.tag; - _t288 = (_t287 == JsonTagNumber); - if (!_t288) goto endif76; + int _t279; + int _t278; + _t278 = v.tag; + _t279 = (_t278 == JsonTagNumber); + if (!_t279) goto endif72; { - double _t289; - _t289 = v.numVal; - return _t289; + double _t280; + _t280 = v.numVal; + return _t280; } - endif76:; + endif72:; return 0.0; } const char* Json_AsString(JsonValue v) { - int _t291; - int _t290; - _t290 = v.tag; - _t291 = (_t290 == JsonTagString); - if (!_t291) goto endif78; + int _t282; + int _t281; + _t281 = v.tag; + _t282 = (_t281 == JsonTagString); + if (!_t282) goto endif74; { - const char* _t292; - _t292 = v.strVal; - return _t292; + const char* _t283; + _t283 = v.strVal; + return _t283; } - endif78:; + endif74:; return ""; } int JsonParser_Peek(JsonParser* p) { - int _t295; - int _t299; - unsigned int _t293; - _t293 = p->pos; - unsigned int _t294; - _t294 = p->len; - _t295 = (_t293 >= _t294); - if (!_t295) goto endif80; + int _t286; + int _t290; + unsigned int _t284; + _t284 = p->pos; + unsigned int _t285; + _t285 = p->len; + _t286 = (_t284 >= _t285); + if (!_t286) goto endif76; { return 0; } - endif80:; - const char* _t296; - _t296 = p->src; - unsigned int _t297; - _t297 = p->pos; - int _t298; - _t298 = _t296[_t297]; - _t299 = (int)_t298; - return _t299; + endif76:; + const char* _t287; + _t287 = p->src; + unsigned int _t288; + _t288 = p->pos; + int _t289; + _t289 = _t287[_t288]; + _t290 = (int)_t289; + return _t290; } void JsonParser_Advance(JsonParser* p) { - int _t302; - int _t304; - unsigned int _t300; - _t300 = p->pos; - unsigned int _t301; - _t301 = p->len; - _t302 = (_t300 < _t301); - if (!_t302) goto endif82; + int _t293; + int _t295; + unsigned int _t291; + _t291 = p->pos; + unsigned int _t292; + _t292 = p->len; + _t293 = (_t291 < _t292); + if (!_t293) goto endif78; { - unsigned int _t303; - _t303 = p->pos; - _t304 = _t303 + 1; - p->pos = _t304; + unsigned int _t294; + _t294 = p->pos; + _t295 = _t294 + 1; + p->pos = _t295; } - endif82:; + endif78:; } void JsonParser_SkipWhitespace(JsonParser* p) { - int _t306; - int _t307; - int _t309; - int _t311; - while83:; - if (!1) goto wend85; + int _t297; + int _t298; + int _t300; + int _t302; + while79:; + if (!1) goto wend80; { int c; - int _t305; - _t305 = JsonParser_Peek(p); - c = _t305; + int _t296; + _t296 = JsonParser_Peek(p); + c = _t296; bool __or_tmp_1; bool __or_tmp_2; bool __or_tmp_3; - _t306 = (c == 32); - if (!_t306) goto else86; + _t297 = (c == 32); + if (!_t297) goto else81; *(bool*)&__or_tmp_3 = 1; - goto endif87; - else86:; - _t307 = (c == 9); - *(bool*)&__or_tmp_3 = _t307; - endif87:; - bool _t308; - _t308 = *(bool*)&__or_tmp_3; - if (!_t308) goto else88; + goto endif82; + else81:; + _t298 = (c == 9); + *(bool*)&__or_tmp_3 = _t298; + endif82:; + bool _t299; + _t299 = *(bool*)&__or_tmp_3; + if (!_t299) goto else83; *(bool*)&__or_tmp_2 = 1; - goto endif89; - else88:; - _t309 = (c == 10); - *(bool*)&__or_tmp_2 = _t309; - endif89:; - bool _t310; - _t310 = *(bool*)&__or_tmp_2; - if (!_t310) goto else90; + goto endif84; + else83:; + _t300 = (c == 10); + *(bool*)&__or_tmp_2 = _t300; + endif84:; + bool _t301; + _t301 = *(bool*)&__or_tmp_2; + if (!_t301) goto else85; *(bool*)&__or_tmp_1 = 1; - goto endif91; - else90:; - _t311 = (c == 13); - *(bool*)&__or_tmp_1 = _t311; - endif91:; - bool _t312; - _t312 = *(bool*)&__or_tmp_1; - if (!_t312) goto else92; + goto endif86; + else85:; + _t302 = (c == 13); + *(bool*)&__or_tmp_1 = _t302; + endif86:; + bool _t303; + _t303 = *(bool*)&__or_tmp_1; + if (!_t303) goto else87; { JsonParser_Advance(p); } - goto endif93; - else92:; + goto endif88; + else87:; { return; } - endif93:; + endif88:; } - goto while83; - wend85:; + goto while79; + wend80:; } bool JsonParser_Match(JsonParser* p, const char* expected) { + int _t306; + int _t308; + int _t309; + int _t312; int _t315; - int _t317; + int _t316; int _t318; - int _t321; - int _t324; - int _t325; - int _t327; unsigned int elen; - unsigned int _t313; - _t313 = String_Len(expected); - elen = _t313; - unsigned int _t314; - _t314 = p->pos; - _t315 = _t314 + elen; - unsigned int _t316; - _t316 = p->len; - _t317 = (_t315 > _t316); - if (!_t317) goto endif95; + unsigned int _t304; + _t304 = String_Len(expected); + elen = _t304; + unsigned int _t305; + _t305 = p->pos; + _t306 = _t305 + elen; + unsigned int _t307; + _t307 = p->len; + _t308 = (_t306 > _t307); + if (!_t308) goto endif90; { return 0; } - endif95:; + endif90:; unsigned int i; i = 0; - while96:; - _t318 = (i < elen); - if (!_t318) goto wend98; + while91:; + _t309 = (i < elen); + if (!_t309) goto wend92; { - const char* _t319; - _t319 = p->src; - unsigned int _t320; - _t320 = p->pos; - _t321 = _t320 + i; - int _t322; - _t322 = _t319[_t321]; - int _t323; - _t323 = expected[i]; - _t324 = (_t322 != _t323); - if (!_t324) goto endif100; + const char* _t310; + _t310 = p->src; + unsigned int _t311; + _t311 = p->pos; + _t312 = _t311 + i; + int _t313; + _t313 = _t310[_t312]; + int _t314; + _t314 = expected[i]; + _t315 = (_t313 != _t314); + if (!_t315) goto endif94; { return 0; } - endif100:; - _t325 = i + 1; - i = _t325; + endif94:; + _t316 = i + 1; + i = _t316; } - goto while96; - wend98:; - unsigned int _t326; - _t326 = p->pos; - _t327 = _t326 + elen; - p->pos = _t327; + goto while91; + wend92:; + unsigned int _t317; + _t317 = p->pos; + _t318 = _t317 + elen; + p->pos = _t318; return 1; } const char* JsonParser_ParseString(JsonParser* p) { - int _t329; - int _t332; + int _t320; + int _t323; + int _t324; + int _t326; + int _t328; + void* _t329; + int _t330; + void* _t331; + char _t332; int _t333; - int _t335; - int _t337; - void* _t338; + void* _t334; + char _t335; + int _t336; + void* _t337; + char _t338; int _t339; void* _t340; char _t341; @@ -2015,234 +2023,262 @@ const char* JsonParser_ParseString(JsonParser* p) { int _t348; void* _t349; char _t350; - int _t351; - void* _t352; - char _t353; - int _t354; + void* _t351; + char _t352; + void* _t353; + char _t354; void* _t355; char _t356; - int _t357; - void* _t358; - char _t359; + int _t358; + void* _t359; void* _t360; - char _t361; void* _t362; - char _t363; - void* _t364; - char _t365; - int _t367; - void* _t368; - void* _t369; - void* _t371; - int _t328; - _t328 = JsonParser_Peek(p); - _t329 = (_t328 != 34); - if (!_t329) goto endif102; + int _t319; + _t319 = JsonParser_Peek(p); + _t320 = (_t319 != 34); + if (!_t320) goto endif96; { p->error = "Expected string"; return ""; } - endif102:; + endif96:; JsonParser_Advance(p); StringBuilder sb; - StringBuilder _t330; - _t330 = StringBuilder_New(); - sb = _t330; - while103:; - if (!1) goto wend105; + StringBuilder _t321; + _t321 = StringBuilder_New(); + sb = _t321; + while97:; + if (!1) goto wend98; { int c; - int _t331; - _t331 = JsonParser_Peek(p); - c = _t331; + int _t322; + _t322 = JsonParser_Peek(p); + c = _t322; bool __or_tmp_4; - _t332 = (c == 0); - if (!_t332) goto else106; + _t323 = (c == 0); + if (!_t323) goto else99; *(bool*)&__or_tmp_4 = 1; - goto endif107; - else106:; - _t333 = (c == 34); - *(bool*)&__or_tmp_4 = _t333; - endif107:; - bool _t334; - _t334 = *(bool*)&__or_tmp_4; - if (!_t334) goto endif109; + goto endif100; + else99:; + _t324 = (c == 34); + *(bool*)&__or_tmp_4 = _t324; + endif100:; + bool _t325; + _t325 = *(bool*)&__or_tmp_4; + if (!_t325) goto endif102; { - goto wend105; + goto wend98; } - endif109:; - _t335 = (c == 92); - if (!_t335) goto else110; + endif102:; + _t326 = (c == 92); + if (!_t326) goto else103; { JsonParser_Advance(p); int esc; - int _t336; - _t336 = JsonParser_Peek(p); - esc = _t336; - _t337 = (esc == 0); - if (!_t337) goto endif113; + int _t327; + _t327 = JsonParser_Peek(p); + esc = _t327; + _t328 = (esc == 0); + if (!_t328) goto endif106; { p->error = "Unterminated string escape"; - _t338 = &sb; - StringBuilder_Free(_t338); + _t329 = &sb; + StringBuilder_Free(_t329); return ""; } - endif113:; - _t339 = (esc == 110); - if (!_t339) goto else114; + endif106:; + _t330 = (esc == 110); + if (!_t330) goto else107; + { + _t331 = &sb; + _t332 = (char)10; + StringBuilder_AppendChar(_t331, _t332); + } + goto endif108; + else107:; + _t333 = (esc == 116); + if (!_t333) goto else109; + { + _t334 = &sb; + _t335 = (char)9; + StringBuilder_AppendChar(_t334, _t335); + } + goto endif110; + else109:; + _t336 = (esc == 114); + if (!_t336) goto else111; + { + _t337 = &sb; + _t338 = (char)13; + StringBuilder_AppendChar(_t337, _t338); + } + goto endif112; + else111:; + _t339 = (esc == 98); + if (!_t339) goto else113; { _t340 = &sb; - _t341 = (char)10; + _t341 = (char)8; StringBuilder_AppendChar(_t340, _t341); } - goto endif115; - else114:; - _t342 = (esc == 116); - if (!_t342) goto else116; + goto endif114; + else113:; + _t342 = (esc == 102); + if (!_t342) goto else115; { _t343 = &sb; - _t344 = (char)9; + _t344 = (char)12; StringBuilder_AppendChar(_t343, _t344); } - goto endif117; - else116:; - _t345 = (esc == 114); - if (!_t345) goto else118; + goto endif116; + else115:; + _t345 = (esc == 34); + if (!_t345) goto else117; { _t346 = &sb; - _t347 = (char)13; + _t347 = (char)34; StringBuilder_AppendChar(_t346, _t347); } - goto endif119; - else118:; - _t348 = (esc == 98); - if (!_t348) goto else120; + goto endif118; + else117:; + _t348 = (esc == 92); + if (!_t348) goto else119; { _t349 = &sb; - _t350 = (char)8; + _t350 = (char)92; StringBuilder_AppendChar(_t349, _t350); } - goto endif121; - else120:; - _t351 = (esc == 102); - if (!_t351) goto else122; + goto endif120; + else119:; { - _t352 = &sb; - _t353 = (char)12; - StringBuilder_AppendChar(_t352, _t353); + _t351 = &sb; + _t352 = (char)92; + StringBuilder_AppendChar(_t351, _t352); + _t353 = &sb; + _t354 = (char)esc; + StringBuilder_AppendChar(_t353, _t354); } - goto endif123; - else122:; - _t354 = (esc == 34); - if (!_t354) goto else124; + endif120:; + endif118:; + endif116:; + endif114:; + endif112:; + endif110:; + endif108:; + JsonParser_Advance(p); + } + goto endif104; + else103:; { _t355 = &sb; - _t356 = (char)34; + _t356 = (char)c; StringBuilder_AppendChar(_t355, _t356); - } - goto endif125; - else124:; - _t357 = (esc == 92); - if (!_t357) goto else126; - { - _t358 = &sb; - _t359 = (char)92; - StringBuilder_AppendChar(_t358, _t359); - } - goto endif127; - else126:; - { - _t360 = &sb; - _t361 = (char)92; - StringBuilder_AppendChar(_t360, _t361); - _t362 = &sb; - _t363 = (char)esc; - StringBuilder_AppendChar(_t362, _t363); - } - endif127:; - endif125:; - endif123:; - endif121:; - endif119:; - endif117:; - endif115:; JsonParser_Advance(p); } - goto endif111; - else110:; - { - _t364 = &sb; - _t365 = (char)c; - StringBuilder_AppendChar(_t364, _t365); - JsonParser_Advance(p); + endif104:; } - endif111:; - } - goto while103; - wend105:; - int _t366; - _t366 = JsonParser_Peek(p); - _t367 = (_t366 != 34); - if (!_t367) goto endif129; + goto while97; + wend98:; + int _t357; + _t357 = JsonParser_Peek(p); + _t358 = (_t357 != 34); + if (!_t358) goto endif122; { p->error = "Unterminated string"; - _t368 = &sb; - StringBuilder_Free(_t368); + _t359 = &sb; + StringBuilder_Free(_t359); return ""; } - endif129:; + endif122:; JsonParser_Advance(p); const char* result; - _t369 = &sb; - const char* _t370; - _t370 = StringBuilder_Build(_t369); - result = _t370; - _t371 = &sb; - StringBuilder_Free(_t371); + _t360 = &sb; + const char* _t361; + _t361 = StringBuilder_Build(_t360); + result = _t361; + _t362 = &sb; + StringBuilder_Free(_t362); return result; } JsonValue JsonParser_ParseNumber(JsonParser* p) { - int _t374; - int _t376; - int _t377; - int _t380; - int _t382; - int _t383; - int _t387; - unsigned int start; - unsigned int _t372; - _t372 = p->pos; - start = _t372; - int c0; + int _t365; + int _t367; + int _t368; + int _t371; int _t373; - _t373 = JsonParser_Peek(p); - c0 = _t373; - _t374 = (c0 == 45); - if (!_t374) goto endif131; + int _t374; + int _t378; + unsigned int start; + unsigned int _t363; + _t363 = p->pos; + start = _t363; + int c0; + int _t364; + _t364 = JsonParser_Peek(p); + c0 = _t364; + _t365 = (c0 == 45); + if (!_t365) goto endif124; { JsonParser_Advance(p); } - endif131:; - while132:; + endif124:; + while125:; + if (!1) goto wend126; + { + int c; + int _t366; + _t366 = JsonParser_Peek(p); + c = _t366; + bool __and_tmp_5; + _t367 = (c >= 48); + if (!_t367) goto else127; + _t368 = (c <= 57); + *(bool*)&__and_tmp_5 = _t368; + goto endif128; + else127:; + *(bool*)&__and_tmp_5 = 0; + endif128:; + bool _t369; + _t369 = *(bool*)&__and_tmp_5; + if (!_t369) goto else129; + { + JsonParser_Advance(p); + } + goto endif130; + else129:; + { + goto wend126; + } + endif130:; + } + goto while125; + wend126:; + int _t370; + _t370 = JsonParser_Peek(p); + _t371 = (_t370 == 46); + if (!_t371) goto endif132; + { + JsonParser_Advance(p); + while133:; if (!1) goto wend134; { int c; - int _t375; - _t375 = JsonParser_Peek(p); - c = _t375; - bool __and_tmp_5; - _t376 = (c >= 48); - if (!_t376) goto else135; - _t377 = (c <= 57); - *(bool*)&__and_tmp_5 = _t377; + int _t372; + _t372 = JsonParser_Peek(p); + c = _t372; + bool __and_tmp_6; + _t373 = (c >= 48); + if (!_t373) goto else135; + _t374 = (c <= 57); + *(bool*)&__and_tmp_6 = _t374; goto endif136; else135:; - *(bool*)&__and_tmp_5 = 0; + *(bool*)&__and_tmp_6 = 0; endif136:; - bool _t378; - _t378 = *(bool*)&__and_tmp_5; - if (!_t378) goto else137; + bool _t375; + _t375 = *(bool*)&__and_tmp_6; + if (!_t375) goto else137; { JsonParser_Advance(p); } @@ -2253,1098 +2289,1061 @@ JsonValue JsonParser_ParseNumber(JsonParser* p) { } endif138:; } - goto while132; + goto while133; wend134:; - int _t379; - _t379 = JsonParser_Peek(p); - _t380 = (_t379 == 46); - if (!_t380) goto endif140; - { - JsonParser_Advance(p); - while141:; - if (!1) goto wend143; - { - int c; - int _t381; - _t381 = JsonParser_Peek(p); - c = _t381; - bool __and_tmp_6; - _t382 = (c >= 48); - if (!_t382) goto else144; - _t383 = (c <= 57); - *(bool*)&__and_tmp_6 = _t383; - goto endif145; - else144:; - *(bool*)&__and_tmp_6 = 0; - endif145:; - bool _t384; - _t384 = *(bool*)&__and_tmp_6; - if (!_t384) goto else146; - { - JsonParser_Advance(p); } - goto endif147; - else146:; - { - goto wend143; - } - endif147:; - } - goto while141; - wend143:; - } - endif140:; + endif132:; const char* numStr; - const char* _t385; - _t385 = p->src; - unsigned int _t386; - _t386 = p->pos; - _t387 = _t386 - start; - const char* _t388; - _t388 = String_Slice(_t385, start, _t387); - numStr = _t388; + const char* _t376; + _t376 = p->src; + unsigned int _t377; + _t377 = p->pos; + _t378 = _t377 - start; + const char* _t379; + _t379 = String_Slice(_t376, start, _t378); + numStr = _t379; double n; - double _t389; - _t389 = String_ToFloat(numStr); - n = _t389; - JsonValue _t390; - _t390 = Json_Number(n); - return _t390; + double _t380; + _t380 = String_ToFloat(numStr); + n = _t380; + JsonValue _t381; + _t381 = Json_Number(n); + return _t381; } JsonValue JsonParser_ParseArray(JsonParser* p) { - int _t393; - int _t396; - void* _t398; - int _t400; - int _t401; + int _t384; + int _t387; + void* _t389; + int _t391; + int _t392; JsonParser_Advance(p); JsonValue arr; - JsonValue _t391; - _t391 = Json_Array(); - arr = _t391; + JsonValue _t382; + _t382 = Json_Array(); + arr = _t382; JsonParser_SkipWhitespace(p); - int _t392; - _t392 = JsonParser_Peek(p); - _t393 = (_t392 == 93); - if (!_t393) goto endif149; + int _t383; + _t383 = JsonParser_Peek(p); + _t384 = (_t383 == 93); + if (!_t384) goto endif140; { JsonParser_Advance(p); return arr; } - endif149:; - while150:; - if (!1) goto wend152; + endif140:; + while141:; + if (!1) goto wend142; { JsonParser_SkipWhitespace(p); JsonValue val; - JsonValue _t394; - _t394 = JsonParser_ParseValue(p); - val = _t394; - const char* _t395; - _t395 = p->error; - _t396 = (_t395 != ""); - if (!_t396) goto endif154; + JsonValue _t385; + _t385 = JsonParser_ParseValue(p); + val = _t385; + const char* _t386; + _t386 = p->error; + _t387 = (_t386 != ""); + if (!_t387) goto endif144; { - JsonValue _t397; - _t397 = Json_Null(); - return _t397; + JsonValue _t388; + _t388 = Json_Null(); + return _t388; } - endif154:; - _t398 = &arr; - Json_ArrayPush(_t398, val); + endif144:; + _t389 = &arr; + Json_ArrayPush(_t389, val); JsonParser_SkipWhitespace(p); int c; - int _t399; - _t399 = JsonParser_Peek(p); - c = _t399; - _t400 = (c == 93); - if (!_t400) goto endif156; + int _t390; + _t390 = JsonParser_Peek(p); + c = _t390; + _t391 = (c == 93); + if (!_t391) goto endif146; { JsonParser_Advance(p); return arr; } - endif156:; - _t401 = (c == 44); - if (!_t401) goto else157; + endif146:; + _t392 = (c == 44); + if (!_t392) goto else147; { JsonParser_Advance(p); } - goto endif158; - else157:; + goto endif148; + else147:; { p->error = "Expected ',' or ']' in array"; - JsonValue _t402; - _t402 = Json_Null(); - return _t402; + JsonValue _t393; + _t393 = Json_Null(); + return _t393; } - endif158:; + endif148:; } - goto while150; - wend152:; + goto while141; + wend142:; } JsonValue JsonParser_ParseObject(JsonParser* p) { - int _t405; - int _t408; + int _t396; + int _t399; + int _t402; + int _t406; + void* _t408; + int _t410; int _t411; - int _t415; - void* _t417; - int _t419; - int _t420; JsonParser_Advance(p); JsonValue obj; - JsonValue _t403; - _t403 = Json_Object(); - obj = _t403; + JsonValue _t394; + _t394 = Json_Object(); + obj = _t394; JsonParser_SkipWhitespace(p); - int _t404; - _t404 = JsonParser_Peek(p); - _t405 = (_t404 == 125); - if (!_t405) goto endif160; + int _t395; + _t395 = JsonParser_Peek(p); + _t396 = (_t395 == 125); + if (!_t396) goto endif150; + { + JsonParser_Advance(p); + return obj; + } + endif150:; + while151:; + if (!1) goto wend152; + { + JsonParser_SkipWhitespace(p); + const char* key; + const char* _t397; + _t397 = JsonParser_ParseString(p); + key = _t397; + const char* _t398; + _t398 = p->error; + _t399 = (_t398 != ""); + if (!_t399) goto endif154; + { + JsonValue _t400; + _t400 = Json_Null(); + return _t400; + } + endif154:; + JsonParser_SkipWhitespace(p); + int _t401; + _t401 = JsonParser_Peek(p); + _t402 = (_t401 != 58); + if (!_t402) goto endif156; + { + p->error = "Expected ':' after object key"; + JsonValue _t403; + _t403 = Json_Null(); + return _t403; + } + endif156:; + JsonParser_Advance(p); + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t404; + _t404 = JsonParser_ParseValue(p); + val = _t404; + const char* _t405; + _t405 = p->error; + _t406 = (_t405 != ""); + if (!_t406) goto endif158; + { + JsonValue _t407; + _t407 = Json_Null(); + return _t407; + } + endif158:; + _t408 = &obj; + Json_ObjectSet(_t408, key, val); + JsonParser_SkipWhitespace(p); + int c; + int _t409; + _t409 = JsonParser_Peek(p); + c = _t409; + _t410 = (c == 125); + if (!_t410) goto endif160; { JsonParser_Advance(p); return obj; } endif160:; - while161:; - if (!1) goto wend163; + _t411 = (c == 44); + if (!_t411) goto else161; { - JsonParser_SkipWhitespace(p); - const char* key; - const char* _t406; - _t406 = JsonParser_ParseString(p); - key = _t406; - const char* _t407; - _t407 = p->error; - _t408 = (_t407 != ""); - if (!_t408) goto endif165; - { - JsonValue _t409; - _t409 = Json_Null(); - return _t409; + JsonParser_Advance(p); } - endif165:; - JsonParser_SkipWhitespace(p); - int _t410; - _t410 = JsonParser_Peek(p); - _t411 = (_t410 != 58); - if (!_t411) goto endif167; + goto endif162; + else161:; { - p->error = "Expected ':' after object key"; + p->error = "Expected ',' or '}' in object"; JsonValue _t412; _t412 = Json_Null(); return _t412; } - endif167:; - JsonParser_Advance(p); - JsonParser_SkipWhitespace(p); - JsonValue val; - JsonValue _t413; - _t413 = JsonParser_ParseValue(p); - val = _t413; - const char* _t414; - _t414 = p->error; - _t415 = (_t414 != ""); - if (!_t415) goto endif169; - { - JsonValue _t416; - _t416 = Json_Null(); - return _t416; + endif162:; } - endif169:; - _t417 = &obj; - Json_ObjectSet(_t417, key, val); - JsonParser_SkipWhitespace(p); - int c; - int _t418; - _t418 = JsonParser_Peek(p); - c = _t418; - _t419 = (c == 125); - if (!_t419) goto endif171; - { - JsonParser_Advance(p); - return obj; - } - endif171:; - _t420 = (c == 44); - if (!_t420) goto else172; - { - JsonParser_Advance(p); - } - goto endif173; - else172:; - { - p->error = "Expected ',' or '}' in object"; - JsonValue _t421; - _t421 = Json_Null(); - return _t421; - } - endif173:; - } - goto while161; - wend163:; + goto while151; + wend152:; } JsonValue JsonParser_ParseValue(JsonParser* p) { + int _t414; + int _t416; + int _t419; + int _t421; int _t423; - int _t425; - int _t428; - int _t430; - int _t432; + int _t427; + int _t431; + int _t435; int _t436; - int _t440; - int _t444; - int _t445; - int _t447; + int _t438; JsonParser_SkipWhitespace(p); int c; - int _t422; - _t422 = JsonParser_Peek(p); - c = _t422; - _t423 = (c == 0); - if (!_t423) goto endif175; + int _t413; + _t413 = JsonParser_Peek(p); + c = _t413; + _t414 = (c == 0); + if (!_t414) goto endif164; { p->error = "Unexpected end of input"; - JsonValue _t424; - _t424 = Json_Null(); - return _t424; + JsonValue _t415; + _t415 = Json_Null(); + return _t415; } - endif175:; - _t425 = (c == 34); - if (!_t425) goto endif177; + endif164:; + _t416 = (c == 34); + if (!_t416) goto endif166; { - const char* _t426; - _t426 = JsonParser_ParseString(p); - JsonValue _t427; - _t427 = Json_String(_t426); - return _t427; + const char* _t417; + _t417 = JsonParser_ParseString(p); + JsonValue _t418; + _t418 = Json_String(_t417); + return _t418; } - endif177:; - _t428 = (c == 123); - if (!_t428) goto endif179; + endif166:; + _t419 = (c == 123); + if (!_t419) goto endif168; + { + JsonValue _t420; + _t420 = JsonParser_ParseObject(p); + return _t420; + } + endif168:; + _t421 = (c == 91); + if (!_t421) goto endif170; + { + JsonValue _t422; + _t422 = JsonParser_ParseArray(p); + return _t422; + } + endif170:; + _t423 = (c == 116); + if (!_t423) goto endif172; + { + bool _t424; + _t424 = JsonParser_Match(p, "true"); + if (!_t424) goto endif174; + { + JsonValue _t425; + _t425 = Json_Bool(1); + return _t425; + } + endif174:; + p->error = "Expected 'true'"; + JsonValue _t426; + _t426 = Json_Null(); + return _t426; + } + endif172:; + _t427 = (c == 102); + if (!_t427) goto endif176; + { + bool _t428; + _t428 = JsonParser_Match(p, "false"); + if (!_t428) goto endif178; { JsonValue _t429; - _t429 = JsonParser_ParseObject(p); + _t429 = Json_Bool(0); return _t429; } - endif179:; - _t430 = (c == 91); - if (!_t430) goto endif181; - { - JsonValue _t431; - _t431 = JsonParser_ParseArray(p); - return _t431; + endif178:; + p->error = "Expected 'false'"; + JsonValue _t430; + _t430 = Json_Null(); + return _t430; } - endif181:; - _t432 = (c == 116); - if (!_t432) goto endif183; + endif176:; + _t431 = (c == 110); + if (!_t431) goto endif180; { - bool _t433; - _t433 = JsonParser_Match(p, "true"); - if (!_t433) goto endif185; + bool _t432; + _t432 = JsonParser_Match(p, "null"); + if (!_t432) goto endif182; { + JsonValue _t433; + _t433 = Json_Null(); + return _t433; + } + endif182:; + p->error = "Expected 'null'"; JsonValue _t434; - _t434 = Json_Bool(1); + _t434 = Json_Null(); return _t434; } - endif185:; - p->error = "Expected 'true'"; - JsonValue _t435; - _t435 = Json_Null(); - return _t435; - } - endif183:; - _t436 = (c == 102); - if (!_t436) goto endif187; - { - bool _t437; - _t437 = JsonParser_Match(p, "false"); - if (!_t437) goto endif189; - { - JsonValue _t438; - _t438 = Json_Bool(0); - return _t438; - } - endif189:; - p->error = "Expected 'false'"; - JsonValue _t439; - _t439 = Json_Null(); - return _t439; - } - endif187:; - _t440 = (c == 110); - if (!_t440) goto endif191; - { - bool _t441; - _t441 = JsonParser_Match(p, "null"); - if (!_t441) goto endif193; - { - JsonValue _t442; - _t442 = Json_Null(); - return _t442; - } - endif193:; - p->error = "Expected 'null'"; - JsonValue _t443; - _t443 = Json_Null(); - return _t443; - } - endif191:; + endif180:; bool __or_tmp_7; bool __and_tmp_8; - _t444 = (c >= 48); - if (!_t444) goto else194; - _t445 = (c <= 57); - *(bool*)&__and_tmp_8 = _t445; - goto endif195; - else194:; + _t435 = (c >= 48); + if (!_t435) goto else183; + _t436 = (c <= 57); + *(bool*)&__and_tmp_8 = _t436; + goto endif184; + else183:; *(bool*)&__and_tmp_8 = 0; - endif195:; - bool _t446; - _t446 = *(bool*)&__and_tmp_8; - if (!_t446) goto else196; + endif184:; + bool _t437; + _t437 = *(bool*)&__and_tmp_8; + if (!_t437) goto else185; *(bool*)&__or_tmp_7 = 1; - goto endif197; - else196:; - _t447 = (c == 45); - *(bool*)&__or_tmp_7 = _t447; - endif197:; - bool _t448; - _t448 = *(bool*)&__or_tmp_7; - if (!_t448) goto endif199; + goto endif186; + else185:; + _t438 = (c == 45); + *(bool*)&__or_tmp_7 = _t438; + endif186:; + bool _t439; + _t439 = *(bool*)&__or_tmp_7; + if (!_t439) goto endif188; { - JsonValue _t449; - _t449 = JsonParser_ParseNumber(p); - return _t449; + JsonValue _t440; + _t440 = JsonParser_ParseNumber(p); + return _t440; } - endif199:; + endif188:; p->error = "Unexpected character"; - JsonValue _t450; - _t450 = Json_Null(); - return _t450; + JsonValue _t441; + _t441 = Json_Null(); + return _t441; } JsonValue Json_Parse(const char* s) { - JsonParser _t452; - void* _t453; - void* _t455; - int _t457; - int _t460; + JsonParser _t443; + void* _t444; + void* _t446; + int _t448; + int _t451; JsonParser p; - unsigned int _t451; - _t451 = String_Len(s); - _t452 = (JsonParser){.src = s, .pos = 0, .len = _t451, .error = ""}; - p = _t452; + unsigned int _t442; + _t442 = String_Len(s); + _t443 = (JsonParser){.src = s, .pos = 0, .len = _t442, .error = ""}; + p = _t443; JsonValue result; - _t453 = &p; - JsonValue _t454; - _t454 = JsonParser_ParseValue(_t453); - result = _t454; - _t455 = &p; - JsonParser_SkipWhitespace(_t455); + _t444 = &p; + JsonValue _t445; + _t445 = JsonParser_ParseValue(_t444); + result = _t445; + _t446 = &p; + JsonParser_SkipWhitespace(_t446); bool __and_tmp_9; - const char* _t456; - _t456 = p.error; - _t457 = (_t456 == ""); - if (!_t457) goto else200; - unsigned int _t458; - _t458 = p.pos; - unsigned int _t459; - _t459 = p.len; - _t460 = (_t458 != _t459); - *(bool*)&__and_tmp_9 = _t460; - goto endif201; - else200:; + const char* _t447; + _t447 = p.error; + _t448 = (_t447 == ""); + if (!_t448) goto else189; + unsigned int _t449; + _t449 = p.pos; + unsigned int _t450; + _t450 = p.len; + _t451 = (_t449 != _t450); + *(bool*)&__and_tmp_9 = _t451; + goto endif190; + else189:; *(bool*)&__and_tmp_9 = 0; - endif201:; - bool _t461; - _t461 = *(bool*)&__and_tmp_9; - if (!_t461) goto endif203; + endif190:; + bool _t452; + _t452 = *(bool*)&__and_tmp_9; + if (!_t452) goto endif192; { p.error = "Trailing data after JSON value"; - JsonValue _t462; - _t462 = Json_Null(); - return _t462; + JsonValue _t453; + _t453 = Json_Null(); + return _t453; } - endif203:; + endif192:; return result; } void Json_StringifyImpl(StringBuilder* sb, JsonValue v) { - int _t464; - int _t466; - int _t469; + int _t455; + int _t457; + int _t460; + int _t463; + char _t464; + char _t466; + int _t468; + char _t469; + int _t471; int _t472; char _t473; - char _t475; - int _t477; - char _t478; - int _t480; - int _t481; - char _t482; - int _t485; - char _t486; - int _t488; + int _t476; + char _t477; + int _t479; + char _t480; + int _t482; + int _t483; + char _t484; + char _t485; + char _t488; char _t489; - int _t491; int _t492; char _t493; - char _t494; - char _t497; - char _t498; - int _t501; - char _t502; - int _t463; - _t463 = v.tag; - _t464 = (_t463 == JsonTagNull); - if (!_t464) goto endif205; + int _t454; + _t454 = v.tag; + _t455 = (_t454 == JsonTagNull); + if (!_t455) goto endif194; { StringBuilder_Append(sb, "null"); return; } - endif205:; - int _t465; - _t465 = v.tag; - _t466 = (_t465 == JsonTagBool); - if (!_t466) goto endif207; + endif194:; + int _t456; + _t456 = v.tag; + _t457 = (_t456 == JsonTagBool); + if (!_t457) goto endif196; { - bool _t467; - _t467 = v.boolVal; - if (!_t467) goto else208; + bool _t458; + _t458 = v.boolVal; + if (!_t458) goto else197; { StringBuilder_Append(sb, "true"); } - goto endif209; - else208:; + goto endif198; + else197:; { StringBuilder_Append(sb, "false"); } - endif209:; + endif198:; return; } - endif207:; - int _t468; - _t468 = v.tag; - _t469 = (_t468 == JsonTagNumber); - if (!_t469) goto endif211; + endif196:; + int _t459; + _t459 = v.tag; + _t460 = (_t459 == JsonTagNumber); + if (!_t460) goto endif200; { - double _t470; - _t470 = v.numVal; - StringBuilder_AppendFloat(sb, _t470); + double _t461; + _t461 = v.numVal; + StringBuilder_AppendFloat(sb, _t461); return; } - endif211:; - int _t471; - _t471 = v.tag; - _t472 = (_t471 == JsonTagString); - if (!_t472) goto endif213; + endif200:; + int _t462; + _t462 = v.tag; + _t463 = (_t462 == JsonTagString); + if (!_t463) goto endif202; { - _t473 = (char)34; + _t464 = (char)34; + StringBuilder_AppendChar(sb, _t464); + const char* _t465; + _t465 = v.strVal; + StringBuilder_Append(sb, _t465); + _t466 = (char)34; + StringBuilder_AppendChar(sb, _t466); + return; + } + endif202:; + int _t467; + _t467 = v.tag; + _t468 = (_t467 == JsonTagArray); + if (!_t468) goto endif204; + { + _t469 = (char)91; + StringBuilder_AppendChar(sb, _t469); + unsigned int i; + i = 0; + while205:; + unsigned int _t470; + _t470 = v.arrLen; + _t471 = (i < _t470); + if (!_t471) goto wend206; + { + _t472 = (i > 0); + if (!_t472) goto endif208; + { + _t473 = (char)44; StringBuilder_AppendChar(sb, _t473); - const char* _t474; - _t474 = v.strVal; - StringBuilder_Append(sb, _t474); - _t475 = (char)34; - StringBuilder_AppendChar(sb, _t475); + } + endif208:; + JsonValue* _t474; + _t474 = v.arrData; + JsonValue _t475; + _t475 = _t474[i]; + Json_StringifyImpl(sb, _t475); + _t476 = i + 1; + i = _t476; + } + goto while205; + wend206:; + _t477 = (char)93; + StringBuilder_AppendChar(sb, _t477); return; } - endif213:; - int _t476; - _t476 = v.tag; - _t477 = (_t476 == JsonTagArray); - if (!_t477) goto endif215; + endif204:; + int _t478; + _t478 = v.tag; + _t479 = (_t478 == JsonTagObject); + if (!_t479) goto endif210; { - _t478 = (char)91; - StringBuilder_AppendChar(sb, _t478); + _t480 = (char)123; + StringBuilder_AppendChar(sb, _t480); unsigned int i; i = 0; - while216:; - unsigned int _t479; - _t479 = v.arrLen; - _t480 = (i < _t479); - if (!_t480) goto wend218; + while211:; + unsigned int _t481; + _t481 = v.objLen; + _t482 = (i < _t481); + if (!_t482) goto wend212; { - _t481 = (i > 0); - if (!_t481) goto endif220; + _t483 = (i > 0); + if (!_t483) goto endif214; { - _t482 = (char)44; - StringBuilder_AppendChar(sb, _t482); + _t484 = (char)44; + StringBuilder_AppendChar(sb, _t484); } - endif220:; - JsonValue* _t483; - _t483 = v.arrData; - JsonValue _t484; - _t484 = _t483[i]; - Json_StringifyImpl(sb, _t484); - _t485 = i + 1; - i = _t485; - } - goto while216; - wend218:; - _t486 = (char)93; - StringBuilder_AppendChar(sb, _t486); - return; - } - endif215:; - int _t487; - _t487 = v.tag; - _t488 = (_t487 == JsonTagObject); - if (!_t488) goto endif222; - { - _t489 = (char)123; + endif214:; + _t485 = (char)34; + StringBuilder_AppendChar(sb, _t485); + const char** _t486; + _t486 = v.objKeys; + const char* _t487; + _t487 = _t486[i]; + StringBuilder_Append(sb, _t487); + _t488 = (char)34; + StringBuilder_AppendChar(sb, _t488); + _t489 = (char)58; StringBuilder_AppendChar(sb, _t489); - unsigned int i; - i = 0; - while223:; - unsigned int _t490; - _t490 = v.objLen; - _t491 = (i < _t490); - if (!_t491) goto wend225; - { - _t492 = (i > 0); - if (!_t492) goto endif227; - { - _t493 = (char)44; + JsonValue* _t490; + _t490 = v.objValues; + JsonValue _t491; + _t491 = _t490[i]; + Json_StringifyImpl(sb, _t491); + _t492 = i + 1; + i = _t492; + } + goto while211; + wend212:; + _t493 = (char)125; StringBuilder_AppendChar(sb, _t493); - } - endif227:; - _t494 = (char)34; - StringBuilder_AppendChar(sb, _t494); - const char** _t495; - _t495 = v.objKeys; - const char* _t496; - _t496 = _t495[i]; - StringBuilder_Append(sb, _t496); - _t497 = (char)34; - StringBuilder_AppendChar(sb, _t497); - _t498 = (char)58; - StringBuilder_AppendChar(sb, _t498); - JsonValue* _t499; - _t499 = v.objValues; - JsonValue _t500; - _t500 = _t499[i]; - Json_StringifyImpl(sb, _t500); - _t501 = i + 1; - i = _t501; - } - goto while223; - wend225:; - _t502 = (char)125; - StringBuilder_AppendChar(sb, _t502); return; } - endif222:; + endif210:; } const char* Json_Stringify(JsonValue v) { - void* _t504; - void* _t505; + void* _t495; + void* _t496; StringBuilder sb; - StringBuilder _t503; - _t503 = StringBuilder_New(); - sb = _t503; - _t504 = &sb; - Json_StringifyImpl(_t504, v); - _t505 = &sb; - const char* _t506; - _t506 = StringBuilder_Build(_t505); - return _t506; + StringBuilder _t494; + _t494 = StringBuilder_New(); + sb = _t494; + _t495 = &sb; + Json_StringifyImpl(_t495, v); + _t496 = &sb; + const char* _t497; + _t497 = StringBuilder_Build(_t496); + return _t497; } unsigned int String_Len(const char* s) { - unsigned int _t507; - _t507 = bux_strlen(s); - return _t507; + unsigned int _t498; + _t498 = bux_strlen(s); + return _t498; } bool String_IsNull(const char* s) { - int _t509; - int _t508; - _t508 = bux_str_is_null(s); - _t509 = (_t508 != 0); - return _t509; + int _t500; + int _t499; + _t499 = bux_str_is_null(s); + _t500 = (_t499 != 0); + return _t500; } bool String_Eq(const char* a, const char* b) { - int _t511; - int _t510; - _t510 = bux_strcmp(a, b); - _t511 = (_t510 == 0); - return _t511; + int _t502; + int _t501; + _t501 = bux_strcmp(a, b); + _t502 = (_t501 == 0); + return _t502; } const char* String_Concat(const char* a, const char* b) { - int _t514; - int _t515; - char* _t517; + int _t505; + int _t506; + char* _t508; unsigned int len_a; - unsigned int _t512; - _t512 = bux_strlen(a); - len_a = _t512; + unsigned int _t503; + _t503 = bux_strlen(a); + len_a = _t503; unsigned int len_b; - unsigned int _t513; - _t513 = bux_strlen(b); - len_b = _t513; + unsigned int _t504; + _t504 = bux_strlen(b); + len_b = _t504; unsigned int total; - _t514 = len_a + len_b; - _t515 = _t514 + 1; - total = _t515; + _t505 = len_a + len_b; + _t506 = _t505 + 1; + total = _t506; char* buf; - void* _t516; - _t516 = bux_alloc(total); - _t517 = (char*)_t516; - buf = _t517; + void* _t507; + _t507 = bux_alloc(total); + _t508 = (char*)_t507; + buf = _t508; bux_strcpy(buf, a); bux_strcat(buf, b); return buf; } const char* String_Copy(const char* s) { - int _t519; - char* _t521; + int _t510; + char* _t512; unsigned int len; - unsigned int _t518; - _t518 = bux_strlen(s); - len = _t518; + unsigned int _t509; + _t509 = bux_strlen(s); + len = _t509; char* buf; - _t519 = len + 1; - void* _t520; - _t520 = bux_alloc(_t519); - _t521 = (char*)_t520; - buf = _t521; + _t510 = len + 1; + void* _t511; + _t511 = bux_alloc(_t510); + _t512 = (char*)_t511; + buf = _t512; bux_strcpy(buf, s); return buf; } bool String_StartsWith(const char* s, const char* prefix) { - int _t524; - int _t526; + int _t515; + int _t517; unsigned int s_len; - unsigned int _t522; - _t522 = bux_strlen(s); - s_len = _t522; + unsigned int _t513; + _t513 = bux_strlen(s); + s_len = _t513; unsigned int p_len; - unsigned int _t523; - _t523 = bux_strlen(prefix); - p_len = _t523; - _t524 = (p_len > s_len); - if (!_t524) goto endif229; + unsigned int _t514; + _t514 = bux_strlen(prefix); + p_len = _t514; + _t515 = (p_len > s_len); + if (!_t515) goto endif216; { return 0; } - endif229:; + endif216:; int r; - int _t525; - _t525 = bux_strncmp(s, prefix, p_len); - r = _t525; - _t526 = (r == 0); - return _t526; + int _t516; + _t516 = bux_strncmp(s, prefix, p_len); + r = _t516; + _t517 = (r == 0); + return _t517; } bool String_EndsWith(const char* s, const char* suffix) { - int _t529; - int _t530; - int _t533; + int _t520; + int _t521; + int _t524; unsigned int s_len; - unsigned int _t527; - _t527 = bux_strlen(s); - s_len = _t527; + unsigned int _t518; + _t518 = bux_strlen(s); + s_len = _t518; unsigned int suf_len; - unsigned int _t528; - _t528 = bux_strlen(suffix); - suf_len = _t528; - _t529 = (suf_len > s_len); - if (!_t529) goto endif231; + unsigned int _t519; + _t519 = bux_strlen(suffix); + suf_len = _t519; + _t520 = (suf_len > s_len); + if (!_t520) goto endif218; { return 0; } - endif231:; + endif218:; unsigned int start; - _t530 = s_len - suf_len; - start = _t530; + _t521 = s_len - suf_len; + start = _t521; const char* tail; - const char* _t531; - _t531 = bux_str_slice(s, start, suf_len); - tail = _t531; + const char* _t522; + _t522 = bux_str_slice(s, start, suf_len); + tail = _t522; bool eq; - int _t532; - _t532 = bux_strcmp(tail, suffix); - _t533 = (_t532 == 0); - eq = _t533; + int _t523; + _t523 = bux_strcmp(tail, suffix); + _t524 = (_t523 == 0); + eq = _t524; return eq; } bool String_Contains(const char* s, const char* substr) { - int _t535; + int _t526; int r; - int _t534; - _t534 = bux_str_contains(s, substr); - r = _t534; - _t535 = (r != 0); - return _t535; + int _t525; + _t525 = bux_str_contains(s, substr); + r = _t525; + _t526 = (r != 0); + return _t526; } const char* String_Slice(const char* s, unsigned int start, unsigned int len) { - const char* _t536; - _t536 = bux_str_slice(s, start, len); - return _t536; + const char* _t527; + _t527 = bux_str_slice(s, start, len); + return _t527; } const char* String_Trim(const char* s) { - const char* _t537; - _t537 = bux_str_trim(s); - return _t537; + const char* _t528; + _t528 = bux_str_trim(s); + return _t528; } const char* String_TrimLeft(const char* s) { - const char* _t538; - _t538 = bux_str_trim_left(s); - return _t538; + const char* _t529; + _t529 = bux_str_trim_left(s); + return _t529; } const char* String_TrimRight(const char* s) { - const char* _t539; - _t539 = bux_str_trim_right(s); - return _t539; + const char* _t530; + _t530 = bux_str_trim_right(s); + return _t530; } const char* String_FromInt(int64_t n) { - const char* _t540; - _t540 = bux_int_to_str(n); - return _t540; + const char* _t531; + _t531 = bux_int_to_str(n); + return _t531; } int64_t String_ToInt(const char* s) { - int64_t _t541; - _t541 = bux_str_to_int(s); - return _t541; + int64_t _t532; + _t532 = bux_str_to_int(s); + return _t532; } StringBuilder StringBuilder_New(void) { - StringBuilder _t543; - void* _t542; - _t542 = bux_sb_new(64); - _t543 = (StringBuilder){.handle = _t542}; - return _t543; + StringBuilder _t534; + void* _t533; + _t533 = bux_sb_new(64); + _t534 = (StringBuilder){.handle = _t533}; + return _t534; } StringBuilder StringBuilder_NewCap(unsigned int cap) { - StringBuilder _t545; - void* _t544; - _t544 = bux_sb_new(cap); - _t545 = (StringBuilder){.handle = _t544}; - return _t545; + StringBuilder _t536; + void* _t535; + _t535 = bux_sb_new(cap); + _t536 = (StringBuilder){.handle = _t535}; + return _t536; } void StringBuilder_Append(StringBuilder* sb, const char* s) { - void* _t546; - _t546 = sb->handle; - bux_sb_append(_t546, s); + void* _t537; + _t537 = sb->handle; + bux_sb_append(_t537, s); } void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) { - void* _t547; - _t547 = sb->handle; - bux_sb_append_int(_t547, n); + void* _t538; + _t538 = sb->handle; + bux_sb_append_int(_t538, n); } void StringBuilder_AppendFloat(StringBuilder* sb, double f) { - void* _t548; - _t548 = sb->handle; - bux_sb_append_float(_t548, f); + void* _t539; + _t539 = sb->handle; + bux_sb_append_float(_t539, f); } void StringBuilder_AppendChar(StringBuilder* sb, char c) { - void* _t549; - _t549 = sb->handle; - bux_sb_append_char(_t549, c); + void* _t540; + _t540 = sb->handle; + bux_sb_append_char(_t540, c); } const char* StringBuilder_Build(StringBuilder* sb) { - void* _t550; - _t550 = sb->handle; - const char* _t551; - _t551 = bux_sb_build(_t550); - return _t551; + void* _t541; + _t541 = sb->handle; + const char* _t542; + _t542 = bux_sb_build(_t541); + return _t542; } void StringBuilder_Free(StringBuilder* sb) { - void* _t552; - _t552 = sb->handle; - bux_sb_free(_t552); + void* _t543; + _t543 = sb->handle; + bux_sb_free(_t543); } unsigned int String_SplitCount(const char* s, const char* delim) { - unsigned int _t553; - _t553 = bux_str_split_count(s, delim); - return _t553; + unsigned int _t544; + _t544 = bux_str_split_count(s, delim); + return _t544; } const char* String_SplitPart(const char* s, const char* delim, unsigned int index) { - const char* _t554; - _t554 = bux_str_split_part(s, delim, index); - return _t554; + const char* _t545; + _t545 = bux_str_split_part(s, delim, index); + return _t545; } const char* String_Join2(const char* a, const char* b, const char* sep) { - const char* _t555; - _t555 = bux_str_join2(a, b, sep); - return _t555; + const char* _t546; + _t546 = bux_str_join2(a, b, sep); + return _t546; } const char* String_Chars(const char* s, unsigned int index) { - const char* _t556; - _t556 = bux_str_slice(s, index, 1); - return _t556; + const char* _t547; + _t547 = bux_str_slice(s, index, 1); + return _t547; } const char* String_Find(const char* haystack, const char* needle) { - const char* _t557; - _t557 = bux_strstr(haystack, needle); - return _t557; + const char* _t548; + _t548 = bux_strstr(haystack, needle); + return _t548; } unsigned int String_Offset(const char* pos, const char* base) { - unsigned int _t558; - _t558 = bux_str_offset(pos, base); - return _t558; + unsigned int _t549; + _t549 = bux_str_offset(pos, base); + return _t549; } const char* String_Replace(const char* s, const char* old, const char* new) { - int _t564; - int _t566; - int _t567; + int _t555; + int _t557; + int _t558; const char* pos; - const char* _t559; - _t559 = bux_strstr(s, old); - pos = _t559; - bool _t560; - _t560 = String_IsNull(pos); - if (!_t560) goto endif233; + const char* _t550; + _t550 = bux_strstr(s, old); + pos = _t550; + bool _t551; + _t551 = String_IsNull(pos); + if (!_t551) goto endif220; { return s; } - endif233:; + endif220:; unsigned int oldLen; - unsigned int _t561; - _t561 = bux_strlen(old); - oldLen = _t561; + unsigned int _t552; + _t552 = bux_strlen(old); + oldLen = _t552; unsigned int prefixLen; - unsigned int _t562; - _t562 = String_Offset(pos, s); - prefixLen = _t562; + unsigned int _t553; + _t553 = String_Offset(pos, s); + prefixLen = _t553; const char* prefix; - const char* _t563; - _t563 = bux_str_slice(s, 0, prefixLen); - prefix = _t563; + const char* _t554; + _t554 = bux_str_slice(s, 0, prefixLen); + prefix = _t554; const char* suffix; - _t564 = prefixLen + oldLen; - unsigned int _t565; - _t565 = bux_strlen(s); - _t566 = _t565 - prefixLen; - _t567 = _t566 - oldLen; - const char* _t568; - _t568 = bux_str_slice(s, _t564, _t567); - suffix = _t568; + _t555 = prefixLen + oldLen; + unsigned int _t556; + _t556 = bux_strlen(s); + _t557 = _t556 - prefixLen; + _t558 = _t557 - oldLen; + const char* _t559; + _t559 = bux_str_slice(s, _t555, _t558); + suffix = _t559; const char* temp; - const char* _t569; - _t569 = String_Concat(prefix, new); - temp = _t569; + const char* _t560; + _t560 = String_Concat(prefix, new); + temp = _t560; const char* result; - const char* _t570; - _t570 = String_Concat(temp, suffix); - result = _t570; + const char* _t561; + _t561 = String_Concat(temp, suffix); + result = _t561; return result; } double String_ToFloat(const char* s) { - double _t571; - _t571 = bux_str_to_float(s); - return _t571; + double _t562; + _t562 = bux_str_to_float(s); + return _t562; } const char* String_FromBool(bool b) { - if (!b) goto endif235; + if (!b) goto endif222; { return "true"; } - endif235:; + endif222:; return "false"; } const char* String_FromFloat(double f) { - const char* _t572; - _t572 = bux_float_to_string(f); - return _t572; + const char* _t563; + _t563 = bux_float_to_string(f); + return _t563; } const char* String_Format1(const char* pattern, const char* a0) { - const char* _t573; - _t573 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); - return _t573; + const char* _t564; + _t564 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); + return _t564; } const char* String_Format2(const char* pattern, const char* a0, const char* a1) { - const char* _t574; - _t574 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); - return _t574; + const char* _t565; + _t565 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); + return _t565; } const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) { - const char* _t575; - _t575 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); - return _t575; + const char* _t566; + _t566 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); + return _t566; } void Channel_SendInt(Channel_int* ch, int value) { - void* _t577; - void* _t578; - void* _t576; - _t576 = ch->handle; - _t577 = &value; - _t578 = (void*)_t577; - bux_channel_send(_t576, _t578); + void* _t568; + void* _t569; + void* _t567; + _t567 = ch->handle; + _t568 = &value; + _t569 = (void*)_t568; + bux_channel_send(_t567, _t569); } int Channel_RecvInt(Channel_int* ch) { - void* _t580; - void* _t581; + void* _t571; + void* _t572; int result; result = 0; - void* _t579; - _t579 = ch->handle; - _t580 = &result; - _t581 = (void*)_t580; - bux_channel_recv(_t579, _t581); + void* _t570; + _t570 = ch->handle; + _t571 = &result; + _t572 = (void*)_t571; + bux_channel_recv(_t570, _t572); return result; } void Channel_SendFloat64(Channel_float64* ch, double value) { - void* _t583; - void* _t584; - void* _t582; - _t582 = ch->handle; - _t583 = &value; - _t584 = (void*)_t583; - bux_channel_send(_t582, _t584); + void* _t574; + void* _t575; + void* _t573; + _t573 = ch->handle; + _t574 = &value; + _t575 = (void*)_t574; + bux_channel_send(_t573, _t575); } double Channel_RecvFloat64(Channel_float64* ch) { - void* _t586; - void* _t587; + void* _t577; + void* _t578; double result; result = 0.0; - void* _t585; - _t585 = ch->handle; - _t586 = &result; - _t587 = (void*)_t586; - bux_channel_recv(_t585, _t587); + void* _t576; + _t576 = ch->handle; + _t577 = &result; + _t578 = (void*)_t577; + bux_channel_recv(_t576, _t578); return result; } const char* Hash_Sha1(const char* data) { - int _t589; + int _t580; int len; - unsigned int _t588; - _t588 = String_Len(data); - _t589 = (int)_t588; - len = _t589; + unsigned int _t579; + _t579 = String_Len(data); + _t580 = (int)_t579; + len = _t580; void* buf; - void* _t590; - _t590 = Alloc(20); - buf = _t590; + void* _t581; + _t581 = Alloc(20); + buf = _t581; bux_sha1(data, len, buf); const char* result; - const char* _t591; - _t591 = bux_bytes_to_hex(buf, 20); - result = _t591; + const char* _t582; + _t582 = bux_bytes_to_hex(buf, 20); + result = _t582; Free(buf); return result; } const char* Hash_Sha256(const char* data) { - int _t593; + int _t584; int len; - unsigned int _t592; - _t592 = String_Len(data); - _t593 = (int)_t592; - len = _t593; + unsigned int _t583; + _t583 = String_Len(data); + _t584 = (int)_t583; + len = _t584; void* buf; - void* _t594; - _t594 = Alloc(32); - buf = _t594; + void* _t585; + _t585 = Alloc(32); + buf = _t585; bux_sha256(data, len, buf); const char* result; - const char* _t595; - _t595 = bux_bytes_to_hex(buf, 32); - result = _t595; + const char* _t586; + _t586 = bux_bytes_to_hex(buf, 32); + result = _t586; Free(buf); return result; } const char* Hash_Sha384(const char* data) { - int _t597; + int _t588; int len; - unsigned int _t596; - _t596 = String_Len(data); - _t597 = (int)_t596; - len = _t597; + unsigned int _t587; + _t587 = String_Len(data); + _t588 = (int)_t587; + len = _t588; void* buf; - void* _t598; - _t598 = Alloc(48); - buf = _t598; + void* _t589; + _t589 = Alloc(48); + buf = _t589; bux_sha384(data, len, buf); const char* result; - const char* _t599; - _t599 = bux_bytes_to_hex(buf, 48); - result = _t599; + const char* _t590; + _t590 = bux_bytes_to_hex(buf, 48); + result = _t590; Free(buf); return result; } const char* Hash_Sha512(const char* data) { - int _t601; + int _t592; int len; - unsigned int _t600; - _t600 = String_Len(data); - _t601 = (int)_t600; - len = _t601; + unsigned int _t591; + _t591 = String_Len(data); + _t592 = (int)_t591; + len = _t592; void* buf; - void* _t602; - _t602 = Alloc(64); - buf = _t602; + void* _t593; + _t593 = Alloc(64); + buf = _t593; bux_sha512(data, len, buf); const char* result; - const char* _t603; - _t603 = bux_bytes_to_hex(buf, 64); - result = _t603; + const char* _t594; + _t594 = bux_bytes_to_hex(buf, 64); + result = _t594; Free(buf); return result; } void Hash_Sha256Raw(const char* data, void* out) { - int _t605; - unsigned int _t604; - _t604 = String_Len(data); - _t605 = (int)_t604; - bux_sha256(data, _t605, out); + int _t596; + unsigned int _t595; + _t595 = String_Len(data); + _t596 = (int)_t595; + bux_sha256(data, _t596, out); } void Hash_Sha384Raw(const char* data, void* out) { - int _t607; - unsigned int _t606; - _t606 = String_Len(data); - _t607 = (int)_t606; - bux_sha384(data, _t607, out); + int _t598; + unsigned int _t597; + _t597 = String_Len(data); + _t598 = (int)_t597; + bux_sha384(data, _t598, out); } void Hash_Sha512Raw(const char* data, void* out) { - int _t609; - unsigned int _t608; - _t608 = String_Len(data); - _t609 = (int)_t608; - bux_sha512(data, _t609, out); + int _t600; + unsigned int _t599; + _t599 = String_Len(data); + _t600 = (int)_t599; + bux_sha512(data, _t600, out); } int Hash_Sha1Size(void) { @@ -3364,1497 +3363,1497 @@ int Hash_Sha512Size(void) { } const char* Base64_Encode(const char* s) { - int _t611; - unsigned int _t610; - _t610 = String_Len(s); - _t611 = (int)_t610; - const char* _t612; - _t612 = bux_base64_encode(s, _t611); - return _t612; + int _t602; + unsigned int _t601; + _t601 = String_Len(s); + _t602 = (int)_t601; + const char* _t603; + _t603 = bux_base64_encode(s, _t602); + return _t603; } const char* Base64_Decode(const char* s) { - int _t614; - void* _t615; + int _t605; + void* _t606; int outlen; outlen = 0; - unsigned int _t613; - _t613 = String_Len(s); - _t614 = (int)_t613; - _t615 = &outlen; - const char* _t616; - _t616 = bux_base64_decode(s, _t614, _t615); - return _t616; + unsigned int _t604; + _t604 = String_Len(s); + _t605 = (int)_t604; + _t606 = &outlen; + const char* _t607; + _t607 = bux_base64_decode(s, _t605, _t606); + return _t607; } const char* Base64URL_Encode(const char* s) { - int _t618; - unsigned int _t617; - _t617 = String_Len(s); - _t618 = (int)_t617; - const char* _t619; - _t619 = bux_base64url_encode(s, _t618); - return _t619; + int _t609; + unsigned int _t608; + _t608 = String_Len(s); + _t609 = (int)_t608; + const char* _t610; + _t610 = bux_base64url_encode(s, _t609); + return _t610; } const char* Base64URL_Decode(const char* s) { - int _t621; - void* _t622; + int _t612; + void* _t613; int outlen; outlen = 0; - unsigned int _t620; - _t620 = String_Len(s); - _t621 = (int)_t620; - _t622 = &outlen; - const char* _t623; - _t623 = bux_base64url_decode(s, _t621, _t622); - return _t623; + unsigned int _t611; + _t611 = String_Len(s); + _t612 = (int)_t611; + _t613 = &outlen; + const char* _t614; + _t614 = bux_base64url_decode(s, _t612, _t613); + return _t614; } const char* Hmac_Sha256(const char* key, const char* message) { - int _t625; - int _t627; + int _t616; + int _t618; int kl; - unsigned int _t624; - _t624 = String_Len(key); - _t625 = (int)_t624; - kl = _t625; + unsigned int _t615; + _t615 = String_Len(key); + _t616 = (int)_t615; + kl = _t616; int ml; - unsigned int _t626; - _t626 = String_Len(message); - _t627 = (int)_t626; - ml = _t627; + unsigned int _t617; + _t617 = String_Len(message); + _t618 = (int)_t617; + ml = _t618; void* buf; - void* _t628; - _t628 = Alloc(32); - buf = _t628; + void* _t619; + _t619 = Alloc(32); + buf = _t619; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - const char* _t629; - _t629 = bux_bytes_to_hex(buf, 32); - result = _t629; + const char* _t620; + _t620 = bux_bytes_to_hex(buf, 32); + result = _t620; Free(buf); return result; } void Hmac_Sha256Raw(const char* key, const char* message, void* out) { - int _t631; - int _t633; - unsigned int _t630; - _t630 = String_Len(key); - _t631 = (int)_t630; - unsigned int _t632; - _t632 = String_Len(message); - _t633 = (int)_t632; - bux_hmac_sha256(key, _t631, message, _t633, out); + int _t622; + int _t624; + unsigned int _t621; + _t621 = String_Len(key); + _t622 = (int)_t621; + unsigned int _t623; + _t623 = String_Len(message); + _t624 = (int)_t623; + bux_hmac_sha256(key, _t622, message, _t624, out); } const char* Hmac_Sha256Base64(const char* key, const char* message) { - int _t635; - int _t637; - const char* _t639; + int _t626; + int _t628; + const char* _t630; int kl; - unsigned int _t634; - _t634 = String_Len(key); - _t635 = (int)_t634; - kl = _t635; + unsigned int _t625; + _t625 = String_Len(key); + _t626 = (int)_t625; + kl = _t626; int ml; - unsigned int _t636; - _t636 = String_Len(message); - _t637 = (int)_t636; - ml = _t637; + unsigned int _t627; + _t627 = String_Len(message); + _t628 = (int)_t627; + ml = _t628; void* buf; - void* _t638; - _t638 = Alloc(32); - buf = _t638; + void* _t629; + _t629 = Alloc(32); + buf = _t629; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - _t639 = (const char*)buf; - const char* _t640; - _t640 = bux_base64_encode(_t639, 32); - result = _t640; + _t630 = (const char*)buf; + const char* _t631; + _t631 = bux_base64_encode(_t630, 32); + result = _t631; Free(buf); return result; } const char* Hmac_Sha384(const char* key, const char* message) { - int _t642; - int _t644; + int _t633; + int _t635; int kl; - unsigned int _t641; - _t641 = String_Len(key); - _t642 = (int)_t641; - kl = _t642; + unsigned int _t632; + _t632 = String_Len(key); + _t633 = (int)_t632; + kl = _t633; int ml; - unsigned int _t643; - _t643 = String_Len(message); - _t644 = (int)_t643; - ml = _t644; + unsigned int _t634; + _t634 = String_Len(message); + _t635 = (int)_t634; + ml = _t635; void* buf; - void* _t645; - _t645 = Alloc(48); - buf = _t645; + void* _t636; + _t636 = Alloc(48); + buf = _t636; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - const char* _t646; - _t646 = bux_bytes_to_hex(buf, 48); - result = _t646; + const char* _t637; + _t637 = bux_bytes_to_hex(buf, 48); + result = _t637; Free(buf); return result; } void Hmac_Sha384Raw(const char* key, const char* message, void* out) { - int _t648; - int _t650; - unsigned int _t647; - _t647 = String_Len(key); - _t648 = (int)_t647; - unsigned int _t649; - _t649 = String_Len(message); - _t650 = (int)_t649; - bux_hmac_sha384(key, _t648, message, _t650, out); + int _t639; + int _t641; + unsigned int _t638; + _t638 = String_Len(key); + _t639 = (int)_t638; + unsigned int _t640; + _t640 = String_Len(message); + _t641 = (int)_t640; + bux_hmac_sha384(key, _t639, message, _t641, out); } const char* Hmac_Sha384Base64(const char* key, const char* message) { - int _t652; - int _t654; - const char* _t656; + int _t643; + int _t645; + const char* _t647; int kl; - unsigned int _t651; - _t651 = String_Len(key); - _t652 = (int)_t651; - kl = _t652; + unsigned int _t642; + _t642 = String_Len(key); + _t643 = (int)_t642; + kl = _t643; int ml; - unsigned int _t653; - _t653 = String_Len(message); - _t654 = (int)_t653; - ml = _t654; + unsigned int _t644; + _t644 = String_Len(message); + _t645 = (int)_t644; + ml = _t645; void* buf; - void* _t655; - _t655 = Alloc(48); - buf = _t655; + void* _t646; + _t646 = Alloc(48); + buf = _t646; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - _t656 = (const char*)buf; - const char* _t657; - _t657 = bux_base64_encode(_t656, 48); - result = _t657; + _t647 = (const char*)buf; + const char* _t648; + _t648 = bux_base64_encode(_t647, 48); + result = _t648; Free(buf); return result; } const char* Hmac_Sha512(const char* key, const char* message) { - int _t659; - int _t661; + int _t650; + int _t652; int kl; - unsigned int _t658; - _t658 = String_Len(key); - _t659 = (int)_t658; - kl = _t659; + unsigned int _t649; + _t649 = String_Len(key); + _t650 = (int)_t649; + kl = _t650; int ml; - unsigned int _t660; - _t660 = String_Len(message); - _t661 = (int)_t660; - ml = _t661; + unsigned int _t651; + _t651 = String_Len(message); + _t652 = (int)_t651; + ml = _t652; void* buf; - void* _t662; - _t662 = Alloc(64); - buf = _t662; + void* _t653; + _t653 = Alloc(64); + buf = _t653; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - const char* _t663; - _t663 = bux_bytes_to_hex(buf, 64); - result = _t663; + const char* _t654; + _t654 = bux_bytes_to_hex(buf, 64); + result = _t654; Free(buf); return result; } void Hmac_Sha512Raw(const char* key, const char* message, void* out) { - int _t665; - int _t667; - unsigned int _t664; - _t664 = String_Len(key); - _t665 = (int)_t664; - unsigned int _t666; - _t666 = String_Len(message); - _t667 = (int)_t666; - bux_hmac_sha512(key, _t665, message, _t667, out); + int _t656; + int _t658; + unsigned int _t655; + _t655 = String_Len(key); + _t656 = (int)_t655; + unsigned int _t657; + _t657 = String_Len(message); + _t658 = (int)_t657; + bux_hmac_sha512(key, _t656, message, _t658, out); } const char* Hmac_Sha512Base64(const char* key, const char* message) { - int _t669; - int _t671; - const char* _t673; + int _t660; + int _t662; + const char* _t664; int kl; - unsigned int _t668; - _t668 = String_Len(key); - _t669 = (int)_t668; - kl = _t669; + unsigned int _t659; + _t659 = String_Len(key); + _t660 = (int)_t659; + kl = _t660; int ml; - unsigned int _t670; - _t670 = String_Len(message); - _t671 = (int)_t670; - ml = _t671; + unsigned int _t661; + _t661 = String_Len(message); + _t662 = (int)_t661; + ml = _t662; void* buf; - void* _t672; - _t672 = Alloc(64); - buf = _t672; + void* _t663; + _t663 = Alloc(64); + buf = _t663; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - _t673 = (const char*)buf; - const char* _t674; - _t674 = bux_base64_encode(_t673, 64); - result = _t674; + _t664 = (const char*)buf; + const char* _t665; + _t665 = bux_base64_encode(_t664, 64); + result = _t665; Free(buf); return result; } const char* Random_Bytes(int n) { - int _t675; - unsigned int _t676; - int _t679; - const char* _t680; - _t675 = (n <= 0); - if (!_t675) goto endif237; + int _t666; + unsigned int _t667; + int _t670; + const char* _t671; + _t666 = (n <= 0); + if (!_t666) goto endif224; { return ""; } - endif237:; + endif224:; void* buf; - _t676 = (unsigned int)n; - void* _t677; - _t677 = Alloc(_t676); - buf = _t677; - int _t678; - _t678 = bux_random_bytes(buf, n); - _t679 = (_t678 != 1); - if (!_t679) goto endif239; + _t667 = (unsigned int)n; + void* _t668; + _t668 = Alloc(_t667); + buf = _t668; + int _t669; + _t669 = bux_random_bytes(buf, n); + _t670 = (_t669 != 1); + if (!_t670) goto endif226; { Free(buf); return ""; } - endif239:; - _t680 = (const char*)buf; - return _t680; + endif226:; + _t671 = (const char*)buf; + return _t671; } const char* Random_Hex(int n) { - int _t681; - unsigned int _t682; - int _t685; - _t681 = (n <= 0); - if (!_t681) goto endif241; + int _t672; + unsigned int _t673; + int _t676; + _t672 = (n <= 0); + if (!_t672) goto endif228; { return ""; } - endif241:; + endif228:; void* buf; - _t682 = (unsigned int)n; - void* _t683; - _t683 = Alloc(_t682); - buf = _t683; - int _t684; - _t684 = bux_random_bytes(buf, n); - _t685 = (_t684 != 1); - if (!_t685) goto endif243; + _t673 = (unsigned int)n; + void* _t674; + _t674 = Alloc(_t673); + buf = _t674; + int _t675; + _t675 = bux_random_bytes(buf, n); + _t676 = (_t675 != 1); + if (!_t676) goto endif230; { Free(buf); return ""; } - endif243:; + endif230:; const char* result; - const char* _t686; - _t686 = bux_bytes_to_hex(buf, n); - result = _t686; + const char* _t677; + _t677 = bux_bytes_to_hex(buf, n); + result = _t677; Free(buf); return result; } const char* Random_Base64(int n) { - int _t687; - unsigned int _t688; - int _t691; - const char* _t692; - _t687 = (n <= 0); - if (!_t687) goto endif245; + int _t678; + unsigned int _t679; + int _t682; + const char* _t683; + _t678 = (n <= 0); + if (!_t678) goto endif232; { return ""; } - endif245:; + endif232:; void* buf; - _t688 = (unsigned int)n; - void* _t689; - _t689 = Alloc(_t688); - buf = _t689; - int _t690; - _t690 = bux_random_bytes(buf, n); - _t691 = (_t690 != 1); - if (!_t691) goto endif247; + _t679 = (unsigned int)n; + void* _t680; + _t680 = Alloc(_t679); + buf = _t680; + int _t681; + _t681 = bux_random_bytes(buf, n); + _t682 = (_t681 != 1); + if (!_t682) goto endif234; { Free(buf); return ""; } - endif247:; + endif234:; const char* result; - _t692 = (const char*)buf; - const char* _t693; - _t693 = bux_base64_encode(_t692, n); - result = _t693; + _t683 = (const char*)buf; + const char* _t684; + _t684 = bux_base64_encode(_t683, n); + result = _t684; Free(buf); return result; } unsigned int Random_Uint32(void) { - int _t696; - unsigned int* _t697; - unsigned int _t698; + int _t687; + unsigned int* _t688; + unsigned int _t689; void* buf; - void* _t694; - _t694 = Alloc(4); - buf = _t694; - int _t695; - _t695 = bux_random_bytes(buf, 4); - _t696 = (_t695 != 1); - if (!_t696) goto endif249; + void* _t685; + _t685 = Alloc(4); + buf = _t685; + int _t686; + _t686 = bux_random_bytes(buf, 4); + _t687 = (_t686 != 1); + if (!_t687) goto endif236; { Free(buf); return 0; } - endif249:; + endif236:; unsigned int* ptr; - _t697 = (unsigned int*)buf; - ptr = _t697; + _t688 = (unsigned int*)buf; + ptr = _t688; unsigned int val; - _t698 = *ptr; - val = _t698; + _t689 = *ptr; + val = _t689; Free(buf); return val; } const char* Aes_GenerateKey(void) { - unsigned int _t699; - int _t702; - const char* _t703; + unsigned int _t690; + int _t693; + const char* _t694; void* buf; - _t699 = (unsigned int)AES_KEY_SIZE; - void* _t700; - _t700 = Alloc(_t699); - buf = _t700; - int _t701; - _t701 = bux_random_bytes(buf, AES_KEY_SIZE); - _t702 = (_t701 != 1); - if (!_t702) goto endif251; + _t690 = (unsigned int)AES_KEY_SIZE; + void* _t691; + _t691 = Alloc(_t690); + buf = _t691; + int _t692; + _t692 = bux_random_bytes(buf, AES_KEY_SIZE); + _t693 = (_t692 != 1); + if (!_t693) goto endif238; { Free(buf); return ""; } - endif251:; - _t703 = (const char*)buf; - return _t703; + endif238:; + _t694 = (const char*)buf; + return _t694; } const char* Aes_GenerateIV(void) { - unsigned int _t704; - int _t707; - const char* _t708; + unsigned int _t695; + int _t698; + const char* _t699; void* buf; - _t704 = (unsigned int)AES_IV_SIZE; - void* _t705; - _t705 = Alloc(_t704); - buf = _t705; - int _t706; - _t706 = bux_random_bytes(buf, AES_IV_SIZE); - _t707 = (_t706 != 1); - if (!_t707) goto endif253; + _t695 = (unsigned int)AES_IV_SIZE; + void* _t696; + _t696 = Alloc(_t695); + buf = _t696; + int _t697; + _t697 = bux_random_bytes(buf, AES_IV_SIZE); + _t698 = (_t697 != 1); + if (!_t698) goto endif240; { Free(buf); return ""; } - endif253:; - _t708 = (const char*)buf; - return _t708; + endif240:; + _t699 = (const char*)buf; + return _t699; } const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv) { - int _t710; - void* _t711; + int _t701; + void* _t702; int outlen; outlen = 0; - unsigned int _t709; - _t709 = String_Len(plain); - _t710 = (int)_t709; - _t711 = &outlen; - const char* _t712; - _t712 = bux_aes_256_cbc_encrypt(plain, _t710, key, iv, _t711); - return _t712; + unsigned int _t700; + _t700 = String_Len(plain); + _t701 = (int)_t700; + _t702 = &outlen; + const char* _t703; + _t703 = bux_aes_256_cbc_encrypt(plain, _t701, key, iv, _t702); + return _t703; } const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv) { - int _t714; - void* _t715; + int _t705; + void* _t706; int outlen; outlen = 0; - unsigned int _t713; - _t713 = String_Len(cipher); - _t714 = (int)_t713; - _t715 = &outlen; - const char* _t716; - _t716 = bux_aes_256_cbc_decrypt(cipher, _t714, key, iv, _t715); - return _t716; + unsigned int _t704; + _t704 = String_Len(cipher); + _t705 = (int)_t704; + _t706 = &outlen; + const char* _t707; + _t707 = bux_aes_256_cbc_decrypt(cipher, _t705, key, iv, _t706); + return _t707; } const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag) { - int _t718; - void* _t719; + int _t709; + void* _t710; int outlen; outlen = 0; - unsigned int _t717; - _t717 = String_Len(plain); - _t718 = (int)_t717; - _t719 = &outlen; - const char* _t720; - _t720 = bux_aes_256_gcm_encrypt(plain, _t718, key, iv, tag, _t719); - return _t720; + unsigned int _t708; + _t708 = String_Len(plain); + _t709 = (int)_t708; + _t710 = &outlen; + const char* _t711; + _t711 = bux_aes_256_gcm_encrypt(plain, _t709, key, iv, tag, _t710); + return _t711; } const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag) { - int _t722; - void* _t723; + int _t713; + void* _t714; int outlen; outlen = 0; - unsigned int _t721; - _t721 = String_Len(cipher); - _t722 = (int)_t721; - _t723 = &outlen; - const char* _t724; - _t724 = bux_aes_256_gcm_decrypt(cipher, _t722, key, iv, tag, _t723); - return _t724; + unsigned int _t712; + _t712 = String_Len(cipher); + _t713 = (int)_t712; + _t714 = &outlen; + const char* _t715; + _t715 = bux_aes_256_gcm_decrypt(cipher, _t713, key, iv, tag, _t714); + return _t715; } const char* Jwt_MakeHeader(JwtAlg alg) { - int _t725; - int _t726; - int _t727; - int _t728; - int _t729; - int _t730; - int _t731; - int _t732; - int _t733; - _t725 = (alg == JwtAlg_HS256); - if (!_t725) goto endif255; + int _t716; + int _t717; + int _t718; + int _t719; + int _t720; + int _t721; + int _t722; + int _t723; + int _t724; + _t716 = (alg == JwtAlg_HS256); + if (!_t716) goto endif242; { return "{\"alg\":\"HS256\",\"typ\":\"JWT\"}"; } - endif255:; - _t726 = (alg == JwtAlg_HS384); - if (!_t726) goto endif257; + endif242:; + _t717 = (alg == JwtAlg_HS384); + if (!_t717) goto endif244; { return "{\"alg\":\"HS384\",\"typ\":\"JWT\"}"; } - endif257:; - _t727 = (alg == JwtAlg_HS512); - if (!_t727) goto endif259; + endif244:; + _t718 = (alg == JwtAlg_HS512); + if (!_t718) goto endif246; { return "{\"alg\":\"HS512\",\"typ\":\"JWT\"}"; } - endif259:; - _t728 = (alg == JwtAlg_RS256); - if (!_t728) goto endif261; + endif246:; + _t719 = (alg == JwtAlg_RS256); + if (!_t719) goto endif248; { return "{\"alg\":\"RS256\",\"typ\":\"JWT\"}"; } - endif261:; - _t729 = (alg == JwtAlg_RS384); - if (!_t729) goto endif263; + endif248:; + _t720 = (alg == JwtAlg_RS384); + if (!_t720) goto endif250; { return "{\"alg\":\"RS384\",\"typ\":\"JWT\"}"; } - endif263:; - _t730 = (alg == JwtAlg_RS512); - if (!_t730) goto endif265; + endif250:; + _t721 = (alg == JwtAlg_RS512); + if (!_t721) goto endif252; { return "{\"alg\":\"RS512\",\"typ\":\"JWT\"}"; } - endif265:; - _t731 = (alg == JwtAlg_ES256); - if (!_t731) goto endif267; + endif252:; + _t722 = (alg == JwtAlg_ES256); + if (!_t722) goto endif254; { return "{\"alg\":\"ES256\",\"typ\":\"JWT\"}"; } - endif267:; - _t732 = (alg == JwtAlg_ES384); - if (!_t732) goto endif269; + endif254:; + _t723 = (alg == JwtAlg_ES384); + if (!_t723) goto endif256; { return "{\"alg\":\"ES384\",\"typ\":\"JWT\"}"; } - endif269:; - _t733 = (alg == JwtAlg_EdDSA); - if (!_t733) goto endif271; + endif256:; + _t724 = (alg == JwtAlg_EdDSA); + if (!_t724) goto endif258; { return "{\"alg\":\"EdDSA\",\"typ\":\"JWT\"}"; } - endif271:; + endif258:; return "{\"alg\":\"none\",\"typ\":\"JWT\"}"; } const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key) { - int _t734; - const char* _t736; - int _t738; - const char* _t740; + int _t725; + const char* _t727; + int _t729; + const char* _t731; + int _t733; + const char* _t735; + int _t737; + int _t740; int _t742; - const char* _t744; - int _t746; - int _t749; - int _t751; - int _t754; - int _t756; - int _t759; - int _t761; - int _t764; - int _t766; - int _t769; - int _t771; - _t734 = (alg == JwtAlg_HS256); - if (!_t734) goto endif273; + int _t745; + int _t747; + int _t750; + int _t752; + int _t755; + int _t757; + int _t760; + int _t762; + _t725 = (alg == JwtAlg_HS256); + if (!_t725) goto endif260; { void* buf; - void* _t735; - _t735 = Alloc(32); - buf = _t735; + void* _t726; + _t726 = Alloc(32); + buf = _t726; Hmac_Sha256Raw(key, signingInput, buf); const char* result; - _t736 = (const char*)buf; - const char* _t737; - _t737 = bux_base64_encode(_t736, 32); - result = _t737; + _t727 = (const char*)buf; + const char* _t728; + _t728 = bux_base64_encode(_t727, 32); + result = _t728; Free(buf); return result; } - endif273:; - _t738 = (alg == JwtAlg_HS384); - if (!_t738) goto endif275; + endif260:; + _t729 = (alg == JwtAlg_HS384); + if (!_t729) goto endif262; { void* buf; - void* _t739; - _t739 = Alloc(48); - buf = _t739; + void* _t730; + _t730 = Alloc(48); + buf = _t730; Hmac_Sha384Raw(key, signingInput, buf); const char* result; - _t740 = (const char*)buf; - const char* _t741; - _t741 = bux_base64_encode(_t740, 48); - result = _t741; + _t731 = (const char*)buf; + const char* _t732; + _t732 = bux_base64_encode(_t731, 48); + result = _t732; Free(buf); return result; } - endif275:; - _t742 = (alg == JwtAlg_HS512); - if (!_t742) goto endif277; + endif262:; + _t733 = (alg == JwtAlg_HS512); + if (!_t733) goto endif264; { void* buf; - void* _t743; - _t743 = Alloc(64); - buf = _t743; + void* _t734; + _t734 = Alloc(64); + buf = _t734; Hmac_Sha512Raw(key, signingInput, buf); const char* result; - _t744 = (const char*)buf; - const char* _t745; - _t745 = bux_base64_encode(_t744, 64); - result = _t745; + _t735 = (const char*)buf; + const char* _t736; + _t736 = bux_base64_encode(_t735, 64); + result = _t736; Free(buf); return result; } - endif277:; - _t746 = (alg == JwtAlg_RS256); - if (!_t746) goto endif279; + endif264:; + _t737 = (alg == JwtAlg_RS256); + if (!_t737) goto endif266; { const char* raw; - const char* _t747; - _t747 = Rsa_SignSha256(key, signingInput); - raw = _t747; - unsigned int _t748; - _t748 = String_Len(raw); - _t749 = (int)_t748; - const char* _t750; - _t750 = bux_base64_encode(raw, _t749); - return _t750; + const char* _t738; + _t738 = Rsa_SignSha256(key, signingInput); + raw = _t738; + unsigned int _t739; + _t739 = String_Len(raw); + _t740 = (int)_t739; + const char* _t741; + _t741 = bux_base64_encode(raw, _t740); + return _t741; } - endif279:; - _t751 = (alg == JwtAlg_RS384); - if (!_t751) goto endif281; + endif266:; + _t742 = (alg == JwtAlg_RS384); + if (!_t742) goto endif268; { const char* raw; - const char* _t752; - _t752 = Rsa_SignSha384(key, signingInput); - raw = _t752; - unsigned int _t753; - _t753 = String_Len(raw); - _t754 = (int)_t753; - const char* _t755; - _t755 = bux_base64_encode(raw, _t754); - return _t755; + const char* _t743; + _t743 = Rsa_SignSha384(key, signingInput); + raw = _t743; + unsigned int _t744; + _t744 = String_Len(raw); + _t745 = (int)_t744; + const char* _t746; + _t746 = bux_base64_encode(raw, _t745); + return _t746; } - endif281:; - _t756 = (alg == JwtAlg_RS512); - if (!_t756) goto endif283; + endif268:; + _t747 = (alg == JwtAlg_RS512); + if (!_t747) goto endif270; { const char* raw; - const char* _t757; - _t757 = Rsa_SignSha512(key, signingInput); - raw = _t757; - unsigned int _t758; - _t758 = String_Len(raw); - _t759 = (int)_t758; - const char* _t760; - _t760 = bux_base64_encode(raw, _t759); - return _t760; + const char* _t748; + _t748 = Rsa_SignSha512(key, signingInput); + raw = _t748; + unsigned int _t749; + _t749 = String_Len(raw); + _t750 = (int)_t749; + const char* _t751; + _t751 = bux_base64_encode(raw, _t750); + return _t751; } - endif283:; - _t761 = (alg == JwtAlg_ES256); - if (!_t761) goto endif285; + endif270:; + _t752 = (alg == JwtAlg_ES256); + if (!_t752) goto endif272; { const char* raw; - const char* _t762; - _t762 = Ecdsa_SignP256(key, signingInput); - raw = _t762; - unsigned int _t763; - _t763 = String_Len(raw); - _t764 = (int)_t763; - const char* _t765; - _t765 = bux_base64_encode(raw, _t764); - return _t765; + const char* _t753; + _t753 = Ecdsa_SignP256(key, signingInput); + raw = _t753; + unsigned int _t754; + _t754 = String_Len(raw); + _t755 = (int)_t754; + const char* _t756; + _t756 = bux_base64_encode(raw, _t755); + return _t756; } - endif285:; - _t766 = (alg == JwtAlg_ES384); - if (!_t766) goto endif287; + endif272:; + _t757 = (alg == JwtAlg_ES384); + if (!_t757) goto endif274; { const char* raw; - const char* _t767; - _t767 = Ecdsa_SignP384(key, signingInput); - raw = _t767; - unsigned int _t768; - _t768 = String_Len(raw); - _t769 = (int)_t768; - const char* _t770; - _t770 = bux_base64_encode(raw, _t769); - return _t770; + const char* _t758; + _t758 = Ecdsa_SignP384(key, signingInput); + raw = _t758; + unsigned int _t759; + _t759 = String_Len(raw); + _t760 = (int)_t759; + const char* _t761; + _t761 = bux_base64_encode(raw, _t760); + return _t761; } - endif287:; - _t771 = (alg == JwtAlg_EdDSA); - if (!_t771) goto endif289; + endif274:; + _t762 = (alg == JwtAlg_EdDSA); + if (!_t762) goto endif276; { - const char* _t772; - _t772 = Ed25519_Sign(key, signingInput); - return _t772; + const char* _t763; + _t763 = Ed25519_Sign(key, signingInput); + return _t763; } - endif289:; + endif276:; return ""; } bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key) { - int _t773; - const char* _t775; - int _t778; - const char* _t780; + int _t764; + const char* _t766; + int _t769; + const char* _t771; + int _t774; + const char* _t776; + int _t779; + int _t781; int _t783; - const char* _t785; - int _t788; - int _t790; - int _t792; - int _t794; - int _t796; - int _t798; - _t773 = (alg == JwtAlg_HS256); - if (!_t773) goto endif291; + int _t785; + int _t787; + int _t789; + _t764 = (alg == JwtAlg_HS256); + if (!_t764) goto endif278; { void* expectBuf; - void* _t774; - _t774 = Alloc(32); - expectBuf = _t774; + void* _t765; + _t765 = Alloc(32); + expectBuf = _t765; Hmac_Sha256Raw(key, signingInput, expectBuf); const char* expectB64; - _t775 = (const char*)expectBuf; - const char* _t776; - _t776 = bux_base64_encode(_t775, 32); - expectB64 = _t776; + _t766 = (const char*)expectBuf; + const char* _t767; + _t767 = bux_base64_encode(_t766, 32); + expectB64 = _t767; Free(expectBuf); - bool _t777; - _t777 = String_Eq(expectB64, signatureB64); - return _t777; + bool _t768; + _t768 = String_Eq(expectB64, signatureB64); + return _t768; } - endif291:; - _t778 = (alg == JwtAlg_HS384); - if (!_t778) goto endif293; + endif278:; + _t769 = (alg == JwtAlg_HS384); + if (!_t769) goto endif280; { void* expectBuf; - void* _t779; - _t779 = Alloc(48); - expectBuf = _t779; + void* _t770; + _t770 = Alloc(48); + expectBuf = _t770; Hmac_Sha384Raw(key, signingInput, expectBuf); const char* expectB64; - _t780 = (const char*)expectBuf; - const char* _t781; - _t781 = bux_base64_encode(_t780, 48); - expectB64 = _t781; + _t771 = (const char*)expectBuf; + const char* _t772; + _t772 = bux_base64_encode(_t771, 48); + expectB64 = _t772; Free(expectBuf); - bool _t782; - _t782 = String_Eq(expectB64, signatureB64); - return _t782; + bool _t773; + _t773 = String_Eq(expectB64, signatureB64); + return _t773; } - endif293:; - _t783 = (alg == JwtAlg_HS512); - if (!_t783) goto endif295; + endif280:; + _t774 = (alg == JwtAlg_HS512); + if (!_t774) goto endif282; { void* expectBuf; - void* _t784; - _t784 = Alloc(64); - expectBuf = _t784; + void* _t775; + _t775 = Alloc(64); + expectBuf = _t775; Hmac_Sha512Raw(key, signingInput, expectBuf); const char* expectB64; - _t785 = (const char*)expectBuf; - const char* _t786; - _t786 = bux_base64_encode(_t785, 64); - expectB64 = _t786; + _t776 = (const char*)expectBuf; + const char* _t777; + _t777 = bux_base64_encode(_t776, 64); + expectB64 = _t777; Free(expectBuf); - bool _t787; - _t787 = String_Eq(expectB64, signatureB64); - return _t787; + bool _t778; + _t778 = String_Eq(expectB64, signatureB64); + return _t778; } - endif295:; - _t788 = (alg == JwtAlg_RS256); - if (!_t788) goto endif297; + endif282:; + _t779 = (alg == JwtAlg_RS256); + if (!_t779) goto endif284; { - bool _t789; - _t789 = Rsa_VerifySha256(key, signingInput, signatureB64); - return _t789; + bool _t780; + _t780 = Rsa_VerifySha256(key, signingInput, signatureB64); + return _t780; } - endif297:; - _t790 = (alg == JwtAlg_RS384); - if (!_t790) goto endif299; + endif284:; + _t781 = (alg == JwtAlg_RS384); + if (!_t781) goto endif286; { - bool _t791; - _t791 = Rsa_VerifySha384(key, signingInput, signatureB64); - return _t791; + bool _t782; + _t782 = Rsa_VerifySha384(key, signingInput, signatureB64); + return _t782; } - endif299:; - _t792 = (alg == JwtAlg_RS512); - if (!_t792) goto endif301; + endif286:; + _t783 = (alg == JwtAlg_RS512); + if (!_t783) goto endif288; { - bool _t793; - _t793 = Rsa_VerifySha512(key, signingInput, signatureB64); - return _t793; + bool _t784; + _t784 = Rsa_VerifySha512(key, signingInput, signatureB64); + return _t784; } - endif301:; - _t794 = (alg == JwtAlg_ES256); - if (!_t794) goto endif303; + endif288:; + _t785 = (alg == JwtAlg_ES256); + if (!_t785) goto endif290; { - bool _t795; - _t795 = Ecdsa_VerifyP256(key, signingInput, signatureB64); - return _t795; + bool _t786; + _t786 = Ecdsa_VerifyP256(key, signingInput, signatureB64); + return _t786; } - endif303:; - _t796 = (alg == JwtAlg_ES384); - if (!_t796) goto endif305; + endif290:; + _t787 = (alg == JwtAlg_ES384); + if (!_t787) goto endif292; { - bool _t797; - _t797 = Ecdsa_VerifyP384(key, signingInput, signatureB64); - return _t797; + bool _t788; + _t788 = Ecdsa_VerifyP384(key, signingInput, signatureB64); + return _t788; } - endif305:; - _t798 = (alg == JwtAlg_EdDSA); - if (!_t798) goto endif307; + endif292:; + _t789 = (alg == JwtAlg_EdDSA); + if (!_t789) goto endif294; { - bool _t799; - _t799 = Ed25519_Verify(key, signatureB64, signingInput); - return _t799; + bool _t790; + _t790 = Ed25519_Verify(key, signatureB64, signingInput); + return _t790; } - endif307:; + endif294:; return 0; } const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key) { const char* headerB64; - const char* _t800; - _t800 = Base64URL_Encode(headerJson); - headerB64 = _t800; + const char* _t791; + _t791 = Base64URL_Encode(headerJson); + headerB64 = _t791; const char* payloadB64; - const char* _t801; - _t801 = Base64URL_Encode(payloadJson); - payloadB64 = _t801; + const char* _t792; + _t792 = Base64URL_Encode(payloadJson); + payloadB64 = _t792; const char* signingInput; - const char* _t802; - _t802 = String_Concat(headerB64, "."); - signingInput = _t802; + const char* _t793; + _t793 = String_Concat(headerB64, "."); + signingInput = _t793; const char* signingInputFull; - const char* _t803; - _t803 = String_Concat(signingInput, payloadB64); - signingInputFull = _t803; + const char* _t794; + _t794 = String_Concat(signingInput, payloadB64); + signingInputFull = _t794; const char* sigB64; - const char* _t804; - _t804 = Jwt_Sign(alg, signingInputFull, key); - sigB64 = _t804; + const char* _t795; + _t795 = Jwt_Sign(alg, signingInputFull, key); + sigB64 = _t795; const char* part1; - const char* _t805; - _t805 = String_Concat(signingInputFull, "."); - part1 = _t805; - const char* _t806; - _t806 = String_Concat(part1, sigB64); - return _t806; + const char* _t796; + _t796 = String_Concat(signingInputFull, "."); + part1 = _t796; + const char* _t797; + _t797 = String_Concat(part1, sigB64); + return _t797; } bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut) { - int _t808; - int _t815; + int _t799; + int _t806; unsigned int partCount; - unsigned int _t807; - _t807 = bux_str_split_count(token, "."); - partCount = _t807; - _t808 = (partCount != 3); - if (!_t808) goto endif309; + unsigned int _t798; + _t798 = bux_str_split_count(token, "."); + partCount = _t798; + _t799 = (partCount != 3); + if (!_t799) goto endif296; { return 0; } - endif309:; + endif296:; const char* headerB64; - const char* _t809; - _t809 = bux_str_split_part(token, ".", 0); - headerB64 = _t809; + const char* _t800; + _t800 = bux_str_split_part(token, ".", 0); + headerB64 = _t800; const char* payloadB64; - const char* _t810; - _t810 = bux_str_split_part(token, ".", 1); - payloadB64 = _t810; + const char* _t801; + _t801 = bux_str_split_part(token, ".", 1); + payloadB64 = _t801; const char* sigB64; - const char* _t811; - _t811 = bux_str_split_part(token, ".", 2); - sigB64 = _t811; + const char* _t802; + _t802 = bux_str_split_part(token, ".", 2); + sigB64 = _t802; const char* input; - const char* _t812; - _t812 = String_Concat(headerB64, "."); - input = _t812; + const char* _t803; + _t803 = String_Concat(headerB64, "."); + input = _t803; const char* signingInput; - const char* _t813; - _t813 = String_Concat(input, payloadB64); - signingInput = _t813; - bool _t814; - _t814 = Jwt_Verify(alg, signingInput, sigB64, key); - _t815 = !_t814; - if (!_t815) goto endif311; + const char* _t804; + _t804 = String_Concat(input, payloadB64); + signingInput = _t804; + bool _t805; + _t805 = Jwt_Verify(alg, signingInput, sigB64, key); + _t806 = !_t805; + if (!_t806) goto endif298; { return 0; } - endif311:; - const char* _t816; - _t816 = Base64URL_Decode(headerB64); - headerOut[0] = _t816; - const char* _t817; - _t817 = Base64URL_Decode(payloadB64); - payloadOut[0] = _t817; + endif298:; + const char* _t807; + _t807 = Base64URL_Decode(headerB64); + headerOut[0] = _t807; + const char* _t808; + _t808 = Base64URL_Decode(payloadB64); + payloadOut[0] = _t808; return 1; } const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret) { const char* header; - const char* _t818; - _t818 = Jwt_MakeHeader(JwtAlg_HS256); - header = _t818; - const char* _t819; - _t819 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); - return _t819; + const char* _t809; + _t809 = Jwt_MakeHeader(JwtAlg_HS256); + header = _t809; + const char* _t810; + _t810 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); + return _t810; } const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret) { const char* header; - const char* _t820; - _t820 = Jwt_MakeHeader(JwtAlg_HS384); - header = _t820; - const char* _t821; - _t821 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); - return _t821; + const char* _t811; + _t811 = Jwt_MakeHeader(JwtAlg_HS384); + header = _t811; + const char* _t812; + _t812 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); + return _t812; } const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret) { const char* header; - const char* _t822; - _t822 = Jwt_MakeHeader(JwtAlg_HS512); - header = _t822; - const char* _t823; - _t823 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); - return _t823; + const char* _t813; + _t813 = Jwt_MakeHeader(JwtAlg_HS512); + header = _t813; + const char* _t814; + _t814 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); + return _t814; } const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t824; - _t824 = Jwt_MakeHeader(JwtAlg_RS256); - header = _t824; - const char* _t825; - _t825 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); - return _t825; + const char* _t815; + _t815 = Jwt_MakeHeader(JwtAlg_RS256); + header = _t815; + const char* _t816; + _t816 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); + return _t816; } const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t826; - _t826 = Jwt_MakeHeader(JwtAlg_ES256); - header = _t826; - const char* _t827; - _t827 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); - return _t827; + const char* _t817; + _t817 = Jwt_MakeHeader(JwtAlg_ES256); + header = _t817; + const char* _t818; + _t818 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); + return _t818; } const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey) { const char* header; - const char* _t828; - _t828 = Jwt_MakeHeader(JwtAlg_EdDSA); - header = _t828; - const char* _t829; - _t829 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); - return _t829; + const char* _t819; + _t819 = Jwt_MakeHeader(JwtAlg_EdDSA); + header = _t819; + const char* _t820; + _t820 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); + return _t820; } const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data) { - int _t831; - int _t833; - void* _t834; + int _t822; + int _t824; + void* _t825; int siglen; siglen = 0; - unsigned int _t830; - _t830 = String_Len(pemPrivateKey); - _t831 = (int)_t830; - unsigned int _t832; - _t832 = String_Len(data); - _t833 = (int)_t832; - _t834 = &siglen; - const char* _t835; - _t835 = bux_ecdsa_sign_p256(pemPrivateKey, _t831, data, _t833, _t834); - return _t835; + unsigned int _t821; + _t821 = String_Len(pemPrivateKey); + _t822 = (int)_t821; + unsigned int _t823; + _t823 = String_Len(data); + _t824 = (int)_t823; + _t825 = &siglen; + const char* _t826; + _t826 = bux_ecdsa_sign_p256(pemPrivateKey, _t822, data, _t824, _t825); + return _t826; } const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data) { - int _t838; + int _t829; const char* raw; - const char* _t836; - _t836 = Ecdsa_SignP256(pemPrivateKey, data); - raw = _t836; - unsigned int _t837; - _t837 = String_Len(raw); - _t838 = (int)_t837; - const char* _t839; - _t839 = bux_base64_encode(raw, _t838); - return _t839; + const char* _t827; + _t827 = Ecdsa_SignP256(pemPrivateKey, data); + raw = _t827; + unsigned int _t828; + _t828 = String_Len(raw); + _t829 = (int)_t828; + const char* _t830; + _t830 = bux_base64_encode(raw, _t829); + return _t830; } bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature) { - int _t841; - int _t843; - int _t845; - int _t847; + int _t832; + int _t834; + int _t836; + int _t838; int r; - unsigned int _t840; - _t840 = String_Len(pemPublicKey); - _t841 = (int)_t840; - unsigned int _t842; - _t842 = String_Len(data); - _t843 = (int)_t842; - unsigned int _t844; - _t844 = String_Len(signature); - _t845 = (int)_t844; - int _t846; - _t846 = bux_ecdsa_verify_p256(pemPublicKey, _t841, data, _t843, signature, _t845); - r = _t846; - _t847 = (r == 1); - return _t847; + unsigned int _t831; + _t831 = String_Len(pemPublicKey); + _t832 = (int)_t831; + unsigned int _t833; + _t833 = String_Len(data); + _t834 = (int)_t833; + unsigned int _t835; + _t835 = String_Len(signature); + _t836 = (int)_t835; + int _t837; + _t837 = bux_ecdsa_verify_p256(pemPublicKey, _t832, data, _t834, signature, _t836); + r = _t837; + _t838 = (r == 1); + return _t838; } bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t849; - void* _t850; + int _t840; + void* _t841; int outlen; outlen = 0; const char* sig; - unsigned int _t848; - _t848 = String_Len(signatureB64); - _t849 = (int)_t848; - _t850 = &outlen; - const char* _t851; - _t851 = bux_base64_decode(signatureB64, _t849, _t850); - sig = _t851; - bool _t852; - _t852 = Ecdsa_VerifyP256(pemPublicKey, data, sig); - return _t852; + unsigned int _t839; + _t839 = String_Len(signatureB64); + _t840 = (int)_t839; + _t841 = &outlen; + const char* _t842; + _t842 = bux_base64_decode(signatureB64, _t840, _t841); + sig = _t842; + bool _t843; + _t843 = Ecdsa_VerifyP256(pemPublicKey, data, sig); + return _t843; } const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data) { - int _t854; - int _t856; - void* _t857; + int _t845; + int _t847; + void* _t848; int siglen; siglen = 0; - unsigned int _t853; - _t853 = String_Len(pemPrivateKey); - _t854 = (int)_t853; - unsigned int _t855; - _t855 = String_Len(data); - _t856 = (int)_t855; - _t857 = &siglen; - const char* _t858; - _t858 = bux_ecdsa_sign_p384(pemPrivateKey, _t854, data, _t856, _t857); - return _t858; + unsigned int _t844; + _t844 = String_Len(pemPrivateKey); + _t845 = (int)_t844; + unsigned int _t846; + _t846 = String_Len(data); + _t847 = (int)_t846; + _t848 = &siglen; + const char* _t849; + _t849 = bux_ecdsa_sign_p384(pemPrivateKey, _t845, data, _t847, _t848); + return _t849; } const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data) { - int _t861; + int _t852; const char* raw; - const char* _t859; - _t859 = Ecdsa_SignP384(pemPrivateKey, data); - raw = _t859; - unsigned int _t860; - _t860 = String_Len(raw); - _t861 = (int)_t860; - const char* _t862; - _t862 = bux_base64_encode(raw, _t861); - return _t862; + const char* _t850; + _t850 = Ecdsa_SignP384(pemPrivateKey, data); + raw = _t850; + unsigned int _t851; + _t851 = String_Len(raw); + _t852 = (int)_t851; + const char* _t853; + _t853 = bux_base64_encode(raw, _t852); + return _t853; } bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature) { - int _t864; - int _t866; - int _t868; - int _t870; + int _t855; + int _t857; + int _t859; + int _t861; int r; - unsigned int _t863; - _t863 = String_Len(pemPublicKey); - _t864 = (int)_t863; - unsigned int _t865; - _t865 = String_Len(data); - _t866 = (int)_t865; - unsigned int _t867; - _t867 = String_Len(signature); - _t868 = (int)_t867; - int _t869; - _t869 = bux_ecdsa_verify_p384(pemPublicKey, _t864, data, _t866, signature, _t868); - r = _t869; - _t870 = (r == 1); - return _t870; + unsigned int _t854; + _t854 = String_Len(pemPublicKey); + _t855 = (int)_t854; + unsigned int _t856; + _t856 = String_Len(data); + _t857 = (int)_t856; + unsigned int _t858; + _t858 = String_Len(signature); + _t859 = (int)_t858; + int _t860; + _t860 = bux_ecdsa_verify_p384(pemPublicKey, _t855, data, _t857, signature, _t859); + r = _t860; + _t861 = (r == 1); + return _t861; } bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t872; - void* _t873; + int _t863; + void* _t864; int outlen; outlen = 0; const char* sig; - unsigned int _t871; - _t871 = String_Len(signatureB64); - _t872 = (int)_t871; - _t873 = &outlen; - const char* _t874; - _t874 = bux_base64_decode(signatureB64, _t872, _t873); - sig = _t874; - bool _t875; - _t875 = Ecdsa_VerifyP384(pemPublicKey, data, sig); - return _t875; + unsigned int _t862; + _t862 = String_Len(signatureB64); + _t863 = (int)_t862; + _t864 = &outlen; + const char* _t865; + _t865 = bux_base64_decode(signatureB64, _t863, _t864); + sig = _t865; + bool _t866; + _t866 = Ecdsa_VerifyP384(pemPublicKey, data, sig); + return _t866; } bool Ed25519_Keypair(void* pubKey, void* privKey) { - int _t877; + int _t868; int r; - int _t876; - _t876 = bux_ed25519_keypair(pubKey, privKey); - r = _t876; - _t877 = (r == 1); - return _t877; + int _t867; + _t867 = bux_ed25519_keypair(pubKey, privKey); + r = _t867; + _t868 = (r == 1); + return _t868; } const char* Ed25519_KeypairBase64(void) { - unsigned int _t878; - unsigned int _t880; - int _t883; - const char* _t884; - const char* _t886; + unsigned int _t869; + unsigned int _t871; + int _t874; + const char* _t875; + const char* _t877; void* pubBuf; - _t878 = (unsigned int)ED25519_PUBKEY_SIZE; - void* _t879; - _t879 = Alloc(_t878); - pubBuf = _t879; + _t869 = (unsigned int)ED25519_PUBKEY_SIZE; + void* _t870; + _t870 = Alloc(_t869); + pubBuf = _t870; void* priv; - _t880 = (unsigned int)ED25519_PRIVKEY_SIZE; - void* _t881; - _t881 = Alloc(_t880); - priv = _t881; - int _t882; - _t882 = bux_ed25519_keypair(pubBuf, priv); - _t883 = (_t882 != 1); - if (!_t883) goto endif313; + _t871 = (unsigned int)ED25519_PRIVKEY_SIZE; + void* _t872; + _t872 = Alloc(_t871); + priv = _t872; + int _t873; + _t873 = bux_ed25519_keypair(pubBuf, priv); + _t874 = (_t873 != 1); + if (!_t874) goto endif300; { Free(pubBuf); Free(priv); return ""; } - endif313:; + endif300:; const char* pubB64; - _t884 = (const char*)pubBuf; - const char* _t885; - _t885 = bux_base64_encode(_t884, ED25519_PUBKEY_SIZE); - pubB64 = _t885; + _t875 = (const char*)pubBuf; + const char* _t876; + _t876 = bux_base64_encode(_t875, ED25519_PUBKEY_SIZE); + pubB64 = _t876; const char* privB64; - _t886 = (const char*)priv; - const char* _t887; - _t887 = bux_base64_encode(_t886, ED25519_PRIVKEY_SIZE); - privB64 = _t887; + _t877 = (const char*)priv; + const char* _t878; + _t878 = bux_base64_encode(_t877, ED25519_PRIVKEY_SIZE); + privB64 = _t878; Free(pubBuf); Free(priv); const char* pair; - const char* _t888; - _t888 = String_Concat(pubB64, ":"); - pair = _t888; - const char* _t889; - _t889 = String_Concat(pair, privB64); - return _t889; + const char* _t879; + _t879 = String_Concat(pubB64, ":"); + pair = _t879; + const char* _t880; + _t880 = String_Concat(pair, privB64); + return _t880; } const char* Ed25519_Sign(const char* privKey, const char* data) { - unsigned int _t890; - int _t893; - int _t895; - const char* _t896; + unsigned int _t881; + int _t884; + int _t886; + const char* _t887; void* sig; - _t890 = (unsigned int)ED25519_SIG_SIZE; - void* _t891; - _t891 = Alloc(_t890); - sig = _t891; - unsigned int _t892; - _t892 = String_Len(data); - _t893 = (int)_t892; - int _t894; - _t894 = bux_ed25519_sign(privKey, data, _t893, sig); - _t895 = (_t894 != 1); - if (!_t895) goto endif315; + _t881 = (unsigned int)ED25519_SIG_SIZE; + void* _t882; + _t882 = Alloc(_t881); + sig = _t882; + unsigned int _t883; + _t883 = String_Len(data); + _t884 = (int)_t883; + int _t885; + _t885 = bux_ed25519_sign(privKey, data, _t884, sig); + _t886 = (_t885 != 1); + if (!_t886) goto endif302; { Free(sig); return ""; } - endif315:; - _t896 = (const char*)sig; - return _t896; + endif302:; + _t887 = (const char*)sig; + return _t887; } const char* Ed25519_SignBase64(const char* privKey, const char* data) { - int _t899; + int _t890; const char* sig; - const char* _t897; - _t897 = Ed25519_Sign(privKey, data); - sig = _t897; - unsigned int _t898; - _t898 = String_Len(sig); - _t899 = (_t898 == 0); - if (!_t899) goto endif317; + const char* _t888; + _t888 = Ed25519_Sign(privKey, data); + sig = _t888; + unsigned int _t889; + _t889 = String_Len(sig); + _t890 = (_t889 == 0); + if (!_t890) goto endif304; { return ""; } - endif317:; - const char* _t900; - _t900 = bux_base64_encode(sig, ED25519_SIG_SIZE); - return _t900; + endif304:; + const char* _t891; + _t891 = bux_base64_encode(sig, ED25519_SIG_SIZE); + return _t891; } bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data) { - int _t902; - int _t904; + int _t893; + int _t895; int r; - unsigned int _t901; - _t901 = String_Len(data); - _t902 = (int)_t901; - int _t903; - _t903 = bux_ed25519_verify(pubKey, signature, data, _t902); - r = _t903; - _t904 = (r == 1); - return _t904; + unsigned int _t892; + _t892 = String_Len(data); + _t893 = (int)_t892; + int _t894; + _t894 = bux_ed25519_verify(pubKey, signature, data, _t893); + r = _t894; + _t895 = (r == 1); + return _t895; } bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data) { - int _t906; - void* _t907; - int _t909; + int _t897; + void* _t898; + int _t900; int outlen; outlen = 0; const char* sig; - unsigned int _t905; - _t905 = String_Len(signatureB64); - _t906 = (int)_t905; - _t907 = &outlen; - const char* _t908; - _t908 = bux_base64_decode(signatureB64, _t906, _t907); - sig = _t908; - _t909 = (outlen != ED25519_SIG_SIZE); - if (!_t909) goto endif319; + unsigned int _t896; + _t896 = String_Len(signatureB64); + _t897 = (int)_t896; + _t898 = &outlen; + const char* _t899; + _t899 = bux_base64_decode(signatureB64, _t897, _t898); + sig = _t899; + _t900 = (outlen != ED25519_SIG_SIZE); + if (!_t900) goto endif306; { return 0; } - endif319:; - bool _t910; - _t910 = Ed25519_Verify(pubKey, sig, data); - return _t910; + endif306:; + bool _t901; + _t901 = Ed25519_Verify(pubKey, sig, data); + return _t901; } const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data) { - int _t912; - int _t914; - void* _t915; + int _t903; + int _t905; + void* _t906; int siglen; siglen = 0; - unsigned int _t911; - _t911 = String_Len(pemPrivateKey); - _t912 = (int)_t911; - unsigned int _t913; - _t913 = String_Len(data); - _t914 = (int)_t913; - _t915 = &siglen; - const char* _t916; - _t916 = bux_rsa_sign_sha256(pemPrivateKey, _t912, data, _t914, _t915); - return _t916; + unsigned int _t902; + _t902 = String_Len(pemPrivateKey); + _t903 = (int)_t902; + unsigned int _t904; + _t904 = String_Len(data); + _t905 = (int)_t904; + _t906 = &siglen; + const char* _t907; + _t907 = bux_rsa_sign_sha256(pemPrivateKey, _t903, data, _t905, _t906); + return _t907; } const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data) { - int _t918; - int _t920; - void* _t921; + int _t909; + int _t911; + void* _t912; int siglen; siglen = 0; - unsigned int _t917; - _t917 = String_Len(pemPrivateKey); - _t918 = (int)_t917; - unsigned int _t919; - _t919 = String_Len(data); - _t920 = (int)_t919; - _t921 = &siglen; - const char* _t922; - _t922 = bux_rsa_sign_sha384(pemPrivateKey, _t918, data, _t920, _t921); - return _t922; + unsigned int _t908; + _t908 = String_Len(pemPrivateKey); + _t909 = (int)_t908; + unsigned int _t910; + _t910 = String_Len(data); + _t911 = (int)_t910; + _t912 = &siglen; + const char* _t913; + _t913 = bux_rsa_sign_sha384(pemPrivateKey, _t909, data, _t911, _t912); + return _t913; } const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data) { - int _t924; - int _t926; - void* _t927; + int _t915; + int _t917; + void* _t918; int siglen; siglen = 0; - unsigned int _t923; - _t923 = String_Len(pemPrivateKey); - _t924 = (int)_t923; - unsigned int _t925; - _t925 = String_Len(data); - _t926 = (int)_t925; - _t927 = &siglen; - const char* _t928; - _t928 = bux_rsa_sign_sha512(pemPrivateKey, _t924, data, _t926, _t927); - return _t928; + unsigned int _t914; + _t914 = String_Len(pemPrivateKey); + _t915 = (int)_t914; + unsigned int _t916; + _t916 = String_Len(data); + _t917 = (int)_t916; + _t918 = &siglen; + const char* _t919; + _t919 = bux_rsa_sign_sha512(pemPrivateKey, _t915, data, _t917, _t918); + return _t919; } const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data) { - int _t931; + int _t922; const char* raw; - const char* _t929; - _t929 = Rsa_SignSha256(pemPrivateKey, data); - raw = _t929; - unsigned int _t930; - _t930 = String_Len(raw); - _t931 = (int)_t930; - const char* _t932; - _t932 = bux_base64_encode(raw, _t931); - return _t932; + const char* _t920; + _t920 = Rsa_SignSha256(pemPrivateKey, data); + raw = _t920; + unsigned int _t921; + _t921 = String_Len(raw); + _t922 = (int)_t921; + const char* _t923; + _t923 = bux_base64_encode(raw, _t922); + return _t923; } const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data) { - int _t935; + int _t926; const char* raw; - const char* _t933; - _t933 = Rsa_SignSha384(pemPrivateKey, data); - raw = _t933; - unsigned int _t934; - _t934 = String_Len(raw); - _t935 = (int)_t934; - const char* _t936; - _t936 = bux_base64_encode(raw, _t935); - return _t936; + const char* _t924; + _t924 = Rsa_SignSha384(pemPrivateKey, data); + raw = _t924; + unsigned int _t925; + _t925 = String_Len(raw); + _t926 = (int)_t925; + const char* _t927; + _t927 = bux_base64_encode(raw, _t926); + return _t927; } const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data) { - int _t939; + int _t930; const char* raw; - const char* _t937; - _t937 = Rsa_SignSha512(pemPrivateKey, data); - raw = _t937; - unsigned int _t938; - _t938 = String_Len(raw); - _t939 = (int)_t938; - const char* _t940; - _t940 = bux_base64_encode(raw, _t939); - return _t940; + const char* _t928; + _t928 = Rsa_SignSha512(pemPrivateKey, data); + raw = _t928; + unsigned int _t929; + _t929 = String_Len(raw); + _t930 = (int)_t929; + const char* _t931; + _t931 = bux_base64_encode(raw, _t930); + return _t931; } bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature) { - int _t942; - int _t944; - int _t946; - int _t948; + int _t933; + int _t935; + int _t937; + int _t939; int r; - unsigned int _t941; - _t941 = String_Len(pemPublicKey); - _t942 = (int)_t941; - unsigned int _t943; - _t943 = String_Len(data); - _t944 = (int)_t943; - unsigned int _t945; - _t945 = String_Len(signature); - _t946 = (int)_t945; - int _t947; - _t947 = bux_rsa_verify_sha256(pemPublicKey, _t942, data, _t944, signature, _t946); - r = _t947; - _t948 = (r == 1); - return _t948; + unsigned int _t932; + _t932 = String_Len(pemPublicKey); + _t933 = (int)_t932; + unsigned int _t934; + _t934 = String_Len(data); + _t935 = (int)_t934; + unsigned int _t936; + _t936 = String_Len(signature); + _t937 = (int)_t936; + int _t938; + _t938 = bux_rsa_verify_sha256(pemPublicKey, _t933, data, _t935, signature, _t937); + r = _t938; + _t939 = (r == 1); + return _t939; } bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature) { - int _t950; - int _t952; - int _t954; - int _t956; + int _t941; + int _t943; + int _t945; + int _t947; int r; - unsigned int _t949; - _t949 = String_Len(pemPublicKey); - _t950 = (int)_t949; - unsigned int _t951; - _t951 = String_Len(data); - _t952 = (int)_t951; - unsigned int _t953; - _t953 = String_Len(signature); - _t954 = (int)_t953; - int _t955; - _t955 = bux_rsa_verify_sha384(pemPublicKey, _t950, data, _t952, signature, _t954); - r = _t955; - _t956 = (r == 1); - return _t956; + unsigned int _t940; + _t940 = String_Len(pemPublicKey); + _t941 = (int)_t940; + unsigned int _t942; + _t942 = String_Len(data); + _t943 = (int)_t942; + unsigned int _t944; + _t944 = String_Len(signature); + _t945 = (int)_t944; + int _t946; + _t946 = bux_rsa_verify_sha384(pemPublicKey, _t941, data, _t943, signature, _t945); + r = _t946; + _t947 = (r == 1); + return _t947; } bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature) { - int _t958; - int _t960; - int _t962; - int _t964; + int _t949; + int _t951; + int _t953; + int _t955; int r; - unsigned int _t957; - _t957 = String_Len(pemPublicKey); - _t958 = (int)_t957; - unsigned int _t959; - _t959 = String_Len(data); - _t960 = (int)_t959; - unsigned int _t961; - _t961 = String_Len(signature); - _t962 = (int)_t961; - int _t963; - _t963 = bux_rsa_verify_sha512(pemPublicKey, _t958, data, _t960, signature, _t962); - r = _t963; - _t964 = (r == 1); - return _t964; + unsigned int _t948; + _t948 = String_Len(pemPublicKey); + _t949 = (int)_t948; + unsigned int _t950; + _t950 = String_Len(data); + _t951 = (int)_t950; + unsigned int _t952; + _t952 = String_Len(signature); + _t953 = (int)_t952; + int _t954; + _t954 = bux_rsa_verify_sha512(pemPublicKey, _t949, data, _t951, signature, _t953); + r = _t954; + _t955 = (r == 1); + return _t955; } bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t966; - void* _t967; + int _t957; + void* _t958; int outlen; outlen = 0; const char* sig; - unsigned int _t965; - _t965 = String_Len(signatureB64); - _t966 = (int)_t965; - _t967 = &outlen; - const char* _t968; - _t968 = bux_base64_decode(signatureB64, _t966, _t967); - sig = _t968; - bool _t969; - _t969 = Rsa_VerifySha256(pemPublicKey, data, sig); - return _t969; + unsigned int _t956; + _t956 = String_Len(signatureB64); + _t957 = (int)_t956; + _t958 = &outlen; + const char* _t959; + _t959 = bux_base64_decode(signatureB64, _t957, _t958); + sig = _t959; + bool _t960; + _t960 = Rsa_VerifySha256(pemPublicKey, data, sig); + return _t960; } bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t971; - void* _t972; + int _t962; + void* _t963; int outlen; outlen = 0; const char* sig; - unsigned int _t970; - _t970 = String_Len(signatureB64); - _t971 = (int)_t970; - _t972 = &outlen; - const char* _t973; - _t973 = bux_base64_decode(signatureB64, _t971, _t972); - sig = _t973; - bool _t974; - _t974 = Rsa_VerifySha384(pemPublicKey, data, sig); - return _t974; + unsigned int _t961; + _t961 = String_Len(signatureB64); + _t962 = (int)_t961; + _t963 = &outlen; + const char* _t964; + _t964 = bux_base64_decode(signatureB64, _t962, _t963); + sig = _t964; + bool _t965; + _t965 = Rsa_VerifySha384(pemPublicKey, data, sig); + return _t965; } bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t976; - void* _t977; + int _t967; + void* _t968; int outlen; outlen = 0; const char* sig; - unsigned int _t975; - _t975 = String_Len(signatureB64); - _t976 = (int)_t975; - _t977 = &outlen; - const char* _t978; - _t978 = bux_base64_decode(signatureB64, _t976, _t977); - sig = _t978; - bool _t979; - _t979 = Rsa_VerifySha512(pemPublicKey, data, sig); - return _t979; + unsigned int _t966; + _t966 = String_Len(signatureB64); + _t967 = (int)_t966; + _t968 = &outlen; + const char* _t969; + _t969 = bux_base64_decode(signatureB64, _t967, _t968); + sig = _t969; + bool _t970; + _t970 = Rsa_VerifySha512(pemPublicKey, data, sig); + return _t970; } int Main(void) { - Result _t980; - Result _t981; - int _t983; - int _t987; + Result _t971; + Result _t972; + int _t974; + int _t978; Result r1; - _t980 = (Result){.tag = Result_Ok}; - r1 = _t980; + _t971 = (Result){.tag = Result_Ok}; + r1 = _t971; r1.data.Ok_0 = 42; Result r2; - _t981 = (Result){.tag = Result_Err}; - r2 = _t981; + _t972 = (Result){.tag = Result_Err}; + r2 = _t972; r2.data.Err_0 = "error message"; - Result_Tag _t982; - _t982 = r1.tag; - _t983 = (_t982 == Result_Ok); - if (!_t983) goto endif321; + Result_Tag _t973; + _t973 = r1.tag; + _t974 = (_t973 == Result_Ok); + if (!_t974) goto endif308; { PrintLine("r1 is Ok:"); - Result_Data _t984; - _t984 = r1.data; - int _t985; - _t985 = _t984.Ok_0; - PrintInt(_t985); + Result_Data _t975; + _t975 = r1.data; + int _t976; + _t976 = _t975.Ok_0; + PrintInt(_t976); PrintLine(""); } - endif321:; - Result_Tag _t986; - _t986 = r2.tag; - _t987 = (_t986 == Result_Err); - if (!_t987) goto endif323; + endif308:; + Result_Tag _t977; + _t977 = r2.tag; + _t978 = (_t977 == Result_Err); + if (!_t978) goto endif310; { PrintLine("r2 is Err:"); - Result_Data _t988; - _t988 = r2.data; - const char* _t989; - _t989 = _t988.Err_0; - PrintLine(_t989); + Result_Data _t979; + _t979 = r2.data; + const char* _t980; + _t980 = _t979.Err_0; + PrintLine(_t980); } - endif323:; + endif310:; return 0; } diff --git a/tests/golden/enums/expected.c b/tests/golden/enums/expected.c index 58512e7..5db141c 100644 --- a/tests/golden/enums/expected.c +++ b/tests/golden/enums/expected.c @@ -198,6 +198,40 @@ extern const char* bux_base64_decode(const char* data, int len, int* outlen); #define ED25519_PRIVKEY_SIZE 32 #define ED25519_SIG_SIZE 64 +typedef struct Channel_float64 { + void* handle; +} Channel_float64; + +typedef struct TaskHandle { + void* handle; +} TaskHandle; + +typedef struct RwLock { + void* handle; +} RwLock; + +typedef enum { + Color_Red, + Color_Green, + Color_Blue +} Color; + +typedef struct Channel_int { + void* handle; +} Channel_int; + +typedef enum { + JwtAlg_HS256, + JwtAlg_HS384, + JwtAlg_HS512, + JwtAlg_RS256, + JwtAlg_RS384, + JwtAlg_RS512, + JwtAlg_ES256, + JwtAlg_ES384, + JwtAlg_EdDSA +} JwtAlg; + typedef enum { Result_Ok, Result_Err @@ -227,37 +261,6 @@ typedef struct { Option_Data data; } Option; -typedef enum { - JwtAlg_HS256, - JwtAlg_HS384, - JwtAlg_HS512, - JwtAlg_RS256, - JwtAlg_RS384, - JwtAlg_RS512, - JwtAlg_ES256, - JwtAlg_ES384, - JwtAlg_EdDSA -} JwtAlg; - -typedef enum { - Color_Red, - Color_Green, - Color_Blue -} Color; - - -typedef struct TaskHandle { - void* handle; -} TaskHandle; - -typedef struct Mutex { - void* handle; -} Mutex; - -typedef struct RwLock { - void* handle; -} RwLock; - typedef struct JsonValue { int tag; bool boolVal; @@ -272,6 +275,14 @@ typedef struct JsonValue { unsigned int objCap; } JsonValue; +typedef struct Mutex { + void* handle; +} Mutex; + +typedef struct StringBuilder { + void* handle; +} StringBuilder; + typedef struct JsonParser { const char* src; unsigned int pos; @@ -279,18 +290,6 @@ typedef struct JsonParser { const char* error; } JsonParser; -typedef struct StringBuilder { - void* handle; -} StringBuilder; - -typedef struct Channel_int { - void* handle; -} Channel_int; - -typedef struct Channel_float64 { - void* handle; -} Channel_float64; - bool DirExists(const char* path); bool Mkdir(const char* path); const char** ListDir(const char* dir, const char* ext, int* count); @@ -873,7 +872,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { tmplLen = _t60; while1:; _t61 = (i < tmplLen); - if (!_t61) goto wend3; + if (!_t61) goto wend2; { const char* ch; const char* _t62; @@ -881,13 +880,13 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { ch = _t62; bool _t63; _t63 = String_Eq(ch, "{"); - if (!_t63) goto endif5; + if (!_t63) goto endif4; { unsigned int digitIdx; _t64 = i + 1; digitIdx = _t64; _t65 = (digitIdx < tmplLen); - if (!_t65) goto endif7; + if (!_t65) goto endif6; { const char* digitCh; const char* _t66; @@ -899,22 +898,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { d = _t67; bool __and_tmp_0; _t68 = (d >= 0); - if (!_t68) goto else8; + if (!_t68) goto else7; _t69 = (int64_t)argCount; _t70 = (d < _t69); *(bool*)&__and_tmp_0 = _t70; - goto endif9; - else8:; + goto endif8; + else7:; *(bool*)&__and_tmp_0 = 0; - endif9:; + endif8:; bool _t71; _t71 = *(bool*)&__and_tmp_0; - if (!_t71) goto endif11; + if (!_t71) goto endif10; { _t72 = i + 2; i = _t72; _t73 = (i < tmplLen); - if (!_t73) goto endif13; + if (!_t73) goto endif12; { const char* closeCh; const char* _t74; @@ -922,7 +921,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { closeCh = _t74; bool _t75; _t75 = String_Eq(closeCh, "}"); - if (!_t75) goto endif15; + if (!_t75) goto endif14; { _t76 = i + 1; i = _t76; @@ -935,22 +934,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { StringBuilder_Append(_t79, argStr); goto while1; } - endif15:; + endif14:; } - endif13:; + endif12:; } - endif11:; + endif10:; } - endif7:; + endif6:; } - endif5:; + endif4:; _t80 = &sb; StringBuilder_Append(_t80, ch); _t81 = i + 1; i = _t81; } goto while1; - wend3:; + wend2:; _t82 = &sb; const char* _t83; _t83 = StringBuilder_Build(_t82); @@ -958,276 +957,276 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { } const char* Fmt_Fmt1(const char* tmpl, const char* a1) { - const char** _t86; + const char** _t85; const char** args; /* sizeof(const char*) */ - void* _t85; - _t85 = bux_alloc(sizeof(const char*)); - _t86 = (const char**)_t85; - args = _t86; + void* _t84; + _t84 = bux_alloc(sizeof(const char*)); + _t85 = (const char**)_t84; + args = _t85; args[0] = a1; - const char* _t87; - _t87 = Fmt_Format(tmpl, args, 1); - return _t87; + const char* _t86; + _t86 = Fmt_Format(tmpl, args, 1); + return _t86; } const char* Fmt_FmtInt(const char* tmpl, int64_t val) { const char* s; + const char* _t87; + _t87 = String_FromInt(val); + s = _t87; const char* _t88; - _t88 = String_FromInt(val); - s = _t88; - const char* _t89; - _t89 = Fmt_Fmt1(tmpl, s); - return _t89; + _t88 = Fmt_Fmt1(tmpl, s); + return _t88; } const char* Fmt_FmtBool(const char* tmpl, bool val) { const char* s; + const char* _t89; + _t89 = String_FromBool(val); + s = _t89; const char* _t90; - _t90 = String_FromBool(val); - s = _t90; - const char* _t91; - _t91 = Fmt_Fmt1(tmpl, s); - return _t91; + _t90 = Fmt_Fmt1(tmpl, s); + return _t90; } const char* Fmt_FmtFloat(const char* tmpl, double val) { const char* s; + const char* _t91; + _t91 = String_FromFloat(val); + s = _t91; const char* _t92; - _t92 = String_FromFloat(val); - s = _t92; - const char* _t93; - _t93 = Fmt_Fmt1(tmpl, s); - return _t93; + _t92 = Fmt_Fmt1(tmpl, s); + return _t92; } const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2) { - int _t95; - const char** _t97; + int _t93; + const char** _t95; const char** args; /* sizeof(const char*) */ - _t95 = 2 * sizeof(const char*); - void* _t96; - _t96 = bux_alloc(_t95); - _t97 = (const char**)_t96; - args = _t97; + _t93 = 2 * sizeof(const char*); + void* _t94; + _t94 = bux_alloc(_t93); + _t95 = (const char**)_t94; + args = _t95; args[0] = a1; args[1] = a2; - const char* _t98; - _t98 = Fmt_Format(tmpl, args, 2); - return _t98; + const char* _t96; + _t96 = Fmt_Format(tmpl, args, 2); + return _t96; } const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3) { - int _t100; - const char** _t102; + int _t97; + const char** _t99; const char** args; /* sizeof(const char*) */ - _t100 = 3 * sizeof(const char*); - void* _t101; - _t101 = bux_alloc(_t100); - _t102 = (const char**)_t101; - args = _t102; + _t97 = 3 * sizeof(const char*); + void* _t98; + _t98 = bux_alloc(_t97); + _t99 = (const char**)_t98; + args = _t99; args[0] = a1; args[1] = a2; args[2] = a3; - const char* _t103; - _t103 = Fmt_Format(tmpl, args, 3); - return _t103; + const char* _t100; + _t100 = Fmt_Format(tmpl, args, 3); + return _t100; } const char* Crypto_Sha256(const char* data) { - int _t105; - void* _t107; + int _t102; + void* _t104; int len; - unsigned int _t104; - _t104 = String_Len(data); - _t105 = (int)_t104; - len = _t105; + unsigned int _t101; + _t101 = String_Len(data); + _t102 = (int)_t101; + len = _t102; void* hashBuf; - void* _t106; - _t106 = Alloc(32); - hashBuf = _t106; + void* _t103; + _t103 = Alloc(32); + hashBuf = _t103; bux_sha256(data, len, hashBuf); const char* result; - _t107 = (void*)hashBuf; - const char* _t108; - _t108 = bux_bytes_to_hex(_t107, 32); - result = _t108; + _t104 = (void*)hashBuf; + const char* _t105; + _t105 = bux_bytes_to_hex(_t104, 32); + result = _t105; Free(hashBuf); return result; } const char* Crypto_HmacSha256(const char* key, const char* message) { - int _t110; - int _t112; - void* _t114; + int _t107; + int _t109; + void* _t111; int keylen; - unsigned int _t109; - _t109 = String_Len(key); - _t110 = (int)_t109; - keylen = _t110; + unsigned int _t106; + _t106 = String_Len(key); + _t107 = (int)_t106; + keylen = _t107; int msglen; - unsigned int _t111; - _t111 = String_Len(message); - _t112 = (int)_t111; - msglen = _t112; + unsigned int _t108; + _t108 = String_Len(message); + _t109 = (int)_t108; + msglen = _t109; void* hmacBuf; - void* _t113; - _t113 = Alloc(32); - hmacBuf = _t113; + void* _t110; + _t110 = Alloc(32); + hmacBuf = _t110; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t114 = (void*)hmacBuf; - const char* _t115; - _t115 = bux_bytes_to_hex(_t114, 32); - result = _t115; + _t111 = (void*)hmacBuf; + const char* _t112; + _t112 = bux_bytes_to_hex(_t111, 32); + result = _t112; Free(hmacBuf); return result; } const char* Crypto_RandomBytes(int n) { - int _t116; - unsigned int _t117; - int _t120; - const char* _t121; - _t116 = (n <= 0); - if (!_t116) goto endif17; + int _t113; + unsigned int _t114; + int _t117; + const char* _t118; + _t113 = (n <= 0); + if (!_t113) goto endif16; { return ""; } - endif17:; + endif16:; void* buf; - _t117 = (unsigned int)n; - void* _t118; - _t118 = Alloc(_t117); - buf = _t118; - int _t119; - _t119 = bux_random_bytes(buf, n); - _t120 = (_t119 != 1); - if (!_t120) goto endif19; + _t114 = (unsigned int)n; + void* _t115; + _t115 = Alloc(_t114); + buf = _t115; + int _t116; + _t116 = bux_random_bytes(buf, n); + _t117 = (_t116 != 1); + if (!_t117) goto endif18; { Free(buf); return ""; } - endif19:; + endif18:; const char* result; - _t121 = (const char*)buf; - const char* _t122; - _t122 = bux_base64_encode(_t121, n); - result = _t122; + _t118 = (const char*)buf; + const char* _t119; + _t119 = bux_base64_encode(_t118, n); + result = _t119; Free(buf); return result; } const char* Crypto_Base64Encode(const char* s) { - int _t124; - unsigned int _t123; - _t123 = String_Len(s); - _t124 = (int)_t123; - const char* _t125; - _t125 = bux_base64_encode(s, _t124); - return _t125; + int _t121; + unsigned int _t120; + _t120 = String_Len(s); + _t121 = (int)_t120; + const char* _t122; + _t122 = bux_base64_encode(s, _t121); + return _t122; } const char* Crypto_HmacSha256Raw(const char* key, const char* message) { - int _t127; - int _t129; - const char* _t131; + int _t124; + int _t126; + const char* _t128; int keylen; - unsigned int _t126; - _t126 = String_Len(key); - _t127 = (int)_t126; - keylen = _t127; + unsigned int _t123; + _t123 = String_Len(key); + _t124 = (int)_t123; + keylen = _t124; int msglen; - unsigned int _t128; - _t128 = String_Len(message); - _t129 = (int)_t128; - msglen = _t129; + unsigned int _t125; + _t125 = String_Len(message); + _t126 = (int)_t125; + msglen = _t126; void* hmacBuf; - void* _t130; - _t130 = Alloc(32); - hmacBuf = _t130; + void* _t127; + _t127 = Alloc(32); + hmacBuf = _t127; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t131 = (const char*)hmacBuf; - const char* _t132; - _t132 = bux_base64_encode(_t131, 32); - result = _t132; + _t128 = (const char*)hmacBuf; + const char* _t129; + _t129 = bux_base64_encode(_t128, 32); + result = _t129; Free(hmacBuf); return result; } const char* Crypto_Base64Decode(const char* s) { - int _t134; - void* _t135; + int _t131; + void* _t132; int outlen; outlen = 0; - unsigned int _t133; - _t133 = String_Len(s); - _t134 = (int)_t133; - _t135 = &outlen; - const char* _t136; - _t136 = bux_base64_decode(s, _t134, _t135); - return _t136; + unsigned int _t130; + _t130 = String_Len(s); + _t131 = (int)_t130; + _t132 = &outlen; + const char* _t133; + _t133 = bux_base64_decode(s, _t131, _t132); + return _t133; } Mutex Mutex_New(void) { - Mutex _t138; - void* _t137; - _t137 = bux_mutex_new(); - _t138 = (Mutex){.handle = _t137}; - return _t138; + Mutex _t135; + void* _t134; + _t134 = bux_mutex_new(); + _t135 = (Mutex){.handle = _t134}; + return _t135; } void Mutex_Lock(Mutex* m) { - void* _t139; - _t139 = m->handle; - bux_mutex_lock(_t139); + void* _t136; + _t136 = m->handle; + bux_mutex_lock(_t136); } void Mutex_Unlock(Mutex* m) { - void* _t140; - _t140 = m->handle; - bux_mutex_unlock(_t140); + void* _t137; + _t137 = m->handle; + bux_mutex_unlock(_t137); } void Mutex_Free(Mutex* m) { - void* _t141; - _t141 = m->handle; - bux_mutex_free(_t141); + void* _t138; + _t138 = m->handle; + bux_mutex_free(_t138); } RwLock RwLock_New(void) { - RwLock _t143; - void* _t142; - _t142 = bux_rwlock_new(); - _t143 = (RwLock){.handle = _t142}; - return _t143; + RwLock _t140; + void* _t139; + _t139 = bux_rwlock_new(); + _t140 = (RwLock){.handle = _t139}; + return _t140; } void RwLock_ReadLock(RwLock* rw) { - void* _t144; - _t144 = rw->handle; - bux_rwlock_rdlock(_t144); + void* _t141; + _t141 = rw->handle; + bux_rwlock_rdlock(_t141); } void RwLock_WriteLock(RwLock* rw) { - void* _t145; - _t145 = rw->handle; - bux_rwlock_wrlock(_t145); + void* _t142; + _t142 = rw->handle; + bux_rwlock_wrlock(_t142); } void RwLock_Unlock(RwLock* rw) { - void* _t146; - _t146 = rw->handle; - bux_rwlock_unlock(_t146); + void* _t143; + _t143 = rw->handle; + bux_rwlock_unlock(_t143); } void RwLock_Free(RwLock* rw) { - void* _t147; - _t147 = rw->handle; - bux_rwlock_free(_t147); + void* _t144; + _t144 = rw->handle; + bux_rwlock_free(_t144); } void Test_Exit(int code) { @@ -1235,15 +1234,15 @@ void Test_Exit(int code) { } void Test_Assert(bool cond) { - int _t148; - _t148 = (int)cond; - bux_assert(_t148, "", 0, ""); + int _t145; + _t145 = (int)cond; + bux_assert(_t145, "", 0, ""); } void Test_AssertEqInt(int a, int b) { - int _t149; - _t149 = (a != b); - if (!_t149) goto endif21; + int _t146; + _t146 = (a != b); + if (!_t146) goto endif20; { PrintLine("ASSERT_EQ FAILED:"); PrintInt(a); @@ -1251,27 +1250,27 @@ void Test_AssertEqInt(int a, int b) { PrintInt(b); bux_exit(1); } - endif21:; + endif20:; } void Test_AssertTrue(bool cond) { - int _t150; - _t150 = !cond; - if (!_t150) goto endif23; + int _t147; + _t147 = !cond; + if (!_t147) goto endif22; { PrintLine("ASSERT_TRUE FAILED"); bux_exit(1); } - endif23:; + endif22:; } void Test_AssertFalse(bool cond) { - if (!cond) goto endif25; + if (!cond) goto endif24; { PrintLine("ASSERT_FALSE FAILED"); bux_exit(1); } - endif25:; + endif24:; } void Test_Fail(const char* msg) { @@ -1281,735 +1280,744 @@ void Test_Fail(const char* msg) { } Result Result_NewOk(int value) { - Result _t151; + Result _t148; Result r; - _t151 = (Result){.tag = Result_Ok}; - r = _t151; + _t148 = (Result){.tag = Result_Ok}; + r = _t148; r.data.Ok_0 = value; return r; } Result Result_NewErr(const char* msg) { - Result _t152; + Result _t149; Result r; - _t152 = (Result){.tag = Result_Err}; - r = _t152; + _t149 = (Result){.tag = Result_Err}; + r = _t149; r.data.Err_0 = msg; return r; } bool Result_IsOk(Result r) { - int _t154; - Result_Tag _t153; - _t153 = r.tag; - _t154 = (_t153 == Result_Ok); - return _t154; + int _t151; + Result_Tag _t150; + _t150 = r.tag; + _t151 = (_t150 == Result_Ok); + return _t151; } bool Result_IsErr(Result r) { - int _t156; - Result_Tag _t155; - _t155 = r.tag; - _t156 = (_t155 == Result_Err); - return _t156; + int _t153; + Result_Tag _t152; + _t152 = r.tag; + _t153 = (_t152 == Result_Err); + return _t153; } int Result_Unwrap(Result r) { - int _t158; - Result_Tag _t157; - _t157 = r.tag; - _t158 = (_t157 != Result_Ok); - if (!_t158) goto endif27; + int _t155; + Result_Tag _t154; + _t154 = r.tag; + _t155 = (_t154 != Result_Ok); + if (!_t155) goto endif26; { PrintLine("panic: unwrap on Err"); return 0; } - endif27:; - Result_Data _t159; - _t159 = r.data; - int _t160; - _t160 = _t159.Ok_0; - return _t160; + endif26:; + Result_Data _t156; + _t156 = r.data; + int _t157; + _t157 = _t156.Ok_0; + return _t157; } int Result_UnwrapOr(Result r, int fallback) { - int _t162; - Result_Tag _t161; - _t161 = r.tag; - _t162 = (_t161 == Result_Ok); - if (!_t162) goto endif29; + int _t159; + Result_Tag _t158; + _t158 = r.tag; + _t159 = (_t158 == Result_Ok); + if (!_t159) goto endif28; { - Result_Data _t163; - _t163 = r.data; - int _t164; - _t164 = _t163.Ok_0; - return _t164; + Result_Data _t160; + _t160 = r.data; + int _t161; + _t161 = _t160.Ok_0; + return _t161; } - endif29:; + endif28:; return fallback; } Option Option_NewSome(int value) { - Option _t165; + Option _t162; Option o; - _t165 = (Option){.tag = Option_Some}; - o = _t165; + _t162 = (Option){.tag = Option_Some}; + o = _t162; o.data.Some_0 = value; return o; } Option Option_NewNone(void) { - Option _t166; - _t166 = (Option){.tag = Option_None}; - return _t166; + Option _t163; + _t163 = (Option){.tag = Option_None}; + return _t163; } bool Option_IsSome(Option o) { - int _t168; - Option_Tag _t167; - _t167 = o.tag; - _t168 = (_t167 == Option_Some); - return _t168; + int _t165; + Option_Tag _t164; + _t164 = o.tag; + _t165 = (_t164 == Option_Some); + return _t165; } bool Option_IsNone(Option o) { - int _t170; - Option_Tag _t169; - _t169 = o.tag; - _t170 = (_t169 == Option_None); - return _t170; + int _t167; + Option_Tag _t166; + _t166 = o.tag; + _t167 = (_t166 == Option_None); + return _t167; } int Option_Unwrap(Option o) { - int _t172; - Option_Tag _t171; - _t171 = o.tag; - _t172 = (_t171 != Option_Some); - if (!_t172) goto endif31; + int _t169; + Option_Tag _t168; + _t168 = o.tag; + _t169 = (_t168 != Option_Some); + if (!_t169) goto endif30; { PrintLine("panic: unwrap on None"); return 0; } - endif31:; - Option_Data _t173; - _t173 = o.data; - int _t174; - _t174 = _t173.Some_0; - return _t174; + endif30:; + Option_Data _t170; + _t170 = o.data; + int _t171; + _t171 = _t170.Some_0; + return _t171; } int Option_UnwrapOr(Option o, int fallback) { - int _t176; - Option_Tag _t175; - _t175 = o.tag; - _t176 = (_t175 == Option_Some); - if (!_t176) goto endif33; + int _t173; + Option_Tag _t172; + _t172 = o.tag; + _t173 = (_t172 == Option_Some); + if (!_t173) goto endif32; { - Option_Data _t177; - _t177 = o.data; - int _t178; - _t178 = _t177.Some_0; - return _t178; + Option_Data _t174; + _t174 = o.data; + int _t175; + _t175 = _t174.Some_0; + return _t175; } - endif33:; + endif32:; return fallback; } JsonValue Json_Null(void) { - JsonValue _t179; - _t179 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t179; + JsonValue _t176; + _t176 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t176; } JsonValue Json_Bool(bool b) { - JsonValue _t180; - _t180 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t180; + JsonValue _t177; + _t177 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t177; } JsonValue Json_Number(double n) { - JsonValue _t181; - _t181 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t181; + JsonValue _t178; + _t178 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t178; } JsonValue Json_String(const char* s) { - JsonValue _t182; - _t182 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t182; + JsonValue _t179; + _t179 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t179; } JsonValue Json_Array(void) { - JsonValue _t183; - _t183 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t183; + JsonValue _t180; + _t180 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t180; } JsonValue Json_Object(void) { - JsonValue _t184; - _t184 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t184; + JsonValue _t181; + _t181 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t181; } unsigned int Json_ArrayLen(JsonValue v) { - int _t186; - int _t185; - _t185 = v.tag; - _t186 = (_t185 != JsonTagArray); - if (!_t186) goto endif35; + int _t183; + int _t182; + _t182 = v.tag; + _t183 = (_t182 != JsonTagArray); + if (!_t183) goto endif34; { return 0; } - endif35:; - unsigned int _t187; - _t187 = v.arrLen; - return _t187; + endif34:; + unsigned int _t184; + _t184 = v.arrLen; + return _t184; } JsonValue Json_ArrayGet(JsonValue v, unsigned int index) { + int _t186; int _t189; - int _t192; - int _t188; - _t188 = v.tag; - _t189 = (_t188 != JsonTagArray); - if (!_t189) goto endif37; + int _t185; + _t185 = v.tag; + _t186 = (_t185 != JsonTagArray); + if (!_t186) goto endif36; + { + JsonValue _t187; + _t187 = Json_Null(); + return _t187; + } + endif36:; + unsigned int _t188; + _t188 = v.arrLen; + _t189 = (index >= _t188); + if (!_t189) goto endif38; { JsonValue _t190; _t190 = Json_Null(); return _t190; } - endif37:; - unsigned int _t191; - _t191 = v.arrLen; - _t192 = (index >= _t191); - if (!_t192) goto endif39; - { - JsonValue _t193; - _t193 = Json_Null(); - return _t193; - } - endif39:; - JsonValue* _t194; - _t194 = v.arrData; - JsonValue _t195; - _t195 = _t194[index]; - return _t195; + endif38:; + JsonValue* _t191; + _t191 = v.arrData; + JsonValue _t192; + _t192 = _t191[index]; + return _t192; } void Json_ArrayPush(JsonValue* self, JsonValue val) { + int _t194; int _t197; + int _t199; int _t200; - int _t202; - int _t204; - JsonValue* _t206; - int _t207; - void* _t209; - int _t211; - JsonValue* _t213; - int _t217; - int _t196; - _t196 = self->tag; - _t197 = (_t196 != JsonTagArray); - if (!_t197) goto endif41; + JsonValue* _t202; + int _t203; + void* _t205; + int _t206; + JsonValue* _t208; + int _t212; + int _t193; + _t193 = self->tag; + _t194 = (_t193 != JsonTagArray); + if (!_t194) goto endif40; { return; } - endif41:; - unsigned int _t198; - _t198 = self->arrLen; - unsigned int _t199; - _t199 = self->arrCap; - _t200 = (_t198 >= _t199); - if (!_t200) goto endif43; + endif40:; + unsigned int _t195; + _t195 = self->arrLen; + unsigned int _t196; + _t196 = self->arrCap; + _t197 = (_t195 >= _t196); + if (!_t197) goto endif42; { unsigned int arrNewCap; - unsigned int _t201; - _t201 = self->arrCap; - arrNewCap = _t201; - _t202 = (arrNewCap == 0); - if (!_t202) goto else44; + unsigned int _t198; + _t198 = self->arrCap; + arrNewCap = _t198; + _t199 = (arrNewCap == 0); + if (!_t199) goto else43; { self->arrCap = 4; /* sizeof(JsonValue) */ - _t204 = 4 * sizeof(JsonValue); - void* _t205; - _t205 = Alloc(_t204); - _t206 = (JsonValue*)_t205; - self->arrData = _t206; + _t200 = 4 * sizeof(JsonValue); + void* _t201; + _t201 = Alloc(_t200); + _t202 = (JsonValue*)_t201; + self->arrData = _t202; } - goto endif45; - else44:; + goto endif44; + else43:; { unsigned int doubleCap; - _t207 = arrNewCap * 2; - doubleCap = _t207; + _t203 = arrNewCap * 2; + doubleCap = _t203; self->arrCap = doubleCap; - JsonValue* _t208; - _t208 = self->arrData; - _t209 = (void*)_t208; + JsonValue* _t204; + _t204 = self->arrData; + _t205 = (void*)_t204; /* sizeof(JsonValue) */ - _t211 = doubleCap * sizeof(JsonValue); - void* _t212; - _t212 = Realloc(_t209, _t211); - _t213 = (JsonValue*)_t212; - self->arrData = _t213; + _t206 = doubleCap * sizeof(JsonValue); + void* _t207; + _t207 = Realloc(_t205, _t206); + _t208 = (JsonValue*)_t207; + self->arrData = _t208; } - endif45:; + endif44:; } - endif43:; - JsonValue* _t214; - _t214 = self->arrData; - unsigned int _t215; - _t215 = self->arrLen; - _t214[_t215] = val; - unsigned int _t216; - _t216 = self->arrLen; - _t217 = _t216 + 1; - self->arrLen = _t217; + endif42:; + JsonValue* _t209; + _t209 = self->arrData; + unsigned int _t210; + _t210 = self->arrLen; + _t209[_t210] = val; + unsigned int _t211; + _t211 = self->arrLen; + _t212 = _t211 + 1; + self->arrLen = _t212; } unsigned int Json_ObjectLen(JsonValue v) { - int _t219; - int _t218; - _t218 = v.tag; - _t219 = (_t218 != JsonTagObject); - if (!_t219) goto endif47; + int _t214; + int _t213; + _t213 = v.tag; + _t214 = (_t213 != JsonTagObject); + if (!_t214) goto endif46; { return 0; } - endif47:; - unsigned int _t220; - _t220 = v.objLen; - return _t220; + endif46:; + unsigned int _t215; + _t215 = v.objLen; + return _t215; } JsonValue Json_ObjectGet(JsonValue v, const char* key) { - int _t222; - int _t225; - int _t231; - int _t221; - _t221 = v.tag; - _t222 = (_t221 != JsonTagObject); - if (!_t222) goto endif49; + int _t217; + int _t220; + int _t226; + int _t216; + _t216 = v.tag; + _t217 = (_t216 != JsonTagObject); + if (!_t217) goto endif48; { - JsonValue _t223; - _t223 = Json_Null(); - return _t223; + JsonValue _t218; + _t218 = Json_Null(); + return _t218; } - endif49:; + endif48:; unsigned int i; i = 0; - while50:; - unsigned int _t224; - _t224 = v.objLen; - _t225 = (i < _t224); - if (!_t225) goto wend52; + while49:; + unsigned int _t219; + _t219 = v.objLen; + _t220 = (i < _t219); + if (!_t220) goto wend50; { - const char** _t226; - _t226 = v.objKeys; - const char* _t227; - _t227 = _t226[i]; - bool _t228; - _t228 = String_Eq(_t227, key); - if (!_t228) goto endif54; + const char** _t221; + _t221 = v.objKeys; + const char* _t222; + _t222 = _t221[i]; + bool _t223; + _t223 = String_Eq(_t222, key); + if (!_t223) goto endif52; { - JsonValue* _t229; - _t229 = v.objValues; - JsonValue _t230; - _t230 = _t229[i]; - return _t230; + JsonValue* _t224; + _t224 = v.objValues; + JsonValue _t225; + _t225 = _t224[i]; + return _t225; } - endif54:; - _t231 = i + 1; - i = _t231; + endif52:; + _t226 = i + 1; + i = _t226; } - goto while50; - wend52:; - JsonValue _t232; - _t232 = Json_Null(); - return _t232; + goto while49; + wend50:; + JsonValue _t227; + _t227 = Json_Null(); + return _t227; } bool Json_ObjectHas(JsonValue v, const char* key) { - int _t234; - int _t236; - int _t240; - int _t233; - _t233 = v.tag; - _t234 = (_t233 != JsonTagObject); - if (!_t234) goto endif56; + int _t229; + int _t231; + int _t235; + int _t228; + _t228 = v.tag; + _t229 = (_t228 != JsonTagObject); + if (!_t229) goto endif54; { return 0; } - endif56:; + endif54:; unsigned int i; i = 0; - while57:; - unsigned int _t235; - _t235 = v.objLen; - _t236 = (i < _t235); - if (!_t236) goto wend59; + while55:; + unsigned int _t230; + _t230 = v.objLen; + _t231 = (i < _t230); + if (!_t231) goto wend56; { - const char** _t237; - _t237 = v.objKeys; - const char* _t238; - _t238 = _t237[i]; - bool _t239; - _t239 = String_Eq(_t238, key); - if (!_t239) goto endif61; + const char** _t232; + _t232 = v.objKeys; + const char* _t233; + _t233 = _t232[i]; + bool _t234; + _t234 = String_Eq(_t233, key); + if (!_t234) goto endif58; { return 1; } - endif61:; - _t240 = i + 1; - i = _t240; + endif58:; + _t235 = i + 1; + i = _t235; } - goto while57; - wend59:; + goto while55; + wend56:; return 0; } void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) { - int _t242; + int _t237; + int _t239; int _t244; + int _t247; int _t249; - int _t252; - int _t254; + int _t250; + const char** _t252; + int _t253; + JsonValue* _t255; int _t256; - const char** _t258; - int _t260; - JsonValue* _t262; - int _t263; - void* _t265; - int _t267; - const char** _t269; - void* _t271; - int _t273; - JsonValue* _t275; - int _t281; - int _t241; - _t241 = self->tag; - _t242 = (_t241 != JsonTagObject); - if (!_t242) goto endif63; + void* _t258; + int _t259; + const char** _t261; + void* _t263; + int _t264; + JsonValue* _t266; + int _t272; + int _t236; + _t236 = self->tag; + _t237 = (_t236 != JsonTagObject); + if (!_t237) goto endif60; { return; } - endif63:; + endif60:; unsigned int i; i = 0; - while64:; - unsigned int _t243; - _t243 = self->objLen; - _t244 = (i < _t243); - if (!_t244) goto wend66; + while61:; + unsigned int _t238; + _t238 = self->objLen; + _t239 = (i < _t238); + if (!_t239) goto wend62; { - const char** _t245; - _t245 = self->objKeys; - const char* _t246; - _t246 = _t245[i]; - bool _t247; - _t247 = String_Eq(_t246, key); - if (!_t247) goto endif68; + const char** _t240; + _t240 = self->objKeys; + const char* _t241; + _t241 = _t240[i]; + bool _t242; + _t242 = String_Eq(_t241, key); + if (!_t242) goto endif64; { - JsonValue* _t248; - _t248 = self->objValues; - _t248[i] = val; + JsonValue* _t243; + _t243 = self->objValues; + _t243[i] = val; return; } - endif68:; - _t249 = i + 1; - i = _t249; + endif64:; + _t244 = i + 1; + i = _t244; } - goto while64; - wend66:; - unsigned int _t250; - _t250 = self->objLen; - unsigned int _t251; - _t251 = self->objCap; - _t252 = (_t250 >= _t251); - if (!_t252) goto endif70; + goto while61; + wend62:; + unsigned int _t245; + _t245 = self->objLen; + unsigned int _t246; + _t246 = self->objCap; + _t247 = (_t245 >= _t246); + if (!_t247) goto endif66; { unsigned int objNewCap; - unsigned int _t253; - _t253 = self->objCap; - objNewCap = _t253; - _t254 = (objNewCap == 0); - if (!_t254) goto else71; + unsigned int _t248; + _t248 = self->objCap; + objNewCap = _t248; + _t249 = (objNewCap == 0); + if (!_t249) goto else67; { self->objCap = 4; /* sizeof(const char*) */ - _t256 = 4 * sizeof(const char*); - void* _t257; - _t257 = Alloc(_t256); - _t258 = (const char**)_t257; - self->objKeys = _t258; + _t250 = 4 * sizeof(const char*); + void* _t251; + _t251 = Alloc(_t250); + _t252 = (const char**)_t251; + self->objKeys = _t252; /* sizeof(JsonValue) */ - _t260 = 4 * sizeof(JsonValue); - void* _t261; - _t261 = Alloc(_t260); - _t262 = (JsonValue*)_t261; - self->objValues = _t262; + _t253 = 4 * sizeof(JsonValue); + void* _t254; + _t254 = Alloc(_t253); + _t255 = (JsonValue*)_t254; + self->objValues = _t255; } - goto endif72; - else71:; + goto endif68; + else67:; { unsigned int doubleCap; - _t263 = objNewCap * 2; - doubleCap = _t263; + _t256 = objNewCap * 2; + doubleCap = _t256; self->objCap = doubleCap; - const char** _t264; - _t264 = self->objKeys; - _t265 = (void*)_t264; + const char** _t257; + _t257 = self->objKeys; + _t258 = (void*)_t257; /* sizeof(const char*) */ - _t267 = doubleCap * sizeof(const char*); - void* _t268; - _t268 = Realloc(_t265, _t267); - _t269 = (const char**)_t268; - self->objKeys = _t269; - JsonValue* _t270; - _t270 = self->objValues; - _t271 = (void*)_t270; + _t259 = doubleCap * sizeof(const char*); + void* _t260; + _t260 = Realloc(_t258, _t259); + _t261 = (const char**)_t260; + self->objKeys = _t261; + JsonValue* _t262; + _t262 = self->objValues; + _t263 = (void*)_t262; /* sizeof(JsonValue) */ - _t273 = doubleCap * sizeof(JsonValue); - void* _t274; - _t274 = Realloc(_t271, _t273); - _t275 = (JsonValue*)_t274; - self->objValues = _t275; + _t264 = doubleCap * sizeof(JsonValue); + void* _t265; + _t265 = Realloc(_t263, _t264); + _t266 = (JsonValue*)_t265; + self->objValues = _t266; } - endif72:; + endif68:; } - endif70:; - const char** _t276; - _t276 = self->objKeys; - unsigned int _t277; - _t277 = self->objLen; - _t276[_t277] = key; - JsonValue* _t278; - _t278 = self->objValues; - unsigned int _t279; - _t279 = self->objLen; - _t278[_t279] = val; - unsigned int _t280; - _t280 = self->objLen; - _t281 = _t280 + 1; - self->objLen = _t281; + endif66:; + const char** _t267; + _t267 = self->objKeys; + unsigned int _t268; + _t268 = self->objLen; + _t267[_t268] = key; + JsonValue* _t269; + _t269 = self->objValues; + unsigned int _t270; + _t270 = self->objLen; + _t269[_t270] = val; + unsigned int _t271; + _t271 = self->objLen; + _t272 = _t271 + 1; + self->objLen = _t272; } bool Json_IsNull(JsonValue v) { - int _t283; - int _t282; - _t282 = v.tag; - _t283 = (_t282 == JsonTagNull); - return _t283; + int _t274; + int _t273; + _t273 = v.tag; + _t274 = (_t273 == JsonTagNull); + return _t274; } bool Json_AsBool(JsonValue v) { - int _t285; - int _t284; - _t284 = v.tag; - _t285 = (_t284 == JsonTagBool); - if (!_t285) goto endif74; + int _t276; + int _t275; + _t275 = v.tag; + _t276 = (_t275 == JsonTagBool); + if (!_t276) goto endif70; { - bool _t286; - _t286 = v.boolVal; - return _t286; + bool _t277; + _t277 = v.boolVal; + return _t277; } - endif74:; + endif70:; return 0; } double Json_AsNumber(JsonValue v) { - int _t288; - int _t287; - _t287 = v.tag; - _t288 = (_t287 == JsonTagNumber); - if (!_t288) goto endif76; + int _t279; + int _t278; + _t278 = v.tag; + _t279 = (_t278 == JsonTagNumber); + if (!_t279) goto endif72; { - double _t289; - _t289 = v.numVal; - return _t289; + double _t280; + _t280 = v.numVal; + return _t280; } - endif76:; + endif72:; return 0.0; } const char* Json_AsString(JsonValue v) { - int _t291; - int _t290; - _t290 = v.tag; - _t291 = (_t290 == JsonTagString); - if (!_t291) goto endif78; + int _t282; + int _t281; + _t281 = v.tag; + _t282 = (_t281 == JsonTagString); + if (!_t282) goto endif74; { - const char* _t292; - _t292 = v.strVal; - return _t292; + const char* _t283; + _t283 = v.strVal; + return _t283; } - endif78:; + endif74:; return ""; } int JsonParser_Peek(JsonParser* p) { - int _t295; - int _t299; - unsigned int _t293; - _t293 = p->pos; - unsigned int _t294; - _t294 = p->len; - _t295 = (_t293 >= _t294); - if (!_t295) goto endif80; + int _t286; + int _t290; + unsigned int _t284; + _t284 = p->pos; + unsigned int _t285; + _t285 = p->len; + _t286 = (_t284 >= _t285); + if (!_t286) goto endif76; { return 0; } - endif80:; - const char* _t296; - _t296 = p->src; - unsigned int _t297; - _t297 = p->pos; - int _t298; - _t298 = _t296[_t297]; - _t299 = (int)_t298; - return _t299; + endif76:; + const char* _t287; + _t287 = p->src; + unsigned int _t288; + _t288 = p->pos; + int _t289; + _t289 = _t287[_t288]; + _t290 = (int)_t289; + return _t290; } void JsonParser_Advance(JsonParser* p) { - int _t302; - int _t304; - unsigned int _t300; - _t300 = p->pos; - unsigned int _t301; - _t301 = p->len; - _t302 = (_t300 < _t301); - if (!_t302) goto endif82; + int _t293; + int _t295; + unsigned int _t291; + _t291 = p->pos; + unsigned int _t292; + _t292 = p->len; + _t293 = (_t291 < _t292); + if (!_t293) goto endif78; { - unsigned int _t303; - _t303 = p->pos; - _t304 = _t303 + 1; - p->pos = _t304; + unsigned int _t294; + _t294 = p->pos; + _t295 = _t294 + 1; + p->pos = _t295; } - endif82:; + endif78:; } void JsonParser_SkipWhitespace(JsonParser* p) { - int _t306; - int _t307; - int _t309; - int _t311; - while83:; - if (!1) goto wend85; + int _t297; + int _t298; + int _t300; + int _t302; + while79:; + if (!1) goto wend80; { int c; - int _t305; - _t305 = JsonParser_Peek(p); - c = _t305; + int _t296; + _t296 = JsonParser_Peek(p); + c = _t296; bool __or_tmp_1; bool __or_tmp_2; bool __or_tmp_3; - _t306 = (c == 32); - if (!_t306) goto else86; + _t297 = (c == 32); + if (!_t297) goto else81; *(bool*)&__or_tmp_3 = 1; - goto endif87; - else86:; - _t307 = (c == 9); - *(bool*)&__or_tmp_3 = _t307; - endif87:; - bool _t308; - _t308 = *(bool*)&__or_tmp_3; - if (!_t308) goto else88; + goto endif82; + else81:; + _t298 = (c == 9); + *(bool*)&__or_tmp_3 = _t298; + endif82:; + bool _t299; + _t299 = *(bool*)&__or_tmp_3; + if (!_t299) goto else83; *(bool*)&__or_tmp_2 = 1; - goto endif89; - else88:; - _t309 = (c == 10); - *(bool*)&__or_tmp_2 = _t309; - endif89:; - bool _t310; - _t310 = *(bool*)&__or_tmp_2; - if (!_t310) goto else90; + goto endif84; + else83:; + _t300 = (c == 10); + *(bool*)&__or_tmp_2 = _t300; + endif84:; + bool _t301; + _t301 = *(bool*)&__or_tmp_2; + if (!_t301) goto else85; *(bool*)&__or_tmp_1 = 1; - goto endif91; - else90:; - _t311 = (c == 13); - *(bool*)&__or_tmp_1 = _t311; - endif91:; - bool _t312; - _t312 = *(bool*)&__or_tmp_1; - if (!_t312) goto else92; + goto endif86; + else85:; + _t302 = (c == 13); + *(bool*)&__or_tmp_1 = _t302; + endif86:; + bool _t303; + _t303 = *(bool*)&__or_tmp_1; + if (!_t303) goto else87; { JsonParser_Advance(p); } - goto endif93; - else92:; + goto endif88; + else87:; { return; } - endif93:; + endif88:; } - goto while83; - wend85:; + goto while79; + wend80:; } bool JsonParser_Match(JsonParser* p, const char* expected) { + int _t306; + int _t308; + int _t309; + int _t312; int _t315; - int _t317; + int _t316; int _t318; - int _t321; - int _t324; - int _t325; - int _t327; unsigned int elen; - unsigned int _t313; - _t313 = String_Len(expected); - elen = _t313; - unsigned int _t314; - _t314 = p->pos; - _t315 = _t314 + elen; - unsigned int _t316; - _t316 = p->len; - _t317 = (_t315 > _t316); - if (!_t317) goto endif95; + unsigned int _t304; + _t304 = String_Len(expected); + elen = _t304; + unsigned int _t305; + _t305 = p->pos; + _t306 = _t305 + elen; + unsigned int _t307; + _t307 = p->len; + _t308 = (_t306 > _t307); + if (!_t308) goto endif90; { return 0; } - endif95:; + endif90:; unsigned int i; i = 0; - while96:; - _t318 = (i < elen); - if (!_t318) goto wend98; + while91:; + _t309 = (i < elen); + if (!_t309) goto wend92; { - const char* _t319; - _t319 = p->src; - unsigned int _t320; - _t320 = p->pos; - _t321 = _t320 + i; - int _t322; - _t322 = _t319[_t321]; - int _t323; - _t323 = expected[i]; - _t324 = (_t322 != _t323); - if (!_t324) goto endif100; + const char* _t310; + _t310 = p->src; + unsigned int _t311; + _t311 = p->pos; + _t312 = _t311 + i; + int _t313; + _t313 = _t310[_t312]; + int _t314; + _t314 = expected[i]; + _t315 = (_t313 != _t314); + if (!_t315) goto endif94; { return 0; } - endif100:; - _t325 = i + 1; - i = _t325; + endif94:; + _t316 = i + 1; + i = _t316; } - goto while96; - wend98:; - unsigned int _t326; - _t326 = p->pos; - _t327 = _t326 + elen; - p->pos = _t327; + goto while91; + wend92:; + unsigned int _t317; + _t317 = p->pos; + _t318 = _t317 + elen; + p->pos = _t318; return 1; } const char* JsonParser_ParseString(JsonParser* p) { - int _t329; - int _t332; + int _t320; + int _t323; + int _t324; + int _t326; + int _t328; + void* _t329; + int _t330; + void* _t331; + char _t332; int _t333; - int _t335; - int _t337; - void* _t338; + void* _t334; + char _t335; + int _t336; + void* _t337; + char _t338; int _t339; void* _t340; char _t341; @@ -2022,234 +2030,262 @@ const char* JsonParser_ParseString(JsonParser* p) { int _t348; void* _t349; char _t350; - int _t351; - void* _t352; - char _t353; - int _t354; + void* _t351; + char _t352; + void* _t353; + char _t354; void* _t355; char _t356; - int _t357; - void* _t358; - char _t359; + int _t358; + void* _t359; void* _t360; - char _t361; void* _t362; - char _t363; - void* _t364; - char _t365; - int _t367; - void* _t368; - void* _t369; - void* _t371; - int _t328; - _t328 = JsonParser_Peek(p); - _t329 = (_t328 != 34); - if (!_t329) goto endif102; + int _t319; + _t319 = JsonParser_Peek(p); + _t320 = (_t319 != 34); + if (!_t320) goto endif96; { p->error = "Expected string"; return ""; } - endif102:; + endif96:; JsonParser_Advance(p); StringBuilder sb; - StringBuilder _t330; - _t330 = StringBuilder_New(); - sb = _t330; - while103:; - if (!1) goto wend105; + StringBuilder _t321; + _t321 = StringBuilder_New(); + sb = _t321; + while97:; + if (!1) goto wend98; { int c; - int _t331; - _t331 = JsonParser_Peek(p); - c = _t331; + int _t322; + _t322 = JsonParser_Peek(p); + c = _t322; bool __or_tmp_4; - _t332 = (c == 0); - if (!_t332) goto else106; + _t323 = (c == 0); + if (!_t323) goto else99; *(bool*)&__or_tmp_4 = 1; - goto endif107; - else106:; - _t333 = (c == 34); - *(bool*)&__or_tmp_4 = _t333; - endif107:; - bool _t334; - _t334 = *(bool*)&__or_tmp_4; - if (!_t334) goto endif109; + goto endif100; + else99:; + _t324 = (c == 34); + *(bool*)&__or_tmp_4 = _t324; + endif100:; + bool _t325; + _t325 = *(bool*)&__or_tmp_4; + if (!_t325) goto endif102; { - goto wend105; + goto wend98; } - endif109:; - _t335 = (c == 92); - if (!_t335) goto else110; + endif102:; + _t326 = (c == 92); + if (!_t326) goto else103; { JsonParser_Advance(p); int esc; - int _t336; - _t336 = JsonParser_Peek(p); - esc = _t336; - _t337 = (esc == 0); - if (!_t337) goto endif113; + int _t327; + _t327 = JsonParser_Peek(p); + esc = _t327; + _t328 = (esc == 0); + if (!_t328) goto endif106; { p->error = "Unterminated string escape"; - _t338 = &sb; - StringBuilder_Free(_t338); + _t329 = &sb; + StringBuilder_Free(_t329); return ""; } - endif113:; - _t339 = (esc == 110); - if (!_t339) goto else114; + endif106:; + _t330 = (esc == 110); + if (!_t330) goto else107; + { + _t331 = &sb; + _t332 = (char)10; + StringBuilder_AppendChar(_t331, _t332); + } + goto endif108; + else107:; + _t333 = (esc == 116); + if (!_t333) goto else109; + { + _t334 = &sb; + _t335 = (char)9; + StringBuilder_AppendChar(_t334, _t335); + } + goto endif110; + else109:; + _t336 = (esc == 114); + if (!_t336) goto else111; + { + _t337 = &sb; + _t338 = (char)13; + StringBuilder_AppendChar(_t337, _t338); + } + goto endif112; + else111:; + _t339 = (esc == 98); + if (!_t339) goto else113; { _t340 = &sb; - _t341 = (char)10; + _t341 = (char)8; StringBuilder_AppendChar(_t340, _t341); } - goto endif115; - else114:; - _t342 = (esc == 116); - if (!_t342) goto else116; + goto endif114; + else113:; + _t342 = (esc == 102); + if (!_t342) goto else115; { _t343 = &sb; - _t344 = (char)9; + _t344 = (char)12; StringBuilder_AppendChar(_t343, _t344); } - goto endif117; - else116:; - _t345 = (esc == 114); - if (!_t345) goto else118; + goto endif116; + else115:; + _t345 = (esc == 34); + if (!_t345) goto else117; { _t346 = &sb; - _t347 = (char)13; + _t347 = (char)34; StringBuilder_AppendChar(_t346, _t347); } - goto endif119; - else118:; - _t348 = (esc == 98); - if (!_t348) goto else120; + goto endif118; + else117:; + _t348 = (esc == 92); + if (!_t348) goto else119; { _t349 = &sb; - _t350 = (char)8; + _t350 = (char)92; StringBuilder_AppendChar(_t349, _t350); } - goto endif121; - else120:; - _t351 = (esc == 102); - if (!_t351) goto else122; + goto endif120; + else119:; { - _t352 = &sb; - _t353 = (char)12; - StringBuilder_AppendChar(_t352, _t353); + _t351 = &sb; + _t352 = (char)92; + StringBuilder_AppendChar(_t351, _t352); + _t353 = &sb; + _t354 = (char)esc; + StringBuilder_AppendChar(_t353, _t354); } - goto endif123; - else122:; - _t354 = (esc == 34); - if (!_t354) goto else124; + endif120:; + endif118:; + endif116:; + endif114:; + endif112:; + endif110:; + endif108:; + JsonParser_Advance(p); + } + goto endif104; + else103:; { _t355 = &sb; - _t356 = (char)34; + _t356 = (char)c; StringBuilder_AppendChar(_t355, _t356); - } - goto endif125; - else124:; - _t357 = (esc == 92); - if (!_t357) goto else126; - { - _t358 = &sb; - _t359 = (char)92; - StringBuilder_AppendChar(_t358, _t359); - } - goto endif127; - else126:; - { - _t360 = &sb; - _t361 = (char)92; - StringBuilder_AppendChar(_t360, _t361); - _t362 = &sb; - _t363 = (char)esc; - StringBuilder_AppendChar(_t362, _t363); - } - endif127:; - endif125:; - endif123:; - endif121:; - endif119:; - endif117:; - endif115:; JsonParser_Advance(p); } - goto endif111; - else110:; - { - _t364 = &sb; - _t365 = (char)c; - StringBuilder_AppendChar(_t364, _t365); - JsonParser_Advance(p); + endif104:; } - endif111:; - } - goto while103; - wend105:; - int _t366; - _t366 = JsonParser_Peek(p); - _t367 = (_t366 != 34); - if (!_t367) goto endif129; + goto while97; + wend98:; + int _t357; + _t357 = JsonParser_Peek(p); + _t358 = (_t357 != 34); + if (!_t358) goto endif122; { p->error = "Unterminated string"; - _t368 = &sb; - StringBuilder_Free(_t368); + _t359 = &sb; + StringBuilder_Free(_t359); return ""; } - endif129:; + endif122:; JsonParser_Advance(p); const char* result; - _t369 = &sb; - const char* _t370; - _t370 = StringBuilder_Build(_t369); - result = _t370; - _t371 = &sb; - StringBuilder_Free(_t371); + _t360 = &sb; + const char* _t361; + _t361 = StringBuilder_Build(_t360); + result = _t361; + _t362 = &sb; + StringBuilder_Free(_t362); return result; } JsonValue JsonParser_ParseNumber(JsonParser* p) { - int _t374; - int _t376; - int _t377; - int _t380; - int _t382; - int _t383; - int _t387; - unsigned int start; - unsigned int _t372; - _t372 = p->pos; - start = _t372; - int c0; + int _t365; + int _t367; + int _t368; + int _t371; int _t373; - _t373 = JsonParser_Peek(p); - c0 = _t373; - _t374 = (c0 == 45); - if (!_t374) goto endif131; + int _t374; + int _t378; + unsigned int start; + unsigned int _t363; + _t363 = p->pos; + start = _t363; + int c0; + int _t364; + _t364 = JsonParser_Peek(p); + c0 = _t364; + _t365 = (c0 == 45); + if (!_t365) goto endif124; { JsonParser_Advance(p); } - endif131:; - while132:; + endif124:; + while125:; + if (!1) goto wend126; + { + int c; + int _t366; + _t366 = JsonParser_Peek(p); + c = _t366; + bool __and_tmp_5; + _t367 = (c >= 48); + if (!_t367) goto else127; + _t368 = (c <= 57); + *(bool*)&__and_tmp_5 = _t368; + goto endif128; + else127:; + *(bool*)&__and_tmp_5 = 0; + endif128:; + bool _t369; + _t369 = *(bool*)&__and_tmp_5; + if (!_t369) goto else129; + { + JsonParser_Advance(p); + } + goto endif130; + else129:; + { + goto wend126; + } + endif130:; + } + goto while125; + wend126:; + int _t370; + _t370 = JsonParser_Peek(p); + _t371 = (_t370 == 46); + if (!_t371) goto endif132; + { + JsonParser_Advance(p); + while133:; if (!1) goto wend134; { int c; - int _t375; - _t375 = JsonParser_Peek(p); - c = _t375; - bool __and_tmp_5; - _t376 = (c >= 48); - if (!_t376) goto else135; - _t377 = (c <= 57); - *(bool*)&__and_tmp_5 = _t377; + int _t372; + _t372 = JsonParser_Peek(p); + c = _t372; + bool __and_tmp_6; + _t373 = (c >= 48); + if (!_t373) goto else135; + _t374 = (c <= 57); + *(bool*)&__and_tmp_6 = _t374; goto endif136; else135:; - *(bool*)&__and_tmp_5 = 0; + *(bool*)&__and_tmp_6 = 0; endif136:; - bool _t378; - _t378 = *(bool*)&__and_tmp_5; - if (!_t378) goto else137; + bool _t375; + _t375 = *(bool*)&__and_tmp_6; + if (!_t375) goto else137; { JsonParser_Advance(p); } @@ -2260,1098 +2296,1061 @@ JsonValue JsonParser_ParseNumber(JsonParser* p) { } endif138:; } - goto while132; + goto while133; wend134:; - int _t379; - _t379 = JsonParser_Peek(p); - _t380 = (_t379 == 46); - if (!_t380) goto endif140; - { - JsonParser_Advance(p); - while141:; - if (!1) goto wend143; - { - int c; - int _t381; - _t381 = JsonParser_Peek(p); - c = _t381; - bool __and_tmp_6; - _t382 = (c >= 48); - if (!_t382) goto else144; - _t383 = (c <= 57); - *(bool*)&__and_tmp_6 = _t383; - goto endif145; - else144:; - *(bool*)&__and_tmp_6 = 0; - endif145:; - bool _t384; - _t384 = *(bool*)&__and_tmp_6; - if (!_t384) goto else146; - { - JsonParser_Advance(p); } - goto endif147; - else146:; - { - goto wend143; - } - endif147:; - } - goto while141; - wend143:; - } - endif140:; + endif132:; const char* numStr; - const char* _t385; - _t385 = p->src; - unsigned int _t386; - _t386 = p->pos; - _t387 = _t386 - start; - const char* _t388; - _t388 = String_Slice(_t385, start, _t387); - numStr = _t388; + const char* _t376; + _t376 = p->src; + unsigned int _t377; + _t377 = p->pos; + _t378 = _t377 - start; + const char* _t379; + _t379 = String_Slice(_t376, start, _t378); + numStr = _t379; double n; - double _t389; - _t389 = String_ToFloat(numStr); - n = _t389; - JsonValue _t390; - _t390 = Json_Number(n); - return _t390; + double _t380; + _t380 = String_ToFloat(numStr); + n = _t380; + JsonValue _t381; + _t381 = Json_Number(n); + return _t381; } JsonValue JsonParser_ParseArray(JsonParser* p) { - int _t393; - int _t396; - void* _t398; - int _t400; - int _t401; + int _t384; + int _t387; + void* _t389; + int _t391; + int _t392; JsonParser_Advance(p); JsonValue arr; - JsonValue _t391; - _t391 = Json_Array(); - arr = _t391; + JsonValue _t382; + _t382 = Json_Array(); + arr = _t382; JsonParser_SkipWhitespace(p); - int _t392; - _t392 = JsonParser_Peek(p); - _t393 = (_t392 == 93); - if (!_t393) goto endif149; + int _t383; + _t383 = JsonParser_Peek(p); + _t384 = (_t383 == 93); + if (!_t384) goto endif140; { JsonParser_Advance(p); return arr; } - endif149:; - while150:; - if (!1) goto wend152; + endif140:; + while141:; + if (!1) goto wend142; { JsonParser_SkipWhitespace(p); JsonValue val; - JsonValue _t394; - _t394 = JsonParser_ParseValue(p); - val = _t394; - const char* _t395; - _t395 = p->error; - _t396 = (_t395 != ""); - if (!_t396) goto endif154; + JsonValue _t385; + _t385 = JsonParser_ParseValue(p); + val = _t385; + const char* _t386; + _t386 = p->error; + _t387 = (_t386 != ""); + if (!_t387) goto endif144; { - JsonValue _t397; - _t397 = Json_Null(); - return _t397; + JsonValue _t388; + _t388 = Json_Null(); + return _t388; } - endif154:; - _t398 = &arr; - Json_ArrayPush(_t398, val); + endif144:; + _t389 = &arr; + Json_ArrayPush(_t389, val); JsonParser_SkipWhitespace(p); int c; - int _t399; - _t399 = JsonParser_Peek(p); - c = _t399; - _t400 = (c == 93); - if (!_t400) goto endif156; + int _t390; + _t390 = JsonParser_Peek(p); + c = _t390; + _t391 = (c == 93); + if (!_t391) goto endif146; { JsonParser_Advance(p); return arr; } - endif156:; - _t401 = (c == 44); - if (!_t401) goto else157; + endif146:; + _t392 = (c == 44); + if (!_t392) goto else147; { JsonParser_Advance(p); } - goto endif158; - else157:; + goto endif148; + else147:; { p->error = "Expected ',' or ']' in array"; - JsonValue _t402; - _t402 = Json_Null(); - return _t402; + JsonValue _t393; + _t393 = Json_Null(); + return _t393; } - endif158:; + endif148:; } - goto while150; - wend152:; + goto while141; + wend142:; } JsonValue JsonParser_ParseObject(JsonParser* p) { - int _t405; - int _t408; + int _t396; + int _t399; + int _t402; + int _t406; + void* _t408; + int _t410; int _t411; - int _t415; - void* _t417; - int _t419; - int _t420; JsonParser_Advance(p); JsonValue obj; - JsonValue _t403; - _t403 = Json_Object(); - obj = _t403; + JsonValue _t394; + _t394 = Json_Object(); + obj = _t394; JsonParser_SkipWhitespace(p); - int _t404; - _t404 = JsonParser_Peek(p); - _t405 = (_t404 == 125); - if (!_t405) goto endif160; + int _t395; + _t395 = JsonParser_Peek(p); + _t396 = (_t395 == 125); + if (!_t396) goto endif150; + { + JsonParser_Advance(p); + return obj; + } + endif150:; + while151:; + if (!1) goto wend152; + { + JsonParser_SkipWhitespace(p); + const char* key; + const char* _t397; + _t397 = JsonParser_ParseString(p); + key = _t397; + const char* _t398; + _t398 = p->error; + _t399 = (_t398 != ""); + if (!_t399) goto endif154; + { + JsonValue _t400; + _t400 = Json_Null(); + return _t400; + } + endif154:; + JsonParser_SkipWhitespace(p); + int _t401; + _t401 = JsonParser_Peek(p); + _t402 = (_t401 != 58); + if (!_t402) goto endif156; + { + p->error = "Expected ':' after object key"; + JsonValue _t403; + _t403 = Json_Null(); + return _t403; + } + endif156:; + JsonParser_Advance(p); + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t404; + _t404 = JsonParser_ParseValue(p); + val = _t404; + const char* _t405; + _t405 = p->error; + _t406 = (_t405 != ""); + if (!_t406) goto endif158; + { + JsonValue _t407; + _t407 = Json_Null(); + return _t407; + } + endif158:; + _t408 = &obj; + Json_ObjectSet(_t408, key, val); + JsonParser_SkipWhitespace(p); + int c; + int _t409; + _t409 = JsonParser_Peek(p); + c = _t409; + _t410 = (c == 125); + if (!_t410) goto endif160; { JsonParser_Advance(p); return obj; } endif160:; - while161:; - if (!1) goto wend163; + _t411 = (c == 44); + if (!_t411) goto else161; { - JsonParser_SkipWhitespace(p); - const char* key; - const char* _t406; - _t406 = JsonParser_ParseString(p); - key = _t406; - const char* _t407; - _t407 = p->error; - _t408 = (_t407 != ""); - if (!_t408) goto endif165; - { - JsonValue _t409; - _t409 = Json_Null(); - return _t409; + JsonParser_Advance(p); } - endif165:; - JsonParser_SkipWhitespace(p); - int _t410; - _t410 = JsonParser_Peek(p); - _t411 = (_t410 != 58); - if (!_t411) goto endif167; + goto endif162; + else161:; { - p->error = "Expected ':' after object key"; + p->error = "Expected ',' or '}' in object"; JsonValue _t412; _t412 = Json_Null(); return _t412; } - endif167:; - JsonParser_Advance(p); - JsonParser_SkipWhitespace(p); - JsonValue val; - JsonValue _t413; - _t413 = JsonParser_ParseValue(p); - val = _t413; - const char* _t414; - _t414 = p->error; - _t415 = (_t414 != ""); - if (!_t415) goto endif169; - { - JsonValue _t416; - _t416 = Json_Null(); - return _t416; + endif162:; } - endif169:; - _t417 = &obj; - Json_ObjectSet(_t417, key, val); - JsonParser_SkipWhitespace(p); - int c; - int _t418; - _t418 = JsonParser_Peek(p); - c = _t418; - _t419 = (c == 125); - if (!_t419) goto endif171; - { - JsonParser_Advance(p); - return obj; - } - endif171:; - _t420 = (c == 44); - if (!_t420) goto else172; - { - JsonParser_Advance(p); - } - goto endif173; - else172:; - { - p->error = "Expected ',' or '}' in object"; - JsonValue _t421; - _t421 = Json_Null(); - return _t421; - } - endif173:; - } - goto while161; - wend163:; + goto while151; + wend152:; } JsonValue JsonParser_ParseValue(JsonParser* p) { + int _t414; + int _t416; + int _t419; + int _t421; int _t423; - int _t425; - int _t428; - int _t430; - int _t432; + int _t427; + int _t431; + int _t435; int _t436; - int _t440; - int _t444; - int _t445; - int _t447; + int _t438; JsonParser_SkipWhitespace(p); int c; - int _t422; - _t422 = JsonParser_Peek(p); - c = _t422; - _t423 = (c == 0); - if (!_t423) goto endif175; + int _t413; + _t413 = JsonParser_Peek(p); + c = _t413; + _t414 = (c == 0); + if (!_t414) goto endif164; { p->error = "Unexpected end of input"; - JsonValue _t424; - _t424 = Json_Null(); - return _t424; + JsonValue _t415; + _t415 = Json_Null(); + return _t415; } - endif175:; - _t425 = (c == 34); - if (!_t425) goto endif177; + endif164:; + _t416 = (c == 34); + if (!_t416) goto endif166; { - const char* _t426; - _t426 = JsonParser_ParseString(p); - JsonValue _t427; - _t427 = Json_String(_t426); - return _t427; + const char* _t417; + _t417 = JsonParser_ParseString(p); + JsonValue _t418; + _t418 = Json_String(_t417); + return _t418; } - endif177:; - _t428 = (c == 123); - if (!_t428) goto endif179; + endif166:; + _t419 = (c == 123); + if (!_t419) goto endif168; + { + JsonValue _t420; + _t420 = JsonParser_ParseObject(p); + return _t420; + } + endif168:; + _t421 = (c == 91); + if (!_t421) goto endif170; + { + JsonValue _t422; + _t422 = JsonParser_ParseArray(p); + return _t422; + } + endif170:; + _t423 = (c == 116); + if (!_t423) goto endif172; + { + bool _t424; + _t424 = JsonParser_Match(p, "true"); + if (!_t424) goto endif174; + { + JsonValue _t425; + _t425 = Json_Bool(1); + return _t425; + } + endif174:; + p->error = "Expected 'true'"; + JsonValue _t426; + _t426 = Json_Null(); + return _t426; + } + endif172:; + _t427 = (c == 102); + if (!_t427) goto endif176; + { + bool _t428; + _t428 = JsonParser_Match(p, "false"); + if (!_t428) goto endif178; { JsonValue _t429; - _t429 = JsonParser_ParseObject(p); + _t429 = Json_Bool(0); return _t429; } - endif179:; - _t430 = (c == 91); - if (!_t430) goto endif181; - { - JsonValue _t431; - _t431 = JsonParser_ParseArray(p); - return _t431; + endif178:; + p->error = "Expected 'false'"; + JsonValue _t430; + _t430 = Json_Null(); + return _t430; } - endif181:; - _t432 = (c == 116); - if (!_t432) goto endif183; + endif176:; + _t431 = (c == 110); + if (!_t431) goto endif180; { - bool _t433; - _t433 = JsonParser_Match(p, "true"); - if (!_t433) goto endif185; + bool _t432; + _t432 = JsonParser_Match(p, "null"); + if (!_t432) goto endif182; { + JsonValue _t433; + _t433 = Json_Null(); + return _t433; + } + endif182:; + p->error = "Expected 'null'"; JsonValue _t434; - _t434 = Json_Bool(1); + _t434 = Json_Null(); return _t434; } - endif185:; - p->error = "Expected 'true'"; - JsonValue _t435; - _t435 = Json_Null(); - return _t435; - } - endif183:; - _t436 = (c == 102); - if (!_t436) goto endif187; - { - bool _t437; - _t437 = JsonParser_Match(p, "false"); - if (!_t437) goto endif189; - { - JsonValue _t438; - _t438 = Json_Bool(0); - return _t438; - } - endif189:; - p->error = "Expected 'false'"; - JsonValue _t439; - _t439 = Json_Null(); - return _t439; - } - endif187:; - _t440 = (c == 110); - if (!_t440) goto endif191; - { - bool _t441; - _t441 = JsonParser_Match(p, "null"); - if (!_t441) goto endif193; - { - JsonValue _t442; - _t442 = Json_Null(); - return _t442; - } - endif193:; - p->error = "Expected 'null'"; - JsonValue _t443; - _t443 = Json_Null(); - return _t443; - } - endif191:; + endif180:; bool __or_tmp_7; bool __and_tmp_8; - _t444 = (c >= 48); - if (!_t444) goto else194; - _t445 = (c <= 57); - *(bool*)&__and_tmp_8 = _t445; - goto endif195; - else194:; + _t435 = (c >= 48); + if (!_t435) goto else183; + _t436 = (c <= 57); + *(bool*)&__and_tmp_8 = _t436; + goto endif184; + else183:; *(bool*)&__and_tmp_8 = 0; - endif195:; - bool _t446; - _t446 = *(bool*)&__and_tmp_8; - if (!_t446) goto else196; + endif184:; + bool _t437; + _t437 = *(bool*)&__and_tmp_8; + if (!_t437) goto else185; *(bool*)&__or_tmp_7 = 1; - goto endif197; - else196:; - _t447 = (c == 45); - *(bool*)&__or_tmp_7 = _t447; - endif197:; - bool _t448; - _t448 = *(bool*)&__or_tmp_7; - if (!_t448) goto endif199; + goto endif186; + else185:; + _t438 = (c == 45); + *(bool*)&__or_tmp_7 = _t438; + endif186:; + bool _t439; + _t439 = *(bool*)&__or_tmp_7; + if (!_t439) goto endif188; { - JsonValue _t449; - _t449 = JsonParser_ParseNumber(p); - return _t449; + JsonValue _t440; + _t440 = JsonParser_ParseNumber(p); + return _t440; } - endif199:; + endif188:; p->error = "Unexpected character"; - JsonValue _t450; - _t450 = Json_Null(); - return _t450; + JsonValue _t441; + _t441 = Json_Null(); + return _t441; } JsonValue Json_Parse(const char* s) { - JsonParser _t452; - void* _t453; - void* _t455; - int _t457; - int _t460; + JsonParser _t443; + void* _t444; + void* _t446; + int _t448; + int _t451; JsonParser p; - unsigned int _t451; - _t451 = String_Len(s); - _t452 = (JsonParser){.src = s, .pos = 0, .len = _t451, .error = ""}; - p = _t452; + unsigned int _t442; + _t442 = String_Len(s); + _t443 = (JsonParser){.src = s, .pos = 0, .len = _t442, .error = ""}; + p = _t443; JsonValue result; - _t453 = &p; - JsonValue _t454; - _t454 = JsonParser_ParseValue(_t453); - result = _t454; - _t455 = &p; - JsonParser_SkipWhitespace(_t455); + _t444 = &p; + JsonValue _t445; + _t445 = JsonParser_ParseValue(_t444); + result = _t445; + _t446 = &p; + JsonParser_SkipWhitespace(_t446); bool __and_tmp_9; - const char* _t456; - _t456 = p.error; - _t457 = (_t456 == ""); - if (!_t457) goto else200; - unsigned int _t458; - _t458 = p.pos; - unsigned int _t459; - _t459 = p.len; - _t460 = (_t458 != _t459); - *(bool*)&__and_tmp_9 = _t460; - goto endif201; - else200:; + const char* _t447; + _t447 = p.error; + _t448 = (_t447 == ""); + if (!_t448) goto else189; + unsigned int _t449; + _t449 = p.pos; + unsigned int _t450; + _t450 = p.len; + _t451 = (_t449 != _t450); + *(bool*)&__and_tmp_9 = _t451; + goto endif190; + else189:; *(bool*)&__and_tmp_9 = 0; - endif201:; - bool _t461; - _t461 = *(bool*)&__and_tmp_9; - if (!_t461) goto endif203; + endif190:; + bool _t452; + _t452 = *(bool*)&__and_tmp_9; + if (!_t452) goto endif192; { p.error = "Trailing data after JSON value"; - JsonValue _t462; - _t462 = Json_Null(); - return _t462; + JsonValue _t453; + _t453 = Json_Null(); + return _t453; } - endif203:; + endif192:; return result; } void Json_StringifyImpl(StringBuilder* sb, JsonValue v) { - int _t464; - int _t466; - int _t469; + int _t455; + int _t457; + int _t460; + int _t463; + char _t464; + char _t466; + int _t468; + char _t469; + int _t471; int _t472; char _t473; - char _t475; - int _t477; - char _t478; - int _t480; - int _t481; - char _t482; - int _t485; - char _t486; - int _t488; + int _t476; + char _t477; + int _t479; + char _t480; + int _t482; + int _t483; + char _t484; + char _t485; + char _t488; char _t489; - int _t491; int _t492; char _t493; - char _t494; - char _t497; - char _t498; - int _t501; - char _t502; - int _t463; - _t463 = v.tag; - _t464 = (_t463 == JsonTagNull); - if (!_t464) goto endif205; + int _t454; + _t454 = v.tag; + _t455 = (_t454 == JsonTagNull); + if (!_t455) goto endif194; { StringBuilder_Append(sb, "null"); return; } - endif205:; - int _t465; - _t465 = v.tag; - _t466 = (_t465 == JsonTagBool); - if (!_t466) goto endif207; + endif194:; + int _t456; + _t456 = v.tag; + _t457 = (_t456 == JsonTagBool); + if (!_t457) goto endif196; { - bool _t467; - _t467 = v.boolVal; - if (!_t467) goto else208; + bool _t458; + _t458 = v.boolVal; + if (!_t458) goto else197; { StringBuilder_Append(sb, "true"); } - goto endif209; - else208:; + goto endif198; + else197:; { StringBuilder_Append(sb, "false"); } - endif209:; + endif198:; return; } - endif207:; - int _t468; - _t468 = v.tag; - _t469 = (_t468 == JsonTagNumber); - if (!_t469) goto endif211; + endif196:; + int _t459; + _t459 = v.tag; + _t460 = (_t459 == JsonTagNumber); + if (!_t460) goto endif200; { - double _t470; - _t470 = v.numVal; - StringBuilder_AppendFloat(sb, _t470); + double _t461; + _t461 = v.numVal; + StringBuilder_AppendFloat(sb, _t461); return; } - endif211:; - int _t471; - _t471 = v.tag; - _t472 = (_t471 == JsonTagString); - if (!_t472) goto endif213; + endif200:; + int _t462; + _t462 = v.tag; + _t463 = (_t462 == JsonTagString); + if (!_t463) goto endif202; { - _t473 = (char)34; + _t464 = (char)34; + StringBuilder_AppendChar(sb, _t464); + const char* _t465; + _t465 = v.strVal; + StringBuilder_Append(sb, _t465); + _t466 = (char)34; + StringBuilder_AppendChar(sb, _t466); + return; + } + endif202:; + int _t467; + _t467 = v.tag; + _t468 = (_t467 == JsonTagArray); + if (!_t468) goto endif204; + { + _t469 = (char)91; + StringBuilder_AppendChar(sb, _t469); + unsigned int i; + i = 0; + while205:; + unsigned int _t470; + _t470 = v.arrLen; + _t471 = (i < _t470); + if (!_t471) goto wend206; + { + _t472 = (i > 0); + if (!_t472) goto endif208; + { + _t473 = (char)44; StringBuilder_AppendChar(sb, _t473); - const char* _t474; - _t474 = v.strVal; - StringBuilder_Append(sb, _t474); - _t475 = (char)34; - StringBuilder_AppendChar(sb, _t475); + } + endif208:; + JsonValue* _t474; + _t474 = v.arrData; + JsonValue _t475; + _t475 = _t474[i]; + Json_StringifyImpl(sb, _t475); + _t476 = i + 1; + i = _t476; + } + goto while205; + wend206:; + _t477 = (char)93; + StringBuilder_AppendChar(sb, _t477); return; } - endif213:; - int _t476; - _t476 = v.tag; - _t477 = (_t476 == JsonTagArray); - if (!_t477) goto endif215; + endif204:; + int _t478; + _t478 = v.tag; + _t479 = (_t478 == JsonTagObject); + if (!_t479) goto endif210; { - _t478 = (char)91; - StringBuilder_AppendChar(sb, _t478); + _t480 = (char)123; + StringBuilder_AppendChar(sb, _t480); unsigned int i; i = 0; - while216:; - unsigned int _t479; - _t479 = v.arrLen; - _t480 = (i < _t479); - if (!_t480) goto wend218; + while211:; + unsigned int _t481; + _t481 = v.objLen; + _t482 = (i < _t481); + if (!_t482) goto wend212; { - _t481 = (i > 0); - if (!_t481) goto endif220; + _t483 = (i > 0); + if (!_t483) goto endif214; { - _t482 = (char)44; - StringBuilder_AppendChar(sb, _t482); + _t484 = (char)44; + StringBuilder_AppendChar(sb, _t484); } - endif220:; - JsonValue* _t483; - _t483 = v.arrData; - JsonValue _t484; - _t484 = _t483[i]; - Json_StringifyImpl(sb, _t484); - _t485 = i + 1; - i = _t485; - } - goto while216; - wend218:; - _t486 = (char)93; - StringBuilder_AppendChar(sb, _t486); - return; - } - endif215:; - int _t487; - _t487 = v.tag; - _t488 = (_t487 == JsonTagObject); - if (!_t488) goto endif222; - { - _t489 = (char)123; + endif214:; + _t485 = (char)34; + StringBuilder_AppendChar(sb, _t485); + const char** _t486; + _t486 = v.objKeys; + const char* _t487; + _t487 = _t486[i]; + StringBuilder_Append(sb, _t487); + _t488 = (char)34; + StringBuilder_AppendChar(sb, _t488); + _t489 = (char)58; StringBuilder_AppendChar(sb, _t489); - unsigned int i; - i = 0; - while223:; - unsigned int _t490; - _t490 = v.objLen; - _t491 = (i < _t490); - if (!_t491) goto wend225; - { - _t492 = (i > 0); - if (!_t492) goto endif227; - { - _t493 = (char)44; + JsonValue* _t490; + _t490 = v.objValues; + JsonValue _t491; + _t491 = _t490[i]; + Json_StringifyImpl(sb, _t491); + _t492 = i + 1; + i = _t492; + } + goto while211; + wend212:; + _t493 = (char)125; StringBuilder_AppendChar(sb, _t493); - } - endif227:; - _t494 = (char)34; - StringBuilder_AppendChar(sb, _t494); - const char** _t495; - _t495 = v.objKeys; - const char* _t496; - _t496 = _t495[i]; - StringBuilder_Append(sb, _t496); - _t497 = (char)34; - StringBuilder_AppendChar(sb, _t497); - _t498 = (char)58; - StringBuilder_AppendChar(sb, _t498); - JsonValue* _t499; - _t499 = v.objValues; - JsonValue _t500; - _t500 = _t499[i]; - Json_StringifyImpl(sb, _t500); - _t501 = i + 1; - i = _t501; - } - goto while223; - wend225:; - _t502 = (char)125; - StringBuilder_AppendChar(sb, _t502); return; } - endif222:; + endif210:; } const char* Json_Stringify(JsonValue v) { - void* _t504; - void* _t505; + void* _t495; + void* _t496; StringBuilder sb; - StringBuilder _t503; - _t503 = StringBuilder_New(); - sb = _t503; - _t504 = &sb; - Json_StringifyImpl(_t504, v); - _t505 = &sb; - const char* _t506; - _t506 = StringBuilder_Build(_t505); - return _t506; + StringBuilder _t494; + _t494 = StringBuilder_New(); + sb = _t494; + _t495 = &sb; + Json_StringifyImpl(_t495, v); + _t496 = &sb; + const char* _t497; + _t497 = StringBuilder_Build(_t496); + return _t497; } unsigned int String_Len(const char* s) { - unsigned int _t507; - _t507 = bux_strlen(s); - return _t507; + unsigned int _t498; + _t498 = bux_strlen(s); + return _t498; } bool String_IsNull(const char* s) { - int _t509; - int _t508; - _t508 = bux_str_is_null(s); - _t509 = (_t508 != 0); - return _t509; + int _t500; + int _t499; + _t499 = bux_str_is_null(s); + _t500 = (_t499 != 0); + return _t500; } bool String_Eq(const char* a, const char* b) { - int _t511; - int _t510; - _t510 = bux_strcmp(a, b); - _t511 = (_t510 == 0); - return _t511; + int _t502; + int _t501; + _t501 = bux_strcmp(a, b); + _t502 = (_t501 == 0); + return _t502; } const char* String_Concat(const char* a, const char* b) { - int _t514; - int _t515; - char* _t517; + int _t505; + int _t506; + char* _t508; unsigned int len_a; - unsigned int _t512; - _t512 = bux_strlen(a); - len_a = _t512; + unsigned int _t503; + _t503 = bux_strlen(a); + len_a = _t503; unsigned int len_b; - unsigned int _t513; - _t513 = bux_strlen(b); - len_b = _t513; + unsigned int _t504; + _t504 = bux_strlen(b); + len_b = _t504; unsigned int total; - _t514 = len_a + len_b; - _t515 = _t514 + 1; - total = _t515; + _t505 = len_a + len_b; + _t506 = _t505 + 1; + total = _t506; char* buf; - void* _t516; - _t516 = bux_alloc(total); - _t517 = (char*)_t516; - buf = _t517; + void* _t507; + _t507 = bux_alloc(total); + _t508 = (char*)_t507; + buf = _t508; bux_strcpy(buf, a); bux_strcat(buf, b); return buf; } const char* String_Copy(const char* s) { - int _t519; - char* _t521; + int _t510; + char* _t512; unsigned int len; - unsigned int _t518; - _t518 = bux_strlen(s); - len = _t518; + unsigned int _t509; + _t509 = bux_strlen(s); + len = _t509; char* buf; - _t519 = len + 1; - void* _t520; - _t520 = bux_alloc(_t519); - _t521 = (char*)_t520; - buf = _t521; + _t510 = len + 1; + void* _t511; + _t511 = bux_alloc(_t510); + _t512 = (char*)_t511; + buf = _t512; bux_strcpy(buf, s); return buf; } bool String_StartsWith(const char* s, const char* prefix) { - int _t524; - int _t526; + int _t515; + int _t517; unsigned int s_len; - unsigned int _t522; - _t522 = bux_strlen(s); - s_len = _t522; + unsigned int _t513; + _t513 = bux_strlen(s); + s_len = _t513; unsigned int p_len; - unsigned int _t523; - _t523 = bux_strlen(prefix); - p_len = _t523; - _t524 = (p_len > s_len); - if (!_t524) goto endif229; + unsigned int _t514; + _t514 = bux_strlen(prefix); + p_len = _t514; + _t515 = (p_len > s_len); + if (!_t515) goto endif216; { return 0; } - endif229:; + endif216:; int r; - int _t525; - _t525 = bux_strncmp(s, prefix, p_len); - r = _t525; - _t526 = (r == 0); - return _t526; + int _t516; + _t516 = bux_strncmp(s, prefix, p_len); + r = _t516; + _t517 = (r == 0); + return _t517; } bool String_EndsWith(const char* s, const char* suffix) { - int _t529; - int _t530; - int _t533; + int _t520; + int _t521; + int _t524; unsigned int s_len; - unsigned int _t527; - _t527 = bux_strlen(s); - s_len = _t527; + unsigned int _t518; + _t518 = bux_strlen(s); + s_len = _t518; unsigned int suf_len; - unsigned int _t528; - _t528 = bux_strlen(suffix); - suf_len = _t528; - _t529 = (suf_len > s_len); - if (!_t529) goto endif231; + unsigned int _t519; + _t519 = bux_strlen(suffix); + suf_len = _t519; + _t520 = (suf_len > s_len); + if (!_t520) goto endif218; { return 0; } - endif231:; + endif218:; unsigned int start; - _t530 = s_len - suf_len; - start = _t530; + _t521 = s_len - suf_len; + start = _t521; const char* tail; - const char* _t531; - _t531 = bux_str_slice(s, start, suf_len); - tail = _t531; + const char* _t522; + _t522 = bux_str_slice(s, start, suf_len); + tail = _t522; bool eq; - int _t532; - _t532 = bux_strcmp(tail, suffix); - _t533 = (_t532 == 0); - eq = _t533; + int _t523; + _t523 = bux_strcmp(tail, suffix); + _t524 = (_t523 == 0); + eq = _t524; return eq; } bool String_Contains(const char* s, const char* substr) { - int _t535; + int _t526; int r; - int _t534; - _t534 = bux_str_contains(s, substr); - r = _t534; - _t535 = (r != 0); - return _t535; + int _t525; + _t525 = bux_str_contains(s, substr); + r = _t525; + _t526 = (r != 0); + return _t526; } const char* String_Slice(const char* s, unsigned int start, unsigned int len) { - const char* _t536; - _t536 = bux_str_slice(s, start, len); - return _t536; + const char* _t527; + _t527 = bux_str_slice(s, start, len); + return _t527; } const char* String_Trim(const char* s) { - const char* _t537; - _t537 = bux_str_trim(s); - return _t537; + const char* _t528; + _t528 = bux_str_trim(s); + return _t528; } const char* String_TrimLeft(const char* s) { - const char* _t538; - _t538 = bux_str_trim_left(s); - return _t538; + const char* _t529; + _t529 = bux_str_trim_left(s); + return _t529; } const char* String_TrimRight(const char* s) { - const char* _t539; - _t539 = bux_str_trim_right(s); - return _t539; + const char* _t530; + _t530 = bux_str_trim_right(s); + return _t530; } const char* String_FromInt(int64_t n) { - const char* _t540; - _t540 = bux_int_to_str(n); - return _t540; + const char* _t531; + _t531 = bux_int_to_str(n); + return _t531; } int64_t String_ToInt(const char* s) { - int64_t _t541; - _t541 = bux_str_to_int(s); - return _t541; + int64_t _t532; + _t532 = bux_str_to_int(s); + return _t532; } StringBuilder StringBuilder_New(void) { - StringBuilder _t543; - void* _t542; - _t542 = bux_sb_new(64); - _t543 = (StringBuilder){.handle = _t542}; - return _t543; + StringBuilder _t534; + void* _t533; + _t533 = bux_sb_new(64); + _t534 = (StringBuilder){.handle = _t533}; + return _t534; } StringBuilder StringBuilder_NewCap(unsigned int cap) { - StringBuilder _t545; - void* _t544; - _t544 = bux_sb_new(cap); - _t545 = (StringBuilder){.handle = _t544}; - return _t545; + StringBuilder _t536; + void* _t535; + _t535 = bux_sb_new(cap); + _t536 = (StringBuilder){.handle = _t535}; + return _t536; } void StringBuilder_Append(StringBuilder* sb, const char* s) { - void* _t546; - _t546 = sb->handle; - bux_sb_append(_t546, s); + void* _t537; + _t537 = sb->handle; + bux_sb_append(_t537, s); } void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) { - void* _t547; - _t547 = sb->handle; - bux_sb_append_int(_t547, n); + void* _t538; + _t538 = sb->handle; + bux_sb_append_int(_t538, n); } void StringBuilder_AppendFloat(StringBuilder* sb, double f) { - void* _t548; - _t548 = sb->handle; - bux_sb_append_float(_t548, f); + void* _t539; + _t539 = sb->handle; + bux_sb_append_float(_t539, f); } void StringBuilder_AppendChar(StringBuilder* sb, char c) { - void* _t549; - _t549 = sb->handle; - bux_sb_append_char(_t549, c); + void* _t540; + _t540 = sb->handle; + bux_sb_append_char(_t540, c); } const char* StringBuilder_Build(StringBuilder* sb) { - void* _t550; - _t550 = sb->handle; - const char* _t551; - _t551 = bux_sb_build(_t550); - return _t551; + void* _t541; + _t541 = sb->handle; + const char* _t542; + _t542 = bux_sb_build(_t541); + return _t542; } void StringBuilder_Free(StringBuilder* sb) { - void* _t552; - _t552 = sb->handle; - bux_sb_free(_t552); + void* _t543; + _t543 = sb->handle; + bux_sb_free(_t543); } unsigned int String_SplitCount(const char* s, const char* delim) { - unsigned int _t553; - _t553 = bux_str_split_count(s, delim); - return _t553; + unsigned int _t544; + _t544 = bux_str_split_count(s, delim); + return _t544; } const char* String_SplitPart(const char* s, const char* delim, unsigned int index) { - const char* _t554; - _t554 = bux_str_split_part(s, delim, index); - return _t554; + const char* _t545; + _t545 = bux_str_split_part(s, delim, index); + return _t545; } const char* String_Join2(const char* a, const char* b, const char* sep) { - const char* _t555; - _t555 = bux_str_join2(a, b, sep); - return _t555; + const char* _t546; + _t546 = bux_str_join2(a, b, sep); + return _t546; } const char* String_Chars(const char* s, unsigned int index) { - const char* _t556; - _t556 = bux_str_slice(s, index, 1); - return _t556; + const char* _t547; + _t547 = bux_str_slice(s, index, 1); + return _t547; } const char* String_Find(const char* haystack, const char* needle) { - const char* _t557; - _t557 = bux_strstr(haystack, needle); - return _t557; + const char* _t548; + _t548 = bux_strstr(haystack, needle); + return _t548; } unsigned int String_Offset(const char* pos, const char* base) { - unsigned int _t558; - _t558 = bux_str_offset(pos, base); - return _t558; + unsigned int _t549; + _t549 = bux_str_offset(pos, base); + return _t549; } const char* String_Replace(const char* s, const char* old, const char* new) { - int _t564; - int _t566; - int _t567; + int _t555; + int _t557; + int _t558; const char* pos; - const char* _t559; - _t559 = bux_strstr(s, old); - pos = _t559; - bool _t560; - _t560 = String_IsNull(pos); - if (!_t560) goto endif233; + const char* _t550; + _t550 = bux_strstr(s, old); + pos = _t550; + bool _t551; + _t551 = String_IsNull(pos); + if (!_t551) goto endif220; { return s; } - endif233:; + endif220:; unsigned int oldLen; - unsigned int _t561; - _t561 = bux_strlen(old); - oldLen = _t561; + unsigned int _t552; + _t552 = bux_strlen(old); + oldLen = _t552; unsigned int prefixLen; - unsigned int _t562; - _t562 = String_Offset(pos, s); - prefixLen = _t562; + unsigned int _t553; + _t553 = String_Offset(pos, s); + prefixLen = _t553; const char* prefix; - const char* _t563; - _t563 = bux_str_slice(s, 0, prefixLen); - prefix = _t563; + const char* _t554; + _t554 = bux_str_slice(s, 0, prefixLen); + prefix = _t554; const char* suffix; - _t564 = prefixLen + oldLen; - unsigned int _t565; - _t565 = bux_strlen(s); - _t566 = _t565 - prefixLen; - _t567 = _t566 - oldLen; - const char* _t568; - _t568 = bux_str_slice(s, _t564, _t567); - suffix = _t568; + _t555 = prefixLen + oldLen; + unsigned int _t556; + _t556 = bux_strlen(s); + _t557 = _t556 - prefixLen; + _t558 = _t557 - oldLen; + const char* _t559; + _t559 = bux_str_slice(s, _t555, _t558); + suffix = _t559; const char* temp; - const char* _t569; - _t569 = String_Concat(prefix, new); - temp = _t569; + const char* _t560; + _t560 = String_Concat(prefix, new); + temp = _t560; const char* result; - const char* _t570; - _t570 = String_Concat(temp, suffix); - result = _t570; + const char* _t561; + _t561 = String_Concat(temp, suffix); + result = _t561; return result; } double String_ToFloat(const char* s) { - double _t571; - _t571 = bux_str_to_float(s); - return _t571; + double _t562; + _t562 = bux_str_to_float(s); + return _t562; } const char* String_FromBool(bool b) { - if (!b) goto endif235; + if (!b) goto endif222; { return "true"; } - endif235:; + endif222:; return "false"; } const char* String_FromFloat(double f) { - const char* _t572; - _t572 = bux_float_to_string(f); - return _t572; + const char* _t563; + _t563 = bux_float_to_string(f); + return _t563; } const char* String_Format1(const char* pattern, const char* a0) { - const char* _t573; - _t573 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); - return _t573; + const char* _t564; + _t564 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); + return _t564; } const char* String_Format2(const char* pattern, const char* a0, const char* a1) { - const char* _t574; - _t574 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); - return _t574; + const char* _t565; + _t565 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); + return _t565; } const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) { - const char* _t575; - _t575 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); - return _t575; + const char* _t566; + _t566 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); + return _t566; } void Channel_SendInt(Channel_int* ch, int value) { - void* _t577; - void* _t578; - void* _t576; - _t576 = ch->handle; - _t577 = &value; - _t578 = (void*)_t577; - bux_channel_send(_t576, _t578); + void* _t568; + void* _t569; + void* _t567; + _t567 = ch->handle; + _t568 = &value; + _t569 = (void*)_t568; + bux_channel_send(_t567, _t569); } int Channel_RecvInt(Channel_int* ch) { - void* _t580; - void* _t581; + void* _t571; + void* _t572; int result; result = 0; - void* _t579; - _t579 = ch->handle; - _t580 = &result; - _t581 = (void*)_t580; - bux_channel_recv(_t579, _t581); + void* _t570; + _t570 = ch->handle; + _t571 = &result; + _t572 = (void*)_t571; + bux_channel_recv(_t570, _t572); return result; } void Channel_SendFloat64(Channel_float64* ch, double value) { - void* _t583; - void* _t584; - void* _t582; - _t582 = ch->handle; - _t583 = &value; - _t584 = (void*)_t583; - bux_channel_send(_t582, _t584); + void* _t574; + void* _t575; + void* _t573; + _t573 = ch->handle; + _t574 = &value; + _t575 = (void*)_t574; + bux_channel_send(_t573, _t575); } double Channel_RecvFloat64(Channel_float64* ch) { - void* _t586; - void* _t587; + void* _t577; + void* _t578; double result; result = 0.0; - void* _t585; - _t585 = ch->handle; - _t586 = &result; - _t587 = (void*)_t586; - bux_channel_recv(_t585, _t587); + void* _t576; + _t576 = ch->handle; + _t577 = &result; + _t578 = (void*)_t577; + bux_channel_recv(_t576, _t578); return result; } const char* Hash_Sha1(const char* data) { - int _t589; + int _t580; int len; - unsigned int _t588; - _t588 = String_Len(data); - _t589 = (int)_t588; - len = _t589; + unsigned int _t579; + _t579 = String_Len(data); + _t580 = (int)_t579; + len = _t580; void* buf; - void* _t590; - _t590 = Alloc(20); - buf = _t590; + void* _t581; + _t581 = Alloc(20); + buf = _t581; bux_sha1(data, len, buf); const char* result; - const char* _t591; - _t591 = bux_bytes_to_hex(buf, 20); - result = _t591; + const char* _t582; + _t582 = bux_bytes_to_hex(buf, 20); + result = _t582; Free(buf); return result; } const char* Hash_Sha256(const char* data) { - int _t593; + int _t584; int len; - unsigned int _t592; - _t592 = String_Len(data); - _t593 = (int)_t592; - len = _t593; + unsigned int _t583; + _t583 = String_Len(data); + _t584 = (int)_t583; + len = _t584; void* buf; - void* _t594; - _t594 = Alloc(32); - buf = _t594; + void* _t585; + _t585 = Alloc(32); + buf = _t585; bux_sha256(data, len, buf); const char* result; - const char* _t595; - _t595 = bux_bytes_to_hex(buf, 32); - result = _t595; + const char* _t586; + _t586 = bux_bytes_to_hex(buf, 32); + result = _t586; Free(buf); return result; } const char* Hash_Sha384(const char* data) { - int _t597; + int _t588; int len; - unsigned int _t596; - _t596 = String_Len(data); - _t597 = (int)_t596; - len = _t597; + unsigned int _t587; + _t587 = String_Len(data); + _t588 = (int)_t587; + len = _t588; void* buf; - void* _t598; - _t598 = Alloc(48); - buf = _t598; + void* _t589; + _t589 = Alloc(48); + buf = _t589; bux_sha384(data, len, buf); const char* result; - const char* _t599; - _t599 = bux_bytes_to_hex(buf, 48); - result = _t599; + const char* _t590; + _t590 = bux_bytes_to_hex(buf, 48); + result = _t590; Free(buf); return result; } const char* Hash_Sha512(const char* data) { - int _t601; + int _t592; int len; - unsigned int _t600; - _t600 = String_Len(data); - _t601 = (int)_t600; - len = _t601; + unsigned int _t591; + _t591 = String_Len(data); + _t592 = (int)_t591; + len = _t592; void* buf; - void* _t602; - _t602 = Alloc(64); - buf = _t602; + void* _t593; + _t593 = Alloc(64); + buf = _t593; bux_sha512(data, len, buf); const char* result; - const char* _t603; - _t603 = bux_bytes_to_hex(buf, 64); - result = _t603; + const char* _t594; + _t594 = bux_bytes_to_hex(buf, 64); + result = _t594; Free(buf); return result; } void Hash_Sha256Raw(const char* data, void* out) { - int _t605; - unsigned int _t604; - _t604 = String_Len(data); - _t605 = (int)_t604; - bux_sha256(data, _t605, out); + int _t596; + unsigned int _t595; + _t595 = String_Len(data); + _t596 = (int)_t595; + bux_sha256(data, _t596, out); } void Hash_Sha384Raw(const char* data, void* out) { - int _t607; - unsigned int _t606; - _t606 = String_Len(data); - _t607 = (int)_t606; - bux_sha384(data, _t607, out); + int _t598; + unsigned int _t597; + _t597 = String_Len(data); + _t598 = (int)_t597; + bux_sha384(data, _t598, out); } void Hash_Sha512Raw(const char* data, void* out) { - int _t609; - unsigned int _t608; - _t608 = String_Len(data); - _t609 = (int)_t608; - bux_sha512(data, _t609, out); + int _t600; + unsigned int _t599; + _t599 = String_Len(data); + _t600 = (int)_t599; + bux_sha512(data, _t600, out); } int Hash_Sha1Size(void) { @@ -3371,1493 +3370,1493 @@ int Hash_Sha512Size(void) { } const char* Base64_Encode(const char* s) { - int _t611; - unsigned int _t610; - _t610 = String_Len(s); - _t611 = (int)_t610; - const char* _t612; - _t612 = bux_base64_encode(s, _t611); - return _t612; + int _t602; + unsigned int _t601; + _t601 = String_Len(s); + _t602 = (int)_t601; + const char* _t603; + _t603 = bux_base64_encode(s, _t602); + return _t603; } const char* Base64_Decode(const char* s) { - int _t614; - void* _t615; + int _t605; + void* _t606; int outlen; outlen = 0; - unsigned int _t613; - _t613 = String_Len(s); - _t614 = (int)_t613; - _t615 = &outlen; - const char* _t616; - _t616 = bux_base64_decode(s, _t614, _t615); - return _t616; + unsigned int _t604; + _t604 = String_Len(s); + _t605 = (int)_t604; + _t606 = &outlen; + const char* _t607; + _t607 = bux_base64_decode(s, _t605, _t606); + return _t607; } const char* Base64URL_Encode(const char* s) { - int _t618; - unsigned int _t617; - _t617 = String_Len(s); - _t618 = (int)_t617; - const char* _t619; - _t619 = bux_base64url_encode(s, _t618); - return _t619; + int _t609; + unsigned int _t608; + _t608 = String_Len(s); + _t609 = (int)_t608; + const char* _t610; + _t610 = bux_base64url_encode(s, _t609); + return _t610; } const char* Base64URL_Decode(const char* s) { - int _t621; - void* _t622; + int _t612; + void* _t613; int outlen; outlen = 0; - unsigned int _t620; - _t620 = String_Len(s); - _t621 = (int)_t620; - _t622 = &outlen; - const char* _t623; - _t623 = bux_base64url_decode(s, _t621, _t622); - return _t623; + unsigned int _t611; + _t611 = String_Len(s); + _t612 = (int)_t611; + _t613 = &outlen; + const char* _t614; + _t614 = bux_base64url_decode(s, _t612, _t613); + return _t614; } const char* Hmac_Sha256(const char* key, const char* message) { - int _t625; - int _t627; + int _t616; + int _t618; int kl; - unsigned int _t624; - _t624 = String_Len(key); - _t625 = (int)_t624; - kl = _t625; + unsigned int _t615; + _t615 = String_Len(key); + _t616 = (int)_t615; + kl = _t616; int ml; - unsigned int _t626; - _t626 = String_Len(message); - _t627 = (int)_t626; - ml = _t627; + unsigned int _t617; + _t617 = String_Len(message); + _t618 = (int)_t617; + ml = _t618; void* buf; - void* _t628; - _t628 = Alloc(32); - buf = _t628; + void* _t619; + _t619 = Alloc(32); + buf = _t619; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - const char* _t629; - _t629 = bux_bytes_to_hex(buf, 32); - result = _t629; + const char* _t620; + _t620 = bux_bytes_to_hex(buf, 32); + result = _t620; Free(buf); return result; } void Hmac_Sha256Raw(const char* key, const char* message, void* out) { - int _t631; - int _t633; - unsigned int _t630; - _t630 = String_Len(key); - _t631 = (int)_t630; - unsigned int _t632; - _t632 = String_Len(message); - _t633 = (int)_t632; - bux_hmac_sha256(key, _t631, message, _t633, out); + int _t622; + int _t624; + unsigned int _t621; + _t621 = String_Len(key); + _t622 = (int)_t621; + unsigned int _t623; + _t623 = String_Len(message); + _t624 = (int)_t623; + bux_hmac_sha256(key, _t622, message, _t624, out); } const char* Hmac_Sha256Base64(const char* key, const char* message) { - int _t635; - int _t637; - const char* _t639; + int _t626; + int _t628; + const char* _t630; int kl; - unsigned int _t634; - _t634 = String_Len(key); - _t635 = (int)_t634; - kl = _t635; + unsigned int _t625; + _t625 = String_Len(key); + _t626 = (int)_t625; + kl = _t626; int ml; - unsigned int _t636; - _t636 = String_Len(message); - _t637 = (int)_t636; - ml = _t637; + unsigned int _t627; + _t627 = String_Len(message); + _t628 = (int)_t627; + ml = _t628; void* buf; - void* _t638; - _t638 = Alloc(32); - buf = _t638; + void* _t629; + _t629 = Alloc(32); + buf = _t629; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - _t639 = (const char*)buf; - const char* _t640; - _t640 = bux_base64_encode(_t639, 32); - result = _t640; + _t630 = (const char*)buf; + const char* _t631; + _t631 = bux_base64_encode(_t630, 32); + result = _t631; Free(buf); return result; } const char* Hmac_Sha384(const char* key, const char* message) { - int _t642; - int _t644; + int _t633; + int _t635; int kl; - unsigned int _t641; - _t641 = String_Len(key); - _t642 = (int)_t641; - kl = _t642; + unsigned int _t632; + _t632 = String_Len(key); + _t633 = (int)_t632; + kl = _t633; int ml; - unsigned int _t643; - _t643 = String_Len(message); - _t644 = (int)_t643; - ml = _t644; + unsigned int _t634; + _t634 = String_Len(message); + _t635 = (int)_t634; + ml = _t635; void* buf; - void* _t645; - _t645 = Alloc(48); - buf = _t645; + void* _t636; + _t636 = Alloc(48); + buf = _t636; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - const char* _t646; - _t646 = bux_bytes_to_hex(buf, 48); - result = _t646; + const char* _t637; + _t637 = bux_bytes_to_hex(buf, 48); + result = _t637; Free(buf); return result; } void Hmac_Sha384Raw(const char* key, const char* message, void* out) { - int _t648; - int _t650; - unsigned int _t647; - _t647 = String_Len(key); - _t648 = (int)_t647; - unsigned int _t649; - _t649 = String_Len(message); - _t650 = (int)_t649; - bux_hmac_sha384(key, _t648, message, _t650, out); + int _t639; + int _t641; + unsigned int _t638; + _t638 = String_Len(key); + _t639 = (int)_t638; + unsigned int _t640; + _t640 = String_Len(message); + _t641 = (int)_t640; + bux_hmac_sha384(key, _t639, message, _t641, out); } const char* Hmac_Sha384Base64(const char* key, const char* message) { - int _t652; - int _t654; - const char* _t656; + int _t643; + int _t645; + const char* _t647; int kl; - unsigned int _t651; - _t651 = String_Len(key); - _t652 = (int)_t651; - kl = _t652; + unsigned int _t642; + _t642 = String_Len(key); + _t643 = (int)_t642; + kl = _t643; int ml; - unsigned int _t653; - _t653 = String_Len(message); - _t654 = (int)_t653; - ml = _t654; + unsigned int _t644; + _t644 = String_Len(message); + _t645 = (int)_t644; + ml = _t645; void* buf; - void* _t655; - _t655 = Alloc(48); - buf = _t655; + void* _t646; + _t646 = Alloc(48); + buf = _t646; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - _t656 = (const char*)buf; - const char* _t657; - _t657 = bux_base64_encode(_t656, 48); - result = _t657; + _t647 = (const char*)buf; + const char* _t648; + _t648 = bux_base64_encode(_t647, 48); + result = _t648; Free(buf); return result; } const char* Hmac_Sha512(const char* key, const char* message) { - int _t659; - int _t661; + int _t650; + int _t652; int kl; - unsigned int _t658; - _t658 = String_Len(key); - _t659 = (int)_t658; - kl = _t659; + unsigned int _t649; + _t649 = String_Len(key); + _t650 = (int)_t649; + kl = _t650; int ml; - unsigned int _t660; - _t660 = String_Len(message); - _t661 = (int)_t660; - ml = _t661; + unsigned int _t651; + _t651 = String_Len(message); + _t652 = (int)_t651; + ml = _t652; void* buf; - void* _t662; - _t662 = Alloc(64); - buf = _t662; + void* _t653; + _t653 = Alloc(64); + buf = _t653; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - const char* _t663; - _t663 = bux_bytes_to_hex(buf, 64); - result = _t663; + const char* _t654; + _t654 = bux_bytes_to_hex(buf, 64); + result = _t654; Free(buf); return result; } void Hmac_Sha512Raw(const char* key, const char* message, void* out) { - int _t665; - int _t667; - unsigned int _t664; - _t664 = String_Len(key); - _t665 = (int)_t664; - unsigned int _t666; - _t666 = String_Len(message); - _t667 = (int)_t666; - bux_hmac_sha512(key, _t665, message, _t667, out); + int _t656; + int _t658; + unsigned int _t655; + _t655 = String_Len(key); + _t656 = (int)_t655; + unsigned int _t657; + _t657 = String_Len(message); + _t658 = (int)_t657; + bux_hmac_sha512(key, _t656, message, _t658, out); } const char* Hmac_Sha512Base64(const char* key, const char* message) { - int _t669; - int _t671; - const char* _t673; + int _t660; + int _t662; + const char* _t664; int kl; - unsigned int _t668; - _t668 = String_Len(key); - _t669 = (int)_t668; - kl = _t669; + unsigned int _t659; + _t659 = String_Len(key); + _t660 = (int)_t659; + kl = _t660; int ml; - unsigned int _t670; - _t670 = String_Len(message); - _t671 = (int)_t670; - ml = _t671; + unsigned int _t661; + _t661 = String_Len(message); + _t662 = (int)_t661; + ml = _t662; void* buf; - void* _t672; - _t672 = Alloc(64); - buf = _t672; + void* _t663; + _t663 = Alloc(64); + buf = _t663; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - _t673 = (const char*)buf; - const char* _t674; - _t674 = bux_base64_encode(_t673, 64); - result = _t674; + _t664 = (const char*)buf; + const char* _t665; + _t665 = bux_base64_encode(_t664, 64); + result = _t665; Free(buf); return result; } const char* Random_Bytes(int n) { - int _t675; - unsigned int _t676; - int _t679; - const char* _t680; - _t675 = (n <= 0); - if (!_t675) goto endif237; + int _t666; + unsigned int _t667; + int _t670; + const char* _t671; + _t666 = (n <= 0); + if (!_t666) goto endif224; { return ""; } - endif237:; + endif224:; void* buf; - _t676 = (unsigned int)n; - void* _t677; - _t677 = Alloc(_t676); - buf = _t677; - int _t678; - _t678 = bux_random_bytes(buf, n); - _t679 = (_t678 != 1); - if (!_t679) goto endif239; + _t667 = (unsigned int)n; + void* _t668; + _t668 = Alloc(_t667); + buf = _t668; + int _t669; + _t669 = bux_random_bytes(buf, n); + _t670 = (_t669 != 1); + if (!_t670) goto endif226; { Free(buf); return ""; } - endif239:; - _t680 = (const char*)buf; - return _t680; + endif226:; + _t671 = (const char*)buf; + return _t671; } const char* Random_Hex(int n) { - int _t681; - unsigned int _t682; - int _t685; - _t681 = (n <= 0); - if (!_t681) goto endif241; + int _t672; + unsigned int _t673; + int _t676; + _t672 = (n <= 0); + if (!_t672) goto endif228; { return ""; } - endif241:; + endif228:; void* buf; - _t682 = (unsigned int)n; - void* _t683; - _t683 = Alloc(_t682); - buf = _t683; - int _t684; - _t684 = bux_random_bytes(buf, n); - _t685 = (_t684 != 1); - if (!_t685) goto endif243; + _t673 = (unsigned int)n; + void* _t674; + _t674 = Alloc(_t673); + buf = _t674; + int _t675; + _t675 = bux_random_bytes(buf, n); + _t676 = (_t675 != 1); + if (!_t676) goto endif230; { Free(buf); return ""; } - endif243:; + endif230:; const char* result; - const char* _t686; - _t686 = bux_bytes_to_hex(buf, n); - result = _t686; + const char* _t677; + _t677 = bux_bytes_to_hex(buf, n); + result = _t677; Free(buf); return result; } const char* Random_Base64(int n) { - int _t687; - unsigned int _t688; - int _t691; - const char* _t692; - _t687 = (n <= 0); - if (!_t687) goto endif245; + int _t678; + unsigned int _t679; + int _t682; + const char* _t683; + _t678 = (n <= 0); + if (!_t678) goto endif232; { return ""; } - endif245:; + endif232:; void* buf; - _t688 = (unsigned int)n; - void* _t689; - _t689 = Alloc(_t688); - buf = _t689; - int _t690; - _t690 = bux_random_bytes(buf, n); - _t691 = (_t690 != 1); - if (!_t691) goto endif247; + _t679 = (unsigned int)n; + void* _t680; + _t680 = Alloc(_t679); + buf = _t680; + int _t681; + _t681 = bux_random_bytes(buf, n); + _t682 = (_t681 != 1); + if (!_t682) goto endif234; { Free(buf); return ""; } - endif247:; + endif234:; const char* result; - _t692 = (const char*)buf; - const char* _t693; - _t693 = bux_base64_encode(_t692, n); - result = _t693; + _t683 = (const char*)buf; + const char* _t684; + _t684 = bux_base64_encode(_t683, n); + result = _t684; Free(buf); return result; } unsigned int Random_Uint32(void) { - int _t696; - unsigned int* _t697; - unsigned int _t698; + int _t687; + unsigned int* _t688; + unsigned int _t689; void* buf; - void* _t694; - _t694 = Alloc(4); - buf = _t694; - int _t695; - _t695 = bux_random_bytes(buf, 4); - _t696 = (_t695 != 1); - if (!_t696) goto endif249; + void* _t685; + _t685 = Alloc(4); + buf = _t685; + int _t686; + _t686 = bux_random_bytes(buf, 4); + _t687 = (_t686 != 1); + if (!_t687) goto endif236; { Free(buf); return 0; } - endif249:; + endif236:; unsigned int* ptr; - _t697 = (unsigned int*)buf; - ptr = _t697; + _t688 = (unsigned int*)buf; + ptr = _t688; unsigned int val; - _t698 = *ptr; - val = _t698; + _t689 = *ptr; + val = _t689; Free(buf); return val; } const char* Aes_GenerateKey(void) { - unsigned int _t699; - int _t702; - const char* _t703; + unsigned int _t690; + int _t693; + const char* _t694; void* buf; - _t699 = (unsigned int)AES_KEY_SIZE; - void* _t700; - _t700 = Alloc(_t699); - buf = _t700; - int _t701; - _t701 = bux_random_bytes(buf, AES_KEY_SIZE); - _t702 = (_t701 != 1); - if (!_t702) goto endif251; + _t690 = (unsigned int)AES_KEY_SIZE; + void* _t691; + _t691 = Alloc(_t690); + buf = _t691; + int _t692; + _t692 = bux_random_bytes(buf, AES_KEY_SIZE); + _t693 = (_t692 != 1); + if (!_t693) goto endif238; { Free(buf); return ""; } - endif251:; - _t703 = (const char*)buf; - return _t703; + endif238:; + _t694 = (const char*)buf; + return _t694; } const char* Aes_GenerateIV(void) { - unsigned int _t704; - int _t707; - const char* _t708; + unsigned int _t695; + int _t698; + const char* _t699; void* buf; - _t704 = (unsigned int)AES_IV_SIZE; - void* _t705; - _t705 = Alloc(_t704); - buf = _t705; - int _t706; - _t706 = bux_random_bytes(buf, AES_IV_SIZE); - _t707 = (_t706 != 1); - if (!_t707) goto endif253; + _t695 = (unsigned int)AES_IV_SIZE; + void* _t696; + _t696 = Alloc(_t695); + buf = _t696; + int _t697; + _t697 = bux_random_bytes(buf, AES_IV_SIZE); + _t698 = (_t697 != 1); + if (!_t698) goto endif240; { Free(buf); return ""; } - endif253:; - _t708 = (const char*)buf; - return _t708; + endif240:; + _t699 = (const char*)buf; + return _t699; } const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv) { - int _t710; - void* _t711; + int _t701; + void* _t702; int outlen; outlen = 0; - unsigned int _t709; - _t709 = String_Len(plain); - _t710 = (int)_t709; - _t711 = &outlen; - const char* _t712; - _t712 = bux_aes_256_cbc_encrypt(plain, _t710, key, iv, _t711); - return _t712; + unsigned int _t700; + _t700 = String_Len(plain); + _t701 = (int)_t700; + _t702 = &outlen; + const char* _t703; + _t703 = bux_aes_256_cbc_encrypt(plain, _t701, key, iv, _t702); + return _t703; } const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv) { - int _t714; - void* _t715; + int _t705; + void* _t706; int outlen; outlen = 0; - unsigned int _t713; - _t713 = String_Len(cipher); - _t714 = (int)_t713; - _t715 = &outlen; - const char* _t716; - _t716 = bux_aes_256_cbc_decrypt(cipher, _t714, key, iv, _t715); - return _t716; + unsigned int _t704; + _t704 = String_Len(cipher); + _t705 = (int)_t704; + _t706 = &outlen; + const char* _t707; + _t707 = bux_aes_256_cbc_decrypt(cipher, _t705, key, iv, _t706); + return _t707; } const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag) { - int _t718; - void* _t719; + int _t709; + void* _t710; int outlen; outlen = 0; - unsigned int _t717; - _t717 = String_Len(plain); - _t718 = (int)_t717; - _t719 = &outlen; - const char* _t720; - _t720 = bux_aes_256_gcm_encrypt(plain, _t718, key, iv, tag, _t719); - return _t720; + unsigned int _t708; + _t708 = String_Len(plain); + _t709 = (int)_t708; + _t710 = &outlen; + const char* _t711; + _t711 = bux_aes_256_gcm_encrypt(plain, _t709, key, iv, tag, _t710); + return _t711; } const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag) { - int _t722; - void* _t723; + int _t713; + void* _t714; int outlen; outlen = 0; - unsigned int _t721; - _t721 = String_Len(cipher); - _t722 = (int)_t721; - _t723 = &outlen; - const char* _t724; - _t724 = bux_aes_256_gcm_decrypt(cipher, _t722, key, iv, tag, _t723); - return _t724; + unsigned int _t712; + _t712 = String_Len(cipher); + _t713 = (int)_t712; + _t714 = &outlen; + const char* _t715; + _t715 = bux_aes_256_gcm_decrypt(cipher, _t713, key, iv, tag, _t714); + return _t715; } const char* Jwt_MakeHeader(JwtAlg alg) { - int _t725; - int _t726; - int _t727; - int _t728; - int _t729; - int _t730; - int _t731; - int _t732; - int _t733; - _t725 = (alg == JwtAlg_HS256); - if (!_t725) goto endif255; + int _t716; + int _t717; + int _t718; + int _t719; + int _t720; + int _t721; + int _t722; + int _t723; + int _t724; + _t716 = (alg == JwtAlg_HS256); + if (!_t716) goto endif242; { return "{\"alg\":\"HS256\",\"typ\":\"JWT\"}"; } - endif255:; - _t726 = (alg == JwtAlg_HS384); - if (!_t726) goto endif257; + endif242:; + _t717 = (alg == JwtAlg_HS384); + if (!_t717) goto endif244; { return "{\"alg\":\"HS384\",\"typ\":\"JWT\"}"; } - endif257:; - _t727 = (alg == JwtAlg_HS512); - if (!_t727) goto endif259; + endif244:; + _t718 = (alg == JwtAlg_HS512); + if (!_t718) goto endif246; { return "{\"alg\":\"HS512\",\"typ\":\"JWT\"}"; } - endif259:; - _t728 = (alg == JwtAlg_RS256); - if (!_t728) goto endif261; + endif246:; + _t719 = (alg == JwtAlg_RS256); + if (!_t719) goto endif248; { return "{\"alg\":\"RS256\",\"typ\":\"JWT\"}"; } - endif261:; - _t729 = (alg == JwtAlg_RS384); - if (!_t729) goto endif263; + endif248:; + _t720 = (alg == JwtAlg_RS384); + if (!_t720) goto endif250; { return "{\"alg\":\"RS384\",\"typ\":\"JWT\"}"; } - endif263:; - _t730 = (alg == JwtAlg_RS512); - if (!_t730) goto endif265; + endif250:; + _t721 = (alg == JwtAlg_RS512); + if (!_t721) goto endif252; { return "{\"alg\":\"RS512\",\"typ\":\"JWT\"}"; } - endif265:; - _t731 = (alg == JwtAlg_ES256); - if (!_t731) goto endif267; + endif252:; + _t722 = (alg == JwtAlg_ES256); + if (!_t722) goto endif254; { return "{\"alg\":\"ES256\",\"typ\":\"JWT\"}"; } - endif267:; - _t732 = (alg == JwtAlg_ES384); - if (!_t732) goto endif269; + endif254:; + _t723 = (alg == JwtAlg_ES384); + if (!_t723) goto endif256; { return "{\"alg\":\"ES384\",\"typ\":\"JWT\"}"; } - endif269:; - _t733 = (alg == JwtAlg_EdDSA); - if (!_t733) goto endif271; + endif256:; + _t724 = (alg == JwtAlg_EdDSA); + if (!_t724) goto endif258; { return "{\"alg\":\"EdDSA\",\"typ\":\"JWT\"}"; } - endif271:; + endif258:; return "{\"alg\":\"none\",\"typ\":\"JWT\"}"; } const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key) { - int _t734; - const char* _t736; - int _t738; - const char* _t740; + int _t725; + const char* _t727; + int _t729; + const char* _t731; + int _t733; + const char* _t735; + int _t737; + int _t740; int _t742; - const char* _t744; - int _t746; - int _t749; - int _t751; - int _t754; - int _t756; - int _t759; - int _t761; - int _t764; - int _t766; - int _t769; - int _t771; - _t734 = (alg == JwtAlg_HS256); - if (!_t734) goto endif273; + int _t745; + int _t747; + int _t750; + int _t752; + int _t755; + int _t757; + int _t760; + int _t762; + _t725 = (alg == JwtAlg_HS256); + if (!_t725) goto endif260; { void* buf; - void* _t735; - _t735 = Alloc(32); - buf = _t735; + void* _t726; + _t726 = Alloc(32); + buf = _t726; Hmac_Sha256Raw(key, signingInput, buf); const char* result; - _t736 = (const char*)buf; - const char* _t737; - _t737 = bux_base64_encode(_t736, 32); - result = _t737; + _t727 = (const char*)buf; + const char* _t728; + _t728 = bux_base64_encode(_t727, 32); + result = _t728; Free(buf); return result; } - endif273:; - _t738 = (alg == JwtAlg_HS384); - if (!_t738) goto endif275; + endif260:; + _t729 = (alg == JwtAlg_HS384); + if (!_t729) goto endif262; { void* buf; - void* _t739; - _t739 = Alloc(48); - buf = _t739; + void* _t730; + _t730 = Alloc(48); + buf = _t730; Hmac_Sha384Raw(key, signingInput, buf); const char* result; - _t740 = (const char*)buf; - const char* _t741; - _t741 = bux_base64_encode(_t740, 48); - result = _t741; + _t731 = (const char*)buf; + const char* _t732; + _t732 = bux_base64_encode(_t731, 48); + result = _t732; Free(buf); return result; } - endif275:; - _t742 = (alg == JwtAlg_HS512); - if (!_t742) goto endif277; + endif262:; + _t733 = (alg == JwtAlg_HS512); + if (!_t733) goto endif264; { void* buf; - void* _t743; - _t743 = Alloc(64); - buf = _t743; + void* _t734; + _t734 = Alloc(64); + buf = _t734; Hmac_Sha512Raw(key, signingInput, buf); const char* result; - _t744 = (const char*)buf; - const char* _t745; - _t745 = bux_base64_encode(_t744, 64); - result = _t745; + _t735 = (const char*)buf; + const char* _t736; + _t736 = bux_base64_encode(_t735, 64); + result = _t736; Free(buf); return result; } - endif277:; - _t746 = (alg == JwtAlg_RS256); - if (!_t746) goto endif279; + endif264:; + _t737 = (alg == JwtAlg_RS256); + if (!_t737) goto endif266; { const char* raw; - const char* _t747; - _t747 = Rsa_SignSha256(key, signingInput); - raw = _t747; - unsigned int _t748; - _t748 = String_Len(raw); - _t749 = (int)_t748; - const char* _t750; - _t750 = bux_base64_encode(raw, _t749); - return _t750; + const char* _t738; + _t738 = Rsa_SignSha256(key, signingInput); + raw = _t738; + unsigned int _t739; + _t739 = String_Len(raw); + _t740 = (int)_t739; + const char* _t741; + _t741 = bux_base64_encode(raw, _t740); + return _t741; } - endif279:; - _t751 = (alg == JwtAlg_RS384); - if (!_t751) goto endif281; + endif266:; + _t742 = (alg == JwtAlg_RS384); + if (!_t742) goto endif268; { const char* raw; - const char* _t752; - _t752 = Rsa_SignSha384(key, signingInput); - raw = _t752; - unsigned int _t753; - _t753 = String_Len(raw); - _t754 = (int)_t753; - const char* _t755; - _t755 = bux_base64_encode(raw, _t754); - return _t755; + const char* _t743; + _t743 = Rsa_SignSha384(key, signingInput); + raw = _t743; + unsigned int _t744; + _t744 = String_Len(raw); + _t745 = (int)_t744; + const char* _t746; + _t746 = bux_base64_encode(raw, _t745); + return _t746; } - endif281:; - _t756 = (alg == JwtAlg_RS512); - if (!_t756) goto endif283; + endif268:; + _t747 = (alg == JwtAlg_RS512); + if (!_t747) goto endif270; { const char* raw; - const char* _t757; - _t757 = Rsa_SignSha512(key, signingInput); - raw = _t757; - unsigned int _t758; - _t758 = String_Len(raw); - _t759 = (int)_t758; - const char* _t760; - _t760 = bux_base64_encode(raw, _t759); - return _t760; + const char* _t748; + _t748 = Rsa_SignSha512(key, signingInput); + raw = _t748; + unsigned int _t749; + _t749 = String_Len(raw); + _t750 = (int)_t749; + const char* _t751; + _t751 = bux_base64_encode(raw, _t750); + return _t751; } - endif283:; - _t761 = (alg == JwtAlg_ES256); - if (!_t761) goto endif285; + endif270:; + _t752 = (alg == JwtAlg_ES256); + if (!_t752) goto endif272; { const char* raw; - const char* _t762; - _t762 = Ecdsa_SignP256(key, signingInput); - raw = _t762; - unsigned int _t763; - _t763 = String_Len(raw); - _t764 = (int)_t763; - const char* _t765; - _t765 = bux_base64_encode(raw, _t764); - return _t765; + const char* _t753; + _t753 = Ecdsa_SignP256(key, signingInput); + raw = _t753; + unsigned int _t754; + _t754 = String_Len(raw); + _t755 = (int)_t754; + const char* _t756; + _t756 = bux_base64_encode(raw, _t755); + return _t756; } - endif285:; - _t766 = (alg == JwtAlg_ES384); - if (!_t766) goto endif287; + endif272:; + _t757 = (alg == JwtAlg_ES384); + if (!_t757) goto endif274; { const char* raw; - const char* _t767; - _t767 = Ecdsa_SignP384(key, signingInput); - raw = _t767; - unsigned int _t768; - _t768 = String_Len(raw); - _t769 = (int)_t768; - const char* _t770; - _t770 = bux_base64_encode(raw, _t769); - return _t770; + const char* _t758; + _t758 = Ecdsa_SignP384(key, signingInput); + raw = _t758; + unsigned int _t759; + _t759 = String_Len(raw); + _t760 = (int)_t759; + const char* _t761; + _t761 = bux_base64_encode(raw, _t760); + return _t761; } - endif287:; - _t771 = (alg == JwtAlg_EdDSA); - if (!_t771) goto endif289; + endif274:; + _t762 = (alg == JwtAlg_EdDSA); + if (!_t762) goto endif276; { - const char* _t772; - _t772 = Ed25519_Sign(key, signingInput); - return _t772; + const char* _t763; + _t763 = Ed25519_Sign(key, signingInput); + return _t763; } - endif289:; + endif276:; return ""; } bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key) { - int _t773; - const char* _t775; - int _t778; - const char* _t780; + int _t764; + const char* _t766; + int _t769; + const char* _t771; + int _t774; + const char* _t776; + int _t779; + int _t781; int _t783; - const char* _t785; - int _t788; - int _t790; - int _t792; - int _t794; - int _t796; - int _t798; - _t773 = (alg == JwtAlg_HS256); - if (!_t773) goto endif291; + int _t785; + int _t787; + int _t789; + _t764 = (alg == JwtAlg_HS256); + if (!_t764) goto endif278; { void* expectBuf; - void* _t774; - _t774 = Alloc(32); - expectBuf = _t774; + void* _t765; + _t765 = Alloc(32); + expectBuf = _t765; Hmac_Sha256Raw(key, signingInput, expectBuf); const char* expectB64; - _t775 = (const char*)expectBuf; - const char* _t776; - _t776 = bux_base64_encode(_t775, 32); - expectB64 = _t776; + _t766 = (const char*)expectBuf; + const char* _t767; + _t767 = bux_base64_encode(_t766, 32); + expectB64 = _t767; Free(expectBuf); - bool _t777; - _t777 = String_Eq(expectB64, signatureB64); - return _t777; + bool _t768; + _t768 = String_Eq(expectB64, signatureB64); + return _t768; } - endif291:; - _t778 = (alg == JwtAlg_HS384); - if (!_t778) goto endif293; + endif278:; + _t769 = (alg == JwtAlg_HS384); + if (!_t769) goto endif280; { void* expectBuf; - void* _t779; - _t779 = Alloc(48); - expectBuf = _t779; + void* _t770; + _t770 = Alloc(48); + expectBuf = _t770; Hmac_Sha384Raw(key, signingInput, expectBuf); const char* expectB64; - _t780 = (const char*)expectBuf; - const char* _t781; - _t781 = bux_base64_encode(_t780, 48); - expectB64 = _t781; + _t771 = (const char*)expectBuf; + const char* _t772; + _t772 = bux_base64_encode(_t771, 48); + expectB64 = _t772; Free(expectBuf); - bool _t782; - _t782 = String_Eq(expectB64, signatureB64); - return _t782; + bool _t773; + _t773 = String_Eq(expectB64, signatureB64); + return _t773; } - endif293:; - _t783 = (alg == JwtAlg_HS512); - if (!_t783) goto endif295; + endif280:; + _t774 = (alg == JwtAlg_HS512); + if (!_t774) goto endif282; { void* expectBuf; - void* _t784; - _t784 = Alloc(64); - expectBuf = _t784; + void* _t775; + _t775 = Alloc(64); + expectBuf = _t775; Hmac_Sha512Raw(key, signingInput, expectBuf); const char* expectB64; - _t785 = (const char*)expectBuf; - const char* _t786; - _t786 = bux_base64_encode(_t785, 64); - expectB64 = _t786; + _t776 = (const char*)expectBuf; + const char* _t777; + _t777 = bux_base64_encode(_t776, 64); + expectB64 = _t777; Free(expectBuf); - bool _t787; - _t787 = String_Eq(expectB64, signatureB64); - return _t787; + bool _t778; + _t778 = String_Eq(expectB64, signatureB64); + return _t778; } - endif295:; - _t788 = (alg == JwtAlg_RS256); - if (!_t788) goto endif297; + endif282:; + _t779 = (alg == JwtAlg_RS256); + if (!_t779) goto endif284; { - bool _t789; - _t789 = Rsa_VerifySha256(key, signingInput, signatureB64); - return _t789; + bool _t780; + _t780 = Rsa_VerifySha256(key, signingInput, signatureB64); + return _t780; } - endif297:; - _t790 = (alg == JwtAlg_RS384); - if (!_t790) goto endif299; + endif284:; + _t781 = (alg == JwtAlg_RS384); + if (!_t781) goto endif286; { - bool _t791; - _t791 = Rsa_VerifySha384(key, signingInput, signatureB64); - return _t791; + bool _t782; + _t782 = Rsa_VerifySha384(key, signingInput, signatureB64); + return _t782; } - endif299:; - _t792 = (alg == JwtAlg_RS512); - if (!_t792) goto endif301; + endif286:; + _t783 = (alg == JwtAlg_RS512); + if (!_t783) goto endif288; { - bool _t793; - _t793 = Rsa_VerifySha512(key, signingInput, signatureB64); - return _t793; + bool _t784; + _t784 = Rsa_VerifySha512(key, signingInput, signatureB64); + return _t784; } - endif301:; - _t794 = (alg == JwtAlg_ES256); - if (!_t794) goto endif303; + endif288:; + _t785 = (alg == JwtAlg_ES256); + if (!_t785) goto endif290; { - bool _t795; - _t795 = Ecdsa_VerifyP256(key, signingInput, signatureB64); - return _t795; + bool _t786; + _t786 = Ecdsa_VerifyP256(key, signingInput, signatureB64); + return _t786; } - endif303:; - _t796 = (alg == JwtAlg_ES384); - if (!_t796) goto endif305; + endif290:; + _t787 = (alg == JwtAlg_ES384); + if (!_t787) goto endif292; { - bool _t797; - _t797 = Ecdsa_VerifyP384(key, signingInput, signatureB64); - return _t797; + bool _t788; + _t788 = Ecdsa_VerifyP384(key, signingInput, signatureB64); + return _t788; } - endif305:; - _t798 = (alg == JwtAlg_EdDSA); - if (!_t798) goto endif307; + endif292:; + _t789 = (alg == JwtAlg_EdDSA); + if (!_t789) goto endif294; { - bool _t799; - _t799 = Ed25519_Verify(key, signatureB64, signingInput); - return _t799; + bool _t790; + _t790 = Ed25519_Verify(key, signatureB64, signingInput); + return _t790; } - endif307:; + endif294:; return 0; } const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key) { const char* headerB64; - const char* _t800; - _t800 = Base64URL_Encode(headerJson); - headerB64 = _t800; + const char* _t791; + _t791 = Base64URL_Encode(headerJson); + headerB64 = _t791; const char* payloadB64; - const char* _t801; - _t801 = Base64URL_Encode(payloadJson); - payloadB64 = _t801; + const char* _t792; + _t792 = Base64URL_Encode(payloadJson); + payloadB64 = _t792; const char* signingInput; - const char* _t802; - _t802 = String_Concat(headerB64, "."); - signingInput = _t802; + const char* _t793; + _t793 = String_Concat(headerB64, "."); + signingInput = _t793; const char* signingInputFull; - const char* _t803; - _t803 = String_Concat(signingInput, payloadB64); - signingInputFull = _t803; + const char* _t794; + _t794 = String_Concat(signingInput, payloadB64); + signingInputFull = _t794; const char* sigB64; - const char* _t804; - _t804 = Jwt_Sign(alg, signingInputFull, key); - sigB64 = _t804; + const char* _t795; + _t795 = Jwt_Sign(alg, signingInputFull, key); + sigB64 = _t795; const char* part1; - const char* _t805; - _t805 = String_Concat(signingInputFull, "."); - part1 = _t805; - const char* _t806; - _t806 = String_Concat(part1, sigB64); - return _t806; + const char* _t796; + _t796 = String_Concat(signingInputFull, "."); + part1 = _t796; + const char* _t797; + _t797 = String_Concat(part1, sigB64); + return _t797; } bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut) { - int _t808; - int _t815; + int _t799; + int _t806; unsigned int partCount; - unsigned int _t807; - _t807 = bux_str_split_count(token, "."); - partCount = _t807; - _t808 = (partCount != 3); - if (!_t808) goto endif309; + unsigned int _t798; + _t798 = bux_str_split_count(token, "."); + partCount = _t798; + _t799 = (partCount != 3); + if (!_t799) goto endif296; { return 0; } - endif309:; + endif296:; const char* headerB64; - const char* _t809; - _t809 = bux_str_split_part(token, ".", 0); - headerB64 = _t809; + const char* _t800; + _t800 = bux_str_split_part(token, ".", 0); + headerB64 = _t800; const char* payloadB64; - const char* _t810; - _t810 = bux_str_split_part(token, ".", 1); - payloadB64 = _t810; + const char* _t801; + _t801 = bux_str_split_part(token, ".", 1); + payloadB64 = _t801; const char* sigB64; - const char* _t811; - _t811 = bux_str_split_part(token, ".", 2); - sigB64 = _t811; + const char* _t802; + _t802 = bux_str_split_part(token, ".", 2); + sigB64 = _t802; const char* input; - const char* _t812; - _t812 = String_Concat(headerB64, "."); - input = _t812; + const char* _t803; + _t803 = String_Concat(headerB64, "."); + input = _t803; const char* signingInput; - const char* _t813; - _t813 = String_Concat(input, payloadB64); - signingInput = _t813; - bool _t814; - _t814 = Jwt_Verify(alg, signingInput, sigB64, key); - _t815 = !_t814; - if (!_t815) goto endif311; + const char* _t804; + _t804 = String_Concat(input, payloadB64); + signingInput = _t804; + bool _t805; + _t805 = Jwt_Verify(alg, signingInput, sigB64, key); + _t806 = !_t805; + if (!_t806) goto endif298; { return 0; } - endif311:; - const char* _t816; - _t816 = Base64URL_Decode(headerB64); - headerOut[0] = _t816; - const char* _t817; - _t817 = Base64URL_Decode(payloadB64); - payloadOut[0] = _t817; + endif298:; + const char* _t807; + _t807 = Base64URL_Decode(headerB64); + headerOut[0] = _t807; + const char* _t808; + _t808 = Base64URL_Decode(payloadB64); + payloadOut[0] = _t808; return 1; } const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret) { const char* header; - const char* _t818; - _t818 = Jwt_MakeHeader(JwtAlg_HS256); - header = _t818; - const char* _t819; - _t819 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); - return _t819; + const char* _t809; + _t809 = Jwt_MakeHeader(JwtAlg_HS256); + header = _t809; + const char* _t810; + _t810 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); + return _t810; } const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret) { const char* header; - const char* _t820; - _t820 = Jwt_MakeHeader(JwtAlg_HS384); - header = _t820; - const char* _t821; - _t821 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); - return _t821; + const char* _t811; + _t811 = Jwt_MakeHeader(JwtAlg_HS384); + header = _t811; + const char* _t812; + _t812 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); + return _t812; } const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret) { const char* header; - const char* _t822; - _t822 = Jwt_MakeHeader(JwtAlg_HS512); - header = _t822; - const char* _t823; - _t823 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); - return _t823; + const char* _t813; + _t813 = Jwt_MakeHeader(JwtAlg_HS512); + header = _t813; + const char* _t814; + _t814 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); + return _t814; } const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t824; - _t824 = Jwt_MakeHeader(JwtAlg_RS256); - header = _t824; - const char* _t825; - _t825 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); - return _t825; + const char* _t815; + _t815 = Jwt_MakeHeader(JwtAlg_RS256); + header = _t815; + const char* _t816; + _t816 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); + return _t816; } const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t826; - _t826 = Jwt_MakeHeader(JwtAlg_ES256); - header = _t826; - const char* _t827; - _t827 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); - return _t827; + const char* _t817; + _t817 = Jwt_MakeHeader(JwtAlg_ES256); + header = _t817; + const char* _t818; + _t818 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); + return _t818; } const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey) { const char* header; - const char* _t828; - _t828 = Jwt_MakeHeader(JwtAlg_EdDSA); - header = _t828; - const char* _t829; - _t829 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); - return _t829; + const char* _t819; + _t819 = Jwt_MakeHeader(JwtAlg_EdDSA); + header = _t819; + const char* _t820; + _t820 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); + return _t820; } const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data) { - int _t831; - int _t833; - void* _t834; + int _t822; + int _t824; + void* _t825; int siglen; siglen = 0; - unsigned int _t830; - _t830 = String_Len(pemPrivateKey); - _t831 = (int)_t830; - unsigned int _t832; - _t832 = String_Len(data); - _t833 = (int)_t832; - _t834 = &siglen; - const char* _t835; - _t835 = bux_ecdsa_sign_p256(pemPrivateKey, _t831, data, _t833, _t834); - return _t835; + unsigned int _t821; + _t821 = String_Len(pemPrivateKey); + _t822 = (int)_t821; + unsigned int _t823; + _t823 = String_Len(data); + _t824 = (int)_t823; + _t825 = &siglen; + const char* _t826; + _t826 = bux_ecdsa_sign_p256(pemPrivateKey, _t822, data, _t824, _t825); + return _t826; } const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data) { - int _t838; + int _t829; const char* raw; - const char* _t836; - _t836 = Ecdsa_SignP256(pemPrivateKey, data); - raw = _t836; - unsigned int _t837; - _t837 = String_Len(raw); - _t838 = (int)_t837; - const char* _t839; - _t839 = bux_base64_encode(raw, _t838); - return _t839; + const char* _t827; + _t827 = Ecdsa_SignP256(pemPrivateKey, data); + raw = _t827; + unsigned int _t828; + _t828 = String_Len(raw); + _t829 = (int)_t828; + const char* _t830; + _t830 = bux_base64_encode(raw, _t829); + return _t830; } bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature) { - int _t841; - int _t843; - int _t845; - int _t847; + int _t832; + int _t834; + int _t836; + int _t838; int r; - unsigned int _t840; - _t840 = String_Len(pemPublicKey); - _t841 = (int)_t840; - unsigned int _t842; - _t842 = String_Len(data); - _t843 = (int)_t842; - unsigned int _t844; - _t844 = String_Len(signature); - _t845 = (int)_t844; - int _t846; - _t846 = bux_ecdsa_verify_p256(pemPublicKey, _t841, data, _t843, signature, _t845); - r = _t846; - _t847 = (r == 1); - return _t847; + unsigned int _t831; + _t831 = String_Len(pemPublicKey); + _t832 = (int)_t831; + unsigned int _t833; + _t833 = String_Len(data); + _t834 = (int)_t833; + unsigned int _t835; + _t835 = String_Len(signature); + _t836 = (int)_t835; + int _t837; + _t837 = bux_ecdsa_verify_p256(pemPublicKey, _t832, data, _t834, signature, _t836); + r = _t837; + _t838 = (r == 1); + return _t838; } bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t849; - void* _t850; + int _t840; + void* _t841; int outlen; outlen = 0; const char* sig; - unsigned int _t848; - _t848 = String_Len(signatureB64); - _t849 = (int)_t848; - _t850 = &outlen; - const char* _t851; - _t851 = bux_base64_decode(signatureB64, _t849, _t850); - sig = _t851; - bool _t852; - _t852 = Ecdsa_VerifyP256(pemPublicKey, data, sig); - return _t852; + unsigned int _t839; + _t839 = String_Len(signatureB64); + _t840 = (int)_t839; + _t841 = &outlen; + const char* _t842; + _t842 = bux_base64_decode(signatureB64, _t840, _t841); + sig = _t842; + bool _t843; + _t843 = Ecdsa_VerifyP256(pemPublicKey, data, sig); + return _t843; } const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data) { - int _t854; - int _t856; - void* _t857; + int _t845; + int _t847; + void* _t848; int siglen; siglen = 0; - unsigned int _t853; - _t853 = String_Len(pemPrivateKey); - _t854 = (int)_t853; - unsigned int _t855; - _t855 = String_Len(data); - _t856 = (int)_t855; - _t857 = &siglen; - const char* _t858; - _t858 = bux_ecdsa_sign_p384(pemPrivateKey, _t854, data, _t856, _t857); - return _t858; + unsigned int _t844; + _t844 = String_Len(pemPrivateKey); + _t845 = (int)_t844; + unsigned int _t846; + _t846 = String_Len(data); + _t847 = (int)_t846; + _t848 = &siglen; + const char* _t849; + _t849 = bux_ecdsa_sign_p384(pemPrivateKey, _t845, data, _t847, _t848); + return _t849; } const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data) { - int _t861; + int _t852; const char* raw; - const char* _t859; - _t859 = Ecdsa_SignP384(pemPrivateKey, data); - raw = _t859; - unsigned int _t860; - _t860 = String_Len(raw); - _t861 = (int)_t860; - const char* _t862; - _t862 = bux_base64_encode(raw, _t861); - return _t862; + const char* _t850; + _t850 = Ecdsa_SignP384(pemPrivateKey, data); + raw = _t850; + unsigned int _t851; + _t851 = String_Len(raw); + _t852 = (int)_t851; + const char* _t853; + _t853 = bux_base64_encode(raw, _t852); + return _t853; } bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature) { - int _t864; - int _t866; - int _t868; - int _t870; + int _t855; + int _t857; + int _t859; + int _t861; int r; - unsigned int _t863; - _t863 = String_Len(pemPublicKey); - _t864 = (int)_t863; - unsigned int _t865; - _t865 = String_Len(data); - _t866 = (int)_t865; - unsigned int _t867; - _t867 = String_Len(signature); - _t868 = (int)_t867; - int _t869; - _t869 = bux_ecdsa_verify_p384(pemPublicKey, _t864, data, _t866, signature, _t868); - r = _t869; - _t870 = (r == 1); - return _t870; + unsigned int _t854; + _t854 = String_Len(pemPublicKey); + _t855 = (int)_t854; + unsigned int _t856; + _t856 = String_Len(data); + _t857 = (int)_t856; + unsigned int _t858; + _t858 = String_Len(signature); + _t859 = (int)_t858; + int _t860; + _t860 = bux_ecdsa_verify_p384(pemPublicKey, _t855, data, _t857, signature, _t859); + r = _t860; + _t861 = (r == 1); + return _t861; } bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t872; - void* _t873; + int _t863; + void* _t864; int outlen; outlen = 0; const char* sig; - unsigned int _t871; - _t871 = String_Len(signatureB64); - _t872 = (int)_t871; - _t873 = &outlen; - const char* _t874; - _t874 = bux_base64_decode(signatureB64, _t872, _t873); - sig = _t874; - bool _t875; - _t875 = Ecdsa_VerifyP384(pemPublicKey, data, sig); - return _t875; + unsigned int _t862; + _t862 = String_Len(signatureB64); + _t863 = (int)_t862; + _t864 = &outlen; + const char* _t865; + _t865 = bux_base64_decode(signatureB64, _t863, _t864); + sig = _t865; + bool _t866; + _t866 = Ecdsa_VerifyP384(pemPublicKey, data, sig); + return _t866; } bool Ed25519_Keypair(void* pubKey, void* privKey) { - int _t877; + int _t868; int r; - int _t876; - _t876 = bux_ed25519_keypair(pubKey, privKey); - r = _t876; - _t877 = (r == 1); - return _t877; + int _t867; + _t867 = bux_ed25519_keypair(pubKey, privKey); + r = _t867; + _t868 = (r == 1); + return _t868; } const char* Ed25519_KeypairBase64(void) { - unsigned int _t878; - unsigned int _t880; - int _t883; - const char* _t884; - const char* _t886; + unsigned int _t869; + unsigned int _t871; + int _t874; + const char* _t875; + const char* _t877; void* pubBuf; - _t878 = (unsigned int)ED25519_PUBKEY_SIZE; - void* _t879; - _t879 = Alloc(_t878); - pubBuf = _t879; + _t869 = (unsigned int)ED25519_PUBKEY_SIZE; + void* _t870; + _t870 = Alloc(_t869); + pubBuf = _t870; void* priv; - _t880 = (unsigned int)ED25519_PRIVKEY_SIZE; - void* _t881; - _t881 = Alloc(_t880); - priv = _t881; - int _t882; - _t882 = bux_ed25519_keypair(pubBuf, priv); - _t883 = (_t882 != 1); - if (!_t883) goto endif313; + _t871 = (unsigned int)ED25519_PRIVKEY_SIZE; + void* _t872; + _t872 = Alloc(_t871); + priv = _t872; + int _t873; + _t873 = bux_ed25519_keypair(pubBuf, priv); + _t874 = (_t873 != 1); + if (!_t874) goto endif300; { Free(pubBuf); Free(priv); return ""; } - endif313:; + endif300:; const char* pubB64; - _t884 = (const char*)pubBuf; - const char* _t885; - _t885 = bux_base64_encode(_t884, ED25519_PUBKEY_SIZE); - pubB64 = _t885; + _t875 = (const char*)pubBuf; + const char* _t876; + _t876 = bux_base64_encode(_t875, ED25519_PUBKEY_SIZE); + pubB64 = _t876; const char* privB64; - _t886 = (const char*)priv; - const char* _t887; - _t887 = bux_base64_encode(_t886, ED25519_PRIVKEY_SIZE); - privB64 = _t887; + _t877 = (const char*)priv; + const char* _t878; + _t878 = bux_base64_encode(_t877, ED25519_PRIVKEY_SIZE); + privB64 = _t878; Free(pubBuf); Free(priv); const char* pair; - const char* _t888; - _t888 = String_Concat(pubB64, ":"); - pair = _t888; - const char* _t889; - _t889 = String_Concat(pair, privB64); - return _t889; + const char* _t879; + _t879 = String_Concat(pubB64, ":"); + pair = _t879; + const char* _t880; + _t880 = String_Concat(pair, privB64); + return _t880; } const char* Ed25519_Sign(const char* privKey, const char* data) { - unsigned int _t890; - int _t893; - int _t895; - const char* _t896; + unsigned int _t881; + int _t884; + int _t886; + const char* _t887; void* sig; - _t890 = (unsigned int)ED25519_SIG_SIZE; - void* _t891; - _t891 = Alloc(_t890); - sig = _t891; - unsigned int _t892; - _t892 = String_Len(data); - _t893 = (int)_t892; - int _t894; - _t894 = bux_ed25519_sign(privKey, data, _t893, sig); - _t895 = (_t894 != 1); - if (!_t895) goto endif315; + _t881 = (unsigned int)ED25519_SIG_SIZE; + void* _t882; + _t882 = Alloc(_t881); + sig = _t882; + unsigned int _t883; + _t883 = String_Len(data); + _t884 = (int)_t883; + int _t885; + _t885 = bux_ed25519_sign(privKey, data, _t884, sig); + _t886 = (_t885 != 1); + if (!_t886) goto endif302; { Free(sig); return ""; } - endif315:; - _t896 = (const char*)sig; - return _t896; + endif302:; + _t887 = (const char*)sig; + return _t887; } const char* Ed25519_SignBase64(const char* privKey, const char* data) { - int _t899; + int _t890; const char* sig; - const char* _t897; - _t897 = Ed25519_Sign(privKey, data); - sig = _t897; - unsigned int _t898; - _t898 = String_Len(sig); - _t899 = (_t898 == 0); - if (!_t899) goto endif317; + const char* _t888; + _t888 = Ed25519_Sign(privKey, data); + sig = _t888; + unsigned int _t889; + _t889 = String_Len(sig); + _t890 = (_t889 == 0); + if (!_t890) goto endif304; { return ""; } - endif317:; - const char* _t900; - _t900 = bux_base64_encode(sig, ED25519_SIG_SIZE); - return _t900; + endif304:; + const char* _t891; + _t891 = bux_base64_encode(sig, ED25519_SIG_SIZE); + return _t891; } bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data) { - int _t902; - int _t904; + int _t893; + int _t895; int r; - unsigned int _t901; - _t901 = String_Len(data); - _t902 = (int)_t901; - int _t903; - _t903 = bux_ed25519_verify(pubKey, signature, data, _t902); - r = _t903; - _t904 = (r == 1); - return _t904; + unsigned int _t892; + _t892 = String_Len(data); + _t893 = (int)_t892; + int _t894; + _t894 = bux_ed25519_verify(pubKey, signature, data, _t893); + r = _t894; + _t895 = (r == 1); + return _t895; } bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data) { - int _t906; - void* _t907; - int _t909; + int _t897; + void* _t898; + int _t900; int outlen; outlen = 0; const char* sig; - unsigned int _t905; - _t905 = String_Len(signatureB64); - _t906 = (int)_t905; - _t907 = &outlen; - const char* _t908; - _t908 = bux_base64_decode(signatureB64, _t906, _t907); - sig = _t908; - _t909 = (outlen != ED25519_SIG_SIZE); - if (!_t909) goto endif319; + unsigned int _t896; + _t896 = String_Len(signatureB64); + _t897 = (int)_t896; + _t898 = &outlen; + const char* _t899; + _t899 = bux_base64_decode(signatureB64, _t897, _t898); + sig = _t899; + _t900 = (outlen != ED25519_SIG_SIZE); + if (!_t900) goto endif306; { return 0; } - endif319:; - bool _t910; - _t910 = Ed25519_Verify(pubKey, sig, data); - return _t910; + endif306:; + bool _t901; + _t901 = Ed25519_Verify(pubKey, sig, data); + return _t901; } const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data) { - int _t912; - int _t914; - void* _t915; + int _t903; + int _t905; + void* _t906; int siglen; siglen = 0; - unsigned int _t911; - _t911 = String_Len(pemPrivateKey); - _t912 = (int)_t911; - unsigned int _t913; - _t913 = String_Len(data); - _t914 = (int)_t913; - _t915 = &siglen; - const char* _t916; - _t916 = bux_rsa_sign_sha256(pemPrivateKey, _t912, data, _t914, _t915); - return _t916; + unsigned int _t902; + _t902 = String_Len(pemPrivateKey); + _t903 = (int)_t902; + unsigned int _t904; + _t904 = String_Len(data); + _t905 = (int)_t904; + _t906 = &siglen; + const char* _t907; + _t907 = bux_rsa_sign_sha256(pemPrivateKey, _t903, data, _t905, _t906); + return _t907; } const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data) { - int _t918; - int _t920; - void* _t921; + int _t909; + int _t911; + void* _t912; int siglen; siglen = 0; - unsigned int _t917; - _t917 = String_Len(pemPrivateKey); - _t918 = (int)_t917; - unsigned int _t919; - _t919 = String_Len(data); - _t920 = (int)_t919; - _t921 = &siglen; - const char* _t922; - _t922 = bux_rsa_sign_sha384(pemPrivateKey, _t918, data, _t920, _t921); - return _t922; + unsigned int _t908; + _t908 = String_Len(pemPrivateKey); + _t909 = (int)_t908; + unsigned int _t910; + _t910 = String_Len(data); + _t911 = (int)_t910; + _t912 = &siglen; + const char* _t913; + _t913 = bux_rsa_sign_sha384(pemPrivateKey, _t909, data, _t911, _t912); + return _t913; } const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data) { - int _t924; - int _t926; - void* _t927; + int _t915; + int _t917; + void* _t918; int siglen; siglen = 0; - unsigned int _t923; - _t923 = String_Len(pemPrivateKey); - _t924 = (int)_t923; - unsigned int _t925; - _t925 = String_Len(data); - _t926 = (int)_t925; - _t927 = &siglen; - const char* _t928; - _t928 = bux_rsa_sign_sha512(pemPrivateKey, _t924, data, _t926, _t927); - return _t928; + unsigned int _t914; + _t914 = String_Len(pemPrivateKey); + _t915 = (int)_t914; + unsigned int _t916; + _t916 = String_Len(data); + _t917 = (int)_t916; + _t918 = &siglen; + const char* _t919; + _t919 = bux_rsa_sign_sha512(pemPrivateKey, _t915, data, _t917, _t918); + return _t919; } const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data) { - int _t931; + int _t922; const char* raw; - const char* _t929; - _t929 = Rsa_SignSha256(pemPrivateKey, data); - raw = _t929; - unsigned int _t930; - _t930 = String_Len(raw); - _t931 = (int)_t930; - const char* _t932; - _t932 = bux_base64_encode(raw, _t931); - return _t932; + const char* _t920; + _t920 = Rsa_SignSha256(pemPrivateKey, data); + raw = _t920; + unsigned int _t921; + _t921 = String_Len(raw); + _t922 = (int)_t921; + const char* _t923; + _t923 = bux_base64_encode(raw, _t922); + return _t923; } const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data) { - int _t935; + int _t926; const char* raw; - const char* _t933; - _t933 = Rsa_SignSha384(pemPrivateKey, data); - raw = _t933; - unsigned int _t934; - _t934 = String_Len(raw); - _t935 = (int)_t934; - const char* _t936; - _t936 = bux_base64_encode(raw, _t935); - return _t936; + const char* _t924; + _t924 = Rsa_SignSha384(pemPrivateKey, data); + raw = _t924; + unsigned int _t925; + _t925 = String_Len(raw); + _t926 = (int)_t925; + const char* _t927; + _t927 = bux_base64_encode(raw, _t926); + return _t927; } const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data) { - int _t939; + int _t930; const char* raw; - const char* _t937; - _t937 = Rsa_SignSha512(pemPrivateKey, data); - raw = _t937; - unsigned int _t938; - _t938 = String_Len(raw); - _t939 = (int)_t938; - const char* _t940; - _t940 = bux_base64_encode(raw, _t939); - return _t940; + const char* _t928; + _t928 = Rsa_SignSha512(pemPrivateKey, data); + raw = _t928; + unsigned int _t929; + _t929 = String_Len(raw); + _t930 = (int)_t929; + const char* _t931; + _t931 = bux_base64_encode(raw, _t930); + return _t931; } bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature) { - int _t942; - int _t944; - int _t946; - int _t948; + int _t933; + int _t935; + int _t937; + int _t939; int r; - unsigned int _t941; - _t941 = String_Len(pemPublicKey); - _t942 = (int)_t941; - unsigned int _t943; - _t943 = String_Len(data); - _t944 = (int)_t943; - unsigned int _t945; - _t945 = String_Len(signature); - _t946 = (int)_t945; - int _t947; - _t947 = bux_rsa_verify_sha256(pemPublicKey, _t942, data, _t944, signature, _t946); - r = _t947; - _t948 = (r == 1); - return _t948; + unsigned int _t932; + _t932 = String_Len(pemPublicKey); + _t933 = (int)_t932; + unsigned int _t934; + _t934 = String_Len(data); + _t935 = (int)_t934; + unsigned int _t936; + _t936 = String_Len(signature); + _t937 = (int)_t936; + int _t938; + _t938 = bux_rsa_verify_sha256(pemPublicKey, _t933, data, _t935, signature, _t937); + r = _t938; + _t939 = (r == 1); + return _t939; } bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature) { - int _t950; - int _t952; - int _t954; - int _t956; + int _t941; + int _t943; + int _t945; + int _t947; int r; - unsigned int _t949; - _t949 = String_Len(pemPublicKey); - _t950 = (int)_t949; - unsigned int _t951; - _t951 = String_Len(data); - _t952 = (int)_t951; - unsigned int _t953; - _t953 = String_Len(signature); - _t954 = (int)_t953; - int _t955; - _t955 = bux_rsa_verify_sha384(pemPublicKey, _t950, data, _t952, signature, _t954); - r = _t955; - _t956 = (r == 1); - return _t956; + unsigned int _t940; + _t940 = String_Len(pemPublicKey); + _t941 = (int)_t940; + unsigned int _t942; + _t942 = String_Len(data); + _t943 = (int)_t942; + unsigned int _t944; + _t944 = String_Len(signature); + _t945 = (int)_t944; + int _t946; + _t946 = bux_rsa_verify_sha384(pemPublicKey, _t941, data, _t943, signature, _t945); + r = _t946; + _t947 = (r == 1); + return _t947; } bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature) { - int _t958; - int _t960; - int _t962; - int _t964; + int _t949; + int _t951; + int _t953; + int _t955; int r; - unsigned int _t957; - _t957 = String_Len(pemPublicKey); - _t958 = (int)_t957; - unsigned int _t959; - _t959 = String_Len(data); - _t960 = (int)_t959; - unsigned int _t961; - _t961 = String_Len(signature); - _t962 = (int)_t961; - int _t963; - _t963 = bux_rsa_verify_sha512(pemPublicKey, _t958, data, _t960, signature, _t962); - r = _t963; - _t964 = (r == 1); - return _t964; + unsigned int _t948; + _t948 = String_Len(pemPublicKey); + _t949 = (int)_t948; + unsigned int _t950; + _t950 = String_Len(data); + _t951 = (int)_t950; + unsigned int _t952; + _t952 = String_Len(signature); + _t953 = (int)_t952; + int _t954; + _t954 = bux_rsa_verify_sha512(pemPublicKey, _t949, data, _t951, signature, _t953); + r = _t954; + _t955 = (r == 1); + return _t955; } bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t966; - void* _t967; + int _t957; + void* _t958; int outlen; outlen = 0; const char* sig; - unsigned int _t965; - _t965 = String_Len(signatureB64); - _t966 = (int)_t965; - _t967 = &outlen; - const char* _t968; - _t968 = bux_base64_decode(signatureB64, _t966, _t967); - sig = _t968; - bool _t969; - _t969 = Rsa_VerifySha256(pemPublicKey, data, sig); - return _t969; + unsigned int _t956; + _t956 = String_Len(signatureB64); + _t957 = (int)_t956; + _t958 = &outlen; + const char* _t959; + _t959 = bux_base64_decode(signatureB64, _t957, _t958); + sig = _t959; + bool _t960; + _t960 = Rsa_VerifySha256(pemPublicKey, data, sig); + return _t960; } bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t971; - void* _t972; + int _t962; + void* _t963; int outlen; outlen = 0; const char* sig; - unsigned int _t970; - _t970 = String_Len(signatureB64); - _t971 = (int)_t970; - _t972 = &outlen; - const char* _t973; - _t973 = bux_base64_decode(signatureB64, _t971, _t972); - sig = _t973; - bool _t974; - _t974 = Rsa_VerifySha384(pemPublicKey, data, sig); - return _t974; + unsigned int _t961; + _t961 = String_Len(signatureB64); + _t962 = (int)_t961; + _t963 = &outlen; + const char* _t964; + _t964 = bux_base64_decode(signatureB64, _t962, _t963); + sig = _t964; + bool _t965; + _t965 = Rsa_VerifySha384(pemPublicKey, data, sig); + return _t965; } bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t976; - void* _t977; + int _t967; + void* _t968; int outlen; outlen = 0; const char* sig; - unsigned int _t975; - _t975 = String_Len(signatureB64); - _t976 = (int)_t975; - _t977 = &outlen; - const char* _t978; - _t978 = bux_base64_decode(signatureB64, _t976, _t977); - sig = _t978; - bool _t979; - _t979 = Rsa_VerifySha512(pemPublicKey, data, sig); - return _t979; + unsigned int _t966; + _t966 = String_Len(signatureB64); + _t967 = (int)_t966; + _t968 = &outlen; + const char* _t969; + _t969 = bux_base64_decode(signatureB64, _t967, _t968); + sig = _t969; + bool _t970; + _t970 = Rsa_VerifySha512(pemPublicKey, data, sig); + return _t970; } const char* ColorName(Color c) { - int _t980; - int _t981; - int _t982; - _t980 = (c == Color_Red); - if (!_t980) goto endif321; + int _t971; + int _t972; + int _t973; + _t971 = (c == Color_Red); + if (!_t971) goto endif308; { return "Red"; } - endif321:; - _t981 = (c == Color_Green); - if (!_t981) goto endif323; + endif308:; + _t972 = (c == Color_Green); + if (!_t972) goto endif310; { return "Green"; } - endif323:; - _t982 = (c == Color_Blue); - if (!_t982) goto endif325; + endif310:; + _t973 = (c == Color_Blue); + if (!_t973) goto endif312; { return "Blue"; } - endif325:; + endif312:; return "Unknown"; } int Main(void) { - int _t984; + int _t975; Color myColor; myColor = Color_Green; PrintLine("My color is:"); - const char* _t983; - _t983 = ColorName(myColor); - PrintLine(_t983); + const char* _t974; + _t974 = ColorName(myColor); + PrintLine(_t974); PrintLine("Color value:"); - _t984 = (int)myColor; - PrintInt(_t984); + _t975 = (int)myColor; + PrintInt(_t975); PrintLine(""); return 0; } diff --git a/tests/golden/fibonacci/expected.c b/tests/golden/fibonacci/expected.c index a4b8171..404bec1 100644 --- a/tests/golden/fibonacci/expected.c +++ b/tests/golden/fibonacci/expected.c @@ -198,6 +198,34 @@ extern const char* bux_base64_decode(const char* data, int len, int* outlen); #define ED25519_PRIVKEY_SIZE 32 #define ED25519_SIG_SIZE 64 +typedef struct Channel_float64 { + void* handle; +} Channel_float64; + +typedef struct TaskHandle { + void* handle; +} TaskHandle; + +typedef struct RwLock { + void* handle; +} RwLock; + +typedef struct Channel_int { + void* handle; +} Channel_int; + +typedef enum { + JwtAlg_HS256, + JwtAlg_HS384, + JwtAlg_HS512, + JwtAlg_RS256, + JwtAlg_RS384, + JwtAlg_RS512, + JwtAlg_ES256, + JwtAlg_ES384, + JwtAlg_EdDSA +} JwtAlg; + typedef enum { Result_Ok, Result_Err @@ -227,31 +255,6 @@ typedef struct { Option_Data data; } Option; -typedef enum { - JwtAlg_HS256, - JwtAlg_HS384, - JwtAlg_HS512, - JwtAlg_RS256, - JwtAlg_RS384, - JwtAlg_RS512, - JwtAlg_ES256, - JwtAlg_ES384, - JwtAlg_EdDSA -} JwtAlg; - - -typedef struct TaskHandle { - void* handle; -} TaskHandle; - -typedef struct Mutex { - void* handle; -} Mutex; - -typedef struct RwLock { - void* handle; -} RwLock; - typedef struct JsonValue { int tag; bool boolVal; @@ -266,6 +269,14 @@ typedef struct JsonValue { unsigned int objCap; } JsonValue; +typedef struct Mutex { + void* handle; +} Mutex; + +typedef struct StringBuilder { + void* handle; +} StringBuilder; + typedef struct JsonParser { const char* src; unsigned int pos; @@ -273,18 +284,6 @@ typedef struct JsonParser { const char* error; } JsonParser; -typedef struct StringBuilder { - void* handle; -} StringBuilder; - -typedef struct Channel_int { - void* handle; -} Channel_int; - -typedef struct Channel_float64 { - void* handle; -} Channel_float64; - bool DirExists(const char* path); bool Mkdir(const char* path); const char** ListDir(const char* dir, const char* ext, int* count); @@ -867,7 +866,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { tmplLen = _t60; while1:; _t61 = (i < tmplLen); - if (!_t61) goto wend3; + if (!_t61) goto wend2; { const char* ch; const char* _t62; @@ -875,13 +874,13 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { ch = _t62; bool _t63; _t63 = String_Eq(ch, "{"); - if (!_t63) goto endif5; + if (!_t63) goto endif4; { unsigned int digitIdx; _t64 = i + 1; digitIdx = _t64; _t65 = (digitIdx < tmplLen); - if (!_t65) goto endif7; + if (!_t65) goto endif6; { const char* digitCh; const char* _t66; @@ -893,22 +892,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { d = _t67; bool __and_tmp_0; _t68 = (d >= 0); - if (!_t68) goto else8; + if (!_t68) goto else7; _t69 = (int64_t)argCount; _t70 = (d < _t69); *(bool*)&__and_tmp_0 = _t70; - goto endif9; - else8:; + goto endif8; + else7:; *(bool*)&__and_tmp_0 = 0; - endif9:; + endif8:; bool _t71; _t71 = *(bool*)&__and_tmp_0; - if (!_t71) goto endif11; + if (!_t71) goto endif10; { _t72 = i + 2; i = _t72; _t73 = (i < tmplLen); - if (!_t73) goto endif13; + if (!_t73) goto endif12; { const char* closeCh; const char* _t74; @@ -916,7 +915,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { closeCh = _t74; bool _t75; _t75 = String_Eq(closeCh, "}"); - if (!_t75) goto endif15; + if (!_t75) goto endif14; { _t76 = i + 1; i = _t76; @@ -929,22 +928,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { StringBuilder_Append(_t79, argStr); goto while1; } - endif15:; + endif14:; } - endif13:; + endif12:; } - endif11:; + endif10:; } - endif7:; + endif6:; } - endif5:; + endif4:; _t80 = &sb; StringBuilder_Append(_t80, ch); _t81 = i + 1; i = _t81; } goto while1; - wend3:; + wend2:; _t82 = &sb; const char* _t83; _t83 = StringBuilder_Build(_t82); @@ -952,276 +951,276 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { } const char* Fmt_Fmt1(const char* tmpl, const char* a1) { - const char** _t86; + const char** _t85; const char** args; /* sizeof(const char*) */ - void* _t85; - _t85 = bux_alloc(sizeof(const char*)); - _t86 = (const char**)_t85; - args = _t86; + void* _t84; + _t84 = bux_alloc(sizeof(const char*)); + _t85 = (const char**)_t84; + args = _t85; args[0] = a1; - const char* _t87; - _t87 = Fmt_Format(tmpl, args, 1); - return _t87; + const char* _t86; + _t86 = Fmt_Format(tmpl, args, 1); + return _t86; } const char* Fmt_FmtInt(const char* tmpl, int64_t val) { const char* s; + const char* _t87; + _t87 = String_FromInt(val); + s = _t87; const char* _t88; - _t88 = String_FromInt(val); - s = _t88; - const char* _t89; - _t89 = Fmt_Fmt1(tmpl, s); - return _t89; + _t88 = Fmt_Fmt1(tmpl, s); + return _t88; } const char* Fmt_FmtBool(const char* tmpl, bool val) { const char* s; + const char* _t89; + _t89 = String_FromBool(val); + s = _t89; const char* _t90; - _t90 = String_FromBool(val); - s = _t90; - const char* _t91; - _t91 = Fmt_Fmt1(tmpl, s); - return _t91; + _t90 = Fmt_Fmt1(tmpl, s); + return _t90; } const char* Fmt_FmtFloat(const char* tmpl, double val) { const char* s; + const char* _t91; + _t91 = String_FromFloat(val); + s = _t91; const char* _t92; - _t92 = String_FromFloat(val); - s = _t92; - const char* _t93; - _t93 = Fmt_Fmt1(tmpl, s); - return _t93; + _t92 = Fmt_Fmt1(tmpl, s); + return _t92; } const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2) { - int _t95; - const char** _t97; + int _t93; + const char** _t95; const char** args; /* sizeof(const char*) */ - _t95 = 2 * sizeof(const char*); - void* _t96; - _t96 = bux_alloc(_t95); - _t97 = (const char**)_t96; - args = _t97; + _t93 = 2 * sizeof(const char*); + void* _t94; + _t94 = bux_alloc(_t93); + _t95 = (const char**)_t94; + args = _t95; args[0] = a1; args[1] = a2; - const char* _t98; - _t98 = Fmt_Format(tmpl, args, 2); - return _t98; + const char* _t96; + _t96 = Fmt_Format(tmpl, args, 2); + return _t96; } const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3) { - int _t100; - const char** _t102; + int _t97; + const char** _t99; const char** args; /* sizeof(const char*) */ - _t100 = 3 * sizeof(const char*); - void* _t101; - _t101 = bux_alloc(_t100); - _t102 = (const char**)_t101; - args = _t102; + _t97 = 3 * sizeof(const char*); + void* _t98; + _t98 = bux_alloc(_t97); + _t99 = (const char**)_t98; + args = _t99; args[0] = a1; args[1] = a2; args[2] = a3; - const char* _t103; - _t103 = Fmt_Format(tmpl, args, 3); - return _t103; + const char* _t100; + _t100 = Fmt_Format(tmpl, args, 3); + return _t100; } const char* Crypto_Sha256(const char* data) { - int _t105; - void* _t107; + int _t102; + void* _t104; int len; - unsigned int _t104; - _t104 = String_Len(data); - _t105 = (int)_t104; - len = _t105; + unsigned int _t101; + _t101 = String_Len(data); + _t102 = (int)_t101; + len = _t102; void* hashBuf; - void* _t106; - _t106 = Alloc(32); - hashBuf = _t106; + void* _t103; + _t103 = Alloc(32); + hashBuf = _t103; bux_sha256(data, len, hashBuf); const char* result; - _t107 = (void*)hashBuf; - const char* _t108; - _t108 = bux_bytes_to_hex(_t107, 32); - result = _t108; + _t104 = (void*)hashBuf; + const char* _t105; + _t105 = bux_bytes_to_hex(_t104, 32); + result = _t105; Free(hashBuf); return result; } const char* Crypto_HmacSha256(const char* key, const char* message) { - int _t110; - int _t112; - void* _t114; + int _t107; + int _t109; + void* _t111; int keylen; - unsigned int _t109; - _t109 = String_Len(key); - _t110 = (int)_t109; - keylen = _t110; + unsigned int _t106; + _t106 = String_Len(key); + _t107 = (int)_t106; + keylen = _t107; int msglen; - unsigned int _t111; - _t111 = String_Len(message); - _t112 = (int)_t111; - msglen = _t112; + unsigned int _t108; + _t108 = String_Len(message); + _t109 = (int)_t108; + msglen = _t109; void* hmacBuf; - void* _t113; - _t113 = Alloc(32); - hmacBuf = _t113; + void* _t110; + _t110 = Alloc(32); + hmacBuf = _t110; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t114 = (void*)hmacBuf; - const char* _t115; - _t115 = bux_bytes_to_hex(_t114, 32); - result = _t115; + _t111 = (void*)hmacBuf; + const char* _t112; + _t112 = bux_bytes_to_hex(_t111, 32); + result = _t112; Free(hmacBuf); return result; } const char* Crypto_RandomBytes(int n) { - int _t116; - unsigned int _t117; - int _t120; - const char* _t121; - _t116 = (n <= 0); - if (!_t116) goto endif17; + int _t113; + unsigned int _t114; + int _t117; + const char* _t118; + _t113 = (n <= 0); + if (!_t113) goto endif16; { return ""; } - endif17:; + endif16:; void* buf; - _t117 = (unsigned int)n; - void* _t118; - _t118 = Alloc(_t117); - buf = _t118; - int _t119; - _t119 = bux_random_bytes(buf, n); - _t120 = (_t119 != 1); - if (!_t120) goto endif19; + _t114 = (unsigned int)n; + void* _t115; + _t115 = Alloc(_t114); + buf = _t115; + int _t116; + _t116 = bux_random_bytes(buf, n); + _t117 = (_t116 != 1); + if (!_t117) goto endif18; { Free(buf); return ""; } - endif19:; + endif18:; const char* result; - _t121 = (const char*)buf; - const char* _t122; - _t122 = bux_base64_encode(_t121, n); - result = _t122; + _t118 = (const char*)buf; + const char* _t119; + _t119 = bux_base64_encode(_t118, n); + result = _t119; Free(buf); return result; } const char* Crypto_Base64Encode(const char* s) { - int _t124; - unsigned int _t123; - _t123 = String_Len(s); - _t124 = (int)_t123; - const char* _t125; - _t125 = bux_base64_encode(s, _t124); - return _t125; + int _t121; + unsigned int _t120; + _t120 = String_Len(s); + _t121 = (int)_t120; + const char* _t122; + _t122 = bux_base64_encode(s, _t121); + return _t122; } const char* Crypto_HmacSha256Raw(const char* key, const char* message) { - int _t127; - int _t129; - const char* _t131; + int _t124; + int _t126; + const char* _t128; int keylen; - unsigned int _t126; - _t126 = String_Len(key); - _t127 = (int)_t126; - keylen = _t127; + unsigned int _t123; + _t123 = String_Len(key); + _t124 = (int)_t123; + keylen = _t124; int msglen; - unsigned int _t128; - _t128 = String_Len(message); - _t129 = (int)_t128; - msglen = _t129; + unsigned int _t125; + _t125 = String_Len(message); + _t126 = (int)_t125; + msglen = _t126; void* hmacBuf; - void* _t130; - _t130 = Alloc(32); - hmacBuf = _t130; + void* _t127; + _t127 = Alloc(32); + hmacBuf = _t127; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t131 = (const char*)hmacBuf; - const char* _t132; - _t132 = bux_base64_encode(_t131, 32); - result = _t132; + _t128 = (const char*)hmacBuf; + const char* _t129; + _t129 = bux_base64_encode(_t128, 32); + result = _t129; Free(hmacBuf); return result; } const char* Crypto_Base64Decode(const char* s) { - int _t134; - void* _t135; + int _t131; + void* _t132; int outlen; outlen = 0; - unsigned int _t133; - _t133 = String_Len(s); - _t134 = (int)_t133; - _t135 = &outlen; - const char* _t136; - _t136 = bux_base64_decode(s, _t134, _t135); - return _t136; + unsigned int _t130; + _t130 = String_Len(s); + _t131 = (int)_t130; + _t132 = &outlen; + const char* _t133; + _t133 = bux_base64_decode(s, _t131, _t132); + return _t133; } Mutex Mutex_New(void) { - Mutex _t138; - void* _t137; - _t137 = bux_mutex_new(); - _t138 = (Mutex){.handle = _t137}; - return _t138; + Mutex _t135; + void* _t134; + _t134 = bux_mutex_new(); + _t135 = (Mutex){.handle = _t134}; + return _t135; } void Mutex_Lock(Mutex* m) { - void* _t139; - _t139 = m->handle; - bux_mutex_lock(_t139); + void* _t136; + _t136 = m->handle; + bux_mutex_lock(_t136); } void Mutex_Unlock(Mutex* m) { - void* _t140; - _t140 = m->handle; - bux_mutex_unlock(_t140); + void* _t137; + _t137 = m->handle; + bux_mutex_unlock(_t137); } void Mutex_Free(Mutex* m) { - void* _t141; - _t141 = m->handle; - bux_mutex_free(_t141); + void* _t138; + _t138 = m->handle; + bux_mutex_free(_t138); } RwLock RwLock_New(void) { - RwLock _t143; - void* _t142; - _t142 = bux_rwlock_new(); - _t143 = (RwLock){.handle = _t142}; - return _t143; + RwLock _t140; + void* _t139; + _t139 = bux_rwlock_new(); + _t140 = (RwLock){.handle = _t139}; + return _t140; } void RwLock_ReadLock(RwLock* rw) { - void* _t144; - _t144 = rw->handle; - bux_rwlock_rdlock(_t144); + void* _t141; + _t141 = rw->handle; + bux_rwlock_rdlock(_t141); } void RwLock_WriteLock(RwLock* rw) { - void* _t145; - _t145 = rw->handle; - bux_rwlock_wrlock(_t145); + void* _t142; + _t142 = rw->handle; + bux_rwlock_wrlock(_t142); } void RwLock_Unlock(RwLock* rw) { - void* _t146; - _t146 = rw->handle; - bux_rwlock_unlock(_t146); + void* _t143; + _t143 = rw->handle; + bux_rwlock_unlock(_t143); } void RwLock_Free(RwLock* rw) { - void* _t147; - _t147 = rw->handle; - bux_rwlock_free(_t147); + void* _t144; + _t144 = rw->handle; + bux_rwlock_free(_t144); } void Test_Exit(int code) { @@ -1229,15 +1228,15 @@ void Test_Exit(int code) { } void Test_Assert(bool cond) { - int _t148; - _t148 = (int)cond; - bux_assert(_t148, "", 0, ""); + int _t145; + _t145 = (int)cond; + bux_assert(_t145, "", 0, ""); } void Test_AssertEqInt(int a, int b) { - int _t149; - _t149 = (a != b); - if (!_t149) goto endif21; + int _t146; + _t146 = (a != b); + if (!_t146) goto endif20; { PrintLine("ASSERT_EQ FAILED:"); PrintInt(a); @@ -1245,27 +1244,27 @@ void Test_AssertEqInt(int a, int b) { PrintInt(b); bux_exit(1); } - endif21:; + endif20:; } void Test_AssertTrue(bool cond) { - int _t150; - _t150 = !cond; - if (!_t150) goto endif23; + int _t147; + _t147 = !cond; + if (!_t147) goto endif22; { PrintLine("ASSERT_TRUE FAILED"); bux_exit(1); } - endif23:; + endif22:; } void Test_AssertFalse(bool cond) { - if (!cond) goto endif25; + if (!cond) goto endif24; { PrintLine("ASSERT_FALSE FAILED"); bux_exit(1); } - endif25:; + endif24:; } void Test_Fail(const char* msg) { @@ -1275,735 +1274,744 @@ void Test_Fail(const char* msg) { } Result Result_NewOk(int value) { - Result _t151; + Result _t148; Result r; - _t151 = (Result){.tag = Result_Ok}; - r = _t151; + _t148 = (Result){.tag = Result_Ok}; + r = _t148; r.data.Ok_0 = value; return r; } Result Result_NewErr(const char* msg) { - Result _t152; + Result _t149; Result r; - _t152 = (Result){.tag = Result_Err}; - r = _t152; + _t149 = (Result){.tag = Result_Err}; + r = _t149; r.data.Err_0 = msg; return r; } bool Result_IsOk(Result r) { - int _t154; - Result_Tag _t153; - _t153 = r.tag; - _t154 = (_t153 == Result_Ok); - return _t154; + int _t151; + Result_Tag _t150; + _t150 = r.tag; + _t151 = (_t150 == Result_Ok); + return _t151; } bool Result_IsErr(Result r) { - int _t156; - Result_Tag _t155; - _t155 = r.tag; - _t156 = (_t155 == Result_Err); - return _t156; + int _t153; + Result_Tag _t152; + _t152 = r.tag; + _t153 = (_t152 == Result_Err); + return _t153; } int Result_Unwrap(Result r) { - int _t158; - Result_Tag _t157; - _t157 = r.tag; - _t158 = (_t157 != Result_Ok); - if (!_t158) goto endif27; + int _t155; + Result_Tag _t154; + _t154 = r.tag; + _t155 = (_t154 != Result_Ok); + if (!_t155) goto endif26; { PrintLine("panic: unwrap on Err"); return 0; } - endif27:; - Result_Data _t159; - _t159 = r.data; - int _t160; - _t160 = _t159.Ok_0; - return _t160; + endif26:; + Result_Data _t156; + _t156 = r.data; + int _t157; + _t157 = _t156.Ok_0; + return _t157; } int Result_UnwrapOr(Result r, int fallback) { - int _t162; - Result_Tag _t161; - _t161 = r.tag; - _t162 = (_t161 == Result_Ok); - if (!_t162) goto endif29; + int _t159; + Result_Tag _t158; + _t158 = r.tag; + _t159 = (_t158 == Result_Ok); + if (!_t159) goto endif28; { - Result_Data _t163; - _t163 = r.data; - int _t164; - _t164 = _t163.Ok_0; - return _t164; + Result_Data _t160; + _t160 = r.data; + int _t161; + _t161 = _t160.Ok_0; + return _t161; } - endif29:; + endif28:; return fallback; } Option Option_NewSome(int value) { - Option _t165; + Option _t162; Option o; - _t165 = (Option){.tag = Option_Some}; - o = _t165; + _t162 = (Option){.tag = Option_Some}; + o = _t162; o.data.Some_0 = value; return o; } Option Option_NewNone(void) { - Option _t166; - _t166 = (Option){.tag = Option_None}; - return _t166; + Option _t163; + _t163 = (Option){.tag = Option_None}; + return _t163; } bool Option_IsSome(Option o) { - int _t168; - Option_Tag _t167; - _t167 = o.tag; - _t168 = (_t167 == Option_Some); - return _t168; + int _t165; + Option_Tag _t164; + _t164 = o.tag; + _t165 = (_t164 == Option_Some); + return _t165; } bool Option_IsNone(Option o) { - int _t170; - Option_Tag _t169; - _t169 = o.tag; - _t170 = (_t169 == Option_None); - return _t170; + int _t167; + Option_Tag _t166; + _t166 = o.tag; + _t167 = (_t166 == Option_None); + return _t167; } int Option_Unwrap(Option o) { - int _t172; - Option_Tag _t171; - _t171 = o.tag; - _t172 = (_t171 != Option_Some); - if (!_t172) goto endif31; + int _t169; + Option_Tag _t168; + _t168 = o.tag; + _t169 = (_t168 != Option_Some); + if (!_t169) goto endif30; { PrintLine("panic: unwrap on None"); return 0; } - endif31:; - Option_Data _t173; - _t173 = o.data; - int _t174; - _t174 = _t173.Some_0; - return _t174; + endif30:; + Option_Data _t170; + _t170 = o.data; + int _t171; + _t171 = _t170.Some_0; + return _t171; } int Option_UnwrapOr(Option o, int fallback) { - int _t176; - Option_Tag _t175; - _t175 = o.tag; - _t176 = (_t175 == Option_Some); - if (!_t176) goto endif33; + int _t173; + Option_Tag _t172; + _t172 = o.tag; + _t173 = (_t172 == Option_Some); + if (!_t173) goto endif32; { - Option_Data _t177; - _t177 = o.data; - int _t178; - _t178 = _t177.Some_0; - return _t178; + Option_Data _t174; + _t174 = o.data; + int _t175; + _t175 = _t174.Some_0; + return _t175; } - endif33:; + endif32:; return fallback; } JsonValue Json_Null(void) { - JsonValue _t179; - _t179 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t179; + JsonValue _t176; + _t176 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t176; } JsonValue Json_Bool(bool b) { - JsonValue _t180; - _t180 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t180; + JsonValue _t177; + _t177 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t177; } JsonValue Json_Number(double n) { - JsonValue _t181; - _t181 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t181; + JsonValue _t178; + _t178 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t178; } JsonValue Json_String(const char* s) { - JsonValue _t182; - _t182 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t182; + JsonValue _t179; + _t179 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t179; } JsonValue Json_Array(void) { - JsonValue _t183; - _t183 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t183; + JsonValue _t180; + _t180 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t180; } JsonValue Json_Object(void) { - JsonValue _t184; - _t184 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t184; + JsonValue _t181; + _t181 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t181; } unsigned int Json_ArrayLen(JsonValue v) { - int _t186; - int _t185; - _t185 = v.tag; - _t186 = (_t185 != JsonTagArray); - if (!_t186) goto endif35; + int _t183; + int _t182; + _t182 = v.tag; + _t183 = (_t182 != JsonTagArray); + if (!_t183) goto endif34; { return 0; } - endif35:; - unsigned int _t187; - _t187 = v.arrLen; - return _t187; + endif34:; + unsigned int _t184; + _t184 = v.arrLen; + return _t184; } JsonValue Json_ArrayGet(JsonValue v, unsigned int index) { + int _t186; int _t189; - int _t192; - int _t188; - _t188 = v.tag; - _t189 = (_t188 != JsonTagArray); - if (!_t189) goto endif37; + int _t185; + _t185 = v.tag; + _t186 = (_t185 != JsonTagArray); + if (!_t186) goto endif36; + { + JsonValue _t187; + _t187 = Json_Null(); + return _t187; + } + endif36:; + unsigned int _t188; + _t188 = v.arrLen; + _t189 = (index >= _t188); + if (!_t189) goto endif38; { JsonValue _t190; _t190 = Json_Null(); return _t190; } - endif37:; - unsigned int _t191; - _t191 = v.arrLen; - _t192 = (index >= _t191); - if (!_t192) goto endif39; - { - JsonValue _t193; - _t193 = Json_Null(); - return _t193; - } - endif39:; - JsonValue* _t194; - _t194 = v.arrData; - JsonValue _t195; - _t195 = _t194[index]; - return _t195; + endif38:; + JsonValue* _t191; + _t191 = v.arrData; + JsonValue _t192; + _t192 = _t191[index]; + return _t192; } void Json_ArrayPush(JsonValue* self, JsonValue val) { + int _t194; int _t197; + int _t199; int _t200; - int _t202; - int _t204; - JsonValue* _t206; - int _t207; - void* _t209; - int _t211; - JsonValue* _t213; - int _t217; - int _t196; - _t196 = self->tag; - _t197 = (_t196 != JsonTagArray); - if (!_t197) goto endif41; + JsonValue* _t202; + int _t203; + void* _t205; + int _t206; + JsonValue* _t208; + int _t212; + int _t193; + _t193 = self->tag; + _t194 = (_t193 != JsonTagArray); + if (!_t194) goto endif40; { return; } - endif41:; - unsigned int _t198; - _t198 = self->arrLen; - unsigned int _t199; - _t199 = self->arrCap; - _t200 = (_t198 >= _t199); - if (!_t200) goto endif43; + endif40:; + unsigned int _t195; + _t195 = self->arrLen; + unsigned int _t196; + _t196 = self->arrCap; + _t197 = (_t195 >= _t196); + if (!_t197) goto endif42; { unsigned int arrNewCap; - unsigned int _t201; - _t201 = self->arrCap; - arrNewCap = _t201; - _t202 = (arrNewCap == 0); - if (!_t202) goto else44; + unsigned int _t198; + _t198 = self->arrCap; + arrNewCap = _t198; + _t199 = (arrNewCap == 0); + if (!_t199) goto else43; { self->arrCap = 4; /* sizeof(JsonValue) */ - _t204 = 4 * sizeof(JsonValue); - void* _t205; - _t205 = Alloc(_t204); - _t206 = (JsonValue*)_t205; - self->arrData = _t206; + _t200 = 4 * sizeof(JsonValue); + void* _t201; + _t201 = Alloc(_t200); + _t202 = (JsonValue*)_t201; + self->arrData = _t202; } - goto endif45; - else44:; + goto endif44; + else43:; { unsigned int doubleCap; - _t207 = arrNewCap * 2; - doubleCap = _t207; + _t203 = arrNewCap * 2; + doubleCap = _t203; self->arrCap = doubleCap; - JsonValue* _t208; - _t208 = self->arrData; - _t209 = (void*)_t208; + JsonValue* _t204; + _t204 = self->arrData; + _t205 = (void*)_t204; /* sizeof(JsonValue) */ - _t211 = doubleCap * sizeof(JsonValue); - void* _t212; - _t212 = Realloc(_t209, _t211); - _t213 = (JsonValue*)_t212; - self->arrData = _t213; + _t206 = doubleCap * sizeof(JsonValue); + void* _t207; + _t207 = Realloc(_t205, _t206); + _t208 = (JsonValue*)_t207; + self->arrData = _t208; } - endif45:; + endif44:; } - endif43:; - JsonValue* _t214; - _t214 = self->arrData; - unsigned int _t215; - _t215 = self->arrLen; - _t214[_t215] = val; - unsigned int _t216; - _t216 = self->arrLen; - _t217 = _t216 + 1; - self->arrLen = _t217; + endif42:; + JsonValue* _t209; + _t209 = self->arrData; + unsigned int _t210; + _t210 = self->arrLen; + _t209[_t210] = val; + unsigned int _t211; + _t211 = self->arrLen; + _t212 = _t211 + 1; + self->arrLen = _t212; } unsigned int Json_ObjectLen(JsonValue v) { - int _t219; - int _t218; - _t218 = v.tag; - _t219 = (_t218 != JsonTagObject); - if (!_t219) goto endif47; + int _t214; + int _t213; + _t213 = v.tag; + _t214 = (_t213 != JsonTagObject); + if (!_t214) goto endif46; { return 0; } - endif47:; - unsigned int _t220; - _t220 = v.objLen; - return _t220; + endif46:; + unsigned int _t215; + _t215 = v.objLen; + return _t215; } JsonValue Json_ObjectGet(JsonValue v, const char* key) { - int _t222; - int _t225; - int _t231; - int _t221; - _t221 = v.tag; - _t222 = (_t221 != JsonTagObject); - if (!_t222) goto endif49; + int _t217; + int _t220; + int _t226; + int _t216; + _t216 = v.tag; + _t217 = (_t216 != JsonTagObject); + if (!_t217) goto endif48; { - JsonValue _t223; - _t223 = Json_Null(); - return _t223; + JsonValue _t218; + _t218 = Json_Null(); + return _t218; } - endif49:; + endif48:; unsigned int i; i = 0; - while50:; - unsigned int _t224; - _t224 = v.objLen; - _t225 = (i < _t224); - if (!_t225) goto wend52; + while49:; + unsigned int _t219; + _t219 = v.objLen; + _t220 = (i < _t219); + if (!_t220) goto wend50; { - const char** _t226; - _t226 = v.objKeys; - const char* _t227; - _t227 = _t226[i]; - bool _t228; - _t228 = String_Eq(_t227, key); - if (!_t228) goto endif54; + const char** _t221; + _t221 = v.objKeys; + const char* _t222; + _t222 = _t221[i]; + bool _t223; + _t223 = String_Eq(_t222, key); + if (!_t223) goto endif52; { - JsonValue* _t229; - _t229 = v.objValues; - JsonValue _t230; - _t230 = _t229[i]; - return _t230; + JsonValue* _t224; + _t224 = v.objValues; + JsonValue _t225; + _t225 = _t224[i]; + return _t225; } - endif54:; - _t231 = i + 1; - i = _t231; + endif52:; + _t226 = i + 1; + i = _t226; } - goto while50; - wend52:; - JsonValue _t232; - _t232 = Json_Null(); - return _t232; + goto while49; + wend50:; + JsonValue _t227; + _t227 = Json_Null(); + return _t227; } bool Json_ObjectHas(JsonValue v, const char* key) { - int _t234; - int _t236; - int _t240; - int _t233; - _t233 = v.tag; - _t234 = (_t233 != JsonTagObject); - if (!_t234) goto endif56; + int _t229; + int _t231; + int _t235; + int _t228; + _t228 = v.tag; + _t229 = (_t228 != JsonTagObject); + if (!_t229) goto endif54; { return 0; } - endif56:; + endif54:; unsigned int i; i = 0; - while57:; - unsigned int _t235; - _t235 = v.objLen; - _t236 = (i < _t235); - if (!_t236) goto wend59; + while55:; + unsigned int _t230; + _t230 = v.objLen; + _t231 = (i < _t230); + if (!_t231) goto wend56; { - const char** _t237; - _t237 = v.objKeys; - const char* _t238; - _t238 = _t237[i]; - bool _t239; - _t239 = String_Eq(_t238, key); - if (!_t239) goto endif61; + const char** _t232; + _t232 = v.objKeys; + const char* _t233; + _t233 = _t232[i]; + bool _t234; + _t234 = String_Eq(_t233, key); + if (!_t234) goto endif58; { return 1; } - endif61:; - _t240 = i + 1; - i = _t240; + endif58:; + _t235 = i + 1; + i = _t235; } - goto while57; - wend59:; + goto while55; + wend56:; return 0; } void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) { - int _t242; + int _t237; + int _t239; int _t244; + int _t247; int _t249; - int _t252; - int _t254; + int _t250; + const char** _t252; + int _t253; + JsonValue* _t255; int _t256; - const char** _t258; - int _t260; - JsonValue* _t262; - int _t263; - void* _t265; - int _t267; - const char** _t269; - void* _t271; - int _t273; - JsonValue* _t275; - int _t281; - int _t241; - _t241 = self->tag; - _t242 = (_t241 != JsonTagObject); - if (!_t242) goto endif63; + void* _t258; + int _t259; + const char** _t261; + void* _t263; + int _t264; + JsonValue* _t266; + int _t272; + int _t236; + _t236 = self->tag; + _t237 = (_t236 != JsonTagObject); + if (!_t237) goto endif60; { return; } - endif63:; + endif60:; unsigned int i; i = 0; - while64:; - unsigned int _t243; - _t243 = self->objLen; - _t244 = (i < _t243); - if (!_t244) goto wend66; + while61:; + unsigned int _t238; + _t238 = self->objLen; + _t239 = (i < _t238); + if (!_t239) goto wend62; { - const char** _t245; - _t245 = self->objKeys; - const char* _t246; - _t246 = _t245[i]; - bool _t247; - _t247 = String_Eq(_t246, key); - if (!_t247) goto endif68; + const char** _t240; + _t240 = self->objKeys; + const char* _t241; + _t241 = _t240[i]; + bool _t242; + _t242 = String_Eq(_t241, key); + if (!_t242) goto endif64; { - JsonValue* _t248; - _t248 = self->objValues; - _t248[i] = val; + JsonValue* _t243; + _t243 = self->objValues; + _t243[i] = val; return; } - endif68:; - _t249 = i + 1; - i = _t249; + endif64:; + _t244 = i + 1; + i = _t244; } - goto while64; - wend66:; - unsigned int _t250; - _t250 = self->objLen; - unsigned int _t251; - _t251 = self->objCap; - _t252 = (_t250 >= _t251); - if (!_t252) goto endif70; + goto while61; + wend62:; + unsigned int _t245; + _t245 = self->objLen; + unsigned int _t246; + _t246 = self->objCap; + _t247 = (_t245 >= _t246); + if (!_t247) goto endif66; { unsigned int objNewCap; - unsigned int _t253; - _t253 = self->objCap; - objNewCap = _t253; - _t254 = (objNewCap == 0); - if (!_t254) goto else71; + unsigned int _t248; + _t248 = self->objCap; + objNewCap = _t248; + _t249 = (objNewCap == 0); + if (!_t249) goto else67; { self->objCap = 4; /* sizeof(const char*) */ - _t256 = 4 * sizeof(const char*); - void* _t257; - _t257 = Alloc(_t256); - _t258 = (const char**)_t257; - self->objKeys = _t258; + _t250 = 4 * sizeof(const char*); + void* _t251; + _t251 = Alloc(_t250); + _t252 = (const char**)_t251; + self->objKeys = _t252; /* sizeof(JsonValue) */ - _t260 = 4 * sizeof(JsonValue); - void* _t261; - _t261 = Alloc(_t260); - _t262 = (JsonValue*)_t261; - self->objValues = _t262; + _t253 = 4 * sizeof(JsonValue); + void* _t254; + _t254 = Alloc(_t253); + _t255 = (JsonValue*)_t254; + self->objValues = _t255; } - goto endif72; - else71:; + goto endif68; + else67:; { unsigned int doubleCap; - _t263 = objNewCap * 2; - doubleCap = _t263; + _t256 = objNewCap * 2; + doubleCap = _t256; self->objCap = doubleCap; - const char** _t264; - _t264 = self->objKeys; - _t265 = (void*)_t264; + const char** _t257; + _t257 = self->objKeys; + _t258 = (void*)_t257; /* sizeof(const char*) */ - _t267 = doubleCap * sizeof(const char*); - void* _t268; - _t268 = Realloc(_t265, _t267); - _t269 = (const char**)_t268; - self->objKeys = _t269; - JsonValue* _t270; - _t270 = self->objValues; - _t271 = (void*)_t270; + _t259 = doubleCap * sizeof(const char*); + void* _t260; + _t260 = Realloc(_t258, _t259); + _t261 = (const char**)_t260; + self->objKeys = _t261; + JsonValue* _t262; + _t262 = self->objValues; + _t263 = (void*)_t262; /* sizeof(JsonValue) */ - _t273 = doubleCap * sizeof(JsonValue); - void* _t274; - _t274 = Realloc(_t271, _t273); - _t275 = (JsonValue*)_t274; - self->objValues = _t275; + _t264 = doubleCap * sizeof(JsonValue); + void* _t265; + _t265 = Realloc(_t263, _t264); + _t266 = (JsonValue*)_t265; + self->objValues = _t266; } - endif72:; + endif68:; } - endif70:; - const char** _t276; - _t276 = self->objKeys; - unsigned int _t277; - _t277 = self->objLen; - _t276[_t277] = key; - JsonValue* _t278; - _t278 = self->objValues; - unsigned int _t279; - _t279 = self->objLen; - _t278[_t279] = val; - unsigned int _t280; - _t280 = self->objLen; - _t281 = _t280 + 1; - self->objLen = _t281; + endif66:; + const char** _t267; + _t267 = self->objKeys; + unsigned int _t268; + _t268 = self->objLen; + _t267[_t268] = key; + JsonValue* _t269; + _t269 = self->objValues; + unsigned int _t270; + _t270 = self->objLen; + _t269[_t270] = val; + unsigned int _t271; + _t271 = self->objLen; + _t272 = _t271 + 1; + self->objLen = _t272; } bool Json_IsNull(JsonValue v) { - int _t283; - int _t282; - _t282 = v.tag; - _t283 = (_t282 == JsonTagNull); - return _t283; + int _t274; + int _t273; + _t273 = v.tag; + _t274 = (_t273 == JsonTagNull); + return _t274; } bool Json_AsBool(JsonValue v) { - int _t285; - int _t284; - _t284 = v.tag; - _t285 = (_t284 == JsonTagBool); - if (!_t285) goto endif74; + int _t276; + int _t275; + _t275 = v.tag; + _t276 = (_t275 == JsonTagBool); + if (!_t276) goto endif70; { - bool _t286; - _t286 = v.boolVal; - return _t286; + bool _t277; + _t277 = v.boolVal; + return _t277; } - endif74:; + endif70:; return 0; } double Json_AsNumber(JsonValue v) { - int _t288; - int _t287; - _t287 = v.tag; - _t288 = (_t287 == JsonTagNumber); - if (!_t288) goto endif76; + int _t279; + int _t278; + _t278 = v.tag; + _t279 = (_t278 == JsonTagNumber); + if (!_t279) goto endif72; { - double _t289; - _t289 = v.numVal; - return _t289; + double _t280; + _t280 = v.numVal; + return _t280; } - endif76:; + endif72:; return 0.0; } const char* Json_AsString(JsonValue v) { - int _t291; - int _t290; - _t290 = v.tag; - _t291 = (_t290 == JsonTagString); - if (!_t291) goto endif78; + int _t282; + int _t281; + _t281 = v.tag; + _t282 = (_t281 == JsonTagString); + if (!_t282) goto endif74; { - const char* _t292; - _t292 = v.strVal; - return _t292; + const char* _t283; + _t283 = v.strVal; + return _t283; } - endif78:; + endif74:; return ""; } int JsonParser_Peek(JsonParser* p) { - int _t295; - int _t299; - unsigned int _t293; - _t293 = p->pos; - unsigned int _t294; - _t294 = p->len; - _t295 = (_t293 >= _t294); - if (!_t295) goto endif80; + int _t286; + int _t290; + unsigned int _t284; + _t284 = p->pos; + unsigned int _t285; + _t285 = p->len; + _t286 = (_t284 >= _t285); + if (!_t286) goto endif76; { return 0; } - endif80:; - const char* _t296; - _t296 = p->src; - unsigned int _t297; - _t297 = p->pos; - int _t298; - _t298 = _t296[_t297]; - _t299 = (int)_t298; - return _t299; + endif76:; + const char* _t287; + _t287 = p->src; + unsigned int _t288; + _t288 = p->pos; + int _t289; + _t289 = _t287[_t288]; + _t290 = (int)_t289; + return _t290; } void JsonParser_Advance(JsonParser* p) { - int _t302; - int _t304; - unsigned int _t300; - _t300 = p->pos; - unsigned int _t301; - _t301 = p->len; - _t302 = (_t300 < _t301); - if (!_t302) goto endif82; + int _t293; + int _t295; + unsigned int _t291; + _t291 = p->pos; + unsigned int _t292; + _t292 = p->len; + _t293 = (_t291 < _t292); + if (!_t293) goto endif78; { - unsigned int _t303; - _t303 = p->pos; - _t304 = _t303 + 1; - p->pos = _t304; + unsigned int _t294; + _t294 = p->pos; + _t295 = _t294 + 1; + p->pos = _t295; } - endif82:; + endif78:; } void JsonParser_SkipWhitespace(JsonParser* p) { - int _t306; - int _t307; - int _t309; - int _t311; - while83:; - if (!1) goto wend85; + int _t297; + int _t298; + int _t300; + int _t302; + while79:; + if (!1) goto wend80; { int c; - int _t305; - _t305 = JsonParser_Peek(p); - c = _t305; + int _t296; + _t296 = JsonParser_Peek(p); + c = _t296; bool __or_tmp_1; bool __or_tmp_2; bool __or_tmp_3; - _t306 = (c == 32); - if (!_t306) goto else86; + _t297 = (c == 32); + if (!_t297) goto else81; *(bool*)&__or_tmp_3 = 1; - goto endif87; - else86:; - _t307 = (c == 9); - *(bool*)&__or_tmp_3 = _t307; - endif87:; - bool _t308; - _t308 = *(bool*)&__or_tmp_3; - if (!_t308) goto else88; + goto endif82; + else81:; + _t298 = (c == 9); + *(bool*)&__or_tmp_3 = _t298; + endif82:; + bool _t299; + _t299 = *(bool*)&__or_tmp_3; + if (!_t299) goto else83; *(bool*)&__or_tmp_2 = 1; - goto endif89; - else88:; - _t309 = (c == 10); - *(bool*)&__or_tmp_2 = _t309; - endif89:; - bool _t310; - _t310 = *(bool*)&__or_tmp_2; - if (!_t310) goto else90; + goto endif84; + else83:; + _t300 = (c == 10); + *(bool*)&__or_tmp_2 = _t300; + endif84:; + bool _t301; + _t301 = *(bool*)&__or_tmp_2; + if (!_t301) goto else85; *(bool*)&__or_tmp_1 = 1; - goto endif91; - else90:; - _t311 = (c == 13); - *(bool*)&__or_tmp_1 = _t311; - endif91:; - bool _t312; - _t312 = *(bool*)&__or_tmp_1; - if (!_t312) goto else92; + goto endif86; + else85:; + _t302 = (c == 13); + *(bool*)&__or_tmp_1 = _t302; + endif86:; + bool _t303; + _t303 = *(bool*)&__or_tmp_1; + if (!_t303) goto else87; { JsonParser_Advance(p); } - goto endif93; - else92:; + goto endif88; + else87:; { return; } - endif93:; + endif88:; } - goto while83; - wend85:; + goto while79; + wend80:; } bool JsonParser_Match(JsonParser* p, const char* expected) { + int _t306; + int _t308; + int _t309; + int _t312; int _t315; - int _t317; + int _t316; int _t318; - int _t321; - int _t324; - int _t325; - int _t327; unsigned int elen; - unsigned int _t313; - _t313 = String_Len(expected); - elen = _t313; - unsigned int _t314; - _t314 = p->pos; - _t315 = _t314 + elen; - unsigned int _t316; - _t316 = p->len; - _t317 = (_t315 > _t316); - if (!_t317) goto endif95; + unsigned int _t304; + _t304 = String_Len(expected); + elen = _t304; + unsigned int _t305; + _t305 = p->pos; + _t306 = _t305 + elen; + unsigned int _t307; + _t307 = p->len; + _t308 = (_t306 > _t307); + if (!_t308) goto endif90; { return 0; } - endif95:; + endif90:; unsigned int i; i = 0; - while96:; - _t318 = (i < elen); - if (!_t318) goto wend98; + while91:; + _t309 = (i < elen); + if (!_t309) goto wend92; { - const char* _t319; - _t319 = p->src; - unsigned int _t320; - _t320 = p->pos; - _t321 = _t320 + i; - int _t322; - _t322 = _t319[_t321]; - int _t323; - _t323 = expected[i]; - _t324 = (_t322 != _t323); - if (!_t324) goto endif100; + const char* _t310; + _t310 = p->src; + unsigned int _t311; + _t311 = p->pos; + _t312 = _t311 + i; + int _t313; + _t313 = _t310[_t312]; + int _t314; + _t314 = expected[i]; + _t315 = (_t313 != _t314); + if (!_t315) goto endif94; { return 0; } - endif100:; - _t325 = i + 1; - i = _t325; + endif94:; + _t316 = i + 1; + i = _t316; } - goto while96; - wend98:; - unsigned int _t326; - _t326 = p->pos; - _t327 = _t326 + elen; - p->pos = _t327; + goto while91; + wend92:; + unsigned int _t317; + _t317 = p->pos; + _t318 = _t317 + elen; + p->pos = _t318; return 1; } const char* JsonParser_ParseString(JsonParser* p) { - int _t329; - int _t332; + int _t320; + int _t323; + int _t324; + int _t326; + int _t328; + void* _t329; + int _t330; + void* _t331; + char _t332; int _t333; - int _t335; - int _t337; - void* _t338; + void* _t334; + char _t335; + int _t336; + void* _t337; + char _t338; int _t339; void* _t340; char _t341; @@ -2016,234 +2024,262 @@ const char* JsonParser_ParseString(JsonParser* p) { int _t348; void* _t349; char _t350; - int _t351; - void* _t352; - char _t353; - int _t354; + void* _t351; + char _t352; + void* _t353; + char _t354; void* _t355; char _t356; - int _t357; - void* _t358; - char _t359; + int _t358; + void* _t359; void* _t360; - char _t361; void* _t362; - char _t363; - void* _t364; - char _t365; - int _t367; - void* _t368; - void* _t369; - void* _t371; - int _t328; - _t328 = JsonParser_Peek(p); - _t329 = (_t328 != 34); - if (!_t329) goto endif102; + int _t319; + _t319 = JsonParser_Peek(p); + _t320 = (_t319 != 34); + if (!_t320) goto endif96; { p->error = "Expected string"; return ""; } - endif102:; + endif96:; JsonParser_Advance(p); StringBuilder sb; - StringBuilder _t330; - _t330 = StringBuilder_New(); - sb = _t330; - while103:; - if (!1) goto wend105; + StringBuilder _t321; + _t321 = StringBuilder_New(); + sb = _t321; + while97:; + if (!1) goto wend98; { int c; - int _t331; - _t331 = JsonParser_Peek(p); - c = _t331; + int _t322; + _t322 = JsonParser_Peek(p); + c = _t322; bool __or_tmp_4; - _t332 = (c == 0); - if (!_t332) goto else106; + _t323 = (c == 0); + if (!_t323) goto else99; *(bool*)&__or_tmp_4 = 1; - goto endif107; - else106:; - _t333 = (c == 34); - *(bool*)&__or_tmp_4 = _t333; - endif107:; - bool _t334; - _t334 = *(bool*)&__or_tmp_4; - if (!_t334) goto endif109; + goto endif100; + else99:; + _t324 = (c == 34); + *(bool*)&__or_tmp_4 = _t324; + endif100:; + bool _t325; + _t325 = *(bool*)&__or_tmp_4; + if (!_t325) goto endif102; { - goto wend105; + goto wend98; } - endif109:; - _t335 = (c == 92); - if (!_t335) goto else110; + endif102:; + _t326 = (c == 92); + if (!_t326) goto else103; { JsonParser_Advance(p); int esc; - int _t336; - _t336 = JsonParser_Peek(p); - esc = _t336; - _t337 = (esc == 0); - if (!_t337) goto endif113; + int _t327; + _t327 = JsonParser_Peek(p); + esc = _t327; + _t328 = (esc == 0); + if (!_t328) goto endif106; { p->error = "Unterminated string escape"; - _t338 = &sb; - StringBuilder_Free(_t338); + _t329 = &sb; + StringBuilder_Free(_t329); return ""; } - endif113:; - _t339 = (esc == 110); - if (!_t339) goto else114; + endif106:; + _t330 = (esc == 110); + if (!_t330) goto else107; + { + _t331 = &sb; + _t332 = (char)10; + StringBuilder_AppendChar(_t331, _t332); + } + goto endif108; + else107:; + _t333 = (esc == 116); + if (!_t333) goto else109; + { + _t334 = &sb; + _t335 = (char)9; + StringBuilder_AppendChar(_t334, _t335); + } + goto endif110; + else109:; + _t336 = (esc == 114); + if (!_t336) goto else111; + { + _t337 = &sb; + _t338 = (char)13; + StringBuilder_AppendChar(_t337, _t338); + } + goto endif112; + else111:; + _t339 = (esc == 98); + if (!_t339) goto else113; { _t340 = &sb; - _t341 = (char)10; + _t341 = (char)8; StringBuilder_AppendChar(_t340, _t341); } - goto endif115; - else114:; - _t342 = (esc == 116); - if (!_t342) goto else116; + goto endif114; + else113:; + _t342 = (esc == 102); + if (!_t342) goto else115; { _t343 = &sb; - _t344 = (char)9; + _t344 = (char)12; StringBuilder_AppendChar(_t343, _t344); } - goto endif117; - else116:; - _t345 = (esc == 114); - if (!_t345) goto else118; + goto endif116; + else115:; + _t345 = (esc == 34); + if (!_t345) goto else117; { _t346 = &sb; - _t347 = (char)13; + _t347 = (char)34; StringBuilder_AppendChar(_t346, _t347); } - goto endif119; - else118:; - _t348 = (esc == 98); - if (!_t348) goto else120; + goto endif118; + else117:; + _t348 = (esc == 92); + if (!_t348) goto else119; { _t349 = &sb; - _t350 = (char)8; + _t350 = (char)92; StringBuilder_AppendChar(_t349, _t350); } - goto endif121; - else120:; - _t351 = (esc == 102); - if (!_t351) goto else122; + goto endif120; + else119:; { - _t352 = &sb; - _t353 = (char)12; - StringBuilder_AppendChar(_t352, _t353); + _t351 = &sb; + _t352 = (char)92; + StringBuilder_AppendChar(_t351, _t352); + _t353 = &sb; + _t354 = (char)esc; + StringBuilder_AppendChar(_t353, _t354); } - goto endif123; - else122:; - _t354 = (esc == 34); - if (!_t354) goto else124; + endif120:; + endif118:; + endif116:; + endif114:; + endif112:; + endif110:; + endif108:; + JsonParser_Advance(p); + } + goto endif104; + else103:; { _t355 = &sb; - _t356 = (char)34; + _t356 = (char)c; StringBuilder_AppendChar(_t355, _t356); - } - goto endif125; - else124:; - _t357 = (esc == 92); - if (!_t357) goto else126; - { - _t358 = &sb; - _t359 = (char)92; - StringBuilder_AppendChar(_t358, _t359); - } - goto endif127; - else126:; - { - _t360 = &sb; - _t361 = (char)92; - StringBuilder_AppendChar(_t360, _t361); - _t362 = &sb; - _t363 = (char)esc; - StringBuilder_AppendChar(_t362, _t363); - } - endif127:; - endif125:; - endif123:; - endif121:; - endif119:; - endif117:; - endif115:; JsonParser_Advance(p); } - goto endif111; - else110:; - { - _t364 = &sb; - _t365 = (char)c; - StringBuilder_AppendChar(_t364, _t365); - JsonParser_Advance(p); + endif104:; } - endif111:; - } - goto while103; - wend105:; - int _t366; - _t366 = JsonParser_Peek(p); - _t367 = (_t366 != 34); - if (!_t367) goto endif129; + goto while97; + wend98:; + int _t357; + _t357 = JsonParser_Peek(p); + _t358 = (_t357 != 34); + if (!_t358) goto endif122; { p->error = "Unterminated string"; - _t368 = &sb; - StringBuilder_Free(_t368); + _t359 = &sb; + StringBuilder_Free(_t359); return ""; } - endif129:; + endif122:; JsonParser_Advance(p); const char* result; - _t369 = &sb; - const char* _t370; - _t370 = StringBuilder_Build(_t369); - result = _t370; - _t371 = &sb; - StringBuilder_Free(_t371); + _t360 = &sb; + const char* _t361; + _t361 = StringBuilder_Build(_t360); + result = _t361; + _t362 = &sb; + StringBuilder_Free(_t362); return result; } JsonValue JsonParser_ParseNumber(JsonParser* p) { - int _t374; - int _t376; - int _t377; - int _t380; - int _t382; - int _t383; - int _t387; - unsigned int start; - unsigned int _t372; - _t372 = p->pos; - start = _t372; - int c0; + int _t365; + int _t367; + int _t368; + int _t371; int _t373; - _t373 = JsonParser_Peek(p); - c0 = _t373; - _t374 = (c0 == 45); - if (!_t374) goto endif131; + int _t374; + int _t378; + unsigned int start; + unsigned int _t363; + _t363 = p->pos; + start = _t363; + int c0; + int _t364; + _t364 = JsonParser_Peek(p); + c0 = _t364; + _t365 = (c0 == 45); + if (!_t365) goto endif124; { JsonParser_Advance(p); } - endif131:; - while132:; + endif124:; + while125:; + if (!1) goto wend126; + { + int c; + int _t366; + _t366 = JsonParser_Peek(p); + c = _t366; + bool __and_tmp_5; + _t367 = (c >= 48); + if (!_t367) goto else127; + _t368 = (c <= 57); + *(bool*)&__and_tmp_5 = _t368; + goto endif128; + else127:; + *(bool*)&__and_tmp_5 = 0; + endif128:; + bool _t369; + _t369 = *(bool*)&__and_tmp_5; + if (!_t369) goto else129; + { + JsonParser_Advance(p); + } + goto endif130; + else129:; + { + goto wend126; + } + endif130:; + } + goto while125; + wend126:; + int _t370; + _t370 = JsonParser_Peek(p); + _t371 = (_t370 == 46); + if (!_t371) goto endif132; + { + JsonParser_Advance(p); + while133:; if (!1) goto wend134; { int c; - int _t375; - _t375 = JsonParser_Peek(p); - c = _t375; - bool __and_tmp_5; - _t376 = (c >= 48); - if (!_t376) goto else135; - _t377 = (c <= 57); - *(bool*)&__and_tmp_5 = _t377; + int _t372; + _t372 = JsonParser_Peek(p); + c = _t372; + bool __and_tmp_6; + _t373 = (c >= 48); + if (!_t373) goto else135; + _t374 = (c <= 57); + *(bool*)&__and_tmp_6 = _t374; goto endif136; else135:; - *(bool*)&__and_tmp_5 = 0; + *(bool*)&__and_tmp_6 = 0; endif136:; - bool _t378; - _t378 = *(bool*)&__and_tmp_5; - if (!_t378) goto else137; + bool _t375; + _t375 = *(bool*)&__and_tmp_6; + if (!_t375) goto else137; { JsonParser_Advance(p); } @@ -2254,1098 +2290,1061 @@ JsonValue JsonParser_ParseNumber(JsonParser* p) { } endif138:; } - goto while132; + goto while133; wend134:; - int _t379; - _t379 = JsonParser_Peek(p); - _t380 = (_t379 == 46); - if (!_t380) goto endif140; - { - JsonParser_Advance(p); - while141:; - if (!1) goto wend143; - { - int c; - int _t381; - _t381 = JsonParser_Peek(p); - c = _t381; - bool __and_tmp_6; - _t382 = (c >= 48); - if (!_t382) goto else144; - _t383 = (c <= 57); - *(bool*)&__and_tmp_6 = _t383; - goto endif145; - else144:; - *(bool*)&__and_tmp_6 = 0; - endif145:; - bool _t384; - _t384 = *(bool*)&__and_tmp_6; - if (!_t384) goto else146; - { - JsonParser_Advance(p); } - goto endif147; - else146:; - { - goto wend143; - } - endif147:; - } - goto while141; - wend143:; - } - endif140:; + endif132:; const char* numStr; - const char* _t385; - _t385 = p->src; - unsigned int _t386; - _t386 = p->pos; - _t387 = _t386 - start; - const char* _t388; - _t388 = String_Slice(_t385, start, _t387); - numStr = _t388; + const char* _t376; + _t376 = p->src; + unsigned int _t377; + _t377 = p->pos; + _t378 = _t377 - start; + const char* _t379; + _t379 = String_Slice(_t376, start, _t378); + numStr = _t379; double n; - double _t389; - _t389 = String_ToFloat(numStr); - n = _t389; - JsonValue _t390; - _t390 = Json_Number(n); - return _t390; + double _t380; + _t380 = String_ToFloat(numStr); + n = _t380; + JsonValue _t381; + _t381 = Json_Number(n); + return _t381; } JsonValue JsonParser_ParseArray(JsonParser* p) { - int _t393; - int _t396; - void* _t398; - int _t400; - int _t401; + int _t384; + int _t387; + void* _t389; + int _t391; + int _t392; JsonParser_Advance(p); JsonValue arr; - JsonValue _t391; - _t391 = Json_Array(); - arr = _t391; + JsonValue _t382; + _t382 = Json_Array(); + arr = _t382; JsonParser_SkipWhitespace(p); - int _t392; - _t392 = JsonParser_Peek(p); - _t393 = (_t392 == 93); - if (!_t393) goto endif149; + int _t383; + _t383 = JsonParser_Peek(p); + _t384 = (_t383 == 93); + if (!_t384) goto endif140; { JsonParser_Advance(p); return arr; } - endif149:; - while150:; - if (!1) goto wend152; + endif140:; + while141:; + if (!1) goto wend142; { JsonParser_SkipWhitespace(p); JsonValue val; - JsonValue _t394; - _t394 = JsonParser_ParseValue(p); - val = _t394; - const char* _t395; - _t395 = p->error; - _t396 = (_t395 != ""); - if (!_t396) goto endif154; + JsonValue _t385; + _t385 = JsonParser_ParseValue(p); + val = _t385; + const char* _t386; + _t386 = p->error; + _t387 = (_t386 != ""); + if (!_t387) goto endif144; { - JsonValue _t397; - _t397 = Json_Null(); - return _t397; + JsonValue _t388; + _t388 = Json_Null(); + return _t388; } - endif154:; - _t398 = &arr; - Json_ArrayPush(_t398, val); + endif144:; + _t389 = &arr; + Json_ArrayPush(_t389, val); JsonParser_SkipWhitespace(p); int c; - int _t399; - _t399 = JsonParser_Peek(p); - c = _t399; - _t400 = (c == 93); - if (!_t400) goto endif156; + int _t390; + _t390 = JsonParser_Peek(p); + c = _t390; + _t391 = (c == 93); + if (!_t391) goto endif146; { JsonParser_Advance(p); return arr; } - endif156:; - _t401 = (c == 44); - if (!_t401) goto else157; + endif146:; + _t392 = (c == 44); + if (!_t392) goto else147; { JsonParser_Advance(p); } - goto endif158; - else157:; + goto endif148; + else147:; { p->error = "Expected ',' or ']' in array"; - JsonValue _t402; - _t402 = Json_Null(); - return _t402; + JsonValue _t393; + _t393 = Json_Null(); + return _t393; } - endif158:; + endif148:; } - goto while150; - wend152:; + goto while141; + wend142:; } JsonValue JsonParser_ParseObject(JsonParser* p) { - int _t405; - int _t408; + int _t396; + int _t399; + int _t402; + int _t406; + void* _t408; + int _t410; int _t411; - int _t415; - void* _t417; - int _t419; - int _t420; JsonParser_Advance(p); JsonValue obj; - JsonValue _t403; - _t403 = Json_Object(); - obj = _t403; + JsonValue _t394; + _t394 = Json_Object(); + obj = _t394; JsonParser_SkipWhitespace(p); - int _t404; - _t404 = JsonParser_Peek(p); - _t405 = (_t404 == 125); - if (!_t405) goto endif160; + int _t395; + _t395 = JsonParser_Peek(p); + _t396 = (_t395 == 125); + if (!_t396) goto endif150; + { + JsonParser_Advance(p); + return obj; + } + endif150:; + while151:; + if (!1) goto wend152; + { + JsonParser_SkipWhitespace(p); + const char* key; + const char* _t397; + _t397 = JsonParser_ParseString(p); + key = _t397; + const char* _t398; + _t398 = p->error; + _t399 = (_t398 != ""); + if (!_t399) goto endif154; + { + JsonValue _t400; + _t400 = Json_Null(); + return _t400; + } + endif154:; + JsonParser_SkipWhitespace(p); + int _t401; + _t401 = JsonParser_Peek(p); + _t402 = (_t401 != 58); + if (!_t402) goto endif156; + { + p->error = "Expected ':' after object key"; + JsonValue _t403; + _t403 = Json_Null(); + return _t403; + } + endif156:; + JsonParser_Advance(p); + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t404; + _t404 = JsonParser_ParseValue(p); + val = _t404; + const char* _t405; + _t405 = p->error; + _t406 = (_t405 != ""); + if (!_t406) goto endif158; + { + JsonValue _t407; + _t407 = Json_Null(); + return _t407; + } + endif158:; + _t408 = &obj; + Json_ObjectSet(_t408, key, val); + JsonParser_SkipWhitespace(p); + int c; + int _t409; + _t409 = JsonParser_Peek(p); + c = _t409; + _t410 = (c == 125); + if (!_t410) goto endif160; { JsonParser_Advance(p); return obj; } endif160:; - while161:; - if (!1) goto wend163; + _t411 = (c == 44); + if (!_t411) goto else161; { - JsonParser_SkipWhitespace(p); - const char* key; - const char* _t406; - _t406 = JsonParser_ParseString(p); - key = _t406; - const char* _t407; - _t407 = p->error; - _t408 = (_t407 != ""); - if (!_t408) goto endif165; - { - JsonValue _t409; - _t409 = Json_Null(); - return _t409; + JsonParser_Advance(p); } - endif165:; - JsonParser_SkipWhitespace(p); - int _t410; - _t410 = JsonParser_Peek(p); - _t411 = (_t410 != 58); - if (!_t411) goto endif167; + goto endif162; + else161:; { - p->error = "Expected ':' after object key"; + p->error = "Expected ',' or '}' in object"; JsonValue _t412; _t412 = Json_Null(); return _t412; } - endif167:; - JsonParser_Advance(p); - JsonParser_SkipWhitespace(p); - JsonValue val; - JsonValue _t413; - _t413 = JsonParser_ParseValue(p); - val = _t413; - const char* _t414; - _t414 = p->error; - _t415 = (_t414 != ""); - if (!_t415) goto endif169; - { - JsonValue _t416; - _t416 = Json_Null(); - return _t416; + endif162:; } - endif169:; - _t417 = &obj; - Json_ObjectSet(_t417, key, val); - JsonParser_SkipWhitespace(p); - int c; - int _t418; - _t418 = JsonParser_Peek(p); - c = _t418; - _t419 = (c == 125); - if (!_t419) goto endif171; - { - JsonParser_Advance(p); - return obj; - } - endif171:; - _t420 = (c == 44); - if (!_t420) goto else172; - { - JsonParser_Advance(p); - } - goto endif173; - else172:; - { - p->error = "Expected ',' or '}' in object"; - JsonValue _t421; - _t421 = Json_Null(); - return _t421; - } - endif173:; - } - goto while161; - wend163:; + goto while151; + wend152:; } JsonValue JsonParser_ParseValue(JsonParser* p) { + int _t414; + int _t416; + int _t419; + int _t421; int _t423; - int _t425; - int _t428; - int _t430; - int _t432; + int _t427; + int _t431; + int _t435; int _t436; - int _t440; - int _t444; - int _t445; - int _t447; + int _t438; JsonParser_SkipWhitespace(p); int c; - int _t422; - _t422 = JsonParser_Peek(p); - c = _t422; - _t423 = (c == 0); - if (!_t423) goto endif175; + int _t413; + _t413 = JsonParser_Peek(p); + c = _t413; + _t414 = (c == 0); + if (!_t414) goto endif164; { p->error = "Unexpected end of input"; - JsonValue _t424; - _t424 = Json_Null(); - return _t424; + JsonValue _t415; + _t415 = Json_Null(); + return _t415; } - endif175:; - _t425 = (c == 34); - if (!_t425) goto endif177; + endif164:; + _t416 = (c == 34); + if (!_t416) goto endif166; { - const char* _t426; - _t426 = JsonParser_ParseString(p); - JsonValue _t427; - _t427 = Json_String(_t426); - return _t427; + const char* _t417; + _t417 = JsonParser_ParseString(p); + JsonValue _t418; + _t418 = Json_String(_t417); + return _t418; } - endif177:; - _t428 = (c == 123); - if (!_t428) goto endif179; + endif166:; + _t419 = (c == 123); + if (!_t419) goto endif168; + { + JsonValue _t420; + _t420 = JsonParser_ParseObject(p); + return _t420; + } + endif168:; + _t421 = (c == 91); + if (!_t421) goto endif170; + { + JsonValue _t422; + _t422 = JsonParser_ParseArray(p); + return _t422; + } + endif170:; + _t423 = (c == 116); + if (!_t423) goto endif172; + { + bool _t424; + _t424 = JsonParser_Match(p, "true"); + if (!_t424) goto endif174; + { + JsonValue _t425; + _t425 = Json_Bool(1); + return _t425; + } + endif174:; + p->error = "Expected 'true'"; + JsonValue _t426; + _t426 = Json_Null(); + return _t426; + } + endif172:; + _t427 = (c == 102); + if (!_t427) goto endif176; + { + bool _t428; + _t428 = JsonParser_Match(p, "false"); + if (!_t428) goto endif178; { JsonValue _t429; - _t429 = JsonParser_ParseObject(p); + _t429 = Json_Bool(0); return _t429; } - endif179:; - _t430 = (c == 91); - if (!_t430) goto endif181; - { - JsonValue _t431; - _t431 = JsonParser_ParseArray(p); - return _t431; + endif178:; + p->error = "Expected 'false'"; + JsonValue _t430; + _t430 = Json_Null(); + return _t430; } - endif181:; - _t432 = (c == 116); - if (!_t432) goto endif183; + endif176:; + _t431 = (c == 110); + if (!_t431) goto endif180; { - bool _t433; - _t433 = JsonParser_Match(p, "true"); - if (!_t433) goto endif185; + bool _t432; + _t432 = JsonParser_Match(p, "null"); + if (!_t432) goto endif182; { + JsonValue _t433; + _t433 = Json_Null(); + return _t433; + } + endif182:; + p->error = "Expected 'null'"; JsonValue _t434; - _t434 = Json_Bool(1); + _t434 = Json_Null(); return _t434; } - endif185:; - p->error = "Expected 'true'"; - JsonValue _t435; - _t435 = Json_Null(); - return _t435; - } - endif183:; - _t436 = (c == 102); - if (!_t436) goto endif187; - { - bool _t437; - _t437 = JsonParser_Match(p, "false"); - if (!_t437) goto endif189; - { - JsonValue _t438; - _t438 = Json_Bool(0); - return _t438; - } - endif189:; - p->error = "Expected 'false'"; - JsonValue _t439; - _t439 = Json_Null(); - return _t439; - } - endif187:; - _t440 = (c == 110); - if (!_t440) goto endif191; - { - bool _t441; - _t441 = JsonParser_Match(p, "null"); - if (!_t441) goto endif193; - { - JsonValue _t442; - _t442 = Json_Null(); - return _t442; - } - endif193:; - p->error = "Expected 'null'"; - JsonValue _t443; - _t443 = Json_Null(); - return _t443; - } - endif191:; + endif180:; bool __or_tmp_7; bool __and_tmp_8; - _t444 = (c >= 48); - if (!_t444) goto else194; - _t445 = (c <= 57); - *(bool*)&__and_tmp_8 = _t445; - goto endif195; - else194:; + _t435 = (c >= 48); + if (!_t435) goto else183; + _t436 = (c <= 57); + *(bool*)&__and_tmp_8 = _t436; + goto endif184; + else183:; *(bool*)&__and_tmp_8 = 0; - endif195:; - bool _t446; - _t446 = *(bool*)&__and_tmp_8; - if (!_t446) goto else196; + endif184:; + bool _t437; + _t437 = *(bool*)&__and_tmp_8; + if (!_t437) goto else185; *(bool*)&__or_tmp_7 = 1; - goto endif197; - else196:; - _t447 = (c == 45); - *(bool*)&__or_tmp_7 = _t447; - endif197:; - bool _t448; - _t448 = *(bool*)&__or_tmp_7; - if (!_t448) goto endif199; + goto endif186; + else185:; + _t438 = (c == 45); + *(bool*)&__or_tmp_7 = _t438; + endif186:; + bool _t439; + _t439 = *(bool*)&__or_tmp_7; + if (!_t439) goto endif188; { - JsonValue _t449; - _t449 = JsonParser_ParseNumber(p); - return _t449; + JsonValue _t440; + _t440 = JsonParser_ParseNumber(p); + return _t440; } - endif199:; + endif188:; p->error = "Unexpected character"; - JsonValue _t450; - _t450 = Json_Null(); - return _t450; + JsonValue _t441; + _t441 = Json_Null(); + return _t441; } JsonValue Json_Parse(const char* s) { - JsonParser _t452; - void* _t453; - void* _t455; - int _t457; - int _t460; + JsonParser _t443; + void* _t444; + void* _t446; + int _t448; + int _t451; JsonParser p; - unsigned int _t451; - _t451 = String_Len(s); - _t452 = (JsonParser){.src = s, .pos = 0, .len = _t451, .error = ""}; - p = _t452; + unsigned int _t442; + _t442 = String_Len(s); + _t443 = (JsonParser){.src = s, .pos = 0, .len = _t442, .error = ""}; + p = _t443; JsonValue result; - _t453 = &p; - JsonValue _t454; - _t454 = JsonParser_ParseValue(_t453); - result = _t454; - _t455 = &p; - JsonParser_SkipWhitespace(_t455); + _t444 = &p; + JsonValue _t445; + _t445 = JsonParser_ParseValue(_t444); + result = _t445; + _t446 = &p; + JsonParser_SkipWhitespace(_t446); bool __and_tmp_9; - const char* _t456; - _t456 = p.error; - _t457 = (_t456 == ""); - if (!_t457) goto else200; - unsigned int _t458; - _t458 = p.pos; - unsigned int _t459; - _t459 = p.len; - _t460 = (_t458 != _t459); - *(bool*)&__and_tmp_9 = _t460; - goto endif201; - else200:; + const char* _t447; + _t447 = p.error; + _t448 = (_t447 == ""); + if (!_t448) goto else189; + unsigned int _t449; + _t449 = p.pos; + unsigned int _t450; + _t450 = p.len; + _t451 = (_t449 != _t450); + *(bool*)&__and_tmp_9 = _t451; + goto endif190; + else189:; *(bool*)&__and_tmp_9 = 0; - endif201:; - bool _t461; - _t461 = *(bool*)&__and_tmp_9; - if (!_t461) goto endif203; + endif190:; + bool _t452; + _t452 = *(bool*)&__and_tmp_9; + if (!_t452) goto endif192; { p.error = "Trailing data after JSON value"; - JsonValue _t462; - _t462 = Json_Null(); - return _t462; + JsonValue _t453; + _t453 = Json_Null(); + return _t453; } - endif203:; + endif192:; return result; } void Json_StringifyImpl(StringBuilder* sb, JsonValue v) { - int _t464; - int _t466; - int _t469; + int _t455; + int _t457; + int _t460; + int _t463; + char _t464; + char _t466; + int _t468; + char _t469; + int _t471; int _t472; char _t473; - char _t475; - int _t477; - char _t478; - int _t480; - int _t481; - char _t482; - int _t485; - char _t486; - int _t488; + int _t476; + char _t477; + int _t479; + char _t480; + int _t482; + int _t483; + char _t484; + char _t485; + char _t488; char _t489; - int _t491; int _t492; char _t493; - char _t494; - char _t497; - char _t498; - int _t501; - char _t502; - int _t463; - _t463 = v.tag; - _t464 = (_t463 == JsonTagNull); - if (!_t464) goto endif205; + int _t454; + _t454 = v.tag; + _t455 = (_t454 == JsonTagNull); + if (!_t455) goto endif194; { StringBuilder_Append(sb, "null"); return; } - endif205:; - int _t465; - _t465 = v.tag; - _t466 = (_t465 == JsonTagBool); - if (!_t466) goto endif207; + endif194:; + int _t456; + _t456 = v.tag; + _t457 = (_t456 == JsonTagBool); + if (!_t457) goto endif196; { - bool _t467; - _t467 = v.boolVal; - if (!_t467) goto else208; + bool _t458; + _t458 = v.boolVal; + if (!_t458) goto else197; { StringBuilder_Append(sb, "true"); } - goto endif209; - else208:; + goto endif198; + else197:; { StringBuilder_Append(sb, "false"); } - endif209:; + endif198:; return; } - endif207:; - int _t468; - _t468 = v.tag; - _t469 = (_t468 == JsonTagNumber); - if (!_t469) goto endif211; + endif196:; + int _t459; + _t459 = v.tag; + _t460 = (_t459 == JsonTagNumber); + if (!_t460) goto endif200; { - double _t470; - _t470 = v.numVal; - StringBuilder_AppendFloat(sb, _t470); + double _t461; + _t461 = v.numVal; + StringBuilder_AppendFloat(sb, _t461); return; } - endif211:; - int _t471; - _t471 = v.tag; - _t472 = (_t471 == JsonTagString); - if (!_t472) goto endif213; + endif200:; + int _t462; + _t462 = v.tag; + _t463 = (_t462 == JsonTagString); + if (!_t463) goto endif202; { - _t473 = (char)34; + _t464 = (char)34; + StringBuilder_AppendChar(sb, _t464); + const char* _t465; + _t465 = v.strVal; + StringBuilder_Append(sb, _t465); + _t466 = (char)34; + StringBuilder_AppendChar(sb, _t466); + return; + } + endif202:; + int _t467; + _t467 = v.tag; + _t468 = (_t467 == JsonTagArray); + if (!_t468) goto endif204; + { + _t469 = (char)91; + StringBuilder_AppendChar(sb, _t469); + unsigned int i; + i = 0; + while205:; + unsigned int _t470; + _t470 = v.arrLen; + _t471 = (i < _t470); + if (!_t471) goto wend206; + { + _t472 = (i > 0); + if (!_t472) goto endif208; + { + _t473 = (char)44; StringBuilder_AppendChar(sb, _t473); - const char* _t474; - _t474 = v.strVal; - StringBuilder_Append(sb, _t474); - _t475 = (char)34; - StringBuilder_AppendChar(sb, _t475); + } + endif208:; + JsonValue* _t474; + _t474 = v.arrData; + JsonValue _t475; + _t475 = _t474[i]; + Json_StringifyImpl(sb, _t475); + _t476 = i + 1; + i = _t476; + } + goto while205; + wend206:; + _t477 = (char)93; + StringBuilder_AppendChar(sb, _t477); return; } - endif213:; - int _t476; - _t476 = v.tag; - _t477 = (_t476 == JsonTagArray); - if (!_t477) goto endif215; + endif204:; + int _t478; + _t478 = v.tag; + _t479 = (_t478 == JsonTagObject); + if (!_t479) goto endif210; { - _t478 = (char)91; - StringBuilder_AppendChar(sb, _t478); + _t480 = (char)123; + StringBuilder_AppendChar(sb, _t480); unsigned int i; i = 0; - while216:; - unsigned int _t479; - _t479 = v.arrLen; - _t480 = (i < _t479); - if (!_t480) goto wend218; + while211:; + unsigned int _t481; + _t481 = v.objLen; + _t482 = (i < _t481); + if (!_t482) goto wend212; { - _t481 = (i > 0); - if (!_t481) goto endif220; + _t483 = (i > 0); + if (!_t483) goto endif214; { - _t482 = (char)44; - StringBuilder_AppendChar(sb, _t482); + _t484 = (char)44; + StringBuilder_AppendChar(sb, _t484); } - endif220:; - JsonValue* _t483; - _t483 = v.arrData; - JsonValue _t484; - _t484 = _t483[i]; - Json_StringifyImpl(sb, _t484); - _t485 = i + 1; - i = _t485; - } - goto while216; - wend218:; - _t486 = (char)93; - StringBuilder_AppendChar(sb, _t486); - return; - } - endif215:; - int _t487; - _t487 = v.tag; - _t488 = (_t487 == JsonTagObject); - if (!_t488) goto endif222; - { - _t489 = (char)123; + endif214:; + _t485 = (char)34; + StringBuilder_AppendChar(sb, _t485); + const char** _t486; + _t486 = v.objKeys; + const char* _t487; + _t487 = _t486[i]; + StringBuilder_Append(sb, _t487); + _t488 = (char)34; + StringBuilder_AppendChar(sb, _t488); + _t489 = (char)58; StringBuilder_AppendChar(sb, _t489); - unsigned int i; - i = 0; - while223:; - unsigned int _t490; - _t490 = v.objLen; - _t491 = (i < _t490); - if (!_t491) goto wend225; - { - _t492 = (i > 0); - if (!_t492) goto endif227; - { - _t493 = (char)44; + JsonValue* _t490; + _t490 = v.objValues; + JsonValue _t491; + _t491 = _t490[i]; + Json_StringifyImpl(sb, _t491); + _t492 = i + 1; + i = _t492; + } + goto while211; + wend212:; + _t493 = (char)125; StringBuilder_AppendChar(sb, _t493); - } - endif227:; - _t494 = (char)34; - StringBuilder_AppendChar(sb, _t494); - const char** _t495; - _t495 = v.objKeys; - const char* _t496; - _t496 = _t495[i]; - StringBuilder_Append(sb, _t496); - _t497 = (char)34; - StringBuilder_AppendChar(sb, _t497); - _t498 = (char)58; - StringBuilder_AppendChar(sb, _t498); - JsonValue* _t499; - _t499 = v.objValues; - JsonValue _t500; - _t500 = _t499[i]; - Json_StringifyImpl(sb, _t500); - _t501 = i + 1; - i = _t501; - } - goto while223; - wend225:; - _t502 = (char)125; - StringBuilder_AppendChar(sb, _t502); return; } - endif222:; + endif210:; } const char* Json_Stringify(JsonValue v) { - void* _t504; - void* _t505; + void* _t495; + void* _t496; StringBuilder sb; - StringBuilder _t503; - _t503 = StringBuilder_New(); - sb = _t503; - _t504 = &sb; - Json_StringifyImpl(_t504, v); - _t505 = &sb; - const char* _t506; - _t506 = StringBuilder_Build(_t505); - return _t506; + StringBuilder _t494; + _t494 = StringBuilder_New(); + sb = _t494; + _t495 = &sb; + Json_StringifyImpl(_t495, v); + _t496 = &sb; + const char* _t497; + _t497 = StringBuilder_Build(_t496); + return _t497; } unsigned int String_Len(const char* s) { - unsigned int _t507; - _t507 = bux_strlen(s); - return _t507; + unsigned int _t498; + _t498 = bux_strlen(s); + return _t498; } bool String_IsNull(const char* s) { - int _t509; - int _t508; - _t508 = bux_str_is_null(s); - _t509 = (_t508 != 0); - return _t509; + int _t500; + int _t499; + _t499 = bux_str_is_null(s); + _t500 = (_t499 != 0); + return _t500; } bool String_Eq(const char* a, const char* b) { - int _t511; - int _t510; - _t510 = bux_strcmp(a, b); - _t511 = (_t510 == 0); - return _t511; + int _t502; + int _t501; + _t501 = bux_strcmp(a, b); + _t502 = (_t501 == 0); + return _t502; } const char* String_Concat(const char* a, const char* b) { - int _t514; - int _t515; - char* _t517; + int _t505; + int _t506; + char* _t508; unsigned int len_a; - unsigned int _t512; - _t512 = bux_strlen(a); - len_a = _t512; + unsigned int _t503; + _t503 = bux_strlen(a); + len_a = _t503; unsigned int len_b; - unsigned int _t513; - _t513 = bux_strlen(b); - len_b = _t513; + unsigned int _t504; + _t504 = bux_strlen(b); + len_b = _t504; unsigned int total; - _t514 = len_a + len_b; - _t515 = _t514 + 1; - total = _t515; + _t505 = len_a + len_b; + _t506 = _t505 + 1; + total = _t506; char* buf; - void* _t516; - _t516 = bux_alloc(total); - _t517 = (char*)_t516; - buf = _t517; + void* _t507; + _t507 = bux_alloc(total); + _t508 = (char*)_t507; + buf = _t508; bux_strcpy(buf, a); bux_strcat(buf, b); return buf; } const char* String_Copy(const char* s) { - int _t519; - char* _t521; + int _t510; + char* _t512; unsigned int len; - unsigned int _t518; - _t518 = bux_strlen(s); - len = _t518; + unsigned int _t509; + _t509 = bux_strlen(s); + len = _t509; char* buf; - _t519 = len + 1; - void* _t520; - _t520 = bux_alloc(_t519); - _t521 = (char*)_t520; - buf = _t521; + _t510 = len + 1; + void* _t511; + _t511 = bux_alloc(_t510); + _t512 = (char*)_t511; + buf = _t512; bux_strcpy(buf, s); return buf; } bool String_StartsWith(const char* s, const char* prefix) { - int _t524; - int _t526; + int _t515; + int _t517; unsigned int s_len; - unsigned int _t522; - _t522 = bux_strlen(s); - s_len = _t522; + unsigned int _t513; + _t513 = bux_strlen(s); + s_len = _t513; unsigned int p_len; - unsigned int _t523; - _t523 = bux_strlen(prefix); - p_len = _t523; - _t524 = (p_len > s_len); - if (!_t524) goto endif229; + unsigned int _t514; + _t514 = bux_strlen(prefix); + p_len = _t514; + _t515 = (p_len > s_len); + if (!_t515) goto endif216; { return 0; } - endif229:; + endif216:; int r; - int _t525; - _t525 = bux_strncmp(s, prefix, p_len); - r = _t525; - _t526 = (r == 0); - return _t526; + int _t516; + _t516 = bux_strncmp(s, prefix, p_len); + r = _t516; + _t517 = (r == 0); + return _t517; } bool String_EndsWith(const char* s, const char* suffix) { - int _t529; - int _t530; - int _t533; + int _t520; + int _t521; + int _t524; unsigned int s_len; - unsigned int _t527; - _t527 = bux_strlen(s); - s_len = _t527; + unsigned int _t518; + _t518 = bux_strlen(s); + s_len = _t518; unsigned int suf_len; - unsigned int _t528; - _t528 = bux_strlen(suffix); - suf_len = _t528; - _t529 = (suf_len > s_len); - if (!_t529) goto endif231; + unsigned int _t519; + _t519 = bux_strlen(suffix); + suf_len = _t519; + _t520 = (suf_len > s_len); + if (!_t520) goto endif218; { return 0; } - endif231:; + endif218:; unsigned int start; - _t530 = s_len - suf_len; - start = _t530; + _t521 = s_len - suf_len; + start = _t521; const char* tail; - const char* _t531; - _t531 = bux_str_slice(s, start, suf_len); - tail = _t531; + const char* _t522; + _t522 = bux_str_slice(s, start, suf_len); + tail = _t522; bool eq; - int _t532; - _t532 = bux_strcmp(tail, suffix); - _t533 = (_t532 == 0); - eq = _t533; + int _t523; + _t523 = bux_strcmp(tail, suffix); + _t524 = (_t523 == 0); + eq = _t524; return eq; } bool String_Contains(const char* s, const char* substr) { - int _t535; + int _t526; int r; - int _t534; - _t534 = bux_str_contains(s, substr); - r = _t534; - _t535 = (r != 0); - return _t535; + int _t525; + _t525 = bux_str_contains(s, substr); + r = _t525; + _t526 = (r != 0); + return _t526; } const char* String_Slice(const char* s, unsigned int start, unsigned int len) { - const char* _t536; - _t536 = bux_str_slice(s, start, len); - return _t536; + const char* _t527; + _t527 = bux_str_slice(s, start, len); + return _t527; } const char* String_Trim(const char* s) { - const char* _t537; - _t537 = bux_str_trim(s); - return _t537; + const char* _t528; + _t528 = bux_str_trim(s); + return _t528; } const char* String_TrimLeft(const char* s) { - const char* _t538; - _t538 = bux_str_trim_left(s); - return _t538; + const char* _t529; + _t529 = bux_str_trim_left(s); + return _t529; } const char* String_TrimRight(const char* s) { - const char* _t539; - _t539 = bux_str_trim_right(s); - return _t539; + const char* _t530; + _t530 = bux_str_trim_right(s); + return _t530; } const char* String_FromInt(int64_t n) { - const char* _t540; - _t540 = bux_int_to_str(n); - return _t540; + const char* _t531; + _t531 = bux_int_to_str(n); + return _t531; } int64_t String_ToInt(const char* s) { - int64_t _t541; - _t541 = bux_str_to_int(s); - return _t541; + int64_t _t532; + _t532 = bux_str_to_int(s); + return _t532; } StringBuilder StringBuilder_New(void) { - StringBuilder _t543; - void* _t542; - _t542 = bux_sb_new(64); - _t543 = (StringBuilder){.handle = _t542}; - return _t543; + StringBuilder _t534; + void* _t533; + _t533 = bux_sb_new(64); + _t534 = (StringBuilder){.handle = _t533}; + return _t534; } StringBuilder StringBuilder_NewCap(unsigned int cap) { - StringBuilder _t545; - void* _t544; - _t544 = bux_sb_new(cap); - _t545 = (StringBuilder){.handle = _t544}; - return _t545; + StringBuilder _t536; + void* _t535; + _t535 = bux_sb_new(cap); + _t536 = (StringBuilder){.handle = _t535}; + return _t536; } void StringBuilder_Append(StringBuilder* sb, const char* s) { - void* _t546; - _t546 = sb->handle; - bux_sb_append(_t546, s); + void* _t537; + _t537 = sb->handle; + bux_sb_append(_t537, s); } void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) { - void* _t547; - _t547 = sb->handle; - bux_sb_append_int(_t547, n); + void* _t538; + _t538 = sb->handle; + bux_sb_append_int(_t538, n); } void StringBuilder_AppendFloat(StringBuilder* sb, double f) { - void* _t548; - _t548 = sb->handle; - bux_sb_append_float(_t548, f); + void* _t539; + _t539 = sb->handle; + bux_sb_append_float(_t539, f); } void StringBuilder_AppendChar(StringBuilder* sb, char c) { - void* _t549; - _t549 = sb->handle; - bux_sb_append_char(_t549, c); + void* _t540; + _t540 = sb->handle; + bux_sb_append_char(_t540, c); } const char* StringBuilder_Build(StringBuilder* sb) { - void* _t550; - _t550 = sb->handle; - const char* _t551; - _t551 = bux_sb_build(_t550); - return _t551; + void* _t541; + _t541 = sb->handle; + const char* _t542; + _t542 = bux_sb_build(_t541); + return _t542; } void StringBuilder_Free(StringBuilder* sb) { - void* _t552; - _t552 = sb->handle; - bux_sb_free(_t552); + void* _t543; + _t543 = sb->handle; + bux_sb_free(_t543); } unsigned int String_SplitCount(const char* s, const char* delim) { - unsigned int _t553; - _t553 = bux_str_split_count(s, delim); - return _t553; + unsigned int _t544; + _t544 = bux_str_split_count(s, delim); + return _t544; } const char* String_SplitPart(const char* s, const char* delim, unsigned int index) { - const char* _t554; - _t554 = bux_str_split_part(s, delim, index); - return _t554; + const char* _t545; + _t545 = bux_str_split_part(s, delim, index); + return _t545; } const char* String_Join2(const char* a, const char* b, const char* sep) { - const char* _t555; - _t555 = bux_str_join2(a, b, sep); - return _t555; + const char* _t546; + _t546 = bux_str_join2(a, b, sep); + return _t546; } const char* String_Chars(const char* s, unsigned int index) { - const char* _t556; - _t556 = bux_str_slice(s, index, 1); - return _t556; + const char* _t547; + _t547 = bux_str_slice(s, index, 1); + return _t547; } const char* String_Find(const char* haystack, const char* needle) { - const char* _t557; - _t557 = bux_strstr(haystack, needle); - return _t557; + const char* _t548; + _t548 = bux_strstr(haystack, needle); + return _t548; } unsigned int String_Offset(const char* pos, const char* base) { - unsigned int _t558; - _t558 = bux_str_offset(pos, base); - return _t558; + unsigned int _t549; + _t549 = bux_str_offset(pos, base); + return _t549; } const char* String_Replace(const char* s, const char* old, const char* new) { - int _t564; - int _t566; - int _t567; + int _t555; + int _t557; + int _t558; const char* pos; - const char* _t559; - _t559 = bux_strstr(s, old); - pos = _t559; - bool _t560; - _t560 = String_IsNull(pos); - if (!_t560) goto endif233; + const char* _t550; + _t550 = bux_strstr(s, old); + pos = _t550; + bool _t551; + _t551 = String_IsNull(pos); + if (!_t551) goto endif220; { return s; } - endif233:; + endif220:; unsigned int oldLen; - unsigned int _t561; - _t561 = bux_strlen(old); - oldLen = _t561; + unsigned int _t552; + _t552 = bux_strlen(old); + oldLen = _t552; unsigned int prefixLen; - unsigned int _t562; - _t562 = String_Offset(pos, s); - prefixLen = _t562; + unsigned int _t553; + _t553 = String_Offset(pos, s); + prefixLen = _t553; const char* prefix; - const char* _t563; - _t563 = bux_str_slice(s, 0, prefixLen); - prefix = _t563; + const char* _t554; + _t554 = bux_str_slice(s, 0, prefixLen); + prefix = _t554; const char* suffix; - _t564 = prefixLen + oldLen; - unsigned int _t565; - _t565 = bux_strlen(s); - _t566 = _t565 - prefixLen; - _t567 = _t566 - oldLen; - const char* _t568; - _t568 = bux_str_slice(s, _t564, _t567); - suffix = _t568; + _t555 = prefixLen + oldLen; + unsigned int _t556; + _t556 = bux_strlen(s); + _t557 = _t556 - prefixLen; + _t558 = _t557 - oldLen; + const char* _t559; + _t559 = bux_str_slice(s, _t555, _t558); + suffix = _t559; const char* temp; - const char* _t569; - _t569 = String_Concat(prefix, new); - temp = _t569; + const char* _t560; + _t560 = String_Concat(prefix, new); + temp = _t560; const char* result; - const char* _t570; - _t570 = String_Concat(temp, suffix); - result = _t570; + const char* _t561; + _t561 = String_Concat(temp, suffix); + result = _t561; return result; } double String_ToFloat(const char* s) { - double _t571; - _t571 = bux_str_to_float(s); - return _t571; + double _t562; + _t562 = bux_str_to_float(s); + return _t562; } const char* String_FromBool(bool b) { - if (!b) goto endif235; + if (!b) goto endif222; { return "true"; } - endif235:; + endif222:; return "false"; } const char* String_FromFloat(double f) { - const char* _t572; - _t572 = bux_float_to_string(f); - return _t572; + const char* _t563; + _t563 = bux_float_to_string(f); + return _t563; } const char* String_Format1(const char* pattern, const char* a0) { - const char* _t573; - _t573 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); - return _t573; + const char* _t564; + _t564 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); + return _t564; } const char* String_Format2(const char* pattern, const char* a0, const char* a1) { - const char* _t574; - _t574 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); - return _t574; + const char* _t565; + _t565 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); + return _t565; } const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) { - const char* _t575; - _t575 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); - return _t575; + const char* _t566; + _t566 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); + return _t566; } void Channel_SendInt(Channel_int* ch, int value) { - void* _t577; - void* _t578; - void* _t576; - _t576 = ch->handle; - _t577 = &value; - _t578 = (void*)_t577; - bux_channel_send(_t576, _t578); + void* _t568; + void* _t569; + void* _t567; + _t567 = ch->handle; + _t568 = &value; + _t569 = (void*)_t568; + bux_channel_send(_t567, _t569); } int Channel_RecvInt(Channel_int* ch) { - void* _t580; - void* _t581; + void* _t571; + void* _t572; int result; result = 0; - void* _t579; - _t579 = ch->handle; - _t580 = &result; - _t581 = (void*)_t580; - bux_channel_recv(_t579, _t581); + void* _t570; + _t570 = ch->handle; + _t571 = &result; + _t572 = (void*)_t571; + bux_channel_recv(_t570, _t572); return result; } void Channel_SendFloat64(Channel_float64* ch, double value) { - void* _t583; - void* _t584; - void* _t582; - _t582 = ch->handle; - _t583 = &value; - _t584 = (void*)_t583; - bux_channel_send(_t582, _t584); + void* _t574; + void* _t575; + void* _t573; + _t573 = ch->handle; + _t574 = &value; + _t575 = (void*)_t574; + bux_channel_send(_t573, _t575); } double Channel_RecvFloat64(Channel_float64* ch) { - void* _t586; - void* _t587; + void* _t577; + void* _t578; double result; result = 0.0; - void* _t585; - _t585 = ch->handle; - _t586 = &result; - _t587 = (void*)_t586; - bux_channel_recv(_t585, _t587); + void* _t576; + _t576 = ch->handle; + _t577 = &result; + _t578 = (void*)_t577; + bux_channel_recv(_t576, _t578); return result; } const char* Hash_Sha1(const char* data) { - int _t589; + int _t580; int len; - unsigned int _t588; - _t588 = String_Len(data); - _t589 = (int)_t588; - len = _t589; + unsigned int _t579; + _t579 = String_Len(data); + _t580 = (int)_t579; + len = _t580; void* buf; - void* _t590; - _t590 = Alloc(20); - buf = _t590; + void* _t581; + _t581 = Alloc(20); + buf = _t581; bux_sha1(data, len, buf); const char* result; - const char* _t591; - _t591 = bux_bytes_to_hex(buf, 20); - result = _t591; + const char* _t582; + _t582 = bux_bytes_to_hex(buf, 20); + result = _t582; Free(buf); return result; } const char* Hash_Sha256(const char* data) { - int _t593; + int _t584; int len; - unsigned int _t592; - _t592 = String_Len(data); - _t593 = (int)_t592; - len = _t593; + unsigned int _t583; + _t583 = String_Len(data); + _t584 = (int)_t583; + len = _t584; void* buf; - void* _t594; - _t594 = Alloc(32); - buf = _t594; + void* _t585; + _t585 = Alloc(32); + buf = _t585; bux_sha256(data, len, buf); const char* result; - const char* _t595; - _t595 = bux_bytes_to_hex(buf, 32); - result = _t595; + const char* _t586; + _t586 = bux_bytes_to_hex(buf, 32); + result = _t586; Free(buf); return result; } const char* Hash_Sha384(const char* data) { - int _t597; + int _t588; int len; - unsigned int _t596; - _t596 = String_Len(data); - _t597 = (int)_t596; - len = _t597; + unsigned int _t587; + _t587 = String_Len(data); + _t588 = (int)_t587; + len = _t588; void* buf; - void* _t598; - _t598 = Alloc(48); - buf = _t598; + void* _t589; + _t589 = Alloc(48); + buf = _t589; bux_sha384(data, len, buf); const char* result; - const char* _t599; - _t599 = bux_bytes_to_hex(buf, 48); - result = _t599; + const char* _t590; + _t590 = bux_bytes_to_hex(buf, 48); + result = _t590; Free(buf); return result; } const char* Hash_Sha512(const char* data) { - int _t601; + int _t592; int len; - unsigned int _t600; - _t600 = String_Len(data); - _t601 = (int)_t600; - len = _t601; + unsigned int _t591; + _t591 = String_Len(data); + _t592 = (int)_t591; + len = _t592; void* buf; - void* _t602; - _t602 = Alloc(64); - buf = _t602; + void* _t593; + _t593 = Alloc(64); + buf = _t593; bux_sha512(data, len, buf); const char* result; - const char* _t603; - _t603 = bux_bytes_to_hex(buf, 64); - result = _t603; + const char* _t594; + _t594 = bux_bytes_to_hex(buf, 64); + result = _t594; Free(buf); return result; } void Hash_Sha256Raw(const char* data, void* out) { - int _t605; - unsigned int _t604; - _t604 = String_Len(data); - _t605 = (int)_t604; - bux_sha256(data, _t605, out); + int _t596; + unsigned int _t595; + _t595 = String_Len(data); + _t596 = (int)_t595; + bux_sha256(data, _t596, out); } void Hash_Sha384Raw(const char* data, void* out) { - int _t607; - unsigned int _t606; - _t606 = String_Len(data); - _t607 = (int)_t606; - bux_sha384(data, _t607, out); + int _t598; + unsigned int _t597; + _t597 = String_Len(data); + _t598 = (int)_t597; + bux_sha384(data, _t598, out); } void Hash_Sha512Raw(const char* data, void* out) { - int _t609; - unsigned int _t608; - _t608 = String_Len(data); - _t609 = (int)_t608; - bux_sha512(data, _t609, out); + int _t600; + unsigned int _t599; + _t599 = String_Len(data); + _t600 = (int)_t599; + bux_sha512(data, _t600, out); } int Hash_Sha1Size(void) { @@ -3365,1502 +3364,1502 @@ int Hash_Sha512Size(void) { } const char* Base64_Encode(const char* s) { - int _t611; - unsigned int _t610; - _t610 = String_Len(s); - _t611 = (int)_t610; - const char* _t612; - _t612 = bux_base64_encode(s, _t611); - return _t612; + int _t602; + unsigned int _t601; + _t601 = String_Len(s); + _t602 = (int)_t601; + const char* _t603; + _t603 = bux_base64_encode(s, _t602); + return _t603; } const char* Base64_Decode(const char* s) { - int _t614; - void* _t615; + int _t605; + void* _t606; int outlen; outlen = 0; - unsigned int _t613; - _t613 = String_Len(s); - _t614 = (int)_t613; - _t615 = &outlen; - const char* _t616; - _t616 = bux_base64_decode(s, _t614, _t615); - return _t616; + unsigned int _t604; + _t604 = String_Len(s); + _t605 = (int)_t604; + _t606 = &outlen; + const char* _t607; + _t607 = bux_base64_decode(s, _t605, _t606); + return _t607; } const char* Base64URL_Encode(const char* s) { - int _t618; - unsigned int _t617; - _t617 = String_Len(s); - _t618 = (int)_t617; - const char* _t619; - _t619 = bux_base64url_encode(s, _t618); - return _t619; + int _t609; + unsigned int _t608; + _t608 = String_Len(s); + _t609 = (int)_t608; + const char* _t610; + _t610 = bux_base64url_encode(s, _t609); + return _t610; } const char* Base64URL_Decode(const char* s) { - int _t621; - void* _t622; + int _t612; + void* _t613; int outlen; outlen = 0; - unsigned int _t620; - _t620 = String_Len(s); - _t621 = (int)_t620; - _t622 = &outlen; - const char* _t623; - _t623 = bux_base64url_decode(s, _t621, _t622); - return _t623; + unsigned int _t611; + _t611 = String_Len(s); + _t612 = (int)_t611; + _t613 = &outlen; + const char* _t614; + _t614 = bux_base64url_decode(s, _t612, _t613); + return _t614; } const char* Hmac_Sha256(const char* key, const char* message) { - int _t625; - int _t627; + int _t616; + int _t618; int kl; - unsigned int _t624; - _t624 = String_Len(key); - _t625 = (int)_t624; - kl = _t625; + unsigned int _t615; + _t615 = String_Len(key); + _t616 = (int)_t615; + kl = _t616; int ml; - unsigned int _t626; - _t626 = String_Len(message); - _t627 = (int)_t626; - ml = _t627; + unsigned int _t617; + _t617 = String_Len(message); + _t618 = (int)_t617; + ml = _t618; void* buf; - void* _t628; - _t628 = Alloc(32); - buf = _t628; + void* _t619; + _t619 = Alloc(32); + buf = _t619; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - const char* _t629; - _t629 = bux_bytes_to_hex(buf, 32); - result = _t629; + const char* _t620; + _t620 = bux_bytes_to_hex(buf, 32); + result = _t620; Free(buf); return result; } void Hmac_Sha256Raw(const char* key, const char* message, void* out) { - int _t631; - int _t633; - unsigned int _t630; - _t630 = String_Len(key); - _t631 = (int)_t630; - unsigned int _t632; - _t632 = String_Len(message); - _t633 = (int)_t632; - bux_hmac_sha256(key, _t631, message, _t633, out); + int _t622; + int _t624; + unsigned int _t621; + _t621 = String_Len(key); + _t622 = (int)_t621; + unsigned int _t623; + _t623 = String_Len(message); + _t624 = (int)_t623; + bux_hmac_sha256(key, _t622, message, _t624, out); } const char* Hmac_Sha256Base64(const char* key, const char* message) { - int _t635; - int _t637; - const char* _t639; + int _t626; + int _t628; + const char* _t630; int kl; - unsigned int _t634; - _t634 = String_Len(key); - _t635 = (int)_t634; - kl = _t635; + unsigned int _t625; + _t625 = String_Len(key); + _t626 = (int)_t625; + kl = _t626; int ml; - unsigned int _t636; - _t636 = String_Len(message); - _t637 = (int)_t636; - ml = _t637; + unsigned int _t627; + _t627 = String_Len(message); + _t628 = (int)_t627; + ml = _t628; void* buf; - void* _t638; - _t638 = Alloc(32); - buf = _t638; + void* _t629; + _t629 = Alloc(32); + buf = _t629; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - _t639 = (const char*)buf; - const char* _t640; - _t640 = bux_base64_encode(_t639, 32); - result = _t640; + _t630 = (const char*)buf; + const char* _t631; + _t631 = bux_base64_encode(_t630, 32); + result = _t631; Free(buf); return result; } const char* Hmac_Sha384(const char* key, const char* message) { - int _t642; - int _t644; + int _t633; + int _t635; int kl; - unsigned int _t641; - _t641 = String_Len(key); - _t642 = (int)_t641; - kl = _t642; + unsigned int _t632; + _t632 = String_Len(key); + _t633 = (int)_t632; + kl = _t633; int ml; - unsigned int _t643; - _t643 = String_Len(message); - _t644 = (int)_t643; - ml = _t644; + unsigned int _t634; + _t634 = String_Len(message); + _t635 = (int)_t634; + ml = _t635; void* buf; - void* _t645; - _t645 = Alloc(48); - buf = _t645; + void* _t636; + _t636 = Alloc(48); + buf = _t636; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - const char* _t646; - _t646 = bux_bytes_to_hex(buf, 48); - result = _t646; + const char* _t637; + _t637 = bux_bytes_to_hex(buf, 48); + result = _t637; Free(buf); return result; } void Hmac_Sha384Raw(const char* key, const char* message, void* out) { - int _t648; - int _t650; - unsigned int _t647; - _t647 = String_Len(key); - _t648 = (int)_t647; - unsigned int _t649; - _t649 = String_Len(message); - _t650 = (int)_t649; - bux_hmac_sha384(key, _t648, message, _t650, out); + int _t639; + int _t641; + unsigned int _t638; + _t638 = String_Len(key); + _t639 = (int)_t638; + unsigned int _t640; + _t640 = String_Len(message); + _t641 = (int)_t640; + bux_hmac_sha384(key, _t639, message, _t641, out); } const char* Hmac_Sha384Base64(const char* key, const char* message) { - int _t652; - int _t654; - const char* _t656; + int _t643; + int _t645; + const char* _t647; int kl; - unsigned int _t651; - _t651 = String_Len(key); - _t652 = (int)_t651; - kl = _t652; + unsigned int _t642; + _t642 = String_Len(key); + _t643 = (int)_t642; + kl = _t643; int ml; - unsigned int _t653; - _t653 = String_Len(message); - _t654 = (int)_t653; - ml = _t654; + unsigned int _t644; + _t644 = String_Len(message); + _t645 = (int)_t644; + ml = _t645; void* buf; - void* _t655; - _t655 = Alloc(48); - buf = _t655; + void* _t646; + _t646 = Alloc(48); + buf = _t646; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - _t656 = (const char*)buf; - const char* _t657; - _t657 = bux_base64_encode(_t656, 48); - result = _t657; + _t647 = (const char*)buf; + const char* _t648; + _t648 = bux_base64_encode(_t647, 48); + result = _t648; Free(buf); return result; } const char* Hmac_Sha512(const char* key, const char* message) { - int _t659; - int _t661; + int _t650; + int _t652; int kl; - unsigned int _t658; - _t658 = String_Len(key); - _t659 = (int)_t658; - kl = _t659; + unsigned int _t649; + _t649 = String_Len(key); + _t650 = (int)_t649; + kl = _t650; int ml; - unsigned int _t660; - _t660 = String_Len(message); - _t661 = (int)_t660; - ml = _t661; + unsigned int _t651; + _t651 = String_Len(message); + _t652 = (int)_t651; + ml = _t652; void* buf; - void* _t662; - _t662 = Alloc(64); - buf = _t662; + void* _t653; + _t653 = Alloc(64); + buf = _t653; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - const char* _t663; - _t663 = bux_bytes_to_hex(buf, 64); - result = _t663; + const char* _t654; + _t654 = bux_bytes_to_hex(buf, 64); + result = _t654; Free(buf); return result; } void Hmac_Sha512Raw(const char* key, const char* message, void* out) { - int _t665; - int _t667; - unsigned int _t664; - _t664 = String_Len(key); - _t665 = (int)_t664; - unsigned int _t666; - _t666 = String_Len(message); - _t667 = (int)_t666; - bux_hmac_sha512(key, _t665, message, _t667, out); + int _t656; + int _t658; + unsigned int _t655; + _t655 = String_Len(key); + _t656 = (int)_t655; + unsigned int _t657; + _t657 = String_Len(message); + _t658 = (int)_t657; + bux_hmac_sha512(key, _t656, message, _t658, out); } const char* Hmac_Sha512Base64(const char* key, const char* message) { - int _t669; - int _t671; - const char* _t673; + int _t660; + int _t662; + const char* _t664; int kl; - unsigned int _t668; - _t668 = String_Len(key); - _t669 = (int)_t668; - kl = _t669; + unsigned int _t659; + _t659 = String_Len(key); + _t660 = (int)_t659; + kl = _t660; int ml; - unsigned int _t670; - _t670 = String_Len(message); - _t671 = (int)_t670; - ml = _t671; + unsigned int _t661; + _t661 = String_Len(message); + _t662 = (int)_t661; + ml = _t662; void* buf; - void* _t672; - _t672 = Alloc(64); - buf = _t672; + void* _t663; + _t663 = Alloc(64); + buf = _t663; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - _t673 = (const char*)buf; - const char* _t674; - _t674 = bux_base64_encode(_t673, 64); - result = _t674; + _t664 = (const char*)buf; + const char* _t665; + _t665 = bux_base64_encode(_t664, 64); + result = _t665; Free(buf); return result; } const char* Random_Bytes(int n) { - int _t675; - unsigned int _t676; - int _t679; - const char* _t680; - _t675 = (n <= 0); - if (!_t675) goto endif237; + int _t666; + unsigned int _t667; + int _t670; + const char* _t671; + _t666 = (n <= 0); + if (!_t666) goto endif224; { return ""; } - endif237:; + endif224:; void* buf; - _t676 = (unsigned int)n; - void* _t677; - _t677 = Alloc(_t676); - buf = _t677; - int _t678; - _t678 = bux_random_bytes(buf, n); - _t679 = (_t678 != 1); - if (!_t679) goto endif239; + _t667 = (unsigned int)n; + void* _t668; + _t668 = Alloc(_t667); + buf = _t668; + int _t669; + _t669 = bux_random_bytes(buf, n); + _t670 = (_t669 != 1); + if (!_t670) goto endif226; { Free(buf); return ""; } - endif239:; - _t680 = (const char*)buf; - return _t680; + endif226:; + _t671 = (const char*)buf; + return _t671; } const char* Random_Hex(int n) { - int _t681; - unsigned int _t682; - int _t685; - _t681 = (n <= 0); - if (!_t681) goto endif241; + int _t672; + unsigned int _t673; + int _t676; + _t672 = (n <= 0); + if (!_t672) goto endif228; { return ""; } - endif241:; + endif228:; void* buf; - _t682 = (unsigned int)n; - void* _t683; - _t683 = Alloc(_t682); - buf = _t683; - int _t684; - _t684 = bux_random_bytes(buf, n); - _t685 = (_t684 != 1); - if (!_t685) goto endif243; + _t673 = (unsigned int)n; + void* _t674; + _t674 = Alloc(_t673); + buf = _t674; + int _t675; + _t675 = bux_random_bytes(buf, n); + _t676 = (_t675 != 1); + if (!_t676) goto endif230; { Free(buf); return ""; } - endif243:; + endif230:; const char* result; - const char* _t686; - _t686 = bux_bytes_to_hex(buf, n); - result = _t686; + const char* _t677; + _t677 = bux_bytes_to_hex(buf, n); + result = _t677; Free(buf); return result; } const char* Random_Base64(int n) { - int _t687; - unsigned int _t688; - int _t691; - const char* _t692; - _t687 = (n <= 0); - if (!_t687) goto endif245; + int _t678; + unsigned int _t679; + int _t682; + const char* _t683; + _t678 = (n <= 0); + if (!_t678) goto endif232; { return ""; } - endif245:; + endif232:; void* buf; - _t688 = (unsigned int)n; - void* _t689; - _t689 = Alloc(_t688); - buf = _t689; - int _t690; - _t690 = bux_random_bytes(buf, n); - _t691 = (_t690 != 1); - if (!_t691) goto endif247; + _t679 = (unsigned int)n; + void* _t680; + _t680 = Alloc(_t679); + buf = _t680; + int _t681; + _t681 = bux_random_bytes(buf, n); + _t682 = (_t681 != 1); + if (!_t682) goto endif234; { Free(buf); return ""; } - endif247:; + endif234:; const char* result; - _t692 = (const char*)buf; - const char* _t693; - _t693 = bux_base64_encode(_t692, n); - result = _t693; + _t683 = (const char*)buf; + const char* _t684; + _t684 = bux_base64_encode(_t683, n); + result = _t684; Free(buf); return result; } unsigned int Random_Uint32(void) { - int _t696; - unsigned int* _t697; - unsigned int _t698; + int _t687; + unsigned int* _t688; + unsigned int _t689; void* buf; - void* _t694; - _t694 = Alloc(4); - buf = _t694; - int _t695; - _t695 = bux_random_bytes(buf, 4); - _t696 = (_t695 != 1); - if (!_t696) goto endif249; + void* _t685; + _t685 = Alloc(4); + buf = _t685; + int _t686; + _t686 = bux_random_bytes(buf, 4); + _t687 = (_t686 != 1); + if (!_t687) goto endif236; { Free(buf); return 0; } - endif249:; + endif236:; unsigned int* ptr; - _t697 = (unsigned int*)buf; - ptr = _t697; + _t688 = (unsigned int*)buf; + ptr = _t688; unsigned int val; - _t698 = *ptr; - val = _t698; + _t689 = *ptr; + val = _t689; Free(buf); return val; } const char* Aes_GenerateKey(void) { - unsigned int _t699; - int _t702; - const char* _t703; + unsigned int _t690; + int _t693; + const char* _t694; void* buf; - _t699 = (unsigned int)AES_KEY_SIZE; - void* _t700; - _t700 = Alloc(_t699); - buf = _t700; - int _t701; - _t701 = bux_random_bytes(buf, AES_KEY_SIZE); - _t702 = (_t701 != 1); - if (!_t702) goto endif251; + _t690 = (unsigned int)AES_KEY_SIZE; + void* _t691; + _t691 = Alloc(_t690); + buf = _t691; + int _t692; + _t692 = bux_random_bytes(buf, AES_KEY_SIZE); + _t693 = (_t692 != 1); + if (!_t693) goto endif238; { Free(buf); return ""; } - endif251:; - _t703 = (const char*)buf; - return _t703; + endif238:; + _t694 = (const char*)buf; + return _t694; } const char* Aes_GenerateIV(void) { - unsigned int _t704; - int _t707; - const char* _t708; + unsigned int _t695; + int _t698; + const char* _t699; void* buf; - _t704 = (unsigned int)AES_IV_SIZE; - void* _t705; - _t705 = Alloc(_t704); - buf = _t705; - int _t706; - _t706 = bux_random_bytes(buf, AES_IV_SIZE); - _t707 = (_t706 != 1); - if (!_t707) goto endif253; + _t695 = (unsigned int)AES_IV_SIZE; + void* _t696; + _t696 = Alloc(_t695); + buf = _t696; + int _t697; + _t697 = bux_random_bytes(buf, AES_IV_SIZE); + _t698 = (_t697 != 1); + if (!_t698) goto endif240; { Free(buf); return ""; } - endif253:; - _t708 = (const char*)buf; - return _t708; + endif240:; + _t699 = (const char*)buf; + return _t699; } const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv) { - int _t710; - void* _t711; + int _t701; + void* _t702; int outlen; outlen = 0; - unsigned int _t709; - _t709 = String_Len(plain); - _t710 = (int)_t709; - _t711 = &outlen; - const char* _t712; - _t712 = bux_aes_256_cbc_encrypt(plain, _t710, key, iv, _t711); - return _t712; + unsigned int _t700; + _t700 = String_Len(plain); + _t701 = (int)_t700; + _t702 = &outlen; + const char* _t703; + _t703 = bux_aes_256_cbc_encrypt(plain, _t701, key, iv, _t702); + return _t703; } const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv) { - int _t714; - void* _t715; + int _t705; + void* _t706; int outlen; outlen = 0; - unsigned int _t713; - _t713 = String_Len(cipher); - _t714 = (int)_t713; - _t715 = &outlen; - const char* _t716; - _t716 = bux_aes_256_cbc_decrypt(cipher, _t714, key, iv, _t715); - return _t716; + unsigned int _t704; + _t704 = String_Len(cipher); + _t705 = (int)_t704; + _t706 = &outlen; + const char* _t707; + _t707 = bux_aes_256_cbc_decrypt(cipher, _t705, key, iv, _t706); + return _t707; } const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag) { - int _t718; - void* _t719; + int _t709; + void* _t710; int outlen; outlen = 0; - unsigned int _t717; - _t717 = String_Len(plain); - _t718 = (int)_t717; - _t719 = &outlen; - const char* _t720; - _t720 = bux_aes_256_gcm_encrypt(plain, _t718, key, iv, tag, _t719); - return _t720; + unsigned int _t708; + _t708 = String_Len(plain); + _t709 = (int)_t708; + _t710 = &outlen; + const char* _t711; + _t711 = bux_aes_256_gcm_encrypt(plain, _t709, key, iv, tag, _t710); + return _t711; } const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag) { - int _t722; - void* _t723; + int _t713; + void* _t714; int outlen; outlen = 0; - unsigned int _t721; - _t721 = String_Len(cipher); - _t722 = (int)_t721; - _t723 = &outlen; - const char* _t724; - _t724 = bux_aes_256_gcm_decrypt(cipher, _t722, key, iv, tag, _t723); - return _t724; + unsigned int _t712; + _t712 = String_Len(cipher); + _t713 = (int)_t712; + _t714 = &outlen; + const char* _t715; + _t715 = bux_aes_256_gcm_decrypt(cipher, _t713, key, iv, tag, _t714); + return _t715; } const char* Jwt_MakeHeader(JwtAlg alg) { - int _t725; - int _t726; - int _t727; - int _t728; - int _t729; - int _t730; - int _t731; - int _t732; - int _t733; - _t725 = (alg == JwtAlg_HS256); - if (!_t725) goto endif255; + int _t716; + int _t717; + int _t718; + int _t719; + int _t720; + int _t721; + int _t722; + int _t723; + int _t724; + _t716 = (alg == JwtAlg_HS256); + if (!_t716) goto endif242; { return "{\"alg\":\"HS256\",\"typ\":\"JWT\"}"; } - endif255:; - _t726 = (alg == JwtAlg_HS384); - if (!_t726) goto endif257; + endif242:; + _t717 = (alg == JwtAlg_HS384); + if (!_t717) goto endif244; { return "{\"alg\":\"HS384\",\"typ\":\"JWT\"}"; } - endif257:; - _t727 = (alg == JwtAlg_HS512); - if (!_t727) goto endif259; + endif244:; + _t718 = (alg == JwtAlg_HS512); + if (!_t718) goto endif246; { return "{\"alg\":\"HS512\",\"typ\":\"JWT\"}"; } - endif259:; - _t728 = (alg == JwtAlg_RS256); - if (!_t728) goto endif261; + endif246:; + _t719 = (alg == JwtAlg_RS256); + if (!_t719) goto endif248; { return "{\"alg\":\"RS256\",\"typ\":\"JWT\"}"; } - endif261:; - _t729 = (alg == JwtAlg_RS384); - if (!_t729) goto endif263; + endif248:; + _t720 = (alg == JwtAlg_RS384); + if (!_t720) goto endif250; { return "{\"alg\":\"RS384\",\"typ\":\"JWT\"}"; } - endif263:; - _t730 = (alg == JwtAlg_RS512); - if (!_t730) goto endif265; + endif250:; + _t721 = (alg == JwtAlg_RS512); + if (!_t721) goto endif252; { return "{\"alg\":\"RS512\",\"typ\":\"JWT\"}"; } - endif265:; - _t731 = (alg == JwtAlg_ES256); - if (!_t731) goto endif267; + endif252:; + _t722 = (alg == JwtAlg_ES256); + if (!_t722) goto endif254; { return "{\"alg\":\"ES256\",\"typ\":\"JWT\"}"; } - endif267:; - _t732 = (alg == JwtAlg_ES384); - if (!_t732) goto endif269; + endif254:; + _t723 = (alg == JwtAlg_ES384); + if (!_t723) goto endif256; { return "{\"alg\":\"ES384\",\"typ\":\"JWT\"}"; } - endif269:; - _t733 = (alg == JwtAlg_EdDSA); - if (!_t733) goto endif271; + endif256:; + _t724 = (alg == JwtAlg_EdDSA); + if (!_t724) goto endif258; { return "{\"alg\":\"EdDSA\",\"typ\":\"JWT\"}"; } - endif271:; + endif258:; return "{\"alg\":\"none\",\"typ\":\"JWT\"}"; } const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key) { - int _t734; - const char* _t736; - int _t738; - const char* _t740; + int _t725; + const char* _t727; + int _t729; + const char* _t731; + int _t733; + const char* _t735; + int _t737; + int _t740; int _t742; - const char* _t744; - int _t746; - int _t749; - int _t751; - int _t754; - int _t756; - int _t759; - int _t761; - int _t764; - int _t766; - int _t769; - int _t771; - _t734 = (alg == JwtAlg_HS256); - if (!_t734) goto endif273; + int _t745; + int _t747; + int _t750; + int _t752; + int _t755; + int _t757; + int _t760; + int _t762; + _t725 = (alg == JwtAlg_HS256); + if (!_t725) goto endif260; { void* buf; - void* _t735; - _t735 = Alloc(32); - buf = _t735; + void* _t726; + _t726 = Alloc(32); + buf = _t726; Hmac_Sha256Raw(key, signingInput, buf); const char* result; - _t736 = (const char*)buf; - const char* _t737; - _t737 = bux_base64_encode(_t736, 32); - result = _t737; + _t727 = (const char*)buf; + const char* _t728; + _t728 = bux_base64_encode(_t727, 32); + result = _t728; Free(buf); return result; } - endif273:; - _t738 = (alg == JwtAlg_HS384); - if (!_t738) goto endif275; + endif260:; + _t729 = (alg == JwtAlg_HS384); + if (!_t729) goto endif262; { void* buf; - void* _t739; - _t739 = Alloc(48); - buf = _t739; + void* _t730; + _t730 = Alloc(48); + buf = _t730; Hmac_Sha384Raw(key, signingInput, buf); const char* result; - _t740 = (const char*)buf; - const char* _t741; - _t741 = bux_base64_encode(_t740, 48); - result = _t741; + _t731 = (const char*)buf; + const char* _t732; + _t732 = bux_base64_encode(_t731, 48); + result = _t732; Free(buf); return result; } - endif275:; - _t742 = (alg == JwtAlg_HS512); - if (!_t742) goto endif277; + endif262:; + _t733 = (alg == JwtAlg_HS512); + if (!_t733) goto endif264; { void* buf; - void* _t743; - _t743 = Alloc(64); - buf = _t743; + void* _t734; + _t734 = Alloc(64); + buf = _t734; Hmac_Sha512Raw(key, signingInput, buf); const char* result; - _t744 = (const char*)buf; - const char* _t745; - _t745 = bux_base64_encode(_t744, 64); - result = _t745; + _t735 = (const char*)buf; + const char* _t736; + _t736 = bux_base64_encode(_t735, 64); + result = _t736; Free(buf); return result; } - endif277:; - _t746 = (alg == JwtAlg_RS256); - if (!_t746) goto endif279; + endif264:; + _t737 = (alg == JwtAlg_RS256); + if (!_t737) goto endif266; { const char* raw; - const char* _t747; - _t747 = Rsa_SignSha256(key, signingInput); - raw = _t747; - unsigned int _t748; - _t748 = String_Len(raw); - _t749 = (int)_t748; - const char* _t750; - _t750 = bux_base64_encode(raw, _t749); - return _t750; + const char* _t738; + _t738 = Rsa_SignSha256(key, signingInput); + raw = _t738; + unsigned int _t739; + _t739 = String_Len(raw); + _t740 = (int)_t739; + const char* _t741; + _t741 = bux_base64_encode(raw, _t740); + return _t741; } - endif279:; - _t751 = (alg == JwtAlg_RS384); - if (!_t751) goto endif281; + endif266:; + _t742 = (alg == JwtAlg_RS384); + if (!_t742) goto endif268; { const char* raw; - const char* _t752; - _t752 = Rsa_SignSha384(key, signingInput); - raw = _t752; - unsigned int _t753; - _t753 = String_Len(raw); - _t754 = (int)_t753; - const char* _t755; - _t755 = bux_base64_encode(raw, _t754); - return _t755; + const char* _t743; + _t743 = Rsa_SignSha384(key, signingInput); + raw = _t743; + unsigned int _t744; + _t744 = String_Len(raw); + _t745 = (int)_t744; + const char* _t746; + _t746 = bux_base64_encode(raw, _t745); + return _t746; } - endif281:; - _t756 = (alg == JwtAlg_RS512); - if (!_t756) goto endif283; + endif268:; + _t747 = (alg == JwtAlg_RS512); + if (!_t747) goto endif270; { const char* raw; - const char* _t757; - _t757 = Rsa_SignSha512(key, signingInput); - raw = _t757; - unsigned int _t758; - _t758 = String_Len(raw); - _t759 = (int)_t758; - const char* _t760; - _t760 = bux_base64_encode(raw, _t759); - return _t760; + const char* _t748; + _t748 = Rsa_SignSha512(key, signingInput); + raw = _t748; + unsigned int _t749; + _t749 = String_Len(raw); + _t750 = (int)_t749; + const char* _t751; + _t751 = bux_base64_encode(raw, _t750); + return _t751; } - endif283:; - _t761 = (alg == JwtAlg_ES256); - if (!_t761) goto endif285; + endif270:; + _t752 = (alg == JwtAlg_ES256); + if (!_t752) goto endif272; { const char* raw; - const char* _t762; - _t762 = Ecdsa_SignP256(key, signingInput); - raw = _t762; - unsigned int _t763; - _t763 = String_Len(raw); - _t764 = (int)_t763; - const char* _t765; - _t765 = bux_base64_encode(raw, _t764); - return _t765; + const char* _t753; + _t753 = Ecdsa_SignP256(key, signingInput); + raw = _t753; + unsigned int _t754; + _t754 = String_Len(raw); + _t755 = (int)_t754; + const char* _t756; + _t756 = bux_base64_encode(raw, _t755); + return _t756; } - endif285:; - _t766 = (alg == JwtAlg_ES384); - if (!_t766) goto endif287; + endif272:; + _t757 = (alg == JwtAlg_ES384); + if (!_t757) goto endif274; { const char* raw; - const char* _t767; - _t767 = Ecdsa_SignP384(key, signingInput); - raw = _t767; - unsigned int _t768; - _t768 = String_Len(raw); - _t769 = (int)_t768; - const char* _t770; - _t770 = bux_base64_encode(raw, _t769); - return _t770; + const char* _t758; + _t758 = Ecdsa_SignP384(key, signingInput); + raw = _t758; + unsigned int _t759; + _t759 = String_Len(raw); + _t760 = (int)_t759; + const char* _t761; + _t761 = bux_base64_encode(raw, _t760); + return _t761; } - endif287:; - _t771 = (alg == JwtAlg_EdDSA); - if (!_t771) goto endif289; + endif274:; + _t762 = (alg == JwtAlg_EdDSA); + if (!_t762) goto endif276; { - const char* _t772; - _t772 = Ed25519_Sign(key, signingInput); - return _t772; + const char* _t763; + _t763 = Ed25519_Sign(key, signingInput); + return _t763; } - endif289:; + endif276:; return ""; } bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key) { - int _t773; - const char* _t775; - int _t778; - const char* _t780; + int _t764; + const char* _t766; + int _t769; + const char* _t771; + int _t774; + const char* _t776; + int _t779; + int _t781; int _t783; - const char* _t785; - int _t788; - int _t790; - int _t792; - int _t794; - int _t796; - int _t798; - _t773 = (alg == JwtAlg_HS256); - if (!_t773) goto endif291; + int _t785; + int _t787; + int _t789; + _t764 = (alg == JwtAlg_HS256); + if (!_t764) goto endif278; { void* expectBuf; - void* _t774; - _t774 = Alloc(32); - expectBuf = _t774; + void* _t765; + _t765 = Alloc(32); + expectBuf = _t765; Hmac_Sha256Raw(key, signingInput, expectBuf); const char* expectB64; - _t775 = (const char*)expectBuf; - const char* _t776; - _t776 = bux_base64_encode(_t775, 32); - expectB64 = _t776; + _t766 = (const char*)expectBuf; + const char* _t767; + _t767 = bux_base64_encode(_t766, 32); + expectB64 = _t767; Free(expectBuf); - bool _t777; - _t777 = String_Eq(expectB64, signatureB64); - return _t777; + bool _t768; + _t768 = String_Eq(expectB64, signatureB64); + return _t768; } - endif291:; - _t778 = (alg == JwtAlg_HS384); - if (!_t778) goto endif293; + endif278:; + _t769 = (alg == JwtAlg_HS384); + if (!_t769) goto endif280; { void* expectBuf; - void* _t779; - _t779 = Alloc(48); - expectBuf = _t779; + void* _t770; + _t770 = Alloc(48); + expectBuf = _t770; Hmac_Sha384Raw(key, signingInput, expectBuf); const char* expectB64; - _t780 = (const char*)expectBuf; - const char* _t781; - _t781 = bux_base64_encode(_t780, 48); - expectB64 = _t781; + _t771 = (const char*)expectBuf; + const char* _t772; + _t772 = bux_base64_encode(_t771, 48); + expectB64 = _t772; Free(expectBuf); - bool _t782; - _t782 = String_Eq(expectB64, signatureB64); - return _t782; + bool _t773; + _t773 = String_Eq(expectB64, signatureB64); + return _t773; } - endif293:; - _t783 = (alg == JwtAlg_HS512); - if (!_t783) goto endif295; + endif280:; + _t774 = (alg == JwtAlg_HS512); + if (!_t774) goto endif282; { void* expectBuf; - void* _t784; - _t784 = Alloc(64); - expectBuf = _t784; + void* _t775; + _t775 = Alloc(64); + expectBuf = _t775; Hmac_Sha512Raw(key, signingInput, expectBuf); const char* expectB64; - _t785 = (const char*)expectBuf; - const char* _t786; - _t786 = bux_base64_encode(_t785, 64); - expectB64 = _t786; + _t776 = (const char*)expectBuf; + const char* _t777; + _t777 = bux_base64_encode(_t776, 64); + expectB64 = _t777; Free(expectBuf); - bool _t787; - _t787 = String_Eq(expectB64, signatureB64); - return _t787; + bool _t778; + _t778 = String_Eq(expectB64, signatureB64); + return _t778; } - endif295:; - _t788 = (alg == JwtAlg_RS256); - if (!_t788) goto endif297; + endif282:; + _t779 = (alg == JwtAlg_RS256); + if (!_t779) goto endif284; { - bool _t789; - _t789 = Rsa_VerifySha256(key, signingInput, signatureB64); - return _t789; + bool _t780; + _t780 = Rsa_VerifySha256(key, signingInput, signatureB64); + return _t780; } - endif297:; - _t790 = (alg == JwtAlg_RS384); - if (!_t790) goto endif299; + endif284:; + _t781 = (alg == JwtAlg_RS384); + if (!_t781) goto endif286; { - bool _t791; - _t791 = Rsa_VerifySha384(key, signingInput, signatureB64); - return _t791; + bool _t782; + _t782 = Rsa_VerifySha384(key, signingInput, signatureB64); + return _t782; } - endif299:; - _t792 = (alg == JwtAlg_RS512); - if (!_t792) goto endif301; + endif286:; + _t783 = (alg == JwtAlg_RS512); + if (!_t783) goto endif288; { - bool _t793; - _t793 = Rsa_VerifySha512(key, signingInput, signatureB64); - return _t793; + bool _t784; + _t784 = Rsa_VerifySha512(key, signingInput, signatureB64); + return _t784; } - endif301:; - _t794 = (alg == JwtAlg_ES256); - if (!_t794) goto endif303; + endif288:; + _t785 = (alg == JwtAlg_ES256); + if (!_t785) goto endif290; { - bool _t795; - _t795 = Ecdsa_VerifyP256(key, signingInput, signatureB64); - return _t795; + bool _t786; + _t786 = Ecdsa_VerifyP256(key, signingInput, signatureB64); + return _t786; } - endif303:; - _t796 = (alg == JwtAlg_ES384); - if (!_t796) goto endif305; + endif290:; + _t787 = (alg == JwtAlg_ES384); + if (!_t787) goto endif292; { - bool _t797; - _t797 = Ecdsa_VerifyP384(key, signingInput, signatureB64); - return _t797; + bool _t788; + _t788 = Ecdsa_VerifyP384(key, signingInput, signatureB64); + return _t788; } - endif305:; - _t798 = (alg == JwtAlg_EdDSA); - if (!_t798) goto endif307; + endif292:; + _t789 = (alg == JwtAlg_EdDSA); + if (!_t789) goto endif294; { - bool _t799; - _t799 = Ed25519_Verify(key, signatureB64, signingInput); - return _t799; + bool _t790; + _t790 = Ed25519_Verify(key, signatureB64, signingInput); + return _t790; } - endif307:; + endif294:; return 0; } const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key) { const char* headerB64; - const char* _t800; - _t800 = Base64URL_Encode(headerJson); - headerB64 = _t800; + const char* _t791; + _t791 = Base64URL_Encode(headerJson); + headerB64 = _t791; const char* payloadB64; - const char* _t801; - _t801 = Base64URL_Encode(payloadJson); - payloadB64 = _t801; + const char* _t792; + _t792 = Base64URL_Encode(payloadJson); + payloadB64 = _t792; const char* signingInput; - const char* _t802; - _t802 = String_Concat(headerB64, "."); - signingInput = _t802; + const char* _t793; + _t793 = String_Concat(headerB64, "."); + signingInput = _t793; const char* signingInputFull; - const char* _t803; - _t803 = String_Concat(signingInput, payloadB64); - signingInputFull = _t803; + const char* _t794; + _t794 = String_Concat(signingInput, payloadB64); + signingInputFull = _t794; const char* sigB64; - const char* _t804; - _t804 = Jwt_Sign(alg, signingInputFull, key); - sigB64 = _t804; + const char* _t795; + _t795 = Jwt_Sign(alg, signingInputFull, key); + sigB64 = _t795; const char* part1; - const char* _t805; - _t805 = String_Concat(signingInputFull, "."); - part1 = _t805; - const char* _t806; - _t806 = String_Concat(part1, sigB64); - return _t806; + const char* _t796; + _t796 = String_Concat(signingInputFull, "."); + part1 = _t796; + const char* _t797; + _t797 = String_Concat(part1, sigB64); + return _t797; } bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut) { - int _t808; - int _t815; + int _t799; + int _t806; unsigned int partCount; - unsigned int _t807; - _t807 = bux_str_split_count(token, "."); - partCount = _t807; - _t808 = (partCount != 3); - if (!_t808) goto endif309; + unsigned int _t798; + _t798 = bux_str_split_count(token, "."); + partCount = _t798; + _t799 = (partCount != 3); + if (!_t799) goto endif296; { return 0; } - endif309:; + endif296:; const char* headerB64; - const char* _t809; - _t809 = bux_str_split_part(token, ".", 0); - headerB64 = _t809; + const char* _t800; + _t800 = bux_str_split_part(token, ".", 0); + headerB64 = _t800; const char* payloadB64; - const char* _t810; - _t810 = bux_str_split_part(token, ".", 1); - payloadB64 = _t810; + const char* _t801; + _t801 = bux_str_split_part(token, ".", 1); + payloadB64 = _t801; const char* sigB64; - const char* _t811; - _t811 = bux_str_split_part(token, ".", 2); - sigB64 = _t811; + const char* _t802; + _t802 = bux_str_split_part(token, ".", 2); + sigB64 = _t802; const char* input; - const char* _t812; - _t812 = String_Concat(headerB64, "."); - input = _t812; + const char* _t803; + _t803 = String_Concat(headerB64, "."); + input = _t803; const char* signingInput; - const char* _t813; - _t813 = String_Concat(input, payloadB64); - signingInput = _t813; - bool _t814; - _t814 = Jwt_Verify(alg, signingInput, sigB64, key); - _t815 = !_t814; - if (!_t815) goto endif311; + const char* _t804; + _t804 = String_Concat(input, payloadB64); + signingInput = _t804; + bool _t805; + _t805 = Jwt_Verify(alg, signingInput, sigB64, key); + _t806 = !_t805; + if (!_t806) goto endif298; { return 0; } - endif311:; - const char* _t816; - _t816 = Base64URL_Decode(headerB64); - headerOut[0] = _t816; - const char* _t817; - _t817 = Base64URL_Decode(payloadB64); - payloadOut[0] = _t817; + endif298:; + const char* _t807; + _t807 = Base64URL_Decode(headerB64); + headerOut[0] = _t807; + const char* _t808; + _t808 = Base64URL_Decode(payloadB64); + payloadOut[0] = _t808; return 1; } const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret) { const char* header; - const char* _t818; - _t818 = Jwt_MakeHeader(JwtAlg_HS256); - header = _t818; - const char* _t819; - _t819 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); - return _t819; + const char* _t809; + _t809 = Jwt_MakeHeader(JwtAlg_HS256); + header = _t809; + const char* _t810; + _t810 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); + return _t810; } const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret) { const char* header; - const char* _t820; - _t820 = Jwt_MakeHeader(JwtAlg_HS384); - header = _t820; - const char* _t821; - _t821 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); - return _t821; + const char* _t811; + _t811 = Jwt_MakeHeader(JwtAlg_HS384); + header = _t811; + const char* _t812; + _t812 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); + return _t812; } const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret) { const char* header; - const char* _t822; - _t822 = Jwt_MakeHeader(JwtAlg_HS512); - header = _t822; - const char* _t823; - _t823 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); - return _t823; + const char* _t813; + _t813 = Jwt_MakeHeader(JwtAlg_HS512); + header = _t813; + const char* _t814; + _t814 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); + return _t814; } const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t824; - _t824 = Jwt_MakeHeader(JwtAlg_RS256); - header = _t824; - const char* _t825; - _t825 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); - return _t825; + const char* _t815; + _t815 = Jwt_MakeHeader(JwtAlg_RS256); + header = _t815; + const char* _t816; + _t816 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); + return _t816; } const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t826; - _t826 = Jwt_MakeHeader(JwtAlg_ES256); - header = _t826; - const char* _t827; - _t827 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); - return _t827; + const char* _t817; + _t817 = Jwt_MakeHeader(JwtAlg_ES256); + header = _t817; + const char* _t818; + _t818 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); + return _t818; } const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey) { const char* header; - const char* _t828; - _t828 = Jwt_MakeHeader(JwtAlg_EdDSA); - header = _t828; - const char* _t829; - _t829 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); - return _t829; + const char* _t819; + _t819 = Jwt_MakeHeader(JwtAlg_EdDSA); + header = _t819; + const char* _t820; + _t820 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); + return _t820; } const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data) { - int _t831; - int _t833; - void* _t834; + int _t822; + int _t824; + void* _t825; int siglen; siglen = 0; - unsigned int _t830; - _t830 = String_Len(pemPrivateKey); - _t831 = (int)_t830; - unsigned int _t832; - _t832 = String_Len(data); - _t833 = (int)_t832; - _t834 = &siglen; - const char* _t835; - _t835 = bux_ecdsa_sign_p256(pemPrivateKey, _t831, data, _t833, _t834); - return _t835; + unsigned int _t821; + _t821 = String_Len(pemPrivateKey); + _t822 = (int)_t821; + unsigned int _t823; + _t823 = String_Len(data); + _t824 = (int)_t823; + _t825 = &siglen; + const char* _t826; + _t826 = bux_ecdsa_sign_p256(pemPrivateKey, _t822, data, _t824, _t825); + return _t826; } const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data) { - int _t838; + int _t829; const char* raw; - const char* _t836; - _t836 = Ecdsa_SignP256(pemPrivateKey, data); - raw = _t836; - unsigned int _t837; - _t837 = String_Len(raw); - _t838 = (int)_t837; - const char* _t839; - _t839 = bux_base64_encode(raw, _t838); - return _t839; + const char* _t827; + _t827 = Ecdsa_SignP256(pemPrivateKey, data); + raw = _t827; + unsigned int _t828; + _t828 = String_Len(raw); + _t829 = (int)_t828; + const char* _t830; + _t830 = bux_base64_encode(raw, _t829); + return _t830; } bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature) { - int _t841; - int _t843; - int _t845; - int _t847; + int _t832; + int _t834; + int _t836; + int _t838; int r; - unsigned int _t840; - _t840 = String_Len(pemPublicKey); - _t841 = (int)_t840; - unsigned int _t842; - _t842 = String_Len(data); - _t843 = (int)_t842; - unsigned int _t844; - _t844 = String_Len(signature); - _t845 = (int)_t844; - int _t846; - _t846 = bux_ecdsa_verify_p256(pemPublicKey, _t841, data, _t843, signature, _t845); - r = _t846; - _t847 = (r == 1); - return _t847; + unsigned int _t831; + _t831 = String_Len(pemPublicKey); + _t832 = (int)_t831; + unsigned int _t833; + _t833 = String_Len(data); + _t834 = (int)_t833; + unsigned int _t835; + _t835 = String_Len(signature); + _t836 = (int)_t835; + int _t837; + _t837 = bux_ecdsa_verify_p256(pemPublicKey, _t832, data, _t834, signature, _t836); + r = _t837; + _t838 = (r == 1); + return _t838; } bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t849; - void* _t850; + int _t840; + void* _t841; int outlen; outlen = 0; const char* sig; - unsigned int _t848; - _t848 = String_Len(signatureB64); - _t849 = (int)_t848; - _t850 = &outlen; - const char* _t851; - _t851 = bux_base64_decode(signatureB64, _t849, _t850); - sig = _t851; - bool _t852; - _t852 = Ecdsa_VerifyP256(pemPublicKey, data, sig); - return _t852; + unsigned int _t839; + _t839 = String_Len(signatureB64); + _t840 = (int)_t839; + _t841 = &outlen; + const char* _t842; + _t842 = bux_base64_decode(signatureB64, _t840, _t841); + sig = _t842; + bool _t843; + _t843 = Ecdsa_VerifyP256(pemPublicKey, data, sig); + return _t843; } const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data) { - int _t854; - int _t856; - void* _t857; + int _t845; + int _t847; + void* _t848; int siglen; siglen = 0; - unsigned int _t853; - _t853 = String_Len(pemPrivateKey); - _t854 = (int)_t853; - unsigned int _t855; - _t855 = String_Len(data); - _t856 = (int)_t855; - _t857 = &siglen; - const char* _t858; - _t858 = bux_ecdsa_sign_p384(pemPrivateKey, _t854, data, _t856, _t857); - return _t858; + unsigned int _t844; + _t844 = String_Len(pemPrivateKey); + _t845 = (int)_t844; + unsigned int _t846; + _t846 = String_Len(data); + _t847 = (int)_t846; + _t848 = &siglen; + const char* _t849; + _t849 = bux_ecdsa_sign_p384(pemPrivateKey, _t845, data, _t847, _t848); + return _t849; } const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data) { - int _t861; + int _t852; const char* raw; - const char* _t859; - _t859 = Ecdsa_SignP384(pemPrivateKey, data); - raw = _t859; - unsigned int _t860; - _t860 = String_Len(raw); - _t861 = (int)_t860; - const char* _t862; - _t862 = bux_base64_encode(raw, _t861); - return _t862; + const char* _t850; + _t850 = Ecdsa_SignP384(pemPrivateKey, data); + raw = _t850; + unsigned int _t851; + _t851 = String_Len(raw); + _t852 = (int)_t851; + const char* _t853; + _t853 = bux_base64_encode(raw, _t852); + return _t853; } bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature) { - int _t864; - int _t866; - int _t868; - int _t870; + int _t855; + int _t857; + int _t859; + int _t861; int r; - unsigned int _t863; - _t863 = String_Len(pemPublicKey); - _t864 = (int)_t863; - unsigned int _t865; - _t865 = String_Len(data); - _t866 = (int)_t865; - unsigned int _t867; - _t867 = String_Len(signature); - _t868 = (int)_t867; - int _t869; - _t869 = bux_ecdsa_verify_p384(pemPublicKey, _t864, data, _t866, signature, _t868); - r = _t869; - _t870 = (r == 1); - return _t870; + unsigned int _t854; + _t854 = String_Len(pemPublicKey); + _t855 = (int)_t854; + unsigned int _t856; + _t856 = String_Len(data); + _t857 = (int)_t856; + unsigned int _t858; + _t858 = String_Len(signature); + _t859 = (int)_t858; + int _t860; + _t860 = bux_ecdsa_verify_p384(pemPublicKey, _t855, data, _t857, signature, _t859); + r = _t860; + _t861 = (r == 1); + return _t861; } bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t872; - void* _t873; + int _t863; + void* _t864; int outlen; outlen = 0; const char* sig; - unsigned int _t871; - _t871 = String_Len(signatureB64); - _t872 = (int)_t871; - _t873 = &outlen; - const char* _t874; - _t874 = bux_base64_decode(signatureB64, _t872, _t873); - sig = _t874; - bool _t875; - _t875 = Ecdsa_VerifyP384(pemPublicKey, data, sig); - return _t875; + unsigned int _t862; + _t862 = String_Len(signatureB64); + _t863 = (int)_t862; + _t864 = &outlen; + const char* _t865; + _t865 = bux_base64_decode(signatureB64, _t863, _t864); + sig = _t865; + bool _t866; + _t866 = Ecdsa_VerifyP384(pemPublicKey, data, sig); + return _t866; } bool Ed25519_Keypair(void* pubKey, void* privKey) { - int _t877; + int _t868; int r; - int _t876; - _t876 = bux_ed25519_keypair(pubKey, privKey); - r = _t876; - _t877 = (r == 1); - return _t877; + int _t867; + _t867 = bux_ed25519_keypair(pubKey, privKey); + r = _t867; + _t868 = (r == 1); + return _t868; } const char* Ed25519_KeypairBase64(void) { - unsigned int _t878; - unsigned int _t880; - int _t883; - const char* _t884; - const char* _t886; + unsigned int _t869; + unsigned int _t871; + int _t874; + const char* _t875; + const char* _t877; void* pubBuf; - _t878 = (unsigned int)ED25519_PUBKEY_SIZE; - void* _t879; - _t879 = Alloc(_t878); - pubBuf = _t879; + _t869 = (unsigned int)ED25519_PUBKEY_SIZE; + void* _t870; + _t870 = Alloc(_t869); + pubBuf = _t870; void* priv; - _t880 = (unsigned int)ED25519_PRIVKEY_SIZE; - void* _t881; - _t881 = Alloc(_t880); - priv = _t881; - int _t882; - _t882 = bux_ed25519_keypair(pubBuf, priv); - _t883 = (_t882 != 1); - if (!_t883) goto endif313; + _t871 = (unsigned int)ED25519_PRIVKEY_SIZE; + void* _t872; + _t872 = Alloc(_t871); + priv = _t872; + int _t873; + _t873 = bux_ed25519_keypair(pubBuf, priv); + _t874 = (_t873 != 1); + if (!_t874) goto endif300; { Free(pubBuf); Free(priv); return ""; } - endif313:; + endif300:; const char* pubB64; - _t884 = (const char*)pubBuf; - const char* _t885; - _t885 = bux_base64_encode(_t884, ED25519_PUBKEY_SIZE); - pubB64 = _t885; + _t875 = (const char*)pubBuf; + const char* _t876; + _t876 = bux_base64_encode(_t875, ED25519_PUBKEY_SIZE); + pubB64 = _t876; const char* privB64; - _t886 = (const char*)priv; - const char* _t887; - _t887 = bux_base64_encode(_t886, ED25519_PRIVKEY_SIZE); - privB64 = _t887; + _t877 = (const char*)priv; + const char* _t878; + _t878 = bux_base64_encode(_t877, ED25519_PRIVKEY_SIZE); + privB64 = _t878; Free(pubBuf); Free(priv); const char* pair; - const char* _t888; - _t888 = String_Concat(pubB64, ":"); - pair = _t888; - const char* _t889; - _t889 = String_Concat(pair, privB64); - return _t889; + const char* _t879; + _t879 = String_Concat(pubB64, ":"); + pair = _t879; + const char* _t880; + _t880 = String_Concat(pair, privB64); + return _t880; } const char* Ed25519_Sign(const char* privKey, const char* data) { - unsigned int _t890; - int _t893; - int _t895; - const char* _t896; + unsigned int _t881; + int _t884; + int _t886; + const char* _t887; void* sig; - _t890 = (unsigned int)ED25519_SIG_SIZE; - void* _t891; - _t891 = Alloc(_t890); - sig = _t891; - unsigned int _t892; - _t892 = String_Len(data); - _t893 = (int)_t892; - int _t894; - _t894 = bux_ed25519_sign(privKey, data, _t893, sig); - _t895 = (_t894 != 1); - if (!_t895) goto endif315; + _t881 = (unsigned int)ED25519_SIG_SIZE; + void* _t882; + _t882 = Alloc(_t881); + sig = _t882; + unsigned int _t883; + _t883 = String_Len(data); + _t884 = (int)_t883; + int _t885; + _t885 = bux_ed25519_sign(privKey, data, _t884, sig); + _t886 = (_t885 != 1); + if (!_t886) goto endif302; { Free(sig); return ""; } - endif315:; - _t896 = (const char*)sig; - return _t896; + endif302:; + _t887 = (const char*)sig; + return _t887; } const char* Ed25519_SignBase64(const char* privKey, const char* data) { - int _t899; + int _t890; const char* sig; - const char* _t897; - _t897 = Ed25519_Sign(privKey, data); - sig = _t897; - unsigned int _t898; - _t898 = String_Len(sig); - _t899 = (_t898 == 0); - if (!_t899) goto endif317; + const char* _t888; + _t888 = Ed25519_Sign(privKey, data); + sig = _t888; + unsigned int _t889; + _t889 = String_Len(sig); + _t890 = (_t889 == 0); + if (!_t890) goto endif304; { return ""; } - endif317:; - const char* _t900; - _t900 = bux_base64_encode(sig, ED25519_SIG_SIZE); - return _t900; + endif304:; + const char* _t891; + _t891 = bux_base64_encode(sig, ED25519_SIG_SIZE); + return _t891; } bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data) { - int _t902; - int _t904; + int _t893; + int _t895; int r; - unsigned int _t901; - _t901 = String_Len(data); - _t902 = (int)_t901; - int _t903; - _t903 = bux_ed25519_verify(pubKey, signature, data, _t902); - r = _t903; - _t904 = (r == 1); - return _t904; + unsigned int _t892; + _t892 = String_Len(data); + _t893 = (int)_t892; + int _t894; + _t894 = bux_ed25519_verify(pubKey, signature, data, _t893); + r = _t894; + _t895 = (r == 1); + return _t895; } bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data) { - int _t906; - void* _t907; - int _t909; + int _t897; + void* _t898; + int _t900; int outlen; outlen = 0; const char* sig; - unsigned int _t905; - _t905 = String_Len(signatureB64); - _t906 = (int)_t905; - _t907 = &outlen; - const char* _t908; - _t908 = bux_base64_decode(signatureB64, _t906, _t907); - sig = _t908; - _t909 = (outlen != ED25519_SIG_SIZE); - if (!_t909) goto endif319; + unsigned int _t896; + _t896 = String_Len(signatureB64); + _t897 = (int)_t896; + _t898 = &outlen; + const char* _t899; + _t899 = bux_base64_decode(signatureB64, _t897, _t898); + sig = _t899; + _t900 = (outlen != ED25519_SIG_SIZE); + if (!_t900) goto endif306; { return 0; } - endif319:; - bool _t910; - _t910 = Ed25519_Verify(pubKey, sig, data); - return _t910; + endif306:; + bool _t901; + _t901 = Ed25519_Verify(pubKey, sig, data); + return _t901; } const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data) { - int _t912; - int _t914; - void* _t915; + int _t903; + int _t905; + void* _t906; int siglen; siglen = 0; - unsigned int _t911; - _t911 = String_Len(pemPrivateKey); - _t912 = (int)_t911; - unsigned int _t913; - _t913 = String_Len(data); - _t914 = (int)_t913; - _t915 = &siglen; - const char* _t916; - _t916 = bux_rsa_sign_sha256(pemPrivateKey, _t912, data, _t914, _t915); - return _t916; + unsigned int _t902; + _t902 = String_Len(pemPrivateKey); + _t903 = (int)_t902; + unsigned int _t904; + _t904 = String_Len(data); + _t905 = (int)_t904; + _t906 = &siglen; + const char* _t907; + _t907 = bux_rsa_sign_sha256(pemPrivateKey, _t903, data, _t905, _t906); + return _t907; } const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data) { - int _t918; - int _t920; - void* _t921; + int _t909; + int _t911; + void* _t912; int siglen; siglen = 0; - unsigned int _t917; - _t917 = String_Len(pemPrivateKey); - _t918 = (int)_t917; - unsigned int _t919; - _t919 = String_Len(data); - _t920 = (int)_t919; - _t921 = &siglen; - const char* _t922; - _t922 = bux_rsa_sign_sha384(pemPrivateKey, _t918, data, _t920, _t921); - return _t922; + unsigned int _t908; + _t908 = String_Len(pemPrivateKey); + _t909 = (int)_t908; + unsigned int _t910; + _t910 = String_Len(data); + _t911 = (int)_t910; + _t912 = &siglen; + const char* _t913; + _t913 = bux_rsa_sign_sha384(pemPrivateKey, _t909, data, _t911, _t912); + return _t913; } const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data) { - int _t924; - int _t926; - void* _t927; + int _t915; + int _t917; + void* _t918; int siglen; siglen = 0; - unsigned int _t923; - _t923 = String_Len(pemPrivateKey); - _t924 = (int)_t923; - unsigned int _t925; - _t925 = String_Len(data); - _t926 = (int)_t925; - _t927 = &siglen; - const char* _t928; - _t928 = bux_rsa_sign_sha512(pemPrivateKey, _t924, data, _t926, _t927); - return _t928; + unsigned int _t914; + _t914 = String_Len(pemPrivateKey); + _t915 = (int)_t914; + unsigned int _t916; + _t916 = String_Len(data); + _t917 = (int)_t916; + _t918 = &siglen; + const char* _t919; + _t919 = bux_rsa_sign_sha512(pemPrivateKey, _t915, data, _t917, _t918); + return _t919; } const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data) { - int _t931; + int _t922; const char* raw; - const char* _t929; - _t929 = Rsa_SignSha256(pemPrivateKey, data); - raw = _t929; - unsigned int _t930; - _t930 = String_Len(raw); - _t931 = (int)_t930; - const char* _t932; - _t932 = bux_base64_encode(raw, _t931); - return _t932; + const char* _t920; + _t920 = Rsa_SignSha256(pemPrivateKey, data); + raw = _t920; + unsigned int _t921; + _t921 = String_Len(raw); + _t922 = (int)_t921; + const char* _t923; + _t923 = bux_base64_encode(raw, _t922); + return _t923; } const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data) { - int _t935; + int _t926; const char* raw; - const char* _t933; - _t933 = Rsa_SignSha384(pemPrivateKey, data); - raw = _t933; - unsigned int _t934; - _t934 = String_Len(raw); - _t935 = (int)_t934; - const char* _t936; - _t936 = bux_base64_encode(raw, _t935); - return _t936; + const char* _t924; + _t924 = Rsa_SignSha384(pemPrivateKey, data); + raw = _t924; + unsigned int _t925; + _t925 = String_Len(raw); + _t926 = (int)_t925; + const char* _t927; + _t927 = bux_base64_encode(raw, _t926); + return _t927; } const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data) { - int _t939; + int _t930; const char* raw; - const char* _t937; - _t937 = Rsa_SignSha512(pemPrivateKey, data); - raw = _t937; - unsigned int _t938; - _t938 = String_Len(raw); - _t939 = (int)_t938; - const char* _t940; - _t940 = bux_base64_encode(raw, _t939); - return _t940; + const char* _t928; + _t928 = Rsa_SignSha512(pemPrivateKey, data); + raw = _t928; + unsigned int _t929; + _t929 = String_Len(raw); + _t930 = (int)_t929; + const char* _t931; + _t931 = bux_base64_encode(raw, _t930); + return _t931; } bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature) { - int _t942; - int _t944; - int _t946; - int _t948; + int _t933; + int _t935; + int _t937; + int _t939; int r; - unsigned int _t941; - _t941 = String_Len(pemPublicKey); - _t942 = (int)_t941; - unsigned int _t943; - _t943 = String_Len(data); - _t944 = (int)_t943; - unsigned int _t945; - _t945 = String_Len(signature); - _t946 = (int)_t945; - int _t947; - _t947 = bux_rsa_verify_sha256(pemPublicKey, _t942, data, _t944, signature, _t946); - r = _t947; - _t948 = (r == 1); - return _t948; + unsigned int _t932; + _t932 = String_Len(pemPublicKey); + _t933 = (int)_t932; + unsigned int _t934; + _t934 = String_Len(data); + _t935 = (int)_t934; + unsigned int _t936; + _t936 = String_Len(signature); + _t937 = (int)_t936; + int _t938; + _t938 = bux_rsa_verify_sha256(pemPublicKey, _t933, data, _t935, signature, _t937); + r = _t938; + _t939 = (r == 1); + return _t939; } bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature) { - int _t950; - int _t952; - int _t954; - int _t956; + int _t941; + int _t943; + int _t945; + int _t947; int r; - unsigned int _t949; - _t949 = String_Len(pemPublicKey); - _t950 = (int)_t949; - unsigned int _t951; - _t951 = String_Len(data); - _t952 = (int)_t951; - unsigned int _t953; - _t953 = String_Len(signature); - _t954 = (int)_t953; - int _t955; - _t955 = bux_rsa_verify_sha384(pemPublicKey, _t950, data, _t952, signature, _t954); - r = _t955; - _t956 = (r == 1); - return _t956; + unsigned int _t940; + _t940 = String_Len(pemPublicKey); + _t941 = (int)_t940; + unsigned int _t942; + _t942 = String_Len(data); + _t943 = (int)_t942; + unsigned int _t944; + _t944 = String_Len(signature); + _t945 = (int)_t944; + int _t946; + _t946 = bux_rsa_verify_sha384(pemPublicKey, _t941, data, _t943, signature, _t945); + r = _t946; + _t947 = (r == 1); + return _t947; } bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature) { - int _t958; - int _t960; - int _t962; - int _t964; + int _t949; + int _t951; + int _t953; + int _t955; int r; - unsigned int _t957; - _t957 = String_Len(pemPublicKey); - _t958 = (int)_t957; - unsigned int _t959; - _t959 = String_Len(data); - _t960 = (int)_t959; - unsigned int _t961; - _t961 = String_Len(signature); - _t962 = (int)_t961; - int _t963; - _t963 = bux_rsa_verify_sha512(pemPublicKey, _t958, data, _t960, signature, _t962); - r = _t963; - _t964 = (r == 1); - return _t964; + unsigned int _t948; + _t948 = String_Len(pemPublicKey); + _t949 = (int)_t948; + unsigned int _t950; + _t950 = String_Len(data); + _t951 = (int)_t950; + unsigned int _t952; + _t952 = String_Len(signature); + _t953 = (int)_t952; + int _t954; + _t954 = bux_rsa_verify_sha512(pemPublicKey, _t949, data, _t951, signature, _t953); + r = _t954; + _t955 = (r == 1); + return _t955; } bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t966; - void* _t967; + int _t957; + void* _t958; int outlen; outlen = 0; const char* sig; - unsigned int _t965; - _t965 = String_Len(signatureB64); - _t966 = (int)_t965; - _t967 = &outlen; - const char* _t968; - _t968 = bux_base64_decode(signatureB64, _t966, _t967); - sig = _t968; - bool _t969; - _t969 = Rsa_VerifySha256(pemPublicKey, data, sig); - return _t969; + unsigned int _t956; + _t956 = String_Len(signatureB64); + _t957 = (int)_t956; + _t958 = &outlen; + const char* _t959; + _t959 = bux_base64_decode(signatureB64, _t957, _t958); + sig = _t959; + bool _t960; + _t960 = Rsa_VerifySha256(pemPublicKey, data, sig); + return _t960; } bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t971; - void* _t972; + int _t962; + void* _t963; int outlen; outlen = 0; const char* sig; - unsigned int _t970; - _t970 = String_Len(signatureB64); - _t971 = (int)_t970; - _t972 = &outlen; - const char* _t973; - _t973 = bux_base64_decode(signatureB64, _t971, _t972); - sig = _t973; - bool _t974; - _t974 = Rsa_VerifySha384(pemPublicKey, data, sig); - return _t974; + unsigned int _t961; + _t961 = String_Len(signatureB64); + _t962 = (int)_t961; + _t963 = &outlen; + const char* _t964; + _t964 = bux_base64_decode(signatureB64, _t962, _t963); + sig = _t964; + bool _t965; + _t965 = Rsa_VerifySha384(pemPublicKey, data, sig); + return _t965; } bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t976; - void* _t977; + int _t967; + void* _t968; int outlen; outlen = 0; const char* sig; - unsigned int _t975; - _t975 = String_Len(signatureB64); - _t976 = (int)_t975; - _t977 = &outlen; - const char* _t978; - _t978 = bux_base64_decode(signatureB64, _t976, _t977); - sig = _t978; - bool _t979; - _t979 = Rsa_VerifySha512(pemPublicKey, data, sig); - return _t979; + unsigned int _t966; + _t966 = String_Len(signatureB64); + _t967 = (int)_t966; + _t968 = &outlen; + const char* _t969; + _t969 = bux_base64_decode(signatureB64, _t967, _t968); + sig = _t969; + bool _t970; + _t970 = Rsa_VerifySha512(pemPublicKey, data, sig); + return _t970; } int Fibonacci(int n) { - int _t980; - int _t981; - int _t983; - int _t985; - _t980 = (n <= 1); - if (!_t980) goto endif321; + int _t971; + int _t972; + int _t974; + int _t976; + _t971 = (n <= 1); + if (!_t971) goto endif308; { return n; } - endif321:; - _t981 = n - 1; - int _t982; - _t982 = Fibonacci(_t981); - _t983 = n - 2; - int _t984; - _t984 = Fibonacci(_t983); - _t985 = _t982 + _t984; - return _t985; + endif308:; + _t972 = n - 1; + int _t973; + _t973 = Fibonacci(_t972); + _t974 = n - 2; + int _t975; + _t975 = Fibonacci(_t974); + _t976 = _t973 + _t975; + return _t976; } int Main(void) { - int _t986; - int _t990; + int _t977; + int _t981; PrintLine("Fibonacci sequence:"); int i; i = 0; - while322:; - _t986 = (i < 10); - if (!_t986) goto wend324; + while309:; + _t977 = (i < 10); + if (!_t977) goto wend310; { int fib; - int _t987; - _t987 = Fibonacci(i); - fib = _t987; - const char* _t988; - _t988 = String_FromInt(fib); - const char* _t989; - _t989 = Fmt_Fmt1("{0}", _t988); - PrintLine(_t989); - _t990 = i + 1; - i = _t990; + int _t978; + _t978 = Fibonacci(i); + fib = _t978; + const char* _t979; + _t979 = String_FromInt(fib); + const char* _t980; + _t980 = Fmt_Fmt1("{0}", _t979); + PrintLine(_t980); + _t981 = i + 1; + i = _t981; } - goto while322; - wend324:; + goto while309; + wend310:; return 0; } diff --git a/tests/golden/generics/expected.c b/tests/golden/generics/expected.c index 042d303..e6a7146 100644 --- a/tests/golden/generics/expected.c +++ b/tests/golden/generics/expected.c @@ -198,6 +198,34 @@ extern const char* bux_base64_decode(const char* data, int len, int* outlen); #define ED25519_PRIVKEY_SIZE 32 #define ED25519_SIG_SIZE 64 +typedef struct Channel_float64 { + void* handle; +} Channel_float64; + +typedef struct TaskHandle { + void* handle; +} TaskHandle; + +typedef struct RwLock { + void* handle; +} RwLock; + +typedef struct Channel_int { + void* handle; +} Channel_int; + +typedef enum { + JwtAlg_HS256, + JwtAlg_HS384, + JwtAlg_HS512, + JwtAlg_RS256, + JwtAlg_RS384, + JwtAlg_RS512, + JwtAlg_ES256, + JwtAlg_ES384, + JwtAlg_EdDSA +} JwtAlg; + typedef enum { Result_Ok, Result_Err @@ -227,31 +255,6 @@ typedef struct { Option_Data data; } Option; -typedef enum { - JwtAlg_HS256, - JwtAlg_HS384, - JwtAlg_HS512, - JwtAlg_RS256, - JwtAlg_RS384, - JwtAlg_RS512, - JwtAlg_ES256, - JwtAlg_ES384, - JwtAlg_EdDSA -} JwtAlg; - - -typedef struct TaskHandle { - void* handle; -} TaskHandle; - -typedef struct Mutex { - void* handle; -} Mutex; - -typedef struct RwLock { - void* handle; -} RwLock; - typedef struct JsonValue { int tag; bool boolVal; @@ -266,6 +269,14 @@ typedef struct JsonValue { unsigned int objCap; } JsonValue; +typedef struct Mutex { + void* handle; +} Mutex; + +typedef struct StringBuilder { + void* handle; +} StringBuilder; + typedef struct JsonParser { const char* src; unsigned int pos; @@ -273,18 +284,6 @@ typedef struct JsonParser { const char* error; } JsonParser; -typedef struct StringBuilder { - void* handle; -} StringBuilder; - -typedef struct Channel_int { - void* handle; -} Channel_int; - -typedef struct Channel_float64 { - void* handle; -} Channel_float64; - bool DirExists(const char* path); bool Mkdir(const char* path); const char** ListDir(const char* dir, const char* ext, int* count); @@ -860,7 +859,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { tmplLen = _t59; while1:; _t60 = (i < tmplLen); - if (!_t60) goto wend3; + if (!_t60) goto wend2; { const char* ch; const char* _t61; @@ -868,13 +867,13 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { ch = _t61; bool _t62; _t62 = String_Eq(ch, "{"); - if (!_t62) goto endif5; + if (!_t62) goto endif4; { unsigned int digitIdx; _t63 = i + 1; digitIdx = _t63; _t64 = (digitIdx < tmplLen); - if (!_t64) goto endif7; + if (!_t64) goto endif6; { const char* digitCh; const char* _t65; @@ -886,22 +885,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { d = _t66; bool __and_tmp_0; _t67 = (d >= 0); - if (!_t67) goto else8; + if (!_t67) goto else7; _t68 = (int64_t)argCount; _t69 = (d < _t68); *(bool*)&__and_tmp_0 = _t69; - goto endif9; - else8:; + goto endif8; + else7:; *(bool*)&__and_tmp_0 = 0; - endif9:; + endif8:; bool _t70; _t70 = *(bool*)&__and_tmp_0; - if (!_t70) goto endif11; + if (!_t70) goto endif10; { _t71 = i + 2; i = _t71; _t72 = (i < tmplLen); - if (!_t72) goto endif13; + if (!_t72) goto endif12; { const char* closeCh; const char* _t73; @@ -909,7 +908,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { closeCh = _t73; bool _t74; _t74 = String_Eq(closeCh, "}"); - if (!_t74) goto endif15; + if (!_t74) goto endif14; { _t75 = i + 1; i = _t75; @@ -922,22 +921,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { StringBuilder_Append(_t78, argStr); goto while1; } - endif15:; + endif14:; } - endif13:; + endif12:; } - endif11:; + endif10:; } - endif7:; + endif6:; } - endif5:; + endif4:; _t79 = &sb; StringBuilder_Append(_t79, ch); _t80 = i + 1; i = _t80; } goto while1; - wend3:; + wend2:; _t81 = &sb; const char* _t82; _t82 = StringBuilder_Build(_t81); @@ -945,276 +944,276 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { } const char* Fmt_Fmt1(const char* tmpl, const char* a1) { - const char** _t85; + const char** _t84; const char** args; /* sizeof(const char*) */ - void* _t84; - _t84 = bux_alloc(sizeof(const char*)); - _t85 = (const char**)_t84; - args = _t85; + void* _t83; + _t83 = bux_alloc(sizeof(const char*)); + _t84 = (const char**)_t83; + args = _t84; args[0] = a1; - const char* _t86; - _t86 = Fmt_Format(tmpl, args, 1); - return _t86; + const char* _t85; + _t85 = Fmt_Format(tmpl, args, 1); + return _t85; } const char* Fmt_FmtInt(const char* tmpl, int64_t val) { const char* s; + const char* _t86; + _t86 = String_FromInt(val); + s = _t86; const char* _t87; - _t87 = String_FromInt(val); - s = _t87; - const char* _t88; - _t88 = Fmt_Fmt1(tmpl, s); - return _t88; + _t87 = Fmt_Fmt1(tmpl, s); + return _t87; } const char* Fmt_FmtBool(const char* tmpl, bool val) { const char* s; + const char* _t88; + _t88 = String_FromBool(val); + s = _t88; const char* _t89; - _t89 = String_FromBool(val); - s = _t89; - const char* _t90; - _t90 = Fmt_Fmt1(tmpl, s); - return _t90; + _t89 = Fmt_Fmt1(tmpl, s); + return _t89; } const char* Fmt_FmtFloat(const char* tmpl, double val) { const char* s; + const char* _t90; + _t90 = String_FromFloat(val); + s = _t90; const char* _t91; - _t91 = String_FromFloat(val); - s = _t91; - const char* _t92; - _t92 = Fmt_Fmt1(tmpl, s); - return _t92; + _t91 = Fmt_Fmt1(tmpl, s); + return _t91; } const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2) { - int _t94; - const char** _t96; + int _t92; + const char** _t94; const char** args; /* sizeof(const char*) */ - _t94 = 2 * sizeof(const char*); - void* _t95; - _t95 = bux_alloc(_t94); - _t96 = (const char**)_t95; - args = _t96; + _t92 = 2 * sizeof(const char*); + void* _t93; + _t93 = bux_alloc(_t92); + _t94 = (const char**)_t93; + args = _t94; args[0] = a1; args[1] = a2; - const char* _t97; - _t97 = Fmt_Format(tmpl, args, 2); - return _t97; + const char* _t95; + _t95 = Fmt_Format(tmpl, args, 2); + return _t95; } const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3) { - int _t99; - const char** _t101; + int _t96; + const char** _t98; const char** args; /* sizeof(const char*) */ - _t99 = 3 * sizeof(const char*); - void* _t100; - _t100 = bux_alloc(_t99); - _t101 = (const char**)_t100; - args = _t101; + _t96 = 3 * sizeof(const char*); + void* _t97; + _t97 = bux_alloc(_t96); + _t98 = (const char**)_t97; + args = _t98; args[0] = a1; args[1] = a2; args[2] = a3; - const char* _t102; - _t102 = Fmt_Format(tmpl, args, 3); - return _t102; + const char* _t99; + _t99 = Fmt_Format(tmpl, args, 3); + return _t99; } const char* Crypto_Sha256(const char* data) { - int _t104; - void* _t106; + int _t101; + void* _t103; int len; - unsigned int _t103; - _t103 = String_Len(data); - _t104 = (int)_t103; - len = _t104; + unsigned int _t100; + _t100 = String_Len(data); + _t101 = (int)_t100; + len = _t101; void* hashBuf; - void* _t105; - _t105 = Alloc(32); - hashBuf = _t105; + void* _t102; + _t102 = Alloc(32); + hashBuf = _t102; bux_sha256(data, len, hashBuf); const char* result; - _t106 = (void*)hashBuf; - const char* _t107; - _t107 = bux_bytes_to_hex(_t106, 32); - result = _t107; + _t103 = (void*)hashBuf; + const char* _t104; + _t104 = bux_bytes_to_hex(_t103, 32); + result = _t104; Free(hashBuf); return result; } const char* Crypto_HmacSha256(const char* key, const char* message) { - int _t109; - int _t111; - void* _t113; + int _t106; + int _t108; + void* _t110; int keylen; - unsigned int _t108; - _t108 = String_Len(key); - _t109 = (int)_t108; - keylen = _t109; + unsigned int _t105; + _t105 = String_Len(key); + _t106 = (int)_t105; + keylen = _t106; int msglen; - unsigned int _t110; - _t110 = String_Len(message); - _t111 = (int)_t110; - msglen = _t111; + unsigned int _t107; + _t107 = String_Len(message); + _t108 = (int)_t107; + msglen = _t108; void* hmacBuf; - void* _t112; - _t112 = Alloc(32); - hmacBuf = _t112; + void* _t109; + _t109 = Alloc(32); + hmacBuf = _t109; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t113 = (void*)hmacBuf; - const char* _t114; - _t114 = bux_bytes_to_hex(_t113, 32); - result = _t114; + _t110 = (void*)hmacBuf; + const char* _t111; + _t111 = bux_bytes_to_hex(_t110, 32); + result = _t111; Free(hmacBuf); return result; } const char* Crypto_RandomBytes(int n) { - int _t115; - unsigned int _t116; - int _t119; - const char* _t120; - _t115 = (n <= 0); - if (!_t115) goto endif17; + int _t112; + unsigned int _t113; + int _t116; + const char* _t117; + _t112 = (n <= 0); + if (!_t112) goto endif16; { return ""; } - endif17:; + endif16:; void* buf; - _t116 = (unsigned int)n; - void* _t117; - _t117 = Alloc(_t116); - buf = _t117; - int _t118; - _t118 = bux_random_bytes(buf, n); - _t119 = (_t118 != 1); - if (!_t119) goto endif19; + _t113 = (unsigned int)n; + void* _t114; + _t114 = Alloc(_t113); + buf = _t114; + int _t115; + _t115 = bux_random_bytes(buf, n); + _t116 = (_t115 != 1); + if (!_t116) goto endif18; { Free(buf); return ""; } - endif19:; + endif18:; const char* result; - _t120 = (const char*)buf; - const char* _t121; - _t121 = bux_base64_encode(_t120, n); - result = _t121; + _t117 = (const char*)buf; + const char* _t118; + _t118 = bux_base64_encode(_t117, n); + result = _t118; Free(buf); return result; } const char* Crypto_Base64Encode(const char* s) { - int _t123; - unsigned int _t122; - _t122 = String_Len(s); - _t123 = (int)_t122; - const char* _t124; - _t124 = bux_base64_encode(s, _t123); - return _t124; + int _t120; + unsigned int _t119; + _t119 = String_Len(s); + _t120 = (int)_t119; + const char* _t121; + _t121 = bux_base64_encode(s, _t120); + return _t121; } const char* Crypto_HmacSha256Raw(const char* key, const char* message) { - int _t126; - int _t128; - const char* _t130; + int _t123; + int _t125; + const char* _t127; int keylen; - unsigned int _t125; - _t125 = String_Len(key); - _t126 = (int)_t125; - keylen = _t126; + unsigned int _t122; + _t122 = String_Len(key); + _t123 = (int)_t122; + keylen = _t123; int msglen; - unsigned int _t127; - _t127 = String_Len(message); - _t128 = (int)_t127; - msglen = _t128; + unsigned int _t124; + _t124 = String_Len(message); + _t125 = (int)_t124; + msglen = _t125; void* hmacBuf; - void* _t129; - _t129 = Alloc(32); - hmacBuf = _t129; + void* _t126; + _t126 = Alloc(32); + hmacBuf = _t126; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t130 = (const char*)hmacBuf; - const char* _t131; - _t131 = bux_base64_encode(_t130, 32); - result = _t131; + _t127 = (const char*)hmacBuf; + const char* _t128; + _t128 = bux_base64_encode(_t127, 32); + result = _t128; Free(hmacBuf); return result; } const char* Crypto_Base64Decode(const char* s) { - int _t133; - void* _t134; + int _t130; + void* _t131; int outlen; outlen = 0; - unsigned int _t132; - _t132 = String_Len(s); - _t133 = (int)_t132; - _t134 = &outlen; - const char* _t135; - _t135 = bux_base64_decode(s, _t133, _t134); - return _t135; + unsigned int _t129; + _t129 = String_Len(s); + _t130 = (int)_t129; + _t131 = &outlen; + const char* _t132; + _t132 = bux_base64_decode(s, _t130, _t131); + return _t132; } Mutex Mutex_New(void) { - Mutex _t137; - void* _t136; - _t136 = bux_mutex_new(); - _t137 = (Mutex){.handle = _t136}; - return _t137; + Mutex _t134; + void* _t133; + _t133 = bux_mutex_new(); + _t134 = (Mutex){.handle = _t133}; + return _t134; } void Mutex_Lock(Mutex* m) { - void* _t138; - _t138 = m->handle; - bux_mutex_lock(_t138); + void* _t135; + _t135 = m->handle; + bux_mutex_lock(_t135); } void Mutex_Unlock(Mutex* m) { - void* _t139; - _t139 = m->handle; - bux_mutex_unlock(_t139); + void* _t136; + _t136 = m->handle; + bux_mutex_unlock(_t136); } void Mutex_Free(Mutex* m) { - void* _t140; - _t140 = m->handle; - bux_mutex_free(_t140); + void* _t137; + _t137 = m->handle; + bux_mutex_free(_t137); } RwLock RwLock_New(void) { - RwLock _t142; - void* _t141; - _t141 = bux_rwlock_new(); - _t142 = (RwLock){.handle = _t141}; - return _t142; + RwLock _t139; + void* _t138; + _t138 = bux_rwlock_new(); + _t139 = (RwLock){.handle = _t138}; + return _t139; } void RwLock_ReadLock(RwLock* rw) { - void* _t143; - _t143 = rw->handle; - bux_rwlock_rdlock(_t143); + void* _t140; + _t140 = rw->handle; + bux_rwlock_rdlock(_t140); } void RwLock_WriteLock(RwLock* rw) { - void* _t144; - _t144 = rw->handle; - bux_rwlock_wrlock(_t144); + void* _t141; + _t141 = rw->handle; + bux_rwlock_wrlock(_t141); } void RwLock_Unlock(RwLock* rw) { - void* _t145; - _t145 = rw->handle; - bux_rwlock_unlock(_t145); + void* _t142; + _t142 = rw->handle; + bux_rwlock_unlock(_t142); } void RwLock_Free(RwLock* rw) { - void* _t146; - _t146 = rw->handle; - bux_rwlock_free(_t146); + void* _t143; + _t143 = rw->handle; + bux_rwlock_free(_t143); } void Test_Exit(int code) { @@ -1222,15 +1221,15 @@ void Test_Exit(int code) { } void Test_Assert(bool cond) { - int _t147; - _t147 = (int)cond; - bux_assert(_t147, "", 0, ""); + int _t144; + _t144 = (int)cond; + bux_assert(_t144, "", 0, ""); } void Test_AssertEqInt(int a, int b) { - int _t148; - _t148 = (a != b); - if (!_t148) goto endif21; + int _t145; + _t145 = (a != b); + if (!_t145) goto endif20; { PrintLine("ASSERT_EQ FAILED:"); PrintInt(a); @@ -1238,27 +1237,27 @@ void Test_AssertEqInt(int a, int b) { PrintInt(b); bux_exit(1); } - endif21:; + endif20:; } void Test_AssertTrue(bool cond) { - int _t149; - _t149 = !cond; - if (!_t149) goto endif23; + int _t146; + _t146 = !cond; + if (!_t146) goto endif22; { PrintLine("ASSERT_TRUE FAILED"); bux_exit(1); } - endif23:; + endif22:; } void Test_AssertFalse(bool cond) { - if (!cond) goto endif25; + if (!cond) goto endif24; { PrintLine("ASSERT_FALSE FAILED"); bux_exit(1); } - endif25:; + endif24:; } void Test_Fail(const char* msg) { @@ -1268,735 +1267,744 @@ void Test_Fail(const char* msg) { } Result Result_NewOk(int value) { - Result _t150; + Result _t147; Result r; - _t150 = (Result){.tag = Result_Ok}; - r = _t150; + _t147 = (Result){.tag = Result_Ok}; + r = _t147; r.data.Ok_0 = value; return r; } Result Result_NewErr(const char* msg) { - Result _t151; + Result _t148; Result r; - _t151 = (Result){.tag = Result_Err}; - r = _t151; + _t148 = (Result){.tag = Result_Err}; + r = _t148; r.data.Err_0 = msg; return r; } bool Result_IsOk(Result r) { - int _t153; - Result_Tag _t152; - _t152 = r.tag; - _t153 = (_t152 == Result_Ok); - return _t153; + int _t150; + Result_Tag _t149; + _t149 = r.tag; + _t150 = (_t149 == Result_Ok); + return _t150; } bool Result_IsErr(Result r) { - int _t155; - Result_Tag _t154; - _t154 = r.tag; - _t155 = (_t154 == Result_Err); - return _t155; + int _t152; + Result_Tag _t151; + _t151 = r.tag; + _t152 = (_t151 == Result_Err); + return _t152; } int Result_Unwrap(Result r) { - int _t157; - Result_Tag _t156; - _t156 = r.tag; - _t157 = (_t156 != Result_Ok); - if (!_t157) goto endif27; + int _t154; + Result_Tag _t153; + _t153 = r.tag; + _t154 = (_t153 != Result_Ok); + if (!_t154) goto endif26; { PrintLine("panic: unwrap on Err"); return 0; } - endif27:; - Result_Data _t158; - _t158 = r.data; - int _t159; - _t159 = _t158.Ok_0; - return _t159; + endif26:; + Result_Data _t155; + _t155 = r.data; + int _t156; + _t156 = _t155.Ok_0; + return _t156; } int Result_UnwrapOr(Result r, int fallback) { - int _t161; - Result_Tag _t160; - _t160 = r.tag; - _t161 = (_t160 == Result_Ok); - if (!_t161) goto endif29; + int _t158; + Result_Tag _t157; + _t157 = r.tag; + _t158 = (_t157 == Result_Ok); + if (!_t158) goto endif28; { - Result_Data _t162; - _t162 = r.data; - int _t163; - _t163 = _t162.Ok_0; - return _t163; + Result_Data _t159; + _t159 = r.data; + int _t160; + _t160 = _t159.Ok_0; + return _t160; } - endif29:; + endif28:; return fallback; } Option Option_NewSome(int value) { - Option _t164; + Option _t161; Option o; - _t164 = (Option){.tag = Option_Some}; - o = _t164; + _t161 = (Option){.tag = Option_Some}; + o = _t161; o.data.Some_0 = value; return o; } Option Option_NewNone(void) { - Option _t165; - _t165 = (Option){.tag = Option_None}; - return _t165; + Option _t162; + _t162 = (Option){.tag = Option_None}; + return _t162; } bool Option_IsSome(Option o) { - int _t167; - Option_Tag _t166; - _t166 = o.tag; - _t167 = (_t166 == Option_Some); - return _t167; + int _t164; + Option_Tag _t163; + _t163 = o.tag; + _t164 = (_t163 == Option_Some); + return _t164; } bool Option_IsNone(Option o) { - int _t169; - Option_Tag _t168; - _t168 = o.tag; - _t169 = (_t168 == Option_None); - return _t169; + int _t166; + Option_Tag _t165; + _t165 = o.tag; + _t166 = (_t165 == Option_None); + return _t166; } int Option_Unwrap(Option o) { - int _t171; - Option_Tag _t170; - _t170 = o.tag; - _t171 = (_t170 != Option_Some); - if (!_t171) goto endif31; + int _t168; + Option_Tag _t167; + _t167 = o.tag; + _t168 = (_t167 != Option_Some); + if (!_t168) goto endif30; { PrintLine("panic: unwrap on None"); return 0; } - endif31:; - Option_Data _t172; - _t172 = o.data; - int _t173; - _t173 = _t172.Some_0; - return _t173; + endif30:; + Option_Data _t169; + _t169 = o.data; + int _t170; + _t170 = _t169.Some_0; + return _t170; } int Option_UnwrapOr(Option o, int fallback) { - int _t175; - Option_Tag _t174; - _t174 = o.tag; - _t175 = (_t174 == Option_Some); - if (!_t175) goto endif33; + int _t172; + Option_Tag _t171; + _t171 = o.tag; + _t172 = (_t171 == Option_Some); + if (!_t172) goto endif32; { - Option_Data _t176; - _t176 = o.data; - int _t177; - _t177 = _t176.Some_0; - return _t177; + Option_Data _t173; + _t173 = o.data; + int _t174; + _t174 = _t173.Some_0; + return _t174; } - endif33:; + endif32:; return fallback; } JsonValue Json_Null(void) { - JsonValue _t178; - _t178 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t178; + JsonValue _t175; + _t175 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t175; } JsonValue Json_Bool(bool b) { - JsonValue _t179; - _t179 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t179; + JsonValue _t176; + _t176 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t176; } JsonValue Json_Number(double n) { - JsonValue _t180; - _t180 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t180; + JsonValue _t177; + _t177 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t177; } JsonValue Json_String(const char* s) { - JsonValue _t181; - _t181 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t181; + JsonValue _t178; + _t178 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t178; } JsonValue Json_Array(void) { - JsonValue _t182; - _t182 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t182; + JsonValue _t179; + _t179 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t179; } JsonValue Json_Object(void) { - JsonValue _t183; - _t183 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t183; + JsonValue _t180; + _t180 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t180; } unsigned int Json_ArrayLen(JsonValue v) { - int _t185; - int _t184; - _t184 = v.tag; - _t185 = (_t184 != JsonTagArray); - if (!_t185) goto endif35; + int _t182; + int _t181; + _t181 = v.tag; + _t182 = (_t181 != JsonTagArray); + if (!_t182) goto endif34; { return 0; } - endif35:; - unsigned int _t186; - _t186 = v.arrLen; - return _t186; + endif34:; + unsigned int _t183; + _t183 = v.arrLen; + return _t183; } JsonValue Json_ArrayGet(JsonValue v, unsigned int index) { + int _t185; int _t188; - int _t191; - int _t187; - _t187 = v.tag; - _t188 = (_t187 != JsonTagArray); - if (!_t188) goto endif37; + int _t184; + _t184 = v.tag; + _t185 = (_t184 != JsonTagArray); + if (!_t185) goto endif36; + { + JsonValue _t186; + _t186 = Json_Null(); + return _t186; + } + endif36:; + unsigned int _t187; + _t187 = v.arrLen; + _t188 = (index >= _t187); + if (!_t188) goto endif38; { JsonValue _t189; _t189 = Json_Null(); return _t189; } - endif37:; - unsigned int _t190; - _t190 = v.arrLen; - _t191 = (index >= _t190); - if (!_t191) goto endif39; - { - JsonValue _t192; - _t192 = Json_Null(); - return _t192; - } - endif39:; - JsonValue* _t193; - _t193 = v.arrData; - JsonValue _t194; - _t194 = _t193[index]; - return _t194; + endif38:; + JsonValue* _t190; + _t190 = v.arrData; + JsonValue _t191; + _t191 = _t190[index]; + return _t191; } void Json_ArrayPush(JsonValue* self, JsonValue val) { + int _t193; int _t196; + int _t198; int _t199; - int _t201; - int _t203; - JsonValue* _t205; - int _t206; - void* _t208; - int _t210; - JsonValue* _t212; - int _t216; - int _t195; - _t195 = self->tag; - _t196 = (_t195 != JsonTagArray); - if (!_t196) goto endif41; + JsonValue* _t201; + int _t202; + void* _t204; + int _t205; + JsonValue* _t207; + int _t211; + int _t192; + _t192 = self->tag; + _t193 = (_t192 != JsonTagArray); + if (!_t193) goto endif40; { return; } - endif41:; - unsigned int _t197; - _t197 = self->arrLen; - unsigned int _t198; - _t198 = self->arrCap; - _t199 = (_t197 >= _t198); - if (!_t199) goto endif43; + endif40:; + unsigned int _t194; + _t194 = self->arrLen; + unsigned int _t195; + _t195 = self->arrCap; + _t196 = (_t194 >= _t195); + if (!_t196) goto endif42; { unsigned int arrNewCap; - unsigned int _t200; - _t200 = self->arrCap; - arrNewCap = _t200; - _t201 = (arrNewCap == 0); - if (!_t201) goto else44; + unsigned int _t197; + _t197 = self->arrCap; + arrNewCap = _t197; + _t198 = (arrNewCap == 0); + if (!_t198) goto else43; { self->arrCap = 4; /* sizeof(JsonValue) */ - _t203 = 4 * sizeof(JsonValue); - void* _t204; - _t204 = Alloc(_t203); - _t205 = (JsonValue*)_t204; - self->arrData = _t205; + _t199 = 4 * sizeof(JsonValue); + void* _t200; + _t200 = Alloc(_t199); + _t201 = (JsonValue*)_t200; + self->arrData = _t201; } - goto endif45; - else44:; + goto endif44; + else43:; { unsigned int doubleCap; - _t206 = arrNewCap * 2; - doubleCap = _t206; + _t202 = arrNewCap * 2; + doubleCap = _t202; self->arrCap = doubleCap; - JsonValue* _t207; - _t207 = self->arrData; - _t208 = (void*)_t207; + JsonValue* _t203; + _t203 = self->arrData; + _t204 = (void*)_t203; /* sizeof(JsonValue) */ - _t210 = doubleCap * sizeof(JsonValue); - void* _t211; - _t211 = Realloc(_t208, _t210); - _t212 = (JsonValue*)_t211; - self->arrData = _t212; + _t205 = doubleCap * sizeof(JsonValue); + void* _t206; + _t206 = Realloc(_t204, _t205); + _t207 = (JsonValue*)_t206; + self->arrData = _t207; } - endif45:; + endif44:; } - endif43:; - JsonValue* _t213; - _t213 = self->arrData; - unsigned int _t214; - _t214 = self->arrLen; - _t213[_t214] = val; - unsigned int _t215; - _t215 = self->arrLen; - _t216 = _t215 + 1; - self->arrLen = _t216; + endif42:; + JsonValue* _t208; + _t208 = self->arrData; + unsigned int _t209; + _t209 = self->arrLen; + _t208[_t209] = val; + unsigned int _t210; + _t210 = self->arrLen; + _t211 = _t210 + 1; + self->arrLen = _t211; } unsigned int Json_ObjectLen(JsonValue v) { - int _t218; - int _t217; - _t217 = v.tag; - _t218 = (_t217 != JsonTagObject); - if (!_t218) goto endif47; + int _t213; + int _t212; + _t212 = v.tag; + _t213 = (_t212 != JsonTagObject); + if (!_t213) goto endif46; { return 0; } - endif47:; - unsigned int _t219; - _t219 = v.objLen; - return _t219; + endif46:; + unsigned int _t214; + _t214 = v.objLen; + return _t214; } JsonValue Json_ObjectGet(JsonValue v, const char* key) { - int _t221; - int _t224; - int _t230; - int _t220; - _t220 = v.tag; - _t221 = (_t220 != JsonTagObject); - if (!_t221) goto endif49; + int _t216; + int _t219; + int _t225; + int _t215; + _t215 = v.tag; + _t216 = (_t215 != JsonTagObject); + if (!_t216) goto endif48; { - JsonValue _t222; - _t222 = Json_Null(); - return _t222; + JsonValue _t217; + _t217 = Json_Null(); + return _t217; } - endif49:; + endif48:; unsigned int i; i = 0; - while50:; - unsigned int _t223; - _t223 = v.objLen; - _t224 = (i < _t223); - if (!_t224) goto wend52; + while49:; + unsigned int _t218; + _t218 = v.objLen; + _t219 = (i < _t218); + if (!_t219) goto wend50; { - const char** _t225; - _t225 = v.objKeys; - const char* _t226; - _t226 = _t225[i]; - bool _t227; - _t227 = String_Eq(_t226, key); - if (!_t227) goto endif54; + const char** _t220; + _t220 = v.objKeys; + const char* _t221; + _t221 = _t220[i]; + bool _t222; + _t222 = String_Eq(_t221, key); + if (!_t222) goto endif52; { - JsonValue* _t228; - _t228 = v.objValues; - JsonValue _t229; - _t229 = _t228[i]; - return _t229; + JsonValue* _t223; + _t223 = v.objValues; + JsonValue _t224; + _t224 = _t223[i]; + return _t224; } - endif54:; - _t230 = i + 1; - i = _t230; + endif52:; + _t225 = i + 1; + i = _t225; } - goto while50; - wend52:; - JsonValue _t231; - _t231 = Json_Null(); - return _t231; + goto while49; + wend50:; + JsonValue _t226; + _t226 = Json_Null(); + return _t226; } bool Json_ObjectHas(JsonValue v, const char* key) { - int _t233; - int _t235; - int _t239; - int _t232; - _t232 = v.tag; - _t233 = (_t232 != JsonTagObject); - if (!_t233) goto endif56; + int _t228; + int _t230; + int _t234; + int _t227; + _t227 = v.tag; + _t228 = (_t227 != JsonTagObject); + if (!_t228) goto endif54; { return 0; } - endif56:; + endif54:; unsigned int i; i = 0; - while57:; - unsigned int _t234; - _t234 = v.objLen; - _t235 = (i < _t234); - if (!_t235) goto wend59; + while55:; + unsigned int _t229; + _t229 = v.objLen; + _t230 = (i < _t229); + if (!_t230) goto wend56; { - const char** _t236; - _t236 = v.objKeys; - const char* _t237; - _t237 = _t236[i]; - bool _t238; - _t238 = String_Eq(_t237, key); - if (!_t238) goto endif61; + const char** _t231; + _t231 = v.objKeys; + const char* _t232; + _t232 = _t231[i]; + bool _t233; + _t233 = String_Eq(_t232, key); + if (!_t233) goto endif58; { return 1; } - endif61:; - _t239 = i + 1; - i = _t239; + endif58:; + _t234 = i + 1; + i = _t234; } - goto while57; - wend59:; + goto while55; + wend56:; return 0; } void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) { - int _t241; + int _t236; + int _t238; int _t243; + int _t246; int _t248; - int _t251; - int _t253; + int _t249; + const char** _t251; + int _t252; + JsonValue* _t254; int _t255; - const char** _t257; - int _t259; - JsonValue* _t261; - int _t262; - void* _t264; - int _t266; - const char** _t268; - void* _t270; - int _t272; - JsonValue* _t274; - int _t280; - int _t240; - _t240 = self->tag; - _t241 = (_t240 != JsonTagObject); - if (!_t241) goto endif63; + void* _t257; + int _t258; + const char** _t260; + void* _t262; + int _t263; + JsonValue* _t265; + int _t271; + int _t235; + _t235 = self->tag; + _t236 = (_t235 != JsonTagObject); + if (!_t236) goto endif60; { return; } - endif63:; + endif60:; unsigned int i; i = 0; - while64:; - unsigned int _t242; - _t242 = self->objLen; - _t243 = (i < _t242); - if (!_t243) goto wend66; + while61:; + unsigned int _t237; + _t237 = self->objLen; + _t238 = (i < _t237); + if (!_t238) goto wend62; { - const char** _t244; - _t244 = self->objKeys; - const char* _t245; - _t245 = _t244[i]; - bool _t246; - _t246 = String_Eq(_t245, key); - if (!_t246) goto endif68; + const char** _t239; + _t239 = self->objKeys; + const char* _t240; + _t240 = _t239[i]; + bool _t241; + _t241 = String_Eq(_t240, key); + if (!_t241) goto endif64; { - JsonValue* _t247; - _t247 = self->objValues; - _t247[i] = val; + JsonValue* _t242; + _t242 = self->objValues; + _t242[i] = val; return; } - endif68:; - _t248 = i + 1; - i = _t248; + endif64:; + _t243 = i + 1; + i = _t243; } - goto while64; - wend66:; - unsigned int _t249; - _t249 = self->objLen; - unsigned int _t250; - _t250 = self->objCap; - _t251 = (_t249 >= _t250); - if (!_t251) goto endif70; + goto while61; + wend62:; + unsigned int _t244; + _t244 = self->objLen; + unsigned int _t245; + _t245 = self->objCap; + _t246 = (_t244 >= _t245); + if (!_t246) goto endif66; { unsigned int objNewCap; - unsigned int _t252; - _t252 = self->objCap; - objNewCap = _t252; - _t253 = (objNewCap == 0); - if (!_t253) goto else71; + unsigned int _t247; + _t247 = self->objCap; + objNewCap = _t247; + _t248 = (objNewCap == 0); + if (!_t248) goto else67; { self->objCap = 4; /* sizeof(const char*) */ - _t255 = 4 * sizeof(const char*); - void* _t256; - _t256 = Alloc(_t255); - _t257 = (const char**)_t256; - self->objKeys = _t257; + _t249 = 4 * sizeof(const char*); + void* _t250; + _t250 = Alloc(_t249); + _t251 = (const char**)_t250; + self->objKeys = _t251; /* sizeof(JsonValue) */ - _t259 = 4 * sizeof(JsonValue); - void* _t260; - _t260 = Alloc(_t259); - _t261 = (JsonValue*)_t260; - self->objValues = _t261; + _t252 = 4 * sizeof(JsonValue); + void* _t253; + _t253 = Alloc(_t252); + _t254 = (JsonValue*)_t253; + self->objValues = _t254; } - goto endif72; - else71:; + goto endif68; + else67:; { unsigned int doubleCap; - _t262 = objNewCap * 2; - doubleCap = _t262; + _t255 = objNewCap * 2; + doubleCap = _t255; self->objCap = doubleCap; - const char** _t263; - _t263 = self->objKeys; - _t264 = (void*)_t263; + const char** _t256; + _t256 = self->objKeys; + _t257 = (void*)_t256; /* sizeof(const char*) */ - _t266 = doubleCap * sizeof(const char*); - void* _t267; - _t267 = Realloc(_t264, _t266); - _t268 = (const char**)_t267; - self->objKeys = _t268; - JsonValue* _t269; - _t269 = self->objValues; - _t270 = (void*)_t269; + _t258 = doubleCap * sizeof(const char*); + void* _t259; + _t259 = Realloc(_t257, _t258); + _t260 = (const char**)_t259; + self->objKeys = _t260; + JsonValue* _t261; + _t261 = self->objValues; + _t262 = (void*)_t261; /* sizeof(JsonValue) */ - _t272 = doubleCap * sizeof(JsonValue); - void* _t273; - _t273 = Realloc(_t270, _t272); - _t274 = (JsonValue*)_t273; - self->objValues = _t274; + _t263 = doubleCap * sizeof(JsonValue); + void* _t264; + _t264 = Realloc(_t262, _t263); + _t265 = (JsonValue*)_t264; + self->objValues = _t265; } - endif72:; + endif68:; } - endif70:; - const char** _t275; - _t275 = self->objKeys; - unsigned int _t276; - _t276 = self->objLen; - _t275[_t276] = key; - JsonValue* _t277; - _t277 = self->objValues; - unsigned int _t278; - _t278 = self->objLen; - _t277[_t278] = val; - unsigned int _t279; - _t279 = self->objLen; - _t280 = _t279 + 1; - self->objLen = _t280; + endif66:; + const char** _t266; + _t266 = self->objKeys; + unsigned int _t267; + _t267 = self->objLen; + _t266[_t267] = key; + JsonValue* _t268; + _t268 = self->objValues; + unsigned int _t269; + _t269 = self->objLen; + _t268[_t269] = val; + unsigned int _t270; + _t270 = self->objLen; + _t271 = _t270 + 1; + self->objLen = _t271; } bool Json_IsNull(JsonValue v) { - int _t282; - int _t281; - _t281 = v.tag; - _t282 = (_t281 == JsonTagNull); - return _t282; + int _t273; + int _t272; + _t272 = v.tag; + _t273 = (_t272 == JsonTagNull); + return _t273; } bool Json_AsBool(JsonValue v) { - int _t284; - int _t283; - _t283 = v.tag; - _t284 = (_t283 == JsonTagBool); - if (!_t284) goto endif74; + int _t275; + int _t274; + _t274 = v.tag; + _t275 = (_t274 == JsonTagBool); + if (!_t275) goto endif70; { - bool _t285; - _t285 = v.boolVal; - return _t285; + bool _t276; + _t276 = v.boolVal; + return _t276; } - endif74:; + endif70:; return 0; } double Json_AsNumber(JsonValue v) { - int _t287; - int _t286; - _t286 = v.tag; - _t287 = (_t286 == JsonTagNumber); - if (!_t287) goto endif76; + int _t278; + int _t277; + _t277 = v.tag; + _t278 = (_t277 == JsonTagNumber); + if (!_t278) goto endif72; { - double _t288; - _t288 = v.numVal; - return _t288; + double _t279; + _t279 = v.numVal; + return _t279; } - endif76:; + endif72:; return 0.0; } const char* Json_AsString(JsonValue v) { - int _t290; - int _t289; - _t289 = v.tag; - _t290 = (_t289 == JsonTagString); - if (!_t290) goto endif78; + int _t281; + int _t280; + _t280 = v.tag; + _t281 = (_t280 == JsonTagString); + if (!_t281) goto endif74; { - const char* _t291; - _t291 = v.strVal; - return _t291; + const char* _t282; + _t282 = v.strVal; + return _t282; } - endif78:; + endif74:; return ""; } int JsonParser_Peek(JsonParser* p) { - int _t294; - int _t298; - unsigned int _t292; - _t292 = p->pos; - unsigned int _t293; - _t293 = p->len; - _t294 = (_t292 >= _t293); - if (!_t294) goto endif80; + int _t285; + int _t289; + unsigned int _t283; + _t283 = p->pos; + unsigned int _t284; + _t284 = p->len; + _t285 = (_t283 >= _t284); + if (!_t285) goto endif76; { return 0; } - endif80:; - const char* _t295; - _t295 = p->src; - unsigned int _t296; - _t296 = p->pos; - int _t297; - _t297 = _t295[_t296]; - _t298 = (int)_t297; - return _t298; + endif76:; + const char* _t286; + _t286 = p->src; + unsigned int _t287; + _t287 = p->pos; + int _t288; + _t288 = _t286[_t287]; + _t289 = (int)_t288; + return _t289; } void JsonParser_Advance(JsonParser* p) { - int _t301; - int _t303; - unsigned int _t299; - _t299 = p->pos; - unsigned int _t300; - _t300 = p->len; - _t301 = (_t299 < _t300); - if (!_t301) goto endif82; + int _t292; + int _t294; + unsigned int _t290; + _t290 = p->pos; + unsigned int _t291; + _t291 = p->len; + _t292 = (_t290 < _t291); + if (!_t292) goto endif78; { - unsigned int _t302; - _t302 = p->pos; - _t303 = _t302 + 1; - p->pos = _t303; + unsigned int _t293; + _t293 = p->pos; + _t294 = _t293 + 1; + p->pos = _t294; } - endif82:; + endif78:; } void JsonParser_SkipWhitespace(JsonParser* p) { - int _t305; - int _t306; - int _t308; - int _t310; - while83:; - if (!1) goto wend85; + int _t296; + int _t297; + int _t299; + int _t301; + while79:; + if (!1) goto wend80; { int c; - int _t304; - _t304 = JsonParser_Peek(p); - c = _t304; + int _t295; + _t295 = JsonParser_Peek(p); + c = _t295; bool __or_tmp_1; bool __or_tmp_2; bool __or_tmp_3; - _t305 = (c == 32); - if (!_t305) goto else86; + _t296 = (c == 32); + if (!_t296) goto else81; *(bool*)&__or_tmp_3 = 1; - goto endif87; - else86:; - _t306 = (c == 9); - *(bool*)&__or_tmp_3 = _t306; - endif87:; - bool _t307; - _t307 = *(bool*)&__or_tmp_3; - if (!_t307) goto else88; + goto endif82; + else81:; + _t297 = (c == 9); + *(bool*)&__or_tmp_3 = _t297; + endif82:; + bool _t298; + _t298 = *(bool*)&__or_tmp_3; + if (!_t298) goto else83; *(bool*)&__or_tmp_2 = 1; - goto endif89; - else88:; - _t308 = (c == 10); - *(bool*)&__or_tmp_2 = _t308; - endif89:; - bool _t309; - _t309 = *(bool*)&__or_tmp_2; - if (!_t309) goto else90; + goto endif84; + else83:; + _t299 = (c == 10); + *(bool*)&__or_tmp_2 = _t299; + endif84:; + bool _t300; + _t300 = *(bool*)&__or_tmp_2; + if (!_t300) goto else85; *(bool*)&__or_tmp_1 = 1; - goto endif91; - else90:; - _t310 = (c == 13); - *(bool*)&__or_tmp_1 = _t310; - endif91:; - bool _t311; - _t311 = *(bool*)&__or_tmp_1; - if (!_t311) goto else92; + goto endif86; + else85:; + _t301 = (c == 13); + *(bool*)&__or_tmp_1 = _t301; + endif86:; + bool _t302; + _t302 = *(bool*)&__or_tmp_1; + if (!_t302) goto else87; { JsonParser_Advance(p); } - goto endif93; - else92:; + goto endif88; + else87:; { return; } - endif93:; + endif88:; } - goto while83; - wend85:; + goto while79; + wend80:; } bool JsonParser_Match(JsonParser* p, const char* expected) { + int _t305; + int _t307; + int _t308; + int _t311; int _t314; - int _t316; + int _t315; int _t317; - int _t320; - int _t323; - int _t324; - int _t326; unsigned int elen; - unsigned int _t312; - _t312 = String_Len(expected); - elen = _t312; - unsigned int _t313; - _t313 = p->pos; - _t314 = _t313 + elen; - unsigned int _t315; - _t315 = p->len; - _t316 = (_t314 > _t315); - if (!_t316) goto endif95; + unsigned int _t303; + _t303 = String_Len(expected); + elen = _t303; + unsigned int _t304; + _t304 = p->pos; + _t305 = _t304 + elen; + unsigned int _t306; + _t306 = p->len; + _t307 = (_t305 > _t306); + if (!_t307) goto endif90; { return 0; } - endif95:; + endif90:; unsigned int i; i = 0; - while96:; - _t317 = (i < elen); - if (!_t317) goto wend98; + while91:; + _t308 = (i < elen); + if (!_t308) goto wend92; { - const char* _t318; - _t318 = p->src; - unsigned int _t319; - _t319 = p->pos; - _t320 = _t319 + i; - int _t321; - _t321 = _t318[_t320]; - int _t322; - _t322 = expected[i]; - _t323 = (_t321 != _t322); - if (!_t323) goto endif100; + const char* _t309; + _t309 = p->src; + unsigned int _t310; + _t310 = p->pos; + _t311 = _t310 + i; + int _t312; + _t312 = _t309[_t311]; + int _t313; + _t313 = expected[i]; + _t314 = (_t312 != _t313); + if (!_t314) goto endif94; { return 0; } - endif100:; - _t324 = i + 1; - i = _t324; + endif94:; + _t315 = i + 1; + i = _t315; } - goto while96; - wend98:; - unsigned int _t325; - _t325 = p->pos; - _t326 = _t325 + elen; - p->pos = _t326; + goto while91; + wend92:; + unsigned int _t316; + _t316 = p->pos; + _t317 = _t316 + elen; + p->pos = _t317; return 1; } const char* JsonParser_ParseString(JsonParser* p) { - int _t328; - int _t331; + int _t319; + int _t322; + int _t323; + int _t325; + int _t327; + void* _t328; + int _t329; + void* _t330; + char _t331; int _t332; - int _t334; - int _t336; - void* _t337; + void* _t333; + char _t334; + int _t335; + void* _t336; + char _t337; int _t338; void* _t339; char _t340; @@ -2009,234 +2017,262 @@ const char* JsonParser_ParseString(JsonParser* p) { int _t347; void* _t348; char _t349; - int _t350; - void* _t351; - char _t352; - int _t353; + void* _t350; + char _t351; + void* _t352; + char _t353; void* _t354; char _t355; - int _t356; - void* _t357; - char _t358; + int _t357; + void* _t358; void* _t359; - char _t360; void* _t361; - char _t362; - void* _t363; - char _t364; - int _t366; - void* _t367; - void* _t368; - void* _t370; - int _t327; - _t327 = JsonParser_Peek(p); - _t328 = (_t327 != 34); - if (!_t328) goto endif102; + int _t318; + _t318 = JsonParser_Peek(p); + _t319 = (_t318 != 34); + if (!_t319) goto endif96; { p->error = "Expected string"; return ""; } - endif102:; + endif96:; JsonParser_Advance(p); StringBuilder sb; - StringBuilder _t329; - _t329 = StringBuilder_New(); - sb = _t329; - while103:; - if (!1) goto wend105; + StringBuilder _t320; + _t320 = StringBuilder_New(); + sb = _t320; + while97:; + if (!1) goto wend98; { int c; - int _t330; - _t330 = JsonParser_Peek(p); - c = _t330; + int _t321; + _t321 = JsonParser_Peek(p); + c = _t321; bool __or_tmp_4; - _t331 = (c == 0); - if (!_t331) goto else106; + _t322 = (c == 0); + if (!_t322) goto else99; *(bool*)&__or_tmp_4 = 1; - goto endif107; - else106:; - _t332 = (c == 34); - *(bool*)&__or_tmp_4 = _t332; - endif107:; - bool _t333; - _t333 = *(bool*)&__or_tmp_4; - if (!_t333) goto endif109; + goto endif100; + else99:; + _t323 = (c == 34); + *(bool*)&__or_tmp_4 = _t323; + endif100:; + bool _t324; + _t324 = *(bool*)&__or_tmp_4; + if (!_t324) goto endif102; { - goto wend105; + goto wend98; } - endif109:; - _t334 = (c == 92); - if (!_t334) goto else110; + endif102:; + _t325 = (c == 92); + if (!_t325) goto else103; { JsonParser_Advance(p); int esc; - int _t335; - _t335 = JsonParser_Peek(p); - esc = _t335; - _t336 = (esc == 0); - if (!_t336) goto endif113; + int _t326; + _t326 = JsonParser_Peek(p); + esc = _t326; + _t327 = (esc == 0); + if (!_t327) goto endif106; { p->error = "Unterminated string escape"; - _t337 = &sb; - StringBuilder_Free(_t337); + _t328 = &sb; + StringBuilder_Free(_t328); return ""; } - endif113:; - _t338 = (esc == 110); - if (!_t338) goto else114; + endif106:; + _t329 = (esc == 110); + if (!_t329) goto else107; + { + _t330 = &sb; + _t331 = (char)10; + StringBuilder_AppendChar(_t330, _t331); + } + goto endif108; + else107:; + _t332 = (esc == 116); + if (!_t332) goto else109; + { + _t333 = &sb; + _t334 = (char)9; + StringBuilder_AppendChar(_t333, _t334); + } + goto endif110; + else109:; + _t335 = (esc == 114); + if (!_t335) goto else111; + { + _t336 = &sb; + _t337 = (char)13; + StringBuilder_AppendChar(_t336, _t337); + } + goto endif112; + else111:; + _t338 = (esc == 98); + if (!_t338) goto else113; { _t339 = &sb; - _t340 = (char)10; + _t340 = (char)8; StringBuilder_AppendChar(_t339, _t340); } - goto endif115; - else114:; - _t341 = (esc == 116); - if (!_t341) goto else116; + goto endif114; + else113:; + _t341 = (esc == 102); + if (!_t341) goto else115; { _t342 = &sb; - _t343 = (char)9; + _t343 = (char)12; StringBuilder_AppendChar(_t342, _t343); } - goto endif117; - else116:; - _t344 = (esc == 114); - if (!_t344) goto else118; + goto endif116; + else115:; + _t344 = (esc == 34); + if (!_t344) goto else117; { _t345 = &sb; - _t346 = (char)13; + _t346 = (char)34; StringBuilder_AppendChar(_t345, _t346); } - goto endif119; - else118:; - _t347 = (esc == 98); - if (!_t347) goto else120; + goto endif118; + else117:; + _t347 = (esc == 92); + if (!_t347) goto else119; { _t348 = &sb; - _t349 = (char)8; + _t349 = (char)92; StringBuilder_AppendChar(_t348, _t349); } - goto endif121; - else120:; - _t350 = (esc == 102); - if (!_t350) goto else122; + goto endif120; + else119:; { - _t351 = &sb; - _t352 = (char)12; - StringBuilder_AppendChar(_t351, _t352); + _t350 = &sb; + _t351 = (char)92; + StringBuilder_AppendChar(_t350, _t351); + _t352 = &sb; + _t353 = (char)esc; + StringBuilder_AppendChar(_t352, _t353); } - goto endif123; - else122:; - _t353 = (esc == 34); - if (!_t353) goto else124; + endif120:; + endif118:; + endif116:; + endif114:; + endif112:; + endif110:; + endif108:; + JsonParser_Advance(p); + } + goto endif104; + else103:; { _t354 = &sb; - _t355 = (char)34; + _t355 = (char)c; StringBuilder_AppendChar(_t354, _t355); - } - goto endif125; - else124:; - _t356 = (esc == 92); - if (!_t356) goto else126; - { - _t357 = &sb; - _t358 = (char)92; - StringBuilder_AppendChar(_t357, _t358); - } - goto endif127; - else126:; - { - _t359 = &sb; - _t360 = (char)92; - StringBuilder_AppendChar(_t359, _t360); - _t361 = &sb; - _t362 = (char)esc; - StringBuilder_AppendChar(_t361, _t362); - } - endif127:; - endif125:; - endif123:; - endif121:; - endif119:; - endif117:; - endif115:; JsonParser_Advance(p); } - goto endif111; - else110:; - { - _t363 = &sb; - _t364 = (char)c; - StringBuilder_AppendChar(_t363, _t364); - JsonParser_Advance(p); + endif104:; } - endif111:; - } - goto while103; - wend105:; - int _t365; - _t365 = JsonParser_Peek(p); - _t366 = (_t365 != 34); - if (!_t366) goto endif129; + goto while97; + wend98:; + int _t356; + _t356 = JsonParser_Peek(p); + _t357 = (_t356 != 34); + if (!_t357) goto endif122; { p->error = "Unterminated string"; - _t367 = &sb; - StringBuilder_Free(_t367); + _t358 = &sb; + StringBuilder_Free(_t358); return ""; } - endif129:; + endif122:; JsonParser_Advance(p); const char* result; - _t368 = &sb; - const char* _t369; - _t369 = StringBuilder_Build(_t368); - result = _t369; - _t370 = &sb; - StringBuilder_Free(_t370); + _t359 = &sb; + const char* _t360; + _t360 = StringBuilder_Build(_t359); + result = _t360; + _t361 = &sb; + StringBuilder_Free(_t361); return result; } JsonValue JsonParser_ParseNumber(JsonParser* p) { - int _t373; - int _t375; - int _t376; - int _t379; - int _t381; - int _t382; - int _t386; - unsigned int start; - unsigned int _t371; - _t371 = p->pos; - start = _t371; - int c0; + int _t364; + int _t366; + int _t367; + int _t370; int _t372; - _t372 = JsonParser_Peek(p); - c0 = _t372; - _t373 = (c0 == 45); - if (!_t373) goto endif131; + int _t373; + int _t377; + unsigned int start; + unsigned int _t362; + _t362 = p->pos; + start = _t362; + int c0; + int _t363; + _t363 = JsonParser_Peek(p); + c0 = _t363; + _t364 = (c0 == 45); + if (!_t364) goto endif124; { JsonParser_Advance(p); } - endif131:; - while132:; + endif124:; + while125:; + if (!1) goto wend126; + { + int c; + int _t365; + _t365 = JsonParser_Peek(p); + c = _t365; + bool __and_tmp_5; + _t366 = (c >= 48); + if (!_t366) goto else127; + _t367 = (c <= 57); + *(bool*)&__and_tmp_5 = _t367; + goto endif128; + else127:; + *(bool*)&__and_tmp_5 = 0; + endif128:; + bool _t368; + _t368 = *(bool*)&__and_tmp_5; + if (!_t368) goto else129; + { + JsonParser_Advance(p); + } + goto endif130; + else129:; + { + goto wend126; + } + endif130:; + } + goto while125; + wend126:; + int _t369; + _t369 = JsonParser_Peek(p); + _t370 = (_t369 == 46); + if (!_t370) goto endif132; + { + JsonParser_Advance(p); + while133:; if (!1) goto wend134; { int c; - int _t374; - _t374 = JsonParser_Peek(p); - c = _t374; - bool __and_tmp_5; - _t375 = (c >= 48); - if (!_t375) goto else135; - _t376 = (c <= 57); - *(bool*)&__and_tmp_5 = _t376; + int _t371; + _t371 = JsonParser_Peek(p); + c = _t371; + bool __and_tmp_6; + _t372 = (c >= 48); + if (!_t372) goto else135; + _t373 = (c <= 57); + *(bool*)&__and_tmp_6 = _t373; goto endif136; else135:; - *(bool*)&__and_tmp_5 = 0; + *(bool*)&__and_tmp_6 = 0; endif136:; - bool _t377; - _t377 = *(bool*)&__and_tmp_5; - if (!_t377) goto else137; + bool _t374; + _t374 = *(bool*)&__and_tmp_6; + if (!_t374) goto else137; { JsonParser_Advance(p); } @@ -2247,1098 +2283,1061 @@ JsonValue JsonParser_ParseNumber(JsonParser* p) { } endif138:; } - goto while132; + goto while133; wend134:; - int _t378; - _t378 = JsonParser_Peek(p); - _t379 = (_t378 == 46); - if (!_t379) goto endif140; - { - JsonParser_Advance(p); - while141:; - if (!1) goto wend143; - { - int c; - int _t380; - _t380 = JsonParser_Peek(p); - c = _t380; - bool __and_tmp_6; - _t381 = (c >= 48); - if (!_t381) goto else144; - _t382 = (c <= 57); - *(bool*)&__and_tmp_6 = _t382; - goto endif145; - else144:; - *(bool*)&__and_tmp_6 = 0; - endif145:; - bool _t383; - _t383 = *(bool*)&__and_tmp_6; - if (!_t383) goto else146; - { - JsonParser_Advance(p); } - goto endif147; - else146:; - { - goto wend143; - } - endif147:; - } - goto while141; - wend143:; - } - endif140:; + endif132:; const char* numStr; - const char* _t384; - _t384 = p->src; - unsigned int _t385; - _t385 = p->pos; - _t386 = _t385 - start; - const char* _t387; - _t387 = String_Slice(_t384, start, _t386); - numStr = _t387; + const char* _t375; + _t375 = p->src; + unsigned int _t376; + _t376 = p->pos; + _t377 = _t376 - start; + const char* _t378; + _t378 = String_Slice(_t375, start, _t377); + numStr = _t378; double n; - double _t388; - _t388 = String_ToFloat(numStr); - n = _t388; - JsonValue _t389; - _t389 = Json_Number(n); - return _t389; + double _t379; + _t379 = String_ToFloat(numStr); + n = _t379; + JsonValue _t380; + _t380 = Json_Number(n); + return _t380; } JsonValue JsonParser_ParseArray(JsonParser* p) { - int _t392; - int _t395; - void* _t397; - int _t399; - int _t400; + int _t383; + int _t386; + void* _t388; + int _t390; + int _t391; JsonParser_Advance(p); JsonValue arr; - JsonValue _t390; - _t390 = Json_Array(); - arr = _t390; + JsonValue _t381; + _t381 = Json_Array(); + arr = _t381; JsonParser_SkipWhitespace(p); - int _t391; - _t391 = JsonParser_Peek(p); - _t392 = (_t391 == 93); - if (!_t392) goto endif149; + int _t382; + _t382 = JsonParser_Peek(p); + _t383 = (_t382 == 93); + if (!_t383) goto endif140; { JsonParser_Advance(p); return arr; } - endif149:; - while150:; - if (!1) goto wend152; + endif140:; + while141:; + if (!1) goto wend142; { JsonParser_SkipWhitespace(p); JsonValue val; - JsonValue _t393; - _t393 = JsonParser_ParseValue(p); - val = _t393; - const char* _t394; - _t394 = p->error; - _t395 = (_t394 != ""); - if (!_t395) goto endif154; + JsonValue _t384; + _t384 = JsonParser_ParseValue(p); + val = _t384; + const char* _t385; + _t385 = p->error; + _t386 = (_t385 != ""); + if (!_t386) goto endif144; { - JsonValue _t396; - _t396 = Json_Null(); - return _t396; + JsonValue _t387; + _t387 = Json_Null(); + return _t387; } - endif154:; - _t397 = &arr; - Json_ArrayPush(_t397, val); + endif144:; + _t388 = &arr; + Json_ArrayPush(_t388, val); JsonParser_SkipWhitespace(p); int c; - int _t398; - _t398 = JsonParser_Peek(p); - c = _t398; - _t399 = (c == 93); - if (!_t399) goto endif156; + int _t389; + _t389 = JsonParser_Peek(p); + c = _t389; + _t390 = (c == 93); + if (!_t390) goto endif146; { JsonParser_Advance(p); return arr; } - endif156:; - _t400 = (c == 44); - if (!_t400) goto else157; + endif146:; + _t391 = (c == 44); + if (!_t391) goto else147; { JsonParser_Advance(p); } - goto endif158; - else157:; + goto endif148; + else147:; { p->error = "Expected ',' or ']' in array"; - JsonValue _t401; - _t401 = Json_Null(); - return _t401; + JsonValue _t392; + _t392 = Json_Null(); + return _t392; } - endif158:; + endif148:; } - goto while150; - wend152:; + goto while141; + wend142:; } JsonValue JsonParser_ParseObject(JsonParser* p) { - int _t404; - int _t407; + int _t395; + int _t398; + int _t401; + int _t405; + void* _t407; + int _t409; int _t410; - int _t414; - void* _t416; - int _t418; - int _t419; JsonParser_Advance(p); JsonValue obj; - JsonValue _t402; - _t402 = Json_Object(); - obj = _t402; + JsonValue _t393; + _t393 = Json_Object(); + obj = _t393; JsonParser_SkipWhitespace(p); - int _t403; - _t403 = JsonParser_Peek(p); - _t404 = (_t403 == 125); - if (!_t404) goto endif160; + int _t394; + _t394 = JsonParser_Peek(p); + _t395 = (_t394 == 125); + if (!_t395) goto endif150; + { + JsonParser_Advance(p); + return obj; + } + endif150:; + while151:; + if (!1) goto wend152; + { + JsonParser_SkipWhitespace(p); + const char* key; + const char* _t396; + _t396 = JsonParser_ParseString(p); + key = _t396; + const char* _t397; + _t397 = p->error; + _t398 = (_t397 != ""); + if (!_t398) goto endif154; + { + JsonValue _t399; + _t399 = Json_Null(); + return _t399; + } + endif154:; + JsonParser_SkipWhitespace(p); + int _t400; + _t400 = JsonParser_Peek(p); + _t401 = (_t400 != 58); + if (!_t401) goto endif156; + { + p->error = "Expected ':' after object key"; + JsonValue _t402; + _t402 = Json_Null(); + return _t402; + } + endif156:; + JsonParser_Advance(p); + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t403; + _t403 = JsonParser_ParseValue(p); + val = _t403; + const char* _t404; + _t404 = p->error; + _t405 = (_t404 != ""); + if (!_t405) goto endif158; + { + JsonValue _t406; + _t406 = Json_Null(); + return _t406; + } + endif158:; + _t407 = &obj; + Json_ObjectSet(_t407, key, val); + JsonParser_SkipWhitespace(p); + int c; + int _t408; + _t408 = JsonParser_Peek(p); + c = _t408; + _t409 = (c == 125); + if (!_t409) goto endif160; { JsonParser_Advance(p); return obj; } endif160:; - while161:; - if (!1) goto wend163; + _t410 = (c == 44); + if (!_t410) goto else161; { - JsonParser_SkipWhitespace(p); - const char* key; - const char* _t405; - _t405 = JsonParser_ParseString(p); - key = _t405; - const char* _t406; - _t406 = p->error; - _t407 = (_t406 != ""); - if (!_t407) goto endif165; - { - JsonValue _t408; - _t408 = Json_Null(); - return _t408; + JsonParser_Advance(p); } - endif165:; - JsonParser_SkipWhitespace(p); - int _t409; - _t409 = JsonParser_Peek(p); - _t410 = (_t409 != 58); - if (!_t410) goto endif167; + goto endif162; + else161:; { - p->error = "Expected ':' after object key"; + p->error = "Expected ',' or '}' in object"; JsonValue _t411; _t411 = Json_Null(); return _t411; } - endif167:; - JsonParser_Advance(p); - JsonParser_SkipWhitespace(p); - JsonValue val; - JsonValue _t412; - _t412 = JsonParser_ParseValue(p); - val = _t412; - const char* _t413; - _t413 = p->error; - _t414 = (_t413 != ""); - if (!_t414) goto endif169; - { - JsonValue _t415; - _t415 = Json_Null(); - return _t415; + endif162:; } - endif169:; - _t416 = &obj; - Json_ObjectSet(_t416, key, val); - JsonParser_SkipWhitespace(p); - int c; - int _t417; - _t417 = JsonParser_Peek(p); - c = _t417; - _t418 = (c == 125); - if (!_t418) goto endif171; - { - JsonParser_Advance(p); - return obj; - } - endif171:; - _t419 = (c == 44); - if (!_t419) goto else172; - { - JsonParser_Advance(p); - } - goto endif173; - else172:; - { - p->error = "Expected ',' or '}' in object"; - JsonValue _t420; - _t420 = Json_Null(); - return _t420; - } - endif173:; - } - goto while161; - wend163:; + goto while151; + wend152:; } JsonValue JsonParser_ParseValue(JsonParser* p) { + int _t413; + int _t415; + int _t418; + int _t420; int _t422; - int _t424; - int _t427; - int _t429; - int _t431; + int _t426; + int _t430; + int _t434; int _t435; - int _t439; - int _t443; - int _t444; - int _t446; + int _t437; JsonParser_SkipWhitespace(p); int c; - int _t421; - _t421 = JsonParser_Peek(p); - c = _t421; - _t422 = (c == 0); - if (!_t422) goto endif175; + int _t412; + _t412 = JsonParser_Peek(p); + c = _t412; + _t413 = (c == 0); + if (!_t413) goto endif164; { p->error = "Unexpected end of input"; - JsonValue _t423; - _t423 = Json_Null(); - return _t423; + JsonValue _t414; + _t414 = Json_Null(); + return _t414; } - endif175:; - _t424 = (c == 34); - if (!_t424) goto endif177; + endif164:; + _t415 = (c == 34); + if (!_t415) goto endif166; { - const char* _t425; - _t425 = JsonParser_ParseString(p); - JsonValue _t426; - _t426 = Json_String(_t425); - return _t426; + const char* _t416; + _t416 = JsonParser_ParseString(p); + JsonValue _t417; + _t417 = Json_String(_t416); + return _t417; } - endif177:; - _t427 = (c == 123); - if (!_t427) goto endif179; + endif166:; + _t418 = (c == 123); + if (!_t418) goto endif168; + { + JsonValue _t419; + _t419 = JsonParser_ParseObject(p); + return _t419; + } + endif168:; + _t420 = (c == 91); + if (!_t420) goto endif170; + { + JsonValue _t421; + _t421 = JsonParser_ParseArray(p); + return _t421; + } + endif170:; + _t422 = (c == 116); + if (!_t422) goto endif172; + { + bool _t423; + _t423 = JsonParser_Match(p, "true"); + if (!_t423) goto endif174; + { + JsonValue _t424; + _t424 = Json_Bool(1); + return _t424; + } + endif174:; + p->error = "Expected 'true'"; + JsonValue _t425; + _t425 = Json_Null(); + return _t425; + } + endif172:; + _t426 = (c == 102); + if (!_t426) goto endif176; + { + bool _t427; + _t427 = JsonParser_Match(p, "false"); + if (!_t427) goto endif178; { JsonValue _t428; - _t428 = JsonParser_ParseObject(p); + _t428 = Json_Bool(0); return _t428; } - endif179:; - _t429 = (c == 91); - if (!_t429) goto endif181; - { - JsonValue _t430; - _t430 = JsonParser_ParseArray(p); - return _t430; + endif178:; + p->error = "Expected 'false'"; + JsonValue _t429; + _t429 = Json_Null(); + return _t429; } - endif181:; - _t431 = (c == 116); - if (!_t431) goto endif183; + endif176:; + _t430 = (c == 110); + if (!_t430) goto endif180; { - bool _t432; - _t432 = JsonParser_Match(p, "true"); - if (!_t432) goto endif185; + bool _t431; + _t431 = JsonParser_Match(p, "null"); + if (!_t431) goto endif182; { + JsonValue _t432; + _t432 = Json_Null(); + return _t432; + } + endif182:; + p->error = "Expected 'null'"; JsonValue _t433; - _t433 = Json_Bool(1); + _t433 = Json_Null(); return _t433; } - endif185:; - p->error = "Expected 'true'"; - JsonValue _t434; - _t434 = Json_Null(); - return _t434; - } - endif183:; - _t435 = (c == 102); - if (!_t435) goto endif187; - { - bool _t436; - _t436 = JsonParser_Match(p, "false"); - if (!_t436) goto endif189; - { - JsonValue _t437; - _t437 = Json_Bool(0); - return _t437; - } - endif189:; - p->error = "Expected 'false'"; - JsonValue _t438; - _t438 = Json_Null(); - return _t438; - } - endif187:; - _t439 = (c == 110); - if (!_t439) goto endif191; - { - bool _t440; - _t440 = JsonParser_Match(p, "null"); - if (!_t440) goto endif193; - { - JsonValue _t441; - _t441 = Json_Null(); - return _t441; - } - endif193:; - p->error = "Expected 'null'"; - JsonValue _t442; - _t442 = Json_Null(); - return _t442; - } - endif191:; + endif180:; bool __or_tmp_7; bool __and_tmp_8; - _t443 = (c >= 48); - if (!_t443) goto else194; - _t444 = (c <= 57); - *(bool*)&__and_tmp_8 = _t444; - goto endif195; - else194:; + _t434 = (c >= 48); + if (!_t434) goto else183; + _t435 = (c <= 57); + *(bool*)&__and_tmp_8 = _t435; + goto endif184; + else183:; *(bool*)&__and_tmp_8 = 0; - endif195:; - bool _t445; - _t445 = *(bool*)&__and_tmp_8; - if (!_t445) goto else196; + endif184:; + bool _t436; + _t436 = *(bool*)&__and_tmp_8; + if (!_t436) goto else185; *(bool*)&__or_tmp_7 = 1; - goto endif197; - else196:; - _t446 = (c == 45); - *(bool*)&__or_tmp_7 = _t446; - endif197:; - bool _t447; - _t447 = *(bool*)&__or_tmp_7; - if (!_t447) goto endif199; + goto endif186; + else185:; + _t437 = (c == 45); + *(bool*)&__or_tmp_7 = _t437; + endif186:; + bool _t438; + _t438 = *(bool*)&__or_tmp_7; + if (!_t438) goto endif188; { - JsonValue _t448; - _t448 = JsonParser_ParseNumber(p); - return _t448; + JsonValue _t439; + _t439 = JsonParser_ParseNumber(p); + return _t439; } - endif199:; + endif188:; p->error = "Unexpected character"; - JsonValue _t449; - _t449 = Json_Null(); - return _t449; + JsonValue _t440; + _t440 = Json_Null(); + return _t440; } JsonValue Json_Parse(const char* s) { - JsonParser _t451; - void* _t452; - void* _t454; - int _t456; - int _t459; + JsonParser _t442; + void* _t443; + void* _t445; + int _t447; + int _t450; JsonParser p; - unsigned int _t450; - _t450 = String_Len(s); - _t451 = (JsonParser){.src = s, .pos = 0, .len = _t450, .error = ""}; - p = _t451; + unsigned int _t441; + _t441 = String_Len(s); + _t442 = (JsonParser){.src = s, .pos = 0, .len = _t441, .error = ""}; + p = _t442; JsonValue result; - _t452 = &p; - JsonValue _t453; - _t453 = JsonParser_ParseValue(_t452); - result = _t453; - _t454 = &p; - JsonParser_SkipWhitespace(_t454); + _t443 = &p; + JsonValue _t444; + _t444 = JsonParser_ParseValue(_t443); + result = _t444; + _t445 = &p; + JsonParser_SkipWhitespace(_t445); bool __and_tmp_9; - const char* _t455; - _t455 = p.error; - _t456 = (_t455 == ""); - if (!_t456) goto else200; - unsigned int _t457; - _t457 = p.pos; - unsigned int _t458; - _t458 = p.len; - _t459 = (_t457 != _t458); - *(bool*)&__and_tmp_9 = _t459; - goto endif201; - else200:; + const char* _t446; + _t446 = p.error; + _t447 = (_t446 == ""); + if (!_t447) goto else189; + unsigned int _t448; + _t448 = p.pos; + unsigned int _t449; + _t449 = p.len; + _t450 = (_t448 != _t449); + *(bool*)&__and_tmp_9 = _t450; + goto endif190; + else189:; *(bool*)&__and_tmp_9 = 0; - endif201:; - bool _t460; - _t460 = *(bool*)&__and_tmp_9; - if (!_t460) goto endif203; + endif190:; + bool _t451; + _t451 = *(bool*)&__and_tmp_9; + if (!_t451) goto endif192; { p.error = "Trailing data after JSON value"; - JsonValue _t461; - _t461 = Json_Null(); - return _t461; + JsonValue _t452; + _t452 = Json_Null(); + return _t452; } - endif203:; + endif192:; return result; } void Json_StringifyImpl(StringBuilder* sb, JsonValue v) { - int _t463; - int _t465; - int _t468; + int _t454; + int _t456; + int _t459; + int _t462; + char _t463; + char _t465; + int _t467; + char _t468; + int _t470; int _t471; char _t472; - char _t474; - int _t476; - char _t477; - int _t479; - int _t480; - char _t481; - int _t484; - char _t485; - int _t487; + int _t475; + char _t476; + int _t478; + char _t479; + int _t481; + int _t482; + char _t483; + char _t484; + char _t487; char _t488; - int _t490; int _t491; char _t492; - char _t493; - char _t496; - char _t497; - int _t500; - char _t501; - int _t462; - _t462 = v.tag; - _t463 = (_t462 == JsonTagNull); - if (!_t463) goto endif205; + int _t453; + _t453 = v.tag; + _t454 = (_t453 == JsonTagNull); + if (!_t454) goto endif194; { StringBuilder_Append(sb, "null"); return; } - endif205:; - int _t464; - _t464 = v.tag; - _t465 = (_t464 == JsonTagBool); - if (!_t465) goto endif207; + endif194:; + int _t455; + _t455 = v.tag; + _t456 = (_t455 == JsonTagBool); + if (!_t456) goto endif196; { - bool _t466; - _t466 = v.boolVal; - if (!_t466) goto else208; + bool _t457; + _t457 = v.boolVal; + if (!_t457) goto else197; { StringBuilder_Append(sb, "true"); } - goto endif209; - else208:; + goto endif198; + else197:; { StringBuilder_Append(sb, "false"); } - endif209:; + endif198:; return; } - endif207:; - int _t467; - _t467 = v.tag; - _t468 = (_t467 == JsonTagNumber); - if (!_t468) goto endif211; + endif196:; + int _t458; + _t458 = v.tag; + _t459 = (_t458 == JsonTagNumber); + if (!_t459) goto endif200; { - double _t469; - _t469 = v.numVal; - StringBuilder_AppendFloat(sb, _t469); + double _t460; + _t460 = v.numVal; + StringBuilder_AppendFloat(sb, _t460); return; } - endif211:; - int _t470; - _t470 = v.tag; - _t471 = (_t470 == JsonTagString); - if (!_t471) goto endif213; + endif200:; + int _t461; + _t461 = v.tag; + _t462 = (_t461 == JsonTagString); + if (!_t462) goto endif202; { - _t472 = (char)34; + _t463 = (char)34; + StringBuilder_AppendChar(sb, _t463); + const char* _t464; + _t464 = v.strVal; + StringBuilder_Append(sb, _t464); + _t465 = (char)34; + StringBuilder_AppendChar(sb, _t465); + return; + } + endif202:; + int _t466; + _t466 = v.tag; + _t467 = (_t466 == JsonTagArray); + if (!_t467) goto endif204; + { + _t468 = (char)91; + StringBuilder_AppendChar(sb, _t468); + unsigned int i; + i = 0; + while205:; + unsigned int _t469; + _t469 = v.arrLen; + _t470 = (i < _t469); + if (!_t470) goto wend206; + { + _t471 = (i > 0); + if (!_t471) goto endif208; + { + _t472 = (char)44; StringBuilder_AppendChar(sb, _t472); - const char* _t473; - _t473 = v.strVal; - StringBuilder_Append(sb, _t473); - _t474 = (char)34; - StringBuilder_AppendChar(sb, _t474); + } + endif208:; + JsonValue* _t473; + _t473 = v.arrData; + JsonValue _t474; + _t474 = _t473[i]; + Json_StringifyImpl(sb, _t474); + _t475 = i + 1; + i = _t475; + } + goto while205; + wend206:; + _t476 = (char)93; + StringBuilder_AppendChar(sb, _t476); return; } - endif213:; - int _t475; - _t475 = v.tag; - _t476 = (_t475 == JsonTagArray); - if (!_t476) goto endif215; + endif204:; + int _t477; + _t477 = v.tag; + _t478 = (_t477 == JsonTagObject); + if (!_t478) goto endif210; { - _t477 = (char)91; - StringBuilder_AppendChar(sb, _t477); + _t479 = (char)123; + StringBuilder_AppendChar(sb, _t479); unsigned int i; i = 0; - while216:; - unsigned int _t478; - _t478 = v.arrLen; - _t479 = (i < _t478); - if (!_t479) goto wend218; + while211:; + unsigned int _t480; + _t480 = v.objLen; + _t481 = (i < _t480); + if (!_t481) goto wend212; { - _t480 = (i > 0); - if (!_t480) goto endif220; + _t482 = (i > 0); + if (!_t482) goto endif214; { - _t481 = (char)44; - StringBuilder_AppendChar(sb, _t481); + _t483 = (char)44; + StringBuilder_AppendChar(sb, _t483); } - endif220:; - JsonValue* _t482; - _t482 = v.arrData; - JsonValue _t483; - _t483 = _t482[i]; - Json_StringifyImpl(sb, _t483); - _t484 = i + 1; - i = _t484; - } - goto while216; - wend218:; - _t485 = (char)93; - StringBuilder_AppendChar(sb, _t485); - return; - } - endif215:; - int _t486; - _t486 = v.tag; - _t487 = (_t486 == JsonTagObject); - if (!_t487) goto endif222; - { - _t488 = (char)123; + endif214:; + _t484 = (char)34; + StringBuilder_AppendChar(sb, _t484); + const char** _t485; + _t485 = v.objKeys; + const char* _t486; + _t486 = _t485[i]; + StringBuilder_Append(sb, _t486); + _t487 = (char)34; + StringBuilder_AppendChar(sb, _t487); + _t488 = (char)58; StringBuilder_AppendChar(sb, _t488); - unsigned int i; - i = 0; - while223:; - unsigned int _t489; - _t489 = v.objLen; - _t490 = (i < _t489); - if (!_t490) goto wend225; - { - _t491 = (i > 0); - if (!_t491) goto endif227; - { - _t492 = (char)44; + JsonValue* _t489; + _t489 = v.objValues; + JsonValue _t490; + _t490 = _t489[i]; + Json_StringifyImpl(sb, _t490); + _t491 = i + 1; + i = _t491; + } + goto while211; + wend212:; + _t492 = (char)125; StringBuilder_AppendChar(sb, _t492); - } - endif227:; - _t493 = (char)34; - StringBuilder_AppendChar(sb, _t493); - const char** _t494; - _t494 = v.objKeys; - const char* _t495; - _t495 = _t494[i]; - StringBuilder_Append(sb, _t495); - _t496 = (char)34; - StringBuilder_AppendChar(sb, _t496); - _t497 = (char)58; - StringBuilder_AppendChar(sb, _t497); - JsonValue* _t498; - _t498 = v.objValues; - JsonValue _t499; - _t499 = _t498[i]; - Json_StringifyImpl(sb, _t499); - _t500 = i + 1; - i = _t500; - } - goto while223; - wend225:; - _t501 = (char)125; - StringBuilder_AppendChar(sb, _t501); return; } - endif222:; + endif210:; } const char* Json_Stringify(JsonValue v) { - void* _t503; - void* _t504; + void* _t494; + void* _t495; StringBuilder sb; - StringBuilder _t502; - _t502 = StringBuilder_New(); - sb = _t502; - _t503 = &sb; - Json_StringifyImpl(_t503, v); - _t504 = &sb; - const char* _t505; - _t505 = StringBuilder_Build(_t504); - return _t505; + StringBuilder _t493; + _t493 = StringBuilder_New(); + sb = _t493; + _t494 = &sb; + Json_StringifyImpl(_t494, v); + _t495 = &sb; + const char* _t496; + _t496 = StringBuilder_Build(_t495); + return _t496; } unsigned int String_Len(const char* s) { - unsigned int _t506; - _t506 = bux_strlen(s); - return _t506; + unsigned int _t497; + _t497 = bux_strlen(s); + return _t497; } bool String_IsNull(const char* s) { - int _t508; - int _t507; - _t507 = bux_str_is_null(s); - _t508 = (_t507 != 0); - return _t508; + int _t499; + int _t498; + _t498 = bux_str_is_null(s); + _t499 = (_t498 != 0); + return _t499; } bool String_Eq(const char* a, const char* b) { - int _t510; - int _t509; - _t509 = bux_strcmp(a, b); - _t510 = (_t509 == 0); - return _t510; + int _t501; + int _t500; + _t500 = bux_strcmp(a, b); + _t501 = (_t500 == 0); + return _t501; } const char* String_Concat(const char* a, const char* b) { - int _t513; - int _t514; - char* _t516; + int _t504; + int _t505; + char* _t507; unsigned int len_a; - unsigned int _t511; - _t511 = bux_strlen(a); - len_a = _t511; + unsigned int _t502; + _t502 = bux_strlen(a); + len_a = _t502; unsigned int len_b; - unsigned int _t512; - _t512 = bux_strlen(b); - len_b = _t512; + unsigned int _t503; + _t503 = bux_strlen(b); + len_b = _t503; unsigned int total; - _t513 = len_a + len_b; - _t514 = _t513 + 1; - total = _t514; + _t504 = len_a + len_b; + _t505 = _t504 + 1; + total = _t505; char* buf; - void* _t515; - _t515 = bux_alloc(total); - _t516 = (char*)_t515; - buf = _t516; + void* _t506; + _t506 = bux_alloc(total); + _t507 = (char*)_t506; + buf = _t507; bux_strcpy(buf, a); bux_strcat(buf, b); return buf; } const char* String_Copy(const char* s) { - int _t518; - char* _t520; + int _t509; + char* _t511; unsigned int len; - unsigned int _t517; - _t517 = bux_strlen(s); - len = _t517; + unsigned int _t508; + _t508 = bux_strlen(s); + len = _t508; char* buf; - _t518 = len + 1; - void* _t519; - _t519 = bux_alloc(_t518); - _t520 = (char*)_t519; - buf = _t520; + _t509 = len + 1; + void* _t510; + _t510 = bux_alloc(_t509); + _t511 = (char*)_t510; + buf = _t511; bux_strcpy(buf, s); return buf; } bool String_StartsWith(const char* s, const char* prefix) { - int _t523; - int _t525; + int _t514; + int _t516; unsigned int s_len; - unsigned int _t521; - _t521 = bux_strlen(s); - s_len = _t521; + unsigned int _t512; + _t512 = bux_strlen(s); + s_len = _t512; unsigned int p_len; - unsigned int _t522; - _t522 = bux_strlen(prefix); - p_len = _t522; - _t523 = (p_len > s_len); - if (!_t523) goto endif229; + unsigned int _t513; + _t513 = bux_strlen(prefix); + p_len = _t513; + _t514 = (p_len > s_len); + if (!_t514) goto endif216; { return 0; } - endif229:; + endif216:; int r; - int _t524; - _t524 = bux_strncmp(s, prefix, p_len); - r = _t524; - _t525 = (r == 0); - return _t525; + int _t515; + _t515 = bux_strncmp(s, prefix, p_len); + r = _t515; + _t516 = (r == 0); + return _t516; } bool String_EndsWith(const char* s, const char* suffix) { - int _t528; - int _t529; - int _t532; + int _t519; + int _t520; + int _t523; unsigned int s_len; - unsigned int _t526; - _t526 = bux_strlen(s); - s_len = _t526; + unsigned int _t517; + _t517 = bux_strlen(s); + s_len = _t517; unsigned int suf_len; - unsigned int _t527; - _t527 = bux_strlen(suffix); - suf_len = _t527; - _t528 = (suf_len > s_len); - if (!_t528) goto endif231; + unsigned int _t518; + _t518 = bux_strlen(suffix); + suf_len = _t518; + _t519 = (suf_len > s_len); + if (!_t519) goto endif218; { return 0; } - endif231:; + endif218:; unsigned int start; - _t529 = s_len - suf_len; - start = _t529; + _t520 = s_len - suf_len; + start = _t520; const char* tail; - const char* _t530; - _t530 = bux_str_slice(s, start, suf_len); - tail = _t530; + const char* _t521; + _t521 = bux_str_slice(s, start, suf_len); + tail = _t521; bool eq; - int _t531; - _t531 = bux_strcmp(tail, suffix); - _t532 = (_t531 == 0); - eq = _t532; + int _t522; + _t522 = bux_strcmp(tail, suffix); + _t523 = (_t522 == 0); + eq = _t523; return eq; } bool String_Contains(const char* s, const char* substr) { - int _t534; + int _t525; int r; - int _t533; - _t533 = bux_str_contains(s, substr); - r = _t533; - _t534 = (r != 0); - return _t534; + int _t524; + _t524 = bux_str_contains(s, substr); + r = _t524; + _t525 = (r != 0); + return _t525; } const char* String_Slice(const char* s, unsigned int start, unsigned int len) { - const char* _t535; - _t535 = bux_str_slice(s, start, len); - return _t535; + const char* _t526; + _t526 = bux_str_slice(s, start, len); + return _t526; } const char* String_Trim(const char* s) { - const char* _t536; - _t536 = bux_str_trim(s); - return _t536; + const char* _t527; + _t527 = bux_str_trim(s); + return _t527; } const char* String_TrimLeft(const char* s) { - const char* _t537; - _t537 = bux_str_trim_left(s); - return _t537; + const char* _t528; + _t528 = bux_str_trim_left(s); + return _t528; } const char* String_TrimRight(const char* s) { - const char* _t538; - _t538 = bux_str_trim_right(s); - return _t538; + const char* _t529; + _t529 = bux_str_trim_right(s); + return _t529; } const char* String_FromInt(int64_t n) { - const char* _t539; - _t539 = bux_int_to_str(n); - return _t539; + const char* _t530; + _t530 = bux_int_to_str(n); + return _t530; } int64_t String_ToInt(const char* s) { - int64_t _t540; - _t540 = bux_str_to_int(s); - return _t540; + int64_t _t531; + _t531 = bux_str_to_int(s); + return _t531; } StringBuilder StringBuilder_New(void) { - StringBuilder _t542; - void* _t541; - _t541 = bux_sb_new(64); - _t542 = (StringBuilder){.handle = _t541}; - return _t542; + StringBuilder _t533; + void* _t532; + _t532 = bux_sb_new(64); + _t533 = (StringBuilder){.handle = _t532}; + return _t533; } StringBuilder StringBuilder_NewCap(unsigned int cap) { - StringBuilder _t544; - void* _t543; - _t543 = bux_sb_new(cap); - _t544 = (StringBuilder){.handle = _t543}; - return _t544; + StringBuilder _t535; + void* _t534; + _t534 = bux_sb_new(cap); + _t535 = (StringBuilder){.handle = _t534}; + return _t535; } void StringBuilder_Append(StringBuilder* sb, const char* s) { - void* _t545; - _t545 = sb->handle; - bux_sb_append(_t545, s); + void* _t536; + _t536 = sb->handle; + bux_sb_append(_t536, s); } void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) { - void* _t546; - _t546 = sb->handle; - bux_sb_append_int(_t546, n); + void* _t537; + _t537 = sb->handle; + bux_sb_append_int(_t537, n); } void StringBuilder_AppendFloat(StringBuilder* sb, double f) { - void* _t547; - _t547 = sb->handle; - bux_sb_append_float(_t547, f); + void* _t538; + _t538 = sb->handle; + bux_sb_append_float(_t538, f); } void StringBuilder_AppendChar(StringBuilder* sb, char c) { - void* _t548; - _t548 = sb->handle; - bux_sb_append_char(_t548, c); + void* _t539; + _t539 = sb->handle; + bux_sb_append_char(_t539, c); } const char* StringBuilder_Build(StringBuilder* sb) { - void* _t549; - _t549 = sb->handle; - const char* _t550; - _t550 = bux_sb_build(_t549); - return _t550; + void* _t540; + _t540 = sb->handle; + const char* _t541; + _t541 = bux_sb_build(_t540); + return _t541; } void StringBuilder_Free(StringBuilder* sb) { - void* _t551; - _t551 = sb->handle; - bux_sb_free(_t551); + void* _t542; + _t542 = sb->handle; + bux_sb_free(_t542); } unsigned int String_SplitCount(const char* s, const char* delim) { - unsigned int _t552; - _t552 = bux_str_split_count(s, delim); - return _t552; + unsigned int _t543; + _t543 = bux_str_split_count(s, delim); + return _t543; } const char* String_SplitPart(const char* s, const char* delim, unsigned int index) { - const char* _t553; - _t553 = bux_str_split_part(s, delim, index); - return _t553; + const char* _t544; + _t544 = bux_str_split_part(s, delim, index); + return _t544; } const char* String_Join2(const char* a, const char* b, const char* sep) { - const char* _t554; - _t554 = bux_str_join2(a, b, sep); - return _t554; + const char* _t545; + _t545 = bux_str_join2(a, b, sep); + return _t545; } const char* String_Chars(const char* s, unsigned int index) { - const char* _t555; - _t555 = bux_str_slice(s, index, 1); - return _t555; + const char* _t546; + _t546 = bux_str_slice(s, index, 1); + return _t546; } const char* String_Find(const char* haystack, const char* needle) { - const char* _t556; - _t556 = bux_strstr(haystack, needle); - return _t556; + const char* _t547; + _t547 = bux_strstr(haystack, needle); + return _t547; } unsigned int String_Offset(const char* pos, const char* base) { - unsigned int _t557; - _t557 = bux_str_offset(pos, base); - return _t557; + unsigned int _t548; + _t548 = bux_str_offset(pos, base); + return _t548; } const char* String_Replace(const char* s, const char* old, const char* new) { - int _t563; - int _t565; - int _t566; + int _t554; + int _t556; + int _t557; const char* pos; - const char* _t558; - _t558 = bux_strstr(s, old); - pos = _t558; - bool _t559; - _t559 = String_IsNull(pos); - if (!_t559) goto endif233; + const char* _t549; + _t549 = bux_strstr(s, old); + pos = _t549; + bool _t550; + _t550 = String_IsNull(pos); + if (!_t550) goto endif220; { return s; } - endif233:; + endif220:; unsigned int oldLen; - unsigned int _t560; - _t560 = bux_strlen(old); - oldLen = _t560; + unsigned int _t551; + _t551 = bux_strlen(old); + oldLen = _t551; unsigned int prefixLen; - unsigned int _t561; - _t561 = String_Offset(pos, s); - prefixLen = _t561; + unsigned int _t552; + _t552 = String_Offset(pos, s); + prefixLen = _t552; const char* prefix; - const char* _t562; - _t562 = bux_str_slice(s, 0, prefixLen); - prefix = _t562; + const char* _t553; + _t553 = bux_str_slice(s, 0, prefixLen); + prefix = _t553; const char* suffix; - _t563 = prefixLen + oldLen; - unsigned int _t564; - _t564 = bux_strlen(s); - _t565 = _t564 - prefixLen; - _t566 = _t565 - oldLen; - const char* _t567; - _t567 = bux_str_slice(s, _t563, _t566); - suffix = _t567; + _t554 = prefixLen + oldLen; + unsigned int _t555; + _t555 = bux_strlen(s); + _t556 = _t555 - prefixLen; + _t557 = _t556 - oldLen; + const char* _t558; + _t558 = bux_str_slice(s, _t554, _t557); + suffix = _t558; const char* temp; - const char* _t568; - _t568 = String_Concat(prefix, new); - temp = _t568; + const char* _t559; + _t559 = String_Concat(prefix, new); + temp = _t559; const char* result; - const char* _t569; - _t569 = String_Concat(temp, suffix); - result = _t569; + const char* _t560; + _t560 = String_Concat(temp, suffix); + result = _t560; return result; } double String_ToFloat(const char* s) { - double _t570; - _t570 = bux_str_to_float(s); - return _t570; + double _t561; + _t561 = bux_str_to_float(s); + return _t561; } const char* String_FromBool(bool b) { - if (!b) goto endif235; + if (!b) goto endif222; { return "true"; } - endif235:; + endif222:; return "false"; } const char* String_FromFloat(double f) { - const char* _t571; - _t571 = bux_float_to_string(f); - return _t571; + const char* _t562; + _t562 = bux_float_to_string(f); + return _t562; } const char* String_Format1(const char* pattern, const char* a0) { - const char* _t572; - _t572 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); - return _t572; + const char* _t563; + _t563 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); + return _t563; } const char* String_Format2(const char* pattern, const char* a0, const char* a1) { - const char* _t573; - _t573 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); - return _t573; + const char* _t564; + _t564 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); + return _t564; } const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) { - const char* _t574; - _t574 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); - return _t574; + const char* _t565; + _t565 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); + return _t565; } void Channel_SendInt(Channel_int* ch, int value) { - void* _t576; - void* _t577; - void* _t575; - _t575 = ch->handle; - _t576 = &value; - _t577 = (void*)_t576; - bux_channel_send(_t575, _t577); + void* _t567; + void* _t568; + void* _t566; + _t566 = ch->handle; + _t567 = &value; + _t568 = (void*)_t567; + bux_channel_send(_t566, _t568); } int Channel_RecvInt(Channel_int* ch) { - void* _t579; - void* _t580; + void* _t570; + void* _t571; int result; result = 0; - void* _t578; - _t578 = ch->handle; - _t579 = &result; - _t580 = (void*)_t579; - bux_channel_recv(_t578, _t580); + void* _t569; + _t569 = ch->handle; + _t570 = &result; + _t571 = (void*)_t570; + bux_channel_recv(_t569, _t571); return result; } void Channel_SendFloat64(Channel_float64* ch, double value) { - void* _t582; - void* _t583; - void* _t581; - _t581 = ch->handle; - _t582 = &value; - _t583 = (void*)_t582; - bux_channel_send(_t581, _t583); + void* _t573; + void* _t574; + void* _t572; + _t572 = ch->handle; + _t573 = &value; + _t574 = (void*)_t573; + bux_channel_send(_t572, _t574); } double Channel_RecvFloat64(Channel_float64* ch) { - void* _t585; - void* _t586; + void* _t576; + void* _t577; double result; result = 0.0; - void* _t584; - _t584 = ch->handle; - _t585 = &result; - _t586 = (void*)_t585; - bux_channel_recv(_t584, _t586); + void* _t575; + _t575 = ch->handle; + _t576 = &result; + _t577 = (void*)_t576; + bux_channel_recv(_t575, _t577); return result; } const char* Hash_Sha1(const char* data) { - int _t588; + int _t579; int len; - unsigned int _t587; - _t587 = String_Len(data); - _t588 = (int)_t587; - len = _t588; + unsigned int _t578; + _t578 = String_Len(data); + _t579 = (int)_t578; + len = _t579; void* buf; - void* _t589; - _t589 = Alloc(20); - buf = _t589; + void* _t580; + _t580 = Alloc(20); + buf = _t580; bux_sha1(data, len, buf); const char* result; - const char* _t590; - _t590 = bux_bytes_to_hex(buf, 20); - result = _t590; + const char* _t581; + _t581 = bux_bytes_to_hex(buf, 20); + result = _t581; Free(buf); return result; } const char* Hash_Sha256(const char* data) { - int _t592; + int _t583; int len; - unsigned int _t591; - _t591 = String_Len(data); - _t592 = (int)_t591; - len = _t592; + unsigned int _t582; + _t582 = String_Len(data); + _t583 = (int)_t582; + len = _t583; void* buf; - void* _t593; - _t593 = Alloc(32); - buf = _t593; + void* _t584; + _t584 = Alloc(32); + buf = _t584; bux_sha256(data, len, buf); const char* result; - const char* _t594; - _t594 = bux_bytes_to_hex(buf, 32); - result = _t594; + const char* _t585; + _t585 = bux_bytes_to_hex(buf, 32); + result = _t585; Free(buf); return result; } const char* Hash_Sha384(const char* data) { - int _t596; + int _t587; int len; - unsigned int _t595; - _t595 = String_Len(data); - _t596 = (int)_t595; - len = _t596; + unsigned int _t586; + _t586 = String_Len(data); + _t587 = (int)_t586; + len = _t587; void* buf; - void* _t597; - _t597 = Alloc(48); - buf = _t597; + void* _t588; + _t588 = Alloc(48); + buf = _t588; bux_sha384(data, len, buf); const char* result; - const char* _t598; - _t598 = bux_bytes_to_hex(buf, 48); - result = _t598; + const char* _t589; + _t589 = bux_bytes_to_hex(buf, 48); + result = _t589; Free(buf); return result; } const char* Hash_Sha512(const char* data) { - int _t600; + int _t591; int len; - unsigned int _t599; - _t599 = String_Len(data); - _t600 = (int)_t599; - len = _t600; + unsigned int _t590; + _t590 = String_Len(data); + _t591 = (int)_t590; + len = _t591; void* buf; - void* _t601; - _t601 = Alloc(64); - buf = _t601; + void* _t592; + _t592 = Alloc(64); + buf = _t592; bux_sha512(data, len, buf); const char* result; - const char* _t602; - _t602 = bux_bytes_to_hex(buf, 64); - result = _t602; + const char* _t593; + _t593 = bux_bytes_to_hex(buf, 64); + result = _t593; Free(buf); return result; } void Hash_Sha256Raw(const char* data, void* out) { - int _t604; - unsigned int _t603; - _t603 = String_Len(data); - _t604 = (int)_t603; - bux_sha256(data, _t604, out); + int _t595; + unsigned int _t594; + _t594 = String_Len(data); + _t595 = (int)_t594; + bux_sha256(data, _t595, out); } void Hash_Sha384Raw(const char* data, void* out) { - int _t606; - unsigned int _t605; - _t605 = String_Len(data); - _t606 = (int)_t605; - bux_sha384(data, _t606, out); + int _t597; + unsigned int _t596; + _t596 = String_Len(data); + _t597 = (int)_t596; + bux_sha384(data, _t597, out); } void Hash_Sha512Raw(const char* data, void* out) { - int _t608; - unsigned int _t607; - _t607 = String_Len(data); - _t608 = (int)_t607; - bux_sha512(data, _t608, out); + int _t599; + unsigned int _t598; + _t598 = String_Len(data); + _t599 = (int)_t598; + bux_sha512(data, _t599, out); } int Hash_Sha1Size(void) { @@ -3358,1466 +3357,1466 @@ int Hash_Sha512Size(void) { } const char* Base64_Encode(const char* s) { - int _t610; - unsigned int _t609; - _t609 = String_Len(s); - _t610 = (int)_t609; - const char* _t611; - _t611 = bux_base64_encode(s, _t610); - return _t611; + int _t601; + unsigned int _t600; + _t600 = String_Len(s); + _t601 = (int)_t600; + const char* _t602; + _t602 = bux_base64_encode(s, _t601); + return _t602; } const char* Base64_Decode(const char* s) { - int _t613; - void* _t614; + int _t604; + void* _t605; int outlen; outlen = 0; - unsigned int _t612; - _t612 = String_Len(s); - _t613 = (int)_t612; - _t614 = &outlen; - const char* _t615; - _t615 = bux_base64_decode(s, _t613, _t614); - return _t615; + unsigned int _t603; + _t603 = String_Len(s); + _t604 = (int)_t603; + _t605 = &outlen; + const char* _t606; + _t606 = bux_base64_decode(s, _t604, _t605); + return _t606; } const char* Base64URL_Encode(const char* s) { - int _t617; - unsigned int _t616; - _t616 = String_Len(s); - _t617 = (int)_t616; - const char* _t618; - _t618 = bux_base64url_encode(s, _t617); - return _t618; + int _t608; + unsigned int _t607; + _t607 = String_Len(s); + _t608 = (int)_t607; + const char* _t609; + _t609 = bux_base64url_encode(s, _t608); + return _t609; } const char* Base64URL_Decode(const char* s) { - int _t620; - void* _t621; + int _t611; + void* _t612; int outlen; outlen = 0; - unsigned int _t619; - _t619 = String_Len(s); - _t620 = (int)_t619; - _t621 = &outlen; - const char* _t622; - _t622 = bux_base64url_decode(s, _t620, _t621); - return _t622; + unsigned int _t610; + _t610 = String_Len(s); + _t611 = (int)_t610; + _t612 = &outlen; + const char* _t613; + _t613 = bux_base64url_decode(s, _t611, _t612); + return _t613; } const char* Hmac_Sha256(const char* key, const char* message) { - int _t624; - int _t626; + int _t615; + int _t617; int kl; - unsigned int _t623; - _t623 = String_Len(key); - _t624 = (int)_t623; - kl = _t624; + unsigned int _t614; + _t614 = String_Len(key); + _t615 = (int)_t614; + kl = _t615; int ml; - unsigned int _t625; - _t625 = String_Len(message); - _t626 = (int)_t625; - ml = _t626; + unsigned int _t616; + _t616 = String_Len(message); + _t617 = (int)_t616; + ml = _t617; void* buf; - void* _t627; - _t627 = Alloc(32); - buf = _t627; + void* _t618; + _t618 = Alloc(32); + buf = _t618; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - const char* _t628; - _t628 = bux_bytes_to_hex(buf, 32); - result = _t628; + const char* _t619; + _t619 = bux_bytes_to_hex(buf, 32); + result = _t619; Free(buf); return result; } void Hmac_Sha256Raw(const char* key, const char* message, void* out) { - int _t630; - int _t632; - unsigned int _t629; - _t629 = String_Len(key); - _t630 = (int)_t629; - unsigned int _t631; - _t631 = String_Len(message); - _t632 = (int)_t631; - bux_hmac_sha256(key, _t630, message, _t632, out); + int _t621; + int _t623; + unsigned int _t620; + _t620 = String_Len(key); + _t621 = (int)_t620; + unsigned int _t622; + _t622 = String_Len(message); + _t623 = (int)_t622; + bux_hmac_sha256(key, _t621, message, _t623, out); } const char* Hmac_Sha256Base64(const char* key, const char* message) { - int _t634; - int _t636; - const char* _t638; + int _t625; + int _t627; + const char* _t629; int kl; - unsigned int _t633; - _t633 = String_Len(key); - _t634 = (int)_t633; - kl = _t634; + unsigned int _t624; + _t624 = String_Len(key); + _t625 = (int)_t624; + kl = _t625; int ml; - unsigned int _t635; - _t635 = String_Len(message); - _t636 = (int)_t635; - ml = _t636; + unsigned int _t626; + _t626 = String_Len(message); + _t627 = (int)_t626; + ml = _t627; void* buf; - void* _t637; - _t637 = Alloc(32); - buf = _t637; + void* _t628; + _t628 = Alloc(32); + buf = _t628; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - _t638 = (const char*)buf; - const char* _t639; - _t639 = bux_base64_encode(_t638, 32); - result = _t639; + _t629 = (const char*)buf; + const char* _t630; + _t630 = bux_base64_encode(_t629, 32); + result = _t630; Free(buf); return result; } const char* Hmac_Sha384(const char* key, const char* message) { - int _t641; - int _t643; + int _t632; + int _t634; int kl; - unsigned int _t640; - _t640 = String_Len(key); - _t641 = (int)_t640; - kl = _t641; + unsigned int _t631; + _t631 = String_Len(key); + _t632 = (int)_t631; + kl = _t632; int ml; - unsigned int _t642; - _t642 = String_Len(message); - _t643 = (int)_t642; - ml = _t643; + unsigned int _t633; + _t633 = String_Len(message); + _t634 = (int)_t633; + ml = _t634; void* buf; - void* _t644; - _t644 = Alloc(48); - buf = _t644; + void* _t635; + _t635 = Alloc(48); + buf = _t635; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - const char* _t645; - _t645 = bux_bytes_to_hex(buf, 48); - result = _t645; + const char* _t636; + _t636 = bux_bytes_to_hex(buf, 48); + result = _t636; Free(buf); return result; } void Hmac_Sha384Raw(const char* key, const char* message, void* out) { - int _t647; - int _t649; - unsigned int _t646; - _t646 = String_Len(key); - _t647 = (int)_t646; - unsigned int _t648; - _t648 = String_Len(message); - _t649 = (int)_t648; - bux_hmac_sha384(key, _t647, message, _t649, out); + int _t638; + int _t640; + unsigned int _t637; + _t637 = String_Len(key); + _t638 = (int)_t637; + unsigned int _t639; + _t639 = String_Len(message); + _t640 = (int)_t639; + bux_hmac_sha384(key, _t638, message, _t640, out); } const char* Hmac_Sha384Base64(const char* key, const char* message) { - int _t651; - int _t653; - const char* _t655; + int _t642; + int _t644; + const char* _t646; int kl; - unsigned int _t650; - _t650 = String_Len(key); - _t651 = (int)_t650; - kl = _t651; + unsigned int _t641; + _t641 = String_Len(key); + _t642 = (int)_t641; + kl = _t642; int ml; - unsigned int _t652; - _t652 = String_Len(message); - _t653 = (int)_t652; - ml = _t653; + unsigned int _t643; + _t643 = String_Len(message); + _t644 = (int)_t643; + ml = _t644; void* buf; - void* _t654; - _t654 = Alloc(48); - buf = _t654; + void* _t645; + _t645 = Alloc(48); + buf = _t645; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - _t655 = (const char*)buf; - const char* _t656; - _t656 = bux_base64_encode(_t655, 48); - result = _t656; + _t646 = (const char*)buf; + const char* _t647; + _t647 = bux_base64_encode(_t646, 48); + result = _t647; Free(buf); return result; } const char* Hmac_Sha512(const char* key, const char* message) { - int _t658; - int _t660; + int _t649; + int _t651; int kl; - unsigned int _t657; - _t657 = String_Len(key); - _t658 = (int)_t657; - kl = _t658; + unsigned int _t648; + _t648 = String_Len(key); + _t649 = (int)_t648; + kl = _t649; int ml; - unsigned int _t659; - _t659 = String_Len(message); - _t660 = (int)_t659; - ml = _t660; + unsigned int _t650; + _t650 = String_Len(message); + _t651 = (int)_t650; + ml = _t651; void* buf; - void* _t661; - _t661 = Alloc(64); - buf = _t661; + void* _t652; + _t652 = Alloc(64); + buf = _t652; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - const char* _t662; - _t662 = bux_bytes_to_hex(buf, 64); - result = _t662; + const char* _t653; + _t653 = bux_bytes_to_hex(buf, 64); + result = _t653; Free(buf); return result; } void Hmac_Sha512Raw(const char* key, const char* message, void* out) { - int _t664; - int _t666; - unsigned int _t663; - _t663 = String_Len(key); - _t664 = (int)_t663; - unsigned int _t665; - _t665 = String_Len(message); - _t666 = (int)_t665; - bux_hmac_sha512(key, _t664, message, _t666, out); + int _t655; + int _t657; + unsigned int _t654; + _t654 = String_Len(key); + _t655 = (int)_t654; + unsigned int _t656; + _t656 = String_Len(message); + _t657 = (int)_t656; + bux_hmac_sha512(key, _t655, message, _t657, out); } const char* Hmac_Sha512Base64(const char* key, const char* message) { - int _t668; - int _t670; - const char* _t672; + int _t659; + int _t661; + const char* _t663; int kl; - unsigned int _t667; - _t667 = String_Len(key); - _t668 = (int)_t667; - kl = _t668; + unsigned int _t658; + _t658 = String_Len(key); + _t659 = (int)_t658; + kl = _t659; int ml; - unsigned int _t669; - _t669 = String_Len(message); - _t670 = (int)_t669; - ml = _t670; + unsigned int _t660; + _t660 = String_Len(message); + _t661 = (int)_t660; + ml = _t661; void* buf; - void* _t671; - _t671 = Alloc(64); - buf = _t671; + void* _t662; + _t662 = Alloc(64); + buf = _t662; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - _t672 = (const char*)buf; - const char* _t673; - _t673 = bux_base64_encode(_t672, 64); - result = _t673; + _t663 = (const char*)buf; + const char* _t664; + _t664 = bux_base64_encode(_t663, 64); + result = _t664; Free(buf); return result; } const char* Random_Bytes(int n) { - int _t674; - unsigned int _t675; - int _t678; - const char* _t679; - _t674 = (n <= 0); - if (!_t674) goto endif237; + int _t665; + unsigned int _t666; + int _t669; + const char* _t670; + _t665 = (n <= 0); + if (!_t665) goto endif224; { return ""; } - endif237:; + endif224:; void* buf; - _t675 = (unsigned int)n; - void* _t676; - _t676 = Alloc(_t675); - buf = _t676; - int _t677; - _t677 = bux_random_bytes(buf, n); - _t678 = (_t677 != 1); - if (!_t678) goto endif239; + _t666 = (unsigned int)n; + void* _t667; + _t667 = Alloc(_t666); + buf = _t667; + int _t668; + _t668 = bux_random_bytes(buf, n); + _t669 = (_t668 != 1); + if (!_t669) goto endif226; { Free(buf); return ""; } - endif239:; - _t679 = (const char*)buf; - return _t679; + endif226:; + _t670 = (const char*)buf; + return _t670; } const char* Random_Hex(int n) { - int _t680; - unsigned int _t681; - int _t684; - _t680 = (n <= 0); - if (!_t680) goto endif241; + int _t671; + unsigned int _t672; + int _t675; + _t671 = (n <= 0); + if (!_t671) goto endif228; { return ""; } - endif241:; + endif228:; void* buf; - _t681 = (unsigned int)n; - void* _t682; - _t682 = Alloc(_t681); - buf = _t682; - int _t683; - _t683 = bux_random_bytes(buf, n); - _t684 = (_t683 != 1); - if (!_t684) goto endif243; + _t672 = (unsigned int)n; + void* _t673; + _t673 = Alloc(_t672); + buf = _t673; + int _t674; + _t674 = bux_random_bytes(buf, n); + _t675 = (_t674 != 1); + if (!_t675) goto endif230; { Free(buf); return ""; } - endif243:; + endif230:; const char* result; - const char* _t685; - _t685 = bux_bytes_to_hex(buf, n); - result = _t685; + const char* _t676; + _t676 = bux_bytes_to_hex(buf, n); + result = _t676; Free(buf); return result; } const char* Random_Base64(int n) { - int _t686; - unsigned int _t687; - int _t690; - const char* _t691; - _t686 = (n <= 0); - if (!_t686) goto endif245; + int _t677; + unsigned int _t678; + int _t681; + const char* _t682; + _t677 = (n <= 0); + if (!_t677) goto endif232; { return ""; } - endif245:; + endif232:; void* buf; - _t687 = (unsigned int)n; - void* _t688; - _t688 = Alloc(_t687); - buf = _t688; - int _t689; - _t689 = bux_random_bytes(buf, n); - _t690 = (_t689 != 1); - if (!_t690) goto endif247; + _t678 = (unsigned int)n; + void* _t679; + _t679 = Alloc(_t678); + buf = _t679; + int _t680; + _t680 = bux_random_bytes(buf, n); + _t681 = (_t680 != 1); + if (!_t681) goto endif234; { Free(buf); return ""; } - endif247:; + endif234:; const char* result; - _t691 = (const char*)buf; - const char* _t692; - _t692 = bux_base64_encode(_t691, n); - result = _t692; + _t682 = (const char*)buf; + const char* _t683; + _t683 = bux_base64_encode(_t682, n); + result = _t683; Free(buf); return result; } unsigned int Random_Uint32(void) { - int _t695; - unsigned int* _t696; - unsigned int _t697; + int _t686; + unsigned int* _t687; + unsigned int _t688; void* buf; - void* _t693; - _t693 = Alloc(4); - buf = _t693; - int _t694; - _t694 = bux_random_bytes(buf, 4); - _t695 = (_t694 != 1); - if (!_t695) goto endif249; + void* _t684; + _t684 = Alloc(4); + buf = _t684; + int _t685; + _t685 = bux_random_bytes(buf, 4); + _t686 = (_t685 != 1); + if (!_t686) goto endif236; { Free(buf); return 0; } - endif249:; + endif236:; unsigned int* ptr; - _t696 = (unsigned int*)buf; - ptr = _t696; + _t687 = (unsigned int*)buf; + ptr = _t687; unsigned int val; - _t697 = *ptr; - val = _t697; + _t688 = *ptr; + val = _t688; Free(buf); return val; } const char* Aes_GenerateKey(void) { - unsigned int _t698; - int _t701; - const char* _t702; + unsigned int _t689; + int _t692; + const char* _t693; void* buf; - _t698 = (unsigned int)AES_KEY_SIZE; - void* _t699; - _t699 = Alloc(_t698); - buf = _t699; - int _t700; - _t700 = bux_random_bytes(buf, AES_KEY_SIZE); - _t701 = (_t700 != 1); - if (!_t701) goto endif251; + _t689 = (unsigned int)AES_KEY_SIZE; + void* _t690; + _t690 = Alloc(_t689); + buf = _t690; + int _t691; + _t691 = bux_random_bytes(buf, AES_KEY_SIZE); + _t692 = (_t691 != 1); + if (!_t692) goto endif238; { Free(buf); return ""; } - endif251:; - _t702 = (const char*)buf; - return _t702; + endif238:; + _t693 = (const char*)buf; + return _t693; } const char* Aes_GenerateIV(void) { - unsigned int _t703; - int _t706; - const char* _t707; + unsigned int _t694; + int _t697; + const char* _t698; void* buf; - _t703 = (unsigned int)AES_IV_SIZE; - void* _t704; - _t704 = Alloc(_t703); - buf = _t704; - int _t705; - _t705 = bux_random_bytes(buf, AES_IV_SIZE); - _t706 = (_t705 != 1); - if (!_t706) goto endif253; + _t694 = (unsigned int)AES_IV_SIZE; + void* _t695; + _t695 = Alloc(_t694); + buf = _t695; + int _t696; + _t696 = bux_random_bytes(buf, AES_IV_SIZE); + _t697 = (_t696 != 1); + if (!_t697) goto endif240; { Free(buf); return ""; } - endif253:; - _t707 = (const char*)buf; - return _t707; + endif240:; + _t698 = (const char*)buf; + return _t698; } const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv) { - int _t709; - void* _t710; + int _t700; + void* _t701; int outlen; outlen = 0; - unsigned int _t708; - _t708 = String_Len(plain); - _t709 = (int)_t708; - _t710 = &outlen; - const char* _t711; - _t711 = bux_aes_256_cbc_encrypt(plain, _t709, key, iv, _t710); - return _t711; + unsigned int _t699; + _t699 = String_Len(plain); + _t700 = (int)_t699; + _t701 = &outlen; + const char* _t702; + _t702 = bux_aes_256_cbc_encrypt(plain, _t700, key, iv, _t701); + return _t702; } const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv) { - int _t713; - void* _t714; + int _t704; + void* _t705; int outlen; outlen = 0; - unsigned int _t712; - _t712 = String_Len(cipher); - _t713 = (int)_t712; - _t714 = &outlen; - const char* _t715; - _t715 = bux_aes_256_cbc_decrypt(cipher, _t713, key, iv, _t714); - return _t715; + unsigned int _t703; + _t703 = String_Len(cipher); + _t704 = (int)_t703; + _t705 = &outlen; + const char* _t706; + _t706 = bux_aes_256_cbc_decrypt(cipher, _t704, key, iv, _t705); + return _t706; } const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag) { - int _t717; - void* _t718; + int _t708; + void* _t709; int outlen; outlen = 0; - unsigned int _t716; - _t716 = String_Len(plain); - _t717 = (int)_t716; - _t718 = &outlen; - const char* _t719; - _t719 = bux_aes_256_gcm_encrypt(plain, _t717, key, iv, tag, _t718); - return _t719; + unsigned int _t707; + _t707 = String_Len(plain); + _t708 = (int)_t707; + _t709 = &outlen; + const char* _t710; + _t710 = bux_aes_256_gcm_encrypt(plain, _t708, key, iv, tag, _t709); + return _t710; } const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag) { - int _t721; - void* _t722; + int _t712; + void* _t713; int outlen; outlen = 0; - unsigned int _t720; - _t720 = String_Len(cipher); - _t721 = (int)_t720; - _t722 = &outlen; - const char* _t723; - _t723 = bux_aes_256_gcm_decrypt(cipher, _t721, key, iv, tag, _t722); - return _t723; + unsigned int _t711; + _t711 = String_Len(cipher); + _t712 = (int)_t711; + _t713 = &outlen; + const char* _t714; + _t714 = bux_aes_256_gcm_decrypt(cipher, _t712, key, iv, tag, _t713); + return _t714; } const char* Jwt_MakeHeader(JwtAlg alg) { - int _t724; - int _t725; - int _t726; - int _t727; - int _t728; - int _t729; - int _t730; - int _t731; - int _t732; - _t724 = (alg == JwtAlg_HS256); - if (!_t724) goto endif255; + int _t715; + int _t716; + int _t717; + int _t718; + int _t719; + int _t720; + int _t721; + int _t722; + int _t723; + _t715 = (alg == JwtAlg_HS256); + if (!_t715) goto endif242; { return "{\"alg\":\"HS256\",\"typ\":\"JWT\"}"; } - endif255:; - _t725 = (alg == JwtAlg_HS384); - if (!_t725) goto endif257; + endif242:; + _t716 = (alg == JwtAlg_HS384); + if (!_t716) goto endif244; { return "{\"alg\":\"HS384\",\"typ\":\"JWT\"}"; } - endif257:; - _t726 = (alg == JwtAlg_HS512); - if (!_t726) goto endif259; + endif244:; + _t717 = (alg == JwtAlg_HS512); + if (!_t717) goto endif246; { return "{\"alg\":\"HS512\",\"typ\":\"JWT\"}"; } - endif259:; - _t727 = (alg == JwtAlg_RS256); - if (!_t727) goto endif261; + endif246:; + _t718 = (alg == JwtAlg_RS256); + if (!_t718) goto endif248; { return "{\"alg\":\"RS256\",\"typ\":\"JWT\"}"; } - endif261:; - _t728 = (alg == JwtAlg_RS384); - if (!_t728) goto endif263; + endif248:; + _t719 = (alg == JwtAlg_RS384); + if (!_t719) goto endif250; { return "{\"alg\":\"RS384\",\"typ\":\"JWT\"}"; } - endif263:; - _t729 = (alg == JwtAlg_RS512); - if (!_t729) goto endif265; + endif250:; + _t720 = (alg == JwtAlg_RS512); + if (!_t720) goto endif252; { return "{\"alg\":\"RS512\",\"typ\":\"JWT\"}"; } - endif265:; - _t730 = (alg == JwtAlg_ES256); - if (!_t730) goto endif267; + endif252:; + _t721 = (alg == JwtAlg_ES256); + if (!_t721) goto endif254; { return "{\"alg\":\"ES256\",\"typ\":\"JWT\"}"; } - endif267:; - _t731 = (alg == JwtAlg_ES384); - if (!_t731) goto endif269; + endif254:; + _t722 = (alg == JwtAlg_ES384); + if (!_t722) goto endif256; { return "{\"alg\":\"ES384\",\"typ\":\"JWT\"}"; } - endif269:; - _t732 = (alg == JwtAlg_EdDSA); - if (!_t732) goto endif271; + endif256:; + _t723 = (alg == JwtAlg_EdDSA); + if (!_t723) goto endif258; { return "{\"alg\":\"EdDSA\",\"typ\":\"JWT\"}"; } - endif271:; + endif258:; return "{\"alg\":\"none\",\"typ\":\"JWT\"}"; } const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key) { - int _t733; - const char* _t735; - int _t737; - const char* _t739; + int _t724; + const char* _t726; + int _t728; + const char* _t730; + int _t732; + const char* _t734; + int _t736; + int _t739; int _t741; - const char* _t743; - int _t745; - int _t748; - int _t750; - int _t753; - int _t755; - int _t758; - int _t760; - int _t763; - int _t765; - int _t768; - int _t770; - _t733 = (alg == JwtAlg_HS256); - if (!_t733) goto endif273; + int _t744; + int _t746; + int _t749; + int _t751; + int _t754; + int _t756; + int _t759; + int _t761; + _t724 = (alg == JwtAlg_HS256); + if (!_t724) goto endif260; { void* buf; - void* _t734; - _t734 = Alloc(32); - buf = _t734; + void* _t725; + _t725 = Alloc(32); + buf = _t725; Hmac_Sha256Raw(key, signingInput, buf); const char* result; - _t735 = (const char*)buf; - const char* _t736; - _t736 = bux_base64_encode(_t735, 32); - result = _t736; + _t726 = (const char*)buf; + const char* _t727; + _t727 = bux_base64_encode(_t726, 32); + result = _t727; Free(buf); return result; } - endif273:; - _t737 = (alg == JwtAlg_HS384); - if (!_t737) goto endif275; + endif260:; + _t728 = (alg == JwtAlg_HS384); + if (!_t728) goto endif262; { void* buf; - void* _t738; - _t738 = Alloc(48); - buf = _t738; + void* _t729; + _t729 = Alloc(48); + buf = _t729; Hmac_Sha384Raw(key, signingInput, buf); const char* result; - _t739 = (const char*)buf; - const char* _t740; - _t740 = bux_base64_encode(_t739, 48); - result = _t740; + _t730 = (const char*)buf; + const char* _t731; + _t731 = bux_base64_encode(_t730, 48); + result = _t731; Free(buf); return result; } - endif275:; - _t741 = (alg == JwtAlg_HS512); - if (!_t741) goto endif277; + endif262:; + _t732 = (alg == JwtAlg_HS512); + if (!_t732) goto endif264; { void* buf; - void* _t742; - _t742 = Alloc(64); - buf = _t742; + void* _t733; + _t733 = Alloc(64); + buf = _t733; Hmac_Sha512Raw(key, signingInput, buf); const char* result; - _t743 = (const char*)buf; - const char* _t744; - _t744 = bux_base64_encode(_t743, 64); - result = _t744; + _t734 = (const char*)buf; + const char* _t735; + _t735 = bux_base64_encode(_t734, 64); + result = _t735; Free(buf); return result; } - endif277:; - _t745 = (alg == JwtAlg_RS256); - if (!_t745) goto endif279; + endif264:; + _t736 = (alg == JwtAlg_RS256); + if (!_t736) goto endif266; { const char* raw; - const char* _t746; - _t746 = Rsa_SignSha256(key, signingInput); - raw = _t746; - unsigned int _t747; - _t747 = String_Len(raw); - _t748 = (int)_t747; - const char* _t749; - _t749 = bux_base64_encode(raw, _t748); - return _t749; + const char* _t737; + _t737 = Rsa_SignSha256(key, signingInput); + raw = _t737; + unsigned int _t738; + _t738 = String_Len(raw); + _t739 = (int)_t738; + const char* _t740; + _t740 = bux_base64_encode(raw, _t739); + return _t740; } - endif279:; - _t750 = (alg == JwtAlg_RS384); - if (!_t750) goto endif281; + endif266:; + _t741 = (alg == JwtAlg_RS384); + if (!_t741) goto endif268; { const char* raw; - const char* _t751; - _t751 = Rsa_SignSha384(key, signingInput); - raw = _t751; - unsigned int _t752; - _t752 = String_Len(raw); - _t753 = (int)_t752; - const char* _t754; - _t754 = bux_base64_encode(raw, _t753); - return _t754; + const char* _t742; + _t742 = Rsa_SignSha384(key, signingInput); + raw = _t742; + unsigned int _t743; + _t743 = String_Len(raw); + _t744 = (int)_t743; + const char* _t745; + _t745 = bux_base64_encode(raw, _t744); + return _t745; } - endif281:; - _t755 = (alg == JwtAlg_RS512); - if (!_t755) goto endif283; + endif268:; + _t746 = (alg == JwtAlg_RS512); + if (!_t746) goto endif270; { const char* raw; - const char* _t756; - _t756 = Rsa_SignSha512(key, signingInput); - raw = _t756; - unsigned int _t757; - _t757 = String_Len(raw); - _t758 = (int)_t757; - const char* _t759; - _t759 = bux_base64_encode(raw, _t758); - return _t759; + const char* _t747; + _t747 = Rsa_SignSha512(key, signingInput); + raw = _t747; + unsigned int _t748; + _t748 = String_Len(raw); + _t749 = (int)_t748; + const char* _t750; + _t750 = bux_base64_encode(raw, _t749); + return _t750; } - endif283:; - _t760 = (alg == JwtAlg_ES256); - if (!_t760) goto endif285; + endif270:; + _t751 = (alg == JwtAlg_ES256); + if (!_t751) goto endif272; { const char* raw; - const char* _t761; - _t761 = Ecdsa_SignP256(key, signingInput); - raw = _t761; - unsigned int _t762; - _t762 = String_Len(raw); - _t763 = (int)_t762; - const char* _t764; - _t764 = bux_base64_encode(raw, _t763); - return _t764; + const char* _t752; + _t752 = Ecdsa_SignP256(key, signingInput); + raw = _t752; + unsigned int _t753; + _t753 = String_Len(raw); + _t754 = (int)_t753; + const char* _t755; + _t755 = bux_base64_encode(raw, _t754); + return _t755; } - endif285:; - _t765 = (alg == JwtAlg_ES384); - if (!_t765) goto endif287; + endif272:; + _t756 = (alg == JwtAlg_ES384); + if (!_t756) goto endif274; { const char* raw; - const char* _t766; - _t766 = Ecdsa_SignP384(key, signingInput); - raw = _t766; - unsigned int _t767; - _t767 = String_Len(raw); - _t768 = (int)_t767; - const char* _t769; - _t769 = bux_base64_encode(raw, _t768); - return _t769; + const char* _t757; + _t757 = Ecdsa_SignP384(key, signingInput); + raw = _t757; + unsigned int _t758; + _t758 = String_Len(raw); + _t759 = (int)_t758; + const char* _t760; + _t760 = bux_base64_encode(raw, _t759); + return _t760; } - endif287:; - _t770 = (alg == JwtAlg_EdDSA); - if (!_t770) goto endif289; + endif274:; + _t761 = (alg == JwtAlg_EdDSA); + if (!_t761) goto endif276; { - const char* _t771; - _t771 = Ed25519_Sign(key, signingInput); - return _t771; + const char* _t762; + _t762 = Ed25519_Sign(key, signingInput); + return _t762; } - endif289:; + endif276:; return ""; } bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key) { - int _t772; - const char* _t774; - int _t777; - const char* _t779; + int _t763; + const char* _t765; + int _t768; + const char* _t770; + int _t773; + const char* _t775; + int _t778; + int _t780; int _t782; - const char* _t784; - int _t787; - int _t789; - int _t791; - int _t793; - int _t795; - int _t797; - _t772 = (alg == JwtAlg_HS256); - if (!_t772) goto endif291; + int _t784; + int _t786; + int _t788; + _t763 = (alg == JwtAlg_HS256); + if (!_t763) goto endif278; { void* expectBuf; - void* _t773; - _t773 = Alloc(32); - expectBuf = _t773; + void* _t764; + _t764 = Alloc(32); + expectBuf = _t764; Hmac_Sha256Raw(key, signingInput, expectBuf); const char* expectB64; - _t774 = (const char*)expectBuf; - const char* _t775; - _t775 = bux_base64_encode(_t774, 32); - expectB64 = _t775; + _t765 = (const char*)expectBuf; + const char* _t766; + _t766 = bux_base64_encode(_t765, 32); + expectB64 = _t766; Free(expectBuf); - bool _t776; - _t776 = String_Eq(expectB64, signatureB64); - return _t776; + bool _t767; + _t767 = String_Eq(expectB64, signatureB64); + return _t767; } - endif291:; - _t777 = (alg == JwtAlg_HS384); - if (!_t777) goto endif293; + endif278:; + _t768 = (alg == JwtAlg_HS384); + if (!_t768) goto endif280; { void* expectBuf; - void* _t778; - _t778 = Alloc(48); - expectBuf = _t778; + void* _t769; + _t769 = Alloc(48); + expectBuf = _t769; Hmac_Sha384Raw(key, signingInput, expectBuf); const char* expectB64; - _t779 = (const char*)expectBuf; - const char* _t780; - _t780 = bux_base64_encode(_t779, 48); - expectB64 = _t780; + _t770 = (const char*)expectBuf; + const char* _t771; + _t771 = bux_base64_encode(_t770, 48); + expectB64 = _t771; Free(expectBuf); - bool _t781; - _t781 = String_Eq(expectB64, signatureB64); - return _t781; + bool _t772; + _t772 = String_Eq(expectB64, signatureB64); + return _t772; } - endif293:; - _t782 = (alg == JwtAlg_HS512); - if (!_t782) goto endif295; + endif280:; + _t773 = (alg == JwtAlg_HS512); + if (!_t773) goto endif282; { void* expectBuf; - void* _t783; - _t783 = Alloc(64); - expectBuf = _t783; + void* _t774; + _t774 = Alloc(64); + expectBuf = _t774; Hmac_Sha512Raw(key, signingInput, expectBuf); const char* expectB64; - _t784 = (const char*)expectBuf; - const char* _t785; - _t785 = bux_base64_encode(_t784, 64); - expectB64 = _t785; + _t775 = (const char*)expectBuf; + const char* _t776; + _t776 = bux_base64_encode(_t775, 64); + expectB64 = _t776; Free(expectBuf); - bool _t786; - _t786 = String_Eq(expectB64, signatureB64); - return _t786; + bool _t777; + _t777 = String_Eq(expectB64, signatureB64); + return _t777; } - endif295:; - _t787 = (alg == JwtAlg_RS256); - if (!_t787) goto endif297; + endif282:; + _t778 = (alg == JwtAlg_RS256); + if (!_t778) goto endif284; { - bool _t788; - _t788 = Rsa_VerifySha256(key, signingInput, signatureB64); - return _t788; + bool _t779; + _t779 = Rsa_VerifySha256(key, signingInput, signatureB64); + return _t779; } - endif297:; - _t789 = (alg == JwtAlg_RS384); - if (!_t789) goto endif299; + endif284:; + _t780 = (alg == JwtAlg_RS384); + if (!_t780) goto endif286; { - bool _t790; - _t790 = Rsa_VerifySha384(key, signingInput, signatureB64); - return _t790; + bool _t781; + _t781 = Rsa_VerifySha384(key, signingInput, signatureB64); + return _t781; } - endif299:; - _t791 = (alg == JwtAlg_RS512); - if (!_t791) goto endif301; + endif286:; + _t782 = (alg == JwtAlg_RS512); + if (!_t782) goto endif288; { - bool _t792; - _t792 = Rsa_VerifySha512(key, signingInput, signatureB64); - return _t792; + bool _t783; + _t783 = Rsa_VerifySha512(key, signingInput, signatureB64); + return _t783; } - endif301:; - _t793 = (alg == JwtAlg_ES256); - if (!_t793) goto endif303; + endif288:; + _t784 = (alg == JwtAlg_ES256); + if (!_t784) goto endif290; { - bool _t794; - _t794 = Ecdsa_VerifyP256(key, signingInput, signatureB64); - return _t794; + bool _t785; + _t785 = Ecdsa_VerifyP256(key, signingInput, signatureB64); + return _t785; } - endif303:; - _t795 = (alg == JwtAlg_ES384); - if (!_t795) goto endif305; + endif290:; + _t786 = (alg == JwtAlg_ES384); + if (!_t786) goto endif292; { - bool _t796; - _t796 = Ecdsa_VerifyP384(key, signingInput, signatureB64); - return _t796; + bool _t787; + _t787 = Ecdsa_VerifyP384(key, signingInput, signatureB64); + return _t787; } - endif305:; - _t797 = (alg == JwtAlg_EdDSA); - if (!_t797) goto endif307; + endif292:; + _t788 = (alg == JwtAlg_EdDSA); + if (!_t788) goto endif294; { - bool _t798; - _t798 = Ed25519_Verify(key, signatureB64, signingInput); - return _t798; + bool _t789; + _t789 = Ed25519_Verify(key, signatureB64, signingInput); + return _t789; } - endif307:; + endif294:; return 0; } const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key) { const char* headerB64; - const char* _t799; - _t799 = Base64URL_Encode(headerJson); - headerB64 = _t799; + const char* _t790; + _t790 = Base64URL_Encode(headerJson); + headerB64 = _t790; const char* payloadB64; - const char* _t800; - _t800 = Base64URL_Encode(payloadJson); - payloadB64 = _t800; + const char* _t791; + _t791 = Base64URL_Encode(payloadJson); + payloadB64 = _t791; const char* signingInput; - const char* _t801; - _t801 = String_Concat(headerB64, "."); - signingInput = _t801; + const char* _t792; + _t792 = String_Concat(headerB64, "."); + signingInput = _t792; const char* signingInputFull; - const char* _t802; - _t802 = String_Concat(signingInput, payloadB64); - signingInputFull = _t802; + const char* _t793; + _t793 = String_Concat(signingInput, payloadB64); + signingInputFull = _t793; const char* sigB64; - const char* _t803; - _t803 = Jwt_Sign(alg, signingInputFull, key); - sigB64 = _t803; + const char* _t794; + _t794 = Jwt_Sign(alg, signingInputFull, key); + sigB64 = _t794; const char* part1; - const char* _t804; - _t804 = String_Concat(signingInputFull, "."); - part1 = _t804; - const char* _t805; - _t805 = String_Concat(part1, sigB64); - return _t805; + const char* _t795; + _t795 = String_Concat(signingInputFull, "."); + part1 = _t795; + const char* _t796; + _t796 = String_Concat(part1, sigB64); + return _t796; } bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut) { - int _t807; - int _t814; + int _t798; + int _t805; unsigned int partCount; - unsigned int _t806; - _t806 = bux_str_split_count(token, "."); - partCount = _t806; - _t807 = (partCount != 3); - if (!_t807) goto endif309; + unsigned int _t797; + _t797 = bux_str_split_count(token, "."); + partCount = _t797; + _t798 = (partCount != 3); + if (!_t798) goto endif296; { return 0; } - endif309:; + endif296:; const char* headerB64; - const char* _t808; - _t808 = bux_str_split_part(token, ".", 0); - headerB64 = _t808; + const char* _t799; + _t799 = bux_str_split_part(token, ".", 0); + headerB64 = _t799; const char* payloadB64; - const char* _t809; - _t809 = bux_str_split_part(token, ".", 1); - payloadB64 = _t809; + const char* _t800; + _t800 = bux_str_split_part(token, ".", 1); + payloadB64 = _t800; const char* sigB64; - const char* _t810; - _t810 = bux_str_split_part(token, ".", 2); - sigB64 = _t810; + const char* _t801; + _t801 = bux_str_split_part(token, ".", 2); + sigB64 = _t801; const char* input; - const char* _t811; - _t811 = String_Concat(headerB64, "."); - input = _t811; + const char* _t802; + _t802 = String_Concat(headerB64, "."); + input = _t802; const char* signingInput; - const char* _t812; - _t812 = String_Concat(input, payloadB64); - signingInput = _t812; - bool _t813; - _t813 = Jwt_Verify(alg, signingInput, sigB64, key); - _t814 = !_t813; - if (!_t814) goto endif311; + const char* _t803; + _t803 = String_Concat(input, payloadB64); + signingInput = _t803; + bool _t804; + _t804 = Jwt_Verify(alg, signingInput, sigB64, key); + _t805 = !_t804; + if (!_t805) goto endif298; { return 0; } - endif311:; - const char* _t815; - _t815 = Base64URL_Decode(headerB64); - headerOut[0] = _t815; - const char* _t816; - _t816 = Base64URL_Decode(payloadB64); - payloadOut[0] = _t816; + endif298:; + const char* _t806; + _t806 = Base64URL_Decode(headerB64); + headerOut[0] = _t806; + const char* _t807; + _t807 = Base64URL_Decode(payloadB64); + payloadOut[0] = _t807; return 1; } const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret) { const char* header; - const char* _t817; - _t817 = Jwt_MakeHeader(JwtAlg_HS256); - header = _t817; - const char* _t818; - _t818 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); - return _t818; + const char* _t808; + _t808 = Jwt_MakeHeader(JwtAlg_HS256); + header = _t808; + const char* _t809; + _t809 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); + return _t809; } const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret) { const char* header; - const char* _t819; - _t819 = Jwt_MakeHeader(JwtAlg_HS384); - header = _t819; - const char* _t820; - _t820 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); - return _t820; + const char* _t810; + _t810 = Jwt_MakeHeader(JwtAlg_HS384); + header = _t810; + const char* _t811; + _t811 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); + return _t811; } const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret) { const char* header; - const char* _t821; - _t821 = Jwt_MakeHeader(JwtAlg_HS512); - header = _t821; - const char* _t822; - _t822 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); - return _t822; + const char* _t812; + _t812 = Jwt_MakeHeader(JwtAlg_HS512); + header = _t812; + const char* _t813; + _t813 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); + return _t813; } const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t823; - _t823 = Jwt_MakeHeader(JwtAlg_RS256); - header = _t823; - const char* _t824; - _t824 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); - return _t824; + const char* _t814; + _t814 = Jwt_MakeHeader(JwtAlg_RS256); + header = _t814; + const char* _t815; + _t815 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); + return _t815; } const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t825; - _t825 = Jwt_MakeHeader(JwtAlg_ES256); - header = _t825; - const char* _t826; - _t826 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); - return _t826; + const char* _t816; + _t816 = Jwt_MakeHeader(JwtAlg_ES256); + header = _t816; + const char* _t817; + _t817 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); + return _t817; } const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey) { const char* header; - const char* _t827; - _t827 = Jwt_MakeHeader(JwtAlg_EdDSA); - header = _t827; - const char* _t828; - _t828 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); - return _t828; + const char* _t818; + _t818 = Jwt_MakeHeader(JwtAlg_EdDSA); + header = _t818; + const char* _t819; + _t819 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); + return _t819; } const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data) { - int _t830; - int _t832; - void* _t833; + int _t821; + int _t823; + void* _t824; int siglen; siglen = 0; - unsigned int _t829; - _t829 = String_Len(pemPrivateKey); - _t830 = (int)_t829; - unsigned int _t831; - _t831 = String_Len(data); - _t832 = (int)_t831; - _t833 = &siglen; - const char* _t834; - _t834 = bux_ecdsa_sign_p256(pemPrivateKey, _t830, data, _t832, _t833); - return _t834; + unsigned int _t820; + _t820 = String_Len(pemPrivateKey); + _t821 = (int)_t820; + unsigned int _t822; + _t822 = String_Len(data); + _t823 = (int)_t822; + _t824 = &siglen; + const char* _t825; + _t825 = bux_ecdsa_sign_p256(pemPrivateKey, _t821, data, _t823, _t824); + return _t825; } const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data) { - int _t837; + int _t828; const char* raw; - const char* _t835; - _t835 = Ecdsa_SignP256(pemPrivateKey, data); - raw = _t835; - unsigned int _t836; - _t836 = String_Len(raw); - _t837 = (int)_t836; - const char* _t838; - _t838 = bux_base64_encode(raw, _t837); - return _t838; + const char* _t826; + _t826 = Ecdsa_SignP256(pemPrivateKey, data); + raw = _t826; + unsigned int _t827; + _t827 = String_Len(raw); + _t828 = (int)_t827; + const char* _t829; + _t829 = bux_base64_encode(raw, _t828); + return _t829; } bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature) { - int _t840; - int _t842; - int _t844; - int _t846; + int _t831; + int _t833; + int _t835; + int _t837; int r; - unsigned int _t839; - _t839 = String_Len(pemPublicKey); - _t840 = (int)_t839; - unsigned int _t841; - _t841 = String_Len(data); - _t842 = (int)_t841; - unsigned int _t843; - _t843 = String_Len(signature); - _t844 = (int)_t843; - int _t845; - _t845 = bux_ecdsa_verify_p256(pemPublicKey, _t840, data, _t842, signature, _t844); - r = _t845; - _t846 = (r == 1); - return _t846; + unsigned int _t830; + _t830 = String_Len(pemPublicKey); + _t831 = (int)_t830; + unsigned int _t832; + _t832 = String_Len(data); + _t833 = (int)_t832; + unsigned int _t834; + _t834 = String_Len(signature); + _t835 = (int)_t834; + int _t836; + _t836 = bux_ecdsa_verify_p256(pemPublicKey, _t831, data, _t833, signature, _t835); + r = _t836; + _t837 = (r == 1); + return _t837; } bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t848; - void* _t849; + int _t839; + void* _t840; int outlen; outlen = 0; const char* sig; - unsigned int _t847; - _t847 = String_Len(signatureB64); - _t848 = (int)_t847; - _t849 = &outlen; - const char* _t850; - _t850 = bux_base64_decode(signatureB64, _t848, _t849); - sig = _t850; - bool _t851; - _t851 = Ecdsa_VerifyP256(pemPublicKey, data, sig); - return _t851; + unsigned int _t838; + _t838 = String_Len(signatureB64); + _t839 = (int)_t838; + _t840 = &outlen; + const char* _t841; + _t841 = bux_base64_decode(signatureB64, _t839, _t840); + sig = _t841; + bool _t842; + _t842 = Ecdsa_VerifyP256(pemPublicKey, data, sig); + return _t842; } const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data) { - int _t853; - int _t855; - void* _t856; + int _t844; + int _t846; + void* _t847; int siglen; siglen = 0; - unsigned int _t852; - _t852 = String_Len(pemPrivateKey); - _t853 = (int)_t852; - unsigned int _t854; - _t854 = String_Len(data); - _t855 = (int)_t854; - _t856 = &siglen; - const char* _t857; - _t857 = bux_ecdsa_sign_p384(pemPrivateKey, _t853, data, _t855, _t856); - return _t857; + unsigned int _t843; + _t843 = String_Len(pemPrivateKey); + _t844 = (int)_t843; + unsigned int _t845; + _t845 = String_Len(data); + _t846 = (int)_t845; + _t847 = &siglen; + const char* _t848; + _t848 = bux_ecdsa_sign_p384(pemPrivateKey, _t844, data, _t846, _t847); + return _t848; } const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data) { - int _t860; + int _t851; const char* raw; - const char* _t858; - _t858 = Ecdsa_SignP384(pemPrivateKey, data); - raw = _t858; - unsigned int _t859; - _t859 = String_Len(raw); - _t860 = (int)_t859; - const char* _t861; - _t861 = bux_base64_encode(raw, _t860); - return _t861; + const char* _t849; + _t849 = Ecdsa_SignP384(pemPrivateKey, data); + raw = _t849; + unsigned int _t850; + _t850 = String_Len(raw); + _t851 = (int)_t850; + const char* _t852; + _t852 = bux_base64_encode(raw, _t851); + return _t852; } bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature) { - int _t863; - int _t865; - int _t867; - int _t869; + int _t854; + int _t856; + int _t858; + int _t860; int r; - unsigned int _t862; - _t862 = String_Len(pemPublicKey); - _t863 = (int)_t862; - unsigned int _t864; - _t864 = String_Len(data); - _t865 = (int)_t864; - unsigned int _t866; - _t866 = String_Len(signature); - _t867 = (int)_t866; - int _t868; - _t868 = bux_ecdsa_verify_p384(pemPublicKey, _t863, data, _t865, signature, _t867); - r = _t868; - _t869 = (r == 1); - return _t869; + unsigned int _t853; + _t853 = String_Len(pemPublicKey); + _t854 = (int)_t853; + unsigned int _t855; + _t855 = String_Len(data); + _t856 = (int)_t855; + unsigned int _t857; + _t857 = String_Len(signature); + _t858 = (int)_t857; + int _t859; + _t859 = bux_ecdsa_verify_p384(pemPublicKey, _t854, data, _t856, signature, _t858); + r = _t859; + _t860 = (r == 1); + return _t860; } bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t871; - void* _t872; + int _t862; + void* _t863; int outlen; outlen = 0; const char* sig; - unsigned int _t870; - _t870 = String_Len(signatureB64); - _t871 = (int)_t870; - _t872 = &outlen; - const char* _t873; - _t873 = bux_base64_decode(signatureB64, _t871, _t872); - sig = _t873; - bool _t874; - _t874 = Ecdsa_VerifyP384(pemPublicKey, data, sig); - return _t874; + unsigned int _t861; + _t861 = String_Len(signatureB64); + _t862 = (int)_t861; + _t863 = &outlen; + const char* _t864; + _t864 = bux_base64_decode(signatureB64, _t862, _t863); + sig = _t864; + bool _t865; + _t865 = Ecdsa_VerifyP384(pemPublicKey, data, sig); + return _t865; } bool Ed25519_Keypair(void* pubKey, void* privKey) { - int _t876; + int _t867; int r; - int _t875; - _t875 = bux_ed25519_keypair(pubKey, privKey); - r = _t875; - _t876 = (r == 1); - return _t876; + int _t866; + _t866 = bux_ed25519_keypair(pubKey, privKey); + r = _t866; + _t867 = (r == 1); + return _t867; } const char* Ed25519_KeypairBase64(void) { - unsigned int _t877; - unsigned int _t879; - int _t882; - const char* _t883; - const char* _t885; + unsigned int _t868; + unsigned int _t870; + int _t873; + const char* _t874; + const char* _t876; void* pubBuf; - _t877 = (unsigned int)ED25519_PUBKEY_SIZE; - void* _t878; - _t878 = Alloc(_t877); - pubBuf = _t878; + _t868 = (unsigned int)ED25519_PUBKEY_SIZE; + void* _t869; + _t869 = Alloc(_t868); + pubBuf = _t869; void* priv; - _t879 = (unsigned int)ED25519_PRIVKEY_SIZE; - void* _t880; - _t880 = Alloc(_t879); - priv = _t880; - int _t881; - _t881 = bux_ed25519_keypair(pubBuf, priv); - _t882 = (_t881 != 1); - if (!_t882) goto endif313; + _t870 = (unsigned int)ED25519_PRIVKEY_SIZE; + void* _t871; + _t871 = Alloc(_t870); + priv = _t871; + int _t872; + _t872 = bux_ed25519_keypair(pubBuf, priv); + _t873 = (_t872 != 1); + if (!_t873) goto endif300; { Free(pubBuf); Free(priv); return ""; } - endif313:; + endif300:; const char* pubB64; - _t883 = (const char*)pubBuf; - const char* _t884; - _t884 = bux_base64_encode(_t883, ED25519_PUBKEY_SIZE); - pubB64 = _t884; + _t874 = (const char*)pubBuf; + const char* _t875; + _t875 = bux_base64_encode(_t874, ED25519_PUBKEY_SIZE); + pubB64 = _t875; const char* privB64; - _t885 = (const char*)priv; - const char* _t886; - _t886 = bux_base64_encode(_t885, ED25519_PRIVKEY_SIZE); - privB64 = _t886; + _t876 = (const char*)priv; + const char* _t877; + _t877 = bux_base64_encode(_t876, ED25519_PRIVKEY_SIZE); + privB64 = _t877; Free(pubBuf); Free(priv); const char* pair; - const char* _t887; - _t887 = String_Concat(pubB64, ":"); - pair = _t887; - const char* _t888; - _t888 = String_Concat(pair, privB64); - return _t888; + const char* _t878; + _t878 = String_Concat(pubB64, ":"); + pair = _t878; + const char* _t879; + _t879 = String_Concat(pair, privB64); + return _t879; } const char* Ed25519_Sign(const char* privKey, const char* data) { - unsigned int _t889; - int _t892; - int _t894; - const char* _t895; + unsigned int _t880; + int _t883; + int _t885; + const char* _t886; void* sig; - _t889 = (unsigned int)ED25519_SIG_SIZE; - void* _t890; - _t890 = Alloc(_t889); - sig = _t890; - unsigned int _t891; - _t891 = String_Len(data); - _t892 = (int)_t891; - int _t893; - _t893 = bux_ed25519_sign(privKey, data, _t892, sig); - _t894 = (_t893 != 1); - if (!_t894) goto endif315; + _t880 = (unsigned int)ED25519_SIG_SIZE; + void* _t881; + _t881 = Alloc(_t880); + sig = _t881; + unsigned int _t882; + _t882 = String_Len(data); + _t883 = (int)_t882; + int _t884; + _t884 = bux_ed25519_sign(privKey, data, _t883, sig); + _t885 = (_t884 != 1); + if (!_t885) goto endif302; { Free(sig); return ""; } - endif315:; - _t895 = (const char*)sig; - return _t895; + endif302:; + _t886 = (const char*)sig; + return _t886; } const char* Ed25519_SignBase64(const char* privKey, const char* data) { - int _t898; + int _t889; const char* sig; - const char* _t896; - _t896 = Ed25519_Sign(privKey, data); - sig = _t896; - unsigned int _t897; - _t897 = String_Len(sig); - _t898 = (_t897 == 0); - if (!_t898) goto endif317; + const char* _t887; + _t887 = Ed25519_Sign(privKey, data); + sig = _t887; + unsigned int _t888; + _t888 = String_Len(sig); + _t889 = (_t888 == 0); + if (!_t889) goto endif304; { return ""; } - endif317:; - const char* _t899; - _t899 = bux_base64_encode(sig, ED25519_SIG_SIZE); - return _t899; + endif304:; + const char* _t890; + _t890 = bux_base64_encode(sig, ED25519_SIG_SIZE); + return _t890; } bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data) { - int _t901; - int _t903; + int _t892; + int _t894; int r; - unsigned int _t900; - _t900 = String_Len(data); - _t901 = (int)_t900; - int _t902; - _t902 = bux_ed25519_verify(pubKey, signature, data, _t901); - r = _t902; - _t903 = (r == 1); - return _t903; + unsigned int _t891; + _t891 = String_Len(data); + _t892 = (int)_t891; + int _t893; + _t893 = bux_ed25519_verify(pubKey, signature, data, _t892); + r = _t893; + _t894 = (r == 1); + return _t894; } bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data) { - int _t905; - void* _t906; - int _t908; + int _t896; + void* _t897; + int _t899; int outlen; outlen = 0; const char* sig; - unsigned int _t904; - _t904 = String_Len(signatureB64); - _t905 = (int)_t904; - _t906 = &outlen; - const char* _t907; - _t907 = bux_base64_decode(signatureB64, _t905, _t906); - sig = _t907; - _t908 = (outlen != ED25519_SIG_SIZE); - if (!_t908) goto endif319; + unsigned int _t895; + _t895 = String_Len(signatureB64); + _t896 = (int)_t895; + _t897 = &outlen; + const char* _t898; + _t898 = bux_base64_decode(signatureB64, _t896, _t897); + sig = _t898; + _t899 = (outlen != ED25519_SIG_SIZE); + if (!_t899) goto endif306; { return 0; } - endif319:; - bool _t909; - _t909 = Ed25519_Verify(pubKey, sig, data); - return _t909; + endif306:; + bool _t900; + _t900 = Ed25519_Verify(pubKey, sig, data); + return _t900; } const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data) { - int _t911; - int _t913; - void* _t914; + int _t902; + int _t904; + void* _t905; int siglen; siglen = 0; - unsigned int _t910; - _t910 = String_Len(pemPrivateKey); - _t911 = (int)_t910; - unsigned int _t912; - _t912 = String_Len(data); - _t913 = (int)_t912; - _t914 = &siglen; - const char* _t915; - _t915 = bux_rsa_sign_sha256(pemPrivateKey, _t911, data, _t913, _t914); - return _t915; + unsigned int _t901; + _t901 = String_Len(pemPrivateKey); + _t902 = (int)_t901; + unsigned int _t903; + _t903 = String_Len(data); + _t904 = (int)_t903; + _t905 = &siglen; + const char* _t906; + _t906 = bux_rsa_sign_sha256(pemPrivateKey, _t902, data, _t904, _t905); + return _t906; } const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data) { - int _t917; - int _t919; - void* _t920; + int _t908; + int _t910; + void* _t911; int siglen; siglen = 0; - unsigned int _t916; - _t916 = String_Len(pemPrivateKey); - _t917 = (int)_t916; - unsigned int _t918; - _t918 = String_Len(data); - _t919 = (int)_t918; - _t920 = &siglen; - const char* _t921; - _t921 = bux_rsa_sign_sha384(pemPrivateKey, _t917, data, _t919, _t920); - return _t921; + unsigned int _t907; + _t907 = String_Len(pemPrivateKey); + _t908 = (int)_t907; + unsigned int _t909; + _t909 = String_Len(data); + _t910 = (int)_t909; + _t911 = &siglen; + const char* _t912; + _t912 = bux_rsa_sign_sha384(pemPrivateKey, _t908, data, _t910, _t911); + return _t912; } const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data) { - int _t923; - int _t925; - void* _t926; + int _t914; + int _t916; + void* _t917; int siglen; siglen = 0; - unsigned int _t922; - _t922 = String_Len(pemPrivateKey); - _t923 = (int)_t922; - unsigned int _t924; - _t924 = String_Len(data); - _t925 = (int)_t924; - _t926 = &siglen; - const char* _t927; - _t927 = bux_rsa_sign_sha512(pemPrivateKey, _t923, data, _t925, _t926); - return _t927; + unsigned int _t913; + _t913 = String_Len(pemPrivateKey); + _t914 = (int)_t913; + unsigned int _t915; + _t915 = String_Len(data); + _t916 = (int)_t915; + _t917 = &siglen; + const char* _t918; + _t918 = bux_rsa_sign_sha512(pemPrivateKey, _t914, data, _t916, _t917); + return _t918; } const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data) { - int _t930; + int _t921; const char* raw; - const char* _t928; - _t928 = Rsa_SignSha256(pemPrivateKey, data); - raw = _t928; - unsigned int _t929; - _t929 = String_Len(raw); - _t930 = (int)_t929; - const char* _t931; - _t931 = bux_base64_encode(raw, _t930); - return _t931; + const char* _t919; + _t919 = Rsa_SignSha256(pemPrivateKey, data); + raw = _t919; + unsigned int _t920; + _t920 = String_Len(raw); + _t921 = (int)_t920; + const char* _t922; + _t922 = bux_base64_encode(raw, _t921); + return _t922; } const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data) { - int _t934; + int _t925; const char* raw; - const char* _t932; - _t932 = Rsa_SignSha384(pemPrivateKey, data); - raw = _t932; - unsigned int _t933; - _t933 = String_Len(raw); - _t934 = (int)_t933; - const char* _t935; - _t935 = bux_base64_encode(raw, _t934); - return _t935; + const char* _t923; + _t923 = Rsa_SignSha384(pemPrivateKey, data); + raw = _t923; + unsigned int _t924; + _t924 = String_Len(raw); + _t925 = (int)_t924; + const char* _t926; + _t926 = bux_base64_encode(raw, _t925); + return _t926; } const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data) { - int _t938; + int _t929; const char* raw; - const char* _t936; - _t936 = Rsa_SignSha512(pemPrivateKey, data); - raw = _t936; - unsigned int _t937; - _t937 = String_Len(raw); - _t938 = (int)_t937; - const char* _t939; - _t939 = bux_base64_encode(raw, _t938); - return _t939; + const char* _t927; + _t927 = Rsa_SignSha512(pemPrivateKey, data); + raw = _t927; + unsigned int _t928; + _t928 = String_Len(raw); + _t929 = (int)_t928; + const char* _t930; + _t930 = bux_base64_encode(raw, _t929); + return _t930; } bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature) { - int _t941; - int _t943; - int _t945; - int _t947; + int _t932; + int _t934; + int _t936; + int _t938; int r; - unsigned int _t940; - _t940 = String_Len(pemPublicKey); - _t941 = (int)_t940; - unsigned int _t942; - _t942 = String_Len(data); - _t943 = (int)_t942; - unsigned int _t944; - _t944 = String_Len(signature); - _t945 = (int)_t944; - int _t946; - _t946 = bux_rsa_verify_sha256(pemPublicKey, _t941, data, _t943, signature, _t945); - r = _t946; - _t947 = (r == 1); - return _t947; + unsigned int _t931; + _t931 = String_Len(pemPublicKey); + _t932 = (int)_t931; + unsigned int _t933; + _t933 = String_Len(data); + _t934 = (int)_t933; + unsigned int _t935; + _t935 = String_Len(signature); + _t936 = (int)_t935; + int _t937; + _t937 = bux_rsa_verify_sha256(pemPublicKey, _t932, data, _t934, signature, _t936); + r = _t937; + _t938 = (r == 1); + return _t938; } bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature) { - int _t949; - int _t951; - int _t953; - int _t955; + int _t940; + int _t942; + int _t944; + int _t946; int r; - unsigned int _t948; - _t948 = String_Len(pemPublicKey); - _t949 = (int)_t948; - unsigned int _t950; - _t950 = String_Len(data); - _t951 = (int)_t950; - unsigned int _t952; - _t952 = String_Len(signature); - _t953 = (int)_t952; - int _t954; - _t954 = bux_rsa_verify_sha384(pemPublicKey, _t949, data, _t951, signature, _t953); - r = _t954; - _t955 = (r == 1); - return _t955; + unsigned int _t939; + _t939 = String_Len(pemPublicKey); + _t940 = (int)_t939; + unsigned int _t941; + _t941 = String_Len(data); + _t942 = (int)_t941; + unsigned int _t943; + _t943 = String_Len(signature); + _t944 = (int)_t943; + int _t945; + _t945 = bux_rsa_verify_sha384(pemPublicKey, _t940, data, _t942, signature, _t944); + r = _t945; + _t946 = (r == 1); + return _t946; } bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature) { - int _t957; - int _t959; - int _t961; - int _t963; + int _t948; + int _t950; + int _t952; + int _t954; int r; - unsigned int _t956; - _t956 = String_Len(pemPublicKey); - _t957 = (int)_t956; - unsigned int _t958; - _t958 = String_Len(data); - _t959 = (int)_t958; - unsigned int _t960; - _t960 = String_Len(signature); - _t961 = (int)_t960; - int _t962; - _t962 = bux_rsa_verify_sha512(pemPublicKey, _t957, data, _t959, signature, _t961); - r = _t962; - _t963 = (r == 1); - return _t963; + unsigned int _t947; + _t947 = String_Len(pemPublicKey); + _t948 = (int)_t947; + unsigned int _t949; + _t949 = String_Len(data); + _t950 = (int)_t949; + unsigned int _t951; + _t951 = String_Len(signature); + _t952 = (int)_t951; + int _t953; + _t953 = bux_rsa_verify_sha512(pemPublicKey, _t948, data, _t950, signature, _t952); + r = _t953; + _t954 = (r == 1); + return _t954; } bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t965; - void* _t966; + int _t956; + void* _t957; int outlen; outlen = 0; const char* sig; - unsigned int _t964; - _t964 = String_Len(signatureB64); - _t965 = (int)_t964; - _t966 = &outlen; - const char* _t967; - _t967 = bux_base64_decode(signatureB64, _t965, _t966); - sig = _t967; - bool _t968; - _t968 = Rsa_VerifySha256(pemPublicKey, data, sig); - return _t968; + unsigned int _t955; + _t955 = String_Len(signatureB64); + _t956 = (int)_t955; + _t957 = &outlen; + const char* _t958; + _t958 = bux_base64_decode(signatureB64, _t956, _t957); + sig = _t958; + bool _t959; + _t959 = Rsa_VerifySha256(pemPublicKey, data, sig); + return _t959; } bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t970; - void* _t971; + int _t961; + void* _t962; int outlen; outlen = 0; const char* sig; - unsigned int _t969; - _t969 = String_Len(signatureB64); - _t970 = (int)_t969; - _t971 = &outlen; - const char* _t972; - _t972 = bux_base64_decode(signatureB64, _t970, _t971); - sig = _t972; - bool _t973; - _t973 = Rsa_VerifySha384(pemPublicKey, data, sig); - return _t973; + unsigned int _t960; + _t960 = String_Len(signatureB64); + _t961 = (int)_t960; + _t962 = &outlen; + const char* _t963; + _t963 = bux_base64_decode(signatureB64, _t961, _t962); + sig = _t963; + bool _t964; + _t964 = Rsa_VerifySha384(pemPublicKey, data, sig); + return _t964; } bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t975; - void* _t976; + int _t966; + void* _t967; int outlen; outlen = 0; const char* sig; - unsigned int _t974; - _t974 = String_Len(signatureB64); - _t975 = (int)_t974; - _t976 = &outlen; - const char* _t977; - _t977 = bux_base64_decode(signatureB64, _t975, _t976); - sig = _t977; - bool _t978; - _t978 = Rsa_VerifySha512(pemPublicKey, data, sig); - return _t978; + unsigned int _t965; + _t965 = String_Len(signatureB64); + _t966 = (int)_t965; + _t967 = &outlen; + const char* _t968; + _t968 = bux_base64_decode(signatureB64, _t966, _t967); + sig = _t968; + bool _t969; + _t969 = Rsa_VerifySha512(pemPublicKey, data, sig); + return _t969; } int Main(void) { int m1; - int _t979; - _t979 = Max_int(10, 20); - m1 = _t979; + int _t970; + _t970 = Max_int(10, 20); + m1 = _t970; int m2; - int _t980; - _t980 = Max_int(5, 3); - m2 = _t980; + int _t971; + _t971 = Max_int(5, 3); + m2 = _t971; PrintLine("Max(10, 20) = "); PrintInt(m1); PrintLine(""); @@ -4828,18 +4827,18 @@ int Main(void) { } int Max_int(int a, int b) { - int _t981; - _t981 = (a > b); - if (!_t981) goto else320; + int _t972; + _t972 = (a > b); + if (!_t972) goto else307; { return a; } - goto endif321; - else320:; + goto endif308; + else307:; { return b; } - endif321:; + endif308:; } /* C entry point wrapper */ diff --git a/tests/golden/hello/expected.c b/tests/golden/hello/expected.c index 584ddaf..c810b9c 100644 --- a/tests/golden/hello/expected.c +++ b/tests/golden/hello/expected.c @@ -198,6 +198,34 @@ extern const char* bux_base64_decode(const char* data, int len, int* outlen); #define ED25519_PRIVKEY_SIZE 32 #define ED25519_SIG_SIZE 64 +typedef struct Channel_float64 { + void* handle; +} Channel_float64; + +typedef struct TaskHandle { + void* handle; +} TaskHandle; + +typedef struct RwLock { + void* handle; +} RwLock; + +typedef struct Channel_int { + void* handle; +} Channel_int; + +typedef enum { + JwtAlg_HS256, + JwtAlg_HS384, + JwtAlg_HS512, + JwtAlg_RS256, + JwtAlg_RS384, + JwtAlg_RS512, + JwtAlg_ES256, + JwtAlg_ES384, + JwtAlg_EdDSA +} JwtAlg; + typedef enum { Result_Ok, Result_Err @@ -227,31 +255,6 @@ typedef struct { Option_Data data; } Option; -typedef enum { - JwtAlg_HS256, - JwtAlg_HS384, - JwtAlg_HS512, - JwtAlg_RS256, - JwtAlg_RS384, - JwtAlg_RS512, - JwtAlg_ES256, - JwtAlg_ES384, - JwtAlg_EdDSA -} JwtAlg; - - -typedef struct TaskHandle { - void* handle; -} TaskHandle; - -typedef struct Mutex { - void* handle; -} Mutex; - -typedef struct RwLock { - void* handle; -} RwLock; - typedef struct JsonValue { int tag; bool boolVal; @@ -266,6 +269,14 @@ typedef struct JsonValue { unsigned int objCap; } JsonValue; +typedef struct Mutex { + void* handle; +} Mutex; + +typedef struct StringBuilder { + void* handle; +} StringBuilder; + typedef struct JsonParser { const char* src; unsigned int pos; @@ -273,18 +284,6 @@ typedef struct JsonParser { const char* error; } JsonParser; -typedef struct StringBuilder { - void* handle; -} StringBuilder; - -typedef struct Channel_int { - void* handle; -} Channel_int; - -typedef struct Channel_float64 { - void* handle; -} Channel_float64; - bool DirExists(const char* path); bool Mkdir(const char* path); const char** ListDir(const char* dir, const char* ext, int* count); @@ -866,7 +865,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { tmplLen = _t60; while1:; _t61 = (i < tmplLen); - if (!_t61) goto wend3; + if (!_t61) goto wend2; { const char* ch; const char* _t62; @@ -874,13 +873,13 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { ch = _t62; bool _t63; _t63 = String_Eq(ch, "{"); - if (!_t63) goto endif5; + if (!_t63) goto endif4; { unsigned int digitIdx; _t64 = i + 1; digitIdx = _t64; _t65 = (digitIdx < tmplLen); - if (!_t65) goto endif7; + if (!_t65) goto endif6; { const char* digitCh; const char* _t66; @@ -892,22 +891,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { d = _t67; bool __and_tmp_0; _t68 = (d >= 0); - if (!_t68) goto else8; + if (!_t68) goto else7; _t69 = (int64_t)argCount; _t70 = (d < _t69); *(bool*)&__and_tmp_0 = _t70; - goto endif9; - else8:; + goto endif8; + else7:; *(bool*)&__and_tmp_0 = 0; - endif9:; + endif8:; bool _t71; _t71 = *(bool*)&__and_tmp_0; - if (!_t71) goto endif11; + if (!_t71) goto endif10; { _t72 = i + 2; i = _t72; _t73 = (i < tmplLen); - if (!_t73) goto endif13; + if (!_t73) goto endif12; { const char* closeCh; const char* _t74; @@ -915,7 +914,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { closeCh = _t74; bool _t75; _t75 = String_Eq(closeCh, "}"); - if (!_t75) goto endif15; + if (!_t75) goto endif14; { _t76 = i + 1; i = _t76; @@ -928,22 +927,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { StringBuilder_Append(_t79, argStr); goto while1; } - endif15:; + endif14:; } - endif13:; + endif12:; } - endif11:; + endif10:; } - endif7:; + endif6:; } - endif5:; + endif4:; _t80 = &sb; StringBuilder_Append(_t80, ch); _t81 = i + 1; i = _t81; } goto while1; - wend3:; + wend2:; _t82 = &sb; const char* _t83; _t83 = StringBuilder_Build(_t82); @@ -951,276 +950,276 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { } const char* Fmt_Fmt1(const char* tmpl, const char* a1) { - const char** _t86; + const char** _t85; const char** args; /* sizeof(const char*) */ - void* _t85; - _t85 = bux_alloc(sizeof(const char*)); - _t86 = (const char**)_t85; - args = _t86; + void* _t84; + _t84 = bux_alloc(sizeof(const char*)); + _t85 = (const char**)_t84; + args = _t85; args[0] = a1; - const char* _t87; - _t87 = Fmt_Format(tmpl, args, 1); - return _t87; + const char* _t86; + _t86 = Fmt_Format(tmpl, args, 1); + return _t86; } const char* Fmt_FmtInt(const char* tmpl, int64_t val) { const char* s; + const char* _t87; + _t87 = String_FromInt(val); + s = _t87; const char* _t88; - _t88 = String_FromInt(val); - s = _t88; - const char* _t89; - _t89 = Fmt_Fmt1(tmpl, s); - return _t89; + _t88 = Fmt_Fmt1(tmpl, s); + return _t88; } const char* Fmt_FmtBool(const char* tmpl, bool val) { const char* s; + const char* _t89; + _t89 = String_FromBool(val); + s = _t89; const char* _t90; - _t90 = String_FromBool(val); - s = _t90; - const char* _t91; - _t91 = Fmt_Fmt1(tmpl, s); - return _t91; + _t90 = Fmt_Fmt1(tmpl, s); + return _t90; } const char* Fmt_FmtFloat(const char* tmpl, double val) { const char* s; + const char* _t91; + _t91 = String_FromFloat(val); + s = _t91; const char* _t92; - _t92 = String_FromFloat(val); - s = _t92; - const char* _t93; - _t93 = Fmt_Fmt1(tmpl, s); - return _t93; + _t92 = Fmt_Fmt1(tmpl, s); + return _t92; } const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2) { - int _t95; - const char** _t97; + int _t93; + const char** _t95; const char** args; /* sizeof(const char*) */ - _t95 = 2 * sizeof(const char*); - void* _t96; - _t96 = bux_alloc(_t95); - _t97 = (const char**)_t96; - args = _t97; + _t93 = 2 * sizeof(const char*); + void* _t94; + _t94 = bux_alloc(_t93); + _t95 = (const char**)_t94; + args = _t95; args[0] = a1; args[1] = a2; - const char* _t98; - _t98 = Fmt_Format(tmpl, args, 2); - return _t98; + const char* _t96; + _t96 = Fmt_Format(tmpl, args, 2); + return _t96; } const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3) { - int _t100; - const char** _t102; + int _t97; + const char** _t99; const char** args; /* sizeof(const char*) */ - _t100 = 3 * sizeof(const char*); - void* _t101; - _t101 = bux_alloc(_t100); - _t102 = (const char**)_t101; - args = _t102; + _t97 = 3 * sizeof(const char*); + void* _t98; + _t98 = bux_alloc(_t97); + _t99 = (const char**)_t98; + args = _t99; args[0] = a1; args[1] = a2; args[2] = a3; - const char* _t103; - _t103 = Fmt_Format(tmpl, args, 3); - return _t103; + const char* _t100; + _t100 = Fmt_Format(tmpl, args, 3); + return _t100; } const char* Crypto_Sha256(const char* data) { - int _t105; - void* _t107; + int _t102; + void* _t104; int len; - unsigned int _t104; - _t104 = String_Len(data); - _t105 = (int)_t104; - len = _t105; + unsigned int _t101; + _t101 = String_Len(data); + _t102 = (int)_t101; + len = _t102; void* hashBuf; - void* _t106; - _t106 = Alloc(32); - hashBuf = _t106; + void* _t103; + _t103 = Alloc(32); + hashBuf = _t103; bux_sha256(data, len, hashBuf); const char* result; - _t107 = (void*)hashBuf; - const char* _t108; - _t108 = bux_bytes_to_hex(_t107, 32); - result = _t108; + _t104 = (void*)hashBuf; + const char* _t105; + _t105 = bux_bytes_to_hex(_t104, 32); + result = _t105; Free(hashBuf); return result; } const char* Crypto_HmacSha256(const char* key, const char* message) { - int _t110; - int _t112; - void* _t114; + int _t107; + int _t109; + void* _t111; int keylen; - unsigned int _t109; - _t109 = String_Len(key); - _t110 = (int)_t109; - keylen = _t110; + unsigned int _t106; + _t106 = String_Len(key); + _t107 = (int)_t106; + keylen = _t107; int msglen; - unsigned int _t111; - _t111 = String_Len(message); - _t112 = (int)_t111; - msglen = _t112; + unsigned int _t108; + _t108 = String_Len(message); + _t109 = (int)_t108; + msglen = _t109; void* hmacBuf; - void* _t113; - _t113 = Alloc(32); - hmacBuf = _t113; + void* _t110; + _t110 = Alloc(32); + hmacBuf = _t110; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t114 = (void*)hmacBuf; - const char* _t115; - _t115 = bux_bytes_to_hex(_t114, 32); - result = _t115; + _t111 = (void*)hmacBuf; + const char* _t112; + _t112 = bux_bytes_to_hex(_t111, 32); + result = _t112; Free(hmacBuf); return result; } const char* Crypto_RandomBytes(int n) { - int _t116; - unsigned int _t117; - int _t120; - const char* _t121; - _t116 = (n <= 0); - if (!_t116) goto endif17; + int _t113; + unsigned int _t114; + int _t117; + const char* _t118; + _t113 = (n <= 0); + if (!_t113) goto endif16; { return ""; } - endif17:; + endif16:; void* buf; - _t117 = (unsigned int)n; - void* _t118; - _t118 = Alloc(_t117); - buf = _t118; - int _t119; - _t119 = bux_random_bytes(buf, n); - _t120 = (_t119 != 1); - if (!_t120) goto endif19; + _t114 = (unsigned int)n; + void* _t115; + _t115 = Alloc(_t114); + buf = _t115; + int _t116; + _t116 = bux_random_bytes(buf, n); + _t117 = (_t116 != 1); + if (!_t117) goto endif18; { Free(buf); return ""; } - endif19:; + endif18:; const char* result; - _t121 = (const char*)buf; - const char* _t122; - _t122 = bux_base64_encode(_t121, n); - result = _t122; + _t118 = (const char*)buf; + const char* _t119; + _t119 = bux_base64_encode(_t118, n); + result = _t119; Free(buf); return result; } const char* Crypto_Base64Encode(const char* s) { - int _t124; - unsigned int _t123; - _t123 = String_Len(s); - _t124 = (int)_t123; - const char* _t125; - _t125 = bux_base64_encode(s, _t124); - return _t125; + int _t121; + unsigned int _t120; + _t120 = String_Len(s); + _t121 = (int)_t120; + const char* _t122; + _t122 = bux_base64_encode(s, _t121); + return _t122; } const char* Crypto_HmacSha256Raw(const char* key, const char* message) { - int _t127; - int _t129; - const char* _t131; + int _t124; + int _t126; + const char* _t128; int keylen; - unsigned int _t126; - _t126 = String_Len(key); - _t127 = (int)_t126; - keylen = _t127; + unsigned int _t123; + _t123 = String_Len(key); + _t124 = (int)_t123; + keylen = _t124; int msglen; - unsigned int _t128; - _t128 = String_Len(message); - _t129 = (int)_t128; - msglen = _t129; + unsigned int _t125; + _t125 = String_Len(message); + _t126 = (int)_t125; + msglen = _t126; void* hmacBuf; - void* _t130; - _t130 = Alloc(32); - hmacBuf = _t130; + void* _t127; + _t127 = Alloc(32); + hmacBuf = _t127; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t131 = (const char*)hmacBuf; - const char* _t132; - _t132 = bux_base64_encode(_t131, 32); - result = _t132; + _t128 = (const char*)hmacBuf; + const char* _t129; + _t129 = bux_base64_encode(_t128, 32); + result = _t129; Free(hmacBuf); return result; } const char* Crypto_Base64Decode(const char* s) { - int _t134; - void* _t135; + int _t131; + void* _t132; int outlen; outlen = 0; - unsigned int _t133; - _t133 = String_Len(s); - _t134 = (int)_t133; - _t135 = &outlen; - const char* _t136; - _t136 = bux_base64_decode(s, _t134, _t135); - return _t136; + unsigned int _t130; + _t130 = String_Len(s); + _t131 = (int)_t130; + _t132 = &outlen; + const char* _t133; + _t133 = bux_base64_decode(s, _t131, _t132); + return _t133; } Mutex Mutex_New(void) { - Mutex _t138; - void* _t137; - _t137 = bux_mutex_new(); - _t138 = (Mutex){.handle = _t137}; - return _t138; + Mutex _t135; + void* _t134; + _t134 = bux_mutex_new(); + _t135 = (Mutex){.handle = _t134}; + return _t135; } void Mutex_Lock(Mutex* m) { - void* _t139; - _t139 = m->handle; - bux_mutex_lock(_t139); + void* _t136; + _t136 = m->handle; + bux_mutex_lock(_t136); } void Mutex_Unlock(Mutex* m) { - void* _t140; - _t140 = m->handle; - bux_mutex_unlock(_t140); + void* _t137; + _t137 = m->handle; + bux_mutex_unlock(_t137); } void Mutex_Free(Mutex* m) { - void* _t141; - _t141 = m->handle; - bux_mutex_free(_t141); + void* _t138; + _t138 = m->handle; + bux_mutex_free(_t138); } RwLock RwLock_New(void) { - RwLock _t143; - void* _t142; - _t142 = bux_rwlock_new(); - _t143 = (RwLock){.handle = _t142}; - return _t143; + RwLock _t140; + void* _t139; + _t139 = bux_rwlock_new(); + _t140 = (RwLock){.handle = _t139}; + return _t140; } void RwLock_ReadLock(RwLock* rw) { - void* _t144; - _t144 = rw->handle; - bux_rwlock_rdlock(_t144); + void* _t141; + _t141 = rw->handle; + bux_rwlock_rdlock(_t141); } void RwLock_WriteLock(RwLock* rw) { - void* _t145; - _t145 = rw->handle; - bux_rwlock_wrlock(_t145); + void* _t142; + _t142 = rw->handle; + bux_rwlock_wrlock(_t142); } void RwLock_Unlock(RwLock* rw) { - void* _t146; - _t146 = rw->handle; - bux_rwlock_unlock(_t146); + void* _t143; + _t143 = rw->handle; + bux_rwlock_unlock(_t143); } void RwLock_Free(RwLock* rw) { - void* _t147; - _t147 = rw->handle; - bux_rwlock_free(_t147); + void* _t144; + _t144 = rw->handle; + bux_rwlock_free(_t144); } void Test_Exit(int code) { @@ -1228,15 +1227,15 @@ void Test_Exit(int code) { } void Test_Assert(bool cond) { - int _t148; - _t148 = (int)cond; - bux_assert(_t148, "", 0, ""); + int _t145; + _t145 = (int)cond; + bux_assert(_t145, "", 0, ""); } void Test_AssertEqInt(int a, int b) { - int _t149; - _t149 = (a != b); - if (!_t149) goto endif21; + int _t146; + _t146 = (a != b); + if (!_t146) goto endif20; { PrintLine("ASSERT_EQ FAILED:"); PrintInt(a); @@ -1244,27 +1243,27 @@ void Test_AssertEqInt(int a, int b) { PrintInt(b); bux_exit(1); } - endif21:; + endif20:; } void Test_AssertTrue(bool cond) { - int _t150; - _t150 = !cond; - if (!_t150) goto endif23; + int _t147; + _t147 = !cond; + if (!_t147) goto endif22; { PrintLine("ASSERT_TRUE FAILED"); bux_exit(1); } - endif23:; + endif22:; } void Test_AssertFalse(bool cond) { - if (!cond) goto endif25; + if (!cond) goto endif24; { PrintLine("ASSERT_FALSE FAILED"); bux_exit(1); } - endif25:; + endif24:; } void Test_Fail(const char* msg) { @@ -1274,735 +1273,744 @@ void Test_Fail(const char* msg) { } Result Result_NewOk(int value) { - Result _t151; + Result _t148; Result r; - _t151 = (Result){.tag = Result_Ok}; - r = _t151; + _t148 = (Result){.tag = Result_Ok}; + r = _t148; r.data.Ok_0 = value; return r; } Result Result_NewErr(const char* msg) { - Result _t152; + Result _t149; Result r; - _t152 = (Result){.tag = Result_Err}; - r = _t152; + _t149 = (Result){.tag = Result_Err}; + r = _t149; r.data.Err_0 = msg; return r; } bool Result_IsOk(Result r) { - int _t154; - Result_Tag _t153; - _t153 = r.tag; - _t154 = (_t153 == Result_Ok); - return _t154; + int _t151; + Result_Tag _t150; + _t150 = r.tag; + _t151 = (_t150 == Result_Ok); + return _t151; } bool Result_IsErr(Result r) { - int _t156; - Result_Tag _t155; - _t155 = r.tag; - _t156 = (_t155 == Result_Err); - return _t156; + int _t153; + Result_Tag _t152; + _t152 = r.tag; + _t153 = (_t152 == Result_Err); + return _t153; } int Result_Unwrap(Result r) { - int _t158; - Result_Tag _t157; - _t157 = r.tag; - _t158 = (_t157 != Result_Ok); - if (!_t158) goto endif27; + int _t155; + Result_Tag _t154; + _t154 = r.tag; + _t155 = (_t154 != Result_Ok); + if (!_t155) goto endif26; { PrintLine("panic: unwrap on Err"); return 0; } - endif27:; - Result_Data _t159; - _t159 = r.data; - int _t160; - _t160 = _t159.Ok_0; - return _t160; + endif26:; + Result_Data _t156; + _t156 = r.data; + int _t157; + _t157 = _t156.Ok_0; + return _t157; } int Result_UnwrapOr(Result r, int fallback) { - int _t162; - Result_Tag _t161; - _t161 = r.tag; - _t162 = (_t161 == Result_Ok); - if (!_t162) goto endif29; + int _t159; + Result_Tag _t158; + _t158 = r.tag; + _t159 = (_t158 == Result_Ok); + if (!_t159) goto endif28; { - Result_Data _t163; - _t163 = r.data; - int _t164; - _t164 = _t163.Ok_0; - return _t164; + Result_Data _t160; + _t160 = r.data; + int _t161; + _t161 = _t160.Ok_0; + return _t161; } - endif29:; + endif28:; return fallback; } Option Option_NewSome(int value) { - Option _t165; + Option _t162; Option o; - _t165 = (Option){.tag = Option_Some}; - o = _t165; + _t162 = (Option){.tag = Option_Some}; + o = _t162; o.data.Some_0 = value; return o; } Option Option_NewNone(void) { - Option _t166; - _t166 = (Option){.tag = Option_None}; - return _t166; + Option _t163; + _t163 = (Option){.tag = Option_None}; + return _t163; } bool Option_IsSome(Option o) { - int _t168; - Option_Tag _t167; - _t167 = o.tag; - _t168 = (_t167 == Option_Some); - return _t168; + int _t165; + Option_Tag _t164; + _t164 = o.tag; + _t165 = (_t164 == Option_Some); + return _t165; } bool Option_IsNone(Option o) { - int _t170; - Option_Tag _t169; - _t169 = o.tag; - _t170 = (_t169 == Option_None); - return _t170; + int _t167; + Option_Tag _t166; + _t166 = o.tag; + _t167 = (_t166 == Option_None); + return _t167; } int Option_Unwrap(Option o) { - int _t172; - Option_Tag _t171; - _t171 = o.tag; - _t172 = (_t171 != Option_Some); - if (!_t172) goto endif31; + int _t169; + Option_Tag _t168; + _t168 = o.tag; + _t169 = (_t168 != Option_Some); + if (!_t169) goto endif30; { PrintLine("panic: unwrap on None"); return 0; } - endif31:; - Option_Data _t173; - _t173 = o.data; - int _t174; - _t174 = _t173.Some_0; - return _t174; + endif30:; + Option_Data _t170; + _t170 = o.data; + int _t171; + _t171 = _t170.Some_0; + return _t171; } int Option_UnwrapOr(Option o, int fallback) { - int _t176; - Option_Tag _t175; - _t175 = o.tag; - _t176 = (_t175 == Option_Some); - if (!_t176) goto endif33; + int _t173; + Option_Tag _t172; + _t172 = o.tag; + _t173 = (_t172 == Option_Some); + if (!_t173) goto endif32; { - Option_Data _t177; - _t177 = o.data; - int _t178; - _t178 = _t177.Some_0; - return _t178; + Option_Data _t174; + _t174 = o.data; + int _t175; + _t175 = _t174.Some_0; + return _t175; } - endif33:; + endif32:; return fallback; } JsonValue Json_Null(void) { - JsonValue _t179; - _t179 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t179; + JsonValue _t176; + _t176 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t176; } JsonValue Json_Bool(bool b) { - JsonValue _t180; - _t180 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t180; + JsonValue _t177; + _t177 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t177; } JsonValue Json_Number(double n) { - JsonValue _t181; - _t181 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t181; + JsonValue _t178; + _t178 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t178; } JsonValue Json_String(const char* s) { - JsonValue _t182; - _t182 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t182; + JsonValue _t179; + _t179 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t179; } JsonValue Json_Array(void) { - JsonValue _t183; - _t183 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t183; + JsonValue _t180; + _t180 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t180; } JsonValue Json_Object(void) { - JsonValue _t184; - _t184 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t184; + JsonValue _t181; + _t181 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t181; } unsigned int Json_ArrayLen(JsonValue v) { - int _t186; - int _t185; - _t185 = v.tag; - _t186 = (_t185 != JsonTagArray); - if (!_t186) goto endif35; + int _t183; + int _t182; + _t182 = v.tag; + _t183 = (_t182 != JsonTagArray); + if (!_t183) goto endif34; { return 0; } - endif35:; - unsigned int _t187; - _t187 = v.arrLen; - return _t187; + endif34:; + unsigned int _t184; + _t184 = v.arrLen; + return _t184; } JsonValue Json_ArrayGet(JsonValue v, unsigned int index) { + int _t186; int _t189; - int _t192; - int _t188; - _t188 = v.tag; - _t189 = (_t188 != JsonTagArray); - if (!_t189) goto endif37; + int _t185; + _t185 = v.tag; + _t186 = (_t185 != JsonTagArray); + if (!_t186) goto endif36; + { + JsonValue _t187; + _t187 = Json_Null(); + return _t187; + } + endif36:; + unsigned int _t188; + _t188 = v.arrLen; + _t189 = (index >= _t188); + if (!_t189) goto endif38; { JsonValue _t190; _t190 = Json_Null(); return _t190; } - endif37:; - unsigned int _t191; - _t191 = v.arrLen; - _t192 = (index >= _t191); - if (!_t192) goto endif39; - { - JsonValue _t193; - _t193 = Json_Null(); - return _t193; - } - endif39:; - JsonValue* _t194; - _t194 = v.arrData; - JsonValue _t195; - _t195 = _t194[index]; - return _t195; + endif38:; + JsonValue* _t191; + _t191 = v.arrData; + JsonValue _t192; + _t192 = _t191[index]; + return _t192; } void Json_ArrayPush(JsonValue* self, JsonValue val) { + int _t194; int _t197; + int _t199; int _t200; - int _t202; - int _t204; - JsonValue* _t206; - int _t207; - void* _t209; - int _t211; - JsonValue* _t213; - int _t217; - int _t196; - _t196 = self->tag; - _t197 = (_t196 != JsonTagArray); - if (!_t197) goto endif41; + JsonValue* _t202; + int _t203; + void* _t205; + int _t206; + JsonValue* _t208; + int _t212; + int _t193; + _t193 = self->tag; + _t194 = (_t193 != JsonTagArray); + if (!_t194) goto endif40; { return; } - endif41:; - unsigned int _t198; - _t198 = self->arrLen; - unsigned int _t199; - _t199 = self->arrCap; - _t200 = (_t198 >= _t199); - if (!_t200) goto endif43; + endif40:; + unsigned int _t195; + _t195 = self->arrLen; + unsigned int _t196; + _t196 = self->arrCap; + _t197 = (_t195 >= _t196); + if (!_t197) goto endif42; { unsigned int arrNewCap; - unsigned int _t201; - _t201 = self->arrCap; - arrNewCap = _t201; - _t202 = (arrNewCap == 0); - if (!_t202) goto else44; + unsigned int _t198; + _t198 = self->arrCap; + arrNewCap = _t198; + _t199 = (arrNewCap == 0); + if (!_t199) goto else43; { self->arrCap = 4; /* sizeof(JsonValue) */ - _t204 = 4 * sizeof(JsonValue); - void* _t205; - _t205 = Alloc(_t204); - _t206 = (JsonValue*)_t205; - self->arrData = _t206; + _t200 = 4 * sizeof(JsonValue); + void* _t201; + _t201 = Alloc(_t200); + _t202 = (JsonValue*)_t201; + self->arrData = _t202; } - goto endif45; - else44:; + goto endif44; + else43:; { unsigned int doubleCap; - _t207 = arrNewCap * 2; - doubleCap = _t207; + _t203 = arrNewCap * 2; + doubleCap = _t203; self->arrCap = doubleCap; - JsonValue* _t208; - _t208 = self->arrData; - _t209 = (void*)_t208; + JsonValue* _t204; + _t204 = self->arrData; + _t205 = (void*)_t204; /* sizeof(JsonValue) */ - _t211 = doubleCap * sizeof(JsonValue); - void* _t212; - _t212 = Realloc(_t209, _t211); - _t213 = (JsonValue*)_t212; - self->arrData = _t213; + _t206 = doubleCap * sizeof(JsonValue); + void* _t207; + _t207 = Realloc(_t205, _t206); + _t208 = (JsonValue*)_t207; + self->arrData = _t208; } - endif45:; + endif44:; } - endif43:; - JsonValue* _t214; - _t214 = self->arrData; - unsigned int _t215; - _t215 = self->arrLen; - _t214[_t215] = val; - unsigned int _t216; - _t216 = self->arrLen; - _t217 = _t216 + 1; - self->arrLen = _t217; + endif42:; + JsonValue* _t209; + _t209 = self->arrData; + unsigned int _t210; + _t210 = self->arrLen; + _t209[_t210] = val; + unsigned int _t211; + _t211 = self->arrLen; + _t212 = _t211 + 1; + self->arrLen = _t212; } unsigned int Json_ObjectLen(JsonValue v) { - int _t219; - int _t218; - _t218 = v.tag; - _t219 = (_t218 != JsonTagObject); - if (!_t219) goto endif47; + int _t214; + int _t213; + _t213 = v.tag; + _t214 = (_t213 != JsonTagObject); + if (!_t214) goto endif46; { return 0; } - endif47:; - unsigned int _t220; - _t220 = v.objLen; - return _t220; + endif46:; + unsigned int _t215; + _t215 = v.objLen; + return _t215; } JsonValue Json_ObjectGet(JsonValue v, const char* key) { - int _t222; - int _t225; - int _t231; - int _t221; - _t221 = v.tag; - _t222 = (_t221 != JsonTagObject); - if (!_t222) goto endif49; + int _t217; + int _t220; + int _t226; + int _t216; + _t216 = v.tag; + _t217 = (_t216 != JsonTagObject); + if (!_t217) goto endif48; { - JsonValue _t223; - _t223 = Json_Null(); - return _t223; + JsonValue _t218; + _t218 = Json_Null(); + return _t218; } - endif49:; + endif48:; unsigned int i; i = 0; - while50:; - unsigned int _t224; - _t224 = v.objLen; - _t225 = (i < _t224); - if (!_t225) goto wend52; + while49:; + unsigned int _t219; + _t219 = v.objLen; + _t220 = (i < _t219); + if (!_t220) goto wend50; { - const char** _t226; - _t226 = v.objKeys; - const char* _t227; - _t227 = _t226[i]; - bool _t228; - _t228 = String_Eq(_t227, key); - if (!_t228) goto endif54; + const char** _t221; + _t221 = v.objKeys; + const char* _t222; + _t222 = _t221[i]; + bool _t223; + _t223 = String_Eq(_t222, key); + if (!_t223) goto endif52; { - JsonValue* _t229; - _t229 = v.objValues; - JsonValue _t230; - _t230 = _t229[i]; - return _t230; + JsonValue* _t224; + _t224 = v.objValues; + JsonValue _t225; + _t225 = _t224[i]; + return _t225; } - endif54:; - _t231 = i + 1; - i = _t231; + endif52:; + _t226 = i + 1; + i = _t226; } - goto while50; - wend52:; - JsonValue _t232; - _t232 = Json_Null(); - return _t232; + goto while49; + wend50:; + JsonValue _t227; + _t227 = Json_Null(); + return _t227; } bool Json_ObjectHas(JsonValue v, const char* key) { - int _t234; - int _t236; - int _t240; - int _t233; - _t233 = v.tag; - _t234 = (_t233 != JsonTagObject); - if (!_t234) goto endif56; + int _t229; + int _t231; + int _t235; + int _t228; + _t228 = v.tag; + _t229 = (_t228 != JsonTagObject); + if (!_t229) goto endif54; { return 0; } - endif56:; + endif54:; unsigned int i; i = 0; - while57:; - unsigned int _t235; - _t235 = v.objLen; - _t236 = (i < _t235); - if (!_t236) goto wend59; + while55:; + unsigned int _t230; + _t230 = v.objLen; + _t231 = (i < _t230); + if (!_t231) goto wend56; { - const char** _t237; - _t237 = v.objKeys; - const char* _t238; - _t238 = _t237[i]; - bool _t239; - _t239 = String_Eq(_t238, key); - if (!_t239) goto endif61; + const char** _t232; + _t232 = v.objKeys; + const char* _t233; + _t233 = _t232[i]; + bool _t234; + _t234 = String_Eq(_t233, key); + if (!_t234) goto endif58; { return 1; } - endif61:; - _t240 = i + 1; - i = _t240; + endif58:; + _t235 = i + 1; + i = _t235; } - goto while57; - wend59:; + goto while55; + wend56:; return 0; } void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) { - int _t242; + int _t237; + int _t239; int _t244; + int _t247; int _t249; - int _t252; - int _t254; + int _t250; + const char** _t252; + int _t253; + JsonValue* _t255; int _t256; - const char** _t258; - int _t260; - JsonValue* _t262; - int _t263; - void* _t265; - int _t267; - const char** _t269; - void* _t271; - int _t273; - JsonValue* _t275; - int _t281; - int _t241; - _t241 = self->tag; - _t242 = (_t241 != JsonTagObject); - if (!_t242) goto endif63; + void* _t258; + int _t259; + const char** _t261; + void* _t263; + int _t264; + JsonValue* _t266; + int _t272; + int _t236; + _t236 = self->tag; + _t237 = (_t236 != JsonTagObject); + if (!_t237) goto endif60; { return; } - endif63:; + endif60:; unsigned int i; i = 0; - while64:; - unsigned int _t243; - _t243 = self->objLen; - _t244 = (i < _t243); - if (!_t244) goto wend66; + while61:; + unsigned int _t238; + _t238 = self->objLen; + _t239 = (i < _t238); + if (!_t239) goto wend62; { - const char** _t245; - _t245 = self->objKeys; - const char* _t246; - _t246 = _t245[i]; - bool _t247; - _t247 = String_Eq(_t246, key); - if (!_t247) goto endif68; + const char** _t240; + _t240 = self->objKeys; + const char* _t241; + _t241 = _t240[i]; + bool _t242; + _t242 = String_Eq(_t241, key); + if (!_t242) goto endif64; { - JsonValue* _t248; - _t248 = self->objValues; - _t248[i] = val; + JsonValue* _t243; + _t243 = self->objValues; + _t243[i] = val; return; } - endif68:; - _t249 = i + 1; - i = _t249; + endif64:; + _t244 = i + 1; + i = _t244; } - goto while64; - wend66:; - unsigned int _t250; - _t250 = self->objLen; - unsigned int _t251; - _t251 = self->objCap; - _t252 = (_t250 >= _t251); - if (!_t252) goto endif70; + goto while61; + wend62:; + unsigned int _t245; + _t245 = self->objLen; + unsigned int _t246; + _t246 = self->objCap; + _t247 = (_t245 >= _t246); + if (!_t247) goto endif66; { unsigned int objNewCap; - unsigned int _t253; - _t253 = self->objCap; - objNewCap = _t253; - _t254 = (objNewCap == 0); - if (!_t254) goto else71; + unsigned int _t248; + _t248 = self->objCap; + objNewCap = _t248; + _t249 = (objNewCap == 0); + if (!_t249) goto else67; { self->objCap = 4; /* sizeof(const char*) */ - _t256 = 4 * sizeof(const char*); - void* _t257; - _t257 = Alloc(_t256); - _t258 = (const char**)_t257; - self->objKeys = _t258; + _t250 = 4 * sizeof(const char*); + void* _t251; + _t251 = Alloc(_t250); + _t252 = (const char**)_t251; + self->objKeys = _t252; /* sizeof(JsonValue) */ - _t260 = 4 * sizeof(JsonValue); - void* _t261; - _t261 = Alloc(_t260); - _t262 = (JsonValue*)_t261; - self->objValues = _t262; + _t253 = 4 * sizeof(JsonValue); + void* _t254; + _t254 = Alloc(_t253); + _t255 = (JsonValue*)_t254; + self->objValues = _t255; } - goto endif72; - else71:; + goto endif68; + else67:; { unsigned int doubleCap; - _t263 = objNewCap * 2; - doubleCap = _t263; + _t256 = objNewCap * 2; + doubleCap = _t256; self->objCap = doubleCap; - const char** _t264; - _t264 = self->objKeys; - _t265 = (void*)_t264; + const char** _t257; + _t257 = self->objKeys; + _t258 = (void*)_t257; /* sizeof(const char*) */ - _t267 = doubleCap * sizeof(const char*); - void* _t268; - _t268 = Realloc(_t265, _t267); - _t269 = (const char**)_t268; - self->objKeys = _t269; - JsonValue* _t270; - _t270 = self->objValues; - _t271 = (void*)_t270; + _t259 = doubleCap * sizeof(const char*); + void* _t260; + _t260 = Realloc(_t258, _t259); + _t261 = (const char**)_t260; + self->objKeys = _t261; + JsonValue* _t262; + _t262 = self->objValues; + _t263 = (void*)_t262; /* sizeof(JsonValue) */ - _t273 = doubleCap * sizeof(JsonValue); - void* _t274; - _t274 = Realloc(_t271, _t273); - _t275 = (JsonValue*)_t274; - self->objValues = _t275; + _t264 = doubleCap * sizeof(JsonValue); + void* _t265; + _t265 = Realloc(_t263, _t264); + _t266 = (JsonValue*)_t265; + self->objValues = _t266; } - endif72:; + endif68:; } - endif70:; - const char** _t276; - _t276 = self->objKeys; - unsigned int _t277; - _t277 = self->objLen; - _t276[_t277] = key; - JsonValue* _t278; - _t278 = self->objValues; - unsigned int _t279; - _t279 = self->objLen; - _t278[_t279] = val; - unsigned int _t280; - _t280 = self->objLen; - _t281 = _t280 + 1; - self->objLen = _t281; + endif66:; + const char** _t267; + _t267 = self->objKeys; + unsigned int _t268; + _t268 = self->objLen; + _t267[_t268] = key; + JsonValue* _t269; + _t269 = self->objValues; + unsigned int _t270; + _t270 = self->objLen; + _t269[_t270] = val; + unsigned int _t271; + _t271 = self->objLen; + _t272 = _t271 + 1; + self->objLen = _t272; } bool Json_IsNull(JsonValue v) { - int _t283; - int _t282; - _t282 = v.tag; - _t283 = (_t282 == JsonTagNull); - return _t283; + int _t274; + int _t273; + _t273 = v.tag; + _t274 = (_t273 == JsonTagNull); + return _t274; } bool Json_AsBool(JsonValue v) { - int _t285; - int _t284; - _t284 = v.tag; - _t285 = (_t284 == JsonTagBool); - if (!_t285) goto endif74; + int _t276; + int _t275; + _t275 = v.tag; + _t276 = (_t275 == JsonTagBool); + if (!_t276) goto endif70; { - bool _t286; - _t286 = v.boolVal; - return _t286; + bool _t277; + _t277 = v.boolVal; + return _t277; } - endif74:; + endif70:; return 0; } double Json_AsNumber(JsonValue v) { - int _t288; - int _t287; - _t287 = v.tag; - _t288 = (_t287 == JsonTagNumber); - if (!_t288) goto endif76; + int _t279; + int _t278; + _t278 = v.tag; + _t279 = (_t278 == JsonTagNumber); + if (!_t279) goto endif72; { - double _t289; - _t289 = v.numVal; - return _t289; + double _t280; + _t280 = v.numVal; + return _t280; } - endif76:; + endif72:; return 0.0; } const char* Json_AsString(JsonValue v) { - int _t291; - int _t290; - _t290 = v.tag; - _t291 = (_t290 == JsonTagString); - if (!_t291) goto endif78; + int _t282; + int _t281; + _t281 = v.tag; + _t282 = (_t281 == JsonTagString); + if (!_t282) goto endif74; { - const char* _t292; - _t292 = v.strVal; - return _t292; + const char* _t283; + _t283 = v.strVal; + return _t283; } - endif78:; + endif74:; return ""; } int JsonParser_Peek(JsonParser* p) { - int _t295; - int _t299; - unsigned int _t293; - _t293 = p->pos; - unsigned int _t294; - _t294 = p->len; - _t295 = (_t293 >= _t294); - if (!_t295) goto endif80; + int _t286; + int _t290; + unsigned int _t284; + _t284 = p->pos; + unsigned int _t285; + _t285 = p->len; + _t286 = (_t284 >= _t285); + if (!_t286) goto endif76; { return 0; } - endif80:; - const char* _t296; - _t296 = p->src; - unsigned int _t297; - _t297 = p->pos; - int _t298; - _t298 = _t296[_t297]; - _t299 = (int)_t298; - return _t299; + endif76:; + const char* _t287; + _t287 = p->src; + unsigned int _t288; + _t288 = p->pos; + int _t289; + _t289 = _t287[_t288]; + _t290 = (int)_t289; + return _t290; } void JsonParser_Advance(JsonParser* p) { - int _t302; - int _t304; - unsigned int _t300; - _t300 = p->pos; - unsigned int _t301; - _t301 = p->len; - _t302 = (_t300 < _t301); - if (!_t302) goto endif82; + int _t293; + int _t295; + unsigned int _t291; + _t291 = p->pos; + unsigned int _t292; + _t292 = p->len; + _t293 = (_t291 < _t292); + if (!_t293) goto endif78; { - unsigned int _t303; - _t303 = p->pos; - _t304 = _t303 + 1; - p->pos = _t304; + unsigned int _t294; + _t294 = p->pos; + _t295 = _t294 + 1; + p->pos = _t295; } - endif82:; + endif78:; } void JsonParser_SkipWhitespace(JsonParser* p) { - int _t306; - int _t307; - int _t309; - int _t311; - while83:; - if (!1) goto wend85; + int _t297; + int _t298; + int _t300; + int _t302; + while79:; + if (!1) goto wend80; { int c; - int _t305; - _t305 = JsonParser_Peek(p); - c = _t305; + int _t296; + _t296 = JsonParser_Peek(p); + c = _t296; bool __or_tmp_1; bool __or_tmp_2; bool __or_tmp_3; - _t306 = (c == 32); - if (!_t306) goto else86; + _t297 = (c == 32); + if (!_t297) goto else81; *(bool*)&__or_tmp_3 = 1; - goto endif87; - else86:; - _t307 = (c == 9); - *(bool*)&__or_tmp_3 = _t307; - endif87:; - bool _t308; - _t308 = *(bool*)&__or_tmp_3; - if (!_t308) goto else88; + goto endif82; + else81:; + _t298 = (c == 9); + *(bool*)&__or_tmp_3 = _t298; + endif82:; + bool _t299; + _t299 = *(bool*)&__or_tmp_3; + if (!_t299) goto else83; *(bool*)&__or_tmp_2 = 1; - goto endif89; - else88:; - _t309 = (c == 10); - *(bool*)&__or_tmp_2 = _t309; - endif89:; - bool _t310; - _t310 = *(bool*)&__or_tmp_2; - if (!_t310) goto else90; + goto endif84; + else83:; + _t300 = (c == 10); + *(bool*)&__or_tmp_2 = _t300; + endif84:; + bool _t301; + _t301 = *(bool*)&__or_tmp_2; + if (!_t301) goto else85; *(bool*)&__or_tmp_1 = 1; - goto endif91; - else90:; - _t311 = (c == 13); - *(bool*)&__or_tmp_1 = _t311; - endif91:; - bool _t312; - _t312 = *(bool*)&__or_tmp_1; - if (!_t312) goto else92; + goto endif86; + else85:; + _t302 = (c == 13); + *(bool*)&__or_tmp_1 = _t302; + endif86:; + bool _t303; + _t303 = *(bool*)&__or_tmp_1; + if (!_t303) goto else87; { JsonParser_Advance(p); } - goto endif93; - else92:; + goto endif88; + else87:; { return; } - endif93:; + endif88:; } - goto while83; - wend85:; + goto while79; + wend80:; } bool JsonParser_Match(JsonParser* p, const char* expected) { + int _t306; + int _t308; + int _t309; + int _t312; int _t315; - int _t317; + int _t316; int _t318; - int _t321; - int _t324; - int _t325; - int _t327; unsigned int elen; - unsigned int _t313; - _t313 = String_Len(expected); - elen = _t313; - unsigned int _t314; - _t314 = p->pos; - _t315 = _t314 + elen; - unsigned int _t316; - _t316 = p->len; - _t317 = (_t315 > _t316); - if (!_t317) goto endif95; + unsigned int _t304; + _t304 = String_Len(expected); + elen = _t304; + unsigned int _t305; + _t305 = p->pos; + _t306 = _t305 + elen; + unsigned int _t307; + _t307 = p->len; + _t308 = (_t306 > _t307); + if (!_t308) goto endif90; { return 0; } - endif95:; + endif90:; unsigned int i; i = 0; - while96:; - _t318 = (i < elen); - if (!_t318) goto wend98; + while91:; + _t309 = (i < elen); + if (!_t309) goto wend92; { - const char* _t319; - _t319 = p->src; - unsigned int _t320; - _t320 = p->pos; - _t321 = _t320 + i; - int _t322; - _t322 = _t319[_t321]; - int _t323; - _t323 = expected[i]; - _t324 = (_t322 != _t323); - if (!_t324) goto endif100; + const char* _t310; + _t310 = p->src; + unsigned int _t311; + _t311 = p->pos; + _t312 = _t311 + i; + int _t313; + _t313 = _t310[_t312]; + int _t314; + _t314 = expected[i]; + _t315 = (_t313 != _t314); + if (!_t315) goto endif94; { return 0; } - endif100:; - _t325 = i + 1; - i = _t325; + endif94:; + _t316 = i + 1; + i = _t316; } - goto while96; - wend98:; - unsigned int _t326; - _t326 = p->pos; - _t327 = _t326 + elen; - p->pos = _t327; + goto while91; + wend92:; + unsigned int _t317; + _t317 = p->pos; + _t318 = _t317 + elen; + p->pos = _t318; return 1; } const char* JsonParser_ParseString(JsonParser* p) { - int _t329; - int _t332; + int _t320; + int _t323; + int _t324; + int _t326; + int _t328; + void* _t329; + int _t330; + void* _t331; + char _t332; int _t333; - int _t335; - int _t337; - void* _t338; + void* _t334; + char _t335; + int _t336; + void* _t337; + char _t338; int _t339; void* _t340; char _t341; @@ -2015,234 +2023,262 @@ const char* JsonParser_ParseString(JsonParser* p) { int _t348; void* _t349; char _t350; - int _t351; - void* _t352; - char _t353; - int _t354; + void* _t351; + char _t352; + void* _t353; + char _t354; void* _t355; char _t356; - int _t357; - void* _t358; - char _t359; + int _t358; + void* _t359; void* _t360; - char _t361; void* _t362; - char _t363; - void* _t364; - char _t365; - int _t367; - void* _t368; - void* _t369; - void* _t371; - int _t328; - _t328 = JsonParser_Peek(p); - _t329 = (_t328 != 34); - if (!_t329) goto endif102; + int _t319; + _t319 = JsonParser_Peek(p); + _t320 = (_t319 != 34); + if (!_t320) goto endif96; { p->error = "Expected string"; return ""; } - endif102:; + endif96:; JsonParser_Advance(p); StringBuilder sb; - StringBuilder _t330; - _t330 = StringBuilder_New(); - sb = _t330; - while103:; - if (!1) goto wend105; + StringBuilder _t321; + _t321 = StringBuilder_New(); + sb = _t321; + while97:; + if (!1) goto wend98; { int c; - int _t331; - _t331 = JsonParser_Peek(p); - c = _t331; + int _t322; + _t322 = JsonParser_Peek(p); + c = _t322; bool __or_tmp_4; - _t332 = (c == 0); - if (!_t332) goto else106; + _t323 = (c == 0); + if (!_t323) goto else99; *(bool*)&__or_tmp_4 = 1; - goto endif107; - else106:; - _t333 = (c == 34); - *(bool*)&__or_tmp_4 = _t333; - endif107:; - bool _t334; - _t334 = *(bool*)&__or_tmp_4; - if (!_t334) goto endif109; + goto endif100; + else99:; + _t324 = (c == 34); + *(bool*)&__or_tmp_4 = _t324; + endif100:; + bool _t325; + _t325 = *(bool*)&__or_tmp_4; + if (!_t325) goto endif102; { - goto wend105; + goto wend98; } - endif109:; - _t335 = (c == 92); - if (!_t335) goto else110; + endif102:; + _t326 = (c == 92); + if (!_t326) goto else103; { JsonParser_Advance(p); int esc; - int _t336; - _t336 = JsonParser_Peek(p); - esc = _t336; - _t337 = (esc == 0); - if (!_t337) goto endif113; + int _t327; + _t327 = JsonParser_Peek(p); + esc = _t327; + _t328 = (esc == 0); + if (!_t328) goto endif106; { p->error = "Unterminated string escape"; - _t338 = &sb; - StringBuilder_Free(_t338); + _t329 = &sb; + StringBuilder_Free(_t329); return ""; } - endif113:; - _t339 = (esc == 110); - if (!_t339) goto else114; + endif106:; + _t330 = (esc == 110); + if (!_t330) goto else107; + { + _t331 = &sb; + _t332 = (char)10; + StringBuilder_AppendChar(_t331, _t332); + } + goto endif108; + else107:; + _t333 = (esc == 116); + if (!_t333) goto else109; + { + _t334 = &sb; + _t335 = (char)9; + StringBuilder_AppendChar(_t334, _t335); + } + goto endif110; + else109:; + _t336 = (esc == 114); + if (!_t336) goto else111; + { + _t337 = &sb; + _t338 = (char)13; + StringBuilder_AppendChar(_t337, _t338); + } + goto endif112; + else111:; + _t339 = (esc == 98); + if (!_t339) goto else113; { _t340 = &sb; - _t341 = (char)10; + _t341 = (char)8; StringBuilder_AppendChar(_t340, _t341); } - goto endif115; - else114:; - _t342 = (esc == 116); - if (!_t342) goto else116; + goto endif114; + else113:; + _t342 = (esc == 102); + if (!_t342) goto else115; { _t343 = &sb; - _t344 = (char)9; + _t344 = (char)12; StringBuilder_AppendChar(_t343, _t344); } - goto endif117; - else116:; - _t345 = (esc == 114); - if (!_t345) goto else118; + goto endif116; + else115:; + _t345 = (esc == 34); + if (!_t345) goto else117; { _t346 = &sb; - _t347 = (char)13; + _t347 = (char)34; StringBuilder_AppendChar(_t346, _t347); } - goto endif119; - else118:; - _t348 = (esc == 98); - if (!_t348) goto else120; + goto endif118; + else117:; + _t348 = (esc == 92); + if (!_t348) goto else119; { _t349 = &sb; - _t350 = (char)8; + _t350 = (char)92; StringBuilder_AppendChar(_t349, _t350); } - goto endif121; - else120:; - _t351 = (esc == 102); - if (!_t351) goto else122; + goto endif120; + else119:; { - _t352 = &sb; - _t353 = (char)12; - StringBuilder_AppendChar(_t352, _t353); + _t351 = &sb; + _t352 = (char)92; + StringBuilder_AppendChar(_t351, _t352); + _t353 = &sb; + _t354 = (char)esc; + StringBuilder_AppendChar(_t353, _t354); } - goto endif123; - else122:; - _t354 = (esc == 34); - if (!_t354) goto else124; + endif120:; + endif118:; + endif116:; + endif114:; + endif112:; + endif110:; + endif108:; + JsonParser_Advance(p); + } + goto endif104; + else103:; { _t355 = &sb; - _t356 = (char)34; + _t356 = (char)c; StringBuilder_AppendChar(_t355, _t356); - } - goto endif125; - else124:; - _t357 = (esc == 92); - if (!_t357) goto else126; - { - _t358 = &sb; - _t359 = (char)92; - StringBuilder_AppendChar(_t358, _t359); - } - goto endif127; - else126:; - { - _t360 = &sb; - _t361 = (char)92; - StringBuilder_AppendChar(_t360, _t361); - _t362 = &sb; - _t363 = (char)esc; - StringBuilder_AppendChar(_t362, _t363); - } - endif127:; - endif125:; - endif123:; - endif121:; - endif119:; - endif117:; - endif115:; JsonParser_Advance(p); } - goto endif111; - else110:; - { - _t364 = &sb; - _t365 = (char)c; - StringBuilder_AppendChar(_t364, _t365); - JsonParser_Advance(p); + endif104:; } - endif111:; - } - goto while103; - wend105:; - int _t366; - _t366 = JsonParser_Peek(p); - _t367 = (_t366 != 34); - if (!_t367) goto endif129; + goto while97; + wend98:; + int _t357; + _t357 = JsonParser_Peek(p); + _t358 = (_t357 != 34); + if (!_t358) goto endif122; { p->error = "Unterminated string"; - _t368 = &sb; - StringBuilder_Free(_t368); + _t359 = &sb; + StringBuilder_Free(_t359); return ""; } - endif129:; + endif122:; JsonParser_Advance(p); const char* result; - _t369 = &sb; - const char* _t370; - _t370 = StringBuilder_Build(_t369); - result = _t370; - _t371 = &sb; - StringBuilder_Free(_t371); + _t360 = &sb; + const char* _t361; + _t361 = StringBuilder_Build(_t360); + result = _t361; + _t362 = &sb; + StringBuilder_Free(_t362); return result; } JsonValue JsonParser_ParseNumber(JsonParser* p) { - int _t374; - int _t376; - int _t377; - int _t380; - int _t382; - int _t383; - int _t387; - unsigned int start; - unsigned int _t372; - _t372 = p->pos; - start = _t372; - int c0; + int _t365; + int _t367; + int _t368; + int _t371; int _t373; - _t373 = JsonParser_Peek(p); - c0 = _t373; - _t374 = (c0 == 45); - if (!_t374) goto endif131; + int _t374; + int _t378; + unsigned int start; + unsigned int _t363; + _t363 = p->pos; + start = _t363; + int c0; + int _t364; + _t364 = JsonParser_Peek(p); + c0 = _t364; + _t365 = (c0 == 45); + if (!_t365) goto endif124; { JsonParser_Advance(p); } - endif131:; - while132:; + endif124:; + while125:; + if (!1) goto wend126; + { + int c; + int _t366; + _t366 = JsonParser_Peek(p); + c = _t366; + bool __and_tmp_5; + _t367 = (c >= 48); + if (!_t367) goto else127; + _t368 = (c <= 57); + *(bool*)&__and_tmp_5 = _t368; + goto endif128; + else127:; + *(bool*)&__and_tmp_5 = 0; + endif128:; + bool _t369; + _t369 = *(bool*)&__and_tmp_5; + if (!_t369) goto else129; + { + JsonParser_Advance(p); + } + goto endif130; + else129:; + { + goto wend126; + } + endif130:; + } + goto while125; + wend126:; + int _t370; + _t370 = JsonParser_Peek(p); + _t371 = (_t370 == 46); + if (!_t371) goto endif132; + { + JsonParser_Advance(p); + while133:; if (!1) goto wend134; { int c; - int _t375; - _t375 = JsonParser_Peek(p); - c = _t375; - bool __and_tmp_5; - _t376 = (c >= 48); - if (!_t376) goto else135; - _t377 = (c <= 57); - *(bool*)&__and_tmp_5 = _t377; + int _t372; + _t372 = JsonParser_Peek(p); + c = _t372; + bool __and_tmp_6; + _t373 = (c >= 48); + if (!_t373) goto else135; + _t374 = (c <= 57); + *(bool*)&__and_tmp_6 = _t374; goto endif136; else135:; - *(bool*)&__and_tmp_5 = 0; + *(bool*)&__and_tmp_6 = 0; endif136:; - bool _t378; - _t378 = *(bool*)&__and_tmp_5; - if (!_t378) goto else137; + bool _t375; + _t375 = *(bool*)&__and_tmp_6; + if (!_t375) goto else137; { JsonParser_Advance(p); } @@ -2253,1098 +2289,1061 @@ JsonValue JsonParser_ParseNumber(JsonParser* p) { } endif138:; } - goto while132; + goto while133; wend134:; - int _t379; - _t379 = JsonParser_Peek(p); - _t380 = (_t379 == 46); - if (!_t380) goto endif140; - { - JsonParser_Advance(p); - while141:; - if (!1) goto wend143; - { - int c; - int _t381; - _t381 = JsonParser_Peek(p); - c = _t381; - bool __and_tmp_6; - _t382 = (c >= 48); - if (!_t382) goto else144; - _t383 = (c <= 57); - *(bool*)&__and_tmp_6 = _t383; - goto endif145; - else144:; - *(bool*)&__and_tmp_6 = 0; - endif145:; - bool _t384; - _t384 = *(bool*)&__and_tmp_6; - if (!_t384) goto else146; - { - JsonParser_Advance(p); } - goto endif147; - else146:; - { - goto wend143; - } - endif147:; - } - goto while141; - wend143:; - } - endif140:; + endif132:; const char* numStr; - const char* _t385; - _t385 = p->src; - unsigned int _t386; - _t386 = p->pos; - _t387 = _t386 - start; - const char* _t388; - _t388 = String_Slice(_t385, start, _t387); - numStr = _t388; + const char* _t376; + _t376 = p->src; + unsigned int _t377; + _t377 = p->pos; + _t378 = _t377 - start; + const char* _t379; + _t379 = String_Slice(_t376, start, _t378); + numStr = _t379; double n; - double _t389; - _t389 = String_ToFloat(numStr); - n = _t389; - JsonValue _t390; - _t390 = Json_Number(n); - return _t390; + double _t380; + _t380 = String_ToFloat(numStr); + n = _t380; + JsonValue _t381; + _t381 = Json_Number(n); + return _t381; } JsonValue JsonParser_ParseArray(JsonParser* p) { - int _t393; - int _t396; - void* _t398; - int _t400; - int _t401; + int _t384; + int _t387; + void* _t389; + int _t391; + int _t392; JsonParser_Advance(p); JsonValue arr; - JsonValue _t391; - _t391 = Json_Array(); - arr = _t391; + JsonValue _t382; + _t382 = Json_Array(); + arr = _t382; JsonParser_SkipWhitespace(p); - int _t392; - _t392 = JsonParser_Peek(p); - _t393 = (_t392 == 93); - if (!_t393) goto endif149; + int _t383; + _t383 = JsonParser_Peek(p); + _t384 = (_t383 == 93); + if (!_t384) goto endif140; { JsonParser_Advance(p); return arr; } - endif149:; - while150:; - if (!1) goto wend152; + endif140:; + while141:; + if (!1) goto wend142; { JsonParser_SkipWhitespace(p); JsonValue val; - JsonValue _t394; - _t394 = JsonParser_ParseValue(p); - val = _t394; - const char* _t395; - _t395 = p->error; - _t396 = (_t395 != ""); - if (!_t396) goto endif154; + JsonValue _t385; + _t385 = JsonParser_ParseValue(p); + val = _t385; + const char* _t386; + _t386 = p->error; + _t387 = (_t386 != ""); + if (!_t387) goto endif144; { - JsonValue _t397; - _t397 = Json_Null(); - return _t397; + JsonValue _t388; + _t388 = Json_Null(); + return _t388; } - endif154:; - _t398 = &arr; - Json_ArrayPush(_t398, val); + endif144:; + _t389 = &arr; + Json_ArrayPush(_t389, val); JsonParser_SkipWhitespace(p); int c; - int _t399; - _t399 = JsonParser_Peek(p); - c = _t399; - _t400 = (c == 93); - if (!_t400) goto endif156; + int _t390; + _t390 = JsonParser_Peek(p); + c = _t390; + _t391 = (c == 93); + if (!_t391) goto endif146; { JsonParser_Advance(p); return arr; } - endif156:; - _t401 = (c == 44); - if (!_t401) goto else157; + endif146:; + _t392 = (c == 44); + if (!_t392) goto else147; { JsonParser_Advance(p); } - goto endif158; - else157:; + goto endif148; + else147:; { p->error = "Expected ',' or ']' in array"; - JsonValue _t402; - _t402 = Json_Null(); - return _t402; + JsonValue _t393; + _t393 = Json_Null(); + return _t393; } - endif158:; + endif148:; } - goto while150; - wend152:; + goto while141; + wend142:; } JsonValue JsonParser_ParseObject(JsonParser* p) { - int _t405; - int _t408; + int _t396; + int _t399; + int _t402; + int _t406; + void* _t408; + int _t410; int _t411; - int _t415; - void* _t417; - int _t419; - int _t420; JsonParser_Advance(p); JsonValue obj; - JsonValue _t403; - _t403 = Json_Object(); - obj = _t403; + JsonValue _t394; + _t394 = Json_Object(); + obj = _t394; JsonParser_SkipWhitespace(p); - int _t404; - _t404 = JsonParser_Peek(p); - _t405 = (_t404 == 125); - if (!_t405) goto endif160; + int _t395; + _t395 = JsonParser_Peek(p); + _t396 = (_t395 == 125); + if (!_t396) goto endif150; + { + JsonParser_Advance(p); + return obj; + } + endif150:; + while151:; + if (!1) goto wend152; + { + JsonParser_SkipWhitespace(p); + const char* key; + const char* _t397; + _t397 = JsonParser_ParseString(p); + key = _t397; + const char* _t398; + _t398 = p->error; + _t399 = (_t398 != ""); + if (!_t399) goto endif154; + { + JsonValue _t400; + _t400 = Json_Null(); + return _t400; + } + endif154:; + JsonParser_SkipWhitespace(p); + int _t401; + _t401 = JsonParser_Peek(p); + _t402 = (_t401 != 58); + if (!_t402) goto endif156; + { + p->error = "Expected ':' after object key"; + JsonValue _t403; + _t403 = Json_Null(); + return _t403; + } + endif156:; + JsonParser_Advance(p); + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t404; + _t404 = JsonParser_ParseValue(p); + val = _t404; + const char* _t405; + _t405 = p->error; + _t406 = (_t405 != ""); + if (!_t406) goto endif158; + { + JsonValue _t407; + _t407 = Json_Null(); + return _t407; + } + endif158:; + _t408 = &obj; + Json_ObjectSet(_t408, key, val); + JsonParser_SkipWhitespace(p); + int c; + int _t409; + _t409 = JsonParser_Peek(p); + c = _t409; + _t410 = (c == 125); + if (!_t410) goto endif160; { JsonParser_Advance(p); return obj; } endif160:; - while161:; - if (!1) goto wend163; + _t411 = (c == 44); + if (!_t411) goto else161; { - JsonParser_SkipWhitespace(p); - const char* key; - const char* _t406; - _t406 = JsonParser_ParseString(p); - key = _t406; - const char* _t407; - _t407 = p->error; - _t408 = (_t407 != ""); - if (!_t408) goto endif165; - { - JsonValue _t409; - _t409 = Json_Null(); - return _t409; + JsonParser_Advance(p); } - endif165:; - JsonParser_SkipWhitespace(p); - int _t410; - _t410 = JsonParser_Peek(p); - _t411 = (_t410 != 58); - if (!_t411) goto endif167; + goto endif162; + else161:; { - p->error = "Expected ':' after object key"; + p->error = "Expected ',' or '}' in object"; JsonValue _t412; _t412 = Json_Null(); return _t412; } - endif167:; - JsonParser_Advance(p); - JsonParser_SkipWhitespace(p); - JsonValue val; - JsonValue _t413; - _t413 = JsonParser_ParseValue(p); - val = _t413; - const char* _t414; - _t414 = p->error; - _t415 = (_t414 != ""); - if (!_t415) goto endif169; - { - JsonValue _t416; - _t416 = Json_Null(); - return _t416; + endif162:; } - endif169:; - _t417 = &obj; - Json_ObjectSet(_t417, key, val); - JsonParser_SkipWhitespace(p); - int c; - int _t418; - _t418 = JsonParser_Peek(p); - c = _t418; - _t419 = (c == 125); - if (!_t419) goto endif171; - { - JsonParser_Advance(p); - return obj; - } - endif171:; - _t420 = (c == 44); - if (!_t420) goto else172; - { - JsonParser_Advance(p); - } - goto endif173; - else172:; - { - p->error = "Expected ',' or '}' in object"; - JsonValue _t421; - _t421 = Json_Null(); - return _t421; - } - endif173:; - } - goto while161; - wend163:; + goto while151; + wend152:; } JsonValue JsonParser_ParseValue(JsonParser* p) { + int _t414; + int _t416; + int _t419; + int _t421; int _t423; - int _t425; - int _t428; - int _t430; - int _t432; + int _t427; + int _t431; + int _t435; int _t436; - int _t440; - int _t444; - int _t445; - int _t447; + int _t438; JsonParser_SkipWhitespace(p); int c; - int _t422; - _t422 = JsonParser_Peek(p); - c = _t422; - _t423 = (c == 0); - if (!_t423) goto endif175; + int _t413; + _t413 = JsonParser_Peek(p); + c = _t413; + _t414 = (c == 0); + if (!_t414) goto endif164; { p->error = "Unexpected end of input"; - JsonValue _t424; - _t424 = Json_Null(); - return _t424; + JsonValue _t415; + _t415 = Json_Null(); + return _t415; } - endif175:; - _t425 = (c == 34); - if (!_t425) goto endif177; + endif164:; + _t416 = (c == 34); + if (!_t416) goto endif166; { - const char* _t426; - _t426 = JsonParser_ParseString(p); - JsonValue _t427; - _t427 = Json_String(_t426); - return _t427; + const char* _t417; + _t417 = JsonParser_ParseString(p); + JsonValue _t418; + _t418 = Json_String(_t417); + return _t418; } - endif177:; - _t428 = (c == 123); - if (!_t428) goto endif179; + endif166:; + _t419 = (c == 123); + if (!_t419) goto endif168; + { + JsonValue _t420; + _t420 = JsonParser_ParseObject(p); + return _t420; + } + endif168:; + _t421 = (c == 91); + if (!_t421) goto endif170; + { + JsonValue _t422; + _t422 = JsonParser_ParseArray(p); + return _t422; + } + endif170:; + _t423 = (c == 116); + if (!_t423) goto endif172; + { + bool _t424; + _t424 = JsonParser_Match(p, "true"); + if (!_t424) goto endif174; + { + JsonValue _t425; + _t425 = Json_Bool(1); + return _t425; + } + endif174:; + p->error = "Expected 'true'"; + JsonValue _t426; + _t426 = Json_Null(); + return _t426; + } + endif172:; + _t427 = (c == 102); + if (!_t427) goto endif176; + { + bool _t428; + _t428 = JsonParser_Match(p, "false"); + if (!_t428) goto endif178; { JsonValue _t429; - _t429 = JsonParser_ParseObject(p); + _t429 = Json_Bool(0); return _t429; } - endif179:; - _t430 = (c == 91); - if (!_t430) goto endif181; - { - JsonValue _t431; - _t431 = JsonParser_ParseArray(p); - return _t431; + endif178:; + p->error = "Expected 'false'"; + JsonValue _t430; + _t430 = Json_Null(); + return _t430; } - endif181:; - _t432 = (c == 116); - if (!_t432) goto endif183; + endif176:; + _t431 = (c == 110); + if (!_t431) goto endif180; { - bool _t433; - _t433 = JsonParser_Match(p, "true"); - if (!_t433) goto endif185; + bool _t432; + _t432 = JsonParser_Match(p, "null"); + if (!_t432) goto endif182; { + JsonValue _t433; + _t433 = Json_Null(); + return _t433; + } + endif182:; + p->error = "Expected 'null'"; JsonValue _t434; - _t434 = Json_Bool(1); + _t434 = Json_Null(); return _t434; } - endif185:; - p->error = "Expected 'true'"; - JsonValue _t435; - _t435 = Json_Null(); - return _t435; - } - endif183:; - _t436 = (c == 102); - if (!_t436) goto endif187; - { - bool _t437; - _t437 = JsonParser_Match(p, "false"); - if (!_t437) goto endif189; - { - JsonValue _t438; - _t438 = Json_Bool(0); - return _t438; - } - endif189:; - p->error = "Expected 'false'"; - JsonValue _t439; - _t439 = Json_Null(); - return _t439; - } - endif187:; - _t440 = (c == 110); - if (!_t440) goto endif191; - { - bool _t441; - _t441 = JsonParser_Match(p, "null"); - if (!_t441) goto endif193; - { - JsonValue _t442; - _t442 = Json_Null(); - return _t442; - } - endif193:; - p->error = "Expected 'null'"; - JsonValue _t443; - _t443 = Json_Null(); - return _t443; - } - endif191:; + endif180:; bool __or_tmp_7; bool __and_tmp_8; - _t444 = (c >= 48); - if (!_t444) goto else194; - _t445 = (c <= 57); - *(bool*)&__and_tmp_8 = _t445; - goto endif195; - else194:; + _t435 = (c >= 48); + if (!_t435) goto else183; + _t436 = (c <= 57); + *(bool*)&__and_tmp_8 = _t436; + goto endif184; + else183:; *(bool*)&__and_tmp_8 = 0; - endif195:; - bool _t446; - _t446 = *(bool*)&__and_tmp_8; - if (!_t446) goto else196; + endif184:; + bool _t437; + _t437 = *(bool*)&__and_tmp_8; + if (!_t437) goto else185; *(bool*)&__or_tmp_7 = 1; - goto endif197; - else196:; - _t447 = (c == 45); - *(bool*)&__or_tmp_7 = _t447; - endif197:; - bool _t448; - _t448 = *(bool*)&__or_tmp_7; - if (!_t448) goto endif199; + goto endif186; + else185:; + _t438 = (c == 45); + *(bool*)&__or_tmp_7 = _t438; + endif186:; + bool _t439; + _t439 = *(bool*)&__or_tmp_7; + if (!_t439) goto endif188; { - JsonValue _t449; - _t449 = JsonParser_ParseNumber(p); - return _t449; + JsonValue _t440; + _t440 = JsonParser_ParseNumber(p); + return _t440; } - endif199:; + endif188:; p->error = "Unexpected character"; - JsonValue _t450; - _t450 = Json_Null(); - return _t450; + JsonValue _t441; + _t441 = Json_Null(); + return _t441; } JsonValue Json_Parse(const char* s) { - JsonParser _t452; - void* _t453; - void* _t455; - int _t457; - int _t460; + JsonParser _t443; + void* _t444; + void* _t446; + int _t448; + int _t451; JsonParser p; - unsigned int _t451; - _t451 = String_Len(s); - _t452 = (JsonParser){.src = s, .pos = 0, .len = _t451, .error = ""}; - p = _t452; + unsigned int _t442; + _t442 = String_Len(s); + _t443 = (JsonParser){.src = s, .pos = 0, .len = _t442, .error = ""}; + p = _t443; JsonValue result; - _t453 = &p; - JsonValue _t454; - _t454 = JsonParser_ParseValue(_t453); - result = _t454; - _t455 = &p; - JsonParser_SkipWhitespace(_t455); + _t444 = &p; + JsonValue _t445; + _t445 = JsonParser_ParseValue(_t444); + result = _t445; + _t446 = &p; + JsonParser_SkipWhitespace(_t446); bool __and_tmp_9; - const char* _t456; - _t456 = p.error; - _t457 = (_t456 == ""); - if (!_t457) goto else200; - unsigned int _t458; - _t458 = p.pos; - unsigned int _t459; - _t459 = p.len; - _t460 = (_t458 != _t459); - *(bool*)&__and_tmp_9 = _t460; - goto endif201; - else200:; + const char* _t447; + _t447 = p.error; + _t448 = (_t447 == ""); + if (!_t448) goto else189; + unsigned int _t449; + _t449 = p.pos; + unsigned int _t450; + _t450 = p.len; + _t451 = (_t449 != _t450); + *(bool*)&__and_tmp_9 = _t451; + goto endif190; + else189:; *(bool*)&__and_tmp_9 = 0; - endif201:; - bool _t461; - _t461 = *(bool*)&__and_tmp_9; - if (!_t461) goto endif203; + endif190:; + bool _t452; + _t452 = *(bool*)&__and_tmp_9; + if (!_t452) goto endif192; { p.error = "Trailing data after JSON value"; - JsonValue _t462; - _t462 = Json_Null(); - return _t462; + JsonValue _t453; + _t453 = Json_Null(); + return _t453; } - endif203:; + endif192:; return result; } void Json_StringifyImpl(StringBuilder* sb, JsonValue v) { - int _t464; - int _t466; - int _t469; + int _t455; + int _t457; + int _t460; + int _t463; + char _t464; + char _t466; + int _t468; + char _t469; + int _t471; int _t472; char _t473; - char _t475; - int _t477; - char _t478; - int _t480; - int _t481; - char _t482; - int _t485; - char _t486; - int _t488; + int _t476; + char _t477; + int _t479; + char _t480; + int _t482; + int _t483; + char _t484; + char _t485; + char _t488; char _t489; - int _t491; int _t492; char _t493; - char _t494; - char _t497; - char _t498; - int _t501; - char _t502; - int _t463; - _t463 = v.tag; - _t464 = (_t463 == JsonTagNull); - if (!_t464) goto endif205; + int _t454; + _t454 = v.tag; + _t455 = (_t454 == JsonTagNull); + if (!_t455) goto endif194; { StringBuilder_Append(sb, "null"); return; } - endif205:; - int _t465; - _t465 = v.tag; - _t466 = (_t465 == JsonTagBool); - if (!_t466) goto endif207; + endif194:; + int _t456; + _t456 = v.tag; + _t457 = (_t456 == JsonTagBool); + if (!_t457) goto endif196; { - bool _t467; - _t467 = v.boolVal; - if (!_t467) goto else208; + bool _t458; + _t458 = v.boolVal; + if (!_t458) goto else197; { StringBuilder_Append(sb, "true"); } - goto endif209; - else208:; + goto endif198; + else197:; { StringBuilder_Append(sb, "false"); } - endif209:; + endif198:; return; } - endif207:; - int _t468; - _t468 = v.tag; - _t469 = (_t468 == JsonTagNumber); - if (!_t469) goto endif211; + endif196:; + int _t459; + _t459 = v.tag; + _t460 = (_t459 == JsonTagNumber); + if (!_t460) goto endif200; { - double _t470; - _t470 = v.numVal; - StringBuilder_AppendFloat(sb, _t470); + double _t461; + _t461 = v.numVal; + StringBuilder_AppendFloat(sb, _t461); return; } - endif211:; - int _t471; - _t471 = v.tag; - _t472 = (_t471 == JsonTagString); - if (!_t472) goto endif213; + endif200:; + int _t462; + _t462 = v.tag; + _t463 = (_t462 == JsonTagString); + if (!_t463) goto endif202; { - _t473 = (char)34; + _t464 = (char)34; + StringBuilder_AppendChar(sb, _t464); + const char* _t465; + _t465 = v.strVal; + StringBuilder_Append(sb, _t465); + _t466 = (char)34; + StringBuilder_AppendChar(sb, _t466); + return; + } + endif202:; + int _t467; + _t467 = v.tag; + _t468 = (_t467 == JsonTagArray); + if (!_t468) goto endif204; + { + _t469 = (char)91; + StringBuilder_AppendChar(sb, _t469); + unsigned int i; + i = 0; + while205:; + unsigned int _t470; + _t470 = v.arrLen; + _t471 = (i < _t470); + if (!_t471) goto wend206; + { + _t472 = (i > 0); + if (!_t472) goto endif208; + { + _t473 = (char)44; StringBuilder_AppendChar(sb, _t473); - const char* _t474; - _t474 = v.strVal; - StringBuilder_Append(sb, _t474); - _t475 = (char)34; - StringBuilder_AppendChar(sb, _t475); + } + endif208:; + JsonValue* _t474; + _t474 = v.arrData; + JsonValue _t475; + _t475 = _t474[i]; + Json_StringifyImpl(sb, _t475); + _t476 = i + 1; + i = _t476; + } + goto while205; + wend206:; + _t477 = (char)93; + StringBuilder_AppendChar(sb, _t477); return; } - endif213:; - int _t476; - _t476 = v.tag; - _t477 = (_t476 == JsonTagArray); - if (!_t477) goto endif215; + endif204:; + int _t478; + _t478 = v.tag; + _t479 = (_t478 == JsonTagObject); + if (!_t479) goto endif210; { - _t478 = (char)91; - StringBuilder_AppendChar(sb, _t478); + _t480 = (char)123; + StringBuilder_AppendChar(sb, _t480); unsigned int i; i = 0; - while216:; - unsigned int _t479; - _t479 = v.arrLen; - _t480 = (i < _t479); - if (!_t480) goto wend218; + while211:; + unsigned int _t481; + _t481 = v.objLen; + _t482 = (i < _t481); + if (!_t482) goto wend212; { - _t481 = (i > 0); - if (!_t481) goto endif220; + _t483 = (i > 0); + if (!_t483) goto endif214; { - _t482 = (char)44; - StringBuilder_AppendChar(sb, _t482); + _t484 = (char)44; + StringBuilder_AppendChar(sb, _t484); } - endif220:; - JsonValue* _t483; - _t483 = v.arrData; - JsonValue _t484; - _t484 = _t483[i]; - Json_StringifyImpl(sb, _t484); - _t485 = i + 1; - i = _t485; - } - goto while216; - wend218:; - _t486 = (char)93; - StringBuilder_AppendChar(sb, _t486); - return; - } - endif215:; - int _t487; - _t487 = v.tag; - _t488 = (_t487 == JsonTagObject); - if (!_t488) goto endif222; - { - _t489 = (char)123; + endif214:; + _t485 = (char)34; + StringBuilder_AppendChar(sb, _t485); + const char** _t486; + _t486 = v.objKeys; + const char* _t487; + _t487 = _t486[i]; + StringBuilder_Append(sb, _t487); + _t488 = (char)34; + StringBuilder_AppendChar(sb, _t488); + _t489 = (char)58; StringBuilder_AppendChar(sb, _t489); - unsigned int i; - i = 0; - while223:; - unsigned int _t490; - _t490 = v.objLen; - _t491 = (i < _t490); - if (!_t491) goto wend225; - { - _t492 = (i > 0); - if (!_t492) goto endif227; - { - _t493 = (char)44; + JsonValue* _t490; + _t490 = v.objValues; + JsonValue _t491; + _t491 = _t490[i]; + Json_StringifyImpl(sb, _t491); + _t492 = i + 1; + i = _t492; + } + goto while211; + wend212:; + _t493 = (char)125; StringBuilder_AppendChar(sb, _t493); - } - endif227:; - _t494 = (char)34; - StringBuilder_AppendChar(sb, _t494); - const char** _t495; - _t495 = v.objKeys; - const char* _t496; - _t496 = _t495[i]; - StringBuilder_Append(sb, _t496); - _t497 = (char)34; - StringBuilder_AppendChar(sb, _t497); - _t498 = (char)58; - StringBuilder_AppendChar(sb, _t498); - JsonValue* _t499; - _t499 = v.objValues; - JsonValue _t500; - _t500 = _t499[i]; - Json_StringifyImpl(sb, _t500); - _t501 = i + 1; - i = _t501; - } - goto while223; - wend225:; - _t502 = (char)125; - StringBuilder_AppendChar(sb, _t502); return; } - endif222:; + endif210:; } const char* Json_Stringify(JsonValue v) { - void* _t504; - void* _t505; + void* _t495; + void* _t496; StringBuilder sb; - StringBuilder _t503; - _t503 = StringBuilder_New(); - sb = _t503; - _t504 = &sb; - Json_StringifyImpl(_t504, v); - _t505 = &sb; - const char* _t506; - _t506 = StringBuilder_Build(_t505); - return _t506; + StringBuilder _t494; + _t494 = StringBuilder_New(); + sb = _t494; + _t495 = &sb; + Json_StringifyImpl(_t495, v); + _t496 = &sb; + const char* _t497; + _t497 = StringBuilder_Build(_t496); + return _t497; } unsigned int String_Len(const char* s) { - unsigned int _t507; - _t507 = bux_strlen(s); - return _t507; + unsigned int _t498; + _t498 = bux_strlen(s); + return _t498; } bool String_IsNull(const char* s) { - int _t509; - int _t508; - _t508 = bux_str_is_null(s); - _t509 = (_t508 != 0); - return _t509; + int _t500; + int _t499; + _t499 = bux_str_is_null(s); + _t500 = (_t499 != 0); + return _t500; } bool String_Eq(const char* a, const char* b) { - int _t511; - int _t510; - _t510 = bux_strcmp(a, b); - _t511 = (_t510 == 0); - return _t511; + int _t502; + int _t501; + _t501 = bux_strcmp(a, b); + _t502 = (_t501 == 0); + return _t502; } const char* String_Concat(const char* a, const char* b) { - int _t514; - int _t515; - char* _t517; + int _t505; + int _t506; + char* _t508; unsigned int len_a; - unsigned int _t512; - _t512 = bux_strlen(a); - len_a = _t512; + unsigned int _t503; + _t503 = bux_strlen(a); + len_a = _t503; unsigned int len_b; - unsigned int _t513; - _t513 = bux_strlen(b); - len_b = _t513; + unsigned int _t504; + _t504 = bux_strlen(b); + len_b = _t504; unsigned int total; - _t514 = len_a + len_b; - _t515 = _t514 + 1; - total = _t515; + _t505 = len_a + len_b; + _t506 = _t505 + 1; + total = _t506; char* buf; - void* _t516; - _t516 = bux_alloc(total); - _t517 = (char*)_t516; - buf = _t517; + void* _t507; + _t507 = bux_alloc(total); + _t508 = (char*)_t507; + buf = _t508; bux_strcpy(buf, a); bux_strcat(buf, b); return buf; } const char* String_Copy(const char* s) { - int _t519; - char* _t521; + int _t510; + char* _t512; unsigned int len; - unsigned int _t518; - _t518 = bux_strlen(s); - len = _t518; + unsigned int _t509; + _t509 = bux_strlen(s); + len = _t509; char* buf; - _t519 = len + 1; - void* _t520; - _t520 = bux_alloc(_t519); - _t521 = (char*)_t520; - buf = _t521; + _t510 = len + 1; + void* _t511; + _t511 = bux_alloc(_t510); + _t512 = (char*)_t511; + buf = _t512; bux_strcpy(buf, s); return buf; } bool String_StartsWith(const char* s, const char* prefix) { - int _t524; - int _t526; + int _t515; + int _t517; unsigned int s_len; - unsigned int _t522; - _t522 = bux_strlen(s); - s_len = _t522; + unsigned int _t513; + _t513 = bux_strlen(s); + s_len = _t513; unsigned int p_len; - unsigned int _t523; - _t523 = bux_strlen(prefix); - p_len = _t523; - _t524 = (p_len > s_len); - if (!_t524) goto endif229; + unsigned int _t514; + _t514 = bux_strlen(prefix); + p_len = _t514; + _t515 = (p_len > s_len); + if (!_t515) goto endif216; { return 0; } - endif229:; + endif216:; int r; - int _t525; - _t525 = bux_strncmp(s, prefix, p_len); - r = _t525; - _t526 = (r == 0); - return _t526; + int _t516; + _t516 = bux_strncmp(s, prefix, p_len); + r = _t516; + _t517 = (r == 0); + return _t517; } bool String_EndsWith(const char* s, const char* suffix) { - int _t529; - int _t530; - int _t533; + int _t520; + int _t521; + int _t524; unsigned int s_len; - unsigned int _t527; - _t527 = bux_strlen(s); - s_len = _t527; + unsigned int _t518; + _t518 = bux_strlen(s); + s_len = _t518; unsigned int suf_len; - unsigned int _t528; - _t528 = bux_strlen(suffix); - suf_len = _t528; - _t529 = (suf_len > s_len); - if (!_t529) goto endif231; + unsigned int _t519; + _t519 = bux_strlen(suffix); + suf_len = _t519; + _t520 = (suf_len > s_len); + if (!_t520) goto endif218; { return 0; } - endif231:; + endif218:; unsigned int start; - _t530 = s_len - suf_len; - start = _t530; + _t521 = s_len - suf_len; + start = _t521; const char* tail; - const char* _t531; - _t531 = bux_str_slice(s, start, suf_len); - tail = _t531; + const char* _t522; + _t522 = bux_str_slice(s, start, suf_len); + tail = _t522; bool eq; - int _t532; - _t532 = bux_strcmp(tail, suffix); - _t533 = (_t532 == 0); - eq = _t533; + int _t523; + _t523 = bux_strcmp(tail, suffix); + _t524 = (_t523 == 0); + eq = _t524; return eq; } bool String_Contains(const char* s, const char* substr) { - int _t535; + int _t526; int r; - int _t534; - _t534 = bux_str_contains(s, substr); - r = _t534; - _t535 = (r != 0); - return _t535; + int _t525; + _t525 = bux_str_contains(s, substr); + r = _t525; + _t526 = (r != 0); + return _t526; } const char* String_Slice(const char* s, unsigned int start, unsigned int len) { - const char* _t536; - _t536 = bux_str_slice(s, start, len); - return _t536; + const char* _t527; + _t527 = bux_str_slice(s, start, len); + return _t527; } const char* String_Trim(const char* s) { - const char* _t537; - _t537 = bux_str_trim(s); - return _t537; + const char* _t528; + _t528 = bux_str_trim(s); + return _t528; } const char* String_TrimLeft(const char* s) { - const char* _t538; - _t538 = bux_str_trim_left(s); - return _t538; + const char* _t529; + _t529 = bux_str_trim_left(s); + return _t529; } const char* String_TrimRight(const char* s) { - const char* _t539; - _t539 = bux_str_trim_right(s); - return _t539; + const char* _t530; + _t530 = bux_str_trim_right(s); + return _t530; } const char* String_FromInt(int64_t n) { - const char* _t540; - _t540 = bux_int_to_str(n); - return _t540; + const char* _t531; + _t531 = bux_int_to_str(n); + return _t531; } int64_t String_ToInt(const char* s) { - int64_t _t541; - _t541 = bux_str_to_int(s); - return _t541; + int64_t _t532; + _t532 = bux_str_to_int(s); + return _t532; } StringBuilder StringBuilder_New(void) { - StringBuilder _t543; - void* _t542; - _t542 = bux_sb_new(64); - _t543 = (StringBuilder){.handle = _t542}; - return _t543; + StringBuilder _t534; + void* _t533; + _t533 = bux_sb_new(64); + _t534 = (StringBuilder){.handle = _t533}; + return _t534; } StringBuilder StringBuilder_NewCap(unsigned int cap) { - StringBuilder _t545; - void* _t544; - _t544 = bux_sb_new(cap); - _t545 = (StringBuilder){.handle = _t544}; - return _t545; + StringBuilder _t536; + void* _t535; + _t535 = bux_sb_new(cap); + _t536 = (StringBuilder){.handle = _t535}; + return _t536; } void StringBuilder_Append(StringBuilder* sb, const char* s) { - void* _t546; - _t546 = sb->handle; - bux_sb_append(_t546, s); + void* _t537; + _t537 = sb->handle; + bux_sb_append(_t537, s); } void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) { - void* _t547; - _t547 = sb->handle; - bux_sb_append_int(_t547, n); + void* _t538; + _t538 = sb->handle; + bux_sb_append_int(_t538, n); } void StringBuilder_AppendFloat(StringBuilder* sb, double f) { - void* _t548; - _t548 = sb->handle; - bux_sb_append_float(_t548, f); + void* _t539; + _t539 = sb->handle; + bux_sb_append_float(_t539, f); } void StringBuilder_AppendChar(StringBuilder* sb, char c) { - void* _t549; - _t549 = sb->handle; - bux_sb_append_char(_t549, c); + void* _t540; + _t540 = sb->handle; + bux_sb_append_char(_t540, c); } const char* StringBuilder_Build(StringBuilder* sb) { - void* _t550; - _t550 = sb->handle; - const char* _t551; - _t551 = bux_sb_build(_t550); - return _t551; + void* _t541; + _t541 = sb->handle; + const char* _t542; + _t542 = bux_sb_build(_t541); + return _t542; } void StringBuilder_Free(StringBuilder* sb) { - void* _t552; - _t552 = sb->handle; - bux_sb_free(_t552); + void* _t543; + _t543 = sb->handle; + bux_sb_free(_t543); } unsigned int String_SplitCount(const char* s, const char* delim) { - unsigned int _t553; - _t553 = bux_str_split_count(s, delim); - return _t553; + unsigned int _t544; + _t544 = bux_str_split_count(s, delim); + return _t544; } const char* String_SplitPart(const char* s, const char* delim, unsigned int index) { - const char* _t554; - _t554 = bux_str_split_part(s, delim, index); - return _t554; + const char* _t545; + _t545 = bux_str_split_part(s, delim, index); + return _t545; } const char* String_Join2(const char* a, const char* b, const char* sep) { - const char* _t555; - _t555 = bux_str_join2(a, b, sep); - return _t555; + const char* _t546; + _t546 = bux_str_join2(a, b, sep); + return _t546; } const char* String_Chars(const char* s, unsigned int index) { - const char* _t556; - _t556 = bux_str_slice(s, index, 1); - return _t556; + const char* _t547; + _t547 = bux_str_slice(s, index, 1); + return _t547; } const char* String_Find(const char* haystack, const char* needle) { - const char* _t557; - _t557 = bux_strstr(haystack, needle); - return _t557; + const char* _t548; + _t548 = bux_strstr(haystack, needle); + return _t548; } unsigned int String_Offset(const char* pos, const char* base) { - unsigned int _t558; - _t558 = bux_str_offset(pos, base); - return _t558; + unsigned int _t549; + _t549 = bux_str_offset(pos, base); + return _t549; } const char* String_Replace(const char* s, const char* old, const char* new) { - int _t564; - int _t566; - int _t567; + int _t555; + int _t557; + int _t558; const char* pos; - const char* _t559; - _t559 = bux_strstr(s, old); - pos = _t559; - bool _t560; - _t560 = String_IsNull(pos); - if (!_t560) goto endif233; + const char* _t550; + _t550 = bux_strstr(s, old); + pos = _t550; + bool _t551; + _t551 = String_IsNull(pos); + if (!_t551) goto endif220; { return s; } - endif233:; + endif220:; unsigned int oldLen; - unsigned int _t561; - _t561 = bux_strlen(old); - oldLen = _t561; + unsigned int _t552; + _t552 = bux_strlen(old); + oldLen = _t552; unsigned int prefixLen; - unsigned int _t562; - _t562 = String_Offset(pos, s); - prefixLen = _t562; + unsigned int _t553; + _t553 = String_Offset(pos, s); + prefixLen = _t553; const char* prefix; - const char* _t563; - _t563 = bux_str_slice(s, 0, prefixLen); - prefix = _t563; + const char* _t554; + _t554 = bux_str_slice(s, 0, prefixLen); + prefix = _t554; const char* suffix; - _t564 = prefixLen + oldLen; - unsigned int _t565; - _t565 = bux_strlen(s); - _t566 = _t565 - prefixLen; - _t567 = _t566 - oldLen; - const char* _t568; - _t568 = bux_str_slice(s, _t564, _t567); - suffix = _t568; + _t555 = prefixLen + oldLen; + unsigned int _t556; + _t556 = bux_strlen(s); + _t557 = _t556 - prefixLen; + _t558 = _t557 - oldLen; + const char* _t559; + _t559 = bux_str_slice(s, _t555, _t558); + suffix = _t559; const char* temp; - const char* _t569; - _t569 = String_Concat(prefix, new); - temp = _t569; + const char* _t560; + _t560 = String_Concat(prefix, new); + temp = _t560; const char* result; - const char* _t570; - _t570 = String_Concat(temp, suffix); - result = _t570; + const char* _t561; + _t561 = String_Concat(temp, suffix); + result = _t561; return result; } double String_ToFloat(const char* s) { - double _t571; - _t571 = bux_str_to_float(s); - return _t571; + double _t562; + _t562 = bux_str_to_float(s); + return _t562; } const char* String_FromBool(bool b) { - if (!b) goto endif235; + if (!b) goto endif222; { return "true"; } - endif235:; + endif222:; return "false"; } const char* String_FromFloat(double f) { - const char* _t572; - _t572 = bux_float_to_string(f); - return _t572; + const char* _t563; + _t563 = bux_float_to_string(f); + return _t563; } const char* String_Format1(const char* pattern, const char* a0) { - const char* _t573; - _t573 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); - return _t573; + const char* _t564; + _t564 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); + return _t564; } const char* String_Format2(const char* pattern, const char* a0, const char* a1) { - const char* _t574; - _t574 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); - return _t574; + const char* _t565; + _t565 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); + return _t565; } const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) { - const char* _t575; - _t575 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); - return _t575; + const char* _t566; + _t566 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); + return _t566; } void Channel_SendInt(Channel_int* ch, int value) { - void* _t577; - void* _t578; - void* _t576; - _t576 = ch->handle; - _t577 = &value; - _t578 = (void*)_t577; - bux_channel_send(_t576, _t578); + void* _t568; + void* _t569; + void* _t567; + _t567 = ch->handle; + _t568 = &value; + _t569 = (void*)_t568; + bux_channel_send(_t567, _t569); } int Channel_RecvInt(Channel_int* ch) { - void* _t580; - void* _t581; + void* _t571; + void* _t572; int result; result = 0; - void* _t579; - _t579 = ch->handle; - _t580 = &result; - _t581 = (void*)_t580; - bux_channel_recv(_t579, _t581); + void* _t570; + _t570 = ch->handle; + _t571 = &result; + _t572 = (void*)_t571; + bux_channel_recv(_t570, _t572); return result; } void Channel_SendFloat64(Channel_float64* ch, double value) { - void* _t583; - void* _t584; - void* _t582; - _t582 = ch->handle; - _t583 = &value; - _t584 = (void*)_t583; - bux_channel_send(_t582, _t584); + void* _t574; + void* _t575; + void* _t573; + _t573 = ch->handle; + _t574 = &value; + _t575 = (void*)_t574; + bux_channel_send(_t573, _t575); } double Channel_RecvFloat64(Channel_float64* ch) { - void* _t586; - void* _t587; + void* _t577; + void* _t578; double result; result = 0.0; - void* _t585; - _t585 = ch->handle; - _t586 = &result; - _t587 = (void*)_t586; - bux_channel_recv(_t585, _t587); + void* _t576; + _t576 = ch->handle; + _t577 = &result; + _t578 = (void*)_t577; + bux_channel_recv(_t576, _t578); return result; } const char* Hash_Sha1(const char* data) { - int _t589; + int _t580; int len; - unsigned int _t588; - _t588 = String_Len(data); - _t589 = (int)_t588; - len = _t589; + unsigned int _t579; + _t579 = String_Len(data); + _t580 = (int)_t579; + len = _t580; void* buf; - void* _t590; - _t590 = Alloc(20); - buf = _t590; + void* _t581; + _t581 = Alloc(20); + buf = _t581; bux_sha1(data, len, buf); const char* result; - const char* _t591; - _t591 = bux_bytes_to_hex(buf, 20); - result = _t591; + const char* _t582; + _t582 = bux_bytes_to_hex(buf, 20); + result = _t582; Free(buf); return result; } const char* Hash_Sha256(const char* data) { - int _t593; + int _t584; int len; - unsigned int _t592; - _t592 = String_Len(data); - _t593 = (int)_t592; - len = _t593; + unsigned int _t583; + _t583 = String_Len(data); + _t584 = (int)_t583; + len = _t584; void* buf; - void* _t594; - _t594 = Alloc(32); - buf = _t594; + void* _t585; + _t585 = Alloc(32); + buf = _t585; bux_sha256(data, len, buf); const char* result; - const char* _t595; - _t595 = bux_bytes_to_hex(buf, 32); - result = _t595; + const char* _t586; + _t586 = bux_bytes_to_hex(buf, 32); + result = _t586; Free(buf); return result; } const char* Hash_Sha384(const char* data) { - int _t597; + int _t588; int len; - unsigned int _t596; - _t596 = String_Len(data); - _t597 = (int)_t596; - len = _t597; + unsigned int _t587; + _t587 = String_Len(data); + _t588 = (int)_t587; + len = _t588; void* buf; - void* _t598; - _t598 = Alloc(48); - buf = _t598; + void* _t589; + _t589 = Alloc(48); + buf = _t589; bux_sha384(data, len, buf); const char* result; - const char* _t599; - _t599 = bux_bytes_to_hex(buf, 48); - result = _t599; + const char* _t590; + _t590 = bux_bytes_to_hex(buf, 48); + result = _t590; Free(buf); return result; } const char* Hash_Sha512(const char* data) { - int _t601; + int _t592; int len; - unsigned int _t600; - _t600 = String_Len(data); - _t601 = (int)_t600; - len = _t601; + unsigned int _t591; + _t591 = String_Len(data); + _t592 = (int)_t591; + len = _t592; void* buf; - void* _t602; - _t602 = Alloc(64); - buf = _t602; + void* _t593; + _t593 = Alloc(64); + buf = _t593; bux_sha512(data, len, buf); const char* result; - const char* _t603; - _t603 = bux_bytes_to_hex(buf, 64); - result = _t603; + const char* _t594; + _t594 = bux_bytes_to_hex(buf, 64); + result = _t594; Free(buf); return result; } void Hash_Sha256Raw(const char* data, void* out) { - int _t605; - unsigned int _t604; - _t604 = String_Len(data); - _t605 = (int)_t604; - bux_sha256(data, _t605, out); + int _t596; + unsigned int _t595; + _t595 = String_Len(data); + _t596 = (int)_t595; + bux_sha256(data, _t596, out); } void Hash_Sha384Raw(const char* data, void* out) { - int _t607; - unsigned int _t606; - _t606 = String_Len(data); - _t607 = (int)_t606; - bux_sha384(data, _t607, out); + int _t598; + unsigned int _t597; + _t597 = String_Len(data); + _t598 = (int)_t597; + bux_sha384(data, _t598, out); } void Hash_Sha512Raw(const char* data, void* out) { - int _t609; - unsigned int _t608; - _t608 = String_Len(data); - _t609 = (int)_t608; - bux_sha512(data, _t609, out); + int _t600; + unsigned int _t599; + _t599 = String_Len(data); + _t600 = (int)_t599; + bux_sha512(data, _t600, out); } int Hash_Sha1Size(void) { @@ -3364,1455 +3363,1455 @@ int Hash_Sha512Size(void) { } const char* Base64_Encode(const char* s) { - int _t611; - unsigned int _t610; - _t610 = String_Len(s); - _t611 = (int)_t610; - const char* _t612; - _t612 = bux_base64_encode(s, _t611); - return _t612; + int _t602; + unsigned int _t601; + _t601 = String_Len(s); + _t602 = (int)_t601; + const char* _t603; + _t603 = bux_base64_encode(s, _t602); + return _t603; } const char* Base64_Decode(const char* s) { - int _t614; - void* _t615; + int _t605; + void* _t606; int outlen; outlen = 0; - unsigned int _t613; - _t613 = String_Len(s); - _t614 = (int)_t613; - _t615 = &outlen; - const char* _t616; - _t616 = bux_base64_decode(s, _t614, _t615); - return _t616; + unsigned int _t604; + _t604 = String_Len(s); + _t605 = (int)_t604; + _t606 = &outlen; + const char* _t607; + _t607 = bux_base64_decode(s, _t605, _t606); + return _t607; } const char* Base64URL_Encode(const char* s) { - int _t618; - unsigned int _t617; - _t617 = String_Len(s); - _t618 = (int)_t617; - const char* _t619; - _t619 = bux_base64url_encode(s, _t618); - return _t619; + int _t609; + unsigned int _t608; + _t608 = String_Len(s); + _t609 = (int)_t608; + const char* _t610; + _t610 = bux_base64url_encode(s, _t609); + return _t610; } const char* Base64URL_Decode(const char* s) { - int _t621; - void* _t622; + int _t612; + void* _t613; int outlen; outlen = 0; - unsigned int _t620; - _t620 = String_Len(s); - _t621 = (int)_t620; - _t622 = &outlen; - const char* _t623; - _t623 = bux_base64url_decode(s, _t621, _t622); - return _t623; + unsigned int _t611; + _t611 = String_Len(s); + _t612 = (int)_t611; + _t613 = &outlen; + const char* _t614; + _t614 = bux_base64url_decode(s, _t612, _t613); + return _t614; } const char* Hmac_Sha256(const char* key, const char* message) { - int _t625; - int _t627; + int _t616; + int _t618; int kl; - unsigned int _t624; - _t624 = String_Len(key); - _t625 = (int)_t624; - kl = _t625; + unsigned int _t615; + _t615 = String_Len(key); + _t616 = (int)_t615; + kl = _t616; int ml; - unsigned int _t626; - _t626 = String_Len(message); - _t627 = (int)_t626; - ml = _t627; + unsigned int _t617; + _t617 = String_Len(message); + _t618 = (int)_t617; + ml = _t618; void* buf; - void* _t628; - _t628 = Alloc(32); - buf = _t628; + void* _t619; + _t619 = Alloc(32); + buf = _t619; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - const char* _t629; - _t629 = bux_bytes_to_hex(buf, 32); - result = _t629; + const char* _t620; + _t620 = bux_bytes_to_hex(buf, 32); + result = _t620; Free(buf); return result; } void Hmac_Sha256Raw(const char* key, const char* message, void* out) { - int _t631; - int _t633; - unsigned int _t630; - _t630 = String_Len(key); - _t631 = (int)_t630; - unsigned int _t632; - _t632 = String_Len(message); - _t633 = (int)_t632; - bux_hmac_sha256(key, _t631, message, _t633, out); + int _t622; + int _t624; + unsigned int _t621; + _t621 = String_Len(key); + _t622 = (int)_t621; + unsigned int _t623; + _t623 = String_Len(message); + _t624 = (int)_t623; + bux_hmac_sha256(key, _t622, message, _t624, out); } const char* Hmac_Sha256Base64(const char* key, const char* message) { - int _t635; - int _t637; - const char* _t639; + int _t626; + int _t628; + const char* _t630; int kl; - unsigned int _t634; - _t634 = String_Len(key); - _t635 = (int)_t634; - kl = _t635; + unsigned int _t625; + _t625 = String_Len(key); + _t626 = (int)_t625; + kl = _t626; int ml; - unsigned int _t636; - _t636 = String_Len(message); - _t637 = (int)_t636; - ml = _t637; + unsigned int _t627; + _t627 = String_Len(message); + _t628 = (int)_t627; + ml = _t628; void* buf; - void* _t638; - _t638 = Alloc(32); - buf = _t638; + void* _t629; + _t629 = Alloc(32); + buf = _t629; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - _t639 = (const char*)buf; - const char* _t640; - _t640 = bux_base64_encode(_t639, 32); - result = _t640; + _t630 = (const char*)buf; + const char* _t631; + _t631 = bux_base64_encode(_t630, 32); + result = _t631; Free(buf); return result; } const char* Hmac_Sha384(const char* key, const char* message) { - int _t642; - int _t644; + int _t633; + int _t635; int kl; - unsigned int _t641; - _t641 = String_Len(key); - _t642 = (int)_t641; - kl = _t642; + unsigned int _t632; + _t632 = String_Len(key); + _t633 = (int)_t632; + kl = _t633; int ml; - unsigned int _t643; - _t643 = String_Len(message); - _t644 = (int)_t643; - ml = _t644; + unsigned int _t634; + _t634 = String_Len(message); + _t635 = (int)_t634; + ml = _t635; void* buf; - void* _t645; - _t645 = Alloc(48); - buf = _t645; + void* _t636; + _t636 = Alloc(48); + buf = _t636; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - const char* _t646; - _t646 = bux_bytes_to_hex(buf, 48); - result = _t646; + const char* _t637; + _t637 = bux_bytes_to_hex(buf, 48); + result = _t637; Free(buf); return result; } void Hmac_Sha384Raw(const char* key, const char* message, void* out) { - int _t648; - int _t650; - unsigned int _t647; - _t647 = String_Len(key); - _t648 = (int)_t647; - unsigned int _t649; - _t649 = String_Len(message); - _t650 = (int)_t649; - bux_hmac_sha384(key, _t648, message, _t650, out); + int _t639; + int _t641; + unsigned int _t638; + _t638 = String_Len(key); + _t639 = (int)_t638; + unsigned int _t640; + _t640 = String_Len(message); + _t641 = (int)_t640; + bux_hmac_sha384(key, _t639, message, _t641, out); } const char* Hmac_Sha384Base64(const char* key, const char* message) { - int _t652; - int _t654; - const char* _t656; + int _t643; + int _t645; + const char* _t647; int kl; - unsigned int _t651; - _t651 = String_Len(key); - _t652 = (int)_t651; - kl = _t652; + unsigned int _t642; + _t642 = String_Len(key); + _t643 = (int)_t642; + kl = _t643; int ml; - unsigned int _t653; - _t653 = String_Len(message); - _t654 = (int)_t653; - ml = _t654; + unsigned int _t644; + _t644 = String_Len(message); + _t645 = (int)_t644; + ml = _t645; void* buf; - void* _t655; - _t655 = Alloc(48); - buf = _t655; + void* _t646; + _t646 = Alloc(48); + buf = _t646; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - _t656 = (const char*)buf; - const char* _t657; - _t657 = bux_base64_encode(_t656, 48); - result = _t657; + _t647 = (const char*)buf; + const char* _t648; + _t648 = bux_base64_encode(_t647, 48); + result = _t648; Free(buf); return result; } const char* Hmac_Sha512(const char* key, const char* message) { - int _t659; - int _t661; + int _t650; + int _t652; int kl; - unsigned int _t658; - _t658 = String_Len(key); - _t659 = (int)_t658; - kl = _t659; + unsigned int _t649; + _t649 = String_Len(key); + _t650 = (int)_t649; + kl = _t650; int ml; - unsigned int _t660; - _t660 = String_Len(message); - _t661 = (int)_t660; - ml = _t661; + unsigned int _t651; + _t651 = String_Len(message); + _t652 = (int)_t651; + ml = _t652; void* buf; - void* _t662; - _t662 = Alloc(64); - buf = _t662; + void* _t653; + _t653 = Alloc(64); + buf = _t653; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - const char* _t663; - _t663 = bux_bytes_to_hex(buf, 64); - result = _t663; + const char* _t654; + _t654 = bux_bytes_to_hex(buf, 64); + result = _t654; Free(buf); return result; } void Hmac_Sha512Raw(const char* key, const char* message, void* out) { - int _t665; - int _t667; - unsigned int _t664; - _t664 = String_Len(key); - _t665 = (int)_t664; - unsigned int _t666; - _t666 = String_Len(message); - _t667 = (int)_t666; - bux_hmac_sha512(key, _t665, message, _t667, out); + int _t656; + int _t658; + unsigned int _t655; + _t655 = String_Len(key); + _t656 = (int)_t655; + unsigned int _t657; + _t657 = String_Len(message); + _t658 = (int)_t657; + bux_hmac_sha512(key, _t656, message, _t658, out); } const char* Hmac_Sha512Base64(const char* key, const char* message) { - int _t669; - int _t671; - const char* _t673; + int _t660; + int _t662; + const char* _t664; int kl; - unsigned int _t668; - _t668 = String_Len(key); - _t669 = (int)_t668; - kl = _t669; + unsigned int _t659; + _t659 = String_Len(key); + _t660 = (int)_t659; + kl = _t660; int ml; - unsigned int _t670; - _t670 = String_Len(message); - _t671 = (int)_t670; - ml = _t671; + unsigned int _t661; + _t661 = String_Len(message); + _t662 = (int)_t661; + ml = _t662; void* buf; - void* _t672; - _t672 = Alloc(64); - buf = _t672; + void* _t663; + _t663 = Alloc(64); + buf = _t663; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - _t673 = (const char*)buf; - const char* _t674; - _t674 = bux_base64_encode(_t673, 64); - result = _t674; + _t664 = (const char*)buf; + const char* _t665; + _t665 = bux_base64_encode(_t664, 64); + result = _t665; Free(buf); return result; } const char* Random_Bytes(int n) { - int _t675; - unsigned int _t676; - int _t679; - const char* _t680; - _t675 = (n <= 0); - if (!_t675) goto endif237; + int _t666; + unsigned int _t667; + int _t670; + const char* _t671; + _t666 = (n <= 0); + if (!_t666) goto endif224; { return ""; } - endif237:; + endif224:; void* buf; - _t676 = (unsigned int)n; - void* _t677; - _t677 = Alloc(_t676); - buf = _t677; - int _t678; - _t678 = bux_random_bytes(buf, n); - _t679 = (_t678 != 1); - if (!_t679) goto endif239; + _t667 = (unsigned int)n; + void* _t668; + _t668 = Alloc(_t667); + buf = _t668; + int _t669; + _t669 = bux_random_bytes(buf, n); + _t670 = (_t669 != 1); + if (!_t670) goto endif226; { Free(buf); return ""; } - endif239:; - _t680 = (const char*)buf; - return _t680; + endif226:; + _t671 = (const char*)buf; + return _t671; } const char* Random_Hex(int n) { - int _t681; - unsigned int _t682; - int _t685; - _t681 = (n <= 0); - if (!_t681) goto endif241; + int _t672; + unsigned int _t673; + int _t676; + _t672 = (n <= 0); + if (!_t672) goto endif228; { return ""; } - endif241:; + endif228:; void* buf; - _t682 = (unsigned int)n; - void* _t683; - _t683 = Alloc(_t682); - buf = _t683; - int _t684; - _t684 = bux_random_bytes(buf, n); - _t685 = (_t684 != 1); - if (!_t685) goto endif243; + _t673 = (unsigned int)n; + void* _t674; + _t674 = Alloc(_t673); + buf = _t674; + int _t675; + _t675 = bux_random_bytes(buf, n); + _t676 = (_t675 != 1); + if (!_t676) goto endif230; { Free(buf); return ""; } - endif243:; + endif230:; const char* result; - const char* _t686; - _t686 = bux_bytes_to_hex(buf, n); - result = _t686; + const char* _t677; + _t677 = bux_bytes_to_hex(buf, n); + result = _t677; Free(buf); return result; } const char* Random_Base64(int n) { - int _t687; - unsigned int _t688; - int _t691; - const char* _t692; - _t687 = (n <= 0); - if (!_t687) goto endif245; + int _t678; + unsigned int _t679; + int _t682; + const char* _t683; + _t678 = (n <= 0); + if (!_t678) goto endif232; { return ""; } - endif245:; + endif232:; void* buf; - _t688 = (unsigned int)n; - void* _t689; - _t689 = Alloc(_t688); - buf = _t689; - int _t690; - _t690 = bux_random_bytes(buf, n); - _t691 = (_t690 != 1); - if (!_t691) goto endif247; + _t679 = (unsigned int)n; + void* _t680; + _t680 = Alloc(_t679); + buf = _t680; + int _t681; + _t681 = bux_random_bytes(buf, n); + _t682 = (_t681 != 1); + if (!_t682) goto endif234; { Free(buf); return ""; } - endif247:; + endif234:; const char* result; - _t692 = (const char*)buf; - const char* _t693; - _t693 = bux_base64_encode(_t692, n); - result = _t693; + _t683 = (const char*)buf; + const char* _t684; + _t684 = bux_base64_encode(_t683, n); + result = _t684; Free(buf); return result; } unsigned int Random_Uint32(void) { - int _t696; - unsigned int* _t697; - unsigned int _t698; + int _t687; + unsigned int* _t688; + unsigned int _t689; void* buf; - void* _t694; - _t694 = Alloc(4); - buf = _t694; - int _t695; - _t695 = bux_random_bytes(buf, 4); - _t696 = (_t695 != 1); - if (!_t696) goto endif249; + void* _t685; + _t685 = Alloc(4); + buf = _t685; + int _t686; + _t686 = bux_random_bytes(buf, 4); + _t687 = (_t686 != 1); + if (!_t687) goto endif236; { Free(buf); return 0; } - endif249:; + endif236:; unsigned int* ptr; - _t697 = (unsigned int*)buf; - ptr = _t697; + _t688 = (unsigned int*)buf; + ptr = _t688; unsigned int val; - _t698 = *ptr; - val = _t698; + _t689 = *ptr; + val = _t689; Free(buf); return val; } const char* Aes_GenerateKey(void) { - unsigned int _t699; - int _t702; - const char* _t703; + unsigned int _t690; + int _t693; + const char* _t694; void* buf; - _t699 = (unsigned int)AES_KEY_SIZE; - void* _t700; - _t700 = Alloc(_t699); - buf = _t700; - int _t701; - _t701 = bux_random_bytes(buf, AES_KEY_SIZE); - _t702 = (_t701 != 1); - if (!_t702) goto endif251; + _t690 = (unsigned int)AES_KEY_SIZE; + void* _t691; + _t691 = Alloc(_t690); + buf = _t691; + int _t692; + _t692 = bux_random_bytes(buf, AES_KEY_SIZE); + _t693 = (_t692 != 1); + if (!_t693) goto endif238; { Free(buf); return ""; } - endif251:; - _t703 = (const char*)buf; - return _t703; + endif238:; + _t694 = (const char*)buf; + return _t694; } const char* Aes_GenerateIV(void) { - unsigned int _t704; - int _t707; - const char* _t708; + unsigned int _t695; + int _t698; + const char* _t699; void* buf; - _t704 = (unsigned int)AES_IV_SIZE; - void* _t705; - _t705 = Alloc(_t704); - buf = _t705; - int _t706; - _t706 = bux_random_bytes(buf, AES_IV_SIZE); - _t707 = (_t706 != 1); - if (!_t707) goto endif253; + _t695 = (unsigned int)AES_IV_SIZE; + void* _t696; + _t696 = Alloc(_t695); + buf = _t696; + int _t697; + _t697 = bux_random_bytes(buf, AES_IV_SIZE); + _t698 = (_t697 != 1); + if (!_t698) goto endif240; { Free(buf); return ""; } - endif253:; - _t708 = (const char*)buf; - return _t708; + endif240:; + _t699 = (const char*)buf; + return _t699; } const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv) { - int _t710; - void* _t711; + int _t701; + void* _t702; int outlen; outlen = 0; - unsigned int _t709; - _t709 = String_Len(plain); - _t710 = (int)_t709; - _t711 = &outlen; - const char* _t712; - _t712 = bux_aes_256_cbc_encrypt(plain, _t710, key, iv, _t711); - return _t712; + unsigned int _t700; + _t700 = String_Len(plain); + _t701 = (int)_t700; + _t702 = &outlen; + const char* _t703; + _t703 = bux_aes_256_cbc_encrypt(plain, _t701, key, iv, _t702); + return _t703; } const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv) { - int _t714; - void* _t715; + int _t705; + void* _t706; int outlen; outlen = 0; - unsigned int _t713; - _t713 = String_Len(cipher); - _t714 = (int)_t713; - _t715 = &outlen; - const char* _t716; - _t716 = bux_aes_256_cbc_decrypt(cipher, _t714, key, iv, _t715); - return _t716; + unsigned int _t704; + _t704 = String_Len(cipher); + _t705 = (int)_t704; + _t706 = &outlen; + const char* _t707; + _t707 = bux_aes_256_cbc_decrypt(cipher, _t705, key, iv, _t706); + return _t707; } const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag) { - int _t718; - void* _t719; + int _t709; + void* _t710; int outlen; outlen = 0; - unsigned int _t717; - _t717 = String_Len(plain); - _t718 = (int)_t717; - _t719 = &outlen; - const char* _t720; - _t720 = bux_aes_256_gcm_encrypt(plain, _t718, key, iv, tag, _t719); - return _t720; + unsigned int _t708; + _t708 = String_Len(plain); + _t709 = (int)_t708; + _t710 = &outlen; + const char* _t711; + _t711 = bux_aes_256_gcm_encrypt(plain, _t709, key, iv, tag, _t710); + return _t711; } const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag) { - int _t722; - void* _t723; + int _t713; + void* _t714; int outlen; outlen = 0; - unsigned int _t721; - _t721 = String_Len(cipher); - _t722 = (int)_t721; - _t723 = &outlen; - const char* _t724; - _t724 = bux_aes_256_gcm_decrypt(cipher, _t722, key, iv, tag, _t723); - return _t724; + unsigned int _t712; + _t712 = String_Len(cipher); + _t713 = (int)_t712; + _t714 = &outlen; + const char* _t715; + _t715 = bux_aes_256_gcm_decrypt(cipher, _t713, key, iv, tag, _t714); + return _t715; } const char* Jwt_MakeHeader(JwtAlg alg) { - int _t725; - int _t726; - int _t727; - int _t728; - int _t729; - int _t730; - int _t731; - int _t732; - int _t733; - _t725 = (alg == JwtAlg_HS256); - if (!_t725) goto endif255; + int _t716; + int _t717; + int _t718; + int _t719; + int _t720; + int _t721; + int _t722; + int _t723; + int _t724; + _t716 = (alg == JwtAlg_HS256); + if (!_t716) goto endif242; { return "{\"alg\":\"HS256\",\"typ\":\"JWT\"}"; } - endif255:; - _t726 = (alg == JwtAlg_HS384); - if (!_t726) goto endif257; + endif242:; + _t717 = (alg == JwtAlg_HS384); + if (!_t717) goto endif244; { return "{\"alg\":\"HS384\",\"typ\":\"JWT\"}"; } - endif257:; - _t727 = (alg == JwtAlg_HS512); - if (!_t727) goto endif259; + endif244:; + _t718 = (alg == JwtAlg_HS512); + if (!_t718) goto endif246; { return "{\"alg\":\"HS512\",\"typ\":\"JWT\"}"; } - endif259:; - _t728 = (alg == JwtAlg_RS256); - if (!_t728) goto endif261; + endif246:; + _t719 = (alg == JwtAlg_RS256); + if (!_t719) goto endif248; { return "{\"alg\":\"RS256\",\"typ\":\"JWT\"}"; } - endif261:; - _t729 = (alg == JwtAlg_RS384); - if (!_t729) goto endif263; + endif248:; + _t720 = (alg == JwtAlg_RS384); + if (!_t720) goto endif250; { return "{\"alg\":\"RS384\",\"typ\":\"JWT\"}"; } - endif263:; - _t730 = (alg == JwtAlg_RS512); - if (!_t730) goto endif265; + endif250:; + _t721 = (alg == JwtAlg_RS512); + if (!_t721) goto endif252; { return "{\"alg\":\"RS512\",\"typ\":\"JWT\"}"; } - endif265:; - _t731 = (alg == JwtAlg_ES256); - if (!_t731) goto endif267; + endif252:; + _t722 = (alg == JwtAlg_ES256); + if (!_t722) goto endif254; { return "{\"alg\":\"ES256\",\"typ\":\"JWT\"}"; } - endif267:; - _t732 = (alg == JwtAlg_ES384); - if (!_t732) goto endif269; + endif254:; + _t723 = (alg == JwtAlg_ES384); + if (!_t723) goto endif256; { return "{\"alg\":\"ES384\",\"typ\":\"JWT\"}"; } - endif269:; - _t733 = (alg == JwtAlg_EdDSA); - if (!_t733) goto endif271; + endif256:; + _t724 = (alg == JwtAlg_EdDSA); + if (!_t724) goto endif258; { return "{\"alg\":\"EdDSA\",\"typ\":\"JWT\"}"; } - endif271:; + endif258:; return "{\"alg\":\"none\",\"typ\":\"JWT\"}"; } const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key) { - int _t734; - const char* _t736; - int _t738; - const char* _t740; + int _t725; + const char* _t727; + int _t729; + const char* _t731; + int _t733; + const char* _t735; + int _t737; + int _t740; int _t742; - const char* _t744; - int _t746; - int _t749; - int _t751; - int _t754; - int _t756; - int _t759; - int _t761; - int _t764; - int _t766; - int _t769; - int _t771; - _t734 = (alg == JwtAlg_HS256); - if (!_t734) goto endif273; + int _t745; + int _t747; + int _t750; + int _t752; + int _t755; + int _t757; + int _t760; + int _t762; + _t725 = (alg == JwtAlg_HS256); + if (!_t725) goto endif260; { void* buf; - void* _t735; - _t735 = Alloc(32); - buf = _t735; + void* _t726; + _t726 = Alloc(32); + buf = _t726; Hmac_Sha256Raw(key, signingInput, buf); const char* result; - _t736 = (const char*)buf; - const char* _t737; - _t737 = bux_base64_encode(_t736, 32); - result = _t737; + _t727 = (const char*)buf; + const char* _t728; + _t728 = bux_base64_encode(_t727, 32); + result = _t728; Free(buf); return result; } - endif273:; - _t738 = (alg == JwtAlg_HS384); - if (!_t738) goto endif275; + endif260:; + _t729 = (alg == JwtAlg_HS384); + if (!_t729) goto endif262; { void* buf; - void* _t739; - _t739 = Alloc(48); - buf = _t739; + void* _t730; + _t730 = Alloc(48); + buf = _t730; Hmac_Sha384Raw(key, signingInput, buf); const char* result; - _t740 = (const char*)buf; - const char* _t741; - _t741 = bux_base64_encode(_t740, 48); - result = _t741; + _t731 = (const char*)buf; + const char* _t732; + _t732 = bux_base64_encode(_t731, 48); + result = _t732; Free(buf); return result; } - endif275:; - _t742 = (alg == JwtAlg_HS512); - if (!_t742) goto endif277; + endif262:; + _t733 = (alg == JwtAlg_HS512); + if (!_t733) goto endif264; { void* buf; - void* _t743; - _t743 = Alloc(64); - buf = _t743; + void* _t734; + _t734 = Alloc(64); + buf = _t734; Hmac_Sha512Raw(key, signingInput, buf); const char* result; - _t744 = (const char*)buf; - const char* _t745; - _t745 = bux_base64_encode(_t744, 64); - result = _t745; + _t735 = (const char*)buf; + const char* _t736; + _t736 = bux_base64_encode(_t735, 64); + result = _t736; Free(buf); return result; } - endif277:; - _t746 = (alg == JwtAlg_RS256); - if (!_t746) goto endif279; + endif264:; + _t737 = (alg == JwtAlg_RS256); + if (!_t737) goto endif266; { const char* raw; - const char* _t747; - _t747 = Rsa_SignSha256(key, signingInput); - raw = _t747; - unsigned int _t748; - _t748 = String_Len(raw); - _t749 = (int)_t748; - const char* _t750; - _t750 = bux_base64_encode(raw, _t749); - return _t750; + const char* _t738; + _t738 = Rsa_SignSha256(key, signingInput); + raw = _t738; + unsigned int _t739; + _t739 = String_Len(raw); + _t740 = (int)_t739; + const char* _t741; + _t741 = bux_base64_encode(raw, _t740); + return _t741; } - endif279:; - _t751 = (alg == JwtAlg_RS384); - if (!_t751) goto endif281; + endif266:; + _t742 = (alg == JwtAlg_RS384); + if (!_t742) goto endif268; { const char* raw; - const char* _t752; - _t752 = Rsa_SignSha384(key, signingInput); - raw = _t752; - unsigned int _t753; - _t753 = String_Len(raw); - _t754 = (int)_t753; - const char* _t755; - _t755 = bux_base64_encode(raw, _t754); - return _t755; + const char* _t743; + _t743 = Rsa_SignSha384(key, signingInput); + raw = _t743; + unsigned int _t744; + _t744 = String_Len(raw); + _t745 = (int)_t744; + const char* _t746; + _t746 = bux_base64_encode(raw, _t745); + return _t746; } - endif281:; - _t756 = (alg == JwtAlg_RS512); - if (!_t756) goto endif283; + endif268:; + _t747 = (alg == JwtAlg_RS512); + if (!_t747) goto endif270; { const char* raw; - const char* _t757; - _t757 = Rsa_SignSha512(key, signingInput); - raw = _t757; - unsigned int _t758; - _t758 = String_Len(raw); - _t759 = (int)_t758; - const char* _t760; - _t760 = bux_base64_encode(raw, _t759); - return _t760; + const char* _t748; + _t748 = Rsa_SignSha512(key, signingInput); + raw = _t748; + unsigned int _t749; + _t749 = String_Len(raw); + _t750 = (int)_t749; + const char* _t751; + _t751 = bux_base64_encode(raw, _t750); + return _t751; } - endif283:; - _t761 = (alg == JwtAlg_ES256); - if (!_t761) goto endif285; + endif270:; + _t752 = (alg == JwtAlg_ES256); + if (!_t752) goto endif272; { const char* raw; - const char* _t762; - _t762 = Ecdsa_SignP256(key, signingInput); - raw = _t762; - unsigned int _t763; - _t763 = String_Len(raw); - _t764 = (int)_t763; - const char* _t765; - _t765 = bux_base64_encode(raw, _t764); - return _t765; + const char* _t753; + _t753 = Ecdsa_SignP256(key, signingInput); + raw = _t753; + unsigned int _t754; + _t754 = String_Len(raw); + _t755 = (int)_t754; + const char* _t756; + _t756 = bux_base64_encode(raw, _t755); + return _t756; } - endif285:; - _t766 = (alg == JwtAlg_ES384); - if (!_t766) goto endif287; + endif272:; + _t757 = (alg == JwtAlg_ES384); + if (!_t757) goto endif274; { const char* raw; - const char* _t767; - _t767 = Ecdsa_SignP384(key, signingInput); - raw = _t767; - unsigned int _t768; - _t768 = String_Len(raw); - _t769 = (int)_t768; - const char* _t770; - _t770 = bux_base64_encode(raw, _t769); - return _t770; + const char* _t758; + _t758 = Ecdsa_SignP384(key, signingInput); + raw = _t758; + unsigned int _t759; + _t759 = String_Len(raw); + _t760 = (int)_t759; + const char* _t761; + _t761 = bux_base64_encode(raw, _t760); + return _t761; } - endif287:; - _t771 = (alg == JwtAlg_EdDSA); - if (!_t771) goto endif289; + endif274:; + _t762 = (alg == JwtAlg_EdDSA); + if (!_t762) goto endif276; { - const char* _t772; - _t772 = Ed25519_Sign(key, signingInput); - return _t772; + const char* _t763; + _t763 = Ed25519_Sign(key, signingInput); + return _t763; } - endif289:; + endif276:; return ""; } bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key) { - int _t773; - const char* _t775; - int _t778; - const char* _t780; + int _t764; + const char* _t766; + int _t769; + const char* _t771; + int _t774; + const char* _t776; + int _t779; + int _t781; int _t783; - const char* _t785; - int _t788; - int _t790; - int _t792; - int _t794; - int _t796; - int _t798; - _t773 = (alg == JwtAlg_HS256); - if (!_t773) goto endif291; + int _t785; + int _t787; + int _t789; + _t764 = (alg == JwtAlg_HS256); + if (!_t764) goto endif278; { void* expectBuf; - void* _t774; - _t774 = Alloc(32); - expectBuf = _t774; + void* _t765; + _t765 = Alloc(32); + expectBuf = _t765; Hmac_Sha256Raw(key, signingInput, expectBuf); const char* expectB64; - _t775 = (const char*)expectBuf; - const char* _t776; - _t776 = bux_base64_encode(_t775, 32); - expectB64 = _t776; + _t766 = (const char*)expectBuf; + const char* _t767; + _t767 = bux_base64_encode(_t766, 32); + expectB64 = _t767; Free(expectBuf); - bool _t777; - _t777 = String_Eq(expectB64, signatureB64); - return _t777; + bool _t768; + _t768 = String_Eq(expectB64, signatureB64); + return _t768; } - endif291:; - _t778 = (alg == JwtAlg_HS384); - if (!_t778) goto endif293; + endif278:; + _t769 = (alg == JwtAlg_HS384); + if (!_t769) goto endif280; { void* expectBuf; - void* _t779; - _t779 = Alloc(48); - expectBuf = _t779; + void* _t770; + _t770 = Alloc(48); + expectBuf = _t770; Hmac_Sha384Raw(key, signingInput, expectBuf); const char* expectB64; - _t780 = (const char*)expectBuf; - const char* _t781; - _t781 = bux_base64_encode(_t780, 48); - expectB64 = _t781; + _t771 = (const char*)expectBuf; + const char* _t772; + _t772 = bux_base64_encode(_t771, 48); + expectB64 = _t772; Free(expectBuf); - bool _t782; - _t782 = String_Eq(expectB64, signatureB64); - return _t782; + bool _t773; + _t773 = String_Eq(expectB64, signatureB64); + return _t773; } - endif293:; - _t783 = (alg == JwtAlg_HS512); - if (!_t783) goto endif295; + endif280:; + _t774 = (alg == JwtAlg_HS512); + if (!_t774) goto endif282; { void* expectBuf; - void* _t784; - _t784 = Alloc(64); - expectBuf = _t784; + void* _t775; + _t775 = Alloc(64); + expectBuf = _t775; Hmac_Sha512Raw(key, signingInput, expectBuf); const char* expectB64; - _t785 = (const char*)expectBuf; - const char* _t786; - _t786 = bux_base64_encode(_t785, 64); - expectB64 = _t786; + _t776 = (const char*)expectBuf; + const char* _t777; + _t777 = bux_base64_encode(_t776, 64); + expectB64 = _t777; Free(expectBuf); - bool _t787; - _t787 = String_Eq(expectB64, signatureB64); - return _t787; + bool _t778; + _t778 = String_Eq(expectB64, signatureB64); + return _t778; } - endif295:; - _t788 = (alg == JwtAlg_RS256); - if (!_t788) goto endif297; + endif282:; + _t779 = (alg == JwtAlg_RS256); + if (!_t779) goto endif284; { - bool _t789; - _t789 = Rsa_VerifySha256(key, signingInput, signatureB64); - return _t789; + bool _t780; + _t780 = Rsa_VerifySha256(key, signingInput, signatureB64); + return _t780; } - endif297:; - _t790 = (alg == JwtAlg_RS384); - if (!_t790) goto endif299; + endif284:; + _t781 = (alg == JwtAlg_RS384); + if (!_t781) goto endif286; { - bool _t791; - _t791 = Rsa_VerifySha384(key, signingInput, signatureB64); - return _t791; + bool _t782; + _t782 = Rsa_VerifySha384(key, signingInput, signatureB64); + return _t782; } - endif299:; - _t792 = (alg == JwtAlg_RS512); - if (!_t792) goto endif301; + endif286:; + _t783 = (alg == JwtAlg_RS512); + if (!_t783) goto endif288; { - bool _t793; - _t793 = Rsa_VerifySha512(key, signingInput, signatureB64); - return _t793; + bool _t784; + _t784 = Rsa_VerifySha512(key, signingInput, signatureB64); + return _t784; } - endif301:; - _t794 = (alg == JwtAlg_ES256); - if (!_t794) goto endif303; + endif288:; + _t785 = (alg == JwtAlg_ES256); + if (!_t785) goto endif290; { - bool _t795; - _t795 = Ecdsa_VerifyP256(key, signingInput, signatureB64); - return _t795; + bool _t786; + _t786 = Ecdsa_VerifyP256(key, signingInput, signatureB64); + return _t786; } - endif303:; - _t796 = (alg == JwtAlg_ES384); - if (!_t796) goto endif305; + endif290:; + _t787 = (alg == JwtAlg_ES384); + if (!_t787) goto endif292; { - bool _t797; - _t797 = Ecdsa_VerifyP384(key, signingInput, signatureB64); - return _t797; + bool _t788; + _t788 = Ecdsa_VerifyP384(key, signingInput, signatureB64); + return _t788; } - endif305:; - _t798 = (alg == JwtAlg_EdDSA); - if (!_t798) goto endif307; + endif292:; + _t789 = (alg == JwtAlg_EdDSA); + if (!_t789) goto endif294; { - bool _t799; - _t799 = Ed25519_Verify(key, signatureB64, signingInput); - return _t799; + bool _t790; + _t790 = Ed25519_Verify(key, signatureB64, signingInput); + return _t790; } - endif307:; + endif294:; return 0; } const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key) { const char* headerB64; - const char* _t800; - _t800 = Base64URL_Encode(headerJson); - headerB64 = _t800; + const char* _t791; + _t791 = Base64URL_Encode(headerJson); + headerB64 = _t791; const char* payloadB64; - const char* _t801; - _t801 = Base64URL_Encode(payloadJson); - payloadB64 = _t801; + const char* _t792; + _t792 = Base64URL_Encode(payloadJson); + payloadB64 = _t792; const char* signingInput; - const char* _t802; - _t802 = String_Concat(headerB64, "."); - signingInput = _t802; + const char* _t793; + _t793 = String_Concat(headerB64, "."); + signingInput = _t793; const char* signingInputFull; - const char* _t803; - _t803 = String_Concat(signingInput, payloadB64); - signingInputFull = _t803; + const char* _t794; + _t794 = String_Concat(signingInput, payloadB64); + signingInputFull = _t794; const char* sigB64; - const char* _t804; - _t804 = Jwt_Sign(alg, signingInputFull, key); - sigB64 = _t804; + const char* _t795; + _t795 = Jwt_Sign(alg, signingInputFull, key); + sigB64 = _t795; const char* part1; - const char* _t805; - _t805 = String_Concat(signingInputFull, "."); - part1 = _t805; - const char* _t806; - _t806 = String_Concat(part1, sigB64); - return _t806; + const char* _t796; + _t796 = String_Concat(signingInputFull, "."); + part1 = _t796; + const char* _t797; + _t797 = String_Concat(part1, sigB64); + return _t797; } bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut) { - int _t808; - int _t815; + int _t799; + int _t806; unsigned int partCount; - unsigned int _t807; - _t807 = bux_str_split_count(token, "."); - partCount = _t807; - _t808 = (partCount != 3); - if (!_t808) goto endif309; + unsigned int _t798; + _t798 = bux_str_split_count(token, "."); + partCount = _t798; + _t799 = (partCount != 3); + if (!_t799) goto endif296; { return 0; } - endif309:; + endif296:; const char* headerB64; - const char* _t809; - _t809 = bux_str_split_part(token, ".", 0); - headerB64 = _t809; + const char* _t800; + _t800 = bux_str_split_part(token, ".", 0); + headerB64 = _t800; const char* payloadB64; - const char* _t810; - _t810 = bux_str_split_part(token, ".", 1); - payloadB64 = _t810; + const char* _t801; + _t801 = bux_str_split_part(token, ".", 1); + payloadB64 = _t801; const char* sigB64; - const char* _t811; - _t811 = bux_str_split_part(token, ".", 2); - sigB64 = _t811; + const char* _t802; + _t802 = bux_str_split_part(token, ".", 2); + sigB64 = _t802; const char* input; - const char* _t812; - _t812 = String_Concat(headerB64, "."); - input = _t812; + const char* _t803; + _t803 = String_Concat(headerB64, "."); + input = _t803; const char* signingInput; - const char* _t813; - _t813 = String_Concat(input, payloadB64); - signingInput = _t813; - bool _t814; - _t814 = Jwt_Verify(alg, signingInput, sigB64, key); - _t815 = !_t814; - if (!_t815) goto endif311; + const char* _t804; + _t804 = String_Concat(input, payloadB64); + signingInput = _t804; + bool _t805; + _t805 = Jwt_Verify(alg, signingInput, sigB64, key); + _t806 = !_t805; + if (!_t806) goto endif298; { return 0; } - endif311:; - const char* _t816; - _t816 = Base64URL_Decode(headerB64); - headerOut[0] = _t816; - const char* _t817; - _t817 = Base64URL_Decode(payloadB64); - payloadOut[0] = _t817; + endif298:; + const char* _t807; + _t807 = Base64URL_Decode(headerB64); + headerOut[0] = _t807; + const char* _t808; + _t808 = Base64URL_Decode(payloadB64); + payloadOut[0] = _t808; return 1; } const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret) { const char* header; - const char* _t818; - _t818 = Jwt_MakeHeader(JwtAlg_HS256); - header = _t818; - const char* _t819; - _t819 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); - return _t819; + const char* _t809; + _t809 = Jwt_MakeHeader(JwtAlg_HS256); + header = _t809; + const char* _t810; + _t810 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); + return _t810; } const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret) { const char* header; - const char* _t820; - _t820 = Jwt_MakeHeader(JwtAlg_HS384); - header = _t820; - const char* _t821; - _t821 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); - return _t821; + const char* _t811; + _t811 = Jwt_MakeHeader(JwtAlg_HS384); + header = _t811; + const char* _t812; + _t812 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); + return _t812; } const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret) { const char* header; - const char* _t822; - _t822 = Jwt_MakeHeader(JwtAlg_HS512); - header = _t822; - const char* _t823; - _t823 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); - return _t823; + const char* _t813; + _t813 = Jwt_MakeHeader(JwtAlg_HS512); + header = _t813; + const char* _t814; + _t814 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); + return _t814; } const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t824; - _t824 = Jwt_MakeHeader(JwtAlg_RS256); - header = _t824; - const char* _t825; - _t825 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); - return _t825; + const char* _t815; + _t815 = Jwt_MakeHeader(JwtAlg_RS256); + header = _t815; + const char* _t816; + _t816 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); + return _t816; } const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t826; - _t826 = Jwt_MakeHeader(JwtAlg_ES256); - header = _t826; - const char* _t827; - _t827 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); - return _t827; + const char* _t817; + _t817 = Jwt_MakeHeader(JwtAlg_ES256); + header = _t817; + const char* _t818; + _t818 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); + return _t818; } const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey) { const char* header; - const char* _t828; - _t828 = Jwt_MakeHeader(JwtAlg_EdDSA); - header = _t828; - const char* _t829; - _t829 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); - return _t829; + const char* _t819; + _t819 = Jwt_MakeHeader(JwtAlg_EdDSA); + header = _t819; + const char* _t820; + _t820 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); + return _t820; } const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data) { - int _t831; - int _t833; - void* _t834; + int _t822; + int _t824; + void* _t825; int siglen; siglen = 0; - unsigned int _t830; - _t830 = String_Len(pemPrivateKey); - _t831 = (int)_t830; - unsigned int _t832; - _t832 = String_Len(data); - _t833 = (int)_t832; - _t834 = &siglen; - const char* _t835; - _t835 = bux_ecdsa_sign_p256(pemPrivateKey, _t831, data, _t833, _t834); - return _t835; + unsigned int _t821; + _t821 = String_Len(pemPrivateKey); + _t822 = (int)_t821; + unsigned int _t823; + _t823 = String_Len(data); + _t824 = (int)_t823; + _t825 = &siglen; + const char* _t826; + _t826 = bux_ecdsa_sign_p256(pemPrivateKey, _t822, data, _t824, _t825); + return _t826; } const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data) { - int _t838; + int _t829; const char* raw; - const char* _t836; - _t836 = Ecdsa_SignP256(pemPrivateKey, data); - raw = _t836; - unsigned int _t837; - _t837 = String_Len(raw); - _t838 = (int)_t837; - const char* _t839; - _t839 = bux_base64_encode(raw, _t838); - return _t839; + const char* _t827; + _t827 = Ecdsa_SignP256(pemPrivateKey, data); + raw = _t827; + unsigned int _t828; + _t828 = String_Len(raw); + _t829 = (int)_t828; + const char* _t830; + _t830 = bux_base64_encode(raw, _t829); + return _t830; } bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature) { - int _t841; - int _t843; - int _t845; - int _t847; + int _t832; + int _t834; + int _t836; + int _t838; int r; - unsigned int _t840; - _t840 = String_Len(pemPublicKey); - _t841 = (int)_t840; - unsigned int _t842; - _t842 = String_Len(data); - _t843 = (int)_t842; - unsigned int _t844; - _t844 = String_Len(signature); - _t845 = (int)_t844; - int _t846; - _t846 = bux_ecdsa_verify_p256(pemPublicKey, _t841, data, _t843, signature, _t845); - r = _t846; - _t847 = (r == 1); - return _t847; + unsigned int _t831; + _t831 = String_Len(pemPublicKey); + _t832 = (int)_t831; + unsigned int _t833; + _t833 = String_Len(data); + _t834 = (int)_t833; + unsigned int _t835; + _t835 = String_Len(signature); + _t836 = (int)_t835; + int _t837; + _t837 = bux_ecdsa_verify_p256(pemPublicKey, _t832, data, _t834, signature, _t836); + r = _t837; + _t838 = (r == 1); + return _t838; } bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t849; - void* _t850; + int _t840; + void* _t841; int outlen; outlen = 0; const char* sig; - unsigned int _t848; - _t848 = String_Len(signatureB64); - _t849 = (int)_t848; - _t850 = &outlen; - const char* _t851; - _t851 = bux_base64_decode(signatureB64, _t849, _t850); - sig = _t851; - bool _t852; - _t852 = Ecdsa_VerifyP256(pemPublicKey, data, sig); - return _t852; + unsigned int _t839; + _t839 = String_Len(signatureB64); + _t840 = (int)_t839; + _t841 = &outlen; + const char* _t842; + _t842 = bux_base64_decode(signatureB64, _t840, _t841); + sig = _t842; + bool _t843; + _t843 = Ecdsa_VerifyP256(pemPublicKey, data, sig); + return _t843; } const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data) { - int _t854; - int _t856; - void* _t857; + int _t845; + int _t847; + void* _t848; int siglen; siglen = 0; - unsigned int _t853; - _t853 = String_Len(pemPrivateKey); - _t854 = (int)_t853; - unsigned int _t855; - _t855 = String_Len(data); - _t856 = (int)_t855; - _t857 = &siglen; - const char* _t858; - _t858 = bux_ecdsa_sign_p384(pemPrivateKey, _t854, data, _t856, _t857); - return _t858; + unsigned int _t844; + _t844 = String_Len(pemPrivateKey); + _t845 = (int)_t844; + unsigned int _t846; + _t846 = String_Len(data); + _t847 = (int)_t846; + _t848 = &siglen; + const char* _t849; + _t849 = bux_ecdsa_sign_p384(pemPrivateKey, _t845, data, _t847, _t848); + return _t849; } const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data) { - int _t861; + int _t852; const char* raw; - const char* _t859; - _t859 = Ecdsa_SignP384(pemPrivateKey, data); - raw = _t859; - unsigned int _t860; - _t860 = String_Len(raw); - _t861 = (int)_t860; - const char* _t862; - _t862 = bux_base64_encode(raw, _t861); - return _t862; + const char* _t850; + _t850 = Ecdsa_SignP384(pemPrivateKey, data); + raw = _t850; + unsigned int _t851; + _t851 = String_Len(raw); + _t852 = (int)_t851; + const char* _t853; + _t853 = bux_base64_encode(raw, _t852); + return _t853; } bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature) { - int _t864; - int _t866; - int _t868; - int _t870; + int _t855; + int _t857; + int _t859; + int _t861; int r; - unsigned int _t863; - _t863 = String_Len(pemPublicKey); - _t864 = (int)_t863; - unsigned int _t865; - _t865 = String_Len(data); - _t866 = (int)_t865; - unsigned int _t867; - _t867 = String_Len(signature); - _t868 = (int)_t867; - int _t869; - _t869 = bux_ecdsa_verify_p384(pemPublicKey, _t864, data, _t866, signature, _t868); - r = _t869; - _t870 = (r == 1); - return _t870; + unsigned int _t854; + _t854 = String_Len(pemPublicKey); + _t855 = (int)_t854; + unsigned int _t856; + _t856 = String_Len(data); + _t857 = (int)_t856; + unsigned int _t858; + _t858 = String_Len(signature); + _t859 = (int)_t858; + int _t860; + _t860 = bux_ecdsa_verify_p384(pemPublicKey, _t855, data, _t857, signature, _t859); + r = _t860; + _t861 = (r == 1); + return _t861; } bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t872; - void* _t873; + int _t863; + void* _t864; int outlen; outlen = 0; const char* sig; - unsigned int _t871; - _t871 = String_Len(signatureB64); - _t872 = (int)_t871; - _t873 = &outlen; - const char* _t874; - _t874 = bux_base64_decode(signatureB64, _t872, _t873); - sig = _t874; - bool _t875; - _t875 = Ecdsa_VerifyP384(pemPublicKey, data, sig); - return _t875; + unsigned int _t862; + _t862 = String_Len(signatureB64); + _t863 = (int)_t862; + _t864 = &outlen; + const char* _t865; + _t865 = bux_base64_decode(signatureB64, _t863, _t864); + sig = _t865; + bool _t866; + _t866 = Ecdsa_VerifyP384(pemPublicKey, data, sig); + return _t866; } bool Ed25519_Keypair(void* pubKey, void* privKey) { - int _t877; + int _t868; int r; - int _t876; - _t876 = bux_ed25519_keypair(pubKey, privKey); - r = _t876; - _t877 = (r == 1); - return _t877; + int _t867; + _t867 = bux_ed25519_keypair(pubKey, privKey); + r = _t867; + _t868 = (r == 1); + return _t868; } const char* Ed25519_KeypairBase64(void) { - unsigned int _t878; - unsigned int _t880; - int _t883; - const char* _t884; - const char* _t886; + unsigned int _t869; + unsigned int _t871; + int _t874; + const char* _t875; + const char* _t877; void* pubBuf; - _t878 = (unsigned int)ED25519_PUBKEY_SIZE; - void* _t879; - _t879 = Alloc(_t878); - pubBuf = _t879; + _t869 = (unsigned int)ED25519_PUBKEY_SIZE; + void* _t870; + _t870 = Alloc(_t869); + pubBuf = _t870; void* priv; - _t880 = (unsigned int)ED25519_PRIVKEY_SIZE; - void* _t881; - _t881 = Alloc(_t880); - priv = _t881; - int _t882; - _t882 = bux_ed25519_keypair(pubBuf, priv); - _t883 = (_t882 != 1); - if (!_t883) goto endif313; + _t871 = (unsigned int)ED25519_PRIVKEY_SIZE; + void* _t872; + _t872 = Alloc(_t871); + priv = _t872; + int _t873; + _t873 = bux_ed25519_keypair(pubBuf, priv); + _t874 = (_t873 != 1); + if (!_t874) goto endif300; { Free(pubBuf); Free(priv); return ""; } - endif313:; + endif300:; const char* pubB64; - _t884 = (const char*)pubBuf; - const char* _t885; - _t885 = bux_base64_encode(_t884, ED25519_PUBKEY_SIZE); - pubB64 = _t885; + _t875 = (const char*)pubBuf; + const char* _t876; + _t876 = bux_base64_encode(_t875, ED25519_PUBKEY_SIZE); + pubB64 = _t876; const char* privB64; - _t886 = (const char*)priv; - const char* _t887; - _t887 = bux_base64_encode(_t886, ED25519_PRIVKEY_SIZE); - privB64 = _t887; + _t877 = (const char*)priv; + const char* _t878; + _t878 = bux_base64_encode(_t877, ED25519_PRIVKEY_SIZE); + privB64 = _t878; Free(pubBuf); Free(priv); const char* pair; - const char* _t888; - _t888 = String_Concat(pubB64, ":"); - pair = _t888; - const char* _t889; - _t889 = String_Concat(pair, privB64); - return _t889; + const char* _t879; + _t879 = String_Concat(pubB64, ":"); + pair = _t879; + const char* _t880; + _t880 = String_Concat(pair, privB64); + return _t880; } const char* Ed25519_Sign(const char* privKey, const char* data) { - unsigned int _t890; - int _t893; - int _t895; - const char* _t896; + unsigned int _t881; + int _t884; + int _t886; + const char* _t887; void* sig; - _t890 = (unsigned int)ED25519_SIG_SIZE; - void* _t891; - _t891 = Alloc(_t890); - sig = _t891; - unsigned int _t892; - _t892 = String_Len(data); - _t893 = (int)_t892; - int _t894; - _t894 = bux_ed25519_sign(privKey, data, _t893, sig); - _t895 = (_t894 != 1); - if (!_t895) goto endif315; + _t881 = (unsigned int)ED25519_SIG_SIZE; + void* _t882; + _t882 = Alloc(_t881); + sig = _t882; + unsigned int _t883; + _t883 = String_Len(data); + _t884 = (int)_t883; + int _t885; + _t885 = bux_ed25519_sign(privKey, data, _t884, sig); + _t886 = (_t885 != 1); + if (!_t886) goto endif302; { Free(sig); return ""; } - endif315:; - _t896 = (const char*)sig; - return _t896; + endif302:; + _t887 = (const char*)sig; + return _t887; } const char* Ed25519_SignBase64(const char* privKey, const char* data) { - int _t899; + int _t890; const char* sig; - const char* _t897; - _t897 = Ed25519_Sign(privKey, data); - sig = _t897; - unsigned int _t898; - _t898 = String_Len(sig); - _t899 = (_t898 == 0); - if (!_t899) goto endif317; + const char* _t888; + _t888 = Ed25519_Sign(privKey, data); + sig = _t888; + unsigned int _t889; + _t889 = String_Len(sig); + _t890 = (_t889 == 0); + if (!_t890) goto endif304; { return ""; } - endif317:; - const char* _t900; - _t900 = bux_base64_encode(sig, ED25519_SIG_SIZE); - return _t900; + endif304:; + const char* _t891; + _t891 = bux_base64_encode(sig, ED25519_SIG_SIZE); + return _t891; } bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data) { - int _t902; - int _t904; + int _t893; + int _t895; int r; - unsigned int _t901; - _t901 = String_Len(data); - _t902 = (int)_t901; - int _t903; - _t903 = bux_ed25519_verify(pubKey, signature, data, _t902); - r = _t903; - _t904 = (r == 1); - return _t904; + unsigned int _t892; + _t892 = String_Len(data); + _t893 = (int)_t892; + int _t894; + _t894 = bux_ed25519_verify(pubKey, signature, data, _t893); + r = _t894; + _t895 = (r == 1); + return _t895; } bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data) { - int _t906; - void* _t907; - int _t909; + int _t897; + void* _t898; + int _t900; int outlen; outlen = 0; const char* sig; - unsigned int _t905; - _t905 = String_Len(signatureB64); - _t906 = (int)_t905; - _t907 = &outlen; - const char* _t908; - _t908 = bux_base64_decode(signatureB64, _t906, _t907); - sig = _t908; - _t909 = (outlen != ED25519_SIG_SIZE); - if (!_t909) goto endif319; + unsigned int _t896; + _t896 = String_Len(signatureB64); + _t897 = (int)_t896; + _t898 = &outlen; + const char* _t899; + _t899 = bux_base64_decode(signatureB64, _t897, _t898); + sig = _t899; + _t900 = (outlen != ED25519_SIG_SIZE); + if (!_t900) goto endif306; { return 0; } - endif319:; - bool _t910; - _t910 = Ed25519_Verify(pubKey, sig, data); - return _t910; + endif306:; + bool _t901; + _t901 = Ed25519_Verify(pubKey, sig, data); + return _t901; } const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data) { - int _t912; - int _t914; - void* _t915; + int _t903; + int _t905; + void* _t906; int siglen; siglen = 0; - unsigned int _t911; - _t911 = String_Len(pemPrivateKey); - _t912 = (int)_t911; - unsigned int _t913; - _t913 = String_Len(data); - _t914 = (int)_t913; - _t915 = &siglen; - const char* _t916; - _t916 = bux_rsa_sign_sha256(pemPrivateKey, _t912, data, _t914, _t915); - return _t916; + unsigned int _t902; + _t902 = String_Len(pemPrivateKey); + _t903 = (int)_t902; + unsigned int _t904; + _t904 = String_Len(data); + _t905 = (int)_t904; + _t906 = &siglen; + const char* _t907; + _t907 = bux_rsa_sign_sha256(pemPrivateKey, _t903, data, _t905, _t906); + return _t907; } const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data) { - int _t918; - int _t920; - void* _t921; + int _t909; + int _t911; + void* _t912; int siglen; siglen = 0; - unsigned int _t917; - _t917 = String_Len(pemPrivateKey); - _t918 = (int)_t917; - unsigned int _t919; - _t919 = String_Len(data); - _t920 = (int)_t919; - _t921 = &siglen; - const char* _t922; - _t922 = bux_rsa_sign_sha384(pemPrivateKey, _t918, data, _t920, _t921); - return _t922; + unsigned int _t908; + _t908 = String_Len(pemPrivateKey); + _t909 = (int)_t908; + unsigned int _t910; + _t910 = String_Len(data); + _t911 = (int)_t910; + _t912 = &siglen; + const char* _t913; + _t913 = bux_rsa_sign_sha384(pemPrivateKey, _t909, data, _t911, _t912); + return _t913; } const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data) { - int _t924; - int _t926; - void* _t927; + int _t915; + int _t917; + void* _t918; int siglen; siglen = 0; - unsigned int _t923; - _t923 = String_Len(pemPrivateKey); - _t924 = (int)_t923; - unsigned int _t925; - _t925 = String_Len(data); - _t926 = (int)_t925; - _t927 = &siglen; - const char* _t928; - _t928 = bux_rsa_sign_sha512(pemPrivateKey, _t924, data, _t926, _t927); - return _t928; + unsigned int _t914; + _t914 = String_Len(pemPrivateKey); + _t915 = (int)_t914; + unsigned int _t916; + _t916 = String_Len(data); + _t917 = (int)_t916; + _t918 = &siglen; + const char* _t919; + _t919 = bux_rsa_sign_sha512(pemPrivateKey, _t915, data, _t917, _t918); + return _t919; } const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data) { - int _t931; + int _t922; const char* raw; - const char* _t929; - _t929 = Rsa_SignSha256(pemPrivateKey, data); - raw = _t929; - unsigned int _t930; - _t930 = String_Len(raw); - _t931 = (int)_t930; - const char* _t932; - _t932 = bux_base64_encode(raw, _t931); - return _t932; + const char* _t920; + _t920 = Rsa_SignSha256(pemPrivateKey, data); + raw = _t920; + unsigned int _t921; + _t921 = String_Len(raw); + _t922 = (int)_t921; + const char* _t923; + _t923 = bux_base64_encode(raw, _t922); + return _t923; } const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data) { - int _t935; + int _t926; const char* raw; - const char* _t933; - _t933 = Rsa_SignSha384(pemPrivateKey, data); - raw = _t933; - unsigned int _t934; - _t934 = String_Len(raw); - _t935 = (int)_t934; - const char* _t936; - _t936 = bux_base64_encode(raw, _t935); - return _t936; + const char* _t924; + _t924 = Rsa_SignSha384(pemPrivateKey, data); + raw = _t924; + unsigned int _t925; + _t925 = String_Len(raw); + _t926 = (int)_t925; + const char* _t927; + _t927 = bux_base64_encode(raw, _t926); + return _t927; } const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data) { - int _t939; + int _t930; const char* raw; - const char* _t937; - _t937 = Rsa_SignSha512(pemPrivateKey, data); - raw = _t937; - unsigned int _t938; - _t938 = String_Len(raw); - _t939 = (int)_t938; - const char* _t940; - _t940 = bux_base64_encode(raw, _t939); - return _t940; + const char* _t928; + _t928 = Rsa_SignSha512(pemPrivateKey, data); + raw = _t928; + unsigned int _t929; + _t929 = String_Len(raw); + _t930 = (int)_t929; + const char* _t931; + _t931 = bux_base64_encode(raw, _t930); + return _t931; } bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature) { - int _t942; - int _t944; - int _t946; - int _t948; + int _t933; + int _t935; + int _t937; + int _t939; int r; - unsigned int _t941; - _t941 = String_Len(pemPublicKey); - _t942 = (int)_t941; - unsigned int _t943; - _t943 = String_Len(data); - _t944 = (int)_t943; - unsigned int _t945; - _t945 = String_Len(signature); - _t946 = (int)_t945; - int _t947; - _t947 = bux_rsa_verify_sha256(pemPublicKey, _t942, data, _t944, signature, _t946); - r = _t947; - _t948 = (r == 1); - return _t948; + unsigned int _t932; + _t932 = String_Len(pemPublicKey); + _t933 = (int)_t932; + unsigned int _t934; + _t934 = String_Len(data); + _t935 = (int)_t934; + unsigned int _t936; + _t936 = String_Len(signature); + _t937 = (int)_t936; + int _t938; + _t938 = bux_rsa_verify_sha256(pemPublicKey, _t933, data, _t935, signature, _t937); + r = _t938; + _t939 = (r == 1); + return _t939; } bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature) { - int _t950; - int _t952; - int _t954; - int _t956; + int _t941; + int _t943; + int _t945; + int _t947; int r; - unsigned int _t949; - _t949 = String_Len(pemPublicKey); - _t950 = (int)_t949; - unsigned int _t951; - _t951 = String_Len(data); - _t952 = (int)_t951; - unsigned int _t953; - _t953 = String_Len(signature); - _t954 = (int)_t953; - int _t955; - _t955 = bux_rsa_verify_sha384(pemPublicKey, _t950, data, _t952, signature, _t954); - r = _t955; - _t956 = (r == 1); - return _t956; + unsigned int _t940; + _t940 = String_Len(pemPublicKey); + _t941 = (int)_t940; + unsigned int _t942; + _t942 = String_Len(data); + _t943 = (int)_t942; + unsigned int _t944; + _t944 = String_Len(signature); + _t945 = (int)_t944; + int _t946; + _t946 = bux_rsa_verify_sha384(pemPublicKey, _t941, data, _t943, signature, _t945); + r = _t946; + _t947 = (r == 1); + return _t947; } bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature) { - int _t958; - int _t960; - int _t962; - int _t964; + int _t949; + int _t951; + int _t953; + int _t955; int r; - unsigned int _t957; - _t957 = String_Len(pemPublicKey); - _t958 = (int)_t957; - unsigned int _t959; - _t959 = String_Len(data); - _t960 = (int)_t959; - unsigned int _t961; - _t961 = String_Len(signature); - _t962 = (int)_t961; - int _t963; - _t963 = bux_rsa_verify_sha512(pemPublicKey, _t958, data, _t960, signature, _t962); - r = _t963; - _t964 = (r == 1); - return _t964; + unsigned int _t948; + _t948 = String_Len(pemPublicKey); + _t949 = (int)_t948; + unsigned int _t950; + _t950 = String_Len(data); + _t951 = (int)_t950; + unsigned int _t952; + _t952 = String_Len(signature); + _t953 = (int)_t952; + int _t954; + _t954 = bux_rsa_verify_sha512(pemPublicKey, _t949, data, _t951, signature, _t953); + r = _t954; + _t955 = (r == 1); + return _t955; } bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t966; - void* _t967; + int _t957; + void* _t958; int outlen; outlen = 0; const char* sig; - unsigned int _t965; - _t965 = String_Len(signatureB64); - _t966 = (int)_t965; - _t967 = &outlen; - const char* _t968; - _t968 = bux_base64_decode(signatureB64, _t966, _t967); - sig = _t968; - bool _t969; - _t969 = Rsa_VerifySha256(pemPublicKey, data, sig); - return _t969; + unsigned int _t956; + _t956 = String_Len(signatureB64); + _t957 = (int)_t956; + _t958 = &outlen; + const char* _t959; + _t959 = bux_base64_decode(signatureB64, _t957, _t958); + sig = _t959; + bool _t960; + _t960 = Rsa_VerifySha256(pemPublicKey, data, sig); + return _t960; } bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t971; - void* _t972; + int _t962; + void* _t963; int outlen; outlen = 0; const char* sig; - unsigned int _t970; - _t970 = String_Len(signatureB64); - _t971 = (int)_t970; - _t972 = &outlen; - const char* _t973; - _t973 = bux_base64_decode(signatureB64, _t971, _t972); - sig = _t973; - bool _t974; - _t974 = Rsa_VerifySha384(pemPublicKey, data, sig); - return _t974; + unsigned int _t961; + _t961 = String_Len(signatureB64); + _t962 = (int)_t961; + _t963 = &outlen; + const char* _t964; + _t964 = bux_base64_decode(signatureB64, _t962, _t963); + sig = _t964; + bool _t965; + _t965 = Rsa_VerifySha384(pemPublicKey, data, sig); + return _t965; } bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t976; - void* _t977; + int _t967; + void* _t968; int outlen; outlen = 0; const char* sig; - unsigned int _t975; - _t975 = String_Len(signatureB64); - _t976 = (int)_t975; - _t977 = &outlen; - const char* _t978; - _t978 = bux_base64_decode(signatureB64, _t976, _t977); - sig = _t978; - bool _t979; - _t979 = Rsa_VerifySha512(pemPublicKey, data, sig); - return _t979; + unsigned int _t966; + _t966 = String_Len(signatureB64); + _t967 = (int)_t966; + _t968 = &outlen; + const char* _t969; + _t969 = bux_base64_decode(signatureB64, _t967, _t968); + sig = _t969; + bool _t970; + _t970 = Rsa_VerifySha512(pemPublicKey, data, sig); + return _t970; } int Main(void) { diff --git a/tests/golden/methods/expected.c b/tests/golden/methods/expected.c index 6ef1639..a645b7f 100644 --- a/tests/golden/methods/expected.c +++ b/tests/golden/methods/expected.c @@ -199,6 +199,34 @@ extern const char* bux_base64_decode(const char* data, int len, int* outlen); #define ED25519_PRIVKEY_SIZE 32 #define ED25519_SIG_SIZE 64 +typedef struct Channel_float64 { + void* handle; +} Channel_float64; + +typedef struct TaskHandle { + void* handle; +} TaskHandle; + +typedef struct RwLock { + void* handle; +} RwLock; + +typedef struct Channel_int { + void* handle; +} Channel_int; + +typedef enum { + JwtAlg_HS256, + JwtAlg_HS384, + JwtAlg_HS512, + JwtAlg_RS256, + JwtAlg_RS384, + JwtAlg_RS512, + JwtAlg_ES256, + JwtAlg_ES384, + JwtAlg_EdDSA +} JwtAlg; + typedef enum { Result_Ok, Result_Err @@ -228,31 +256,6 @@ typedef struct { Option_Data data; } Option; -typedef enum { - JwtAlg_HS256, - JwtAlg_HS384, - JwtAlg_HS512, - JwtAlg_RS256, - JwtAlg_RS384, - JwtAlg_RS512, - JwtAlg_ES256, - JwtAlg_ES384, - JwtAlg_EdDSA -} JwtAlg; - - -typedef struct TaskHandle { - void* handle; -} TaskHandle; - -typedef struct Mutex { - void* handle; -} Mutex; - -typedef struct RwLock { - void* handle; -} RwLock; - typedef struct JsonValue { int tag; bool boolVal; @@ -267,12 +270,9 @@ typedef struct JsonValue { unsigned int objCap; } JsonValue; -typedef struct JsonParser { - const char* src; - unsigned int pos; - unsigned int len; - const char* error; -} JsonParser; +typedef struct Mutex { + void* handle; +} Mutex; typedef struct StringBuilder { void* handle; @@ -283,13 +283,12 @@ typedef struct Rectangle { int height; } Rectangle; -typedef struct Channel_int { - void* handle; -} Channel_int; - -typedef struct Channel_float64 { - void* handle; -} Channel_float64; +typedef struct JsonParser { + const char* src; + unsigned int pos; + unsigned int len; + const char* error; +} JsonParser; bool DirExists(const char* path); bool Mkdir(const char* path); @@ -874,7 +873,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { tmplLen = _t60; while1:; _t61 = (i < tmplLen); - if (!_t61) goto wend3; + if (!_t61) goto wend2; { const char* ch; const char* _t62; @@ -882,13 +881,13 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { ch = _t62; bool _t63; _t63 = String_Eq(ch, "{"); - if (!_t63) goto endif5; + if (!_t63) goto endif4; { unsigned int digitIdx; _t64 = i + 1; digitIdx = _t64; _t65 = (digitIdx < tmplLen); - if (!_t65) goto endif7; + if (!_t65) goto endif6; { const char* digitCh; const char* _t66; @@ -900,22 +899,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { d = _t67; bool __and_tmp_0; _t68 = (d >= 0); - if (!_t68) goto else8; + if (!_t68) goto else7; _t69 = (int64_t)argCount; _t70 = (d < _t69); *(bool*)&__and_tmp_0 = _t70; - goto endif9; - else8:; + goto endif8; + else7:; *(bool*)&__and_tmp_0 = 0; - endif9:; + endif8:; bool _t71; _t71 = *(bool*)&__and_tmp_0; - if (!_t71) goto endif11; + if (!_t71) goto endif10; { _t72 = i + 2; i = _t72; _t73 = (i < tmplLen); - if (!_t73) goto endif13; + if (!_t73) goto endif12; { const char* closeCh; const char* _t74; @@ -923,7 +922,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { closeCh = _t74; bool _t75; _t75 = String_Eq(closeCh, "}"); - if (!_t75) goto endif15; + if (!_t75) goto endif14; { _t76 = i + 1; i = _t76; @@ -936,22 +935,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { StringBuilder_Append(_t79, argStr); goto while1; } - endif15:; + endif14:; } - endif13:; + endif12:; } - endif11:; + endif10:; } - endif7:; + endif6:; } - endif5:; + endif4:; _t80 = &sb; StringBuilder_Append(_t80, ch); _t81 = i + 1; i = _t81; } goto while1; - wend3:; + wend2:; _t82 = &sb; const char* _t83; _t83 = StringBuilder_Build(_t82); @@ -959,276 +958,276 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { } const char* Fmt_Fmt1(const char* tmpl, const char* a1) { - const char** _t86; + const char** _t85; const char** args; /* sizeof(const char*) */ - void* _t85; - _t85 = bux_alloc(sizeof(const char*)); - _t86 = (const char**)_t85; - args = _t86; + void* _t84; + _t84 = bux_alloc(sizeof(const char*)); + _t85 = (const char**)_t84; + args = _t85; args[0] = a1; - const char* _t87; - _t87 = Fmt_Format(tmpl, args, 1); - return _t87; + const char* _t86; + _t86 = Fmt_Format(tmpl, args, 1); + return _t86; } const char* Fmt_FmtInt(const char* tmpl, int64_t val) { const char* s; + const char* _t87; + _t87 = String_FromInt(val); + s = _t87; const char* _t88; - _t88 = String_FromInt(val); - s = _t88; - const char* _t89; - _t89 = Fmt_Fmt1(tmpl, s); - return _t89; + _t88 = Fmt_Fmt1(tmpl, s); + return _t88; } const char* Fmt_FmtBool(const char* tmpl, bool val) { const char* s; + const char* _t89; + _t89 = String_FromBool(val); + s = _t89; const char* _t90; - _t90 = String_FromBool(val); - s = _t90; - const char* _t91; - _t91 = Fmt_Fmt1(tmpl, s); - return _t91; + _t90 = Fmt_Fmt1(tmpl, s); + return _t90; } const char* Fmt_FmtFloat(const char* tmpl, double val) { const char* s; + const char* _t91; + _t91 = String_FromFloat(val); + s = _t91; const char* _t92; - _t92 = String_FromFloat(val); - s = _t92; - const char* _t93; - _t93 = Fmt_Fmt1(tmpl, s); - return _t93; + _t92 = Fmt_Fmt1(tmpl, s); + return _t92; } const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2) { - int _t95; - const char** _t97; + int _t93; + const char** _t95; const char** args; /* sizeof(const char*) */ - _t95 = 2 * sizeof(const char*); - void* _t96; - _t96 = bux_alloc(_t95); - _t97 = (const char**)_t96; - args = _t97; + _t93 = 2 * sizeof(const char*); + void* _t94; + _t94 = bux_alloc(_t93); + _t95 = (const char**)_t94; + args = _t95; args[0] = a1; args[1] = a2; - const char* _t98; - _t98 = Fmt_Format(tmpl, args, 2); - return _t98; + const char* _t96; + _t96 = Fmt_Format(tmpl, args, 2); + return _t96; } const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3) { - int _t100; - const char** _t102; + int _t97; + const char** _t99; const char** args; /* sizeof(const char*) */ - _t100 = 3 * sizeof(const char*); - void* _t101; - _t101 = bux_alloc(_t100); - _t102 = (const char**)_t101; - args = _t102; + _t97 = 3 * sizeof(const char*); + void* _t98; + _t98 = bux_alloc(_t97); + _t99 = (const char**)_t98; + args = _t99; args[0] = a1; args[1] = a2; args[2] = a3; - const char* _t103; - _t103 = Fmt_Format(tmpl, args, 3); - return _t103; + const char* _t100; + _t100 = Fmt_Format(tmpl, args, 3); + return _t100; } const char* Crypto_Sha256(const char* data) { - int _t105; - void* _t107; + int _t102; + void* _t104; int len; - unsigned int _t104; - _t104 = String_Len(data); - _t105 = (int)_t104; - len = _t105; + unsigned int _t101; + _t101 = String_Len(data); + _t102 = (int)_t101; + len = _t102; void* hashBuf; - void* _t106; - _t106 = Alloc(32); - hashBuf = _t106; + void* _t103; + _t103 = Alloc(32); + hashBuf = _t103; bux_sha256(data, len, hashBuf); const char* result; - _t107 = (void*)hashBuf; - const char* _t108; - _t108 = bux_bytes_to_hex(_t107, 32); - result = _t108; + _t104 = (void*)hashBuf; + const char* _t105; + _t105 = bux_bytes_to_hex(_t104, 32); + result = _t105; Free(hashBuf); return result; } const char* Crypto_HmacSha256(const char* key, const char* message) { - int _t110; - int _t112; - void* _t114; + int _t107; + int _t109; + void* _t111; int keylen; - unsigned int _t109; - _t109 = String_Len(key); - _t110 = (int)_t109; - keylen = _t110; + unsigned int _t106; + _t106 = String_Len(key); + _t107 = (int)_t106; + keylen = _t107; int msglen; - unsigned int _t111; - _t111 = String_Len(message); - _t112 = (int)_t111; - msglen = _t112; + unsigned int _t108; + _t108 = String_Len(message); + _t109 = (int)_t108; + msglen = _t109; void* hmacBuf; - void* _t113; - _t113 = Alloc(32); - hmacBuf = _t113; + void* _t110; + _t110 = Alloc(32); + hmacBuf = _t110; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t114 = (void*)hmacBuf; - const char* _t115; - _t115 = bux_bytes_to_hex(_t114, 32); - result = _t115; + _t111 = (void*)hmacBuf; + const char* _t112; + _t112 = bux_bytes_to_hex(_t111, 32); + result = _t112; Free(hmacBuf); return result; } const char* Crypto_RandomBytes(int n) { - int _t116; - unsigned int _t117; - int _t120; - const char* _t121; - _t116 = (n <= 0); - if (!_t116) goto endif17; + int _t113; + unsigned int _t114; + int _t117; + const char* _t118; + _t113 = (n <= 0); + if (!_t113) goto endif16; { return ""; } - endif17:; + endif16:; void* buf; - _t117 = (unsigned int)n; - void* _t118; - _t118 = Alloc(_t117); - buf = _t118; - int _t119; - _t119 = bux_random_bytes(buf, n); - _t120 = (_t119 != 1); - if (!_t120) goto endif19; + _t114 = (unsigned int)n; + void* _t115; + _t115 = Alloc(_t114); + buf = _t115; + int _t116; + _t116 = bux_random_bytes(buf, n); + _t117 = (_t116 != 1); + if (!_t117) goto endif18; { Free(buf); return ""; } - endif19:; + endif18:; const char* result; - _t121 = (const char*)buf; - const char* _t122; - _t122 = bux_base64_encode(_t121, n); - result = _t122; + _t118 = (const char*)buf; + const char* _t119; + _t119 = bux_base64_encode(_t118, n); + result = _t119; Free(buf); return result; } const char* Crypto_Base64Encode(const char* s) { - int _t124; - unsigned int _t123; - _t123 = String_Len(s); - _t124 = (int)_t123; - const char* _t125; - _t125 = bux_base64_encode(s, _t124); - return _t125; + int _t121; + unsigned int _t120; + _t120 = String_Len(s); + _t121 = (int)_t120; + const char* _t122; + _t122 = bux_base64_encode(s, _t121); + return _t122; } const char* Crypto_HmacSha256Raw(const char* key, const char* message) { - int _t127; - int _t129; - const char* _t131; + int _t124; + int _t126; + const char* _t128; int keylen; - unsigned int _t126; - _t126 = String_Len(key); - _t127 = (int)_t126; - keylen = _t127; + unsigned int _t123; + _t123 = String_Len(key); + _t124 = (int)_t123; + keylen = _t124; int msglen; - unsigned int _t128; - _t128 = String_Len(message); - _t129 = (int)_t128; - msglen = _t129; + unsigned int _t125; + _t125 = String_Len(message); + _t126 = (int)_t125; + msglen = _t126; void* hmacBuf; - void* _t130; - _t130 = Alloc(32); - hmacBuf = _t130; + void* _t127; + _t127 = Alloc(32); + hmacBuf = _t127; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t131 = (const char*)hmacBuf; - const char* _t132; - _t132 = bux_base64_encode(_t131, 32); - result = _t132; + _t128 = (const char*)hmacBuf; + const char* _t129; + _t129 = bux_base64_encode(_t128, 32); + result = _t129; Free(hmacBuf); return result; } const char* Crypto_Base64Decode(const char* s) { - int _t134; - void* _t135; + int _t131; + void* _t132; int outlen; outlen = 0; - unsigned int _t133; - _t133 = String_Len(s); - _t134 = (int)_t133; - _t135 = &outlen; - const char* _t136; - _t136 = bux_base64_decode(s, _t134, _t135); - return _t136; + unsigned int _t130; + _t130 = String_Len(s); + _t131 = (int)_t130; + _t132 = &outlen; + const char* _t133; + _t133 = bux_base64_decode(s, _t131, _t132); + return _t133; } Mutex Mutex_New(void) { - Mutex _t138; - void* _t137; - _t137 = bux_mutex_new(); - _t138 = (Mutex){.handle = _t137}; - return _t138; + Mutex _t135; + void* _t134; + _t134 = bux_mutex_new(); + _t135 = (Mutex){.handle = _t134}; + return _t135; } void Mutex_Lock(Mutex* m) { - void* _t139; - _t139 = m->handle; - bux_mutex_lock(_t139); + void* _t136; + _t136 = m->handle; + bux_mutex_lock(_t136); } void Mutex_Unlock(Mutex* m) { - void* _t140; - _t140 = m->handle; - bux_mutex_unlock(_t140); + void* _t137; + _t137 = m->handle; + bux_mutex_unlock(_t137); } void Mutex_Free(Mutex* m) { - void* _t141; - _t141 = m->handle; - bux_mutex_free(_t141); + void* _t138; + _t138 = m->handle; + bux_mutex_free(_t138); } RwLock RwLock_New(void) { - RwLock _t143; - void* _t142; - _t142 = bux_rwlock_new(); - _t143 = (RwLock){.handle = _t142}; - return _t143; + RwLock _t140; + void* _t139; + _t139 = bux_rwlock_new(); + _t140 = (RwLock){.handle = _t139}; + return _t140; } void RwLock_ReadLock(RwLock* rw) { - void* _t144; - _t144 = rw->handle; - bux_rwlock_rdlock(_t144); + void* _t141; + _t141 = rw->handle; + bux_rwlock_rdlock(_t141); } void RwLock_WriteLock(RwLock* rw) { - void* _t145; - _t145 = rw->handle; - bux_rwlock_wrlock(_t145); + void* _t142; + _t142 = rw->handle; + bux_rwlock_wrlock(_t142); } void RwLock_Unlock(RwLock* rw) { - void* _t146; - _t146 = rw->handle; - bux_rwlock_unlock(_t146); + void* _t143; + _t143 = rw->handle; + bux_rwlock_unlock(_t143); } void RwLock_Free(RwLock* rw) { - void* _t147; - _t147 = rw->handle; - bux_rwlock_free(_t147); + void* _t144; + _t144 = rw->handle; + bux_rwlock_free(_t144); } void Test_Exit(int code) { @@ -1236,15 +1235,15 @@ void Test_Exit(int code) { } void Test_Assert(bool cond) { - int _t148; - _t148 = (int)cond; - bux_assert(_t148, "", 0, ""); + int _t145; + _t145 = (int)cond; + bux_assert(_t145, "", 0, ""); } void Test_AssertEqInt(int a, int b) { - int _t149; - _t149 = (a != b); - if (!_t149) goto endif21; + int _t146; + _t146 = (a != b); + if (!_t146) goto endif20; { PrintLine("ASSERT_EQ FAILED:"); PrintInt(a); @@ -1252,27 +1251,27 @@ void Test_AssertEqInt(int a, int b) { PrintInt(b); bux_exit(1); } - endif21:; + endif20:; } void Test_AssertTrue(bool cond) { - int _t150; - _t150 = !cond; - if (!_t150) goto endif23; + int _t147; + _t147 = !cond; + if (!_t147) goto endif22; { PrintLine("ASSERT_TRUE FAILED"); bux_exit(1); } - endif23:; + endif22:; } void Test_AssertFalse(bool cond) { - if (!cond) goto endif25; + if (!cond) goto endif24; { PrintLine("ASSERT_FALSE FAILED"); bux_exit(1); } - endif25:; + endif24:; } void Test_Fail(const char* msg) { @@ -1282,735 +1281,744 @@ void Test_Fail(const char* msg) { } Result Result_NewOk(int value) { - Result _t151; + Result _t148; Result r; - _t151 = (Result){.tag = Result_Ok}; - r = _t151; + _t148 = (Result){.tag = Result_Ok}; + r = _t148; r.data.Ok_0 = value; return r; } Result Result_NewErr(const char* msg) { - Result _t152; + Result _t149; Result r; - _t152 = (Result){.tag = Result_Err}; - r = _t152; + _t149 = (Result){.tag = Result_Err}; + r = _t149; r.data.Err_0 = msg; return r; } bool Result_IsOk(Result r) { - int _t154; - Result_Tag _t153; - _t153 = r.tag; - _t154 = (_t153 == Result_Ok); - return _t154; + int _t151; + Result_Tag _t150; + _t150 = r.tag; + _t151 = (_t150 == Result_Ok); + return _t151; } bool Result_IsErr(Result r) { - int _t156; - Result_Tag _t155; - _t155 = r.tag; - _t156 = (_t155 == Result_Err); - return _t156; + int _t153; + Result_Tag _t152; + _t152 = r.tag; + _t153 = (_t152 == Result_Err); + return _t153; } int Result_Unwrap(Result r) { - int _t158; - Result_Tag _t157; - _t157 = r.tag; - _t158 = (_t157 != Result_Ok); - if (!_t158) goto endif27; + int _t155; + Result_Tag _t154; + _t154 = r.tag; + _t155 = (_t154 != Result_Ok); + if (!_t155) goto endif26; { PrintLine("panic: unwrap on Err"); return 0; } - endif27:; - Result_Data _t159; - _t159 = r.data; - int _t160; - _t160 = _t159.Ok_0; - return _t160; + endif26:; + Result_Data _t156; + _t156 = r.data; + int _t157; + _t157 = _t156.Ok_0; + return _t157; } int Result_UnwrapOr(Result r, int fallback) { - int _t162; - Result_Tag _t161; - _t161 = r.tag; - _t162 = (_t161 == Result_Ok); - if (!_t162) goto endif29; + int _t159; + Result_Tag _t158; + _t158 = r.tag; + _t159 = (_t158 == Result_Ok); + if (!_t159) goto endif28; { - Result_Data _t163; - _t163 = r.data; - int _t164; - _t164 = _t163.Ok_0; - return _t164; + Result_Data _t160; + _t160 = r.data; + int _t161; + _t161 = _t160.Ok_0; + return _t161; } - endif29:; + endif28:; return fallback; } Option Option_NewSome(int value) { - Option _t165; + Option _t162; Option o; - _t165 = (Option){.tag = Option_Some}; - o = _t165; + _t162 = (Option){.tag = Option_Some}; + o = _t162; o.data.Some_0 = value; return o; } Option Option_NewNone(void) { - Option _t166; - _t166 = (Option){.tag = Option_None}; - return _t166; + Option _t163; + _t163 = (Option){.tag = Option_None}; + return _t163; } bool Option_IsSome(Option o) { - int _t168; - Option_Tag _t167; - _t167 = o.tag; - _t168 = (_t167 == Option_Some); - return _t168; + int _t165; + Option_Tag _t164; + _t164 = o.tag; + _t165 = (_t164 == Option_Some); + return _t165; } bool Option_IsNone(Option o) { - int _t170; - Option_Tag _t169; - _t169 = o.tag; - _t170 = (_t169 == Option_None); - return _t170; + int _t167; + Option_Tag _t166; + _t166 = o.tag; + _t167 = (_t166 == Option_None); + return _t167; } int Option_Unwrap(Option o) { - int _t172; - Option_Tag _t171; - _t171 = o.tag; - _t172 = (_t171 != Option_Some); - if (!_t172) goto endif31; + int _t169; + Option_Tag _t168; + _t168 = o.tag; + _t169 = (_t168 != Option_Some); + if (!_t169) goto endif30; { PrintLine("panic: unwrap on None"); return 0; } - endif31:; - Option_Data _t173; - _t173 = o.data; - int _t174; - _t174 = _t173.Some_0; - return _t174; + endif30:; + Option_Data _t170; + _t170 = o.data; + int _t171; + _t171 = _t170.Some_0; + return _t171; } int Option_UnwrapOr(Option o, int fallback) { - int _t176; - Option_Tag _t175; - _t175 = o.tag; - _t176 = (_t175 == Option_Some); - if (!_t176) goto endif33; + int _t173; + Option_Tag _t172; + _t172 = o.tag; + _t173 = (_t172 == Option_Some); + if (!_t173) goto endif32; { - Option_Data _t177; - _t177 = o.data; - int _t178; - _t178 = _t177.Some_0; - return _t178; + Option_Data _t174; + _t174 = o.data; + int _t175; + _t175 = _t174.Some_0; + return _t175; } - endif33:; + endif32:; return fallback; } JsonValue Json_Null(void) { - JsonValue _t179; - _t179 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t179; + JsonValue _t176; + _t176 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t176; } JsonValue Json_Bool(bool b) { - JsonValue _t180; - _t180 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t180; + JsonValue _t177; + _t177 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t177; } JsonValue Json_Number(double n) { - JsonValue _t181; - _t181 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t181; + JsonValue _t178; + _t178 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t178; } JsonValue Json_String(const char* s) { - JsonValue _t182; - _t182 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t182; + JsonValue _t179; + _t179 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t179; } JsonValue Json_Array(void) { - JsonValue _t183; - _t183 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t183; + JsonValue _t180; + _t180 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t180; } JsonValue Json_Object(void) { - JsonValue _t184; - _t184 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t184; + JsonValue _t181; + _t181 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t181; } unsigned int Json_ArrayLen(JsonValue v) { - int _t186; - int _t185; - _t185 = v.tag; - _t186 = (_t185 != JsonTagArray); - if (!_t186) goto endif35; + int _t183; + int _t182; + _t182 = v.tag; + _t183 = (_t182 != JsonTagArray); + if (!_t183) goto endif34; { return 0; } - endif35:; - unsigned int _t187; - _t187 = v.arrLen; - return _t187; + endif34:; + unsigned int _t184; + _t184 = v.arrLen; + return _t184; } JsonValue Json_ArrayGet(JsonValue v, unsigned int index) { + int _t186; int _t189; - int _t192; - int _t188; - _t188 = v.tag; - _t189 = (_t188 != JsonTagArray); - if (!_t189) goto endif37; + int _t185; + _t185 = v.tag; + _t186 = (_t185 != JsonTagArray); + if (!_t186) goto endif36; + { + JsonValue _t187; + _t187 = Json_Null(); + return _t187; + } + endif36:; + unsigned int _t188; + _t188 = v.arrLen; + _t189 = (index >= _t188); + if (!_t189) goto endif38; { JsonValue _t190; _t190 = Json_Null(); return _t190; } - endif37:; - unsigned int _t191; - _t191 = v.arrLen; - _t192 = (index >= _t191); - if (!_t192) goto endif39; - { - JsonValue _t193; - _t193 = Json_Null(); - return _t193; - } - endif39:; - JsonValue* _t194; - _t194 = v.arrData; - JsonValue _t195; - _t195 = _t194[index]; - return _t195; + endif38:; + JsonValue* _t191; + _t191 = v.arrData; + JsonValue _t192; + _t192 = _t191[index]; + return _t192; } void Json_ArrayPush(JsonValue* self, JsonValue val) { + int _t194; int _t197; + int _t199; int _t200; - int _t202; - int _t204; - JsonValue* _t206; - int _t207; - void* _t209; - int _t211; - JsonValue* _t213; - int _t217; - int _t196; - _t196 = self->tag; - _t197 = (_t196 != JsonTagArray); - if (!_t197) goto endif41; + JsonValue* _t202; + int _t203; + void* _t205; + int _t206; + JsonValue* _t208; + int _t212; + int _t193; + _t193 = self->tag; + _t194 = (_t193 != JsonTagArray); + if (!_t194) goto endif40; { return; } - endif41:; - unsigned int _t198; - _t198 = self->arrLen; - unsigned int _t199; - _t199 = self->arrCap; - _t200 = (_t198 >= _t199); - if (!_t200) goto endif43; + endif40:; + unsigned int _t195; + _t195 = self->arrLen; + unsigned int _t196; + _t196 = self->arrCap; + _t197 = (_t195 >= _t196); + if (!_t197) goto endif42; { unsigned int arrNewCap; - unsigned int _t201; - _t201 = self->arrCap; - arrNewCap = _t201; - _t202 = (arrNewCap == 0); - if (!_t202) goto else44; + unsigned int _t198; + _t198 = self->arrCap; + arrNewCap = _t198; + _t199 = (arrNewCap == 0); + if (!_t199) goto else43; { self->arrCap = 4; /* sizeof(JsonValue) */ - _t204 = 4 * sizeof(JsonValue); - void* _t205; - _t205 = Alloc(_t204); - _t206 = (JsonValue*)_t205; - self->arrData = _t206; + _t200 = 4 * sizeof(JsonValue); + void* _t201; + _t201 = Alloc(_t200); + _t202 = (JsonValue*)_t201; + self->arrData = _t202; } - goto endif45; - else44:; + goto endif44; + else43:; { unsigned int doubleCap; - _t207 = arrNewCap * 2; - doubleCap = _t207; + _t203 = arrNewCap * 2; + doubleCap = _t203; self->arrCap = doubleCap; - JsonValue* _t208; - _t208 = self->arrData; - _t209 = (void*)_t208; + JsonValue* _t204; + _t204 = self->arrData; + _t205 = (void*)_t204; /* sizeof(JsonValue) */ - _t211 = doubleCap * sizeof(JsonValue); - void* _t212; - _t212 = Realloc(_t209, _t211); - _t213 = (JsonValue*)_t212; - self->arrData = _t213; + _t206 = doubleCap * sizeof(JsonValue); + void* _t207; + _t207 = Realloc(_t205, _t206); + _t208 = (JsonValue*)_t207; + self->arrData = _t208; } - endif45:; + endif44:; } - endif43:; - JsonValue* _t214; - _t214 = self->arrData; - unsigned int _t215; - _t215 = self->arrLen; - _t214[_t215] = val; - unsigned int _t216; - _t216 = self->arrLen; - _t217 = _t216 + 1; - self->arrLen = _t217; + endif42:; + JsonValue* _t209; + _t209 = self->arrData; + unsigned int _t210; + _t210 = self->arrLen; + _t209[_t210] = val; + unsigned int _t211; + _t211 = self->arrLen; + _t212 = _t211 + 1; + self->arrLen = _t212; } unsigned int Json_ObjectLen(JsonValue v) { - int _t219; - int _t218; - _t218 = v.tag; - _t219 = (_t218 != JsonTagObject); - if (!_t219) goto endif47; + int _t214; + int _t213; + _t213 = v.tag; + _t214 = (_t213 != JsonTagObject); + if (!_t214) goto endif46; { return 0; } - endif47:; - unsigned int _t220; - _t220 = v.objLen; - return _t220; + endif46:; + unsigned int _t215; + _t215 = v.objLen; + return _t215; } JsonValue Json_ObjectGet(JsonValue v, const char* key) { - int _t222; - int _t225; - int _t231; - int _t221; - _t221 = v.tag; - _t222 = (_t221 != JsonTagObject); - if (!_t222) goto endif49; + int _t217; + int _t220; + int _t226; + int _t216; + _t216 = v.tag; + _t217 = (_t216 != JsonTagObject); + if (!_t217) goto endif48; { - JsonValue _t223; - _t223 = Json_Null(); - return _t223; + JsonValue _t218; + _t218 = Json_Null(); + return _t218; } - endif49:; + endif48:; unsigned int i; i = 0; - while50:; - unsigned int _t224; - _t224 = v.objLen; - _t225 = (i < _t224); - if (!_t225) goto wend52; + while49:; + unsigned int _t219; + _t219 = v.objLen; + _t220 = (i < _t219); + if (!_t220) goto wend50; { - const char** _t226; - _t226 = v.objKeys; - const char* _t227; - _t227 = _t226[i]; - bool _t228; - _t228 = String_Eq(_t227, key); - if (!_t228) goto endif54; + const char** _t221; + _t221 = v.objKeys; + const char* _t222; + _t222 = _t221[i]; + bool _t223; + _t223 = String_Eq(_t222, key); + if (!_t223) goto endif52; { - JsonValue* _t229; - _t229 = v.objValues; - JsonValue _t230; - _t230 = _t229[i]; - return _t230; + JsonValue* _t224; + _t224 = v.objValues; + JsonValue _t225; + _t225 = _t224[i]; + return _t225; } - endif54:; - _t231 = i + 1; - i = _t231; + endif52:; + _t226 = i + 1; + i = _t226; } - goto while50; - wend52:; - JsonValue _t232; - _t232 = Json_Null(); - return _t232; + goto while49; + wend50:; + JsonValue _t227; + _t227 = Json_Null(); + return _t227; } bool Json_ObjectHas(JsonValue v, const char* key) { - int _t234; - int _t236; - int _t240; - int _t233; - _t233 = v.tag; - _t234 = (_t233 != JsonTagObject); - if (!_t234) goto endif56; + int _t229; + int _t231; + int _t235; + int _t228; + _t228 = v.tag; + _t229 = (_t228 != JsonTagObject); + if (!_t229) goto endif54; { return 0; } - endif56:; + endif54:; unsigned int i; i = 0; - while57:; - unsigned int _t235; - _t235 = v.objLen; - _t236 = (i < _t235); - if (!_t236) goto wend59; + while55:; + unsigned int _t230; + _t230 = v.objLen; + _t231 = (i < _t230); + if (!_t231) goto wend56; { - const char** _t237; - _t237 = v.objKeys; - const char* _t238; - _t238 = _t237[i]; - bool _t239; - _t239 = String_Eq(_t238, key); - if (!_t239) goto endif61; + const char** _t232; + _t232 = v.objKeys; + const char* _t233; + _t233 = _t232[i]; + bool _t234; + _t234 = String_Eq(_t233, key); + if (!_t234) goto endif58; { return 1; } - endif61:; - _t240 = i + 1; - i = _t240; + endif58:; + _t235 = i + 1; + i = _t235; } - goto while57; - wend59:; + goto while55; + wend56:; return 0; } void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) { - int _t242; + int _t237; + int _t239; int _t244; + int _t247; int _t249; - int _t252; - int _t254; + int _t250; + const char** _t252; + int _t253; + JsonValue* _t255; int _t256; - const char** _t258; - int _t260; - JsonValue* _t262; - int _t263; - void* _t265; - int _t267; - const char** _t269; - void* _t271; - int _t273; - JsonValue* _t275; - int _t281; - int _t241; - _t241 = self->tag; - _t242 = (_t241 != JsonTagObject); - if (!_t242) goto endif63; + void* _t258; + int _t259; + const char** _t261; + void* _t263; + int _t264; + JsonValue* _t266; + int _t272; + int _t236; + _t236 = self->tag; + _t237 = (_t236 != JsonTagObject); + if (!_t237) goto endif60; { return; } - endif63:; + endif60:; unsigned int i; i = 0; - while64:; - unsigned int _t243; - _t243 = self->objLen; - _t244 = (i < _t243); - if (!_t244) goto wend66; + while61:; + unsigned int _t238; + _t238 = self->objLen; + _t239 = (i < _t238); + if (!_t239) goto wend62; { - const char** _t245; - _t245 = self->objKeys; - const char* _t246; - _t246 = _t245[i]; - bool _t247; - _t247 = String_Eq(_t246, key); - if (!_t247) goto endif68; + const char** _t240; + _t240 = self->objKeys; + const char* _t241; + _t241 = _t240[i]; + bool _t242; + _t242 = String_Eq(_t241, key); + if (!_t242) goto endif64; { - JsonValue* _t248; - _t248 = self->objValues; - _t248[i] = val; + JsonValue* _t243; + _t243 = self->objValues; + _t243[i] = val; return; } - endif68:; - _t249 = i + 1; - i = _t249; + endif64:; + _t244 = i + 1; + i = _t244; } - goto while64; - wend66:; - unsigned int _t250; - _t250 = self->objLen; - unsigned int _t251; - _t251 = self->objCap; - _t252 = (_t250 >= _t251); - if (!_t252) goto endif70; + goto while61; + wend62:; + unsigned int _t245; + _t245 = self->objLen; + unsigned int _t246; + _t246 = self->objCap; + _t247 = (_t245 >= _t246); + if (!_t247) goto endif66; { unsigned int objNewCap; - unsigned int _t253; - _t253 = self->objCap; - objNewCap = _t253; - _t254 = (objNewCap == 0); - if (!_t254) goto else71; + unsigned int _t248; + _t248 = self->objCap; + objNewCap = _t248; + _t249 = (objNewCap == 0); + if (!_t249) goto else67; { self->objCap = 4; /* sizeof(const char*) */ - _t256 = 4 * sizeof(const char*); - void* _t257; - _t257 = Alloc(_t256); - _t258 = (const char**)_t257; - self->objKeys = _t258; + _t250 = 4 * sizeof(const char*); + void* _t251; + _t251 = Alloc(_t250); + _t252 = (const char**)_t251; + self->objKeys = _t252; /* sizeof(JsonValue) */ - _t260 = 4 * sizeof(JsonValue); - void* _t261; - _t261 = Alloc(_t260); - _t262 = (JsonValue*)_t261; - self->objValues = _t262; + _t253 = 4 * sizeof(JsonValue); + void* _t254; + _t254 = Alloc(_t253); + _t255 = (JsonValue*)_t254; + self->objValues = _t255; } - goto endif72; - else71:; + goto endif68; + else67:; { unsigned int doubleCap; - _t263 = objNewCap * 2; - doubleCap = _t263; + _t256 = objNewCap * 2; + doubleCap = _t256; self->objCap = doubleCap; - const char** _t264; - _t264 = self->objKeys; - _t265 = (void*)_t264; + const char** _t257; + _t257 = self->objKeys; + _t258 = (void*)_t257; /* sizeof(const char*) */ - _t267 = doubleCap * sizeof(const char*); - void* _t268; - _t268 = Realloc(_t265, _t267); - _t269 = (const char**)_t268; - self->objKeys = _t269; - JsonValue* _t270; - _t270 = self->objValues; - _t271 = (void*)_t270; + _t259 = doubleCap * sizeof(const char*); + void* _t260; + _t260 = Realloc(_t258, _t259); + _t261 = (const char**)_t260; + self->objKeys = _t261; + JsonValue* _t262; + _t262 = self->objValues; + _t263 = (void*)_t262; /* sizeof(JsonValue) */ - _t273 = doubleCap * sizeof(JsonValue); - void* _t274; - _t274 = Realloc(_t271, _t273); - _t275 = (JsonValue*)_t274; - self->objValues = _t275; + _t264 = doubleCap * sizeof(JsonValue); + void* _t265; + _t265 = Realloc(_t263, _t264); + _t266 = (JsonValue*)_t265; + self->objValues = _t266; } - endif72:; + endif68:; } - endif70:; - const char** _t276; - _t276 = self->objKeys; - unsigned int _t277; - _t277 = self->objLen; - _t276[_t277] = key; - JsonValue* _t278; - _t278 = self->objValues; - unsigned int _t279; - _t279 = self->objLen; - _t278[_t279] = val; - unsigned int _t280; - _t280 = self->objLen; - _t281 = _t280 + 1; - self->objLen = _t281; + endif66:; + const char** _t267; + _t267 = self->objKeys; + unsigned int _t268; + _t268 = self->objLen; + _t267[_t268] = key; + JsonValue* _t269; + _t269 = self->objValues; + unsigned int _t270; + _t270 = self->objLen; + _t269[_t270] = val; + unsigned int _t271; + _t271 = self->objLen; + _t272 = _t271 + 1; + self->objLen = _t272; } bool Json_IsNull(JsonValue v) { - int _t283; - int _t282; - _t282 = v.tag; - _t283 = (_t282 == JsonTagNull); - return _t283; + int _t274; + int _t273; + _t273 = v.tag; + _t274 = (_t273 == JsonTagNull); + return _t274; } bool Json_AsBool(JsonValue v) { - int _t285; - int _t284; - _t284 = v.tag; - _t285 = (_t284 == JsonTagBool); - if (!_t285) goto endif74; + int _t276; + int _t275; + _t275 = v.tag; + _t276 = (_t275 == JsonTagBool); + if (!_t276) goto endif70; { - bool _t286; - _t286 = v.boolVal; - return _t286; + bool _t277; + _t277 = v.boolVal; + return _t277; } - endif74:; + endif70:; return 0; } double Json_AsNumber(JsonValue v) { - int _t288; - int _t287; - _t287 = v.tag; - _t288 = (_t287 == JsonTagNumber); - if (!_t288) goto endif76; + int _t279; + int _t278; + _t278 = v.tag; + _t279 = (_t278 == JsonTagNumber); + if (!_t279) goto endif72; { - double _t289; - _t289 = v.numVal; - return _t289; + double _t280; + _t280 = v.numVal; + return _t280; } - endif76:; + endif72:; return 0.0; } const char* Json_AsString(JsonValue v) { - int _t291; - int _t290; - _t290 = v.tag; - _t291 = (_t290 == JsonTagString); - if (!_t291) goto endif78; + int _t282; + int _t281; + _t281 = v.tag; + _t282 = (_t281 == JsonTagString); + if (!_t282) goto endif74; { - const char* _t292; - _t292 = v.strVal; - return _t292; + const char* _t283; + _t283 = v.strVal; + return _t283; } - endif78:; + endif74:; return ""; } int JsonParser_Peek(JsonParser* p) { - int _t295; - int _t299; - unsigned int _t293; - _t293 = p->pos; - unsigned int _t294; - _t294 = p->len; - _t295 = (_t293 >= _t294); - if (!_t295) goto endif80; + int _t286; + int _t290; + unsigned int _t284; + _t284 = p->pos; + unsigned int _t285; + _t285 = p->len; + _t286 = (_t284 >= _t285); + if (!_t286) goto endif76; { return 0; } - endif80:; - const char* _t296; - _t296 = p->src; - unsigned int _t297; - _t297 = p->pos; - int _t298; - _t298 = _t296[_t297]; - _t299 = (int)_t298; - return _t299; + endif76:; + const char* _t287; + _t287 = p->src; + unsigned int _t288; + _t288 = p->pos; + int _t289; + _t289 = _t287[_t288]; + _t290 = (int)_t289; + return _t290; } void JsonParser_Advance(JsonParser* p) { - int _t302; - int _t304; - unsigned int _t300; - _t300 = p->pos; - unsigned int _t301; - _t301 = p->len; - _t302 = (_t300 < _t301); - if (!_t302) goto endif82; + int _t293; + int _t295; + unsigned int _t291; + _t291 = p->pos; + unsigned int _t292; + _t292 = p->len; + _t293 = (_t291 < _t292); + if (!_t293) goto endif78; { - unsigned int _t303; - _t303 = p->pos; - _t304 = _t303 + 1; - p->pos = _t304; + unsigned int _t294; + _t294 = p->pos; + _t295 = _t294 + 1; + p->pos = _t295; } - endif82:; + endif78:; } void JsonParser_SkipWhitespace(JsonParser* p) { - int _t306; - int _t307; - int _t309; - int _t311; - while83:; - if (!1) goto wend85; + int _t297; + int _t298; + int _t300; + int _t302; + while79:; + if (!1) goto wend80; { int c; - int _t305; - _t305 = JsonParser_Peek(p); - c = _t305; + int _t296; + _t296 = JsonParser_Peek(p); + c = _t296; bool __or_tmp_1; bool __or_tmp_2; bool __or_tmp_3; - _t306 = (c == 32); - if (!_t306) goto else86; + _t297 = (c == 32); + if (!_t297) goto else81; *(bool*)&__or_tmp_3 = 1; - goto endif87; - else86:; - _t307 = (c == 9); - *(bool*)&__or_tmp_3 = _t307; - endif87:; - bool _t308; - _t308 = *(bool*)&__or_tmp_3; - if (!_t308) goto else88; + goto endif82; + else81:; + _t298 = (c == 9); + *(bool*)&__or_tmp_3 = _t298; + endif82:; + bool _t299; + _t299 = *(bool*)&__or_tmp_3; + if (!_t299) goto else83; *(bool*)&__or_tmp_2 = 1; - goto endif89; - else88:; - _t309 = (c == 10); - *(bool*)&__or_tmp_2 = _t309; - endif89:; - bool _t310; - _t310 = *(bool*)&__or_tmp_2; - if (!_t310) goto else90; + goto endif84; + else83:; + _t300 = (c == 10); + *(bool*)&__or_tmp_2 = _t300; + endif84:; + bool _t301; + _t301 = *(bool*)&__or_tmp_2; + if (!_t301) goto else85; *(bool*)&__or_tmp_1 = 1; - goto endif91; - else90:; - _t311 = (c == 13); - *(bool*)&__or_tmp_1 = _t311; - endif91:; - bool _t312; - _t312 = *(bool*)&__or_tmp_1; - if (!_t312) goto else92; + goto endif86; + else85:; + _t302 = (c == 13); + *(bool*)&__or_tmp_1 = _t302; + endif86:; + bool _t303; + _t303 = *(bool*)&__or_tmp_1; + if (!_t303) goto else87; { JsonParser_Advance(p); } - goto endif93; - else92:; + goto endif88; + else87:; { return; } - endif93:; + endif88:; } - goto while83; - wend85:; + goto while79; + wend80:; } bool JsonParser_Match(JsonParser* p, const char* expected) { + int _t306; + int _t308; + int _t309; + int _t312; int _t315; - int _t317; + int _t316; int _t318; - int _t321; - int _t324; - int _t325; - int _t327; unsigned int elen; - unsigned int _t313; - _t313 = String_Len(expected); - elen = _t313; - unsigned int _t314; - _t314 = p->pos; - _t315 = _t314 + elen; - unsigned int _t316; - _t316 = p->len; - _t317 = (_t315 > _t316); - if (!_t317) goto endif95; + unsigned int _t304; + _t304 = String_Len(expected); + elen = _t304; + unsigned int _t305; + _t305 = p->pos; + _t306 = _t305 + elen; + unsigned int _t307; + _t307 = p->len; + _t308 = (_t306 > _t307); + if (!_t308) goto endif90; { return 0; } - endif95:; + endif90:; unsigned int i; i = 0; - while96:; - _t318 = (i < elen); - if (!_t318) goto wend98; + while91:; + _t309 = (i < elen); + if (!_t309) goto wend92; { - const char* _t319; - _t319 = p->src; - unsigned int _t320; - _t320 = p->pos; - _t321 = _t320 + i; - int _t322; - _t322 = _t319[_t321]; - int _t323; - _t323 = expected[i]; - _t324 = (_t322 != _t323); - if (!_t324) goto endif100; + const char* _t310; + _t310 = p->src; + unsigned int _t311; + _t311 = p->pos; + _t312 = _t311 + i; + int _t313; + _t313 = _t310[_t312]; + int _t314; + _t314 = expected[i]; + _t315 = (_t313 != _t314); + if (!_t315) goto endif94; { return 0; } - endif100:; - _t325 = i + 1; - i = _t325; + endif94:; + _t316 = i + 1; + i = _t316; } - goto while96; - wend98:; - unsigned int _t326; - _t326 = p->pos; - _t327 = _t326 + elen; - p->pos = _t327; + goto while91; + wend92:; + unsigned int _t317; + _t317 = p->pos; + _t318 = _t317 + elen; + p->pos = _t318; return 1; } const char* JsonParser_ParseString(JsonParser* p) { - int _t329; - int _t332; + int _t320; + int _t323; + int _t324; + int _t326; + int _t328; + void* _t329; + int _t330; + void* _t331; + char _t332; int _t333; - int _t335; - int _t337; - void* _t338; + void* _t334; + char _t335; + int _t336; + void* _t337; + char _t338; int _t339; void* _t340; char _t341; @@ -2023,234 +2031,262 @@ const char* JsonParser_ParseString(JsonParser* p) { int _t348; void* _t349; char _t350; - int _t351; - void* _t352; - char _t353; - int _t354; + void* _t351; + char _t352; + void* _t353; + char _t354; void* _t355; char _t356; - int _t357; - void* _t358; - char _t359; + int _t358; + void* _t359; void* _t360; - char _t361; void* _t362; - char _t363; - void* _t364; - char _t365; - int _t367; - void* _t368; - void* _t369; - void* _t371; - int _t328; - _t328 = JsonParser_Peek(p); - _t329 = (_t328 != 34); - if (!_t329) goto endif102; + int _t319; + _t319 = JsonParser_Peek(p); + _t320 = (_t319 != 34); + if (!_t320) goto endif96; { p->error = "Expected string"; return ""; } - endif102:; + endif96:; JsonParser_Advance(p); StringBuilder sb; - StringBuilder _t330; - _t330 = StringBuilder_New(); - sb = _t330; - while103:; - if (!1) goto wend105; + StringBuilder _t321; + _t321 = StringBuilder_New(); + sb = _t321; + while97:; + if (!1) goto wend98; { int c; - int _t331; - _t331 = JsonParser_Peek(p); - c = _t331; + int _t322; + _t322 = JsonParser_Peek(p); + c = _t322; bool __or_tmp_4; - _t332 = (c == 0); - if (!_t332) goto else106; + _t323 = (c == 0); + if (!_t323) goto else99; *(bool*)&__or_tmp_4 = 1; - goto endif107; - else106:; - _t333 = (c == 34); - *(bool*)&__or_tmp_4 = _t333; - endif107:; - bool _t334; - _t334 = *(bool*)&__or_tmp_4; - if (!_t334) goto endif109; + goto endif100; + else99:; + _t324 = (c == 34); + *(bool*)&__or_tmp_4 = _t324; + endif100:; + bool _t325; + _t325 = *(bool*)&__or_tmp_4; + if (!_t325) goto endif102; { - goto wend105; + goto wend98; } - endif109:; - _t335 = (c == 92); - if (!_t335) goto else110; + endif102:; + _t326 = (c == 92); + if (!_t326) goto else103; { JsonParser_Advance(p); int esc; - int _t336; - _t336 = JsonParser_Peek(p); - esc = _t336; - _t337 = (esc == 0); - if (!_t337) goto endif113; + int _t327; + _t327 = JsonParser_Peek(p); + esc = _t327; + _t328 = (esc == 0); + if (!_t328) goto endif106; { p->error = "Unterminated string escape"; - _t338 = &sb; - StringBuilder_Free(_t338); + _t329 = &sb; + StringBuilder_Free(_t329); return ""; } - endif113:; - _t339 = (esc == 110); - if (!_t339) goto else114; + endif106:; + _t330 = (esc == 110); + if (!_t330) goto else107; + { + _t331 = &sb; + _t332 = (char)10; + StringBuilder_AppendChar(_t331, _t332); + } + goto endif108; + else107:; + _t333 = (esc == 116); + if (!_t333) goto else109; + { + _t334 = &sb; + _t335 = (char)9; + StringBuilder_AppendChar(_t334, _t335); + } + goto endif110; + else109:; + _t336 = (esc == 114); + if (!_t336) goto else111; + { + _t337 = &sb; + _t338 = (char)13; + StringBuilder_AppendChar(_t337, _t338); + } + goto endif112; + else111:; + _t339 = (esc == 98); + if (!_t339) goto else113; { _t340 = &sb; - _t341 = (char)10; + _t341 = (char)8; StringBuilder_AppendChar(_t340, _t341); } - goto endif115; - else114:; - _t342 = (esc == 116); - if (!_t342) goto else116; + goto endif114; + else113:; + _t342 = (esc == 102); + if (!_t342) goto else115; { _t343 = &sb; - _t344 = (char)9; + _t344 = (char)12; StringBuilder_AppendChar(_t343, _t344); } - goto endif117; - else116:; - _t345 = (esc == 114); - if (!_t345) goto else118; + goto endif116; + else115:; + _t345 = (esc == 34); + if (!_t345) goto else117; { _t346 = &sb; - _t347 = (char)13; + _t347 = (char)34; StringBuilder_AppendChar(_t346, _t347); } - goto endif119; - else118:; - _t348 = (esc == 98); - if (!_t348) goto else120; + goto endif118; + else117:; + _t348 = (esc == 92); + if (!_t348) goto else119; { _t349 = &sb; - _t350 = (char)8; + _t350 = (char)92; StringBuilder_AppendChar(_t349, _t350); } - goto endif121; - else120:; - _t351 = (esc == 102); - if (!_t351) goto else122; + goto endif120; + else119:; { - _t352 = &sb; - _t353 = (char)12; - StringBuilder_AppendChar(_t352, _t353); + _t351 = &sb; + _t352 = (char)92; + StringBuilder_AppendChar(_t351, _t352); + _t353 = &sb; + _t354 = (char)esc; + StringBuilder_AppendChar(_t353, _t354); } - goto endif123; - else122:; - _t354 = (esc == 34); - if (!_t354) goto else124; + endif120:; + endif118:; + endif116:; + endif114:; + endif112:; + endif110:; + endif108:; + JsonParser_Advance(p); + } + goto endif104; + else103:; { _t355 = &sb; - _t356 = (char)34; + _t356 = (char)c; StringBuilder_AppendChar(_t355, _t356); - } - goto endif125; - else124:; - _t357 = (esc == 92); - if (!_t357) goto else126; - { - _t358 = &sb; - _t359 = (char)92; - StringBuilder_AppendChar(_t358, _t359); - } - goto endif127; - else126:; - { - _t360 = &sb; - _t361 = (char)92; - StringBuilder_AppendChar(_t360, _t361); - _t362 = &sb; - _t363 = (char)esc; - StringBuilder_AppendChar(_t362, _t363); - } - endif127:; - endif125:; - endif123:; - endif121:; - endif119:; - endif117:; - endif115:; JsonParser_Advance(p); } - goto endif111; - else110:; - { - _t364 = &sb; - _t365 = (char)c; - StringBuilder_AppendChar(_t364, _t365); - JsonParser_Advance(p); + endif104:; } - endif111:; - } - goto while103; - wend105:; - int _t366; - _t366 = JsonParser_Peek(p); - _t367 = (_t366 != 34); - if (!_t367) goto endif129; + goto while97; + wend98:; + int _t357; + _t357 = JsonParser_Peek(p); + _t358 = (_t357 != 34); + if (!_t358) goto endif122; { p->error = "Unterminated string"; - _t368 = &sb; - StringBuilder_Free(_t368); + _t359 = &sb; + StringBuilder_Free(_t359); return ""; } - endif129:; + endif122:; JsonParser_Advance(p); const char* result; - _t369 = &sb; - const char* _t370; - _t370 = StringBuilder_Build(_t369); - result = _t370; - _t371 = &sb; - StringBuilder_Free(_t371); + _t360 = &sb; + const char* _t361; + _t361 = StringBuilder_Build(_t360); + result = _t361; + _t362 = &sb; + StringBuilder_Free(_t362); return result; } JsonValue JsonParser_ParseNumber(JsonParser* p) { - int _t374; - int _t376; - int _t377; - int _t380; - int _t382; - int _t383; - int _t387; - unsigned int start; - unsigned int _t372; - _t372 = p->pos; - start = _t372; - int c0; + int _t365; + int _t367; + int _t368; + int _t371; int _t373; - _t373 = JsonParser_Peek(p); - c0 = _t373; - _t374 = (c0 == 45); - if (!_t374) goto endif131; + int _t374; + int _t378; + unsigned int start; + unsigned int _t363; + _t363 = p->pos; + start = _t363; + int c0; + int _t364; + _t364 = JsonParser_Peek(p); + c0 = _t364; + _t365 = (c0 == 45); + if (!_t365) goto endif124; { JsonParser_Advance(p); } - endif131:; - while132:; + endif124:; + while125:; + if (!1) goto wend126; + { + int c; + int _t366; + _t366 = JsonParser_Peek(p); + c = _t366; + bool __and_tmp_5; + _t367 = (c >= 48); + if (!_t367) goto else127; + _t368 = (c <= 57); + *(bool*)&__and_tmp_5 = _t368; + goto endif128; + else127:; + *(bool*)&__and_tmp_5 = 0; + endif128:; + bool _t369; + _t369 = *(bool*)&__and_tmp_5; + if (!_t369) goto else129; + { + JsonParser_Advance(p); + } + goto endif130; + else129:; + { + goto wend126; + } + endif130:; + } + goto while125; + wend126:; + int _t370; + _t370 = JsonParser_Peek(p); + _t371 = (_t370 == 46); + if (!_t371) goto endif132; + { + JsonParser_Advance(p); + while133:; if (!1) goto wend134; { int c; - int _t375; - _t375 = JsonParser_Peek(p); - c = _t375; - bool __and_tmp_5; - _t376 = (c >= 48); - if (!_t376) goto else135; - _t377 = (c <= 57); - *(bool*)&__and_tmp_5 = _t377; + int _t372; + _t372 = JsonParser_Peek(p); + c = _t372; + bool __and_tmp_6; + _t373 = (c >= 48); + if (!_t373) goto else135; + _t374 = (c <= 57); + *(bool*)&__and_tmp_6 = _t374; goto endif136; else135:; - *(bool*)&__and_tmp_5 = 0; + *(bool*)&__and_tmp_6 = 0; endif136:; - bool _t378; - _t378 = *(bool*)&__and_tmp_5; - if (!_t378) goto else137; + bool _t375; + _t375 = *(bool*)&__and_tmp_6; + if (!_t375) goto else137; { JsonParser_Advance(p); } @@ -2261,1098 +2297,1061 @@ JsonValue JsonParser_ParseNumber(JsonParser* p) { } endif138:; } - goto while132; + goto while133; wend134:; - int _t379; - _t379 = JsonParser_Peek(p); - _t380 = (_t379 == 46); - if (!_t380) goto endif140; - { - JsonParser_Advance(p); - while141:; - if (!1) goto wend143; - { - int c; - int _t381; - _t381 = JsonParser_Peek(p); - c = _t381; - bool __and_tmp_6; - _t382 = (c >= 48); - if (!_t382) goto else144; - _t383 = (c <= 57); - *(bool*)&__and_tmp_6 = _t383; - goto endif145; - else144:; - *(bool*)&__and_tmp_6 = 0; - endif145:; - bool _t384; - _t384 = *(bool*)&__and_tmp_6; - if (!_t384) goto else146; - { - JsonParser_Advance(p); } - goto endif147; - else146:; - { - goto wend143; - } - endif147:; - } - goto while141; - wend143:; - } - endif140:; + endif132:; const char* numStr; - const char* _t385; - _t385 = p->src; - unsigned int _t386; - _t386 = p->pos; - _t387 = _t386 - start; - const char* _t388; - _t388 = String_Slice(_t385, start, _t387); - numStr = _t388; + const char* _t376; + _t376 = p->src; + unsigned int _t377; + _t377 = p->pos; + _t378 = _t377 - start; + const char* _t379; + _t379 = String_Slice(_t376, start, _t378); + numStr = _t379; double n; - double _t389; - _t389 = String_ToFloat(numStr); - n = _t389; - JsonValue _t390; - _t390 = Json_Number(n); - return _t390; + double _t380; + _t380 = String_ToFloat(numStr); + n = _t380; + JsonValue _t381; + _t381 = Json_Number(n); + return _t381; } JsonValue JsonParser_ParseArray(JsonParser* p) { - int _t393; - int _t396; - void* _t398; - int _t400; - int _t401; + int _t384; + int _t387; + void* _t389; + int _t391; + int _t392; JsonParser_Advance(p); JsonValue arr; - JsonValue _t391; - _t391 = Json_Array(); - arr = _t391; + JsonValue _t382; + _t382 = Json_Array(); + arr = _t382; JsonParser_SkipWhitespace(p); - int _t392; - _t392 = JsonParser_Peek(p); - _t393 = (_t392 == 93); - if (!_t393) goto endif149; + int _t383; + _t383 = JsonParser_Peek(p); + _t384 = (_t383 == 93); + if (!_t384) goto endif140; { JsonParser_Advance(p); return arr; } - endif149:; - while150:; - if (!1) goto wend152; + endif140:; + while141:; + if (!1) goto wend142; { JsonParser_SkipWhitespace(p); JsonValue val; - JsonValue _t394; - _t394 = JsonParser_ParseValue(p); - val = _t394; - const char* _t395; - _t395 = p->error; - _t396 = (_t395 != ""); - if (!_t396) goto endif154; + JsonValue _t385; + _t385 = JsonParser_ParseValue(p); + val = _t385; + const char* _t386; + _t386 = p->error; + _t387 = (_t386 != ""); + if (!_t387) goto endif144; { - JsonValue _t397; - _t397 = Json_Null(); - return _t397; + JsonValue _t388; + _t388 = Json_Null(); + return _t388; } - endif154:; - _t398 = &arr; - Json_ArrayPush(_t398, val); + endif144:; + _t389 = &arr; + Json_ArrayPush(_t389, val); JsonParser_SkipWhitespace(p); int c; - int _t399; - _t399 = JsonParser_Peek(p); - c = _t399; - _t400 = (c == 93); - if (!_t400) goto endif156; + int _t390; + _t390 = JsonParser_Peek(p); + c = _t390; + _t391 = (c == 93); + if (!_t391) goto endif146; { JsonParser_Advance(p); return arr; } - endif156:; - _t401 = (c == 44); - if (!_t401) goto else157; + endif146:; + _t392 = (c == 44); + if (!_t392) goto else147; { JsonParser_Advance(p); } - goto endif158; - else157:; + goto endif148; + else147:; { p->error = "Expected ',' or ']' in array"; - JsonValue _t402; - _t402 = Json_Null(); - return _t402; + JsonValue _t393; + _t393 = Json_Null(); + return _t393; } - endif158:; + endif148:; } - goto while150; - wend152:; + goto while141; + wend142:; } JsonValue JsonParser_ParseObject(JsonParser* p) { - int _t405; - int _t408; + int _t396; + int _t399; + int _t402; + int _t406; + void* _t408; + int _t410; int _t411; - int _t415; - void* _t417; - int _t419; - int _t420; JsonParser_Advance(p); JsonValue obj; - JsonValue _t403; - _t403 = Json_Object(); - obj = _t403; + JsonValue _t394; + _t394 = Json_Object(); + obj = _t394; JsonParser_SkipWhitespace(p); - int _t404; - _t404 = JsonParser_Peek(p); - _t405 = (_t404 == 125); - if (!_t405) goto endif160; + int _t395; + _t395 = JsonParser_Peek(p); + _t396 = (_t395 == 125); + if (!_t396) goto endif150; + { + JsonParser_Advance(p); + return obj; + } + endif150:; + while151:; + if (!1) goto wend152; + { + JsonParser_SkipWhitespace(p); + const char* key; + const char* _t397; + _t397 = JsonParser_ParseString(p); + key = _t397; + const char* _t398; + _t398 = p->error; + _t399 = (_t398 != ""); + if (!_t399) goto endif154; + { + JsonValue _t400; + _t400 = Json_Null(); + return _t400; + } + endif154:; + JsonParser_SkipWhitespace(p); + int _t401; + _t401 = JsonParser_Peek(p); + _t402 = (_t401 != 58); + if (!_t402) goto endif156; + { + p->error = "Expected ':' after object key"; + JsonValue _t403; + _t403 = Json_Null(); + return _t403; + } + endif156:; + JsonParser_Advance(p); + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t404; + _t404 = JsonParser_ParseValue(p); + val = _t404; + const char* _t405; + _t405 = p->error; + _t406 = (_t405 != ""); + if (!_t406) goto endif158; + { + JsonValue _t407; + _t407 = Json_Null(); + return _t407; + } + endif158:; + _t408 = &obj; + Json_ObjectSet(_t408, key, val); + JsonParser_SkipWhitespace(p); + int c; + int _t409; + _t409 = JsonParser_Peek(p); + c = _t409; + _t410 = (c == 125); + if (!_t410) goto endif160; { JsonParser_Advance(p); return obj; } endif160:; - while161:; - if (!1) goto wend163; + _t411 = (c == 44); + if (!_t411) goto else161; { - JsonParser_SkipWhitespace(p); - const char* key; - const char* _t406; - _t406 = JsonParser_ParseString(p); - key = _t406; - const char* _t407; - _t407 = p->error; - _t408 = (_t407 != ""); - if (!_t408) goto endif165; - { - JsonValue _t409; - _t409 = Json_Null(); - return _t409; + JsonParser_Advance(p); } - endif165:; - JsonParser_SkipWhitespace(p); - int _t410; - _t410 = JsonParser_Peek(p); - _t411 = (_t410 != 58); - if (!_t411) goto endif167; + goto endif162; + else161:; { - p->error = "Expected ':' after object key"; + p->error = "Expected ',' or '}' in object"; JsonValue _t412; _t412 = Json_Null(); return _t412; } - endif167:; - JsonParser_Advance(p); - JsonParser_SkipWhitespace(p); - JsonValue val; - JsonValue _t413; - _t413 = JsonParser_ParseValue(p); - val = _t413; - const char* _t414; - _t414 = p->error; - _t415 = (_t414 != ""); - if (!_t415) goto endif169; - { - JsonValue _t416; - _t416 = Json_Null(); - return _t416; + endif162:; } - endif169:; - _t417 = &obj; - Json_ObjectSet(_t417, key, val); - JsonParser_SkipWhitespace(p); - int c; - int _t418; - _t418 = JsonParser_Peek(p); - c = _t418; - _t419 = (c == 125); - if (!_t419) goto endif171; - { - JsonParser_Advance(p); - return obj; - } - endif171:; - _t420 = (c == 44); - if (!_t420) goto else172; - { - JsonParser_Advance(p); - } - goto endif173; - else172:; - { - p->error = "Expected ',' or '}' in object"; - JsonValue _t421; - _t421 = Json_Null(); - return _t421; - } - endif173:; - } - goto while161; - wend163:; + goto while151; + wend152:; } JsonValue JsonParser_ParseValue(JsonParser* p) { + int _t414; + int _t416; + int _t419; + int _t421; int _t423; - int _t425; - int _t428; - int _t430; - int _t432; + int _t427; + int _t431; + int _t435; int _t436; - int _t440; - int _t444; - int _t445; - int _t447; + int _t438; JsonParser_SkipWhitespace(p); int c; - int _t422; - _t422 = JsonParser_Peek(p); - c = _t422; - _t423 = (c == 0); - if (!_t423) goto endif175; + int _t413; + _t413 = JsonParser_Peek(p); + c = _t413; + _t414 = (c == 0); + if (!_t414) goto endif164; { p->error = "Unexpected end of input"; - JsonValue _t424; - _t424 = Json_Null(); - return _t424; + JsonValue _t415; + _t415 = Json_Null(); + return _t415; } - endif175:; - _t425 = (c == 34); - if (!_t425) goto endif177; + endif164:; + _t416 = (c == 34); + if (!_t416) goto endif166; { - const char* _t426; - _t426 = JsonParser_ParseString(p); - JsonValue _t427; - _t427 = Json_String(_t426); - return _t427; + const char* _t417; + _t417 = JsonParser_ParseString(p); + JsonValue _t418; + _t418 = Json_String(_t417); + return _t418; } - endif177:; - _t428 = (c == 123); - if (!_t428) goto endif179; + endif166:; + _t419 = (c == 123); + if (!_t419) goto endif168; + { + JsonValue _t420; + _t420 = JsonParser_ParseObject(p); + return _t420; + } + endif168:; + _t421 = (c == 91); + if (!_t421) goto endif170; + { + JsonValue _t422; + _t422 = JsonParser_ParseArray(p); + return _t422; + } + endif170:; + _t423 = (c == 116); + if (!_t423) goto endif172; + { + bool _t424; + _t424 = JsonParser_Match(p, "true"); + if (!_t424) goto endif174; + { + JsonValue _t425; + _t425 = Json_Bool(1); + return _t425; + } + endif174:; + p->error = "Expected 'true'"; + JsonValue _t426; + _t426 = Json_Null(); + return _t426; + } + endif172:; + _t427 = (c == 102); + if (!_t427) goto endif176; + { + bool _t428; + _t428 = JsonParser_Match(p, "false"); + if (!_t428) goto endif178; { JsonValue _t429; - _t429 = JsonParser_ParseObject(p); + _t429 = Json_Bool(0); return _t429; } - endif179:; - _t430 = (c == 91); - if (!_t430) goto endif181; - { - JsonValue _t431; - _t431 = JsonParser_ParseArray(p); - return _t431; + endif178:; + p->error = "Expected 'false'"; + JsonValue _t430; + _t430 = Json_Null(); + return _t430; } - endif181:; - _t432 = (c == 116); - if (!_t432) goto endif183; + endif176:; + _t431 = (c == 110); + if (!_t431) goto endif180; { - bool _t433; - _t433 = JsonParser_Match(p, "true"); - if (!_t433) goto endif185; + bool _t432; + _t432 = JsonParser_Match(p, "null"); + if (!_t432) goto endif182; { + JsonValue _t433; + _t433 = Json_Null(); + return _t433; + } + endif182:; + p->error = "Expected 'null'"; JsonValue _t434; - _t434 = Json_Bool(1); + _t434 = Json_Null(); return _t434; } - endif185:; - p->error = "Expected 'true'"; - JsonValue _t435; - _t435 = Json_Null(); - return _t435; - } - endif183:; - _t436 = (c == 102); - if (!_t436) goto endif187; - { - bool _t437; - _t437 = JsonParser_Match(p, "false"); - if (!_t437) goto endif189; - { - JsonValue _t438; - _t438 = Json_Bool(0); - return _t438; - } - endif189:; - p->error = "Expected 'false'"; - JsonValue _t439; - _t439 = Json_Null(); - return _t439; - } - endif187:; - _t440 = (c == 110); - if (!_t440) goto endif191; - { - bool _t441; - _t441 = JsonParser_Match(p, "null"); - if (!_t441) goto endif193; - { - JsonValue _t442; - _t442 = Json_Null(); - return _t442; - } - endif193:; - p->error = "Expected 'null'"; - JsonValue _t443; - _t443 = Json_Null(); - return _t443; - } - endif191:; + endif180:; bool __or_tmp_7; bool __and_tmp_8; - _t444 = (c >= 48); - if (!_t444) goto else194; - _t445 = (c <= 57); - *(bool*)&__and_tmp_8 = _t445; - goto endif195; - else194:; + _t435 = (c >= 48); + if (!_t435) goto else183; + _t436 = (c <= 57); + *(bool*)&__and_tmp_8 = _t436; + goto endif184; + else183:; *(bool*)&__and_tmp_8 = 0; - endif195:; - bool _t446; - _t446 = *(bool*)&__and_tmp_8; - if (!_t446) goto else196; + endif184:; + bool _t437; + _t437 = *(bool*)&__and_tmp_8; + if (!_t437) goto else185; *(bool*)&__or_tmp_7 = 1; - goto endif197; - else196:; - _t447 = (c == 45); - *(bool*)&__or_tmp_7 = _t447; - endif197:; - bool _t448; - _t448 = *(bool*)&__or_tmp_7; - if (!_t448) goto endif199; + goto endif186; + else185:; + _t438 = (c == 45); + *(bool*)&__or_tmp_7 = _t438; + endif186:; + bool _t439; + _t439 = *(bool*)&__or_tmp_7; + if (!_t439) goto endif188; { - JsonValue _t449; - _t449 = JsonParser_ParseNumber(p); - return _t449; + JsonValue _t440; + _t440 = JsonParser_ParseNumber(p); + return _t440; } - endif199:; + endif188:; p->error = "Unexpected character"; - JsonValue _t450; - _t450 = Json_Null(); - return _t450; + JsonValue _t441; + _t441 = Json_Null(); + return _t441; } JsonValue Json_Parse(const char* s) { - JsonParser _t452; - void* _t453; - void* _t455; - int _t457; - int _t460; + JsonParser _t443; + void* _t444; + void* _t446; + int _t448; + int _t451; JsonParser p; - unsigned int _t451; - _t451 = String_Len(s); - _t452 = (JsonParser){.src = s, .pos = 0, .len = _t451, .error = ""}; - p = _t452; + unsigned int _t442; + _t442 = String_Len(s); + _t443 = (JsonParser){.src = s, .pos = 0, .len = _t442, .error = ""}; + p = _t443; JsonValue result; - _t453 = &p; - JsonValue _t454; - _t454 = JsonParser_ParseValue(_t453); - result = _t454; - _t455 = &p; - JsonParser_SkipWhitespace(_t455); + _t444 = &p; + JsonValue _t445; + _t445 = JsonParser_ParseValue(_t444); + result = _t445; + _t446 = &p; + JsonParser_SkipWhitespace(_t446); bool __and_tmp_9; - const char* _t456; - _t456 = p.error; - _t457 = (_t456 == ""); - if (!_t457) goto else200; - unsigned int _t458; - _t458 = p.pos; - unsigned int _t459; - _t459 = p.len; - _t460 = (_t458 != _t459); - *(bool*)&__and_tmp_9 = _t460; - goto endif201; - else200:; + const char* _t447; + _t447 = p.error; + _t448 = (_t447 == ""); + if (!_t448) goto else189; + unsigned int _t449; + _t449 = p.pos; + unsigned int _t450; + _t450 = p.len; + _t451 = (_t449 != _t450); + *(bool*)&__and_tmp_9 = _t451; + goto endif190; + else189:; *(bool*)&__and_tmp_9 = 0; - endif201:; - bool _t461; - _t461 = *(bool*)&__and_tmp_9; - if (!_t461) goto endif203; + endif190:; + bool _t452; + _t452 = *(bool*)&__and_tmp_9; + if (!_t452) goto endif192; { p.error = "Trailing data after JSON value"; - JsonValue _t462; - _t462 = Json_Null(); - return _t462; + JsonValue _t453; + _t453 = Json_Null(); + return _t453; } - endif203:; + endif192:; return result; } void Json_StringifyImpl(StringBuilder* sb, JsonValue v) { - int _t464; - int _t466; - int _t469; + int _t455; + int _t457; + int _t460; + int _t463; + char _t464; + char _t466; + int _t468; + char _t469; + int _t471; int _t472; char _t473; - char _t475; - int _t477; - char _t478; - int _t480; - int _t481; - char _t482; - int _t485; - char _t486; - int _t488; + int _t476; + char _t477; + int _t479; + char _t480; + int _t482; + int _t483; + char _t484; + char _t485; + char _t488; char _t489; - int _t491; int _t492; char _t493; - char _t494; - char _t497; - char _t498; - int _t501; - char _t502; - int _t463; - _t463 = v.tag; - _t464 = (_t463 == JsonTagNull); - if (!_t464) goto endif205; + int _t454; + _t454 = v.tag; + _t455 = (_t454 == JsonTagNull); + if (!_t455) goto endif194; { StringBuilder_Append(sb, "null"); return; } - endif205:; - int _t465; - _t465 = v.tag; - _t466 = (_t465 == JsonTagBool); - if (!_t466) goto endif207; + endif194:; + int _t456; + _t456 = v.tag; + _t457 = (_t456 == JsonTagBool); + if (!_t457) goto endif196; { - bool _t467; - _t467 = v.boolVal; - if (!_t467) goto else208; + bool _t458; + _t458 = v.boolVal; + if (!_t458) goto else197; { StringBuilder_Append(sb, "true"); } - goto endif209; - else208:; + goto endif198; + else197:; { StringBuilder_Append(sb, "false"); } - endif209:; + endif198:; return; } - endif207:; - int _t468; - _t468 = v.tag; - _t469 = (_t468 == JsonTagNumber); - if (!_t469) goto endif211; + endif196:; + int _t459; + _t459 = v.tag; + _t460 = (_t459 == JsonTagNumber); + if (!_t460) goto endif200; { - double _t470; - _t470 = v.numVal; - StringBuilder_AppendFloat(sb, _t470); + double _t461; + _t461 = v.numVal; + StringBuilder_AppendFloat(sb, _t461); return; } - endif211:; - int _t471; - _t471 = v.tag; - _t472 = (_t471 == JsonTagString); - if (!_t472) goto endif213; + endif200:; + int _t462; + _t462 = v.tag; + _t463 = (_t462 == JsonTagString); + if (!_t463) goto endif202; { - _t473 = (char)34; + _t464 = (char)34; + StringBuilder_AppendChar(sb, _t464); + const char* _t465; + _t465 = v.strVal; + StringBuilder_Append(sb, _t465); + _t466 = (char)34; + StringBuilder_AppendChar(sb, _t466); + return; + } + endif202:; + int _t467; + _t467 = v.tag; + _t468 = (_t467 == JsonTagArray); + if (!_t468) goto endif204; + { + _t469 = (char)91; + StringBuilder_AppendChar(sb, _t469); + unsigned int i; + i = 0; + while205:; + unsigned int _t470; + _t470 = v.arrLen; + _t471 = (i < _t470); + if (!_t471) goto wend206; + { + _t472 = (i > 0); + if (!_t472) goto endif208; + { + _t473 = (char)44; StringBuilder_AppendChar(sb, _t473); - const char* _t474; - _t474 = v.strVal; - StringBuilder_Append(sb, _t474); - _t475 = (char)34; - StringBuilder_AppendChar(sb, _t475); + } + endif208:; + JsonValue* _t474; + _t474 = v.arrData; + JsonValue _t475; + _t475 = _t474[i]; + Json_StringifyImpl(sb, _t475); + _t476 = i + 1; + i = _t476; + } + goto while205; + wend206:; + _t477 = (char)93; + StringBuilder_AppendChar(sb, _t477); return; } - endif213:; - int _t476; - _t476 = v.tag; - _t477 = (_t476 == JsonTagArray); - if (!_t477) goto endif215; + endif204:; + int _t478; + _t478 = v.tag; + _t479 = (_t478 == JsonTagObject); + if (!_t479) goto endif210; { - _t478 = (char)91; - StringBuilder_AppendChar(sb, _t478); + _t480 = (char)123; + StringBuilder_AppendChar(sb, _t480); unsigned int i; i = 0; - while216:; - unsigned int _t479; - _t479 = v.arrLen; - _t480 = (i < _t479); - if (!_t480) goto wend218; + while211:; + unsigned int _t481; + _t481 = v.objLen; + _t482 = (i < _t481); + if (!_t482) goto wend212; { - _t481 = (i > 0); - if (!_t481) goto endif220; + _t483 = (i > 0); + if (!_t483) goto endif214; { - _t482 = (char)44; - StringBuilder_AppendChar(sb, _t482); + _t484 = (char)44; + StringBuilder_AppendChar(sb, _t484); } - endif220:; - JsonValue* _t483; - _t483 = v.arrData; - JsonValue _t484; - _t484 = _t483[i]; - Json_StringifyImpl(sb, _t484); - _t485 = i + 1; - i = _t485; - } - goto while216; - wend218:; - _t486 = (char)93; - StringBuilder_AppendChar(sb, _t486); - return; - } - endif215:; - int _t487; - _t487 = v.tag; - _t488 = (_t487 == JsonTagObject); - if (!_t488) goto endif222; - { - _t489 = (char)123; + endif214:; + _t485 = (char)34; + StringBuilder_AppendChar(sb, _t485); + const char** _t486; + _t486 = v.objKeys; + const char* _t487; + _t487 = _t486[i]; + StringBuilder_Append(sb, _t487); + _t488 = (char)34; + StringBuilder_AppendChar(sb, _t488); + _t489 = (char)58; StringBuilder_AppendChar(sb, _t489); - unsigned int i; - i = 0; - while223:; - unsigned int _t490; - _t490 = v.objLen; - _t491 = (i < _t490); - if (!_t491) goto wend225; - { - _t492 = (i > 0); - if (!_t492) goto endif227; - { - _t493 = (char)44; + JsonValue* _t490; + _t490 = v.objValues; + JsonValue _t491; + _t491 = _t490[i]; + Json_StringifyImpl(sb, _t491); + _t492 = i + 1; + i = _t492; + } + goto while211; + wend212:; + _t493 = (char)125; StringBuilder_AppendChar(sb, _t493); - } - endif227:; - _t494 = (char)34; - StringBuilder_AppendChar(sb, _t494); - const char** _t495; - _t495 = v.objKeys; - const char* _t496; - _t496 = _t495[i]; - StringBuilder_Append(sb, _t496); - _t497 = (char)34; - StringBuilder_AppendChar(sb, _t497); - _t498 = (char)58; - StringBuilder_AppendChar(sb, _t498); - JsonValue* _t499; - _t499 = v.objValues; - JsonValue _t500; - _t500 = _t499[i]; - Json_StringifyImpl(sb, _t500); - _t501 = i + 1; - i = _t501; - } - goto while223; - wend225:; - _t502 = (char)125; - StringBuilder_AppendChar(sb, _t502); return; } - endif222:; + endif210:; } const char* Json_Stringify(JsonValue v) { - void* _t504; - void* _t505; + void* _t495; + void* _t496; StringBuilder sb; - StringBuilder _t503; - _t503 = StringBuilder_New(); - sb = _t503; - _t504 = &sb; - Json_StringifyImpl(_t504, v); - _t505 = &sb; - const char* _t506; - _t506 = StringBuilder_Build(_t505); - return _t506; + StringBuilder _t494; + _t494 = StringBuilder_New(); + sb = _t494; + _t495 = &sb; + Json_StringifyImpl(_t495, v); + _t496 = &sb; + const char* _t497; + _t497 = StringBuilder_Build(_t496); + return _t497; } unsigned int String_Len(const char* s) { - unsigned int _t507; - _t507 = bux_strlen(s); - return _t507; + unsigned int _t498; + _t498 = bux_strlen(s); + return _t498; } bool String_IsNull(const char* s) { - int _t509; - int _t508; - _t508 = bux_str_is_null(s); - _t509 = (_t508 != 0); - return _t509; + int _t500; + int _t499; + _t499 = bux_str_is_null(s); + _t500 = (_t499 != 0); + return _t500; } bool String_Eq(const char* a, const char* b) { - int _t511; - int _t510; - _t510 = bux_strcmp(a, b); - _t511 = (_t510 == 0); - return _t511; + int _t502; + int _t501; + _t501 = bux_strcmp(a, b); + _t502 = (_t501 == 0); + return _t502; } const char* String_Concat(const char* a, const char* b) { - int _t514; - int _t515; - char* _t517; + int _t505; + int _t506; + char* _t508; unsigned int len_a; - unsigned int _t512; - _t512 = bux_strlen(a); - len_a = _t512; + unsigned int _t503; + _t503 = bux_strlen(a); + len_a = _t503; unsigned int len_b; - unsigned int _t513; - _t513 = bux_strlen(b); - len_b = _t513; + unsigned int _t504; + _t504 = bux_strlen(b); + len_b = _t504; unsigned int total; - _t514 = len_a + len_b; - _t515 = _t514 + 1; - total = _t515; + _t505 = len_a + len_b; + _t506 = _t505 + 1; + total = _t506; char* buf; - void* _t516; - _t516 = bux_alloc(total); - _t517 = (char*)_t516; - buf = _t517; + void* _t507; + _t507 = bux_alloc(total); + _t508 = (char*)_t507; + buf = _t508; bux_strcpy(buf, a); bux_strcat(buf, b); return buf; } const char* String_Copy(const char* s) { - int _t519; - char* _t521; + int _t510; + char* _t512; unsigned int len; - unsigned int _t518; - _t518 = bux_strlen(s); - len = _t518; + unsigned int _t509; + _t509 = bux_strlen(s); + len = _t509; char* buf; - _t519 = len + 1; - void* _t520; - _t520 = bux_alloc(_t519); - _t521 = (char*)_t520; - buf = _t521; + _t510 = len + 1; + void* _t511; + _t511 = bux_alloc(_t510); + _t512 = (char*)_t511; + buf = _t512; bux_strcpy(buf, s); return buf; } bool String_StartsWith(const char* s, const char* prefix) { - int _t524; - int _t526; + int _t515; + int _t517; unsigned int s_len; - unsigned int _t522; - _t522 = bux_strlen(s); - s_len = _t522; + unsigned int _t513; + _t513 = bux_strlen(s); + s_len = _t513; unsigned int p_len; - unsigned int _t523; - _t523 = bux_strlen(prefix); - p_len = _t523; - _t524 = (p_len > s_len); - if (!_t524) goto endif229; + unsigned int _t514; + _t514 = bux_strlen(prefix); + p_len = _t514; + _t515 = (p_len > s_len); + if (!_t515) goto endif216; { return 0; } - endif229:; + endif216:; int r; - int _t525; - _t525 = bux_strncmp(s, prefix, p_len); - r = _t525; - _t526 = (r == 0); - return _t526; + int _t516; + _t516 = bux_strncmp(s, prefix, p_len); + r = _t516; + _t517 = (r == 0); + return _t517; } bool String_EndsWith(const char* s, const char* suffix) { - int _t529; - int _t530; - int _t533; + int _t520; + int _t521; + int _t524; unsigned int s_len; - unsigned int _t527; - _t527 = bux_strlen(s); - s_len = _t527; + unsigned int _t518; + _t518 = bux_strlen(s); + s_len = _t518; unsigned int suf_len; - unsigned int _t528; - _t528 = bux_strlen(suffix); - suf_len = _t528; - _t529 = (suf_len > s_len); - if (!_t529) goto endif231; + unsigned int _t519; + _t519 = bux_strlen(suffix); + suf_len = _t519; + _t520 = (suf_len > s_len); + if (!_t520) goto endif218; { return 0; } - endif231:; + endif218:; unsigned int start; - _t530 = s_len - suf_len; - start = _t530; + _t521 = s_len - suf_len; + start = _t521; const char* tail; - const char* _t531; - _t531 = bux_str_slice(s, start, suf_len); - tail = _t531; + const char* _t522; + _t522 = bux_str_slice(s, start, suf_len); + tail = _t522; bool eq; - int _t532; - _t532 = bux_strcmp(tail, suffix); - _t533 = (_t532 == 0); - eq = _t533; + int _t523; + _t523 = bux_strcmp(tail, suffix); + _t524 = (_t523 == 0); + eq = _t524; return eq; } bool String_Contains(const char* s, const char* substr) { - int _t535; + int _t526; int r; - int _t534; - _t534 = bux_str_contains(s, substr); - r = _t534; - _t535 = (r != 0); - return _t535; + int _t525; + _t525 = bux_str_contains(s, substr); + r = _t525; + _t526 = (r != 0); + return _t526; } const char* String_Slice(const char* s, unsigned int start, unsigned int len) { - const char* _t536; - _t536 = bux_str_slice(s, start, len); - return _t536; + const char* _t527; + _t527 = bux_str_slice(s, start, len); + return _t527; } const char* String_Trim(const char* s) { - const char* _t537; - _t537 = bux_str_trim(s); - return _t537; + const char* _t528; + _t528 = bux_str_trim(s); + return _t528; } const char* String_TrimLeft(const char* s) { - const char* _t538; - _t538 = bux_str_trim_left(s); - return _t538; + const char* _t529; + _t529 = bux_str_trim_left(s); + return _t529; } const char* String_TrimRight(const char* s) { - const char* _t539; - _t539 = bux_str_trim_right(s); - return _t539; + const char* _t530; + _t530 = bux_str_trim_right(s); + return _t530; } const char* String_FromInt(int64_t n) { - const char* _t540; - _t540 = bux_int_to_str(n); - return _t540; + const char* _t531; + _t531 = bux_int_to_str(n); + return _t531; } int64_t String_ToInt(const char* s) { - int64_t _t541; - _t541 = bux_str_to_int(s); - return _t541; + int64_t _t532; + _t532 = bux_str_to_int(s); + return _t532; } StringBuilder StringBuilder_New(void) { - StringBuilder _t543; - void* _t542; - _t542 = bux_sb_new(64); - _t543 = (StringBuilder){.handle = _t542}; - return _t543; + StringBuilder _t534; + void* _t533; + _t533 = bux_sb_new(64); + _t534 = (StringBuilder){.handle = _t533}; + return _t534; } StringBuilder StringBuilder_NewCap(unsigned int cap) { - StringBuilder _t545; - void* _t544; - _t544 = bux_sb_new(cap); - _t545 = (StringBuilder){.handle = _t544}; - return _t545; + StringBuilder _t536; + void* _t535; + _t535 = bux_sb_new(cap); + _t536 = (StringBuilder){.handle = _t535}; + return _t536; } void StringBuilder_Append(StringBuilder* sb, const char* s) { - void* _t546; - _t546 = sb->handle; - bux_sb_append(_t546, s); + void* _t537; + _t537 = sb->handle; + bux_sb_append(_t537, s); } void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) { - void* _t547; - _t547 = sb->handle; - bux_sb_append_int(_t547, n); + void* _t538; + _t538 = sb->handle; + bux_sb_append_int(_t538, n); } void StringBuilder_AppendFloat(StringBuilder* sb, double f) { - void* _t548; - _t548 = sb->handle; - bux_sb_append_float(_t548, f); + void* _t539; + _t539 = sb->handle; + bux_sb_append_float(_t539, f); } void StringBuilder_AppendChar(StringBuilder* sb, char c) { - void* _t549; - _t549 = sb->handle; - bux_sb_append_char(_t549, c); + void* _t540; + _t540 = sb->handle; + bux_sb_append_char(_t540, c); } const char* StringBuilder_Build(StringBuilder* sb) { - void* _t550; - _t550 = sb->handle; - const char* _t551; - _t551 = bux_sb_build(_t550); - return _t551; + void* _t541; + _t541 = sb->handle; + const char* _t542; + _t542 = bux_sb_build(_t541); + return _t542; } void StringBuilder_Free(StringBuilder* sb) { - void* _t552; - _t552 = sb->handle; - bux_sb_free(_t552); + void* _t543; + _t543 = sb->handle; + bux_sb_free(_t543); } unsigned int String_SplitCount(const char* s, const char* delim) { - unsigned int _t553; - _t553 = bux_str_split_count(s, delim); - return _t553; + unsigned int _t544; + _t544 = bux_str_split_count(s, delim); + return _t544; } const char* String_SplitPart(const char* s, const char* delim, unsigned int index) { - const char* _t554; - _t554 = bux_str_split_part(s, delim, index); - return _t554; + const char* _t545; + _t545 = bux_str_split_part(s, delim, index); + return _t545; } const char* String_Join2(const char* a, const char* b, const char* sep) { - const char* _t555; - _t555 = bux_str_join2(a, b, sep); - return _t555; + const char* _t546; + _t546 = bux_str_join2(a, b, sep); + return _t546; } const char* String_Chars(const char* s, unsigned int index) { - const char* _t556; - _t556 = bux_str_slice(s, index, 1); - return _t556; + const char* _t547; + _t547 = bux_str_slice(s, index, 1); + return _t547; } const char* String_Find(const char* haystack, const char* needle) { - const char* _t557; - _t557 = bux_strstr(haystack, needle); - return _t557; + const char* _t548; + _t548 = bux_strstr(haystack, needle); + return _t548; } unsigned int String_Offset(const char* pos, const char* base) { - unsigned int _t558; - _t558 = bux_str_offset(pos, base); - return _t558; + unsigned int _t549; + _t549 = bux_str_offset(pos, base); + return _t549; } const char* String_Replace(const char* s, const char* old, const char* new) { - int _t564; - int _t566; - int _t567; + int _t555; + int _t557; + int _t558; const char* pos; - const char* _t559; - _t559 = bux_strstr(s, old); - pos = _t559; - bool _t560; - _t560 = String_IsNull(pos); - if (!_t560) goto endif233; + const char* _t550; + _t550 = bux_strstr(s, old); + pos = _t550; + bool _t551; + _t551 = String_IsNull(pos); + if (!_t551) goto endif220; { return s; } - endif233:; + endif220:; unsigned int oldLen; - unsigned int _t561; - _t561 = bux_strlen(old); - oldLen = _t561; + unsigned int _t552; + _t552 = bux_strlen(old); + oldLen = _t552; unsigned int prefixLen; - unsigned int _t562; - _t562 = String_Offset(pos, s); - prefixLen = _t562; + unsigned int _t553; + _t553 = String_Offset(pos, s); + prefixLen = _t553; const char* prefix; - const char* _t563; - _t563 = bux_str_slice(s, 0, prefixLen); - prefix = _t563; + const char* _t554; + _t554 = bux_str_slice(s, 0, prefixLen); + prefix = _t554; const char* suffix; - _t564 = prefixLen + oldLen; - unsigned int _t565; - _t565 = bux_strlen(s); - _t566 = _t565 - prefixLen; - _t567 = _t566 - oldLen; - const char* _t568; - _t568 = bux_str_slice(s, _t564, _t567); - suffix = _t568; + _t555 = prefixLen + oldLen; + unsigned int _t556; + _t556 = bux_strlen(s); + _t557 = _t556 - prefixLen; + _t558 = _t557 - oldLen; + const char* _t559; + _t559 = bux_str_slice(s, _t555, _t558); + suffix = _t559; const char* temp; - const char* _t569; - _t569 = String_Concat(prefix, new); - temp = _t569; + const char* _t560; + _t560 = String_Concat(prefix, new); + temp = _t560; const char* result; - const char* _t570; - _t570 = String_Concat(temp, suffix); - result = _t570; + const char* _t561; + _t561 = String_Concat(temp, suffix); + result = _t561; return result; } double String_ToFloat(const char* s) { - double _t571; - _t571 = bux_str_to_float(s); - return _t571; + double _t562; + _t562 = bux_str_to_float(s); + return _t562; } const char* String_FromBool(bool b) { - if (!b) goto endif235; + if (!b) goto endif222; { return "true"; } - endif235:; + endif222:; return "false"; } const char* String_FromFloat(double f) { - const char* _t572; - _t572 = bux_float_to_string(f); - return _t572; + const char* _t563; + _t563 = bux_float_to_string(f); + return _t563; } const char* String_Format1(const char* pattern, const char* a0) { - const char* _t573; - _t573 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); - return _t573; + const char* _t564; + _t564 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); + return _t564; } const char* String_Format2(const char* pattern, const char* a0, const char* a1) { - const char* _t574; - _t574 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); - return _t574; + const char* _t565; + _t565 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); + return _t565; } const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) { - const char* _t575; - _t575 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); - return _t575; + const char* _t566; + _t566 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); + return _t566; } void Channel_SendInt(Channel_int* ch, int value) { - void* _t577; - void* _t578; - void* _t576; - _t576 = ch->handle; - _t577 = &value; - _t578 = (void*)_t577; - bux_channel_send(_t576, _t578); + void* _t568; + void* _t569; + void* _t567; + _t567 = ch->handle; + _t568 = &value; + _t569 = (void*)_t568; + bux_channel_send(_t567, _t569); } int Channel_RecvInt(Channel_int* ch) { - void* _t580; - void* _t581; + void* _t571; + void* _t572; int result; result = 0; - void* _t579; - _t579 = ch->handle; - _t580 = &result; - _t581 = (void*)_t580; - bux_channel_recv(_t579, _t581); + void* _t570; + _t570 = ch->handle; + _t571 = &result; + _t572 = (void*)_t571; + bux_channel_recv(_t570, _t572); return result; } void Channel_SendFloat64(Channel_float64* ch, double value) { - void* _t583; - void* _t584; - void* _t582; - _t582 = ch->handle; - _t583 = &value; - _t584 = (void*)_t583; - bux_channel_send(_t582, _t584); + void* _t574; + void* _t575; + void* _t573; + _t573 = ch->handle; + _t574 = &value; + _t575 = (void*)_t574; + bux_channel_send(_t573, _t575); } double Channel_RecvFloat64(Channel_float64* ch) { - void* _t586; - void* _t587; + void* _t577; + void* _t578; double result; result = 0.0; - void* _t585; - _t585 = ch->handle; - _t586 = &result; - _t587 = (void*)_t586; - bux_channel_recv(_t585, _t587); + void* _t576; + _t576 = ch->handle; + _t577 = &result; + _t578 = (void*)_t577; + bux_channel_recv(_t576, _t578); return result; } const char* Hash_Sha1(const char* data) { - int _t589; + int _t580; int len; - unsigned int _t588; - _t588 = String_Len(data); - _t589 = (int)_t588; - len = _t589; + unsigned int _t579; + _t579 = String_Len(data); + _t580 = (int)_t579; + len = _t580; void* buf; - void* _t590; - _t590 = Alloc(20); - buf = _t590; + void* _t581; + _t581 = Alloc(20); + buf = _t581; bux_sha1(data, len, buf); const char* result; - const char* _t591; - _t591 = bux_bytes_to_hex(buf, 20); - result = _t591; + const char* _t582; + _t582 = bux_bytes_to_hex(buf, 20); + result = _t582; Free(buf); return result; } const char* Hash_Sha256(const char* data) { - int _t593; + int _t584; int len; - unsigned int _t592; - _t592 = String_Len(data); - _t593 = (int)_t592; - len = _t593; + unsigned int _t583; + _t583 = String_Len(data); + _t584 = (int)_t583; + len = _t584; void* buf; - void* _t594; - _t594 = Alloc(32); - buf = _t594; + void* _t585; + _t585 = Alloc(32); + buf = _t585; bux_sha256(data, len, buf); const char* result; - const char* _t595; - _t595 = bux_bytes_to_hex(buf, 32); - result = _t595; + const char* _t586; + _t586 = bux_bytes_to_hex(buf, 32); + result = _t586; Free(buf); return result; } const char* Hash_Sha384(const char* data) { - int _t597; + int _t588; int len; - unsigned int _t596; - _t596 = String_Len(data); - _t597 = (int)_t596; - len = _t597; + unsigned int _t587; + _t587 = String_Len(data); + _t588 = (int)_t587; + len = _t588; void* buf; - void* _t598; - _t598 = Alloc(48); - buf = _t598; + void* _t589; + _t589 = Alloc(48); + buf = _t589; bux_sha384(data, len, buf); const char* result; - const char* _t599; - _t599 = bux_bytes_to_hex(buf, 48); - result = _t599; + const char* _t590; + _t590 = bux_bytes_to_hex(buf, 48); + result = _t590; Free(buf); return result; } const char* Hash_Sha512(const char* data) { - int _t601; + int _t592; int len; - unsigned int _t600; - _t600 = String_Len(data); - _t601 = (int)_t600; - len = _t601; + unsigned int _t591; + _t591 = String_Len(data); + _t592 = (int)_t591; + len = _t592; void* buf; - void* _t602; - _t602 = Alloc(64); - buf = _t602; + void* _t593; + _t593 = Alloc(64); + buf = _t593; bux_sha512(data, len, buf); const char* result; - const char* _t603; - _t603 = bux_bytes_to_hex(buf, 64); - result = _t603; + const char* _t594; + _t594 = bux_bytes_to_hex(buf, 64); + result = _t594; Free(buf); return result; } void Hash_Sha256Raw(const char* data, void* out) { - int _t605; - unsigned int _t604; - _t604 = String_Len(data); - _t605 = (int)_t604; - bux_sha256(data, _t605, out); + int _t596; + unsigned int _t595; + _t595 = String_Len(data); + _t596 = (int)_t595; + bux_sha256(data, _t596, out); } void Hash_Sha384Raw(const char* data, void* out) { - int _t607; - unsigned int _t606; - _t606 = String_Len(data); - _t607 = (int)_t606; - bux_sha384(data, _t607, out); + int _t598; + unsigned int _t597; + _t597 = String_Len(data); + _t598 = (int)_t597; + bux_sha384(data, _t598, out); } void Hash_Sha512Raw(const char* data, void* out) { - int _t609; - unsigned int _t608; - _t608 = String_Len(data); - _t609 = (int)_t608; - bux_sha512(data, _t609, out); + int _t600; + unsigned int _t599; + _t599 = String_Len(data); + _t600 = (int)_t599; + bux_sha512(data, _t600, out); } int Hash_Sha1Size(void) { @@ -3372,1504 +3371,1504 @@ int Hash_Sha512Size(void) { } const char* Base64_Encode(const char* s) { - int _t611; - unsigned int _t610; - _t610 = String_Len(s); - _t611 = (int)_t610; - const char* _t612; - _t612 = bux_base64_encode(s, _t611); - return _t612; + int _t602; + unsigned int _t601; + _t601 = String_Len(s); + _t602 = (int)_t601; + const char* _t603; + _t603 = bux_base64_encode(s, _t602); + return _t603; } const char* Base64_Decode(const char* s) { - int _t614; - void* _t615; + int _t605; + void* _t606; int outlen; outlen = 0; - unsigned int _t613; - _t613 = String_Len(s); - _t614 = (int)_t613; - _t615 = &outlen; - const char* _t616; - _t616 = bux_base64_decode(s, _t614, _t615); - return _t616; + unsigned int _t604; + _t604 = String_Len(s); + _t605 = (int)_t604; + _t606 = &outlen; + const char* _t607; + _t607 = bux_base64_decode(s, _t605, _t606); + return _t607; } const char* Base64URL_Encode(const char* s) { - int _t618; - unsigned int _t617; - _t617 = String_Len(s); - _t618 = (int)_t617; - const char* _t619; - _t619 = bux_base64url_encode(s, _t618); - return _t619; + int _t609; + unsigned int _t608; + _t608 = String_Len(s); + _t609 = (int)_t608; + const char* _t610; + _t610 = bux_base64url_encode(s, _t609); + return _t610; } const char* Base64URL_Decode(const char* s) { - int _t621; - void* _t622; + int _t612; + void* _t613; int outlen; outlen = 0; - unsigned int _t620; - _t620 = String_Len(s); - _t621 = (int)_t620; - _t622 = &outlen; - const char* _t623; - _t623 = bux_base64url_decode(s, _t621, _t622); - return _t623; + unsigned int _t611; + _t611 = String_Len(s); + _t612 = (int)_t611; + _t613 = &outlen; + const char* _t614; + _t614 = bux_base64url_decode(s, _t612, _t613); + return _t614; } const char* Hmac_Sha256(const char* key, const char* message) { - int _t625; - int _t627; + int _t616; + int _t618; int kl; - unsigned int _t624; - _t624 = String_Len(key); - _t625 = (int)_t624; - kl = _t625; + unsigned int _t615; + _t615 = String_Len(key); + _t616 = (int)_t615; + kl = _t616; int ml; - unsigned int _t626; - _t626 = String_Len(message); - _t627 = (int)_t626; - ml = _t627; + unsigned int _t617; + _t617 = String_Len(message); + _t618 = (int)_t617; + ml = _t618; void* buf; - void* _t628; - _t628 = Alloc(32); - buf = _t628; + void* _t619; + _t619 = Alloc(32); + buf = _t619; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - const char* _t629; - _t629 = bux_bytes_to_hex(buf, 32); - result = _t629; + const char* _t620; + _t620 = bux_bytes_to_hex(buf, 32); + result = _t620; Free(buf); return result; } void Hmac_Sha256Raw(const char* key, const char* message, void* out) { - int _t631; - int _t633; - unsigned int _t630; - _t630 = String_Len(key); - _t631 = (int)_t630; - unsigned int _t632; - _t632 = String_Len(message); - _t633 = (int)_t632; - bux_hmac_sha256(key, _t631, message, _t633, out); + int _t622; + int _t624; + unsigned int _t621; + _t621 = String_Len(key); + _t622 = (int)_t621; + unsigned int _t623; + _t623 = String_Len(message); + _t624 = (int)_t623; + bux_hmac_sha256(key, _t622, message, _t624, out); } const char* Hmac_Sha256Base64(const char* key, const char* message) { - int _t635; - int _t637; - const char* _t639; + int _t626; + int _t628; + const char* _t630; int kl; - unsigned int _t634; - _t634 = String_Len(key); - _t635 = (int)_t634; - kl = _t635; + unsigned int _t625; + _t625 = String_Len(key); + _t626 = (int)_t625; + kl = _t626; int ml; - unsigned int _t636; - _t636 = String_Len(message); - _t637 = (int)_t636; - ml = _t637; + unsigned int _t627; + _t627 = String_Len(message); + _t628 = (int)_t627; + ml = _t628; void* buf; - void* _t638; - _t638 = Alloc(32); - buf = _t638; + void* _t629; + _t629 = Alloc(32); + buf = _t629; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - _t639 = (const char*)buf; - const char* _t640; - _t640 = bux_base64_encode(_t639, 32); - result = _t640; + _t630 = (const char*)buf; + const char* _t631; + _t631 = bux_base64_encode(_t630, 32); + result = _t631; Free(buf); return result; } const char* Hmac_Sha384(const char* key, const char* message) { - int _t642; - int _t644; + int _t633; + int _t635; int kl; - unsigned int _t641; - _t641 = String_Len(key); - _t642 = (int)_t641; - kl = _t642; + unsigned int _t632; + _t632 = String_Len(key); + _t633 = (int)_t632; + kl = _t633; int ml; - unsigned int _t643; - _t643 = String_Len(message); - _t644 = (int)_t643; - ml = _t644; + unsigned int _t634; + _t634 = String_Len(message); + _t635 = (int)_t634; + ml = _t635; void* buf; - void* _t645; - _t645 = Alloc(48); - buf = _t645; + void* _t636; + _t636 = Alloc(48); + buf = _t636; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - const char* _t646; - _t646 = bux_bytes_to_hex(buf, 48); - result = _t646; + const char* _t637; + _t637 = bux_bytes_to_hex(buf, 48); + result = _t637; Free(buf); return result; } void Hmac_Sha384Raw(const char* key, const char* message, void* out) { - int _t648; - int _t650; - unsigned int _t647; - _t647 = String_Len(key); - _t648 = (int)_t647; - unsigned int _t649; - _t649 = String_Len(message); - _t650 = (int)_t649; - bux_hmac_sha384(key, _t648, message, _t650, out); + int _t639; + int _t641; + unsigned int _t638; + _t638 = String_Len(key); + _t639 = (int)_t638; + unsigned int _t640; + _t640 = String_Len(message); + _t641 = (int)_t640; + bux_hmac_sha384(key, _t639, message, _t641, out); } const char* Hmac_Sha384Base64(const char* key, const char* message) { - int _t652; - int _t654; - const char* _t656; + int _t643; + int _t645; + const char* _t647; int kl; - unsigned int _t651; - _t651 = String_Len(key); - _t652 = (int)_t651; - kl = _t652; + unsigned int _t642; + _t642 = String_Len(key); + _t643 = (int)_t642; + kl = _t643; int ml; - unsigned int _t653; - _t653 = String_Len(message); - _t654 = (int)_t653; - ml = _t654; + unsigned int _t644; + _t644 = String_Len(message); + _t645 = (int)_t644; + ml = _t645; void* buf; - void* _t655; - _t655 = Alloc(48); - buf = _t655; + void* _t646; + _t646 = Alloc(48); + buf = _t646; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - _t656 = (const char*)buf; - const char* _t657; - _t657 = bux_base64_encode(_t656, 48); - result = _t657; + _t647 = (const char*)buf; + const char* _t648; + _t648 = bux_base64_encode(_t647, 48); + result = _t648; Free(buf); return result; } const char* Hmac_Sha512(const char* key, const char* message) { - int _t659; - int _t661; + int _t650; + int _t652; int kl; - unsigned int _t658; - _t658 = String_Len(key); - _t659 = (int)_t658; - kl = _t659; + unsigned int _t649; + _t649 = String_Len(key); + _t650 = (int)_t649; + kl = _t650; int ml; - unsigned int _t660; - _t660 = String_Len(message); - _t661 = (int)_t660; - ml = _t661; + unsigned int _t651; + _t651 = String_Len(message); + _t652 = (int)_t651; + ml = _t652; void* buf; - void* _t662; - _t662 = Alloc(64); - buf = _t662; + void* _t653; + _t653 = Alloc(64); + buf = _t653; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - const char* _t663; - _t663 = bux_bytes_to_hex(buf, 64); - result = _t663; + const char* _t654; + _t654 = bux_bytes_to_hex(buf, 64); + result = _t654; Free(buf); return result; } void Hmac_Sha512Raw(const char* key, const char* message, void* out) { - int _t665; - int _t667; - unsigned int _t664; - _t664 = String_Len(key); - _t665 = (int)_t664; - unsigned int _t666; - _t666 = String_Len(message); - _t667 = (int)_t666; - bux_hmac_sha512(key, _t665, message, _t667, out); + int _t656; + int _t658; + unsigned int _t655; + _t655 = String_Len(key); + _t656 = (int)_t655; + unsigned int _t657; + _t657 = String_Len(message); + _t658 = (int)_t657; + bux_hmac_sha512(key, _t656, message, _t658, out); } const char* Hmac_Sha512Base64(const char* key, const char* message) { - int _t669; - int _t671; - const char* _t673; + int _t660; + int _t662; + const char* _t664; int kl; - unsigned int _t668; - _t668 = String_Len(key); - _t669 = (int)_t668; - kl = _t669; + unsigned int _t659; + _t659 = String_Len(key); + _t660 = (int)_t659; + kl = _t660; int ml; - unsigned int _t670; - _t670 = String_Len(message); - _t671 = (int)_t670; - ml = _t671; + unsigned int _t661; + _t661 = String_Len(message); + _t662 = (int)_t661; + ml = _t662; void* buf; - void* _t672; - _t672 = Alloc(64); - buf = _t672; + void* _t663; + _t663 = Alloc(64); + buf = _t663; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - _t673 = (const char*)buf; - const char* _t674; - _t674 = bux_base64_encode(_t673, 64); - result = _t674; + _t664 = (const char*)buf; + const char* _t665; + _t665 = bux_base64_encode(_t664, 64); + result = _t665; Free(buf); return result; } const char* Random_Bytes(int n) { - int _t675; - unsigned int _t676; - int _t679; - const char* _t680; - _t675 = (n <= 0); - if (!_t675) goto endif237; + int _t666; + unsigned int _t667; + int _t670; + const char* _t671; + _t666 = (n <= 0); + if (!_t666) goto endif224; { return ""; } - endif237:; + endif224:; void* buf; - _t676 = (unsigned int)n; - void* _t677; - _t677 = Alloc(_t676); - buf = _t677; - int _t678; - _t678 = bux_random_bytes(buf, n); - _t679 = (_t678 != 1); - if (!_t679) goto endif239; + _t667 = (unsigned int)n; + void* _t668; + _t668 = Alloc(_t667); + buf = _t668; + int _t669; + _t669 = bux_random_bytes(buf, n); + _t670 = (_t669 != 1); + if (!_t670) goto endif226; { Free(buf); return ""; } - endif239:; - _t680 = (const char*)buf; - return _t680; + endif226:; + _t671 = (const char*)buf; + return _t671; } const char* Random_Hex(int n) { - int _t681; - unsigned int _t682; - int _t685; - _t681 = (n <= 0); - if (!_t681) goto endif241; + int _t672; + unsigned int _t673; + int _t676; + _t672 = (n <= 0); + if (!_t672) goto endif228; { return ""; } - endif241:; + endif228:; void* buf; - _t682 = (unsigned int)n; - void* _t683; - _t683 = Alloc(_t682); - buf = _t683; - int _t684; - _t684 = bux_random_bytes(buf, n); - _t685 = (_t684 != 1); - if (!_t685) goto endif243; + _t673 = (unsigned int)n; + void* _t674; + _t674 = Alloc(_t673); + buf = _t674; + int _t675; + _t675 = bux_random_bytes(buf, n); + _t676 = (_t675 != 1); + if (!_t676) goto endif230; { Free(buf); return ""; } - endif243:; + endif230:; const char* result; - const char* _t686; - _t686 = bux_bytes_to_hex(buf, n); - result = _t686; + const char* _t677; + _t677 = bux_bytes_to_hex(buf, n); + result = _t677; Free(buf); return result; } const char* Random_Base64(int n) { - int _t687; - unsigned int _t688; - int _t691; - const char* _t692; - _t687 = (n <= 0); - if (!_t687) goto endif245; + int _t678; + unsigned int _t679; + int _t682; + const char* _t683; + _t678 = (n <= 0); + if (!_t678) goto endif232; { return ""; } - endif245:; + endif232:; void* buf; - _t688 = (unsigned int)n; - void* _t689; - _t689 = Alloc(_t688); - buf = _t689; - int _t690; - _t690 = bux_random_bytes(buf, n); - _t691 = (_t690 != 1); - if (!_t691) goto endif247; + _t679 = (unsigned int)n; + void* _t680; + _t680 = Alloc(_t679); + buf = _t680; + int _t681; + _t681 = bux_random_bytes(buf, n); + _t682 = (_t681 != 1); + if (!_t682) goto endif234; { Free(buf); return ""; } - endif247:; + endif234:; const char* result; - _t692 = (const char*)buf; - const char* _t693; - _t693 = bux_base64_encode(_t692, n); - result = _t693; + _t683 = (const char*)buf; + const char* _t684; + _t684 = bux_base64_encode(_t683, n); + result = _t684; Free(buf); return result; } unsigned int Random_Uint32(void) { - int _t696; - unsigned int* _t697; - unsigned int _t698; + int _t687; + unsigned int* _t688; + unsigned int _t689; void* buf; - void* _t694; - _t694 = Alloc(4); - buf = _t694; - int _t695; - _t695 = bux_random_bytes(buf, 4); - _t696 = (_t695 != 1); - if (!_t696) goto endif249; + void* _t685; + _t685 = Alloc(4); + buf = _t685; + int _t686; + _t686 = bux_random_bytes(buf, 4); + _t687 = (_t686 != 1); + if (!_t687) goto endif236; { Free(buf); return 0; } - endif249:; + endif236:; unsigned int* ptr; - _t697 = (unsigned int*)buf; - ptr = _t697; + _t688 = (unsigned int*)buf; + ptr = _t688; unsigned int val; - _t698 = *ptr; - val = _t698; + _t689 = *ptr; + val = _t689; Free(buf); return val; } const char* Aes_GenerateKey(void) { - unsigned int _t699; - int _t702; - const char* _t703; + unsigned int _t690; + int _t693; + const char* _t694; void* buf; - _t699 = (unsigned int)AES_KEY_SIZE; - void* _t700; - _t700 = Alloc(_t699); - buf = _t700; - int _t701; - _t701 = bux_random_bytes(buf, AES_KEY_SIZE); - _t702 = (_t701 != 1); - if (!_t702) goto endif251; + _t690 = (unsigned int)AES_KEY_SIZE; + void* _t691; + _t691 = Alloc(_t690); + buf = _t691; + int _t692; + _t692 = bux_random_bytes(buf, AES_KEY_SIZE); + _t693 = (_t692 != 1); + if (!_t693) goto endif238; { Free(buf); return ""; } - endif251:; - _t703 = (const char*)buf; - return _t703; + endif238:; + _t694 = (const char*)buf; + return _t694; } const char* Aes_GenerateIV(void) { - unsigned int _t704; - int _t707; - const char* _t708; + unsigned int _t695; + int _t698; + const char* _t699; void* buf; - _t704 = (unsigned int)AES_IV_SIZE; - void* _t705; - _t705 = Alloc(_t704); - buf = _t705; - int _t706; - _t706 = bux_random_bytes(buf, AES_IV_SIZE); - _t707 = (_t706 != 1); - if (!_t707) goto endif253; + _t695 = (unsigned int)AES_IV_SIZE; + void* _t696; + _t696 = Alloc(_t695); + buf = _t696; + int _t697; + _t697 = bux_random_bytes(buf, AES_IV_SIZE); + _t698 = (_t697 != 1); + if (!_t698) goto endif240; { Free(buf); return ""; } - endif253:; - _t708 = (const char*)buf; - return _t708; + endif240:; + _t699 = (const char*)buf; + return _t699; } const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv) { - int _t710; - void* _t711; + int _t701; + void* _t702; int outlen; outlen = 0; - unsigned int _t709; - _t709 = String_Len(plain); - _t710 = (int)_t709; - _t711 = &outlen; - const char* _t712; - _t712 = bux_aes_256_cbc_encrypt(plain, _t710, key, iv, _t711); - return _t712; + unsigned int _t700; + _t700 = String_Len(plain); + _t701 = (int)_t700; + _t702 = &outlen; + const char* _t703; + _t703 = bux_aes_256_cbc_encrypt(plain, _t701, key, iv, _t702); + return _t703; } const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv) { - int _t714; - void* _t715; + int _t705; + void* _t706; int outlen; outlen = 0; - unsigned int _t713; - _t713 = String_Len(cipher); - _t714 = (int)_t713; - _t715 = &outlen; - const char* _t716; - _t716 = bux_aes_256_cbc_decrypt(cipher, _t714, key, iv, _t715); - return _t716; + unsigned int _t704; + _t704 = String_Len(cipher); + _t705 = (int)_t704; + _t706 = &outlen; + const char* _t707; + _t707 = bux_aes_256_cbc_decrypt(cipher, _t705, key, iv, _t706); + return _t707; } const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag) { - int _t718; - void* _t719; + int _t709; + void* _t710; int outlen; outlen = 0; - unsigned int _t717; - _t717 = String_Len(plain); - _t718 = (int)_t717; - _t719 = &outlen; - const char* _t720; - _t720 = bux_aes_256_gcm_encrypt(plain, _t718, key, iv, tag, _t719); - return _t720; + unsigned int _t708; + _t708 = String_Len(plain); + _t709 = (int)_t708; + _t710 = &outlen; + const char* _t711; + _t711 = bux_aes_256_gcm_encrypt(plain, _t709, key, iv, tag, _t710); + return _t711; } const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag) { - int _t722; - void* _t723; + int _t713; + void* _t714; int outlen; outlen = 0; - unsigned int _t721; - _t721 = String_Len(cipher); - _t722 = (int)_t721; - _t723 = &outlen; - const char* _t724; - _t724 = bux_aes_256_gcm_decrypt(cipher, _t722, key, iv, tag, _t723); - return _t724; + unsigned int _t712; + _t712 = String_Len(cipher); + _t713 = (int)_t712; + _t714 = &outlen; + const char* _t715; + _t715 = bux_aes_256_gcm_decrypt(cipher, _t713, key, iv, tag, _t714); + return _t715; } const char* Jwt_MakeHeader(JwtAlg alg) { - int _t725; - int _t726; - int _t727; - int _t728; - int _t729; - int _t730; - int _t731; - int _t732; - int _t733; - _t725 = (alg == JwtAlg_HS256); - if (!_t725) goto endif255; + int _t716; + int _t717; + int _t718; + int _t719; + int _t720; + int _t721; + int _t722; + int _t723; + int _t724; + _t716 = (alg == JwtAlg_HS256); + if (!_t716) goto endif242; { return "{\"alg\":\"HS256\",\"typ\":\"JWT\"}"; } - endif255:; - _t726 = (alg == JwtAlg_HS384); - if (!_t726) goto endif257; + endif242:; + _t717 = (alg == JwtAlg_HS384); + if (!_t717) goto endif244; { return "{\"alg\":\"HS384\",\"typ\":\"JWT\"}"; } - endif257:; - _t727 = (alg == JwtAlg_HS512); - if (!_t727) goto endif259; + endif244:; + _t718 = (alg == JwtAlg_HS512); + if (!_t718) goto endif246; { return "{\"alg\":\"HS512\",\"typ\":\"JWT\"}"; } - endif259:; - _t728 = (alg == JwtAlg_RS256); - if (!_t728) goto endif261; + endif246:; + _t719 = (alg == JwtAlg_RS256); + if (!_t719) goto endif248; { return "{\"alg\":\"RS256\",\"typ\":\"JWT\"}"; } - endif261:; - _t729 = (alg == JwtAlg_RS384); - if (!_t729) goto endif263; + endif248:; + _t720 = (alg == JwtAlg_RS384); + if (!_t720) goto endif250; { return "{\"alg\":\"RS384\",\"typ\":\"JWT\"}"; } - endif263:; - _t730 = (alg == JwtAlg_RS512); - if (!_t730) goto endif265; + endif250:; + _t721 = (alg == JwtAlg_RS512); + if (!_t721) goto endif252; { return "{\"alg\":\"RS512\",\"typ\":\"JWT\"}"; } - endif265:; - _t731 = (alg == JwtAlg_ES256); - if (!_t731) goto endif267; + endif252:; + _t722 = (alg == JwtAlg_ES256); + if (!_t722) goto endif254; { return "{\"alg\":\"ES256\",\"typ\":\"JWT\"}"; } - endif267:; - _t732 = (alg == JwtAlg_ES384); - if (!_t732) goto endif269; + endif254:; + _t723 = (alg == JwtAlg_ES384); + if (!_t723) goto endif256; { return "{\"alg\":\"ES384\",\"typ\":\"JWT\"}"; } - endif269:; - _t733 = (alg == JwtAlg_EdDSA); - if (!_t733) goto endif271; + endif256:; + _t724 = (alg == JwtAlg_EdDSA); + if (!_t724) goto endif258; { return "{\"alg\":\"EdDSA\",\"typ\":\"JWT\"}"; } - endif271:; + endif258:; return "{\"alg\":\"none\",\"typ\":\"JWT\"}"; } const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key) { - int _t734; - const char* _t736; - int _t738; - const char* _t740; + int _t725; + const char* _t727; + int _t729; + const char* _t731; + int _t733; + const char* _t735; + int _t737; + int _t740; int _t742; - const char* _t744; - int _t746; - int _t749; - int _t751; - int _t754; - int _t756; - int _t759; - int _t761; - int _t764; - int _t766; - int _t769; - int _t771; - _t734 = (alg == JwtAlg_HS256); - if (!_t734) goto endif273; + int _t745; + int _t747; + int _t750; + int _t752; + int _t755; + int _t757; + int _t760; + int _t762; + _t725 = (alg == JwtAlg_HS256); + if (!_t725) goto endif260; { void* buf; - void* _t735; - _t735 = Alloc(32); - buf = _t735; + void* _t726; + _t726 = Alloc(32); + buf = _t726; Hmac_Sha256Raw(key, signingInput, buf); const char* result; - _t736 = (const char*)buf; - const char* _t737; - _t737 = bux_base64_encode(_t736, 32); - result = _t737; + _t727 = (const char*)buf; + const char* _t728; + _t728 = bux_base64_encode(_t727, 32); + result = _t728; Free(buf); return result; } - endif273:; - _t738 = (alg == JwtAlg_HS384); - if (!_t738) goto endif275; + endif260:; + _t729 = (alg == JwtAlg_HS384); + if (!_t729) goto endif262; { void* buf; - void* _t739; - _t739 = Alloc(48); - buf = _t739; + void* _t730; + _t730 = Alloc(48); + buf = _t730; Hmac_Sha384Raw(key, signingInput, buf); const char* result; - _t740 = (const char*)buf; - const char* _t741; - _t741 = bux_base64_encode(_t740, 48); - result = _t741; + _t731 = (const char*)buf; + const char* _t732; + _t732 = bux_base64_encode(_t731, 48); + result = _t732; Free(buf); return result; } - endif275:; - _t742 = (alg == JwtAlg_HS512); - if (!_t742) goto endif277; + endif262:; + _t733 = (alg == JwtAlg_HS512); + if (!_t733) goto endif264; { void* buf; - void* _t743; - _t743 = Alloc(64); - buf = _t743; + void* _t734; + _t734 = Alloc(64); + buf = _t734; Hmac_Sha512Raw(key, signingInput, buf); const char* result; - _t744 = (const char*)buf; - const char* _t745; - _t745 = bux_base64_encode(_t744, 64); - result = _t745; + _t735 = (const char*)buf; + const char* _t736; + _t736 = bux_base64_encode(_t735, 64); + result = _t736; Free(buf); return result; } - endif277:; - _t746 = (alg == JwtAlg_RS256); - if (!_t746) goto endif279; + endif264:; + _t737 = (alg == JwtAlg_RS256); + if (!_t737) goto endif266; { const char* raw; - const char* _t747; - _t747 = Rsa_SignSha256(key, signingInput); - raw = _t747; - unsigned int _t748; - _t748 = String_Len(raw); - _t749 = (int)_t748; - const char* _t750; - _t750 = bux_base64_encode(raw, _t749); - return _t750; + const char* _t738; + _t738 = Rsa_SignSha256(key, signingInput); + raw = _t738; + unsigned int _t739; + _t739 = String_Len(raw); + _t740 = (int)_t739; + const char* _t741; + _t741 = bux_base64_encode(raw, _t740); + return _t741; } - endif279:; - _t751 = (alg == JwtAlg_RS384); - if (!_t751) goto endif281; + endif266:; + _t742 = (alg == JwtAlg_RS384); + if (!_t742) goto endif268; { const char* raw; - const char* _t752; - _t752 = Rsa_SignSha384(key, signingInput); - raw = _t752; - unsigned int _t753; - _t753 = String_Len(raw); - _t754 = (int)_t753; - const char* _t755; - _t755 = bux_base64_encode(raw, _t754); - return _t755; + const char* _t743; + _t743 = Rsa_SignSha384(key, signingInput); + raw = _t743; + unsigned int _t744; + _t744 = String_Len(raw); + _t745 = (int)_t744; + const char* _t746; + _t746 = bux_base64_encode(raw, _t745); + return _t746; } - endif281:; - _t756 = (alg == JwtAlg_RS512); - if (!_t756) goto endif283; + endif268:; + _t747 = (alg == JwtAlg_RS512); + if (!_t747) goto endif270; { const char* raw; - const char* _t757; - _t757 = Rsa_SignSha512(key, signingInput); - raw = _t757; - unsigned int _t758; - _t758 = String_Len(raw); - _t759 = (int)_t758; - const char* _t760; - _t760 = bux_base64_encode(raw, _t759); - return _t760; + const char* _t748; + _t748 = Rsa_SignSha512(key, signingInput); + raw = _t748; + unsigned int _t749; + _t749 = String_Len(raw); + _t750 = (int)_t749; + const char* _t751; + _t751 = bux_base64_encode(raw, _t750); + return _t751; } - endif283:; - _t761 = (alg == JwtAlg_ES256); - if (!_t761) goto endif285; + endif270:; + _t752 = (alg == JwtAlg_ES256); + if (!_t752) goto endif272; { const char* raw; - const char* _t762; - _t762 = Ecdsa_SignP256(key, signingInput); - raw = _t762; - unsigned int _t763; - _t763 = String_Len(raw); - _t764 = (int)_t763; - const char* _t765; - _t765 = bux_base64_encode(raw, _t764); - return _t765; + const char* _t753; + _t753 = Ecdsa_SignP256(key, signingInput); + raw = _t753; + unsigned int _t754; + _t754 = String_Len(raw); + _t755 = (int)_t754; + const char* _t756; + _t756 = bux_base64_encode(raw, _t755); + return _t756; } - endif285:; - _t766 = (alg == JwtAlg_ES384); - if (!_t766) goto endif287; + endif272:; + _t757 = (alg == JwtAlg_ES384); + if (!_t757) goto endif274; { const char* raw; - const char* _t767; - _t767 = Ecdsa_SignP384(key, signingInput); - raw = _t767; - unsigned int _t768; - _t768 = String_Len(raw); - _t769 = (int)_t768; - const char* _t770; - _t770 = bux_base64_encode(raw, _t769); - return _t770; + const char* _t758; + _t758 = Ecdsa_SignP384(key, signingInput); + raw = _t758; + unsigned int _t759; + _t759 = String_Len(raw); + _t760 = (int)_t759; + const char* _t761; + _t761 = bux_base64_encode(raw, _t760); + return _t761; } - endif287:; - _t771 = (alg == JwtAlg_EdDSA); - if (!_t771) goto endif289; + endif274:; + _t762 = (alg == JwtAlg_EdDSA); + if (!_t762) goto endif276; { - const char* _t772; - _t772 = Ed25519_Sign(key, signingInput); - return _t772; + const char* _t763; + _t763 = Ed25519_Sign(key, signingInput); + return _t763; } - endif289:; + endif276:; return ""; } bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key) { - int _t773; - const char* _t775; - int _t778; - const char* _t780; + int _t764; + const char* _t766; + int _t769; + const char* _t771; + int _t774; + const char* _t776; + int _t779; + int _t781; int _t783; - const char* _t785; - int _t788; - int _t790; - int _t792; - int _t794; - int _t796; - int _t798; - _t773 = (alg == JwtAlg_HS256); - if (!_t773) goto endif291; + int _t785; + int _t787; + int _t789; + _t764 = (alg == JwtAlg_HS256); + if (!_t764) goto endif278; { void* expectBuf; - void* _t774; - _t774 = Alloc(32); - expectBuf = _t774; + void* _t765; + _t765 = Alloc(32); + expectBuf = _t765; Hmac_Sha256Raw(key, signingInput, expectBuf); const char* expectB64; - _t775 = (const char*)expectBuf; - const char* _t776; - _t776 = bux_base64_encode(_t775, 32); - expectB64 = _t776; + _t766 = (const char*)expectBuf; + const char* _t767; + _t767 = bux_base64_encode(_t766, 32); + expectB64 = _t767; Free(expectBuf); - bool _t777; - _t777 = String_Eq(expectB64, signatureB64); - return _t777; + bool _t768; + _t768 = String_Eq(expectB64, signatureB64); + return _t768; } - endif291:; - _t778 = (alg == JwtAlg_HS384); - if (!_t778) goto endif293; + endif278:; + _t769 = (alg == JwtAlg_HS384); + if (!_t769) goto endif280; { void* expectBuf; - void* _t779; - _t779 = Alloc(48); - expectBuf = _t779; + void* _t770; + _t770 = Alloc(48); + expectBuf = _t770; Hmac_Sha384Raw(key, signingInput, expectBuf); const char* expectB64; - _t780 = (const char*)expectBuf; - const char* _t781; - _t781 = bux_base64_encode(_t780, 48); - expectB64 = _t781; + _t771 = (const char*)expectBuf; + const char* _t772; + _t772 = bux_base64_encode(_t771, 48); + expectB64 = _t772; Free(expectBuf); - bool _t782; - _t782 = String_Eq(expectB64, signatureB64); - return _t782; + bool _t773; + _t773 = String_Eq(expectB64, signatureB64); + return _t773; } - endif293:; - _t783 = (alg == JwtAlg_HS512); - if (!_t783) goto endif295; + endif280:; + _t774 = (alg == JwtAlg_HS512); + if (!_t774) goto endif282; { void* expectBuf; - void* _t784; - _t784 = Alloc(64); - expectBuf = _t784; + void* _t775; + _t775 = Alloc(64); + expectBuf = _t775; Hmac_Sha512Raw(key, signingInput, expectBuf); const char* expectB64; - _t785 = (const char*)expectBuf; - const char* _t786; - _t786 = bux_base64_encode(_t785, 64); - expectB64 = _t786; + _t776 = (const char*)expectBuf; + const char* _t777; + _t777 = bux_base64_encode(_t776, 64); + expectB64 = _t777; Free(expectBuf); - bool _t787; - _t787 = String_Eq(expectB64, signatureB64); - return _t787; + bool _t778; + _t778 = String_Eq(expectB64, signatureB64); + return _t778; } - endif295:; - _t788 = (alg == JwtAlg_RS256); - if (!_t788) goto endif297; + endif282:; + _t779 = (alg == JwtAlg_RS256); + if (!_t779) goto endif284; { - bool _t789; - _t789 = Rsa_VerifySha256(key, signingInput, signatureB64); - return _t789; + bool _t780; + _t780 = Rsa_VerifySha256(key, signingInput, signatureB64); + return _t780; } - endif297:; - _t790 = (alg == JwtAlg_RS384); - if (!_t790) goto endif299; + endif284:; + _t781 = (alg == JwtAlg_RS384); + if (!_t781) goto endif286; { - bool _t791; - _t791 = Rsa_VerifySha384(key, signingInput, signatureB64); - return _t791; + bool _t782; + _t782 = Rsa_VerifySha384(key, signingInput, signatureB64); + return _t782; } - endif299:; - _t792 = (alg == JwtAlg_RS512); - if (!_t792) goto endif301; + endif286:; + _t783 = (alg == JwtAlg_RS512); + if (!_t783) goto endif288; { - bool _t793; - _t793 = Rsa_VerifySha512(key, signingInput, signatureB64); - return _t793; + bool _t784; + _t784 = Rsa_VerifySha512(key, signingInput, signatureB64); + return _t784; } - endif301:; - _t794 = (alg == JwtAlg_ES256); - if (!_t794) goto endif303; + endif288:; + _t785 = (alg == JwtAlg_ES256); + if (!_t785) goto endif290; { - bool _t795; - _t795 = Ecdsa_VerifyP256(key, signingInput, signatureB64); - return _t795; + bool _t786; + _t786 = Ecdsa_VerifyP256(key, signingInput, signatureB64); + return _t786; } - endif303:; - _t796 = (alg == JwtAlg_ES384); - if (!_t796) goto endif305; + endif290:; + _t787 = (alg == JwtAlg_ES384); + if (!_t787) goto endif292; { - bool _t797; - _t797 = Ecdsa_VerifyP384(key, signingInput, signatureB64); - return _t797; + bool _t788; + _t788 = Ecdsa_VerifyP384(key, signingInput, signatureB64); + return _t788; } - endif305:; - _t798 = (alg == JwtAlg_EdDSA); - if (!_t798) goto endif307; + endif292:; + _t789 = (alg == JwtAlg_EdDSA); + if (!_t789) goto endif294; { - bool _t799; - _t799 = Ed25519_Verify(key, signatureB64, signingInput); - return _t799; + bool _t790; + _t790 = Ed25519_Verify(key, signatureB64, signingInput); + return _t790; } - endif307:; + endif294:; return 0; } const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key) { const char* headerB64; - const char* _t800; - _t800 = Base64URL_Encode(headerJson); - headerB64 = _t800; + const char* _t791; + _t791 = Base64URL_Encode(headerJson); + headerB64 = _t791; const char* payloadB64; - const char* _t801; - _t801 = Base64URL_Encode(payloadJson); - payloadB64 = _t801; + const char* _t792; + _t792 = Base64URL_Encode(payloadJson); + payloadB64 = _t792; const char* signingInput; - const char* _t802; - _t802 = String_Concat(headerB64, "."); - signingInput = _t802; + const char* _t793; + _t793 = String_Concat(headerB64, "."); + signingInput = _t793; const char* signingInputFull; - const char* _t803; - _t803 = String_Concat(signingInput, payloadB64); - signingInputFull = _t803; + const char* _t794; + _t794 = String_Concat(signingInput, payloadB64); + signingInputFull = _t794; const char* sigB64; - const char* _t804; - _t804 = Jwt_Sign(alg, signingInputFull, key); - sigB64 = _t804; + const char* _t795; + _t795 = Jwt_Sign(alg, signingInputFull, key); + sigB64 = _t795; const char* part1; - const char* _t805; - _t805 = String_Concat(signingInputFull, "."); - part1 = _t805; - const char* _t806; - _t806 = String_Concat(part1, sigB64); - return _t806; + const char* _t796; + _t796 = String_Concat(signingInputFull, "."); + part1 = _t796; + const char* _t797; + _t797 = String_Concat(part1, sigB64); + return _t797; } bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut) { - int _t808; - int _t815; + int _t799; + int _t806; unsigned int partCount; - unsigned int _t807; - _t807 = bux_str_split_count(token, "."); - partCount = _t807; - _t808 = (partCount != 3); - if (!_t808) goto endif309; + unsigned int _t798; + _t798 = bux_str_split_count(token, "."); + partCount = _t798; + _t799 = (partCount != 3); + if (!_t799) goto endif296; { return 0; } - endif309:; + endif296:; const char* headerB64; - const char* _t809; - _t809 = bux_str_split_part(token, ".", 0); - headerB64 = _t809; + const char* _t800; + _t800 = bux_str_split_part(token, ".", 0); + headerB64 = _t800; const char* payloadB64; - const char* _t810; - _t810 = bux_str_split_part(token, ".", 1); - payloadB64 = _t810; + const char* _t801; + _t801 = bux_str_split_part(token, ".", 1); + payloadB64 = _t801; const char* sigB64; - const char* _t811; - _t811 = bux_str_split_part(token, ".", 2); - sigB64 = _t811; + const char* _t802; + _t802 = bux_str_split_part(token, ".", 2); + sigB64 = _t802; const char* input; - const char* _t812; - _t812 = String_Concat(headerB64, "."); - input = _t812; + const char* _t803; + _t803 = String_Concat(headerB64, "."); + input = _t803; const char* signingInput; - const char* _t813; - _t813 = String_Concat(input, payloadB64); - signingInput = _t813; - bool _t814; - _t814 = Jwt_Verify(alg, signingInput, sigB64, key); - _t815 = !_t814; - if (!_t815) goto endif311; + const char* _t804; + _t804 = String_Concat(input, payloadB64); + signingInput = _t804; + bool _t805; + _t805 = Jwt_Verify(alg, signingInput, sigB64, key); + _t806 = !_t805; + if (!_t806) goto endif298; { return 0; } - endif311:; - const char* _t816; - _t816 = Base64URL_Decode(headerB64); - headerOut[0] = _t816; - const char* _t817; - _t817 = Base64URL_Decode(payloadB64); - payloadOut[0] = _t817; + endif298:; + const char* _t807; + _t807 = Base64URL_Decode(headerB64); + headerOut[0] = _t807; + const char* _t808; + _t808 = Base64URL_Decode(payloadB64); + payloadOut[0] = _t808; return 1; } const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret) { const char* header; - const char* _t818; - _t818 = Jwt_MakeHeader(JwtAlg_HS256); - header = _t818; - const char* _t819; - _t819 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); - return _t819; + const char* _t809; + _t809 = Jwt_MakeHeader(JwtAlg_HS256); + header = _t809; + const char* _t810; + _t810 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); + return _t810; } const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret) { const char* header; - const char* _t820; - _t820 = Jwt_MakeHeader(JwtAlg_HS384); - header = _t820; - const char* _t821; - _t821 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); - return _t821; + const char* _t811; + _t811 = Jwt_MakeHeader(JwtAlg_HS384); + header = _t811; + const char* _t812; + _t812 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); + return _t812; } const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret) { const char* header; - const char* _t822; - _t822 = Jwt_MakeHeader(JwtAlg_HS512); - header = _t822; - const char* _t823; - _t823 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); - return _t823; + const char* _t813; + _t813 = Jwt_MakeHeader(JwtAlg_HS512); + header = _t813; + const char* _t814; + _t814 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); + return _t814; } const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t824; - _t824 = Jwt_MakeHeader(JwtAlg_RS256); - header = _t824; - const char* _t825; - _t825 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); - return _t825; + const char* _t815; + _t815 = Jwt_MakeHeader(JwtAlg_RS256); + header = _t815; + const char* _t816; + _t816 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); + return _t816; } const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t826; - _t826 = Jwt_MakeHeader(JwtAlg_ES256); - header = _t826; - const char* _t827; - _t827 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); - return _t827; + const char* _t817; + _t817 = Jwt_MakeHeader(JwtAlg_ES256); + header = _t817; + const char* _t818; + _t818 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); + return _t818; } const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey) { const char* header; - const char* _t828; - _t828 = Jwt_MakeHeader(JwtAlg_EdDSA); - header = _t828; - const char* _t829; - _t829 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); - return _t829; + const char* _t819; + _t819 = Jwt_MakeHeader(JwtAlg_EdDSA); + header = _t819; + const char* _t820; + _t820 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); + return _t820; } const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data) { - int _t831; - int _t833; - void* _t834; + int _t822; + int _t824; + void* _t825; int siglen; siglen = 0; - unsigned int _t830; - _t830 = String_Len(pemPrivateKey); - _t831 = (int)_t830; - unsigned int _t832; - _t832 = String_Len(data); - _t833 = (int)_t832; - _t834 = &siglen; - const char* _t835; - _t835 = bux_ecdsa_sign_p256(pemPrivateKey, _t831, data, _t833, _t834); - return _t835; + unsigned int _t821; + _t821 = String_Len(pemPrivateKey); + _t822 = (int)_t821; + unsigned int _t823; + _t823 = String_Len(data); + _t824 = (int)_t823; + _t825 = &siglen; + const char* _t826; + _t826 = bux_ecdsa_sign_p256(pemPrivateKey, _t822, data, _t824, _t825); + return _t826; } const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data) { - int _t838; + int _t829; const char* raw; - const char* _t836; - _t836 = Ecdsa_SignP256(pemPrivateKey, data); - raw = _t836; - unsigned int _t837; - _t837 = String_Len(raw); - _t838 = (int)_t837; - const char* _t839; - _t839 = bux_base64_encode(raw, _t838); - return _t839; + const char* _t827; + _t827 = Ecdsa_SignP256(pemPrivateKey, data); + raw = _t827; + unsigned int _t828; + _t828 = String_Len(raw); + _t829 = (int)_t828; + const char* _t830; + _t830 = bux_base64_encode(raw, _t829); + return _t830; } bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature) { - int _t841; - int _t843; - int _t845; - int _t847; + int _t832; + int _t834; + int _t836; + int _t838; int r; - unsigned int _t840; - _t840 = String_Len(pemPublicKey); - _t841 = (int)_t840; - unsigned int _t842; - _t842 = String_Len(data); - _t843 = (int)_t842; - unsigned int _t844; - _t844 = String_Len(signature); - _t845 = (int)_t844; - int _t846; - _t846 = bux_ecdsa_verify_p256(pemPublicKey, _t841, data, _t843, signature, _t845); - r = _t846; - _t847 = (r == 1); - return _t847; + unsigned int _t831; + _t831 = String_Len(pemPublicKey); + _t832 = (int)_t831; + unsigned int _t833; + _t833 = String_Len(data); + _t834 = (int)_t833; + unsigned int _t835; + _t835 = String_Len(signature); + _t836 = (int)_t835; + int _t837; + _t837 = bux_ecdsa_verify_p256(pemPublicKey, _t832, data, _t834, signature, _t836); + r = _t837; + _t838 = (r == 1); + return _t838; } bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t849; - void* _t850; + int _t840; + void* _t841; int outlen; outlen = 0; const char* sig; - unsigned int _t848; - _t848 = String_Len(signatureB64); - _t849 = (int)_t848; - _t850 = &outlen; - const char* _t851; - _t851 = bux_base64_decode(signatureB64, _t849, _t850); - sig = _t851; - bool _t852; - _t852 = Ecdsa_VerifyP256(pemPublicKey, data, sig); - return _t852; + unsigned int _t839; + _t839 = String_Len(signatureB64); + _t840 = (int)_t839; + _t841 = &outlen; + const char* _t842; + _t842 = bux_base64_decode(signatureB64, _t840, _t841); + sig = _t842; + bool _t843; + _t843 = Ecdsa_VerifyP256(pemPublicKey, data, sig); + return _t843; } const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data) { - int _t854; - int _t856; - void* _t857; + int _t845; + int _t847; + void* _t848; int siglen; siglen = 0; - unsigned int _t853; - _t853 = String_Len(pemPrivateKey); - _t854 = (int)_t853; - unsigned int _t855; - _t855 = String_Len(data); - _t856 = (int)_t855; - _t857 = &siglen; - const char* _t858; - _t858 = bux_ecdsa_sign_p384(pemPrivateKey, _t854, data, _t856, _t857); - return _t858; + unsigned int _t844; + _t844 = String_Len(pemPrivateKey); + _t845 = (int)_t844; + unsigned int _t846; + _t846 = String_Len(data); + _t847 = (int)_t846; + _t848 = &siglen; + const char* _t849; + _t849 = bux_ecdsa_sign_p384(pemPrivateKey, _t845, data, _t847, _t848); + return _t849; } const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data) { - int _t861; + int _t852; const char* raw; - const char* _t859; - _t859 = Ecdsa_SignP384(pemPrivateKey, data); - raw = _t859; - unsigned int _t860; - _t860 = String_Len(raw); - _t861 = (int)_t860; - const char* _t862; - _t862 = bux_base64_encode(raw, _t861); - return _t862; + const char* _t850; + _t850 = Ecdsa_SignP384(pemPrivateKey, data); + raw = _t850; + unsigned int _t851; + _t851 = String_Len(raw); + _t852 = (int)_t851; + const char* _t853; + _t853 = bux_base64_encode(raw, _t852); + return _t853; } bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature) { - int _t864; - int _t866; - int _t868; - int _t870; + int _t855; + int _t857; + int _t859; + int _t861; int r; - unsigned int _t863; - _t863 = String_Len(pemPublicKey); - _t864 = (int)_t863; - unsigned int _t865; - _t865 = String_Len(data); - _t866 = (int)_t865; - unsigned int _t867; - _t867 = String_Len(signature); - _t868 = (int)_t867; - int _t869; - _t869 = bux_ecdsa_verify_p384(pemPublicKey, _t864, data, _t866, signature, _t868); - r = _t869; - _t870 = (r == 1); - return _t870; + unsigned int _t854; + _t854 = String_Len(pemPublicKey); + _t855 = (int)_t854; + unsigned int _t856; + _t856 = String_Len(data); + _t857 = (int)_t856; + unsigned int _t858; + _t858 = String_Len(signature); + _t859 = (int)_t858; + int _t860; + _t860 = bux_ecdsa_verify_p384(pemPublicKey, _t855, data, _t857, signature, _t859); + r = _t860; + _t861 = (r == 1); + return _t861; } bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t872; - void* _t873; + int _t863; + void* _t864; int outlen; outlen = 0; const char* sig; - unsigned int _t871; - _t871 = String_Len(signatureB64); - _t872 = (int)_t871; - _t873 = &outlen; - const char* _t874; - _t874 = bux_base64_decode(signatureB64, _t872, _t873); - sig = _t874; - bool _t875; - _t875 = Ecdsa_VerifyP384(pemPublicKey, data, sig); - return _t875; + unsigned int _t862; + _t862 = String_Len(signatureB64); + _t863 = (int)_t862; + _t864 = &outlen; + const char* _t865; + _t865 = bux_base64_decode(signatureB64, _t863, _t864); + sig = _t865; + bool _t866; + _t866 = Ecdsa_VerifyP384(pemPublicKey, data, sig); + return _t866; } bool Ed25519_Keypair(void* pubKey, void* privKey) { - int _t877; + int _t868; int r; - int _t876; - _t876 = bux_ed25519_keypair(pubKey, privKey); - r = _t876; - _t877 = (r == 1); - return _t877; + int _t867; + _t867 = bux_ed25519_keypair(pubKey, privKey); + r = _t867; + _t868 = (r == 1); + return _t868; } const char* Ed25519_KeypairBase64(void) { - unsigned int _t878; - unsigned int _t880; - int _t883; - const char* _t884; - const char* _t886; + unsigned int _t869; + unsigned int _t871; + int _t874; + const char* _t875; + const char* _t877; void* pubBuf; - _t878 = (unsigned int)ED25519_PUBKEY_SIZE; - void* _t879; - _t879 = Alloc(_t878); - pubBuf = _t879; + _t869 = (unsigned int)ED25519_PUBKEY_SIZE; + void* _t870; + _t870 = Alloc(_t869); + pubBuf = _t870; void* priv; - _t880 = (unsigned int)ED25519_PRIVKEY_SIZE; - void* _t881; - _t881 = Alloc(_t880); - priv = _t881; - int _t882; - _t882 = bux_ed25519_keypair(pubBuf, priv); - _t883 = (_t882 != 1); - if (!_t883) goto endif313; + _t871 = (unsigned int)ED25519_PRIVKEY_SIZE; + void* _t872; + _t872 = Alloc(_t871); + priv = _t872; + int _t873; + _t873 = bux_ed25519_keypair(pubBuf, priv); + _t874 = (_t873 != 1); + if (!_t874) goto endif300; { Free(pubBuf); Free(priv); return ""; } - endif313:; + endif300:; const char* pubB64; - _t884 = (const char*)pubBuf; - const char* _t885; - _t885 = bux_base64_encode(_t884, ED25519_PUBKEY_SIZE); - pubB64 = _t885; + _t875 = (const char*)pubBuf; + const char* _t876; + _t876 = bux_base64_encode(_t875, ED25519_PUBKEY_SIZE); + pubB64 = _t876; const char* privB64; - _t886 = (const char*)priv; - const char* _t887; - _t887 = bux_base64_encode(_t886, ED25519_PRIVKEY_SIZE); - privB64 = _t887; + _t877 = (const char*)priv; + const char* _t878; + _t878 = bux_base64_encode(_t877, ED25519_PRIVKEY_SIZE); + privB64 = _t878; Free(pubBuf); Free(priv); const char* pair; - const char* _t888; - _t888 = String_Concat(pubB64, ":"); - pair = _t888; - const char* _t889; - _t889 = String_Concat(pair, privB64); - return _t889; + const char* _t879; + _t879 = String_Concat(pubB64, ":"); + pair = _t879; + const char* _t880; + _t880 = String_Concat(pair, privB64); + return _t880; } const char* Ed25519_Sign(const char* privKey, const char* data) { - unsigned int _t890; - int _t893; - int _t895; - const char* _t896; + unsigned int _t881; + int _t884; + int _t886; + const char* _t887; void* sig; - _t890 = (unsigned int)ED25519_SIG_SIZE; - void* _t891; - _t891 = Alloc(_t890); - sig = _t891; - unsigned int _t892; - _t892 = String_Len(data); - _t893 = (int)_t892; - int _t894; - _t894 = bux_ed25519_sign(privKey, data, _t893, sig); - _t895 = (_t894 != 1); - if (!_t895) goto endif315; + _t881 = (unsigned int)ED25519_SIG_SIZE; + void* _t882; + _t882 = Alloc(_t881); + sig = _t882; + unsigned int _t883; + _t883 = String_Len(data); + _t884 = (int)_t883; + int _t885; + _t885 = bux_ed25519_sign(privKey, data, _t884, sig); + _t886 = (_t885 != 1); + if (!_t886) goto endif302; { Free(sig); return ""; } - endif315:; - _t896 = (const char*)sig; - return _t896; + endif302:; + _t887 = (const char*)sig; + return _t887; } const char* Ed25519_SignBase64(const char* privKey, const char* data) { - int _t899; + int _t890; const char* sig; - const char* _t897; - _t897 = Ed25519_Sign(privKey, data); - sig = _t897; - unsigned int _t898; - _t898 = String_Len(sig); - _t899 = (_t898 == 0); - if (!_t899) goto endif317; + const char* _t888; + _t888 = Ed25519_Sign(privKey, data); + sig = _t888; + unsigned int _t889; + _t889 = String_Len(sig); + _t890 = (_t889 == 0); + if (!_t890) goto endif304; { return ""; } - endif317:; - const char* _t900; - _t900 = bux_base64_encode(sig, ED25519_SIG_SIZE); - return _t900; + endif304:; + const char* _t891; + _t891 = bux_base64_encode(sig, ED25519_SIG_SIZE); + return _t891; } bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data) { - int _t902; - int _t904; + int _t893; + int _t895; int r; - unsigned int _t901; - _t901 = String_Len(data); - _t902 = (int)_t901; - int _t903; - _t903 = bux_ed25519_verify(pubKey, signature, data, _t902); - r = _t903; - _t904 = (r == 1); - return _t904; + unsigned int _t892; + _t892 = String_Len(data); + _t893 = (int)_t892; + int _t894; + _t894 = bux_ed25519_verify(pubKey, signature, data, _t893); + r = _t894; + _t895 = (r == 1); + return _t895; } bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data) { - int _t906; - void* _t907; - int _t909; + int _t897; + void* _t898; + int _t900; int outlen; outlen = 0; const char* sig; - unsigned int _t905; - _t905 = String_Len(signatureB64); - _t906 = (int)_t905; - _t907 = &outlen; - const char* _t908; - _t908 = bux_base64_decode(signatureB64, _t906, _t907); - sig = _t908; - _t909 = (outlen != ED25519_SIG_SIZE); - if (!_t909) goto endif319; + unsigned int _t896; + _t896 = String_Len(signatureB64); + _t897 = (int)_t896; + _t898 = &outlen; + const char* _t899; + _t899 = bux_base64_decode(signatureB64, _t897, _t898); + sig = _t899; + _t900 = (outlen != ED25519_SIG_SIZE); + if (!_t900) goto endif306; { return 0; } - endif319:; - bool _t910; - _t910 = Ed25519_Verify(pubKey, sig, data); - return _t910; + endif306:; + bool _t901; + _t901 = Ed25519_Verify(pubKey, sig, data); + return _t901; } const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data) { - int _t912; - int _t914; - void* _t915; + int _t903; + int _t905; + void* _t906; int siglen; siglen = 0; - unsigned int _t911; - _t911 = String_Len(pemPrivateKey); - _t912 = (int)_t911; - unsigned int _t913; - _t913 = String_Len(data); - _t914 = (int)_t913; - _t915 = &siglen; - const char* _t916; - _t916 = bux_rsa_sign_sha256(pemPrivateKey, _t912, data, _t914, _t915); - return _t916; + unsigned int _t902; + _t902 = String_Len(pemPrivateKey); + _t903 = (int)_t902; + unsigned int _t904; + _t904 = String_Len(data); + _t905 = (int)_t904; + _t906 = &siglen; + const char* _t907; + _t907 = bux_rsa_sign_sha256(pemPrivateKey, _t903, data, _t905, _t906); + return _t907; } const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data) { - int _t918; - int _t920; - void* _t921; + int _t909; + int _t911; + void* _t912; int siglen; siglen = 0; - unsigned int _t917; - _t917 = String_Len(pemPrivateKey); - _t918 = (int)_t917; - unsigned int _t919; - _t919 = String_Len(data); - _t920 = (int)_t919; - _t921 = &siglen; - const char* _t922; - _t922 = bux_rsa_sign_sha384(pemPrivateKey, _t918, data, _t920, _t921); - return _t922; + unsigned int _t908; + _t908 = String_Len(pemPrivateKey); + _t909 = (int)_t908; + unsigned int _t910; + _t910 = String_Len(data); + _t911 = (int)_t910; + _t912 = &siglen; + const char* _t913; + _t913 = bux_rsa_sign_sha384(pemPrivateKey, _t909, data, _t911, _t912); + return _t913; } const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data) { - int _t924; - int _t926; - void* _t927; + int _t915; + int _t917; + void* _t918; int siglen; siglen = 0; - unsigned int _t923; - _t923 = String_Len(pemPrivateKey); - _t924 = (int)_t923; - unsigned int _t925; - _t925 = String_Len(data); - _t926 = (int)_t925; - _t927 = &siglen; - const char* _t928; - _t928 = bux_rsa_sign_sha512(pemPrivateKey, _t924, data, _t926, _t927); - return _t928; + unsigned int _t914; + _t914 = String_Len(pemPrivateKey); + _t915 = (int)_t914; + unsigned int _t916; + _t916 = String_Len(data); + _t917 = (int)_t916; + _t918 = &siglen; + const char* _t919; + _t919 = bux_rsa_sign_sha512(pemPrivateKey, _t915, data, _t917, _t918); + return _t919; } const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data) { - int _t931; + int _t922; const char* raw; - const char* _t929; - _t929 = Rsa_SignSha256(pemPrivateKey, data); - raw = _t929; - unsigned int _t930; - _t930 = String_Len(raw); - _t931 = (int)_t930; - const char* _t932; - _t932 = bux_base64_encode(raw, _t931); - return _t932; + const char* _t920; + _t920 = Rsa_SignSha256(pemPrivateKey, data); + raw = _t920; + unsigned int _t921; + _t921 = String_Len(raw); + _t922 = (int)_t921; + const char* _t923; + _t923 = bux_base64_encode(raw, _t922); + return _t923; } const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data) { - int _t935; + int _t926; const char* raw; - const char* _t933; - _t933 = Rsa_SignSha384(pemPrivateKey, data); - raw = _t933; - unsigned int _t934; - _t934 = String_Len(raw); - _t935 = (int)_t934; - const char* _t936; - _t936 = bux_base64_encode(raw, _t935); - return _t936; + const char* _t924; + _t924 = Rsa_SignSha384(pemPrivateKey, data); + raw = _t924; + unsigned int _t925; + _t925 = String_Len(raw); + _t926 = (int)_t925; + const char* _t927; + _t927 = bux_base64_encode(raw, _t926); + return _t927; } const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data) { - int _t939; + int _t930; const char* raw; - const char* _t937; - _t937 = Rsa_SignSha512(pemPrivateKey, data); - raw = _t937; - unsigned int _t938; - _t938 = String_Len(raw); - _t939 = (int)_t938; - const char* _t940; - _t940 = bux_base64_encode(raw, _t939); - return _t940; + const char* _t928; + _t928 = Rsa_SignSha512(pemPrivateKey, data); + raw = _t928; + unsigned int _t929; + _t929 = String_Len(raw); + _t930 = (int)_t929; + const char* _t931; + _t931 = bux_base64_encode(raw, _t930); + return _t931; } bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature) { - int _t942; - int _t944; - int _t946; - int _t948; + int _t933; + int _t935; + int _t937; + int _t939; int r; - unsigned int _t941; - _t941 = String_Len(pemPublicKey); - _t942 = (int)_t941; - unsigned int _t943; - _t943 = String_Len(data); - _t944 = (int)_t943; - unsigned int _t945; - _t945 = String_Len(signature); - _t946 = (int)_t945; - int _t947; - _t947 = bux_rsa_verify_sha256(pemPublicKey, _t942, data, _t944, signature, _t946); - r = _t947; - _t948 = (r == 1); - return _t948; + unsigned int _t932; + _t932 = String_Len(pemPublicKey); + _t933 = (int)_t932; + unsigned int _t934; + _t934 = String_Len(data); + _t935 = (int)_t934; + unsigned int _t936; + _t936 = String_Len(signature); + _t937 = (int)_t936; + int _t938; + _t938 = bux_rsa_verify_sha256(pemPublicKey, _t933, data, _t935, signature, _t937); + r = _t938; + _t939 = (r == 1); + return _t939; } bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature) { - int _t950; - int _t952; - int _t954; - int _t956; + int _t941; + int _t943; + int _t945; + int _t947; int r; - unsigned int _t949; - _t949 = String_Len(pemPublicKey); - _t950 = (int)_t949; - unsigned int _t951; - _t951 = String_Len(data); - _t952 = (int)_t951; - unsigned int _t953; - _t953 = String_Len(signature); - _t954 = (int)_t953; - int _t955; - _t955 = bux_rsa_verify_sha384(pemPublicKey, _t950, data, _t952, signature, _t954); - r = _t955; - _t956 = (r == 1); - return _t956; + unsigned int _t940; + _t940 = String_Len(pemPublicKey); + _t941 = (int)_t940; + unsigned int _t942; + _t942 = String_Len(data); + _t943 = (int)_t942; + unsigned int _t944; + _t944 = String_Len(signature); + _t945 = (int)_t944; + int _t946; + _t946 = bux_rsa_verify_sha384(pemPublicKey, _t941, data, _t943, signature, _t945); + r = _t946; + _t947 = (r == 1); + return _t947; } bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature) { - int _t958; - int _t960; - int _t962; - int _t964; + int _t949; + int _t951; + int _t953; + int _t955; int r; - unsigned int _t957; - _t957 = String_Len(pemPublicKey); - _t958 = (int)_t957; - unsigned int _t959; - _t959 = String_Len(data); - _t960 = (int)_t959; - unsigned int _t961; - _t961 = String_Len(signature); - _t962 = (int)_t961; - int _t963; - _t963 = bux_rsa_verify_sha512(pemPublicKey, _t958, data, _t960, signature, _t962); - r = _t963; - _t964 = (r == 1); - return _t964; + unsigned int _t948; + _t948 = String_Len(pemPublicKey); + _t949 = (int)_t948; + unsigned int _t950; + _t950 = String_Len(data); + _t951 = (int)_t950; + unsigned int _t952; + _t952 = String_Len(signature); + _t953 = (int)_t952; + int _t954; + _t954 = bux_rsa_verify_sha512(pemPublicKey, _t949, data, _t951, signature, _t953); + r = _t954; + _t955 = (r == 1); + return _t955; } bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t966; - void* _t967; + int _t957; + void* _t958; int outlen; outlen = 0; const char* sig; - unsigned int _t965; - _t965 = String_Len(signatureB64); - _t966 = (int)_t965; - _t967 = &outlen; - const char* _t968; - _t968 = bux_base64_decode(signatureB64, _t966, _t967); - sig = _t968; - bool _t969; - _t969 = Rsa_VerifySha256(pemPublicKey, data, sig); - return _t969; + unsigned int _t956; + _t956 = String_Len(signatureB64); + _t957 = (int)_t956; + _t958 = &outlen; + const char* _t959; + _t959 = bux_base64_decode(signatureB64, _t957, _t958); + sig = _t959; + bool _t960; + _t960 = Rsa_VerifySha256(pemPublicKey, data, sig); + return _t960; } bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t971; - void* _t972; + int _t962; + void* _t963; int outlen; outlen = 0; const char* sig; - unsigned int _t970; - _t970 = String_Len(signatureB64); - _t971 = (int)_t970; - _t972 = &outlen; - const char* _t973; - _t973 = bux_base64_decode(signatureB64, _t971, _t972); - sig = _t973; - bool _t974; - _t974 = Rsa_VerifySha384(pemPublicKey, data, sig); - return _t974; + unsigned int _t961; + _t961 = String_Len(signatureB64); + _t962 = (int)_t961; + _t963 = &outlen; + const char* _t964; + _t964 = bux_base64_decode(signatureB64, _t962, _t963); + sig = _t964; + bool _t965; + _t965 = Rsa_VerifySha384(pemPublicKey, data, sig); + return _t965; } bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t976; - void* _t977; + int _t967; + void* _t968; int outlen; outlen = 0; const char* sig; - unsigned int _t975; - _t975 = String_Len(signatureB64); - _t976 = (int)_t975; - _t977 = &outlen; - const char* _t978; - _t978 = bux_base64_decode(signatureB64, _t976, _t977); - sig = _t978; - bool _t979; - _t979 = Rsa_VerifySha512(pemPublicKey, data, sig); - return _t979; + unsigned int _t966; + _t966 = String_Len(signatureB64); + _t967 = (int)_t966; + _t968 = &outlen; + const char* _t969; + _t969 = bux_base64_decode(signatureB64, _t967, _t968); + sig = _t969; + bool _t970; + _t970 = Rsa_VerifySha512(pemPublicKey, data, sig); + return _t970; } int Rectangle_Area(Rectangle self) { - int _t982; - int _t980; - _t980 = self.width; - int _t981; - _t981 = self.height; - _t982 = _t980 * _t981; - return _t982; + int _t973; + int _t971; + _t971 = self.width; + int _t972; + _t972 = self.height; + _t973 = _t971 * _t972; + return _t973; } int Rectangle_Perimeter(Rectangle self) { - int _t985; - int _t986; - int _t983; - _t983 = self.width; - int _t984; - _t984 = self.height; - _t985 = _t983 + _t984; - _t986 = 2 * _t985; - return _t986; + int _t976; + int _t977; + int _t974; + _t974 = self.width; + int _t975; + _t975 = self.height; + _t976 = _t974 + _t975; + _t977 = 2 * _t976; + return _t977; } int Main(void) { - Rectangle _t987; + Rectangle _t978; Rectangle rect; - _t987 = (Rectangle){.width = 10, .height = 5}; - rect = _t987; + _t978 = (Rectangle){.width = 10, .height = 5}; + rect = _t978; PrintLine("Rectangle:"); PrintLine("Width = "); - int _t988; - _t988 = rect.width; - PrintInt(_t988); + int _t979; + _t979 = rect.width; + PrintInt(_t979); PrintLine(""); PrintLine("Height = "); - int _t989; - _t989 = rect.height; - PrintInt(_t989); + int _t980; + _t980 = rect.height; + PrintInt(_t980); PrintLine(""); PrintLine("Area = "); - int _t990; - _t990 = Rectangle_Area(rect); - PrintInt(_t990); + int _t981; + _t981 = Rectangle_Area(rect); + PrintInt(_t981); PrintLine(""); PrintLine("Perimeter = "); - int _t991; - _t991 = Rectangle_Perimeter(rect); - PrintInt(_t991); + int _t982; + _t982 = Rectangle_Perimeter(rect); + PrintInt(_t982); PrintLine(""); return 0; } diff --git a/tests/golden/modern_features/bux.toml b/tests/golden/modern_features/bux.toml new file mode 100644 index 0000000..22ab125 --- /dev/null +++ b/tests/golden/modern_features/bux.toml @@ -0,0 +1,7 @@ +[Package] +Name = "modern_features" +Version = "0.1.0" +Type = "bin" + +[Build] +Output = "Bin" diff --git a/tests/golden/modern_features/expected.c b/tests/golden/modern_features/expected.c new file mode 100644 index 0000000..a418ef0 --- /dev/null +++ b/tests/golden/modern_features/expected.c @@ -0,0 +1,5056 @@ +/* Generated by Bux Compiler (LIR backend) */ +#include +#include +#include +#include +#include + +typedef struct TaskHandle TaskHandle; +typedef struct Mutex Mutex; +typedef struct RwLock RwLock; +typedef struct JsonValue JsonValue; +typedef struct JsonParser JsonParser; +typedef struct StringBuilder StringBuilder; +typedef struct Record Record; +typedef struct Box Box; +typedef struct Channel_int Channel_int; +typedef struct Channel_float64 Channel_float64; +typedef struct Array_Record Array_Record; +typedef struct Iter_Record Iter_Record; + +typedef struct Drop_FatPtr Drop_FatPtr; + +/* Extern function declarations */ +extern int bux_dir_exists(const char* path); +extern int bux_mkdir_if_needed(const char* path); +extern const char** bux_list_dir(const char* dir, const char* ext, int* out_count); +extern void PrintLine(const char* s); +extern void Print(const char* s); +extern void PrintInt(int n); +extern void PrintInt64(int64_t n); +extern void PrintFloat(double f); +extern void PrintBool(bool b); +extern const char* ReadLine(void); +extern const char* bux_read_file(const char* path); +extern int bux_write_file(const char* path, const char* content); +extern int bux_file_exists(const char* path); +extern double bux_sqrt(double x); +extern double bux_pow(double x, double y); +extern int64_t bux_abs_i64(int64_t x); +extern double bux_abs_f64(double x); +extern int64_t bux_min_i64(int64_t a, int64_t b); +extern int64_t bux_max_i64(int64_t a, int64_t b); +extern double bux_min_f64(double a, double b); +extern double bux_max_f64(double a, double b); +extern void* bux_alloc(unsigned int size); +extern void* bux_realloc(void* ptr, unsigned int size); +extern void bux_free(void* ptr); +extern int bux_mem_eq(void* a, void* b, unsigned int size); +extern const char* bux_path_join(const char* a, const char* b); +extern const char* bux_path_parent(const char* path); +extern const char* bux_path_ext(const char* path); +extern void bux_task_init(int num_workers); +extern void* bux_task_spawn(void* fn, void* arg); +extern void bux_task_join(void* handle); +extern void bux_task_sleep(int64_t ms); +extern void bux_task_yield(void); +extern int bux_task_current_id(void); +extern void bux_task_shutdown(void); +extern int bux_argc(void); +extern const char* bux_argv(int index); +extern const char* bux_getenv(const char* name); +extern int bux_setenv(const char* name, const char* value); +extern const char* bux_getcwd(void); +extern int bux_chdir(const char* path); +extern int64_t bux_time_ms(void); +extern int64_t bux_time_us(void); +extern void bux_sleep_ms(int64_t ms); +extern int bux_process_run(const char* cmd); +extern const char* bux_process_output(const char* cmd); +extern int bux_socket_create(void); +extern int bux_socket_reuse(int fd); +extern int bux_socket_bind(int fd, const char* addr, int port); +extern int bux_socket_listen(int fd, int backlog); +extern int bux_socket_accept(int fd); +extern int bux_socket_connect(int fd, const char* addr, int port); +extern int bux_socket_send(int fd, const char* data, int len); +extern const char* bux_socket_recv(int fd, int maxLen); +extern int bux_socket_close(int fd); +extern const char* bux_socket_error(void); +extern unsigned int bux_strlen(const char* s); +extern int64_t bux_str_to_int(const char* s); +extern void* bux_alloc(unsigned int size); +extern void bux_sha256(const char* data, int len, void* out); +extern void bux_hmac_sha256(const char* key, int keylen, const char* msg, int msglen, void* out); +extern int bux_random_bytes(void* buf, int len); +extern const char* bux_base64_encode(const char* data, int len); +extern const char* bux_base64_decode(const char* data, int len, int* outlen); +extern const char* bux_bytes_to_hex(void* data, int len); +extern void* bux_mutex_new(void); +extern void bux_mutex_lock(void* handle); +extern void bux_mutex_unlock(void* handle); +extern void bux_mutex_free(void* handle); +extern void* bux_rwlock_new(void); +extern void bux_rwlock_rdlock(void* handle); +extern void bux_rwlock_wrlock(void* handle); +extern void bux_rwlock_unlock(void* handle); +extern void bux_rwlock_free(void* handle); +extern void bux_exit(int code); +extern void bux_assert(int cond, const char* file, int line, const char* expr); +extern JsonValue JsonParser_ParseValue(JsonParser* p); +extern unsigned int bux_strlen(const char* s); +extern int bux_strcmp(const char* a, const char* b); +extern int bux_strncmp(const char* a, const char* b, unsigned int n); +extern char* bux_strcpy(char* dest, const char* src); +extern char* bux_strcat(char* dest, const char* src); +extern char* bux_strncpy(char* dest, const char* src, unsigned int n); +extern const char* bux_strstr(const char* haystack, const char* needle); +extern int bux_str_contains(const char* haystack, const char* needle); +extern unsigned int bux_str_offset(const char* pos, const char* base); +extern int bux_str_is_null(const char* s); +extern const char* bux_str_slice(const char* s, unsigned int start, unsigned int len); +extern const char* bux_str_trim_left(const char* s); +extern const char* bux_str_trim_right(const char* s); +extern const char* bux_str_trim(const char* s); +extern const char* bux_int_to_str(int64_t n); +extern int64_t bux_str_to_int(const char* s); +extern void* bux_sb_new(unsigned int initial_cap); +extern void bux_sb_append(void* sb, const char* s); +extern void bux_sb_append_int(void* sb, int64_t n); +extern void bux_sb_append_float(void* sb, double f); +extern void bux_sb_append_char(void* sb, char c); +extern const char* bux_sb_build(void* sb); +extern void bux_sb_free(void* sb); +extern unsigned int bux_str_split_count(const char* s, const char* delim); +extern const char* bux_str_split_part(const char* s, const char* delim, unsigned int index); +extern const char* bux_str_join2(const char* a, const char* b, const char* sep); +extern const char* bux_float_to_string(double f); +extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7); +extern double bux_str_to_float(const char* s); +extern void bux_bounds_check(unsigned int index, unsigned int len); +extern void* bux_alloc(unsigned int size); +extern void* bux_realloc(void* ptr, unsigned int size); +extern void bux_free(void* ptr); +extern void bux_bounds_check(unsigned int index, unsigned int len); +extern void* bux_channel_new(int64_t capacity, int64_t elem_size); +extern void bux_channel_send(void* handle, void* elem); +extern int bux_channel_recv(void* handle, void* out); +extern void bux_channel_close(void* handle); +extern void bux_channel_free(void* handle); +extern unsigned int bux_hash_bytes(void* ptr, unsigned int size); +extern unsigned int bux_hash_string(const char* s); +extern unsigned int bux_hash_bytes(void* ptr, unsigned int size); +extern int bux_mem_eq(void* a, void* b, unsigned int size); +extern void* bux_alloc(unsigned int size); +extern void bux_free(void* ptr); +extern void bux_sha1(const char* data, int len, void* out); +extern void bux_sha256(const char* data, int len, void* out); +extern void bux_sha384(const char* data, int len, void* out); +extern void bux_sha512(const char* data, int len, void* out); +extern const char* bux_bytes_to_hex(void* data, int len); +extern const char* bux_base64_encode(const char* data, int len); +extern const char* bux_base64_decode(const char* data, int len, int* outlen); +extern const char* bux_base64url_encode(const char* data, int len); +extern const char* bux_base64url_decode(const char* data, int len, int* outlen); +extern void bux_hmac_sha256(const char* key, int keylen, const char* msg, int msglen, void* out); +extern void bux_hmac_sha384(const char* key, int keylen, const char* msg, int msglen, void* out); +extern void bux_hmac_sha512(const char* key, int keylen, const char* msg, int msglen, void* out); +extern const char* bux_bytes_to_hex(void* data, int len); +extern const char* bux_base64_encode(const char* data, int len); +extern int bux_random_bytes(void* buf, int len); +extern const char* bux_base64_encode(const char* data, int len); +extern const char* bux_bytes_to_hex(void* data, int len); +extern int bux_random_bytes(void* buf, int len); +extern const char* bux_aes_256_cbc_encrypt(const char* plain, int plainlen, const char* key, const char* iv, int* outlen); +extern const char* bux_aes_256_cbc_decrypt(const char* cipher, int cipherlen, const char* key, const char* iv, int* outlen); +extern const char* bux_aes_256_gcm_encrypt(const char* plain, int plainlen, const char* key, const char* iv, void* tag, int* outlen); +extern const char* bux_aes_256_gcm_decrypt(const char* cipher, int cipherlen, const char* key, const char* iv, const char* tag, int* outlen); +extern const char* bux_base64_encode(const char* data, int len); +extern unsigned int bux_str_split_count(const char* s, const char* delim); +extern const char* bux_str_split_part(const char* s, const char* delim, unsigned int index); +extern const char* bux_ecdsa_sign_p256(const char* key, int keylen, const char* data, int datalen, int* outlen); +extern int bux_ecdsa_verify_p256(const char* key, int keylen, const char* data, int datalen, const char* sig, int siglen); +extern const char* bux_ecdsa_sign_p384(const char* key, int keylen, const char* data, int datalen, int* outlen); +extern int bux_ecdsa_verify_p384(const char* key, int keylen, const char* data, int datalen, const char* sig, int siglen); +extern const char* bux_base64_encode(const char* data, int len); +extern const char* bux_base64_decode(const char* data, int len, int* outlen); +extern int bux_ed25519_keypair(void* pubKey, void* privKey); +extern int bux_ed25519_sign(const char* privKey, const char* data, int datalen, void* sig); +extern int bux_ed25519_verify(const char* pubKey, const char* sig, const char* data, int datalen); +extern const char* bux_base64_encode(const char* data, int len); +extern const char* bux_base64_decode(const char* data, int len, int* outlen); +extern const char* bux_rsa_sign_sha256(const char* key, int keylen, const char* data, int datalen, int* outlen); +extern const char* bux_rsa_sign_sha384(const char* key, int keylen, const char* data, int datalen, int* outlen); +extern const char* bux_rsa_sign_sha512(const char* key, int keylen, const char* data, int datalen, int* outlen); +extern int bux_rsa_verify_sha256(const char* key, int keylen, const char* data, int datalen, const char* sig, int siglen); +extern int bux_rsa_verify_sha384(const char* key, int keylen, const char* data, int datalen, const char* sig, int siglen); +extern int bux_rsa_verify_sha512(const char* key, int keylen, const char* data, int datalen, const char* sig, int siglen); +extern const char* bux_base64_encode(const char* data, int len); +extern const char* bux_base64_decode(const char* data, int len, int* outlen); + +/* Constants */ +#define JsonTagNull 0 +#define JsonTagBool 1 +#define JsonTagNumber 2 +#define JsonTagString 3 +#define JsonTagArray 4 +#define JsonTagObject 5 +#define AES_KEY_SIZE 32 +#define AES_IV_SIZE 16 +#define AES_GCM_TAG_SIZE 16 +#define ED25519_PUBKEY_SIZE 32 +#define ED25519_PRIVKEY_SIZE 32 +#define ED25519_SIG_SIZE 64 + +typedef struct Channel_float64 { + void* handle; +} Channel_float64; + +typedef struct Iter_Record { + Record* data; + unsigned int len; + unsigned int pos; +} Iter_Record; + +typedef struct TaskHandle { + void* handle; +} TaskHandle; + +typedef struct Record { + const char* name; + int value; +} Record; + +typedef enum { + Payload_Ok, + Payload_Err +} Payload_Tag; + +typedef union { + Record Ok_0; + const char* Err_0; +} Payload_Data; + +typedef struct { + Payload_Tag tag; + Payload_Data data; +} Payload; + +typedef struct RwLock { + void* handle; +} RwLock; + +typedef enum { + Color_Red, + Color_Green +} Color; + +typedef struct Channel_int { + void* handle; +} Channel_int; + +typedef enum { + JwtAlg_HS256, + JwtAlg_HS384, + JwtAlg_HS512, + JwtAlg_RS256, + JwtAlg_RS384, + JwtAlg_RS512, + JwtAlg_ES256, + JwtAlg_ES384, + JwtAlg_EdDSA +} JwtAlg; + +typedef enum { + Result_Ok, + Result_Err +} Result_Tag; + +typedef union { + int Ok_0; + const char* Err_0; +} Result_Data; + +typedef struct { + Result_Tag tag; + Result_Data data; +} Result; + +typedef enum { + Option_Some, + Option_None +} Option_Tag; + +typedef union { + int Some_0; +} Option_Data; + +typedef struct { + Option_Tag tag; + Option_Data data; +} Option; + +typedef struct JsonValue { + int tag; + bool boolVal; + double numVal; + const char* strVal; + JsonValue* arrData; + unsigned int arrLen; + unsigned int arrCap; + const char** objKeys; + JsonValue* objValues; + unsigned int objLen; + unsigned int objCap; +} JsonValue; + +typedef struct Mutex { + void* handle; +} Mutex; + +typedef struct StringBuilder { + void* handle; +} StringBuilder; + +typedef struct Array_Record { + Record* data; + unsigned int len; + unsigned int cap; +} Array_Record; + +typedef struct Box { + Array_Record items; +} Box; + +typedef struct JsonParser { + const char* src; + unsigned int pos; + unsigned int len; + const char* error; +} JsonParser; + +bool DirExists(const char* path); +bool Mkdir(const char* path); +const char** ListDir(const char* dir, const char* ext, int* count); +const char* ReadFile(const char* path); +bool WriteFile(const char* path, const char* content); +bool FileExists(const char* path); +double Sqrt(double x); +double Pow(double x, double y); +int64_t Abs(int64_t n); +double AbsF(double f); +int64_t Min(int64_t a, int64_t b); +int64_t Max(int64_t a, int64_t b); +double MinF(double a, double b); +double MaxF(double a, double b); +void* Alloc(unsigned int size); +void* Realloc(void* ptr, unsigned int size); +void Free(void* ptr); +bool MemEq(void* a, void* b, unsigned int size); +const char* Path_Join(const char* a, const char* b); +const char* Path_Parent(const char* path); +const char* Path_Ext(const char* path); +void Task_Init(int num_workers); +TaskHandle Task_Spawn(void* fn, void* arg); +void Task_Wait(TaskHandle t); +void Task_Sleep(int64_t ms); +void Task_Yield(void); +int Task_CurrentId(void); +void Task_Shutdown(void); +int Os_ArgsCount(void); +const char* Os_Args(int index); +const char* Os_GetEnv(const char* name); +bool Os_SetEnv(const char* name, const char* value); +const char* Os_GetCwd(void); +bool Os_Chdir(const char* path); +int64_t Time_NowMs(void); +int64_t Time_NowUs(void); +void Time_SleepMs(int64_t ms); +int Process_Run(const char* cmd); +const char* Process_Output(const char* cmd); +int Net_Create(void); +bool Net_SetReuse(int fd); +bool Net_Bind(int fd, const char* addr, int port); +bool Net_Listen(int fd, int backlog); +int Net_Accept(int fd); +bool Net_Connect(int fd, const char* addr, int port); +int Net_Send(int fd, const char* data); +const char* Net_Recv(int fd, int maxLen); +bool Net_Close(int fd); +const char* Net_LastError(void); +const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount); +const char* Fmt_Fmt1(const char* tmpl, const char* a1); +const char* Fmt_FmtInt(const char* tmpl, int64_t val); +const char* Fmt_FmtBool(const char* tmpl, bool val); +const char* Fmt_FmtFloat(const char* tmpl, double val); +const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2); +const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3); +const char* Crypto_Sha256(const char* data); +const char* Crypto_HmacSha256(const char* key, const char* message); +const char* Crypto_RandomBytes(int n); +const char* Crypto_Base64Encode(const char* s); +const char* Crypto_HmacSha256Raw(const char* key, const char* message); +const char* Crypto_Base64Decode(const char* s); +Mutex Mutex_New(void); +void Mutex_Lock(Mutex* m); +void Mutex_Unlock(Mutex* m); +void Mutex_Free(Mutex* m); +RwLock RwLock_New(void); +void RwLock_ReadLock(RwLock* rw); +void RwLock_WriteLock(RwLock* rw); +void RwLock_Unlock(RwLock* rw); +void RwLock_Free(RwLock* rw); +void Test_Exit(int code); +void Test_Assert(bool cond); +void Test_AssertEqInt(int a, int b); +void Test_AssertTrue(bool cond); +void Test_AssertFalse(bool cond); +void Test_Fail(const char* msg); +Result Result_NewOk(int value); +Result Result_NewErr(const char* msg); +bool Result_IsOk(Result r); +bool Result_IsErr(Result r); +int Result_Unwrap(Result r); +int Result_UnwrapOr(Result r, int fallback); +Option Option_NewSome(int value); +Option Option_NewNone(void); +bool Option_IsSome(Option o); +bool Option_IsNone(Option o); +int Option_Unwrap(Option o); +int Option_UnwrapOr(Option o, int fallback); +JsonValue Json_Null(void); +JsonValue Json_Bool(bool b); +JsonValue Json_Number(double n); +JsonValue Json_String(const char* s); +JsonValue Json_Array(void); +JsonValue Json_Object(void); +unsigned int Json_ArrayLen(JsonValue v); +JsonValue Json_ArrayGet(JsonValue v, unsigned int index); +void Json_ArrayPush(JsonValue* self, JsonValue val); +unsigned int Json_ObjectLen(JsonValue v); +JsonValue Json_ObjectGet(JsonValue v, const char* key); +bool Json_ObjectHas(JsonValue v, const char* key); +void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val); +bool Json_IsNull(JsonValue v); +bool Json_AsBool(JsonValue v); +double Json_AsNumber(JsonValue v); +const char* Json_AsString(JsonValue v); +int JsonParser_Peek(JsonParser* p); +void JsonParser_Advance(JsonParser* p); +void JsonParser_SkipWhitespace(JsonParser* p); +bool JsonParser_Match(JsonParser* p, const char* expected); +const char* JsonParser_ParseString(JsonParser* p); +JsonValue JsonParser_ParseNumber(JsonParser* p); +JsonValue JsonParser_ParseArray(JsonParser* p); +JsonValue JsonParser_ParseObject(JsonParser* p); +JsonValue JsonParser_ParseValue(JsonParser* p); +JsonValue Json_Parse(const char* s); +void Json_StringifyImpl(StringBuilder* sb, JsonValue v); +const char* Json_Stringify(JsonValue v); +unsigned int String_Len(const char* s); +bool String_IsNull(const char* s); +bool String_Eq(const char* a, const char* b); +const char* String_Concat(const char* a, const char* b); +const char* String_Copy(const char* s); +bool String_StartsWith(const char* s, const char* prefix); +bool String_EndsWith(const char* s, const char* suffix); +bool String_Contains(const char* s, const char* substr); +const char* String_Slice(const char* s, unsigned int start, unsigned int len); +const char* String_Trim(const char* s); +const char* String_TrimLeft(const char* s); +const char* String_TrimRight(const char* s); +const char* String_FromInt(int64_t n); +int64_t String_ToInt(const char* s); +StringBuilder StringBuilder_New(void); +StringBuilder StringBuilder_NewCap(unsigned int cap); +void StringBuilder_Append(StringBuilder* sb, const char* s); +void StringBuilder_AppendInt(StringBuilder* sb, int64_t n); +void StringBuilder_AppendFloat(StringBuilder* sb, double f); +void StringBuilder_AppendChar(StringBuilder* sb, char c); +const char* StringBuilder_Build(StringBuilder* sb); +void StringBuilder_Free(StringBuilder* sb); +unsigned int String_SplitCount(const char* s, const char* delim); +const char* String_SplitPart(const char* s, const char* delim, unsigned int index); +const char* String_Join2(const char* a, const char* b, const char* sep); +const char* String_Chars(const char* s, unsigned int index); +const char* String_Find(const char* haystack, const char* needle); +unsigned int String_Offset(const char* pos, const char* base); +const char* String_Replace(const char* s, const char* old, const char* new); +double String_ToFloat(const char* s); +const char* String_FromBool(bool b); +const char* String_FromFloat(double f); +const char* String_Format1(const char* pattern, const char* a0); +const char* String_Format2(const char* pattern, const char* a0, const char* a1); +const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2); +void Channel_SendInt(Channel_int* ch, int value); +int Channel_RecvInt(Channel_int* ch); +void Channel_SendFloat64(Channel_float64* ch, double value); +double Channel_RecvFloat64(Channel_float64* ch); +const char* Hash_Sha1(const char* data); +const char* Hash_Sha256(const char* data); +const char* Hash_Sha384(const char* data); +const char* Hash_Sha512(const char* data); +void Hash_Sha256Raw(const char* data, void* out); +void Hash_Sha384Raw(const char* data, void* out); +void Hash_Sha512Raw(const char* data, void* out); +int Hash_Sha1Size(void); +int Hash_Sha256Size(void); +int Hash_Sha384Size(void); +int Hash_Sha512Size(void); +const char* Base64_Encode(const char* s); +const char* Base64_Decode(const char* s); +const char* Base64URL_Encode(const char* s); +const char* Base64URL_Decode(const char* s); +const char* Hmac_Sha256(const char* key, const char* message); +void Hmac_Sha256Raw(const char* key, const char* message, void* out); +const char* Hmac_Sha256Base64(const char* key, const char* message); +const char* Hmac_Sha384(const char* key, const char* message); +void Hmac_Sha384Raw(const char* key, const char* message, void* out); +const char* Hmac_Sha384Base64(const char* key, const char* message); +const char* Hmac_Sha512(const char* key, const char* message); +void Hmac_Sha512Raw(const char* key, const char* message, void* out); +const char* Hmac_Sha512Base64(const char* key, const char* message); +const char* Random_Bytes(int n); +const char* Random_Hex(int n); +const char* Random_Base64(int n); +unsigned int Random_Uint32(void); +const char* Aes_GenerateKey(void); +const char* Aes_GenerateIV(void); +const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv); +const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv); +const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag); +const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag); +const char* Jwt_MakeHeader(JwtAlg alg); +const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key); +bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key); +const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key); +bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut); +const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret); +const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret); +const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret); +const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey); +const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey); +const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey); +const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data); +const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data); +bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature); +bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64); +const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data); +const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data); +bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature); +bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64); +bool Ed25519_Keypair(void* pubKey, void* privKey); +const char* Ed25519_KeypairBase64(void); +const char* Ed25519_Sign(const char* privKey, const char* data); +const char* Ed25519_SignBase64(const char* privKey, const char* data); +bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data); +bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data); +const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data); +const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data); +const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data); +const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data); +const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data); +const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data); +bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature); +bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature); +bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature); +bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64); +bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64); +bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64); +const char* Name(Color c); +int Main(void); +Array_Record Array_New_Record(unsigned int cap); +void Array_Push_Record(Array_Record* self, Record value); +Iter_Record Array_Iter_Record(Array_Record* arr); +bool Iter_HasNext_Record(Iter_Record* it); +Record Iter_Next_Record(Iter_Record* it); + +typedef struct Drop_VTable { + void (*Drop)(void* self); +} Drop_VTable; +typedef struct Drop_FatPtr { + void* data; + Drop_VTable* vtable; +} Drop_FatPtr; + +bool DirExists(const char* path) { + int _t2; + int _t1; + _t1 = bux_dir_exists(path); + _t2 = (_t1 != 0); + return _t2; +} + +bool Mkdir(const char* path) { + int _t4; + int _t3; + _t3 = bux_mkdir_if_needed(path); + _t4 = (_t3 != 0); + return _t4; +} + +const char** ListDir(const char* dir, const char* ext, int* count) { + const char** _t5; + _t5 = bux_list_dir(dir, ext, count); + return _t5; +} + +const char* ReadFile(const char* path) { + const char* _t6; + _t6 = bux_read_file(path); + return _t6; +} + +bool WriteFile(const char* path, const char* content) { + int _t8; + int r; + int _t7; + _t7 = bux_write_file(path, content); + r = _t7; + _t8 = (r != 0); + return _t8; +} + +bool FileExists(const char* path) { + int _t10; + int r; + int _t9; + _t9 = bux_file_exists(path); + r = _t9; + _t10 = (r != 0); + return _t10; +} + +double Sqrt(double x) { + double _t11; + _t11 = bux_sqrt(x); + return _t11; +} + +double Pow(double x, double y) { + double _t12; + _t12 = bux_pow(x, y); + return _t12; +} + +int64_t Abs(int64_t n) { + int64_t _t13; + _t13 = bux_abs_i64(n); + return _t13; +} + +double AbsF(double f) { + double _t14; + _t14 = bux_abs_f64(f); + return _t14; +} + +int64_t Min(int64_t a, int64_t b) { + int64_t _t15; + _t15 = bux_min_i64(a, b); + return _t15; +} + +int64_t Max(int64_t a, int64_t b) { + int64_t _t16; + _t16 = bux_max_i64(a, b); + return _t16; +} + +double MinF(double a, double b) { + double _t17; + _t17 = bux_min_f64(a, b); + return _t17; +} + +double MaxF(double a, double b) { + double _t18; + _t18 = bux_max_f64(a, b); + return _t18; +} + +void* Alloc(unsigned int size) { + void* _t19; + _t19 = bux_alloc(size); + return _t19; +} + +void* Realloc(void* ptr, unsigned int size) { + void* _t20; + _t20 = bux_realloc(ptr, size); + return _t20; +} + +void Free(void* ptr) { + bux_free(ptr); +} + +bool MemEq(void* a, void* b, unsigned int size) { + int _t22; + int _t21; + _t21 = bux_mem_eq(a, b, size); + _t22 = (_t21 != 0); + return _t22; +} + +const char* Path_Join(const char* a, const char* b) { + const char* _t23; + _t23 = bux_path_join(a, b); + return _t23; +} + +const char* Path_Parent(const char* path) { + const char* _t24; + _t24 = bux_path_parent(path); + return _t24; +} + +const char* Path_Ext(const char* path) { + const char* _t25; + _t25 = bux_path_ext(path); + return _t25; +} + +void Task_Init(int num_workers) { + bux_task_init(num_workers); +} + +TaskHandle Task_Spawn(void* fn, void* arg) { + TaskHandle _t27; + void* _t26; + _t26 = bux_task_spawn(fn, arg); + _t27 = (TaskHandle){.handle = _t26}; + return _t27; +} + +void Task_Wait(TaskHandle t) { + void* _t28; + _t28 = t.handle; + bux_task_join(_t28); +} + +void Task_Sleep(int64_t ms) { + bux_task_sleep(ms); +} + +void Task_Yield(void) { + bux_task_yield(); +} + +int Task_CurrentId(void) { + int _t29; + _t29 = bux_task_current_id(); + return _t29; +} + +void Task_Shutdown(void) { + bux_task_shutdown(); +} + +int Os_ArgsCount(void) { + int _t30; + _t30 = bux_argc(); + return _t30; +} + +const char* Os_Args(int index) { + const char* _t31; + _t31 = bux_argv(index); + return _t31; +} + +const char* Os_GetEnv(const char* name) { + const char* _t32; + _t32 = bux_getenv(name); + return _t32; +} + +bool Os_SetEnv(const char* name, const char* value) { + int _t34; + int _t33; + _t33 = bux_setenv(name, value); + _t34 = (_t33 == 0); + return _t34; +} + +const char* Os_GetCwd(void) { + const char* _t35; + _t35 = bux_getcwd(); + return _t35; +} + +bool Os_Chdir(const char* path) { + int _t37; + int _t36; + _t36 = bux_chdir(path); + _t37 = (_t36 == 0); + return _t37; +} + +int64_t Time_NowMs(void) { + int64_t _t38; + _t38 = bux_time_ms(); + return _t38; +} + +int64_t Time_NowUs(void) { + int64_t _t39; + _t39 = bux_time_us(); + return _t39; +} + +void Time_SleepMs(int64_t ms) { + bux_sleep_ms(ms); +} + +int Process_Run(const char* cmd) { + int _t40; + _t40 = bux_process_run(cmd); + return _t40; +} + +const char* Process_Output(const char* cmd) { + const char* _t41; + _t41 = bux_process_output(cmd); + return _t41; +} + +int Net_Create(void) { + int _t42; + _t42 = bux_socket_create(); + return _t42; +} + +bool Net_SetReuse(int fd) { + int _t44; + int _t43; + _t43 = bux_socket_reuse(fd); + _t44 = (_t43 == 0); + return _t44; +} + +bool Net_Bind(int fd, const char* addr, int port) { + int _t46; + int _t45; + _t45 = bux_socket_bind(fd, addr, port); + _t46 = (_t45 == 0); + return _t46; +} + +bool Net_Listen(int fd, int backlog) { + int _t48; + int _t47; + _t47 = bux_socket_listen(fd, backlog); + _t48 = (_t47 == 0); + return _t48; +} + +int Net_Accept(int fd) { + int _t49; + _t49 = bux_socket_accept(fd); + return _t49; +} + +bool Net_Connect(int fd, const char* addr, int port) { + int _t51; + int _t50; + _t50 = bux_socket_connect(fd, addr, port); + _t51 = (_t50 == 0); + return _t51; +} + +int Net_Send(int fd, const char* data) { + int _t53; + unsigned int _t52; + _t52 = bux_strlen(data); + _t53 = (int)_t52; + int _t54; + _t54 = bux_socket_send(fd, data, _t53); + return _t54; +} + +const char* Net_Recv(int fd, int maxLen) { + const char* _t55; + _t55 = bux_socket_recv(fd, maxLen); + return _t55; +} + +bool Net_Close(int fd) { + int _t57; + int _t56; + _t56 = bux_socket_close(fd); + _t57 = (_t56 == 0); + return _t57; +} + +const char* Net_LastError(void) { + const char* _t58; + _t58 = bux_socket_error(); + return _t58; +} + +const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { + int _t61; + int _t64; + int _t65; + int _t68; + int64_t _t69; + int _t70; + int _t72; + int _t73; + int _t76; + unsigned int _t77; + void* _t79; + void* _t80; + int _t81; + void* _t82; + StringBuilder sb; + StringBuilder _t59; + _t59 = StringBuilder_New(); + sb = _t59; + unsigned int i; + i = 0; + unsigned int tmplLen; + unsigned int _t60; + _t60 = bux_strlen(tmpl); + tmplLen = _t60; + while1:; + _t61 = (i < tmplLen); + if (!_t61) goto wend2; + { + const char* ch; + const char* _t62; + _t62 = String_Chars(tmpl, i); + ch = _t62; + bool _t63; + _t63 = String_Eq(ch, "{"); + if (!_t63) goto endif4; + { + unsigned int digitIdx; + _t64 = i + 1; + digitIdx = _t64; + _t65 = (digitIdx < tmplLen); + if (!_t65) goto endif6; + { + const char* digitCh; + const char* _t66; + _t66 = String_Chars(tmpl, digitIdx); + digitCh = _t66; + int64_t d; + int64_t _t67; + _t67 = bux_str_to_int(digitCh); + d = _t67; + bool __and_tmp_0; + _t68 = (d >= 0); + if (!_t68) goto else7; + _t69 = (int64_t)argCount; + _t70 = (d < _t69); + *(bool*)&__and_tmp_0 = _t70; + goto endif8; + else7:; + *(bool*)&__and_tmp_0 = 0; + endif8:; + bool _t71; + _t71 = *(bool*)&__and_tmp_0; + if (!_t71) goto endif10; + { + _t72 = i + 2; + i = _t72; + _t73 = (i < tmplLen); + if (!_t73) goto endif12; + { + const char* closeCh; + const char* _t74; + _t74 = String_Chars(tmpl, i); + closeCh = _t74; + bool _t75; + _t75 = String_Eq(closeCh, "}"); + if (!_t75) goto endif14; + { + _t76 = i + 1; + i = _t76; + const char* argStr; + _t77 = (unsigned int)d; + const char* _t78; + _t78 = argStrs[_t77]; + argStr = _t78; + _t79 = &sb; + StringBuilder_Append(_t79, argStr); + goto while1; + } + endif14:; + } + endif12:; + } + endif10:; + } + endif6:; + } + endif4:; + _t80 = &sb; + StringBuilder_Append(_t80, ch); + _t81 = i + 1; + i = _t81; + } + goto while1; + wend2:; + _t82 = &sb; + const char* _t83; + _t83 = StringBuilder_Build(_t82); + return _t83; +} + +const char* Fmt_Fmt1(const char* tmpl, const char* a1) { + const char** _t85; + const char** args; + /* sizeof(const char*) */ + void* _t84; + _t84 = bux_alloc(sizeof(const char*)); + _t85 = (const char**)_t84; + args = _t85; + args[0] = a1; + const char* _t86; + _t86 = Fmt_Format(tmpl, args, 1); + return _t86; +} + +const char* Fmt_FmtInt(const char* tmpl, int64_t val) { + const char* s; + const char* _t87; + _t87 = String_FromInt(val); + s = _t87; + const char* _t88; + _t88 = Fmt_Fmt1(tmpl, s); + return _t88; +} + +const char* Fmt_FmtBool(const char* tmpl, bool val) { + const char* s; + const char* _t89; + _t89 = String_FromBool(val); + s = _t89; + const char* _t90; + _t90 = Fmt_Fmt1(tmpl, s); + return _t90; +} + +const char* Fmt_FmtFloat(const char* tmpl, double val) { + const char* s; + const char* _t91; + _t91 = String_FromFloat(val); + s = _t91; + const char* _t92; + _t92 = Fmt_Fmt1(tmpl, s); + return _t92; +} + +const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2) { + int _t93; + const char** _t95; + const char** args; + /* sizeof(const char*) */ + _t93 = 2 * sizeof(const char*); + void* _t94; + _t94 = bux_alloc(_t93); + _t95 = (const char**)_t94; + args = _t95; + args[0] = a1; + args[1] = a2; + const char* _t96; + _t96 = Fmt_Format(tmpl, args, 2); + return _t96; +} + +const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3) { + int _t97; + const char** _t99; + const char** args; + /* sizeof(const char*) */ + _t97 = 3 * sizeof(const char*); + void* _t98; + _t98 = bux_alloc(_t97); + _t99 = (const char**)_t98; + args = _t99; + args[0] = a1; + args[1] = a2; + args[2] = a3; + const char* _t100; + _t100 = Fmt_Format(tmpl, args, 3); + return _t100; +} + +const char* Crypto_Sha256(const char* data) { + int _t102; + void* _t104; + int len; + unsigned int _t101; + _t101 = String_Len(data); + _t102 = (int)_t101; + len = _t102; + void* hashBuf; + void* _t103; + _t103 = Alloc(32); + hashBuf = _t103; + bux_sha256(data, len, hashBuf); + const char* result; + _t104 = (void*)hashBuf; + const char* _t105; + _t105 = bux_bytes_to_hex(_t104, 32); + result = _t105; + Free(hashBuf); + return result; +} + +const char* Crypto_HmacSha256(const char* key, const char* message) { + int _t107; + int _t109; + void* _t111; + int keylen; + unsigned int _t106; + _t106 = String_Len(key); + _t107 = (int)_t106; + keylen = _t107; + int msglen; + unsigned int _t108; + _t108 = String_Len(message); + _t109 = (int)_t108; + msglen = _t109; + void* hmacBuf; + void* _t110; + _t110 = Alloc(32); + hmacBuf = _t110; + bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); + const char* result; + _t111 = (void*)hmacBuf; + const char* _t112; + _t112 = bux_bytes_to_hex(_t111, 32); + result = _t112; + Free(hmacBuf); + return result; +} + +const char* Crypto_RandomBytes(int n) { + int _t113; + unsigned int _t114; + int _t117; + const char* _t118; + _t113 = (n <= 0); + if (!_t113) goto endif16; + { + return ""; + } + endif16:; + void* buf; + _t114 = (unsigned int)n; + void* _t115; + _t115 = Alloc(_t114); + buf = _t115; + int _t116; + _t116 = bux_random_bytes(buf, n); + _t117 = (_t116 != 1); + if (!_t117) goto endif18; + { + Free(buf); + return ""; + } + endif18:; + const char* result; + _t118 = (const char*)buf; + const char* _t119; + _t119 = bux_base64_encode(_t118, n); + result = _t119; + Free(buf); + return result; +} + +const char* Crypto_Base64Encode(const char* s) { + int _t121; + unsigned int _t120; + _t120 = String_Len(s); + _t121 = (int)_t120; + const char* _t122; + _t122 = bux_base64_encode(s, _t121); + return _t122; +} + +const char* Crypto_HmacSha256Raw(const char* key, const char* message) { + int _t124; + int _t126; + const char* _t128; + int keylen; + unsigned int _t123; + _t123 = String_Len(key); + _t124 = (int)_t123; + keylen = _t124; + int msglen; + unsigned int _t125; + _t125 = String_Len(message); + _t126 = (int)_t125; + msglen = _t126; + void* hmacBuf; + void* _t127; + _t127 = Alloc(32); + hmacBuf = _t127; + bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); + const char* result; + _t128 = (const char*)hmacBuf; + const char* _t129; + _t129 = bux_base64_encode(_t128, 32); + result = _t129; + Free(hmacBuf); + return result; +} + +const char* Crypto_Base64Decode(const char* s) { + int _t131; + void* _t132; + int outlen; + outlen = 0; + unsigned int _t130; + _t130 = String_Len(s); + _t131 = (int)_t130; + _t132 = &outlen; + const char* _t133; + _t133 = bux_base64_decode(s, _t131, _t132); + return _t133; +} + +Mutex Mutex_New(void) { + Mutex _t135; + void* _t134; + _t134 = bux_mutex_new(); + _t135 = (Mutex){.handle = _t134}; + return _t135; +} + +void Mutex_Lock(Mutex* m) { + void* _t136; + _t136 = m->handle; + bux_mutex_lock(_t136); +} + +void Mutex_Unlock(Mutex* m) { + void* _t137; + _t137 = m->handle; + bux_mutex_unlock(_t137); +} + +void Mutex_Free(Mutex* m) { + void* _t138; + _t138 = m->handle; + bux_mutex_free(_t138); +} + +RwLock RwLock_New(void) { + RwLock _t140; + void* _t139; + _t139 = bux_rwlock_new(); + _t140 = (RwLock){.handle = _t139}; + return _t140; +} + +void RwLock_ReadLock(RwLock* rw) { + void* _t141; + _t141 = rw->handle; + bux_rwlock_rdlock(_t141); +} + +void RwLock_WriteLock(RwLock* rw) { + void* _t142; + _t142 = rw->handle; + bux_rwlock_wrlock(_t142); +} + +void RwLock_Unlock(RwLock* rw) { + void* _t143; + _t143 = rw->handle; + bux_rwlock_unlock(_t143); +} + +void RwLock_Free(RwLock* rw) { + void* _t144; + _t144 = rw->handle; + bux_rwlock_free(_t144); +} + +void Test_Exit(int code) { + bux_exit(code); +} + +void Test_Assert(bool cond) { + int _t145; + _t145 = (int)cond; + bux_assert(_t145, "", 0, ""); +} + +void Test_AssertEqInt(int a, int b) { + int _t146; + _t146 = (a != b); + if (!_t146) goto endif20; + { + PrintLine("ASSERT_EQ FAILED:"); + PrintInt(a); + PrintLine(" != "); + PrintInt(b); + bux_exit(1); + } + endif20:; +} + +void Test_AssertTrue(bool cond) { + int _t147; + _t147 = !cond; + if (!_t147) goto endif22; + { + PrintLine("ASSERT_TRUE FAILED"); + bux_exit(1); + } + endif22:; +} + +void Test_AssertFalse(bool cond) { + if (!cond) goto endif24; + { + PrintLine("ASSERT_FALSE FAILED"); + bux_exit(1); + } + endif24:; +} + +void Test_Fail(const char* msg) { + PrintLine("FAIL:"); + PrintLine(msg); + bux_exit(1); +} + +Result Result_NewOk(int value) { + Result _t148; + Result r; + _t148 = (Result){.tag = Result_Ok}; + r = _t148; + r.data.Ok_0 = value; + return r; +} + +Result Result_NewErr(const char* msg) { + Result _t149; + Result r; + _t149 = (Result){.tag = Result_Err}; + r = _t149; + r.data.Err_0 = msg; + return r; +} + +bool Result_IsOk(Result r) { + int _t151; + Result_Tag _t150; + _t150 = r.tag; + _t151 = (_t150 == Result_Ok); + return _t151; +} + +bool Result_IsErr(Result r) { + int _t153; + Result_Tag _t152; + _t152 = r.tag; + _t153 = (_t152 == Result_Err); + return _t153; +} + +int Result_Unwrap(Result r) { + int _t155; + Result_Tag _t154; + _t154 = r.tag; + _t155 = (_t154 != Result_Ok); + if (!_t155) goto endif26; + { + PrintLine("panic: unwrap on Err"); + return 0; + } + endif26:; + Result_Data _t156; + _t156 = r.data; + int _t157; + _t157 = _t156.Ok_0; + return _t157; +} + +int Result_UnwrapOr(Result r, int fallback) { + int _t159; + Result_Tag _t158; + _t158 = r.tag; + _t159 = (_t158 == Result_Ok); + if (!_t159) goto endif28; + { + Result_Data _t160; + _t160 = r.data; + int _t161; + _t161 = _t160.Ok_0; + return _t161; + } + endif28:; + return fallback; +} + +Option Option_NewSome(int value) { + Option _t162; + Option o; + _t162 = (Option){.tag = Option_Some}; + o = _t162; + o.data.Some_0 = value; + return o; +} + +Option Option_NewNone(void) { + Option _t163; + _t163 = (Option){.tag = Option_None}; + return _t163; +} + +bool Option_IsSome(Option o) { + int _t165; + Option_Tag _t164; + _t164 = o.tag; + _t165 = (_t164 == Option_Some); + return _t165; +} + +bool Option_IsNone(Option o) { + int _t167; + Option_Tag _t166; + _t166 = o.tag; + _t167 = (_t166 == Option_None); + return _t167; +} + +int Option_Unwrap(Option o) { + int _t169; + Option_Tag _t168; + _t168 = o.tag; + _t169 = (_t168 != Option_Some); + if (!_t169) goto endif30; + { + PrintLine("panic: unwrap on None"); + return 0; + } + endif30:; + Option_Data _t170; + _t170 = o.data; + int _t171; + _t171 = _t170.Some_0; + return _t171; +} + +int Option_UnwrapOr(Option o, int fallback) { + int _t173; + Option_Tag _t172; + _t172 = o.tag; + _t173 = (_t172 == Option_Some); + if (!_t173) goto endif32; + { + Option_Data _t174; + _t174 = o.data; + int _t175; + _t175 = _t174.Some_0; + return _t175; + } + endif32:; + return fallback; +} + +JsonValue Json_Null(void) { + JsonValue _t176; + _t176 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t176; +} + +JsonValue Json_Bool(bool b) { + JsonValue _t177; + _t177 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t177; +} + +JsonValue Json_Number(double n) { + JsonValue _t178; + _t178 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t178; +} + +JsonValue Json_String(const char* s) { + JsonValue _t179; + _t179 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t179; +} + +JsonValue Json_Array(void) { + JsonValue _t180; + _t180 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t180; +} + +JsonValue Json_Object(void) { + JsonValue _t181; + _t181 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t181; +} + +unsigned int Json_ArrayLen(JsonValue v) { + int _t183; + int _t182; + _t182 = v.tag; + _t183 = (_t182 != JsonTagArray); + if (!_t183) goto endif34; + { + return 0; + } + endif34:; + unsigned int _t184; + _t184 = v.arrLen; + return _t184; +} + +JsonValue Json_ArrayGet(JsonValue v, unsigned int index) { + int _t186; + int _t189; + int _t185; + _t185 = v.tag; + _t186 = (_t185 != JsonTagArray); + if (!_t186) goto endif36; + { + JsonValue _t187; + _t187 = Json_Null(); + return _t187; + } + endif36:; + unsigned int _t188; + _t188 = v.arrLen; + _t189 = (index >= _t188); + if (!_t189) goto endif38; + { + JsonValue _t190; + _t190 = Json_Null(); + return _t190; + } + endif38:; + JsonValue* _t191; + _t191 = v.arrData; + JsonValue _t192; + _t192 = _t191[index]; + return _t192; +} + +void Json_ArrayPush(JsonValue* self, JsonValue val) { + int _t194; + int _t197; + int _t199; + int _t200; + JsonValue* _t202; + int _t203; + void* _t205; + int _t206; + JsonValue* _t208; + int _t212; + int _t193; + _t193 = self->tag; + _t194 = (_t193 != JsonTagArray); + if (!_t194) goto endif40; + { + return; + } + endif40:; + unsigned int _t195; + _t195 = self->arrLen; + unsigned int _t196; + _t196 = self->arrCap; + _t197 = (_t195 >= _t196); + if (!_t197) goto endif42; + { + unsigned int arrNewCap; + unsigned int _t198; + _t198 = self->arrCap; + arrNewCap = _t198; + _t199 = (arrNewCap == 0); + if (!_t199) goto else43; + { + self->arrCap = 4; + /* sizeof(JsonValue) */ + _t200 = 4 * sizeof(JsonValue); + void* _t201; + _t201 = Alloc(_t200); + _t202 = (JsonValue*)_t201; + self->arrData = _t202; + } + goto endif44; + else43:; + { + unsigned int doubleCap; + _t203 = arrNewCap * 2; + doubleCap = _t203; + self->arrCap = doubleCap; + JsonValue* _t204; + _t204 = self->arrData; + _t205 = (void*)_t204; + /* sizeof(JsonValue) */ + _t206 = doubleCap * sizeof(JsonValue); + void* _t207; + _t207 = Realloc(_t205, _t206); + _t208 = (JsonValue*)_t207; + self->arrData = _t208; + } + endif44:; + } + endif42:; + JsonValue* _t209; + _t209 = self->arrData; + unsigned int _t210; + _t210 = self->arrLen; + _t209[_t210] = val; + unsigned int _t211; + _t211 = self->arrLen; + _t212 = _t211 + 1; + self->arrLen = _t212; +} + +unsigned int Json_ObjectLen(JsonValue v) { + int _t214; + int _t213; + _t213 = v.tag; + _t214 = (_t213 != JsonTagObject); + if (!_t214) goto endif46; + { + return 0; + } + endif46:; + unsigned int _t215; + _t215 = v.objLen; + return _t215; +} + +JsonValue Json_ObjectGet(JsonValue v, const char* key) { + int _t217; + int _t220; + int _t226; + int _t216; + _t216 = v.tag; + _t217 = (_t216 != JsonTagObject); + if (!_t217) goto endif48; + { + JsonValue _t218; + _t218 = Json_Null(); + return _t218; + } + endif48:; + unsigned int i; + i = 0; + while49:; + unsigned int _t219; + _t219 = v.objLen; + _t220 = (i < _t219); + if (!_t220) goto wend50; + { + const char** _t221; + _t221 = v.objKeys; + const char* _t222; + _t222 = _t221[i]; + bool _t223; + _t223 = String_Eq(_t222, key); + if (!_t223) goto endif52; + { + JsonValue* _t224; + _t224 = v.objValues; + JsonValue _t225; + _t225 = _t224[i]; + return _t225; + } + endif52:; + _t226 = i + 1; + i = _t226; + } + goto while49; + wend50:; + JsonValue _t227; + _t227 = Json_Null(); + return _t227; +} + +bool Json_ObjectHas(JsonValue v, const char* key) { + int _t229; + int _t231; + int _t235; + int _t228; + _t228 = v.tag; + _t229 = (_t228 != JsonTagObject); + if (!_t229) goto endif54; + { + return 0; + } + endif54:; + unsigned int i; + i = 0; + while55:; + unsigned int _t230; + _t230 = v.objLen; + _t231 = (i < _t230); + if (!_t231) goto wend56; + { + const char** _t232; + _t232 = v.objKeys; + const char* _t233; + _t233 = _t232[i]; + bool _t234; + _t234 = String_Eq(_t233, key); + if (!_t234) goto endif58; + { + return 1; + } + endif58:; + _t235 = i + 1; + i = _t235; + } + goto while55; + wend56:; + return 0; +} + +void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) { + int _t237; + int _t239; + int _t244; + int _t247; + int _t249; + int _t250; + const char** _t252; + int _t253; + JsonValue* _t255; + int _t256; + void* _t258; + int _t259; + const char** _t261; + void* _t263; + int _t264; + JsonValue* _t266; + int _t272; + int _t236; + _t236 = self->tag; + _t237 = (_t236 != JsonTagObject); + if (!_t237) goto endif60; + { + return; + } + endif60:; + unsigned int i; + i = 0; + while61:; + unsigned int _t238; + _t238 = self->objLen; + _t239 = (i < _t238); + if (!_t239) goto wend62; + { + const char** _t240; + _t240 = self->objKeys; + const char* _t241; + _t241 = _t240[i]; + bool _t242; + _t242 = String_Eq(_t241, key); + if (!_t242) goto endif64; + { + JsonValue* _t243; + _t243 = self->objValues; + _t243[i] = val; + return; + } + endif64:; + _t244 = i + 1; + i = _t244; + } + goto while61; + wend62:; + unsigned int _t245; + _t245 = self->objLen; + unsigned int _t246; + _t246 = self->objCap; + _t247 = (_t245 >= _t246); + if (!_t247) goto endif66; + { + unsigned int objNewCap; + unsigned int _t248; + _t248 = self->objCap; + objNewCap = _t248; + _t249 = (objNewCap == 0); + if (!_t249) goto else67; + { + self->objCap = 4; + /* sizeof(const char*) */ + _t250 = 4 * sizeof(const char*); + void* _t251; + _t251 = Alloc(_t250); + _t252 = (const char**)_t251; + self->objKeys = _t252; + /* sizeof(JsonValue) */ + _t253 = 4 * sizeof(JsonValue); + void* _t254; + _t254 = Alloc(_t253); + _t255 = (JsonValue*)_t254; + self->objValues = _t255; + } + goto endif68; + else67:; + { + unsigned int doubleCap; + _t256 = objNewCap * 2; + doubleCap = _t256; + self->objCap = doubleCap; + const char** _t257; + _t257 = self->objKeys; + _t258 = (void*)_t257; + /* sizeof(const char*) */ + _t259 = doubleCap * sizeof(const char*); + void* _t260; + _t260 = Realloc(_t258, _t259); + _t261 = (const char**)_t260; + self->objKeys = _t261; + JsonValue* _t262; + _t262 = self->objValues; + _t263 = (void*)_t262; + /* sizeof(JsonValue) */ + _t264 = doubleCap * sizeof(JsonValue); + void* _t265; + _t265 = Realloc(_t263, _t264); + _t266 = (JsonValue*)_t265; + self->objValues = _t266; + } + endif68:; + } + endif66:; + const char** _t267; + _t267 = self->objKeys; + unsigned int _t268; + _t268 = self->objLen; + _t267[_t268] = key; + JsonValue* _t269; + _t269 = self->objValues; + unsigned int _t270; + _t270 = self->objLen; + _t269[_t270] = val; + unsigned int _t271; + _t271 = self->objLen; + _t272 = _t271 + 1; + self->objLen = _t272; +} + +bool Json_IsNull(JsonValue v) { + int _t274; + int _t273; + _t273 = v.tag; + _t274 = (_t273 == JsonTagNull); + return _t274; +} + +bool Json_AsBool(JsonValue v) { + int _t276; + int _t275; + _t275 = v.tag; + _t276 = (_t275 == JsonTagBool); + if (!_t276) goto endif70; + { + bool _t277; + _t277 = v.boolVal; + return _t277; + } + endif70:; + return 0; +} + +double Json_AsNumber(JsonValue v) { + int _t279; + int _t278; + _t278 = v.tag; + _t279 = (_t278 == JsonTagNumber); + if (!_t279) goto endif72; + { + double _t280; + _t280 = v.numVal; + return _t280; + } + endif72:; + return 0.0; +} + +const char* Json_AsString(JsonValue v) { + int _t282; + int _t281; + _t281 = v.tag; + _t282 = (_t281 == JsonTagString); + if (!_t282) goto endif74; + { + const char* _t283; + _t283 = v.strVal; + return _t283; + } + endif74:; + return ""; +} + +int JsonParser_Peek(JsonParser* p) { + int _t286; + int _t290; + unsigned int _t284; + _t284 = p->pos; + unsigned int _t285; + _t285 = p->len; + _t286 = (_t284 >= _t285); + if (!_t286) goto endif76; + { + return 0; + } + endif76:; + const char* _t287; + _t287 = p->src; + unsigned int _t288; + _t288 = p->pos; + int _t289; + _t289 = _t287[_t288]; + _t290 = (int)_t289; + return _t290; +} + +void JsonParser_Advance(JsonParser* p) { + int _t293; + int _t295; + unsigned int _t291; + _t291 = p->pos; + unsigned int _t292; + _t292 = p->len; + _t293 = (_t291 < _t292); + if (!_t293) goto endif78; + { + unsigned int _t294; + _t294 = p->pos; + _t295 = _t294 + 1; + p->pos = _t295; + } + endif78:; +} + +void JsonParser_SkipWhitespace(JsonParser* p) { + int _t297; + int _t298; + int _t300; + int _t302; + while79:; + if (!1) goto wend80; + { + int c; + int _t296; + _t296 = JsonParser_Peek(p); + c = _t296; + bool __or_tmp_1; + bool __or_tmp_2; + bool __or_tmp_3; + _t297 = (c == 32); + if (!_t297) goto else81; + *(bool*)&__or_tmp_3 = 1; + goto endif82; + else81:; + _t298 = (c == 9); + *(bool*)&__or_tmp_3 = _t298; + endif82:; + bool _t299; + _t299 = *(bool*)&__or_tmp_3; + if (!_t299) goto else83; + *(bool*)&__or_tmp_2 = 1; + goto endif84; + else83:; + _t300 = (c == 10); + *(bool*)&__or_tmp_2 = _t300; + endif84:; + bool _t301; + _t301 = *(bool*)&__or_tmp_2; + if (!_t301) goto else85; + *(bool*)&__or_tmp_1 = 1; + goto endif86; + else85:; + _t302 = (c == 13); + *(bool*)&__or_tmp_1 = _t302; + endif86:; + bool _t303; + _t303 = *(bool*)&__or_tmp_1; + if (!_t303) goto else87; + { + JsonParser_Advance(p); + } + goto endif88; + else87:; + { + return; + } + endif88:; + } + goto while79; + wend80:; +} + +bool JsonParser_Match(JsonParser* p, const char* expected) { + int _t306; + int _t308; + int _t309; + int _t312; + int _t315; + int _t316; + int _t318; + unsigned int elen; + unsigned int _t304; + _t304 = String_Len(expected); + elen = _t304; + unsigned int _t305; + _t305 = p->pos; + _t306 = _t305 + elen; + unsigned int _t307; + _t307 = p->len; + _t308 = (_t306 > _t307); + if (!_t308) goto endif90; + { + return 0; + } + endif90:; + unsigned int i; + i = 0; + while91:; + _t309 = (i < elen); + if (!_t309) goto wend92; + { + const char* _t310; + _t310 = p->src; + unsigned int _t311; + _t311 = p->pos; + _t312 = _t311 + i; + int _t313; + _t313 = _t310[_t312]; + int _t314; + _t314 = expected[i]; + _t315 = (_t313 != _t314); + if (!_t315) goto endif94; + { + return 0; + } + endif94:; + _t316 = i + 1; + i = _t316; + } + goto while91; + wend92:; + unsigned int _t317; + _t317 = p->pos; + _t318 = _t317 + elen; + p->pos = _t318; + return 1; +} + +const char* JsonParser_ParseString(JsonParser* p) { + int _t320; + int _t323; + int _t324; + int _t326; + int _t328; + void* _t329; + int _t330; + void* _t331; + char _t332; + int _t333; + void* _t334; + char _t335; + int _t336; + void* _t337; + char _t338; + int _t339; + void* _t340; + char _t341; + int _t342; + void* _t343; + char _t344; + int _t345; + void* _t346; + char _t347; + int _t348; + void* _t349; + char _t350; + void* _t351; + char _t352; + void* _t353; + char _t354; + void* _t355; + char _t356; + int _t358; + void* _t359; + void* _t360; + void* _t362; + int _t319; + _t319 = JsonParser_Peek(p); + _t320 = (_t319 != 34); + if (!_t320) goto endif96; + { + p->error = "Expected string"; + return ""; + } + endif96:; + JsonParser_Advance(p); + StringBuilder sb; + StringBuilder _t321; + _t321 = StringBuilder_New(); + sb = _t321; + while97:; + if (!1) goto wend98; + { + int c; + int _t322; + _t322 = JsonParser_Peek(p); + c = _t322; + bool __or_tmp_4; + _t323 = (c == 0); + if (!_t323) goto else99; + *(bool*)&__or_tmp_4 = 1; + goto endif100; + else99:; + _t324 = (c == 34); + *(bool*)&__or_tmp_4 = _t324; + endif100:; + bool _t325; + _t325 = *(bool*)&__or_tmp_4; + if (!_t325) goto endif102; + { + goto wend98; + } + endif102:; + _t326 = (c == 92); + if (!_t326) goto else103; + { + JsonParser_Advance(p); + int esc; + int _t327; + _t327 = JsonParser_Peek(p); + esc = _t327; + _t328 = (esc == 0); + if (!_t328) goto endif106; + { + p->error = "Unterminated string escape"; + _t329 = &sb; + StringBuilder_Free(_t329); + return ""; + } + endif106:; + _t330 = (esc == 110); + if (!_t330) goto else107; + { + _t331 = &sb; + _t332 = (char)10; + StringBuilder_AppendChar(_t331, _t332); + } + goto endif108; + else107:; + _t333 = (esc == 116); + if (!_t333) goto else109; + { + _t334 = &sb; + _t335 = (char)9; + StringBuilder_AppendChar(_t334, _t335); + } + goto endif110; + else109:; + _t336 = (esc == 114); + if (!_t336) goto else111; + { + _t337 = &sb; + _t338 = (char)13; + StringBuilder_AppendChar(_t337, _t338); + } + goto endif112; + else111:; + _t339 = (esc == 98); + if (!_t339) goto else113; + { + _t340 = &sb; + _t341 = (char)8; + StringBuilder_AppendChar(_t340, _t341); + } + goto endif114; + else113:; + _t342 = (esc == 102); + if (!_t342) goto else115; + { + _t343 = &sb; + _t344 = (char)12; + StringBuilder_AppendChar(_t343, _t344); + } + goto endif116; + else115:; + _t345 = (esc == 34); + if (!_t345) goto else117; + { + _t346 = &sb; + _t347 = (char)34; + StringBuilder_AppendChar(_t346, _t347); + } + goto endif118; + else117:; + _t348 = (esc == 92); + if (!_t348) goto else119; + { + _t349 = &sb; + _t350 = (char)92; + StringBuilder_AppendChar(_t349, _t350); + } + goto endif120; + else119:; + { + _t351 = &sb; + _t352 = (char)92; + StringBuilder_AppendChar(_t351, _t352); + _t353 = &sb; + _t354 = (char)esc; + StringBuilder_AppendChar(_t353, _t354); + } + endif120:; + endif118:; + endif116:; + endif114:; + endif112:; + endif110:; + endif108:; + JsonParser_Advance(p); + } + goto endif104; + else103:; + { + _t355 = &sb; + _t356 = (char)c; + StringBuilder_AppendChar(_t355, _t356); + JsonParser_Advance(p); + } + endif104:; + } + goto while97; + wend98:; + int _t357; + _t357 = JsonParser_Peek(p); + _t358 = (_t357 != 34); + if (!_t358) goto endif122; + { + p->error = "Unterminated string"; + _t359 = &sb; + StringBuilder_Free(_t359); + return ""; + } + endif122:; + JsonParser_Advance(p); + const char* result; + _t360 = &sb; + const char* _t361; + _t361 = StringBuilder_Build(_t360); + result = _t361; + _t362 = &sb; + StringBuilder_Free(_t362); + return result; +} + +JsonValue JsonParser_ParseNumber(JsonParser* p) { + int _t365; + int _t367; + int _t368; + int _t371; + int _t373; + int _t374; + int _t378; + unsigned int start; + unsigned int _t363; + _t363 = p->pos; + start = _t363; + int c0; + int _t364; + _t364 = JsonParser_Peek(p); + c0 = _t364; + _t365 = (c0 == 45); + if (!_t365) goto endif124; + { + JsonParser_Advance(p); + } + endif124:; + while125:; + if (!1) goto wend126; + { + int c; + int _t366; + _t366 = JsonParser_Peek(p); + c = _t366; + bool __and_tmp_5; + _t367 = (c >= 48); + if (!_t367) goto else127; + _t368 = (c <= 57); + *(bool*)&__and_tmp_5 = _t368; + goto endif128; + else127:; + *(bool*)&__and_tmp_5 = 0; + endif128:; + bool _t369; + _t369 = *(bool*)&__and_tmp_5; + if (!_t369) goto else129; + { + JsonParser_Advance(p); + } + goto endif130; + else129:; + { + goto wend126; + } + endif130:; + } + goto while125; + wend126:; + int _t370; + _t370 = JsonParser_Peek(p); + _t371 = (_t370 == 46); + if (!_t371) goto endif132; + { + JsonParser_Advance(p); + while133:; + if (!1) goto wend134; + { + int c; + int _t372; + _t372 = JsonParser_Peek(p); + c = _t372; + bool __and_tmp_6; + _t373 = (c >= 48); + if (!_t373) goto else135; + _t374 = (c <= 57); + *(bool*)&__and_tmp_6 = _t374; + goto endif136; + else135:; + *(bool*)&__and_tmp_6 = 0; + endif136:; + bool _t375; + _t375 = *(bool*)&__and_tmp_6; + if (!_t375) goto else137; + { + JsonParser_Advance(p); + } + goto endif138; + else137:; + { + goto wend134; + } + endif138:; + } + goto while133; + wend134:; + } + endif132:; + const char* numStr; + const char* _t376; + _t376 = p->src; + unsigned int _t377; + _t377 = p->pos; + _t378 = _t377 - start; + const char* _t379; + _t379 = String_Slice(_t376, start, _t378); + numStr = _t379; + double n; + double _t380; + _t380 = String_ToFloat(numStr); + n = _t380; + JsonValue _t381; + _t381 = Json_Number(n); + return _t381; +} + +JsonValue JsonParser_ParseArray(JsonParser* p) { + int _t384; + int _t387; + void* _t389; + int _t391; + int _t392; + JsonParser_Advance(p); + JsonValue arr; + JsonValue _t382; + _t382 = Json_Array(); + arr = _t382; + JsonParser_SkipWhitespace(p); + int _t383; + _t383 = JsonParser_Peek(p); + _t384 = (_t383 == 93); + if (!_t384) goto endif140; + { + JsonParser_Advance(p); + return arr; + } + endif140:; + while141:; + if (!1) goto wend142; + { + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t385; + _t385 = JsonParser_ParseValue(p); + val = _t385; + const char* _t386; + _t386 = p->error; + _t387 = (_t386 != ""); + if (!_t387) goto endif144; + { + JsonValue _t388; + _t388 = Json_Null(); + return _t388; + } + endif144:; + _t389 = &arr; + Json_ArrayPush(_t389, val); + JsonParser_SkipWhitespace(p); + int c; + int _t390; + _t390 = JsonParser_Peek(p); + c = _t390; + _t391 = (c == 93); + if (!_t391) goto endif146; + { + JsonParser_Advance(p); + return arr; + } + endif146:; + _t392 = (c == 44); + if (!_t392) goto else147; + { + JsonParser_Advance(p); + } + goto endif148; + else147:; + { + p->error = "Expected ',' or ']' in array"; + JsonValue _t393; + _t393 = Json_Null(); + return _t393; + } + endif148:; + } + goto while141; + wend142:; +} + +JsonValue JsonParser_ParseObject(JsonParser* p) { + int _t396; + int _t399; + int _t402; + int _t406; + void* _t408; + int _t410; + int _t411; + JsonParser_Advance(p); + JsonValue obj; + JsonValue _t394; + _t394 = Json_Object(); + obj = _t394; + JsonParser_SkipWhitespace(p); + int _t395; + _t395 = JsonParser_Peek(p); + _t396 = (_t395 == 125); + if (!_t396) goto endif150; + { + JsonParser_Advance(p); + return obj; + } + endif150:; + while151:; + if (!1) goto wend152; + { + JsonParser_SkipWhitespace(p); + const char* key; + const char* _t397; + _t397 = JsonParser_ParseString(p); + key = _t397; + const char* _t398; + _t398 = p->error; + _t399 = (_t398 != ""); + if (!_t399) goto endif154; + { + JsonValue _t400; + _t400 = Json_Null(); + return _t400; + } + endif154:; + JsonParser_SkipWhitespace(p); + int _t401; + _t401 = JsonParser_Peek(p); + _t402 = (_t401 != 58); + if (!_t402) goto endif156; + { + p->error = "Expected ':' after object key"; + JsonValue _t403; + _t403 = Json_Null(); + return _t403; + } + endif156:; + JsonParser_Advance(p); + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t404; + _t404 = JsonParser_ParseValue(p); + val = _t404; + const char* _t405; + _t405 = p->error; + _t406 = (_t405 != ""); + if (!_t406) goto endif158; + { + JsonValue _t407; + _t407 = Json_Null(); + return _t407; + } + endif158:; + _t408 = &obj; + Json_ObjectSet(_t408, key, val); + JsonParser_SkipWhitespace(p); + int c; + int _t409; + _t409 = JsonParser_Peek(p); + c = _t409; + _t410 = (c == 125); + if (!_t410) goto endif160; + { + JsonParser_Advance(p); + return obj; + } + endif160:; + _t411 = (c == 44); + if (!_t411) goto else161; + { + JsonParser_Advance(p); + } + goto endif162; + else161:; + { + p->error = "Expected ',' or '}' in object"; + JsonValue _t412; + _t412 = Json_Null(); + return _t412; + } + endif162:; + } + goto while151; + wend152:; +} + +JsonValue JsonParser_ParseValue(JsonParser* p) { + int _t414; + int _t416; + int _t419; + int _t421; + int _t423; + int _t427; + int _t431; + int _t435; + int _t436; + int _t438; + JsonParser_SkipWhitespace(p); + int c; + int _t413; + _t413 = JsonParser_Peek(p); + c = _t413; + _t414 = (c == 0); + if (!_t414) goto endif164; + { + p->error = "Unexpected end of input"; + JsonValue _t415; + _t415 = Json_Null(); + return _t415; + } + endif164:; + _t416 = (c == 34); + if (!_t416) goto endif166; + { + const char* _t417; + _t417 = JsonParser_ParseString(p); + JsonValue _t418; + _t418 = Json_String(_t417); + return _t418; + } + endif166:; + _t419 = (c == 123); + if (!_t419) goto endif168; + { + JsonValue _t420; + _t420 = JsonParser_ParseObject(p); + return _t420; + } + endif168:; + _t421 = (c == 91); + if (!_t421) goto endif170; + { + JsonValue _t422; + _t422 = JsonParser_ParseArray(p); + return _t422; + } + endif170:; + _t423 = (c == 116); + if (!_t423) goto endif172; + { + bool _t424; + _t424 = JsonParser_Match(p, "true"); + if (!_t424) goto endif174; + { + JsonValue _t425; + _t425 = Json_Bool(1); + return _t425; + } + endif174:; + p->error = "Expected 'true'"; + JsonValue _t426; + _t426 = Json_Null(); + return _t426; + } + endif172:; + _t427 = (c == 102); + if (!_t427) goto endif176; + { + bool _t428; + _t428 = JsonParser_Match(p, "false"); + if (!_t428) goto endif178; + { + JsonValue _t429; + _t429 = Json_Bool(0); + return _t429; + } + endif178:; + p->error = "Expected 'false'"; + JsonValue _t430; + _t430 = Json_Null(); + return _t430; + } + endif176:; + _t431 = (c == 110); + if (!_t431) goto endif180; + { + bool _t432; + _t432 = JsonParser_Match(p, "null"); + if (!_t432) goto endif182; + { + JsonValue _t433; + _t433 = Json_Null(); + return _t433; + } + endif182:; + p->error = "Expected 'null'"; + JsonValue _t434; + _t434 = Json_Null(); + return _t434; + } + endif180:; + bool __or_tmp_7; + bool __and_tmp_8; + _t435 = (c >= 48); + if (!_t435) goto else183; + _t436 = (c <= 57); + *(bool*)&__and_tmp_8 = _t436; + goto endif184; + else183:; + *(bool*)&__and_tmp_8 = 0; + endif184:; + bool _t437; + _t437 = *(bool*)&__and_tmp_8; + if (!_t437) goto else185; + *(bool*)&__or_tmp_7 = 1; + goto endif186; + else185:; + _t438 = (c == 45); + *(bool*)&__or_tmp_7 = _t438; + endif186:; + bool _t439; + _t439 = *(bool*)&__or_tmp_7; + if (!_t439) goto endif188; + { + JsonValue _t440; + _t440 = JsonParser_ParseNumber(p); + return _t440; + } + endif188:; + p->error = "Unexpected character"; + JsonValue _t441; + _t441 = Json_Null(); + return _t441; +} + +JsonValue Json_Parse(const char* s) { + JsonParser _t443; + void* _t444; + void* _t446; + int _t448; + int _t451; + JsonParser p; + unsigned int _t442; + _t442 = String_Len(s); + _t443 = (JsonParser){.src = s, .pos = 0, .len = _t442, .error = ""}; + p = _t443; + JsonValue result; + _t444 = &p; + JsonValue _t445; + _t445 = JsonParser_ParseValue(_t444); + result = _t445; + _t446 = &p; + JsonParser_SkipWhitespace(_t446); + bool __and_tmp_9; + const char* _t447; + _t447 = p.error; + _t448 = (_t447 == ""); + if (!_t448) goto else189; + unsigned int _t449; + _t449 = p.pos; + unsigned int _t450; + _t450 = p.len; + _t451 = (_t449 != _t450); + *(bool*)&__and_tmp_9 = _t451; + goto endif190; + else189:; + *(bool*)&__and_tmp_9 = 0; + endif190:; + bool _t452; + _t452 = *(bool*)&__and_tmp_9; + if (!_t452) goto endif192; + { + p.error = "Trailing data after JSON value"; + JsonValue _t453; + _t453 = Json_Null(); + return _t453; + } + endif192:; + return result; +} + +void Json_StringifyImpl(StringBuilder* sb, JsonValue v) { + int _t455; + int _t457; + int _t460; + int _t463; + char _t464; + char _t466; + int _t468; + char _t469; + int _t471; + int _t472; + char _t473; + int _t476; + char _t477; + int _t479; + char _t480; + int _t482; + int _t483; + char _t484; + char _t485; + char _t488; + char _t489; + int _t492; + char _t493; + int _t454; + _t454 = v.tag; + _t455 = (_t454 == JsonTagNull); + if (!_t455) goto endif194; + { + StringBuilder_Append(sb, "null"); + return; + } + endif194:; + int _t456; + _t456 = v.tag; + _t457 = (_t456 == JsonTagBool); + if (!_t457) goto endif196; + { + bool _t458; + _t458 = v.boolVal; + if (!_t458) goto else197; + { + StringBuilder_Append(sb, "true"); + } + goto endif198; + else197:; + { + StringBuilder_Append(sb, "false"); + } + endif198:; + return; + } + endif196:; + int _t459; + _t459 = v.tag; + _t460 = (_t459 == JsonTagNumber); + if (!_t460) goto endif200; + { + double _t461; + _t461 = v.numVal; + StringBuilder_AppendFloat(sb, _t461); + return; + } + endif200:; + int _t462; + _t462 = v.tag; + _t463 = (_t462 == JsonTagString); + if (!_t463) goto endif202; + { + _t464 = (char)34; + StringBuilder_AppendChar(sb, _t464); + const char* _t465; + _t465 = v.strVal; + StringBuilder_Append(sb, _t465); + _t466 = (char)34; + StringBuilder_AppendChar(sb, _t466); + return; + } + endif202:; + int _t467; + _t467 = v.tag; + _t468 = (_t467 == JsonTagArray); + if (!_t468) goto endif204; + { + _t469 = (char)91; + StringBuilder_AppendChar(sb, _t469); + unsigned int i; + i = 0; + while205:; + unsigned int _t470; + _t470 = v.arrLen; + _t471 = (i < _t470); + if (!_t471) goto wend206; + { + _t472 = (i > 0); + if (!_t472) goto endif208; + { + _t473 = (char)44; + StringBuilder_AppendChar(sb, _t473); + } + endif208:; + JsonValue* _t474; + _t474 = v.arrData; + JsonValue _t475; + _t475 = _t474[i]; + Json_StringifyImpl(sb, _t475); + _t476 = i + 1; + i = _t476; + } + goto while205; + wend206:; + _t477 = (char)93; + StringBuilder_AppendChar(sb, _t477); + return; + } + endif204:; + int _t478; + _t478 = v.tag; + _t479 = (_t478 == JsonTagObject); + if (!_t479) goto endif210; + { + _t480 = (char)123; + StringBuilder_AppendChar(sb, _t480); + unsigned int i; + i = 0; + while211:; + unsigned int _t481; + _t481 = v.objLen; + _t482 = (i < _t481); + if (!_t482) goto wend212; + { + _t483 = (i > 0); + if (!_t483) goto endif214; + { + _t484 = (char)44; + StringBuilder_AppendChar(sb, _t484); + } + endif214:; + _t485 = (char)34; + StringBuilder_AppendChar(sb, _t485); + const char** _t486; + _t486 = v.objKeys; + const char* _t487; + _t487 = _t486[i]; + StringBuilder_Append(sb, _t487); + _t488 = (char)34; + StringBuilder_AppendChar(sb, _t488); + _t489 = (char)58; + StringBuilder_AppendChar(sb, _t489); + JsonValue* _t490; + _t490 = v.objValues; + JsonValue _t491; + _t491 = _t490[i]; + Json_StringifyImpl(sb, _t491); + _t492 = i + 1; + i = _t492; + } + goto while211; + wend212:; + _t493 = (char)125; + StringBuilder_AppendChar(sb, _t493); + return; + } + endif210:; +} + +const char* Json_Stringify(JsonValue v) { + void* _t495; + void* _t496; + StringBuilder sb; + StringBuilder _t494; + _t494 = StringBuilder_New(); + sb = _t494; + _t495 = &sb; + Json_StringifyImpl(_t495, v); + _t496 = &sb; + const char* _t497; + _t497 = StringBuilder_Build(_t496); + return _t497; +} + +unsigned int String_Len(const char* s) { + unsigned int _t498; + _t498 = bux_strlen(s); + return _t498; +} + +bool String_IsNull(const char* s) { + int _t500; + int _t499; + _t499 = bux_str_is_null(s); + _t500 = (_t499 != 0); + return _t500; +} + +bool String_Eq(const char* a, const char* b) { + int _t502; + int _t501; + _t501 = bux_strcmp(a, b); + _t502 = (_t501 == 0); + return _t502; +} + +const char* String_Concat(const char* a, const char* b) { + int _t505; + int _t506; + char* _t508; + unsigned int len_a; + unsigned int _t503; + _t503 = bux_strlen(a); + len_a = _t503; + unsigned int len_b; + unsigned int _t504; + _t504 = bux_strlen(b); + len_b = _t504; + unsigned int total; + _t505 = len_a + len_b; + _t506 = _t505 + 1; + total = _t506; + char* buf; + void* _t507; + _t507 = bux_alloc(total); + _t508 = (char*)_t507; + buf = _t508; + bux_strcpy(buf, a); + bux_strcat(buf, b); + return buf; +} + +const char* String_Copy(const char* s) { + int _t510; + char* _t512; + unsigned int len; + unsigned int _t509; + _t509 = bux_strlen(s); + len = _t509; + char* buf; + _t510 = len + 1; + void* _t511; + _t511 = bux_alloc(_t510); + _t512 = (char*)_t511; + buf = _t512; + bux_strcpy(buf, s); + return buf; +} + +bool String_StartsWith(const char* s, const char* prefix) { + int _t515; + int _t517; + unsigned int s_len; + unsigned int _t513; + _t513 = bux_strlen(s); + s_len = _t513; + unsigned int p_len; + unsigned int _t514; + _t514 = bux_strlen(prefix); + p_len = _t514; + _t515 = (p_len > s_len); + if (!_t515) goto endif216; + { + return 0; + } + endif216:; + int r; + int _t516; + _t516 = bux_strncmp(s, prefix, p_len); + r = _t516; + _t517 = (r == 0); + return _t517; +} + +bool String_EndsWith(const char* s, const char* suffix) { + int _t520; + int _t521; + int _t524; + unsigned int s_len; + unsigned int _t518; + _t518 = bux_strlen(s); + s_len = _t518; + unsigned int suf_len; + unsigned int _t519; + _t519 = bux_strlen(suffix); + suf_len = _t519; + _t520 = (suf_len > s_len); + if (!_t520) goto endif218; + { + return 0; + } + endif218:; + unsigned int start; + _t521 = s_len - suf_len; + start = _t521; + const char* tail; + const char* _t522; + _t522 = bux_str_slice(s, start, suf_len); + tail = _t522; + bool eq; + int _t523; + _t523 = bux_strcmp(tail, suffix); + _t524 = (_t523 == 0); + eq = _t524; + return eq; +} + +bool String_Contains(const char* s, const char* substr) { + int _t526; + int r; + int _t525; + _t525 = bux_str_contains(s, substr); + r = _t525; + _t526 = (r != 0); + return _t526; +} + +const char* String_Slice(const char* s, unsigned int start, unsigned int len) { + const char* _t527; + _t527 = bux_str_slice(s, start, len); + return _t527; +} + +const char* String_Trim(const char* s) { + const char* _t528; + _t528 = bux_str_trim(s); + return _t528; +} + +const char* String_TrimLeft(const char* s) { + const char* _t529; + _t529 = bux_str_trim_left(s); + return _t529; +} + +const char* String_TrimRight(const char* s) { + const char* _t530; + _t530 = bux_str_trim_right(s); + return _t530; +} + +const char* String_FromInt(int64_t n) { + const char* _t531; + _t531 = bux_int_to_str(n); + return _t531; +} + +int64_t String_ToInt(const char* s) { + int64_t _t532; + _t532 = bux_str_to_int(s); + return _t532; +} + +StringBuilder StringBuilder_New(void) { + StringBuilder _t534; + void* _t533; + _t533 = bux_sb_new(64); + _t534 = (StringBuilder){.handle = _t533}; + return _t534; +} + +StringBuilder StringBuilder_NewCap(unsigned int cap) { + StringBuilder _t536; + void* _t535; + _t535 = bux_sb_new(cap); + _t536 = (StringBuilder){.handle = _t535}; + return _t536; +} + +void StringBuilder_Append(StringBuilder* sb, const char* s) { + void* _t537; + _t537 = sb->handle; + bux_sb_append(_t537, s); +} + +void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) { + void* _t538; + _t538 = sb->handle; + bux_sb_append_int(_t538, n); +} + +void StringBuilder_AppendFloat(StringBuilder* sb, double f) { + void* _t539; + _t539 = sb->handle; + bux_sb_append_float(_t539, f); +} + +void StringBuilder_AppendChar(StringBuilder* sb, char c) { + void* _t540; + _t540 = sb->handle; + bux_sb_append_char(_t540, c); +} + +const char* StringBuilder_Build(StringBuilder* sb) { + void* _t541; + _t541 = sb->handle; + const char* _t542; + _t542 = bux_sb_build(_t541); + return _t542; +} + +void StringBuilder_Free(StringBuilder* sb) { + void* _t543; + _t543 = sb->handle; + bux_sb_free(_t543); +} + +unsigned int String_SplitCount(const char* s, const char* delim) { + unsigned int _t544; + _t544 = bux_str_split_count(s, delim); + return _t544; +} + +const char* String_SplitPart(const char* s, const char* delim, unsigned int index) { + const char* _t545; + _t545 = bux_str_split_part(s, delim, index); + return _t545; +} + +const char* String_Join2(const char* a, const char* b, const char* sep) { + const char* _t546; + _t546 = bux_str_join2(a, b, sep); + return _t546; +} + +const char* String_Chars(const char* s, unsigned int index) { + const char* _t547; + _t547 = bux_str_slice(s, index, 1); + return _t547; +} + +const char* String_Find(const char* haystack, const char* needle) { + const char* _t548; + _t548 = bux_strstr(haystack, needle); + return _t548; +} + +unsigned int String_Offset(const char* pos, const char* base) { + unsigned int _t549; + _t549 = bux_str_offset(pos, base); + return _t549; +} + +const char* String_Replace(const char* s, const char* old, const char* new) { + int _t555; + int _t557; + int _t558; + const char* pos; + const char* _t550; + _t550 = bux_strstr(s, old); + pos = _t550; + bool _t551; + _t551 = String_IsNull(pos); + if (!_t551) goto endif220; + { + return s; + } + endif220:; + unsigned int oldLen; + unsigned int _t552; + _t552 = bux_strlen(old); + oldLen = _t552; + unsigned int prefixLen; + unsigned int _t553; + _t553 = String_Offset(pos, s); + prefixLen = _t553; + const char* prefix; + const char* _t554; + _t554 = bux_str_slice(s, 0, prefixLen); + prefix = _t554; + const char* suffix; + _t555 = prefixLen + oldLen; + unsigned int _t556; + _t556 = bux_strlen(s); + _t557 = _t556 - prefixLen; + _t558 = _t557 - oldLen; + const char* _t559; + _t559 = bux_str_slice(s, _t555, _t558); + suffix = _t559; + const char* temp; + const char* _t560; + _t560 = String_Concat(prefix, new); + temp = _t560; + const char* result; + const char* _t561; + _t561 = String_Concat(temp, suffix); + result = _t561; + return result; +} + +double String_ToFloat(const char* s) { + double _t562; + _t562 = bux_str_to_float(s); + return _t562; +} + +const char* String_FromBool(bool b) { + if (!b) goto endif222; + { + return "true"; + } + endif222:; + return "false"; +} + +const char* String_FromFloat(double f) { + const char* _t563; + _t563 = bux_float_to_string(f); + return _t563; +} + +const char* String_Format1(const char* pattern, const char* a0) { + const char* _t564; + _t564 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); + return _t564; +} + +const char* String_Format2(const char* pattern, const char* a0, const char* a1) { + const char* _t565; + _t565 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); + return _t565; +} + +const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) { + const char* _t566; + _t566 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); + return _t566; +} + +void Channel_SendInt(Channel_int* ch, int value) { + void* _t568; + void* _t569; + void* _t567; + _t567 = ch->handle; + _t568 = &value; + _t569 = (void*)_t568; + bux_channel_send(_t567, _t569); +} + +int Channel_RecvInt(Channel_int* ch) { + void* _t571; + void* _t572; + int result; + result = 0; + void* _t570; + _t570 = ch->handle; + _t571 = &result; + _t572 = (void*)_t571; + bux_channel_recv(_t570, _t572); + return result; +} + +void Channel_SendFloat64(Channel_float64* ch, double value) { + void* _t574; + void* _t575; + void* _t573; + _t573 = ch->handle; + _t574 = &value; + _t575 = (void*)_t574; + bux_channel_send(_t573, _t575); +} + +double Channel_RecvFloat64(Channel_float64* ch) { + void* _t577; + void* _t578; + double result; + result = 0.0; + void* _t576; + _t576 = ch->handle; + _t577 = &result; + _t578 = (void*)_t577; + bux_channel_recv(_t576, _t578); + return result; +} + +const char* Hash_Sha1(const char* data) { + int _t580; + int len; + unsigned int _t579; + _t579 = String_Len(data); + _t580 = (int)_t579; + len = _t580; + void* buf; + void* _t581; + _t581 = Alloc(20); + buf = _t581; + bux_sha1(data, len, buf); + const char* result; + const char* _t582; + _t582 = bux_bytes_to_hex(buf, 20); + result = _t582; + Free(buf); + return result; +} + +const char* Hash_Sha256(const char* data) { + int _t584; + int len; + unsigned int _t583; + _t583 = String_Len(data); + _t584 = (int)_t583; + len = _t584; + void* buf; + void* _t585; + _t585 = Alloc(32); + buf = _t585; + bux_sha256(data, len, buf); + const char* result; + const char* _t586; + _t586 = bux_bytes_to_hex(buf, 32); + result = _t586; + Free(buf); + return result; +} + +const char* Hash_Sha384(const char* data) { + int _t588; + int len; + unsigned int _t587; + _t587 = String_Len(data); + _t588 = (int)_t587; + len = _t588; + void* buf; + void* _t589; + _t589 = Alloc(48); + buf = _t589; + bux_sha384(data, len, buf); + const char* result; + const char* _t590; + _t590 = bux_bytes_to_hex(buf, 48); + result = _t590; + Free(buf); + return result; +} + +const char* Hash_Sha512(const char* data) { + int _t592; + int len; + unsigned int _t591; + _t591 = String_Len(data); + _t592 = (int)_t591; + len = _t592; + void* buf; + void* _t593; + _t593 = Alloc(64); + buf = _t593; + bux_sha512(data, len, buf); + const char* result; + const char* _t594; + _t594 = bux_bytes_to_hex(buf, 64); + result = _t594; + Free(buf); + return result; +} + +void Hash_Sha256Raw(const char* data, void* out) { + int _t596; + unsigned int _t595; + _t595 = String_Len(data); + _t596 = (int)_t595; + bux_sha256(data, _t596, out); +} + +void Hash_Sha384Raw(const char* data, void* out) { + int _t598; + unsigned int _t597; + _t597 = String_Len(data); + _t598 = (int)_t597; + bux_sha384(data, _t598, out); +} + +void Hash_Sha512Raw(const char* data, void* out) { + int _t600; + unsigned int _t599; + _t599 = String_Len(data); + _t600 = (int)_t599; + bux_sha512(data, _t600, out); +} + +int Hash_Sha1Size(void) { + return 20; +} + +int Hash_Sha256Size(void) { + return 32; +} + +int Hash_Sha384Size(void) { + return 48; +} + +int Hash_Sha512Size(void) { + return 64; +} + +const char* Base64_Encode(const char* s) { + int _t602; + unsigned int _t601; + _t601 = String_Len(s); + _t602 = (int)_t601; + const char* _t603; + _t603 = bux_base64_encode(s, _t602); + return _t603; +} + +const char* Base64_Decode(const char* s) { + int _t605; + void* _t606; + int outlen; + outlen = 0; + unsigned int _t604; + _t604 = String_Len(s); + _t605 = (int)_t604; + _t606 = &outlen; + const char* _t607; + _t607 = bux_base64_decode(s, _t605, _t606); + return _t607; +} + +const char* Base64URL_Encode(const char* s) { + int _t609; + unsigned int _t608; + _t608 = String_Len(s); + _t609 = (int)_t608; + const char* _t610; + _t610 = bux_base64url_encode(s, _t609); + return _t610; +} + +const char* Base64URL_Decode(const char* s) { + int _t612; + void* _t613; + int outlen; + outlen = 0; + unsigned int _t611; + _t611 = String_Len(s); + _t612 = (int)_t611; + _t613 = &outlen; + const char* _t614; + _t614 = bux_base64url_decode(s, _t612, _t613); + return _t614; +} + +const char* Hmac_Sha256(const char* key, const char* message) { + int _t616; + int _t618; + int kl; + unsigned int _t615; + _t615 = String_Len(key); + _t616 = (int)_t615; + kl = _t616; + int ml; + unsigned int _t617; + _t617 = String_Len(message); + _t618 = (int)_t617; + ml = _t618; + void* buf; + void* _t619; + _t619 = Alloc(32); + buf = _t619; + bux_hmac_sha256(key, kl, message, ml, buf); + const char* result; + const char* _t620; + _t620 = bux_bytes_to_hex(buf, 32); + result = _t620; + Free(buf); + return result; +} + +void Hmac_Sha256Raw(const char* key, const char* message, void* out) { + int _t622; + int _t624; + unsigned int _t621; + _t621 = String_Len(key); + _t622 = (int)_t621; + unsigned int _t623; + _t623 = String_Len(message); + _t624 = (int)_t623; + bux_hmac_sha256(key, _t622, message, _t624, out); +} + +const char* Hmac_Sha256Base64(const char* key, const char* message) { + int _t626; + int _t628; + const char* _t630; + int kl; + unsigned int _t625; + _t625 = String_Len(key); + _t626 = (int)_t625; + kl = _t626; + int ml; + unsigned int _t627; + _t627 = String_Len(message); + _t628 = (int)_t627; + ml = _t628; + void* buf; + void* _t629; + _t629 = Alloc(32); + buf = _t629; + bux_hmac_sha256(key, kl, message, ml, buf); + const char* result; + _t630 = (const char*)buf; + const char* _t631; + _t631 = bux_base64_encode(_t630, 32); + result = _t631; + Free(buf); + return result; +} + +const char* Hmac_Sha384(const char* key, const char* message) { + int _t633; + int _t635; + int kl; + unsigned int _t632; + _t632 = String_Len(key); + _t633 = (int)_t632; + kl = _t633; + int ml; + unsigned int _t634; + _t634 = String_Len(message); + _t635 = (int)_t634; + ml = _t635; + void* buf; + void* _t636; + _t636 = Alloc(48); + buf = _t636; + bux_hmac_sha384(key, kl, message, ml, buf); + const char* result; + const char* _t637; + _t637 = bux_bytes_to_hex(buf, 48); + result = _t637; + Free(buf); + return result; +} + +void Hmac_Sha384Raw(const char* key, const char* message, void* out) { + int _t639; + int _t641; + unsigned int _t638; + _t638 = String_Len(key); + _t639 = (int)_t638; + unsigned int _t640; + _t640 = String_Len(message); + _t641 = (int)_t640; + bux_hmac_sha384(key, _t639, message, _t641, out); +} + +const char* Hmac_Sha384Base64(const char* key, const char* message) { + int _t643; + int _t645; + const char* _t647; + int kl; + unsigned int _t642; + _t642 = String_Len(key); + _t643 = (int)_t642; + kl = _t643; + int ml; + unsigned int _t644; + _t644 = String_Len(message); + _t645 = (int)_t644; + ml = _t645; + void* buf; + void* _t646; + _t646 = Alloc(48); + buf = _t646; + bux_hmac_sha384(key, kl, message, ml, buf); + const char* result; + _t647 = (const char*)buf; + const char* _t648; + _t648 = bux_base64_encode(_t647, 48); + result = _t648; + Free(buf); + return result; +} + +const char* Hmac_Sha512(const char* key, const char* message) { + int _t650; + int _t652; + int kl; + unsigned int _t649; + _t649 = String_Len(key); + _t650 = (int)_t649; + kl = _t650; + int ml; + unsigned int _t651; + _t651 = String_Len(message); + _t652 = (int)_t651; + ml = _t652; + void* buf; + void* _t653; + _t653 = Alloc(64); + buf = _t653; + bux_hmac_sha512(key, kl, message, ml, buf); + const char* result; + const char* _t654; + _t654 = bux_bytes_to_hex(buf, 64); + result = _t654; + Free(buf); + return result; +} + +void Hmac_Sha512Raw(const char* key, const char* message, void* out) { + int _t656; + int _t658; + unsigned int _t655; + _t655 = String_Len(key); + _t656 = (int)_t655; + unsigned int _t657; + _t657 = String_Len(message); + _t658 = (int)_t657; + bux_hmac_sha512(key, _t656, message, _t658, out); +} + +const char* Hmac_Sha512Base64(const char* key, const char* message) { + int _t660; + int _t662; + const char* _t664; + int kl; + unsigned int _t659; + _t659 = String_Len(key); + _t660 = (int)_t659; + kl = _t660; + int ml; + unsigned int _t661; + _t661 = String_Len(message); + _t662 = (int)_t661; + ml = _t662; + void* buf; + void* _t663; + _t663 = Alloc(64); + buf = _t663; + bux_hmac_sha512(key, kl, message, ml, buf); + const char* result; + _t664 = (const char*)buf; + const char* _t665; + _t665 = bux_base64_encode(_t664, 64); + result = _t665; + Free(buf); + return result; +} + +const char* Random_Bytes(int n) { + int _t666; + unsigned int _t667; + int _t670; + const char* _t671; + _t666 = (n <= 0); + if (!_t666) goto endif224; + { + return ""; + } + endif224:; + void* buf; + _t667 = (unsigned int)n; + void* _t668; + _t668 = Alloc(_t667); + buf = _t668; + int _t669; + _t669 = bux_random_bytes(buf, n); + _t670 = (_t669 != 1); + if (!_t670) goto endif226; + { + Free(buf); + return ""; + } + endif226:; + _t671 = (const char*)buf; + return _t671; +} + +const char* Random_Hex(int n) { + int _t672; + unsigned int _t673; + int _t676; + _t672 = (n <= 0); + if (!_t672) goto endif228; + { + return ""; + } + endif228:; + void* buf; + _t673 = (unsigned int)n; + void* _t674; + _t674 = Alloc(_t673); + buf = _t674; + int _t675; + _t675 = bux_random_bytes(buf, n); + _t676 = (_t675 != 1); + if (!_t676) goto endif230; + { + Free(buf); + return ""; + } + endif230:; + const char* result; + const char* _t677; + _t677 = bux_bytes_to_hex(buf, n); + result = _t677; + Free(buf); + return result; +} + +const char* Random_Base64(int n) { + int _t678; + unsigned int _t679; + int _t682; + const char* _t683; + _t678 = (n <= 0); + if (!_t678) goto endif232; + { + return ""; + } + endif232:; + void* buf; + _t679 = (unsigned int)n; + void* _t680; + _t680 = Alloc(_t679); + buf = _t680; + int _t681; + _t681 = bux_random_bytes(buf, n); + _t682 = (_t681 != 1); + if (!_t682) goto endif234; + { + Free(buf); + return ""; + } + endif234:; + const char* result; + _t683 = (const char*)buf; + const char* _t684; + _t684 = bux_base64_encode(_t683, n); + result = _t684; + Free(buf); + return result; +} + +unsigned int Random_Uint32(void) { + int _t687; + unsigned int* _t688; + unsigned int _t689; + void* buf; + void* _t685; + _t685 = Alloc(4); + buf = _t685; + int _t686; + _t686 = bux_random_bytes(buf, 4); + _t687 = (_t686 != 1); + if (!_t687) goto endif236; + { + Free(buf); + return 0; + } + endif236:; + unsigned int* ptr; + _t688 = (unsigned int*)buf; + ptr = _t688; + unsigned int val; + _t689 = *ptr; + val = _t689; + Free(buf); + return val; +} + +const char* Aes_GenerateKey(void) { + unsigned int _t690; + int _t693; + const char* _t694; + void* buf; + _t690 = (unsigned int)AES_KEY_SIZE; + void* _t691; + _t691 = Alloc(_t690); + buf = _t691; + int _t692; + _t692 = bux_random_bytes(buf, AES_KEY_SIZE); + _t693 = (_t692 != 1); + if (!_t693) goto endif238; + { + Free(buf); + return ""; + } + endif238:; + _t694 = (const char*)buf; + return _t694; +} + +const char* Aes_GenerateIV(void) { + unsigned int _t695; + int _t698; + const char* _t699; + void* buf; + _t695 = (unsigned int)AES_IV_SIZE; + void* _t696; + _t696 = Alloc(_t695); + buf = _t696; + int _t697; + _t697 = bux_random_bytes(buf, AES_IV_SIZE); + _t698 = (_t697 != 1); + if (!_t698) goto endif240; + { + Free(buf); + return ""; + } + endif240:; + _t699 = (const char*)buf; + return _t699; +} + +const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv) { + int _t701; + void* _t702; + int outlen; + outlen = 0; + unsigned int _t700; + _t700 = String_Len(plain); + _t701 = (int)_t700; + _t702 = &outlen; + const char* _t703; + _t703 = bux_aes_256_cbc_encrypt(plain, _t701, key, iv, _t702); + return _t703; +} + +const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv) { + int _t705; + void* _t706; + int outlen; + outlen = 0; + unsigned int _t704; + _t704 = String_Len(cipher); + _t705 = (int)_t704; + _t706 = &outlen; + const char* _t707; + _t707 = bux_aes_256_cbc_decrypt(cipher, _t705, key, iv, _t706); + return _t707; +} + +const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag) { + int _t709; + void* _t710; + int outlen; + outlen = 0; + unsigned int _t708; + _t708 = String_Len(plain); + _t709 = (int)_t708; + _t710 = &outlen; + const char* _t711; + _t711 = bux_aes_256_gcm_encrypt(plain, _t709, key, iv, tag, _t710); + return _t711; +} + +const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag) { + int _t713; + void* _t714; + int outlen; + outlen = 0; + unsigned int _t712; + _t712 = String_Len(cipher); + _t713 = (int)_t712; + _t714 = &outlen; + const char* _t715; + _t715 = bux_aes_256_gcm_decrypt(cipher, _t713, key, iv, tag, _t714); + return _t715; +} + +const char* Jwt_MakeHeader(JwtAlg alg) { + int _t716; + int _t717; + int _t718; + int _t719; + int _t720; + int _t721; + int _t722; + int _t723; + int _t724; + _t716 = (alg == JwtAlg_HS256); + if (!_t716) goto endif242; + { + return "{\"alg\":\"HS256\",\"typ\":\"JWT\"}"; + } + endif242:; + _t717 = (alg == JwtAlg_HS384); + if (!_t717) goto endif244; + { + return "{\"alg\":\"HS384\",\"typ\":\"JWT\"}"; + } + endif244:; + _t718 = (alg == JwtAlg_HS512); + if (!_t718) goto endif246; + { + return "{\"alg\":\"HS512\",\"typ\":\"JWT\"}"; + } + endif246:; + _t719 = (alg == JwtAlg_RS256); + if (!_t719) goto endif248; + { + return "{\"alg\":\"RS256\",\"typ\":\"JWT\"}"; + } + endif248:; + _t720 = (alg == JwtAlg_RS384); + if (!_t720) goto endif250; + { + return "{\"alg\":\"RS384\",\"typ\":\"JWT\"}"; + } + endif250:; + _t721 = (alg == JwtAlg_RS512); + if (!_t721) goto endif252; + { + return "{\"alg\":\"RS512\",\"typ\":\"JWT\"}"; + } + endif252:; + _t722 = (alg == JwtAlg_ES256); + if (!_t722) goto endif254; + { + return "{\"alg\":\"ES256\",\"typ\":\"JWT\"}"; + } + endif254:; + _t723 = (alg == JwtAlg_ES384); + if (!_t723) goto endif256; + { + return "{\"alg\":\"ES384\",\"typ\":\"JWT\"}"; + } + endif256:; + _t724 = (alg == JwtAlg_EdDSA); + if (!_t724) goto endif258; + { + return "{\"alg\":\"EdDSA\",\"typ\":\"JWT\"}"; + } + endif258:; + return "{\"alg\":\"none\",\"typ\":\"JWT\"}"; +} + +const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key) { + int _t725; + const char* _t727; + int _t729; + const char* _t731; + int _t733; + const char* _t735; + int _t737; + int _t740; + int _t742; + int _t745; + int _t747; + int _t750; + int _t752; + int _t755; + int _t757; + int _t760; + int _t762; + _t725 = (alg == JwtAlg_HS256); + if (!_t725) goto endif260; + { + void* buf; + void* _t726; + _t726 = Alloc(32); + buf = _t726; + Hmac_Sha256Raw(key, signingInput, buf); + const char* result; + _t727 = (const char*)buf; + const char* _t728; + _t728 = bux_base64_encode(_t727, 32); + result = _t728; + Free(buf); + return result; + } + endif260:; + _t729 = (alg == JwtAlg_HS384); + if (!_t729) goto endif262; + { + void* buf; + void* _t730; + _t730 = Alloc(48); + buf = _t730; + Hmac_Sha384Raw(key, signingInput, buf); + const char* result; + _t731 = (const char*)buf; + const char* _t732; + _t732 = bux_base64_encode(_t731, 48); + result = _t732; + Free(buf); + return result; + } + endif262:; + _t733 = (alg == JwtAlg_HS512); + if (!_t733) goto endif264; + { + void* buf; + void* _t734; + _t734 = Alloc(64); + buf = _t734; + Hmac_Sha512Raw(key, signingInput, buf); + const char* result; + _t735 = (const char*)buf; + const char* _t736; + _t736 = bux_base64_encode(_t735, 64); + result = _t736; + Free(buf); + return result; + } + endif264:; + _t737 = (alg == JwtAlg_RS256); + if (!_t737) goto endif266; + { + const char* raw; + const char* _t738; + _t738 = Rsa_SignSha256(key, signingInput); + raw = _t738; + unsigned int _t739; + _t739 = String_Len(raw); + _t740 = (int)_t739; + const char* _t741; + _t741 = bux_base64_encode(raw, _t740); + return _t741; + } + endif266:; + _t742 = (alg == JwtAlg_RS384); + if (!_t742) goto endif268; + { + const char* raw; + const char* _t743; + _t743 = Rsa_SignSha384(key, signingInput); + raw = _t743; + unsigned int _t744; + _t744 = String_Len(raw); + _t745 = (int)_t744; + const char* _t746; + _t746 = bux_base64_encode(raw, _t745); + return _t746; + } + endif268:; + _t747 = (alg == JwtAlg_RS512); + if (!_t747) goto endif270; + { + const char* raw; + const char* _t748; + _t748 = Rsa_SignSha512(key, signingInput); + raw = _t748; + unsigned int _t749; + _t749 = String_Len(raw); + _t750 = (int)_t749; + const char* _t751; + _t751 = bux_base64_encode(raw, _t750); + return _t751; + } + endif270:; + _t752 = (alg == JwtAlg_ES256); + if (!_t752) goto endif272; + { + const char* raw; + const char* _t753; + _t753 = Ecdsa_SignP256(key, signingInput); + raw = _t753; + unsigned int _t754; + _t754 = String_Len(raw); + _t755 = (int)_t754; + const char* _t756; + _t756 = bux_base64_encode(raw, _t755); + return _t756; + } + endif272:; + _t757 = (alg == JwtAlg_ES384); + if (!_t757) goto endif274; + { + const char* raw; + const char* _t758; + _t758 = Ecdsa_SignP384(key, signingInput); + raw = _t758; + unsigned int _t759; + _t759 = String_Len(raw); + _t760 = (int)_t759; + const char* _t761; + _t761 = bux_base64_encode(raw, _t760); + return _t761; + } + endif274:; + _t762 = (alg == JwtAlg_EdDSA); + if (!_t762) goto endif276; + { + const char* _t763; + _t763 = Ed25519_Sign(key, signingInput); + return _t763; + } + endif276:; + return ""; +} + +bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key) { + int _t764; + const char* _t766; + int _t769; + const char* _t771; + int _t774; + const char* _t776; + int _t779; + int _t781; + int _t783; + int _t785; + int _t787; + int _t789; + _t764 = (alg == JwtAlg_HS256); + if (!_t764) goto endif278; + { + void* expectBuf; + void* _t765; + _t765 = Alloc(32); + expectBuf = _t765; + Hmac_Sha256Raw(key, signingInput, expectBuf); + const char* expectB64; + _t766 = (const char*)expectBuf; + const char* _t767; + _t767 = bux_base64_encode(_t766, 32); + expectB64 = _t767; + Free(expectBuf); + bool _t768; + _t768 = String_Eq(expectB64, signatureB64); + return _t768; + } + endif278:; + _t769 = (alg == JwtAlg_HS384); + if (!_t769) goto endif280; + { + void* expectBuf; + void* _t770; + _t770 = Alloc(48); + expectBuf = _t770; + Hmac_Sha384Raw(key, signingInput, expectBuf); + const char* expectB64; + _t771 = (const char*)expectBuf; + const char* _t772; + _t772 = bux_base64_encode(_t771, 48); + expectB64 = _t772; + Free(expectBuf); + bool _t773; + _t773 = String_Eq(expectB64, signatureB64); + return _t773; + } + endif280:; + _t774 = (alg == JwtAlg_HS512); + if (!_t774) goto endif282; + { + void* expectBuf; + void* _t775; + _t775 = Alloc(64); + expectBuf = _t775; + Hmac_Sha512Raw(key, signingInput, expectBuf); + const char* expectB64; + _t776 = (const char*)expectBuf; + const char* _t777; + _t777 = bux_base64_encode(_t776, 64); + expectB64 = _t777; + Free(expectBuf); + bool _t778; + _t778 = String_Eq(expectB64, signatureB64); + return _t778; + } + endif282:; + _t779 = (alg == JwtAlg_RS256); + if (!_t779) goto endif284; + { + bool _t780; + _t780 = Rsa_VerifySha256(key, signingInput, signatureB64); + return _t780; + } + endif284:; + _t781 = (alg == JwtAlg_RS384); + if (!_t781) goto endif286; + { + bool _t782; + _t782 = Rsa_VerifySha384(key, signingInput, signatureB64); + return _t782; + } + endif286:; + _t783 = (alg == JwtAlg_RS512); + if (!_t783) goto endif288; + { + bool _t784; + _t784 = Rsa_VerifySha512(key, signingInput, signatureB64); + return _t784; + } + endif288:; + _t785 = (alg == JwtAlg_ES256); + if (!_t785) goto endif290; + { + bool _t786; + _t786 = Ecdsa_VerifyP256(key, signingInput, signatureB64); + return _t786; + } + endif290:; + _t787 = (alg == JwtAlg_ES384); + if (!_t787) goto endif292; + { + bool _t788; + _t788 = Ecdsa_VerifyP384(key, signingInput, signatureB64); + return _t788; + } + endif292:; + _t789 = (alg == JwtAlg_EdDSA); + if (!_t789) goto endif294; + { + bool _t790; + _t790 = Ed25519_Verify(key, signatureB64, signingInput); + return _t790; + } + endif294:; + return 0; +} + +const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key) { + const char* headerB64; + const char* _t791; + _t791 = Base64URL_Encode(headerJson); + headerB64 = _t791; + const char* payloadB64; + const char* _t792; + _t792 = Base64URL_Encode(payloadJson); + payloadB64 = _t792; + const char* signingInput; + const char* _t793; + _t793 = String_Concat(headerB64, "."); + signingInput = _t793; + const char* signingInputFull; + const char* _t794; + _t794 = String_Concat(signingInput, payloadB64); + signingInputFull = _t794; + const char* sigB64; + const char* _t795; + _t795 = Jwt_Sign(alg, signingInputFull, key); + sigB64 = _t795; + const char* part1; + const char* _t796; + _t796 = String_Concat(signingInputFull, "."); + part1 = _t796; + const char* _t797; + _t797 = String_Concat(part1, sigB64); + return _t797; +} + +bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut) { + int _t799; + int _t806; + unsigned int partCount; + unsigned int _t798; + _t798 = bux_str_split_count(token, "."); + partCount = _t798; + _t799 = (partCount != 3); + if (!_t799) goto endif296; + { + return 0; + } + endif296:; + const char* headerB64; + const char* _t800; + _t800 = bux_str_split_part(token, ".", 0); + headerB64 = _t800; + const char* payloadB64; + const char* _t801; + _t801 = bux_str_split_part(token, ".", 1); + payloadB64 = _t801; + const char* sigB64; + const char* _t802; + _t802 = bux_str_split_part(token, ".", 2); + sigB64 = _t802; + const char* input; + const char* _t803; + _t803 = String_Concat(headerB64, "."); + input = _t803; + const char* signingInput; + const char* _t804; + _t804 = String_Concat(input, payloadB64); + signingInput = _t804; + bool _t805; + _t805 = Jwt_Verify(alg, signingInput, sigB64, key); + _t806 = !_t805; + if (!_t806) goto endif298; + { + return 0; + } + endif298:; + const char* _t807; + _t807 = Base64URL_Decode(headerB64); + headerOut[0] = _t807; + const char* _t808; + _t808 = Base64URL_Decode(payloadB64); + payloadOut[0] = _t808; + return 1; +} + +const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret) { + const char* header; + const char* _t809; + _t809 = Jwt_MakeHeader(JwtAlg_HS256); + header = _t809; + const char* _t810; + _t810 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); + return _t810; +} + +const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret) { + const char* header; + const char* _t811; + _t811 = Jwt_MakeHeader(JwtAlg_HS384); + header = _t811; + const char* _t812; + _t812 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); + return _t812; +} + +const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret) { + const char* header; + const char* _t813; + _t813 = Jwt_MakeHeader(JwtAlg_HS512); + header = _t813; + const char* _t814; + _t814 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); + return _t814; +} + +const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey) { + const char* header; + const char* _t815; + _t815 = Jwt_MakeHeader(JwtAlg_RS256); + header = _t815; + const char* _t816; + _t816 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); + return _t816; +} + +const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey) { + const char* header; + const char* _t817; + _t817 = Jwt_MakeHeader(JwtAlg_ES256); + header = _t817; + const char* _t818; + _t818 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); + return _t818; +} + +const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey) { + const char* header; + const char* _t819; + _t819 = Jwt_MakeHeader(JwtAlg_EdDSA); + header = _t819; + const char* _t820; + _t820 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); + return _t820; +} + +const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data) { + int _t822; + int _t824; + void* _t825; + int siglen; + siglen = 0; + unsigned int _t821; + _t821 = String_Len(pemPrivateKey); + _t822 = (int)_t821; + unsigned int _t823; + _t823 = String_Len(data); + _t824 = (int)_t823; + _t825 = &siglen; + const char* _t826; + _t826 = bux_ecdsa_sign_p256(pemPrivateKey, _t822, data, _t824, _t825); + return _t826; +} + +const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data) { + int _t829; + const char* raw; + const char* _t827; + _t827 = Ecdsa_SignP256(pemPrivateKey, data); + raw = _t827; + unsigned int _t828; + _t828 = String_Len(raw); + _t829 = (int)_t828; + const char* _t830; + _t830 = bux_base64_encode(raw, _t829); + return _t830; +} + +bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature) { + int _t832; + int _t834; + int _t836; + int _t838; + int r; + unsigned int _t831; + _t831 = String_Len(pemPublicKey); + _t832 = (int)_t831; + unsigned int _t833; + _t833 = String_Len(data); + _t834 = (int)_t833; + unsigned int _t835; + _t835 = String_Len(signature); + _t836 = (int)_t835; + int _t837; + _t837 = bux_ecdsa_verify_p256(pemPublicKey, _t832, data, _t834, signature, _t836); + r = _t837; + _t838 = (r == 1); + return _t838; +} + +bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { + int _t840; + void* _t841; + int outlen; + outlen = 0; + const char* sig; + unsigned int _t839; + _t839 = String_Len(signatureB64); + _t840 = (int)_t839; + _t841 = &outlen; + const char* _t842; + _t842 = bux_base64_decode(signatureB64, _t840, _t841); + sig = _t842; + bool _t843; + _t843 = Ecdsa_VerifyP256(pemPublicKey, data, sig); + return _t843; +} + +const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data) { + int _t845; + int _t847; + void* _t848; + int siglen; + siglen = 0; + unsigned int _t844; + _t844 = String_Len(pemPrivateKey); + _t845 = (int)_t844; + unsigned int _t846; + _t846 = String_Len(data); + _t847 = (int)_t846; + _t848 = &siglen; + const char* _t849; + _t849 = bux_ecdsa_sign_p384(pemPrivateKey, _t845, data, _t847, _t848); + return _t849; +} + +const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data) { + int _t852; + const char* raw; + const char* _t850; + _t850 = Ecdsa_SignP384(pemPrivateKey, data); + raw = _t850; + unsigned int _t851; + _t851 = String_Len(raw); + _t852 = (int)_t851; + const char* _t853; + _t853 = bux_base64_encode(raw, _t852); + return _t853; +} + +bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature) { + int _t855; + int _t857; + int _t859; + int _t861; + int r; + unsigned int _t854; + _t854 = String_Len(pemPublicKey); + _t855 = (int)_t854; + unsigned int _t856; + _t856 = String_Len(data); + _t857 = (int)_t856; + unsigned int _t858; + _t858 = String_Len(signature); + _t859 = (int)_t858; + int _t860; + _t860 = bux_ecdsa_verify_p384(pemPublicKey, _t855, data, _t857, signature, _t859); + r = _t860; + _t861 = (r == 1); + return _t861; +} + +bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { + int _t863; + void* _t864; + int outlen; + outlen = 0; + const char* sig; + unsigned int _t862; + _t862 = String_Len(signatureB64); + _t863 = (int)_t862; + _t864 = &outlen; + const char* _t865; + _t865 = bux_base64_decode(signatureB64, _t863, _t864); + sig = _t865; + bool _t866; + _t866 = Ecdsa_VerifyP384(pemPublicKey, data, sig); + return _t866; +} + +bool Ed25519_Keypair(void* pubKey, void* privKey) { + int _t868; + int r; + int _t867; + _t867 = bux_ed25519_keypair(pubKey, privKey); + r = _t867; + _t868 = (r == 1); + return _t868; +} + +const char* Ed25519_KeypairBase64(void) { + unsigned int _t869; + unsigned int _t871; + int _t874; + const char* _t875; + const char* _t877; + void* pubBuf; + _t869 = (unsigned int)ED25519_PUBKEY_SIZE; + void* _t870; + _t870 = Alloc(_t869); + pubBuf = _t870; + void* priv; + _t871 = (unsigned int)ED25519_PRIVKEY_SIZE; + void* _t872; + _t872 = Alloc(_t871); + priv = _t872; + int _t873; + _t873 = bux_ed25519_keypair(pubBuf, priv); + _t874 = (_t873 != 1); + if (!_t874) goto endif300; + { + Free(pubBuf); + Free(priv); + return ""; + } + endif300:; + const char* pubB64; + _t875 = (const char*)pubBuf; + const char* _t876; + _t876 = bux_base64_encode(_t875, ED25519_PUBKEY_SIZE); + pubB64 = _t876; + const char* privB64; + _t877 = (const char*)priv; + const char* _t878; + _t878 = bux_base64_encode(_t877, ED25519_PRIVKEY_SIZE); + privB64 = _t878; + Free(pubBuf); + Free(priv); + const char* pair; + const char* _t879; + _t879 = String_Concat(pubB64, ":"); + pair = _t879; + const char* _t880; + _t880 = String_Concat(pair, privB64); + return _t880; +} + +const char* Ed25519_Sign(const char* privKey, const char* data) { + unsigned int _t881; + int _t884; + int _t886; + const char* _t887; + void* sig; + _t881 = (unsigned int)ED25519_SIG_SIZE; + void* _t882; + _t882 = Alloc(_t881); + sig = _t882; + unsigned int _t883; + _t883 = String_Len(data); + _t884 = (int)_t883; + int _t885; + _t885 = bux_ed25519_sign(privKey, data, _t884, sig); + _t886 = (_t885 != 1); + if (!_t886) goto endif302; + { + Free(sig); + return ""; + } + endif302:; + _t887 = (const char*)sig; + return _t887; +} + +const char* Ed25519_SignBase64(const char* privKey, const char* data) { + int _t890; + const char* sig; + const char* _t888; + _t888 = Ed25519_Sign(privKey, data); + sig = _t888; + unsigned int _t889; + _t889 = String_Len(sig); + _t890 = (_t889 == 0); + if (!_t890) goto endif304; + { + return ""; + } + endif304:; + const char* _t891; + _t891 = bux_base64_encode(sig, ED25519_SIG_SIZE); + return _t891; +} + +bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data) { + int _t893; + int _t895; + int r; + unsigned int _t892; + _t892 = String_Len(data); + _t893 = (int)_t892; + int _t894; + _t894 = bux_ed25519_verify(pubKey, signature, data, _t893); + r = _t894; + _t895 = (r == 1); + return _t895; +} + +bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data) { + int _t897; + void* _t898; + int _t900; + int outlen; + outlen = 0; + const char* sig; + unsigned int _t896; + _t896 = String_Len(signatureB64); + _t897 = (int)_t896; + _t898 = &outlen; + const char* _t899; + _t899 = bux_base64_decode(signatureB64, _t897, _t898); + sig = _t899; + _t900 = (outlen != ED25519_SIG_SIZE); + if (!_t900) goto endif306; + { + return 0; + } + endif306:; + bool _t901; + _t901 = Ed25519_Verify(pubKey, sig, data); + return _t901; +} + +const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data) { + int _t903; + int _t905; + void* _t906; + int siglen; + siglen = 0; + unsigned int _t902; + _t902 = String_Len(pemPrivateKey); + _t903 = (int)_t902; + unsigned int _t904; + _t904 = String_Len(data); + _t905 = (int)_t904; + _t906 = &siglen; + const char* _t907; + _t907 = bux_rsa_sign_sha256(pemPrivateKey, _t903, data, _t905, _t906); + return _t907; +} + +const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data) { + int _t909; + int _t911; + void* _t912; + int siglen; + siglen = 0; + unsigned int _t908; + _t908 = String_Len(pemPrivateKey); + _t909 = (int)_t908; + unsigned int _t910; + _t910 = String_Len(data); + _t911 = (int)_t910; + _t912 = &siglen; + const char* _t913; + _t913 = bux_rsa_sign_sha384(pemPrivateKey, _t909, data, _t911, _t912); + return _t913; +} + +const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data) { + int _t915; + int _t917; + void* _t918; + int siglen; + siglen = 0; + unsigned int _t914; + _t914 = String_Len(pemPrivateKey); + _t915 = (int)_t914; + unsigned int _t916; + _t916 = String_Len(data); + _t917 = (int)_t916; + _t918 = &siglen; + const char* _t919; + _t919 = bux_rsa_sign_sha512(pemPrivateKey, _t915, data, _t917, _t918); + return _t919; +} + +const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data) { + int _t922; + const char* raw; + const char* _t920; + _t920 = Rsa_SignSha256(pemPrivateKey, data); + raw = _t920; + unsigned int _t921; + _t921 = String_Len(raw); + _t922 = (int)_t921; + const char* _t923; + _t923 = bux_base64_encode(raw, _t922); + return _t923; +} + +const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data) { + int _t926; + const char* raw; + const char* _t924; + _t924 = Rsa_SignSha384(pemPrivateKey, data); + raw = _t924; + unsigned int _t925; + _t925 = String_Len(raw); + _t926 = (int)_t925; + const char* _t927; + _t927 = bux_base64_encode(raw, _t926); + return _t927; +} + +const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data) { + int _t930; + const char* raw; + const char* _t928; + _t928 = Rsa_SignSha512(pemPrivateKey, data); + raw = _t928; + unsigned int _t929; + _t929 = String_Len(raw); + _t930 = (int)_t929; + const char* _t931; + _t931 = bux_base64_encode(raw, _t930); + return _t931; +} + +bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature) { + int _t933; + int _t935; + int _t937; + int _t939; + int r; + unsigned int _t932; + _t932 = String_Len(pemPublicKey); + _t933 = (int)_t932; + unsigned int _t934; + _t934 = String_Len(data); + _t935 = (int)_t934; + unsigned int _t936; + _t936 = String_Len(signature); + _t937 = (int)_t936; + int _t938; + _t938 = bux_rsa_verify_sha256(pemPublicKey, _t933, data, _t935, signature, _t937); + r = _t938; + _t939 = (r == 1); + return _t939; +} + +bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature) { + int _t941; + int _t943; + int _t945; + int _t947; + int r; + unsigned int _t940; + _t940 = String_Len(pemPublicKey); + _t941 = (int)_t940; + unsigned int _t942; + _t942 = String_Len(data); + _t943 = (int)_t942; + unsigned int _t944; + _t944 = String_Len(signature); + _t945 = (int)_t944; + int _t946; + _t946 = bux_rsa_verify_sha384(pemPublicKey, _t941, data, _t943, signature, _t945); + r = _t946; + _t947 = (r == 1); + return _t947; +} + +bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature) { + int _t949; + int _t951; + int _t953; + int _t955; + int r; + unsigned int _t948; + _t948 = String_Len(pemPublicKey); + _t949 = (int)_t948; + unsigned int _t950; + _t950 = String_Len(data); + _t951 = (int)_t950; + unsigned int _t952; + _t952 = String_Len(signature); + _t953 = (int)_t952; + int _t954; + _t954 = bux_rsa_verify_sha512(pemPublicKey, _t949, data, _t951, signature, _t953); + r = _t954; + _t955 = (r == 1); + return _t955; +} + +bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { + int _t957; + void* _t958; + int outlen; + outlen = 0; + const char* sig; + unsigned int _t956; + _t956 = String_Len(signatureB64); + _t957 = (int)_t956; + _t958 = &outlen; + const char* _t959; + _t959 = bux_base64_decode(signatureB64, _t957, _t958); + sig = _t959; + bool _t960; + _t960 = Rsa_VerifySha256(pemPublicKey, data, sig); + return _t960; +} + +bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { + int _t962; + void* _t963; + int outlen; + outlen = 0; + const char* sig; + unsigned int _t961; + _t961 = String_Len(signatureB64); + _t962 = (int)_t961; + _t963 = &outlen; + const char* _t964; + _t964 = bux_base64_decode(signatureB64, _t962, _t963); + sig = _t964; + bool _t965; + _t965 = Rsa_VerifySha384(pemPublicKey, data, sig); + return _t965; +} + +bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { + int _t967; + void* _t968; + int outlen; + outlen = 0; + const char* sig; + unsigned int _t966; + _t966 = String_Len(signatureB64); + _t967 = (int)_t966; + _t968 = &outlen; + const char* _t969; + _t969 = bux_base64_decode(signatureB64, _t967, _t968); + sig = _t969; + bool _t970; + _t970 = Rsa_VerifySha512(pemPublicKey, data, sig); + return _t970; +} + +const char* Name(Color c) { + int _t971; + int _t972; + const char* __tmp_11; + _t971 = (c == Color_Red); + if (!_t971) goto else307; + __tmp_11 = "red"; + goto endif308; + else307:; + _t972 = (c == Color_Green); + if (!_t972) goto endif310; + __tmp_11 = "green"; + endif310:; + endif308:; + return __tmp_11; +} + +int Main(void) { + Record _t976; + void* _t978; + void* _t980; + void* _t982; + int _t985; + Record _t986; + int _t990; + Box box; + Array_Record _t973; + _t973 = Array_New_Record(4); + box.items = _t973; + Array_Record _t974; + _t974 = box.items; + void* _t975; + _t975 = &(box.items); + _t976 = (Record){.name = "x", .value = 10}; + Array_Push_Record(_t975, _t976); + { + Array_Record __tmp_13; + Array_Record _t977; + _t977 = box.items; + __tmp_13 = _t977; + Iter_Record __iter_it_11; + _t978 = &__tmp_13; + Iter_Record _t979; + _t979 = Array_Iter_Record(_t978); + __iter_it_11 = _t979; + while311:; + _t980 = &__iter_it_11; + bool _t981; + _t981 = Iter_HasNext_Record(_t980); + if (!_t981) goto wend312; + Record it; + _t982 = &__iter_it_11; + Record _t983; + _t983 = Iter_Next_Record(_t982); + it = _t983; + { + int _t984; + _t984 = it.value; + _t985 = (_t984 == 10); + if (!_t985) goto endif314; + { + return 0; + } + endif314:; + } + goto while311; + wend312:; + } + Payload r; + r.tag = Payload_Ok; + _t986 = (Record){.name = "y", .value = 20}; + r.data.Ok_0 = _t986; + Payload_Data _t987; + _t987 = r.data; + Record _t988; + _t988 = _t987.Ok_0; + int _t989; + _t989 = _t988.value; + _t990 = (_t989 == 20); + if (!_t990) goto endif316; + { + return 0; + } + endif316:; + return 1; +} + +Array_Record Array_New_Record(unsigned int cap) { + int _t991; + Record* _t993; + Array_Record _t994; + Record* data; + /* sizeof(Record) */ + _t991 = cap * sizeof(Record); + void* _t992; + _t992 = bux_alloc(_t991); + _t993 = (Record*)_t992; + data = _t993; + _t994 = (Array_Record){.data = data, .len = 0, .cap = cap}; + return _t994; +} + +void Array_Push_Record(Array_Record* self, Record value) { + int _t997; + int _t999; + void* _t1001; + int _t1003; + Record* _t1005; + int _t1009; + unsigned int _t995; + _t995 = self->len; + unsigned int _t996; + _t996 = self->cap; + _t997 = (_t995 >= _t996); + if (!_t997) goto endif318; + { + unsigned int _t998; + _t998 = self->cap; + _t999 = _t998 * 2; + self->cap = _t999; + Record* _t1000; + _t1000 = self->data; + _t1001 = (void*)_t1000; + unsigned int _t1002; + _t1002 = self->cap; + /* sizeof(Record) */ + _t1003 = _t1002 * sizeof(Record); + void* _t1004; + _t1004 = bux_realloc(_t1001, _t1003); + _t1005 = (Record*)_t1004; + self->data = _t1005; + } + endif318:; + Record* _t1006; + _t1006 = self->data; + unsigned int _t1007; + _t1007 = self->len; + _t1006[_t1007] = value; + unsigned int _t1008; + _t1008 = self->len; + _t1009 = _t1008 + 1; + self->len = _t1009; +} + +Iter_Record Array_Iter_Record(Array_Record* arr) { + Iter_Record _t1012; + Record* _t1010; + _t1010 = arr->data; + unsigned int _t1011; + _t1011 = arr->len; + _t1012 = (Iter_Record){.data = _t1010, .len = _t1011, .pos = 0}; + return _t1012; +} + +bool Iter_HasNext_Record(Iter_Record* it) { + int _t1015; + unsigned int _t1013; + _t1013 = it->pos; + unsigned int _t1014; + _t1014 = it->len; + _t1015 = (_t1013 < _t1014); + return _t1015; +} + +Record Iter_Next_Record(Iter_Record* it) { + int _t1020; + Record val; + Record* _t1016; + _t1016 = it->data; + unsigned int _t1017; + _t1017 = it->pos; + Record _t1018; + _t1018 = _t1016[_t1017]; + val = _t1018; + unsigned int _t1019; + _t1019 = it->pos; + _t1020 = _t1019 + 1; + it->pos = _t1020; + return val; +} + +/* C entry point wrapper */ +extern int g_argc; +extern char** g_argv; +int main(int argc, char** argv) { + g_argc = argc; + g_argv = argv; + return Main(); +} diff --git a/tests/golden/modern_features/src/Main.bux b/tests/golden/modern_features/src/Main.bux new file mode 100644 index 0000000..d7d80a4 --- /dev/null +++ b/tests/golden/modern_features/src/Main.bux @@ -0,0 +1,49 @@ +module Main { + +import Std::Array::{Array, Array_New, Array_Push}; + +struct Record { + name: String; + value: int; +} + +struct Box { + items: Array; +} + +enum Payload { + Ok(Record), + Err(String), +} + +enum Color { Red, Green } + +func Name(c: Color) -> String { + match c { + Color::Red => "red", + Color::Green => "green", + } +} + +func Main() -> int { + var box: Box; + box.items = Array_New(4); + Array_Push(&box.items, Record { name: "x", value: 10 }); + + for it in box.items { + if it.value == 10 { + return 0; + } + } + + var r: Payload; + r.tag = Payload_Ok; + r.data.Ok_0 = Record { name: "y", value: 20 }; + if r.data.Ok_0.value == 20 { + return 0; + } + + return 1; +} + +} diff --git a/tests/golden/strings/expected.c b/tests/golden/strings/expected.c index 6e072c6..56f4e70 100644 --- a/tests/golden/strings/expected.c +++ b/tests/golden/strings/expected.c @@ -198,6 +198,34 @@ extern const char* bux_base64_decode(const char* data, int len, int* outlen); #define ED25519_PRIVKEY_SIZE 32 #define ED25519_SIG_SIZE 64 +typedef struct Channel_float64 { + void* handle; +} Channel_float64; + +typedef struct TaskHandle { + void* handle; +} TaskHandle; + +typedef struct RwLock { + void* handle; +} RwLock; + +typedef struct Channel_int { + void* handle; +} Channel_int; + +typedef enum { + JwtAlg_HS256, + JwtAlg_HS384, + JwtAlg_HS512, + JwtAlg_RS256, + JwtAlg_RS384, + JwtAlg_RS512, + JwtAlg_ES256, + JwtAlg_ES384, + JwtAlg_EdDSA +} JwtAlg; + typedef enum { Result_Ok, Result_Err @@ -227,31 +255,6 @@ typedef struct { Option_Data data; } Option; -typedef enum { - JwtAlg_HS256, - JwtAlg_HS384, - JwtAlg_HS512, - JwtAlg_RS256, - JwtAlg_RS384, - JwtAlg_RS512, - JwtAlg_ES256, - JwtAlg_ES384, - JwtAlg_EdDSA -} JwtAlg; - - -typedef struct TaskHandle { - void* handle; -} TaskHandle; - -typedef struct Mutex { - void* handle; -} Mutex; - -typedef struct RwLock { - void* handle; -} RwLock; - typedef struct JsonValue { int tag; bool boolVal; @@ -266,6 +269,14 @@ typedef struct JsonValue { unsigned int objCap; } JsonValue; +typedef struct Mutex { + void* handle; +} Mutex; + +typedef struct StringBuilder { + void* handle; +} StringBuilder; + typedef struct JsonParser { const char* src; unsigned int pos; @@ -273,18 +284,6 @@ typedef struct JsonParser { const char* error; } JsonParser; -typedef struct StringBuilder { - void* handle; -} StringBuilder; - -typedef struct Channel_int { - void* handle; -} Channel_int; - -typedef struct Channel_float64 { - void* handle; -} Channel_float64; - bool DirExists(const char* path); bool Mkdir(const char* path); const char** ListDir(const char* dir, const char* ext, int* count); @@ -866,7 +865,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { tmplLen = _t60; while1:; _t61 = (i < tmplLen); - if (!_t61) goto wend3; + if (!_t61) goto wend2; { const char* ch; const char* _t62; @@ -874,13 +873,13 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { ch = _t62; bool _t63; _t63 = String_Eq(ch, "{"); - if (!_t63) goto endif5; + if (!_t63) goto endif4; { unsigned int digitIdx; _t64 = i + 1; digitIdx = _t64; _t65 = (digitIdx < tmplLen); - if (!_t65) goto endif7; + if (!_t65) goto endif6; { const char* digitCh; const char* _t66; @@ -892,22 +891,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { d = _t67; bool __and_tmp_0; _t68 = (d >= 0); - if (!_t68) goto else8; + if (!_t68) goto else7; _t69 = (int64_t)argCount; _t70 = (d < _t69); *(bool*)&__and_tmp_0 = _t70; - goto endif9; - else8:; + goto endif8; + else7:; *(bool*)&__and_tmp_0 = 0; - endif9:; + endif8:; bool _t71; _t71 = *(bool*)&__and_tmp_0; - if (!_t71) goto endif11; + if (!_t71) goto endif10; { _t72 = i + 2; i = _t72; _t73 = (i < tmplLen); - if (!_t73) goto endif13; + if (!_t73) goto endif12; { const char* closeCh; const char* _t74; @@ -915,7 +914,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { closeCh = _t74; bool _t75; _t75 = String_Eq(closeCh, "}"); - if (!_t75) goto endif15; + if (!_t75) goto endif14; { _t76 = i + 1; i = _t76; @@ -928,22 +927,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { StringBuilder_Append(_t79, argStr); goto while1; } - endif15:; + endif14:; } - endif13:; + endif12:; } - endif11:; + endif10:; } - endif7:; + endif6:; } - endif5:; + endif4:; _t80 = &sb; StringBuilder_Append(_t80, ch); _t81 = i + 1; i = _t81; } goto while1; - wend3:; + wend2:; _t82 = &sb; const char* _t83; _t83 = StringBuilder_Build(_t82); @@ -951,276 +950,276 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { } const char* Fmt_Fmt1(const char* tmpl, const char* a1) { - const char** _t86; + const char** _t85; const char** args; /* sizeof(const char*) */ - void* _t85; - _t85 = bux_alloc(sizeof(const char*)); - _t86 = (const char**)_t85; - args = _t86; + void* _t84; + _t84 = bux_alloc(sizeof(const char*)); + _t85 = (const char**)_t84; + args = _t85; args[0] = a1; - const char* _t87; - _t87 = Fmt_Format(tmpl, args, 1); - return _t87; + const char* _t86; + _t86 = Fmt_Format(tmpl, args, 1); + return _t86; } const char* Fmt_FmtInt(const char* tmpl, int64_t val) { const char* s; + const char* _t87; + _t87 = String_FromInt(val); + s = _t87; const char* _t88; - _t88 = String_FromInt(val); - s = _t88; - const char* _t89; - _t89 = Fmt_Fmt1(tmpl, s); - return _t89; + _t88 = Fmt_Fmt1(tmpl, s); + return _t88; } const char* Fmt_FmtBool(const char* tmpl, bool val) { const char* s; + const char* _t89; + _t89 = String_FromBool(val); + s = _t89; const char* _t90; - _t90 = String_FromBool(val); - s = _t90; - const char* _t91; - _t91 = Fmt_Fmt1(tmpl, s); - return _t91; + _t90 = Fmt_Fmt1(tmpl, s); + return _t90; } const char* Fmt_FmtFloat(const char* tmpl, double val) { const char* s; + const char* _t91; + _t91 = String_FromFloat(val); + s = _t91; const char* _t92; - _t92 = String_FromFloat(val); - s = _t92; - const char* _t93; - _t93 = Fmt_Fmt1(tmpl, s); - return _t93; + _t92 = Fmt_Fmt1(tmpl, s); + return _t92; } const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2) { - int _t95; - const char** _t97; + int _t93; + const char** _t95; const char** args; /* sizeof(const char*) */ - _t95 = 2 * sizeof(const char*); - void* _t96; - _t96 = bux_alloc(_t95); - _t97 = (const char**)_t96; - args = _t97; + _t93 = 2 * sizeof(const char*); + void* _t94; + _t94 = bux_alloc(_t93); + _t95 = (const char**)_t94; + args = _t95; args[0] = a1; args[1] = a2; - const char* _t98; - _t98 = Fmt_Format(tmpl, args, 2); - return _t98; + const char* _t96; + _t96 = Fmt_Format(tmpl, args, 2); + return _t96; } const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3) { - int _t100; - const char** _t102; + int _t97; + const char** _t99; const char** args; /* sizeof(const char*) */ - _t100 = 3 * sizeof(const char*); - void* _t101; - _t101 = bux_alloc(_t100); - _t102 = (const char**)_t101; - args = _t102; + _t97 = 3 * sizeof(const char*); + void* _t98; + _t98 = bux_alloc(_t97); + _t99 = (const char**)_t98; + args = _t99; args[0] = a1; args[1] = a2; args[2] = a3; - const char* _t103; - _t103 = Fmt_Format(tmpl, args, 3); - return _t103; + const char* _t100; + _t100 = Fmt_Format(tmpl, args, 3); + return _t100; } const char* Crypto_Sha256(const char* data) { - int _t105; - void* _t107; + int _t102; + void* _t104; int len; - unsigned int _t104; - _t104 = String_Len(data); - _t105 = (int)_t104; - len = _t105; + unsigned int _t101; + _t101 = String_Len(data); + _t102 = (int)_t101; + len = _t102; void* hashBuf; - void* _t106; - _t106 = Alloc(32); - hashBuf = _t106; + void* _t103; + _t103 = Alloc(32); + hashBuf = _t103; bux_sha256(data, len, hashBuf); const char* result; - _t107 = (void*)hashBuf; - const char* _t108; - _t108 = bux_bytes_to_hex(_t107, 32); - result = _t108; + _t104 = (void*)hashBuf; + const char* _t105; + _t105 = bux_bytes_to_hex(_t104, 32); + result = _t105; Free(hashBuf); return result; } const char* Crypto_HmacSha256(const char* key, const char* message) { - int _t110; - int _t112; - void* _t114; + int _t107; + int _t109; + void* _t111; int keylen; - unsigned int _t109; - _t109 = String_Len(key); - _t110 = (int)_t109; - keylen = _t110; + unsigned int _t106; + _t106 = String_Len(key); + _t107 = (int)_t106; + keylen = _t107; int msglen; - unsigned int _t111; - _t111 = String_Len(message); - _t112 = (int)_t111; - msglen = _t112; + unsigned int _t108; + _t108 = String_Len(message); + _t109 = (int)_t108; + msglen = _t109; void* hmacBuf; - void* _t113; - _t113 = Alloc(32); - hmacBuf = _t113; + void* _t110; + _t110 = Alloc(32); + hmacBuf = _t110; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t114 = (void*)hmacBuf; - const char* _t115; - _t115 = bux_bytes_to_hex(_t114, 32); - result = _t115; + _t111 = (void*)hmacBuf; + const char* _t112; + _t112 = bux_bytes_to_hex(_t111, 32); + result = _t112; Free(hmacBuf); return result; } const char* Crypto_RandomBytes(int n) { - int _t116; - unsigned int _t117; - int _t120; - const char* _t121; - _t116 = (n <= 0); - if (!_t116) goto endif17; + int _t113; + unsigned int _t114; + int _t117; + const char* _t118; + _t113 = (n <= 0); + if (!_t113) goto endif16; { return ""; } - endif17:; + endif16:; void* buf; - _t117 = (unsigned int)n; - void* _t118; - _t118 = Alloc(_t117); - buf = _t118; - int _t119; - _t119 = bux_random_bytes(buf, n); - _t120 = (_t119 != 1); - if (!_t120) goto endif19; + _t114 = (unsigned int)n; + void* _t115; + _t115 = Alloc(_t114); + buf = _t115; + int _t116; + _t116 = bux_random_bytes(buf, n); + _t117 = (_t116 != 1); + if (!_t117) goto endif18; { Free(buf); return ""; } - endif19:; + endif18:; const char* result; - _t121 = (const char*)buf; - const char* _t122; - _t122 = bux_base64_encode(_t121, n); - result = _t122; + _t118 = (const char*)buf; + const char* _t119; + _t119 = bux_base64_encode(_t118, n); + result = _t119; Free(buf); return result; } const char* Crypto_Base64Encode(const char* s) { - int _t124; - unsigned int _t123; - _t123 = String_Len(s); - _t124 = (int)_t123; - const char* _t125; - _t125 = bux_base64_encode(s, _t124); - return _t125; + int _t121; + unsigned int _t120; + _t120 = String_Len(s); + _t121 = (int)_t120; + const char* _t122; + _t122 = bux_base64_encode(s, _t121); + return _t122; } const char* Crypto_HmacSha256Raw(const char* key, const char* message) { - int _t127; - int _t129; - const char* _t131; + int _t124; + int _t126; + const char* _t128; int keylen; - unsigned int _t126; - _t126 = String_Len(key); - _t127 = (int)_t126; - keylen = _t127; + unsigned int _t123; + _t123 = String_Len(key); + _t124 = (int)_t123; + keylen = _t124; int msglen; - unsigned int _t128; - _t128 = String_Len(message); - _t129 = (int)_t128; - msglen = _t129; + unsigned int _t125; + _t125 = String_Len(message); + _t126 = (int)_t125; + msglen = _t126; void* hmacBuf; - void* _t130; - _t130 = Alloc(32); - hmacBuf = _t130; + void* _t127; + _t127 = Alloc(32); + hmacBuf = _t127; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t131 = (const char*)hmacBuf; - const char* _t132; - _t132 = bux_base64_encode(_t131, 32); - result = _t132; + _t128 = (const char*)hmacBuf; + const char* _t129; + _t129 = bux_base64_encode(_t128, 32); + result = _t129; Free(hmacBuf); return result; } const char* Crypto_Base64Decode(const char* s) { - int _t134; - void* _t135; + int _t131; + void* _t132; int outlen; outlen = 0; - unsigned int _t133; - _t133 = String_Len(s); - _t134 = (int)_t133; - _t135 = &outlen; - const char* _t136; - _t136 = bux_base64_decode(s, _t134, _t135); - return _t136; + unsigned int _t130; + _t130 = String_Len(s); + _t131 = (int)_t130; + _t132 = &outlen; + const char* _t133; + _t133 = bux_base64_decode(s, _t131, _t132); + return _t133; } Mutex Mutex_New(void) { - Mutex _t138; - void* _t137; - _t137 = bux_mutex_new(); - _t138 = (Mutex){.handle = _t137}; - return _t138; + Mutex _t135; + void* _t134; + _t134 = bux_mutex_new(); + _t135 = (Mutex){.handle = _t134}; + return _t135; } void Mutex_Lock(Mutex* m) { - void* _t139; - _t139 = m->handle; - bux_mutex_lock(_t139); + void* _t136; + _t136 = m->handle; + bux_mutex_lock(_t136); } void Mutex_Unlock(Mutex* m) { - void* _t140; - _t140 = m->handle; - bux_mutex_unlock(_t140); + void* _t137; + _t137 = m->handle; + bux_mutex_unlock(_t137); } void Mutex_Free(Mutex* m) { - void* _t141; - _t141 = m->handle; - bux_mutex_free(_t141); + void* _t138; + _t138 = m->handle; + bux_mutex_free(_t138); } RwLock RwLock_New(void) { - RwLock _t143; - void* _t142; - _t142 = bux_rwlock_new(); - _t143 = (RwLock){.handle = _t142}; - return _t143; + RwLock _t140; + void* _t139; + _t139 = bux_rwlock_new(); + _t140 = (RwLock){.handle = _t139}; + return _t140; } void RwLock_ReadLock(RwLock* rw) { - void* _t144; - _t144 = rw->handle; - bux_rwlock_rdlock(_t144); + void* _t141; + _t141 = rw->handle; + bux_rwlock_rdlock(_t141); } void RwLock_WriteLock(RwLock* rw) { - void* _t145; - _t145 = rw->handle; - bux_rwlock_wrlock(_t145); + void* _t142; + _t142 = rw->handle; + bux_rwlock_wrlock(_t142); } void RwLock_Unlock(RwLock* rw) { - void* _t146; - _t146 = rw->handle; - bux_rwlock_unlock(_t146); + void* _t143; + _t143 = rw->handle; + bux_rwlock_unlock(_t143); } void RwLock_Free(RwLock* rw) { - void* _t147; - _t147 = rw->handle; - bux_rwlock_free(_t147); + void* _t144; + _t144 = rw->handle; + bux_rwlock_free(_t144); } void Test_Exit(int code) { @@ -1228,15 +1227,15 @@ void Test_Exit(int code) { } void Test_Assert(bool cond) { - int _t148; - _t148 = (int)cond; - bux_assert(_t148, "", 0, ""); + int _t145; + _t145 = (int)cond; + bux_assert(_t145, "", 0, ""); } void Test_AssertEqInt(int a, int b) { - int _t149; - _t149 = (a != b); - if (!_t149) goto endif21; + int _t146; + _t146 = (a != b); + if (!_t146) goto endif20; { PrintLine("ASSERT_EQ FAILED:"); PrintInt(a); @@ -1244,27 +1243,27 @@ void Test_AssertEqInt(int a, int b) { PrintInt(b); bux_exit(1); } - endif21:; + endif20:; } void Test_AssertTrue(bool cond) { - int _t150; - _t150 = !cond; - if (!_t150) goto endif23; + int _t147; + _t147 = !cond; + if (!_t147) goto endif22; { PrintLine("ASSERT_TRUE FAILED"); bux_exit(1); } - endif23:; + endif22:; } void Test_AssertFalse(bool cond) { - if (!cond) goto endif25; + if (!cond) goto endif24; { PrintLine("ASSERT_FALSE FAILED"); bux_exit(1); } - endif25:; + endif24:; } void Test_Fail(const char* msg) { @@ -1274,735 +1273,744 @@ void Test_Fail(const char* msg) { } Result Result_NewOk(int value) { - Result _t151; + Result _t148; Result r; - _t151 = (Result){.tag = Result_Ok}; - r = _t151; + _t148 = (Result){.tag = Result_Ok}; + r = _t148; r.data.Ok_0 = value; return r; } Result Result_NewErr(const char* msg) { - Result _t152; + Result _t149; Result r; - _t152 = (Result){.tag = Result_Err}; - r = _t152; + _t149 = (Result){.tag = Result_Err}; + r = _t149; r.data.Err_0 = msg; return r; } bool Result_IsOk(Result r) { - int _t154; - Result_Tag _t153; - _t153 = r.tag; - _t154 = (_t153 == Result_Ok); - return _t154; + int _t151; + Result_Tag _t150; + _t150 = r.tag; + _t151 = (_t150 == Result_Ok); + return _t151; } bool Result_IsErr(Result r) { - int _t156; - Result_Tag _t155; - _t155 = r.tag; - _t156 = (_t155 == Result_Err); - return _t156; + int _t153; + Result_Tag _t152; + _t152 = r.tag; + _t153 = (_t152 == Result_Err); + return _t153; } int Result_Unwrap(Result r) { - int _t158; - Result_Tag _t157; - _t157 = r.tag; - _t158 = (_t157 != Result_Ok); - if (!_t158) goto endif27; + int _t155; + Result_Tag _t154; + _t154 = r.tag; + _t155 = (_t154 != Result_Ok); + if (!_t155) goto endif26; { PrintLine("panic: unwrap on Err"); return 0; } - endif27:; - Result_Data _t159; - _t159 = r.data; - int _t160; - _t160 = _t159.Ok_0; - return _t160; + endif26:; + Result_Data _t156; + _t156 = r.data; + int _t157; + _t157 = _t156.Ok_0; + return _t157; } int Result_UnwrapOr(Result r, int fallback) { - int _t162; - Result_Tag _t161; - _t161 = r.tag; - _t162 = (_t161 == Result_Ok); - if (!_t162) goto endif29; + int _t159; + Result_Tag _t158; + _t158 = r.tag; + _t159 = (_t158 == Result_Ok); + if (!_t159) goto endif28; { - Result_Data _t163; - _t163 = r.data; - int _t164; - _t164 = _t163.Ok_0; - return _t164; + Result_Data _t160; + _t160 = r.data; + int _t161; + _t161 = _t160.Ok_0; + return _t161; } - endif29:; + endif28:; return fallback; } Option Option_NewSome(int value) { - Option _t165; + Option _t162; Option o; - _t165 = (Option){.tag = Option_Some}; - o = _t165; + _t162 = (Option){.tag = Option_Some}; + o = _t162; o.data.Some_0 = value; return o; } Option Option_NewNone(void) { - Option _t166; - _t166 = (Option){.tag = Option_None}; - return _t166; + Option _t163; + _t163 = (Option){.tag = Option_None}; + return _t163; } bool Option_IsSome(Option o) { - int _t168; - Option_Tag _t167; - _t167 = o.tag; - _t168 = (_t167 == Option_Some); - return _t168; + int _t165; + Option_Tag _t164; + _t164 = o.tag; + _t165 = (_t164 == Option_Some); + return _t165; } bool Option_IsNone(Option o) { - int _t170; - Option_Tag _t169; - _t169 = o.tag; - _t170 = (_t169 == Option_None); - return _t170; + int _t167; + Option_Tag _t166; + _t166 = o.tag; + _t167 = (_t166 == Option_None); + return _t167; } int Option_Unwrap(Option o) { - int _t172; - Option_Tag _t171; - _t171 = o.tag; - _t172 = (_t171 != Option_Some); - if (!_t172) goto endif31; + int _t169; + Option_Tag _t168; + _t168 = o.tag; + _t169 = (_t168 != Option_Some); + if (!_t169) goto endif30; { PrintLine("panic: unwrap on None"); return 0; } - endif31:; - Option_Data _t173; - _t173 = o.data; - int _t174; - _t174 = _t173.Some_0; - return _t174; + endif30:; + Option_Data _t170; + _t170 = o.data; + int _t171; + _t171 = _t170.Some_0; + return _t171; } int Option_UnwrapOr(Option o, int fallback) { - int _t176; - Option_Tag _t175; - _t175 = o.tag; - _t176 = (_t175 == Option_Some); - if (!_t176) goto endif33; + int _t173; + Option_Tag _t172; + _t172 = o.tag; + _t173 = (_t172 == Option_Some); + if (!_t173) goto endif32; { - Option_Data _t177; - _t177 = o.data; - int _t178; - _t178 = _t177.Some_0; - return _t178; + Option_Data _t174; + _t174 = o.data; + int _t175; + _t175 = _t174.Some_0; + return _t175; } - endif33:; + endif32:; return fallback; } JsonValue Json_Null(void) { - JsonValue _t179; - _t179 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t179; + JsonValue _t176; + _t176 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t176; } JsonValue Json_Bool(bool b) { - JsonValue _t180; - _t180 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t180; + JsonValue _t177; + _t177 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t177; } JsonValue Json_Number(double n) { - JsonValue _t181; - _t181 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t181; + JsonValue _t178; + _t178 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t178; } JsonValue Json_String(const char* s) { - JsonValue _t182; - _t182 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t182; + JsonValue _t179; + _t179 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t179; } JsonValue Json_Array(void) { - JsonValue _t183; - _t183 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t183; + JsonValue _t180; + _t180 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t180; } JsonValue Json_Object(void) { - JsonValue _t184; - _t184 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t184; + JsonValue _t181; + _t181 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t181; } unsigned int Json_ArrayLen(JsonValue v) { - int _t186; - int _t185; - _t185 = v.tag; - _t186 = (_t185 != JsonTagArray); - if (!_t186) goto endif35; + int _t183; + int _t182; + _t182 = v.tag; + _t183 = (_t182 != JsonTagArray); + if (!_t183) goto endif34; { return 0; } - endif35:; - unsigned int _t187; - _t187 = v.arrLen; - return _t187; + endif34:; + unsigned int _t184; + _t184 = v.arrLen; + return _t184; } JsonValue Json_ArrayGet(JsonValue v, unsigned int index) { + int _t186; int _t189; - int _t192; - int _t188; - _t188 = v.tag; - _t189 = (_t188 != JsonTagArray); - if (!_t189) goto endif37; + int _t185; + _t185 = v.tag; + _t186 = (_t185 != JsonTagArray); + if (!_t186) goto endif36; + { + JsonValue _t187; + _t187 = Json_Null(); + return _t187; + } + endif36:; + unsigned int _t188; + _t188 = v.arrLen; + _t189 = (index >= _t188); + if (!_t189) goto endif38; { JsonValue _t190; _t190 = Json_Null(); return _t190; } - endif37:; - unsigned int _t191; - _t191 = v.arrLen; - _t192 = (index >= _t191); - if (!_t192) goto endif39; - { - JsonValue _t193; - _t193 = Json_Null(); - return _t193; - } - endif39:; - JsonValue* _t194; - _t194 = v.arrData; - JsonValue _t195; - _t195 = _t194[index]; - return _t195; + endif38:; + JsonValue* _t191; + _t191 = v.arrData; + JsonValue _t192; + _t192 = _t191[index]; + return _t192; } void Json_ArrayPush(JsonValue* self, JsonValue val) { + int _t194; int _t197; + int _t199; int _t200; - int _t202; - int _t204; - JsonValue* _t206; - int _t207; - void* _t209; - int _t211; - JsonValue* _t213; - int _t217; - int _t196; - _t196 = self->tag; - _t197 = (_t196 != JsonTagArray); - if (!_t197) goto endif41; + JsonValue* _t202; + int _t203; + void* _t205; + int _t206; + JsonValue* _t208; + int _t212; + int _t193; + _t193 = self->tag; + _t194 = (_t193 != JsonTagArray); + if (!_t194) goto endif40; { return; } - endif41:; - unsigned int _t198; - _t198 = self->arrLen; - unsigned int _t199; - _t199 = self->arrCap; - _t200 = (_t198 >= _t199); - if (!_t200) goto endif43; + endif40:; + unsigned int _t195; + _t195 = self->arrLen; + unsigned int _t196; + _t196 = self->arrCap; + _t197 = (_t195 >= _t196); + if (!_t197) goto endif42; { unsigned int arrNewCap; - unsigned int _t201; - _t201 = self->arrCap; - arrNewCap = _t201; - _t202 = (arrNewCap == 0); - if (!_t202) goto else44; + unsigned int _t198; + _t198 = self->arrCap; + arrNewCap = _t198; + _t199 = (arrNewCap == 0); + if (!_t199) goto else43; { self->arrCap = 4; /* sizeof(JsonValue) */ - _t204 = 4 * sizeof(JsonValue); - void* _t205; - _t205 = Alloc(_t204); - _t206 = (JsonValue*)_t205; - self->arrData = _t206; + _t200 = 4 * sizeof(JsonValue); + void* _t201; + _t201 = Alloc(_t200); + _t202 = (JsonValue*)_t201; + self->arrData = _t202; } - goto endif45; - else44:; + goto endif44; + else43:; { unsigned int doubleCap; - _t207 = arrNewCap * 2; - doubleCap = _t207; + _t203 = arrNewCap * 2; + doubleCap = _t203; self->arrCap = doubleCap; - JsonValue* _t208; - _t208 = self->arrData; - _t209 = (void*)_t208; + JsonValue* _t204; + _t204 = self->arrData; + _t205 = (void*)_t204; /* sizeof(JsonValue) */ - _t211 = doubleCap * sizeof(JsonValue); - void* _t212; - _t212 = Realloc(_t209, _t211); - _t213 = (JsonValue*)_t212; - self->arrData = _t213; + _t206 = doubleCap * sizeof(JsonValue); + void* _t207; + _t207 = Realloc(_t205, _t206); + _t208 = (JsonValue*)_t207; + self->arrData = _t208; } - endif45:; + endif44:; } - endif43:; - JsonValue* _t214; - _t214 = self->arrData; - unsigned int _t215; - _t215 = self->arrLen; - _t214[_t215] = val; - unsigned int _t216; - _t216 = self->arrLen; - _t217 = _t216 + 1; - self->arrLen = _t217; + endif42:; + JsonValue* _t209; + _t209 = self->arrData; + unsigned int _t210; + _t210 = self->arrLen; + _t209[_t210] = val; + unsigned int _t211; + _t211 = self->arrLen; + _t212 = _t211 + 1; + self->arrLen = _t212; } unsigned int Json_ObjectLen(JsonValue v) { - int _t219; - int _t218; - _t218 = v.tag; - _t219 = (_t218 != JsonTagObject); - if (!_t219) goto endif47; + int _t214; + int _t213; + _t213 = v.tag; + _t214 = (_t213 != JsonTagObject); + if (!_t214) goto endif46; { return 0; } - endif47:; - unsigned int _t220; - _t220 = v.objLen; - return _t220; + endif46:; + unsigned int _t215; + _t215 = v.objLen; + return _t215; } JsonValue Json_ObjectGet(JsonValue v, const char* key) { - int _t222; - int _t225; - int _t231; - int _t221; - _t221 = v.tag; - _t222 = (_t221 != JsonTagObject); - if (!_t222) goto endif49; + int _t217; + int _t220; + int _t226; + int _t216; + _t216 = v.tag; + _t217 = (_t216 != JsonTagObject); + if (!_t217) goto endif48; { - JsonValue _t223; - _t223 = Json_Null(); - return _t223; + JsonValue _t218; + _t218 = Json_Null(); + return _t218; } - endif49:; + endif48:; unsigned int i; i = 0; - while50:; - unsigned int _t224; - _t224 = v.objLen; - _t225 = (i < _t224); - if (!_t225) goto wend52; + while49:; + unsigned int _t219; + _t219 = v.objLen; + _t220 = (i < _t219); + if (!_t220) goto wend50; { - const char** _t226; - _t226 = v.objKeys; - const char* _t227; - _t227 = _t226[i]; - bool _t228; - _t228 = String_Eq(_t227, key); - if (!_t228) goto endif54; + const char** _t221; + _t221 = v.objKeys; + const char* _t222; + _t222 = _t221[i]; + bool _t223; + _t223 = String_Eq(_t222, key); + if (!_t223) goto endif52; { - JsonValue* _t229; - _t229 = v.objValues; - JsonValue _t230; - _t230 = _t229[i]; - return _t230; + JsonValue* _t224; + _t224 = v.objValues; + JsonValue _t225; + _t225 = _t224[i]; + return _t225; } - endif54:; - _t231 = i + 1; - i = _t231; + endif52:; + _t226 = i + 1; + i = _t226; } - goto while50; - wend52:; - JsonValue _t232; - _t232 = Json_Null(); - return _t232; + goto while49; + wend50:; + JsonValue _t227; + _t227 = Json_Null(); + return _t227; } bool Json_ObjectHas(JsonValue v, const char* key) { - int _t234; - int _t236; - int _t240; - int _t233; - _t233 = v.tag; - _t234 = (_t233 != JsonTagObject); - if (!_t234) goto endif56; + int _t229; + int _t231; + int _t235; + int _t228; + _t228 = v.tag; + _t229 = (_t228 != JsonTagObject); + if (!_t229) goto endif54; { return 0; } - endif56:; + endif54:; unsigned int i; i = 0; - while57:; - unsigned int _t235; - _t235 = v.objLen; - _t236 = (i < _t235); - if (!_t236) goto wend59; + while55:; + unsigned int _t230; + _t230 = v.objLen; + _t231 = (i < _t230); + if (!_t231) goto wend56; { - const char** _t237; - _t237 = v.objKeys; - const char* _t238; - _t238 = _t237[i]; - bool _t239; - _t239 = String_Eq(_t238, key); - if (!_t239) goto endif61; + const char** _t232; + _t232 = v.objKeys; + const char* _t233; + _t233 = _t232[i]; + bool _t234; + _t234 = String_Eq(_t233, key); + if (!_t234) goto endif58; { return 1; } - endif61:; - _t240 = i + 1; - i = _t240; + endif58:; + _t235 = i + 1; + i = _t235; } - goto while57; - wend59:; + goto while55; + wend56:; return 0; } void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) { - int _t242; + int _t237; + int _t239; int _t244; + int _t247; int _t249; - int _t252; - int _t254; + int _t250; + const char** _t252; + int _t253; + JsonValue* _t255; int _t256; - const char** _t258; - int _t260; - JsonValue* _t262; - int _t263; - void* _t265; - int _t267; - const char** _t269; - void* _t271; - int _t273; - JsonValue* _t275; - int _t281; - int _t241; - _t241 = self->tag; - _t242 = (_t241 != JsonTagObject); - if (!_t242) goto endif63; + void* _t258; + int _t259; + const char** _t261; + void* _t263; + int _t264; + JsonValue* _t266; + int _t272; + int _t236; + _t236 = self->tag; + _t237 = (_t236 != JsonTagObject); + if (!_t237) goto endif60; { return; } - endif63:; + endif60:; unsigned int i; i = 0; - while64:; - unsigned int _t243; - _t243 = self->objLen; - _t244 = (i < _t243); - if (!_t244) goto wend66; + while61:; + unsigned int _t238; + _t238 = self->objLen; + _t239 = (i < _t238); + if (!_t239) goto wend62; { - const char** _t245; - _t245 = self->objKeys; - const char* _t246; - _t246 = _t245[i]; - bool _t247; - _t247 = String_Eq(_t246, key); - if (!_t247) goto endif68; + const char** _t240; + _t240 = self->objKeys; + const char* _t241; + _t241 = _t240[i]; + bool _t242; + _t242 = String_Eq(_t241, key); + if (!_t242) goto endif64; { - JsonValue* _t248; - _t248 = self->objValues; - _t248[i] = val; + JsonValue* _t243; + _t243 = self->objValues; + _t243[i] = val; return; } - endif68:; - _t249 = i + 1; - i = _t249; + endif64:; + _t244 = i + 1; + i = _t244; } - goto while64; - wend66:; - unsigned int _t250; - _t250 = self->objLen; - unsigned int _t251; - _t251 = self->objCap; - _t252 = (_t250 >= _t251); - if (!_t252) goto endif70; + goto while61; + wend62:; + unsigned int _t245; + _t245 = self->objLen; + unsigned int _t246; + _t246 = self->objCap; + _t247 = (_t245 >= _t246); + if (!_t247) goto endif66; { unsigned int objNewCap; - unsigned int _t253; - _t253 = self->objCap; - objNewCap = _t253; - _t254 = (objNewCap == 0); - if (!_t254) goto else71; + unsigned int _t248; + _t248 = self->objCap; + objNewCap = _t248; + _t249 = (objNewCap == 0); + if (!_t249) goto else67; { self->objCap = 4; /* sizeof(const char*) */ - _t256 = 4 * sizeof(const char*); - void* _t257; - _t257 = Alloc(_t256); - _t258 = (const char**)_t257; - self->objKeys = _t258; + _t250 = 4 * sizeof(const char*); + void* _t251; + _t251 = Alloc(_t250); + _t252 = (const char**)_t251; + self->objKeys = _t252; /* sizeof(JsonValue) */ - _t260 = 4 * sizeof(JsonValue); - void* _t261; - _t261 = Alloc(_t260); - _t262 = (JsonValue*)_t261; - self->objValues = _t262; + _t253 = 4 * sizeof(JsonValue); + void* _t254; + _t254 = Alloc(_t253); + _t255 = (JsonValue*)_t254; + self->objValues = _t255; } - goto endif72; - else71:; + goto endif68; + else67:; { unsigned int doubleCap; - _t263 = objNewCap * 2; - doubleCap = _t263; + _t256 = objNewCap * 2; + doubleCap = _t256; self->objCap = doubleCap; - const char** _t264; - _t264 = self->objKeys; - _t265 = (void*)_t264; + const char** _t257; + _t257 = self->objKeys; + _t258 = (void*)_t257; /* sizeof(const char*) */ - _t267 = doubleCap * sizeof(const char*); - void* _t268; - _t268 = Realloc(_t265, _t267); - _t269 = (const char**)_t268; - self->objKeys = _t269; - JsonValue* _t270; - _t270 = self->objValues; - _t271 = (void*)_t270; + _t259 = doubleCap * sizeof(const char*); + void* _t260; + _t260 = Realloc(_t258, _t259); + _t261 = (const char**)_t260; + self->objKeys = _t261; + JsonValue* _t262; + _t262 = self->objValues; + _t263 = (void*)_t262; /* sizeof(JsonValue) */ - _t273 = doubleCap * sizeof(JsonValue); - void* _t274; - _t274 = Realloc(_t271, _t273); - _t275 = (JsonValue*)_t274; - self->objValues = _t275; + _t264 = doubleCap * sizeof(JsonValue); + void* _t265; + _t265 = Realloc(_t263, _t264); + _t266 = (JsonValue*)_t265; + self->objValues = _t266; } - endif72:; + endif68:; } - endif70:; - const char** _t276; - _t276 = self->objKeys; - unsigned int _t277; - _t277 = self->objLen; - _t276[_t277] = key; - JsonValue* _t278; - _t278 = self->objValues; - unsigned int _t279; - _t279 = self->objLen; - _t278[_t279] = val; - unsigned int _t280; - _t280 = self->objLen; - _t281 = _t280 + 1; - self->objLen = _t281; + endif66:; + const char** _t267; + _t267 = self->objKeys; + unsigned int _t268; + _t268 = self->objLen; + _t267[_t268] = key; + JsonValue* _t269; + _t269 = self->objValues; + unsigned int _t270; + _t270 = self->objLen; + _t269[_t270] = val; + unsigned int _t271; + _t271 = self->objLen; + _t272 = _t271 + 1; + self->objLen = _t272; } bool Json_IsNull(JsonValue v) { - int _t283; - int _t282; - _t282 = v.tag; - _t283 = (_t282 == JsonTagNull); - return _t283; + int _t274; + int _t273; + _t273 = v.tag; + _t274 = (_t273 == JsonTagNull); + return _t274; } bool Json_AsBool(JsonValue v) { - int _t285; - int _t284; - _t284 = v.tag; - _t285 = (_t284 == JsonTagBool); - if (!_t285) goto endif74; + int _t276; + int _t275; + _t275 = v.tag; + _t276 = (_t275 == JsonTagBool); + if (!_t276) goto endif70; { - bool _t286; - _t286 = v.boolVal; - return _t286; + bool _t277; + _t277 = v.boolVal; + return _t277; } - endif74:; + endif70:; return 0; } double Json_AsNumber(JsonValue v) { - int _t288; - int _t287; - _t287 = v.tag; - _t288 = (_t287 == JsonTagNumber); - if (!_t288) goto endif76; + int _t279; + int _t278; + _t278 = v.tag; + _t279 = (_t278 == JsonTagNumber); + if (!_t279) goto endif72; { - double _t289; - _t289 = v.numVal; - return _t289; + double _t280; + _t280 = v.numVal; + return _t280; } - endif76:; + endif72:; return 0.0; } const char* Json_AsString(JsonValue v) { - int _t291; - int _t290; - _t290 = v.tag; - _t291 = (_t290 == JsonTagString); - if (!_t291) goto endif78; + int _t282; + int _t281; + _t281 = v.tag; + _t282 = (_t281 == JsonTagString); + if (!_t282) goto endif74; { - const char* _t292; - _t292 = v.strVal; - return _t292; + const char* _t283; + _t283 = v.strVal; + return _t283; } - endif78:; + endif74:; return ""; } int JsonParser_Peek(JsonParser* p) { - int _t295; - int _t299; - unsigned int _t293; - _t293 = p->pos; - unsigned int _t294; - _t294 = p->len; - _t295 = (_t293 >= _t294); - if (!_t295) goto endif80; + int _t286; + int _t290; + unsigned int _t284; + _t284 = p->pos; + unsigned int _t285; + _t285 = p->len; + _t286 = (_t284 >= _t285); + if (!_t286) goto endif76; { return 0; } - endif80:; - const char* _t296; - _t296 = p->src; - unsigned int _t297; - _t297 = p->pos; - int _t298; - _t298 = _t296[_t297]; - _t299 = (int)_t298; - return _t299; + endif76:; + const char* _t287; + _t287 = p->src; + unsigned int _t288; + _t288 = p->pos; + int _t289; + _t289 = _t287[_t288]; + _t290 = (int)_t289; + return _t290; } void JsonParser_Advance(JsonParser* p) { - int _t302; - int _t304; - unsigned int _t300; - _t300 = p->pos; - unsigned int _t301; - _t301 = p->len; - _t302 = (_t300 < _t301); - if (!_t302) goto endif82; + int _t293; + int _t295; + unsigned int _t291; + _t291 = p->pos; + unsigned int _t292; + _t292 = p->len; + _t293 = (_t291 < _t292); + if (!_t293) goto endif78; { - unsigned int _t303; - _t303 = p->pos; - _t304 = _t303 + 1; - p->pos = _t304; + unsigned int _t294; + _t294 = p->pos; + _t295 = _t294 + 1; + p->pos = _t295; } - endif82:; + endif78:; } void JsonParser_SkipWhitespace(JsonParser* p) { - int _t306; - int _t307; - int _t309; - int _t311; - while83:; - if (!1) goto wend85; + int _t297; + int _t298; + int _t300; + int _t302; + while79:; + if (!1) goto wend80; { int c; - int _t305; - _t305 = JsonParser_Peek(p); - c = _t305; + int _t296; + _t296 = JsonParser_Peek(p); + c = _t296; bool __or_tmp_1; bool __or_tmp_2; bool __or_tmp_3; - _t306 = (c == 32); - if (!_t306) goto else86; + _t297 = (c == 32); + if (!_t297) goto else81; *(bool*)&__or_tmp_3 = 1; - goto endif87; - else86:; - _t307 = (c == 9); - *(bool*)&__or_tmp_3 = _t307; - endif87:; - bool _t308; - _t308 = *(bool*)&__or_tmp_3; - if (!_t308) goto else88; + goto endif82; + else81:; + _t298 = (c == 9); + *(bool*)&__or_tmp_3 = _t298; + endif82:; + bool _t299; + _t299 = *(bool*)&__or_tmp_3; + if (!_t299) goto else83; *(bool*)&__or_tmp_2 = 1; - goto endif89; - else88:; - _t309 = (c == 10); - *(bool*)&__or_tmp_2 = _t309; - endif89:; - bool _t310; - _t310 = *(bool*)&__or_tmp_2; - if (!_t310) goto else90; + goto endif84; + else83:; + _t300 = (c == 10); + *(bool*)&__or_tmp_2 = _t300; + endif84:; + bool _t301; + _t301 = *(bool*)&__or_tmp_2; + if (!_t301) goto else85; *(bool*)&__or_tmp_1 = 1; - goto endif91; - else90:; - _t311 = (c == 13); - *(bool*)&__or_tmp_1 = _t311; - endif91:; - bool _t312; - _t312 = *(bool*)&__or_tmp_1; - if (!_t312) goto else92; + goto endif86; + else85:; + _t302 = (c == 13); + *(bool*)&__or_tmp_1 = _t302; + endif86:; + bool _t303; + _t303 = *(bool*)&__or_tmp_1; + if (!_t303) goto else87; { JsonParser_Advance(p); } - goto endif93; - else92:; + goto endif88; + else87:; { return; } - endif93:; + endif88:; } - goto while83; - wend85:; + goto while79; + wend80:; } bool JsonParser_Match(JsonParser* p, const char* expected) { + int _t306; + int _t308; + int _t309; + int _t312; int _t315; - int _t317; + int _t316; int _t318; - int _t321; - int _t324; - int _t325; - int _t327; unsigned int elen; - unsigned int _t313; - _t313 = String_Len(expected); - elen = _t313; - unsigned int _t314; - _t314 = p->pos; - _t315 = _t314 + elen; - unsigned int _t316; - _t316 = p->len; - _t317 = (_t315 > _t316); - if (!_t317) goto endif95; + unsigned int _t304; + _t304 = String_Len(expected); + elen = _t304; + unsigned int _t305; + _t305 = p->pos; + _t306 = _t305 + elen; + unsigned int _t307; + _t307 = p->len; + _t308 = (_t306 > _t307); + if (!_t308) goto endif90; { return 0; } - endif95:; + endif90:; unsigned int i; i = 0; - while96:; - _t318 = (i < elen); - if (!_t318) goto wend98; + while91:; + _t309 = (i < elen); + if (!_t309) goto wend92; { - const char* _t319; - _t319 = p->src; - unsigned int _t320; - _t320 = p->pos; - _t321 = _t320 + i; - int _t322; - _t322 = _t319[_t321]; - int _t323; - _t323 = expected[i]; - _t324 = (_t322 != _t323); - if (!_t324) goto endif100; + const char* _t310; + _t310 = p->src; + unsigned int _t311; + _t311 = p->pos; + _t312 = _t311 + i; + int _t313; + _t313 = _t310[_t312]; + int _t314; + _t314 = expected[i]; + _t315 = (_t313 != _t314); + if (!_t315) goto endif94; { return 0; } - endif100:; - _t325 = i + 1; - i = _t325; + endif94:; + _t316 = i + 1; + i = _t316; } - goto while96; - wend98:; - unsigned int _t326; - _t326 = p->pos; - _t327 = _t326 + elen; - p->pos = _t327; + goto while91; + wend92:; + unsigned int _t317; + _t317 = p->pos; + _t318 = _t317 + elen; + p->pos = _t318; return 1; } const char* JsonParser_ParseString(JsonParser* p) { - int _t329; - int _t332; + int _t320; + int _t323; + int _t324; + int _t326; + int _t328; + void* _t329; + int _t330; + void* _t331; + char _t332; int _t333; - int _t335; - int _t337; - void* _t338; + void* _t334; + char _t335; + int _t336; + void* _t337; + char _t338; int _t339; void* _t340; char _t341; @@ -2015,234 +2023,262 @@ const char* JsonParser_ParseString(JsonParser* p) { int _t348; void* _t349; char _t350; - int _t351; - void* _t352; - char _t353; - int _t354; + void* _t351; + char _t352; + void* _t353; + char _t354; void* _t355; char _t356; - int _t357; - void* _t358; - char _t359; + int _t358; + void* _t359; void* _t360; - char _t361; void* _t362; - char _t363; - void* _t364; - char _t365; - int _t367; - void* _t368; - void* _t369; - void* _t371; - int _t328; - _t328 = JsonParser_Peek(p); - _t329 = (_t328 != 34); - if (!_t329) goto endif102; + int _t319; + _t319 = JsonParser_Peek(p); + _t320 = (_t319 != 34); + if (!_t320) goto endif96; { p->error = "Expected string"; return ""; } - endif102:; + endif96:; JsonParser_Advance(p); StringBuilder sb; - StringBuilder _t330; - _t330 = StringBuilder_New(); - sb = _t330; - while103:; - if (!1) goto wend105; + StringBuilder _t321; + _t321 = StringBuilder_New(); + sb = _t321; + while97:; + if (!1) goto wend98; { int c; - int _t331; - _t331 = JsonParser_Peek(p); - c = _t331; + int _t322; + _t322 = JsonParser_Peek(p); + c = _t322; bool __or_tmp_4; - _t332 = (c == 0); - if (!_t332) goto else106; + _t323 = (c == 0); + if (!_t323) goto else99; *(bool*)&__or_tmp_4 = 1; - goto endif107; - else106:; - _t333 = (c == 34); - *(bool*)&__or_tmp_4 = _t333; - endif107:; - bool _t334; - _t334 = *(bool*)&__or_tmp_4; - if (!_t334) goto endif109; + goto endif100; + else99:; + _t324 = (c == 34); + *(bool*)&__or_tmp_4 = _t324; + endif100:; + bool _t325; + _t325 = *(bool*)&__or_tmp_4; + if (!_t325) goto endif102; { - goto wend105; + goto wend98; } - endif109:; - _t335 = (c == 92); - if (!_t335) goto else110; + endif102:; + _t326 = (c == 92); + if (!_t326) goto else103; { JsonParser_Advance(p); int esc; - int _t336; - _t336 = JsonParser_Peek(p); - esc = _t336; - _t337 = (esc == 0); - if (!_t337) goto endif113; + int _t327; + _t327 = JsonParser_Peek(p); + esc = _t327; + _t328 = (esc == 0); + if (!_t328) goto endif106; { p->error = "Unterminated string escape"; - _t338 = &sb; - StringBuilder_Free(_t338); + _t329 = &sb; + StringBuilder_Free(_t329); return ""; } - endif113:; - _t339 = (esc == 110); - if (!_t339) goto else114; + endif106:; + _t330 = (esc == 110); + if (!_t330) goto else107; + { + _t331 = &sb; + _t332 = (char)10; + StringBuilder_AppendChar(_t331, _t332); + } + goto endif108; + else107:; + _t333 = (esc == 116); + if (!_t333) goto else109; + { + _t334 = &sb; + _t335 = (char)9; + StringBuilder_AppendChar(_t334, _t335); + } + goto endif110; + else109:; + _t336 = (esc == 114); + if (!_t336) goto else111; + { + _t337 = &sb; + _t338 = (char)13; + StringBuilder_AppendChar(_t337, _t338); + } + goto endif112; + else111:; + _t339 = (esc == 98); + if (!_t339) goto else113; { _t340 = &sb; - _t341 = (char)10; + _t341 = (char)8; StringBuilder_AppendChar(_t340, _t341); } - goto endif115; - else114:; - _t342 = (esc == 116); - if (!_t342) goto else116; + goto endif114; + else113:; + _t342 = (esc == 102); + if (!_t342) goto else115; { _t343 = &sb; - _t344 = (char)9; + _t344 = (char)12; StringBuilder_AppendChar(_t343, _t344); } - goto endif117; - else116:; - _t345 = (esc == 114); - if (!_t345) goto else118; + goto endif116; + else115:; + _t345 = (esc == 34); + if (!_t345) goto else117; { _t346 = &sb; - _t347 = (char)13; + _t347 = (char)34; StringBuilder_AppendChar(_t346, _t347); } - goto endif119; - else118:; - _t348 = (esc == 98); - if (!_t348) goto else120; + goto endif118; + else117:; + _t348 = (esc == 92); + if (!_t348) goto else119; { _t349 = &sb; - _t350 = (char)8; + _t350 = (char)92; StringBuilder_AppendChar(_t349, _t350); } - goto endif121; - else120:; - _t351 = (esc == 102); - if (!_t351) goto else122; + goto endif120; + else119:; { - _t352 = &sb; - _t353 = (char)12; - StringBuilder_AppendChar(_t352, _t353); + _t351 = &sb; + _t352 = (char)92; + StringBuilder_AppendChar(_t351, _t352); + _t353 = &sb; + _t354 = (char)esc; + StringBuilder_AppendChar(_t353, _t354); } - goto endif123; - else122:; - _t354 = (esc == 34); - if (!_t354) goto else124; + endif120:; + endif118:; + endif116:; + endif114:; + endif112:; + endif110:; + endif108:; + JsonParser_Advance(p); + } + goto endif104; + else103:; { _t355 = &sb; - _t356 = (char)34; + _t356 = (char)c; StringBuilder_AppendChar(_t355, _t356); - } - goto endif125; - else124:; - _t357 = (esc == 92); - if (!_t357) goto else126; - { - _t358 = &sb; - _t359 = (char)92; - StringBuilder_AppendChar(_t358, _t359); - } - goto endif127; - else126:; - { - _t360 = &sb; - _t361 = (char)92; - StringBuilder_AppendChar(_t360, _t361); - _t362 = &sb; - _t363 = (char)esc; - StringBuilder_AppendChar(_t362, _t363); - } - endif127:; - endif125:; - endif123:; - endif121:; - endif119:; - endif117:; - endif115:; JsonParser_Advance(p); } - goto endif111; - else110:; - { - _t364 = &sb; - _t365 = (char)c; - StringBuilder_AppendChar(_t364, _t365); - JsonParser_Advance(p); + endif104:; } - endif111:; - } - goto while103; - wend105:; - int _t366; - _t366 = JsonParser_Peek(p); - _t367 = (_t366 != 34); - if (!_t367) goto endif129; + goto while97; + wend98:; + int _t357; + _t357 = JsonParser_Peek(p); + _t358 = (_t357 != 34); + if (!_t358) goto endif122; { p->error = "Unterminated string"; - _t368 = &sb; - StringBuilder_Free(_t368); + _t359 = &sb; + StringBuilder_Free(_t359); return ""; } - endif129:; + endif122:; JsonParser_Advance(p); const char* result; - _t369 = &sb; - const char* _t370; - _t370 = StringBuilder_Build(_t369); - result = _t370; - _t371 = &sb; - StringBuilder_Free(_t371); + _t360 = &sb; + const char* _t361; + _t361 = StringBuilder_Build(_t360); + result = _t361; + _t362 = &sb; + StringBuilder_Free(_t362); return result; } JsonValue JsonParser_ParseNumber(JsonParser* p) { - int _t374; - int _t376; - int _t377; - int _t380; - int _t382; - int _t383; - int _t387; - unsigned int start; - unsigned int _t372; - _t372 = p->pos; - start = _t372; - int c0; + int _t365; + int _t367; + int _t368; + int _t371; int _t373; - _t373 = JsonParser_Peek(p); - c0 = _t373; - _t374 = (c0 == 45); - if (!_t374) goto endif131; + int _t374; + int _t378; + unsigned int start; + unsigned int _t363; + _t363 = p->pos; + start = _t363; + int c0; + int _t364; + _t364 = JsonParser_Peek(p); + c0 = _t364; + _t365 = (c0 == 45); + if (!_t365) goto endif124; { JsonParser_Advance(p); } - endif131:; - while132:; + endif124:; + while125:; + if (!1) goto wend126; + { + int c; + int _t366; + _t366 = JsonParser_Peek(p); + c = _t366; + bool __and_tmp_5; + _t367 = (c >= 48); + if (!_t367) goto else127; + _t368 = (c <= 57); + *(bool*)&__and_tmp_5 = _t368; + goto endif128; + else127:; + *(bool*)&__and_tmp_5 = 0; + endif128:; + bool _t369; + _t369 = *(bool*)&__and_tmp_5; + if (!_t369) goto else129; + { + JsonParser_Advance(p); + } + goto endif130; + else129:; + { + goto wend126; + } + endif130:; + } + goto while125; + wend126:; + int _t370; + _t370 = JsonParser_Peek(p); + _t371 = (_t370 == 46); + if (!_t371) goto endif132; + { + JsonParser_Advance(p); + while133:; if (!1) goto wend134; { int c; - int _t375; - _t375 = JsonParser_Peek(p); - c = _t375; - bool __and_tmp_5; - _t376 = (c >= 48); - if (!_t376) goto else135; - _t377 = (c <= 57); - *(bool*)&__and_tmp_5 = _t377; + int _t372; + _t372 = JsonParser_Peek(p); + c = _t372; + bool __and_tmp_6; + _t373 = (c >= 48); + if (!_t373) goto else135; + _t374 = (c <= 57); + *(bool*)&__and_tmp_6 = _t374; goto endif136; else135:; - *(bool*)&__and_tmp_5 = 0; + *(bool*)&__and_tmp_6 = 0; endif136:; - bool _t378; - _t378 = *(bool*)&__and_tmp_5; - if (!_t378) goto else137; + bool _t375; + _t375 = *(bool*)&__and_tmp_6; + if (!_t375) goto else137; { JsonParser_Advance(p); } @@ -2253,1098 +2289,1061 @@ JsonValue JsonParser_ParseNumber(JsonParser* p) { } endif138:; } - goto while132; + goto while133; wend134:; - int _t379; - _t379 = JsonParser_Peek(p); - _t380 = (_t379 == 46); - if (!_t380) goto endif140; - { - JsonParser_Advance(p); - while141:; - if (!1) goto wend143; - { - int c; - int _t381; - _t381 = JsonParser_Peek(p); - c = _t381; - bool __and_tmp_6; - _t382 = (c >= 48); - if (!_t382) goto else144; - _t383 = (c <= 57); - *(bool*)&__and_tmp_6 = _t383; - goto endif145; - else144:; - *(bool*)&__and_tmp_6 = 0; - endif145:; - bool _t384; - _t384 = *(bool*)&__and_tmp_6; - if (!_t384) goto else146; - { - JsonParser_Advance(p); } - goto endif147; - else146:; - { - goto wend143; - } - endif147:; - } - goto while141; - wend143:; - } - endif140:; + endif132:; const char* numStr; - const char* _t385; - _t385 = p->src; - unsigned int _t386; - _t386 = p->pos; - _t387 = _t386 - start; - const char* _t388; - _t388 = String_Slice(_t385, start, _t387); - numStr = _t388; + const char* _t376; + _t376 = p->src; + unsigned int _t377; + _t377 = p->pos; + _t378 = _t377 - start; + const char* _t379; + _t379 = String_Slice(_t376, start, _t378); + numStr = _t379; double n; - double _t389; - _t389 = String_ToFloat(numStr); - n = _t389; - JsonValue _t390; - _t390 = Json_Number(n); - return _t390; + double _t380; + _t380 = String_ToFloat(numStr); + n = _t380; + JsonValue _t381; + _t381 = Json_Number(n); + return _t381; } JsonValue JsonParser_ParseArray(JsonParser* p) { - int _t393; - int _t396; - void* _t398; - int _t400; - int _t401; + int _t384; + int _t387; + void* _t389; + int _t391; + int _t392; JsonParser_Advance(p); JsonValue arr; - JsonValue _t391; - _t391 = Json_Array(); - arr = _t391; + JsonValue _t382; + _t382 = Json_Array(); + arr = _t382; JsonParser_SkipWhitespace(p); - int _t392; - _t392 = JsonParser_Peek(p); - _t393 = (_t392 == 93); - if (!_t393) goto endif149; + int _t383; + _t383 = JsonParser_Peek(p); + _t384 = (_t383 == 93); + if (!_t384) goto endif140; { JsonParser_Advance(p); return arr; } - endif149:; - while150:; - if (!1) goto wend152; + endif140:; + while141:; + if (!1) goto wend142; { JsonParser_SkipWhitespace(p); JsonValue val; - JsonValue _t394; - _t394 = JsonParser_ParseValue(p); - val = _t394; - const char* _t395; - _t395 = p->error; - _t396 = (_t395 != ""); - if (!_t396) goto endif154; + JsonValue _t385; + _t385 = JsonParser_ParseValue(p); + val = _t385; + const char* _t386; + _t386 = p->error; + _t387 = (_t386 != ""); + if (!_t387) goto endif144; { - JsonValue _t397; - _t397 = Json_Null(); - return _t397; + JsonValue _t388; + _t388 = Json_Null(); + return _t388; } - endif154:; - _t398 = &arr; - Json_ArrayPush(_t398, val); + endif144:; + _t389 = &arr; + Json_ArrayPush(_t389, val); JsonParser_SkipWhitespace(p); int c; - int _t399; - _t399 = JsonParser_Peek(p); - c = _t399; - _t400 = (c == 93); - if (!_t400) goto endif156; + int _t390; + _t390 = JsonParser_Peek(p); + c = _t390; + _t391 = (c == 93); + if (!_t391) goto endif146; { JsonParser_Advance(p); return arr; } - endif156:; - _t401 = (c == 44); - if (!_t401) goto else157; + endif146:; + _t392 = (c == 44); + if (!_t392) goto else147; { JsonParser_Advance(p); } - goto endif158; - else157:; + goto endif148; + else147:; { p->error = "Expected ',' or ']' in array"; - JsonValue _t402; - _t402 = Json_Null(); - return _t402; + JsonValue _t393; + _t393 = Json_Null(); + return _t393; } - endif158:; + endif148:; } - goto while150; - wend152:; + goto while141; + wend142:; } JsonValue JsonParser_ParseObject(JsonParser* p) { - int _t405; - int _t408; + int _t396; + int _t399; + int _t402; + int _t406; + void* _t408; + int _t410; int _t411; - int _t415; - void* _t417; - int _t419; - int _t420; JsonParser_Advance(p); JsonValue obj; - JsonValue _t403; - _t403 = Json_Object(); - obj = _t403; + JsonValue _t394; + _t394 = Json_Object(); + obj = _t394; JsonParser_SkipWhitespace(p); - int _t404; - _t404 = JsonParser_Peek(p); - _t405 = (_t404 == 125); - if (!_t405) goto endif160; + int _t395; + _t395 = JsonParser_Peek(p); + _t396 = (_t395 == 125); + if (!_t396) goto endif150; + { + JsonParser_Advance(p); + return obj; + } + endif150:; + while151:; + if (!1) goto wend152; + { + JsonParser_SkipWhitespace(p); + const char* key; + const char* _t397; + _t397 = JsonParser_ParseString(p); + key = _t397; + const char* _t398; + _t398 = p->error; + _t399 = (_t398 != ""); + if (!_t399) goto endif154; + { + JsonValue _t400; + _t400 = Json_Null(); + return _t400; + } + endif154:; + JsonParser_SkipWhitespace(p); + int _t401; + _t401 = JsonParser_Peek(p); + _t402 = (_t401 != 58); + if (!_t402) goto endif156; + { + p->error = "Expected ':' after object key"; + JsonValue _t403; + _t403 = Json_Null(); + return _t403; + } + endif156:; + JsonParser_Advance(p); + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t404; + _t404 = JsonParser_ParseValue(p); + val = _t404; + const char* _t405; + _t405 = p->error; + _t406 = (_t405 != ""); + if (!_t406) goto endif158; + { + JsonValue _t407; + _t407 = Json_Null(); + return _t407; + } + endif158:; + _t408 = &obj; + Json_ObjectSet(_t408, key, val); + JsonParser_SkipWhitespace(p); + int c; + int _t409; + _t409 = JsonParser_Peek(p); + c = _t409; + _t410 = (c == 125); + if (!_t410) goto endif160; { JsonParser_Advance(p); return obj; } endif160:; - while161:; - if (!1) goto wend163; + _t411 = (c == 44); + if (!_t411) goto else161; { - JsonParser_SkipWhitespace(p); - const char* key; - const char* _t406; - _t406 = JsonParser_ParseString(p); - key = _t406; - const char* _t407; - _t407 = p->error; - _t408 = (_t407 != ""); - if (!_t408) goto endif165; - { - JsonValue _t409; - _t409 = Json_Null(); - return _t409; + JsonParser_Advance(p); } - endif165:; - JsonParser_SkipWhitespace(p); - int _t410; - _t410 = JsonParser_Peek(p); - _t411 = (_t410 != 58); - if (!_t411) goto endif167; + goto endif162; + else161:; { - p->error = "Expected ':' after object key"; + p->error = "Expected ',' or '}' in object"; JsonValue _t412; _t412 = Json_Null(); return _t412; } - endif167:; - JsonParser_Advance(p); - JsonParser_SkipWhitespace(p); - JsonValue val; - JsonValue _t413; - _t413 = JsonParser_ParseValue(p); - val = _t413; - const char* _t414; - _t414 = p->error; - _t415 = (_t414 != ""); - if (!_t415) goto endif169; - { - JsonValue _t416; - _t416 = Json_Null(); - return _t416; + endif162:; } - endif169:; - _t417 = &obj; - Json_ObjectSet(_t417, key, val); - JsonParser_SkipWhitespace(p); - int c; - int _t418; - _t418 = JsonParser_Peek(p); - c = _t418; - _t419 = (c == 125); - if (!_t419) goto endif171; - { - JsonParser_Advance(p); - return obj; - } - endif171:; - _t420 = (c == 44); - if (!_t420) goto else172; - { - JsonParser_Advance(p); - } - goto endif173; - else172:; - { - p->error = "Expected ',' or '}' in object"; - JsonValue _t421; - _t421 = Json_Null(); - return _t421; - } - endif173:; - } - goto while161; - wend163:; + goto while151; + wend152:; } JsonValue JsonParser_ParseValue(JsonParser* p) { + int _t414; + int _t416; + int _t419; + int _t421; int _t423; - int _t425; - int _t428; - int _t430; - int _t432; + int _t427; + int _t431; + int _t435; int _t436; - int _t440; - int _t444; - int _t445; - int _t447; + int _t438; JsonParser_SkipWhitespace(p); int c; - int _t422; - _t422 = JsonParser_Peek(p); - c = _t422; - _t423 = (c == 0); - if (!_t423) goto endif175; + int _t413; + _t413 = JsonParser_Peek(p); + c = _t413; + _t414 = (c == 0); + if (!_t414) goto endif164; { p->error = "Unexpected end of input"; - JsonValue _t424; - _t424 = Json_Null(); - return _t424; + JsonValue _t415; + _t415 = Json_Null(); + return _t415; } - endif175:; - _t425 = (c == 34); - if (!_t425) goto endif177; + endif164:; + _t416 = (c == 34); + if (!_t416) goto endif166; { - const char* _t426; - _t426 = JsonParser_ParseString(p); - JsonValue _t427; - _t427 = Json_String(_t426); - return _t427; + const char* _t417; + _t417 = JsonParser_ParseString(p); + JsonValue _t418; + _t418 = Json_String(_t417); + return _t418; } - endif177:; - _t428 = (c == 123); - if (!_t428) goto endif179; + endif166:; + _t419 = (c == 123); + if (!_t419) goto endif168; + { + JsonValue _t420; + _t420 = JsonParser_ParseObject(p); + return _t420; + } + endif168:; + _t421 = (c == 91); + if (!_t421) goto endif170; + { + JsonValue _t422; + _t422 = JsonParser_ParseArray(p); + return _t422; + } + endif170:; + _t423 = (c == 116); + if (!_t423) goto endif172; + { + bool _t424; + _t424 = JsonParser_Match(p, "true"); + if (!_t424) goto endif174; + { + JsonValue _t425; + _t425 = Json_Bool(1); + return _t425; + } + endif174:; + p->error = "Expected 'true'"; + JsonValue _t426; + _t426 = Json_Null(); + return _t426; + } + endif172:; + _t427 = (c == 102); + if (!_t427) goto endif176; + { + bool _t428; + _t428 = JsonParser_Match(p, "false"); + if (!_t428) goto endif178; { JsonValue _t429; - _t429 = JsonParser_ParseObject(p); + _t429 = Json_Bool(0); return _t429; } - endif179:; - _t430 = (c == 91); - if (!_t430) goto endif181; - { - JsonValue _t431; - _t431 = JsonParser_ParseArray(p); - return _t431; + endif178:; + p->error = "Expected 'false'"; + JsonValue _t430; + _t430 = Json_Null(); + return _t430; } - endif181:; - _t432 = (c == 116); - if (!_t432) goto endif183; + endif176:; + _t431 = (c == 110); + if (!_t431) goto endif180; { - bool _t433; - _t433 = JsonParser_Match(p, "true"); - if (!_t433) goto endif185; + bool _t432; + _t432 = JsonParser_Match(p, "null"); + if (!_t432) goto endif182; { + JsonValue _t433; + _t433 = Json_Null(); + return _t433; + } + endif182:; + p->error = "Expected 'null'"; JsonValue _t434; - _t434 = Json_Bool(1); + _t434 = Json_Null(); return _t434; } - endif185:; - p->error = "Expected 'true'"; - JsonValue _t435; - _t435 = Json_Null(); - return _t435; - } - endif183:; - _t436 = (c == 102); - if (!_t436) goto endif187; - { - bool _t437; - _t437 = JsonParser_Match(p, "false"); - if (!_t437) goto endif189; - { - JsonValue _t438; - _t438 = Json_Bool(0); - return _t438; - } - endif189:; - p->error = "Expected 'false'"; - JsonValue _t439; - _t439 = Json_Null(); - return _t439; - } - endif187:; - _t440 = (c == 110); - if (!_t440) goto endif191; - { - bool _t441; - _t441 = JsonParser_Match(p, "null"); - if (!_t441) goto endif193; - { - JsonValue _t442; - _t442 = Json_Null(); - return _t442; - } - endif193:; - p->error = "Expected 'null'"; - JsonValue _t443; - _t443 = Json_Null(); - return _t443; - } - endif191:; + endif180:; bool __or_tmp_7; bool __and_tmp_8; - _t444 = (c >= 48); - if (!_t444) goto else194; - _t445 = (c <= 57); - *(bool*)&__and_tmp_8 = _t445; - goto endif195; - else194:; + _t435 = (c >= 48); + if (!_t435) goto else183; + _t436 = (c <= 57); + *(bool*)&__and_tmp_8 = _t436; + goto endif184; + else183:; *(bool*)&__and_tmp_8 = 0; - endif195:; - bool _t446; - _t446 = *(bool*)&__and_tmp_8; - if (!_t446) goto else196; + endif184:; + bool _t437; + _t437 = *(bool*)&__and_tmp_8; + if (!_t437) goto else185; *(bool*)&__or_tmp_7 = 1; - goto endif197; - else196:; - _t447 = (c == 45); - *(bool*)&__or_tmp_7 = _t447; - endif197:; - bool _t448; - _t448 = *(bool*)&__or_tmp_7; - if (!_t448) goto endif199; + goto endif186; + else185:; + _t438 = (c == 45); + *(bool*)&__or_tmp_7 = _t438; + endif186:; + bool _t439; + _t439 = *(bool*)&__or_tmp_7; + if (!_t439) goto endif188; { - JsonValue _t449; - _t449 = JsonParser_ParseNumber(p); - return _t449; + JsonValue _t440; + _t440 = JsonParser_ParseNumber(p); + return _t440; } - endif199:; + endif188:; p->error = "Unexpected character"; - JsonValue _t450; - _t450 = Json_Null(); - return _t450; + JsonValue _t441; + _t441 = Json_Null(); + return _t441; } JsonValue Json_Parse(const char* s) { - JsonParser _t452; - void* _t453; - void* _t455; - int _t457; - int _t460; + JsonParser _t443; + void* _t444; + void* _t446; + int _t448; + int _t451; JsonParser p; - unsigned int _t451; - _t451 = String_Len(s); - _t452 = (JsonParser){.src = s, .pos = 0, .len = _t451, .error = ""}; - p = _t452; + unsigned int _t442; + _t442 = String_Len(s); + _t443 = (JsonParser){.src = s, .pos = 0, .len = _t442, .error = ""}; + p = _t443; JsonValue result; - _t453 = &p; - JsonValue _t454; - _t454 = JsonParser_ParseValue(_t453); - result = _t454; - _t455 = &p; - JsonParser_SkipWhitespace(_t455); + _t444 = &p; + JsonValue _t445; + _t445 = JsonParser_ParseValue(_t444); + result = _t445; + _t446 = &p; + JsonParser_SkipWhitespace(_t446); bool __and_tmp_9; - const char* _t456; - _t456 = p.error; - _t457 = (_t456 == ""); - if (!_t457) goto else200; - unsigned int _t458; - _t458 = p.pos; - unsigned int _t459; - _t459 = p.len; - _t460 = (_t458 != _t459); - *(bool*)&__and_tmp_9 = _t460; - goto endif201; - else200:; + const char* _t447; + _t447 = p.error; + _t448 = (_t447 == ""); + if (!_t448) goto else189; + unsigned int _t449; + _t449 = p.pos; + unsigned int _t450; + _t450 = p.len; + _t451 = (_t449 != _t450); + *(bool*)&__and_tmp_9 = _t451; + goto endif190; + else189:; *(bool*)&__and_tmp_9 = 0; - endif201:; - bool _t461; - _t461 = *(bool*)&__and_tmp_9; - if (!_t461) goto endif203; + endif190:; + bool _t452; + _t452 = *(bool*)&__and_tmp_9; + if (!_t452) goto endif192; { p.error = "Trailing data after JSON value"; - JsonValue _t462; - _t462 = Json_Null(); - return _t462; + JsonValue _t453; + _t453 = Json_Null(); + return _t453; } - endif203:; + endif192:; return result; } void Json_StringifyImpl(StringBuilder* sb, JsonValue v) { - int _t464; - int _t466; - int _t469; + int _t455; + int _t457; + int _t460; + int _t463; + char _t464; + char _t466; + int _t468; + char _t469; + int _t471; int _t472; char _t473; - char _t475; - int _t477; - char _t478; - int _t480; - int _t481; - char _t482; - int _t485; - char _t486; - int _t488; + int _t476; + char _t477; + int _t479; + char _t480; + int _t482; + int _t483; + char _t484; + char _t485; + char _t488; char _t489; - int _t491; int _t492; char _t493; - char _t494; - char _t497; - char _t498; - int _t501; - char _t502; - int _t463; - _t463 = v.tag; - _t464 = (_t463 == JsonTagNull); - if (!_t464) goto endif205; + int _t454; + _t454 = v.tag; + _t455 = (_t454 == JsonTagNull); + if (!_t455) goto endif194; { StringBuilder_Append(sb, "null"); return; } - endif205:; - int _t465; - _t465 = v.tag; - _t466 = (_t465 == JsonTagBool); - if (!_t466) goto endif207; + endif194:; + int _t456; + _t456 = v.tag; + _t457 = (_t456 == JsonTagBool); + if (!_t457) goto endif196; { - bool _t467; - _t467 = v.boolVal; - if (!_t467) goto else208; + bool _t458; + _t458 = v.boolVal; + if (!_t458) goto else197; { StringBuilder_Append(sb, "true"); } - goto endif209; - else208:; + goto endif198; + else197:; { StringBuilder_Append(sb, "false"); } - endif209:; + endif198:; return; } - endif207:; - int _t468; - _t468 = v.tag; - _t469 = (_t468 == JsonTagNumber); - if (!_t469) goto endif211; + endif196:; + int _t459; + _t459 = v.tag; + _t460 = (_t459 == JsonTagNumber); + if (!_t460) goto endif200; { - double _t470; - _t470 = v.numVal; - StringBuilder_AppendFloat(sb, _t470); + double _t461; + _t461 = v.numVal; + StringBuilder_AppendFloat(sb, _t461); return; } - endif211:; - int _t471; - _t471 = v.tag; - _t472 = (_t471 == JsonTagString); - if (!_t472) goto endif213; + endif200:; + int _t462; + _t462 = v.tag; + _t463 = (_t462 == JsonTagString); + if (!_t463) goto endif202; { - _t473 = (char)34; + _t464 = (char)34; + StringBuilder_AppendChar(sb, _t464); + const char* _t465; + _t465 = v.strVal; + StringBuilder_Append(sb, _t465); + _t466 = (char)34; + StringBuilder_AppendChar(sb, _t466); + return; + } + endif202:; + int _t467; + _t467 = v.tag; + _t468 = (_t467 == JsonTagArray); + if (!_t468) goto endif204; + { + _t469 = (char)91; + StringBuilder_AppendChar(sb, _t469); + unsigned int i; + i = 0; + while205:; + unsigned int _t470; + _t470 = v.arrLen; + _t471 = (i < _t470); + if (!_t471) goto wend206; + { + _t472 = (i > 0); + if (!_t472) goto endif208; + { + _t473 = (char)44; StringBuilder_AppendChar(sb, _t473); - const char* _t474; - _t474 = v.strVal; - StringBuilder_Append(sb, _t474); - _t475 = (char)34; - StringBuilder_AppendChar(sb, _t475); + } + endif208:; + JsonValue* _t474; + _t474 = v.arrData; + JsonValue _t475; + _t475 = _t474[i]; + Json_StringifyImpl(sb, _t475); + _t476 = i + 1; + i = _t476; + } + goto while205; + wend206:; + _t477 = (char)93; + StringBuilder_AppendChar(sb, _t477); return; } - endif213:; - int _t476; - _t476 = v.tag; - _t477 = (_t476 == JsonTagArray); - if (!_t477) goto endif215; + endif204:; + int _t478; + _t478 = v.tag; + _t479 = (_t478 == JsonTagObject); + if (!_t479) goto endif210; { - _t478 = (char)91; - StringBuilder_AppendChar(sb, _t478); + _t480 = (char)123; + StringBuilder_AppendChar(sb, _t480); unsigned int i; i = 0; - while216:; - unsigned int _t479; - _t479 = v.arrLen; - _t480 = (i < _t479); - if (!_t480) goto wend218; + while211:; + unsigned int _t481; + _t481 = v.objLen; + _t482 = (i < _t481); + if (!_t482) goto wend212; { - _t481 = (i > 0); - if (!_t481) goto endif220; + _t483 = (i > 0); + if (!_t483) goto endif214; { - _t482 = (char)44; - StringBuilder_AppendChar(sb, _t482); + _t484 = (char)44; + StringBuilder_AppendChar(sb, _t484); } - endif220:; - JsonValue* _t483; - _t483 = v.arrData; - JsonValue _t484; - _t484 = _t483[i]; - Json_StringifyImpl(sb, _t484); - _t485 = i + 1; - i = _t485; - } - goto while216; - wend218:; - _t486 = (char)93; - StringBuilder_AppendChar(sb, _t486); - return; - } - endif215:; - int _t487; - _t487 = v.tag; - _t488 = (_t487 == JsonTagObject); - if (!_t488) goto endif222; - { - _t489 = (char)123; + endif214:; + _t485 = (char)34; + StringBuilder_AppendChar(sb, _t485); + const char** _t486; + _t486 = v.objKeys; + const char* _t487; + _t487 = _t486[i]; + StringBuilder_Append(sb, _t487); + _t488 = (char)34; + StringBuilder_AppendChar(sb, _t488); + _t489 = (char)58; StringBuilder_AppendChar(sb, _t489); - unsigned int i; - i = 0; - while223:; - unsigned int _t490; - _t490 = v.objLen; - _t491 = (i < _t490); - if (!_t491) goto wend225; - { - _t492 = (i > 0); - if (!_t492) goto endif227; - { - _t493 = (char)44; + JsonValue* _t490; + _t490 = v.objValues; + JsonValue _t491; + _t491 = _t490[i]; + Json_StringifyImpl(sb, _t491); + _t492 = i + 1; + i = _t492; + } + goto while211; + wend212:; + _t493 = (char)125; StringBuilder_AppendChar(sb, _t493); - } - endif227:; - _t494 = (char)34; - StringBuilder_AppendChar(sb, _t494); - const char** _t495; - _t495 = v.objKeys; - const char* _t496; - _t496 = _t495[i]; - StringBuilder_Append(sb, _t496); - _t497 = (char)34; - StringBuilder_AppendChar(sb, _t497); - _t498 = (char)58; - StringBuilder_AppendChar(sb, _t498); - JsonValue* _t499; - _t499 = v.objValues; - JsonValue _t500; - _t500 = _t499[i]; - Json_StringifyImpl(sb, _t500); - _t501 = i + 1; - i = _t501; - } - goto while223; - wend225:; - _t502 = (char)125; - StringBuilder_AppendChar(sb, _t502); return; } - endif222:; + endif210:; } const char* Json_Stringify(JsonValue v) { - void* _t504; - void* _t505; + void* _t495; + void* _t496; StringBuilder sb; - StringBuilder _t503; - _t503 = StringBuilder_New(); - sb = _t503; - _t504 = &sb; - Json_StringifyImpl(_t504, v); - _t505 = &sb; - const char* _t506; - _t506 = StringBuilder_Build(_t505); - return _t506; + StringBuilder _t494; + _t494 = StringBuilder_New(); + sb = _t494; + _t495 = &sb; + Json_StringifyImpl(_t495, v); + _t496 = &sb; + const char* _t497; + _t497 = StringBuilder_Build(_t496); + return _t497; } unsigned int String_Len(const char* s) { - unsigned int _t507; - _t507 = bux_strlen(s); - return _t507; + unsigned int _t498; + _t498 = bux_strlen(s); + return _t498; } bool String_IsNull(const char* s) { - int _t509; - int _t508; - _t508 = bux_str_is_null(s); - _t509 = (_t508 != 0); - return _t509; + int _t500; + int _t499; + _t499 = bux_str_is_null(s); + _t500 = (_t499 != 0); + return _t500; } bool String_Eq(const char* a, const char* b) { - int _t511; - int _t510; - _t510 = bux_strcmp(a, b); - _t511 = (_t510 == 0); - return _t511; + int _t502; + int _t501; + _t501 = bux_strcmp(a, b); + _t502 = (_t501 == 0); + return _t502; } const char* String_Concat(const char* a, const char* b) { - int _t514; - int _t515; - char* _t517; + int _t505; + int _t506; + char* _t508; unsigned int len_a; - unsigned int _t512; - _t512 = bux_strlen(a); - len_a = _t512; + unsigned int _t503; + _t503 = bux_strlen(a); + len_a = _t503; unsigned int len_b; - unsigned int _t513; - _t513 = bux_strlen(b); - len_b = _t513; + unsigned int _t504; + _t504 = bux_strlen(b); + len_b = _t504; unsigned int total; - _t514 = len_a + len_b; - _t515 = _t514 + 1; - total = _t515; + _t505 = len_a + len_b; + _t506 = _t505 + 1; + total = _t506; char* buf; - void* _t516; - _t516 = bux_alloc(total); - _t517 = (char*)_t516; - buf = _t517; + void* _t507; + _t507 = bux_alloc(total); + _t508 = (char*)_t507; + buf = _t508; bux_strcpy(buf, a); bux_strcat(buf, b); return buf; } const char* String_Copy(const char* s) { - int _t519; - char* _t521; + int _t510; + char* _t512; unsigned int len; - unsigned int _t518; - _t518 = bux_strlen(s); - len = _t518; + unsigned int _t509; + _t509 = bux_strlen(s); + len = _t509; char* buf; - _t519 = len + 1; - void* _t520; - _t520 = bux_alloc(_t519); - _t521 = (char*)_t520; - buf = _t521; + _t510 = len + 1; + void* _t511; + _t511 = bux_alloc(_t510); + _t512 = (char*)_t511; + buf = _t512; bux_strcpy(buf, s); return buf; } bool String_StartsWith(const char* s, const char* prefix) { - int _t524; - int _t526; + int _t515; + int _t517; unsigned int s_len; - unsigned int _t522; - _t522 = bux_strlen(s); - s_len = _t522; + unsigned int _t513; + _t513 = bux_strlen(s); + s_len = _t513; unsigned int p_len; - unsigned int _t523; - _t523 = bux_strlen(prefix); - p_len = _t523; - _t524 = (p_len > s_len); - if (!_t524) goto endif229; + unsigned int _t514; + _t514 = bux_strlen(prefix); + p_len = _t514; + _t515 = (p_len > s_len); + if (!_t515) goto endif216; { return 0; } - endif229:; + endif216:; int r; - int _t525; - _t525 = bux_strncmp(s, prefix, p_len); - r = _t525; - _t526 = (r == 0); - return _t526; + int _t516; + _t516 = bux_strncmp(s, prefix, p_len); + r = _t516; + _t517 = (r == 0); + return _t517; } bool String_EndsWith(const char* s, const char* suffix) { - int _t529; - int _t530; - int _t533; + int _t520; + int _t521; + int _t524; unsigned int s_len; - unsigned int _t527; - _t527 = bux_strlen(s); - s_len = _t527; + unsigned int _t518; + _t518 = bux_strlen(s); + s_len = _t518; unsigned int suf_len; - unsigned int _t528; - _t528 = bux_strlen(suffix); - suf_len = _t528; - _t529 = (suf_len > s_len); - if (!_t529) goto endif231; + unsigned int _t519; + _t519 = bux_strlen(suffix); + suf_len = _t519; + _t520 = (suf_len > s_len); + if (!_t520) goto endif218; { return 0; } - endif231:; + endif218:; unsigned int start; - _t530 = s_len - suf_len; - start = _t530; + _t521 = s_len - suf_len; + start = _t521; const char* tail; - const char* _t531; - _t531 = bux_str_slice(s, start, suf_len); - tail = _t531; + const char* _t522; + _t522 = bux_str_slice(s, start, suf_len); + tail = _t522; bool eq; - int _t532; - _t532 = bux_strcmp(tail, suffix); - _t533 = (_t532 == 0); - eq = _t533; + int _t523; + _t523 = bux_strcmp(tail, suffix); + _t524 = (_t523 == 0); + eq = _t524; return eq; } bool String_Contains(const char* s, const char* substr) { - int _t535; + int _t526; int r; - int _t534; - _t534 = bux_str_contains(s, substr); - r = _t534; - _t535 = (r != 0); - return _t535; + int _t525; + _t525 = bux_str_contains(s, substr); + r = _t525; + _t526 = (r != 0); + return _t526; } const char* String_Slice(const char* s, unsigned int start, unsigned int len) { - const char* _t536; - _t536 = bux_str_slice(s, start, len); - return _t536; + const char* _t527; + _t527 = bux_str_slice(s, start, len); + return _t527; } const char* String_Trim(const char* s) { - const char* _t537; - _t537 = bux_str_trim(s); - return _t537; + const char* _t528; + _t528 = bux_str_trim(s); + return _t528; } const char* String_TrimLeft(const char* s) { - const char* _t538; - _t538 = bux_str_trim_left(s); - return _t538; + const char* _t529; + _t529 = bux_str_trim_left(s); + return _t529; } const char* String_TrimRight(const char* s) { - const char* _t539; - _t539 = bux_str_trim_right(s); - return _t539; + const char* _t530; + _t530 = bux_str_trim_right(s); + return _t530; } const char* String_FromInt(int64_t n) { - const char* _t540; - _t540 = bux_int_to_str(n); - return _t540; + const char* _t531; + _t531 = bux_int_to_str(n); + return _t531; } int64_t String_ToInt(const char* s) { - int64_t _t541; - _t541 = bux_str_to_int(s); - return _t541; + int64_t _t532; + _t532 = bux_str_to_int(s); + return _t532; } StringBuilder StringBuilder_New(void) { - StringBuilder _t543; - void* _t542; - _t542 = bux_sb_new(64); - _t543 = (StringBuilder){.handle = _t542}; - return _t543; + StringBuilder _t534; + void* _t533; + _t533 = bux_sb_new(64); + _t534 = (StringBuilder){.handle = _t533}; + return _t534; } StringBuilder StringBuilder_NewCap(unsigned int cap) { - StringBuilder _t545; - void* _t544; - _t544 = bux_sb_new(cap); - _t545 = (StringBuilder){.handle = _t544}; - return _t545; + StringBuilder _t536; + void* _t535; + _t535 = bux_sb_new(cap); + _t536 = (StringBuilder){.handle = _t535}; + return _t536; } void StringBuilder_Append(StringBuilder* sb, const char* s) { - void* _t546; - _t546 = sb->handle; - bux_sb_append(_t546, s); + void* _t537; + _t537 = sb->handle; + bux_sb_append(_t537, s); } void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) { - void* _t547; - _t547 = sb->handle; - bux_sb_append_int(_t547, n); + void* _t538; + _t538 = sb->handle; + bux_sb_append_int(_t538, n); } void StringBuilder_AppendFloat(StringBuilder* sb, double f) { - void* _t548; - _t548 = sb->handle; - bux_sb_append_float(_t548, f); + void* _t539; + _t539 = sb->handle; + bux_sb_append_float(_t539, f); } void StringBuilder_AppendChar(StringBuilder* sb, char c) { - void* _t549; - _t549 = sb->handle; - bux_sb_append_char(_t549, c); + void* _t540; + _t540 = sb->handle; + bux_sb_append_char(_t540, c); } const char* StringBuilder_Build(StringBuilder* sb) { - void* _t550; - _t550 = sb->handle; - const char* _t551; - _t551 = bux_sb_build(_t550); - return _t551; + void* _t541; + _t541 = sb->handle; + const char* _t542; + _t542 = bux_sb_build(_t541); + return _t542; } void StringBuilder_Free(StringBuilder* sb) { - void* _t552; - _t552 = sb->handle; - bux_sb_free(_t552); + void* _t543; + _t543 = sb->handle; + bux_sb_free(_t543); } unsigned int String_SplitCount(const char* s, const char* delim) { - unsigned int _t553; - _t553 = bux_str_split_count(s, delim); - return _t553; + unsigned int _t544; + _t544 = bux_str_split_count(s, delim); + return _t544; } const char* String_SplitPart(const char* s, const char* delim, unsigned int index) { - const char* _t554; - _t554 = bux_str_split_part(s, delim, index); - return _t554; + const char* _t545; + _t545 = bux_str_split_part(s, delim, index); + return _t545; } const char* String_Join2(const char* a, const char* b, const char* sep) { - const char* _t555; - _t555 = bux_str_join2(a, b, sep); - return _t555; + const char* _t546; + _t546 = bux_str_join2(a, b, sep); + return _t546; } const char* String_Chars(const char* s, unsigned int index) { - const char* _t556; - _t556 = bux_str_slice(s, index, 1); - return _t556; + const char* _t547; + _t547 = bux_str_slice(s, index, 1); + return _t547; } const char* String_Find(const char* haystack, const char* needle) { - const char* _t557; - _t557 = bux_strstr(haystack, needle); - return _t557; + const char* _t548; + _t548 = bux_strstr(haystack, needle); + return _t548; } unsigned int String_Offset(const char* pos, const char* base) { - unsigned int _t558; - _t558 = bux_str_offset(pos, base); - return _t558; + unsigned int _t549; + _t549 = bux_str_offset(pos, base); + return _t549; } const char* String_Replace(const char* s, const char* old, const char* new) { - int _t564; - int _t566; - int _t567; + int _t555; + int _t557; + int _t558; const char* pos; - const char* _t559; - _t559 = bux_strstr(s, old); - pos = _t559; - bool _t560; - _t560 = String_IsNull(pos); - if (!_t560) goto endif233; + const char* _t550; + _t550 = bux_strstr(s, old); + pos = _t550; + bool _t551; + _t551 = String_IsNull(pos); + if (!_t551) goto endif220; { return s; } - endif233:; + endif220:; unsigned int oldLen; - unsigned int _t561; - _t561 = bux_strlen(old); - oldLen = _t561; + unsigned int _t552; + _t552 = bux_strlen(old); + oldLen = _t552; unsigned int prefixLen; - unsigned int _t562; - _t562 = String_Offset(pos, s); - prefixLen = _t562; + unsigned int _t553; + _t553 = String_Offset(pos, s); + prefixLen = _t553; const char* prefix; - const char* _t563; - _t563 = bux_str_slice(s, 0, prefixLen); - prefix = _t563; + const char* _t554; + _t554 = bux_str_slice(s, 0, prefixLen); + prefix = _t554; const char* suffix; - _t564 = prefixLen + oldLen; - unsigned int _t565; - _t565 = bux_strlen(s); - _t566 = _t565 - prefixLen; - _t567 = _t566 - oldLen; - const char* _t568; - _t568 = bux_str_slice(s, _t564, _t567); - suffix = _t568; + _t555 = prefixLen + oldLen; + unsigned int _t556; + _t556 = bux_strlen(s); + _t557 = _t556 - prefixLen; + _t558 = _t557 - oldLen; + const char* _t559; + _t559 = bux_str_slice(s, _t555, _t558); + suffix = _t559; const char* temp; - const char* _t569; - _t569 = String_Concat(prefix, new); - temp = _t569; + const char* _t560; + _t560 = String_Concat(prefix, new); + temp = _t560; const char* result; - const char* _t570; - _t570 = String_Concat(temp, suffix); - result = _t570; + const char* _t561; + _t561 = String_Concat(temp, suffix); + result = _t561; return result; } double String_ToFloat(const char* s) { - double _t571; - _t571 = bux_str_to_float(s); - return _t571; + double _t562; + _t562 = bux_str_to_float(s); + return _t562; } const char* String_FromBool(bool b) { - if (!b) goto endif235; + if (!b) goto endif222; { return "true"; } - endif235:; + endif222:; return "false"; } const char* String_FromFloat(double f) { - const char* _t572; - _t572 = bux_float_to_string(f); - return _t572; + const char* _t563; + _t563 = bux_float_to_string(f); + return _t563; } const char* String_Format1(const char* pattern, const char* a0) { - const char* _t573; - _t573 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); - return _t573; + const char* _t564; + _t564 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); + return _t564; } const char* String_Format2(const char* pattern, const char* a0, const char* a1) { - const char* _t574; - _t574 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); - return _t574; + const char* _t565; + _t565 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); + return _t565; } const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) { - const char* _t575; - _t575 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); - return _t575; + const char* _t566; + _t566 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); + return _t566; } void Channel_SendInt(Channel_int* ch, int value) { - void* _t577; - void* _t578; - void* _t576; - _t576 = ch->handle; - _t577 = &value; - _t578 = (void*)_t577; - bux_channel_send(_t576, _t578); + void* _t568; + void* _t569; + void* _t567; + _t567 = ch->handle; + _t568 = &value; + _t569 = (void*)_t568; + bux_channel_send(_t567, _t569); } int Channel_RecvInt(Channel_int* ch) { - void* _t580; - void* _t581; + void* _t571; + void* _t572; int result; result = 0; - void* _t579; - _t579 = ch->handle; - _t580 = &result; - _t581 = (void*)_t580; - bux_channel_recv(_t579, _t581); + void* _t570; + _t570 = ch->handle; + _t571 = &result; + _t572 = (void*)_t571; + bux_channel_recv(_t570, _t572); return result; } void Channel_SendFloat64(Channel_float64* ch, double value) { - void* _t583; - void* _t584; - void* _t582; - _t582 = ch->handle; - _t583 = &value; - _t584 = (void*)_t583; - bux_channel_send(_t582, _t584); + void* _t574; + void* _t575; + void* _t573; + _t573 = ch->handle; + _t574 = &value; + _t575 = (void*)_t574; + bux_channel_send(_t573, _t575); } double Channel_RecvFloat64(Channel_float64* ch) { - void* _t586; - void* _t587; + void* _t577; + void* _t578; double result; result = 0.0; - void* _t585; - _t585 = ch->handle; - _t586 = &result; - _t587 = (void*)_t586; - bux_channel_recv(_t585, _t587); + void* _t576; + _t576 = ch->handle; + _t577 = &result; + _t578 = (void*)_t577; + bux_channel_recv(_t576, _t578); return result; } const char* Hash_Sha1(const char* data) { - int _t589; + int _t580; int len; - unsigned int _t588; - _t588 = String_Len(data); - _t589 = (int)_t588; - len = _t589; + unsigned int _t579; + _t579 = String_Len(data); + _t580 = (int)_t579; + len = _t580; void* buf; - void* _t590; - _t590 = Alloc(20); - buf = _t590; + void* _t581; + _t581 = Alloc(20); + buf = _t581; bux_sha1(data, len, buf); const char* result; - const char* _t591; - _t591 = bux_bytes_to_hex(buf, 20); - result = _t591; + const char* _t582; + _t582 = bux_bytes_to_hex(buf, 20); + result = _t582; Free(buf); return result; } const char* Hash_Sha256(const char* data) { - int _t593; + int _t584; int len; - unsigned int _t592; - _t592 = String_Len(data); - _t593 = (int)_t592; - len = _t593; + unsigned int _t583; + _t583 = String_Len(data); + _t584 = (int)_t583; + len = _t584; void* buf; - void* _t594; - _t594 = Alloc(32); - buf = _t594; + void* _t585; + _t585 = Alloc(32); + buf = _t585; bux_sha256(data, len, buf); const char* result; - const char* _t595; - _t595 = bux_bytes_to_hex(buf, 32); - result = _t595; + const char* _t586; + _t586 = bux_bytes_to_hex(buf, 32); + result = _t586; Free(buf); return result; } const char* Hash_Sha384(const char* data) { - int _t597; + int _t588; int len; - unsigned int _t596; - _t596 = String_Len(data); - _t597 = (int)_t596; - len = _t597; + unsigned int _t587; + _t587 = String_Len(data); + _t588 = (int)_t587; + len = _t588; void* buf; - void* _t598; - _t598 = Alloc(48); - buf = _t598; + void* _t589; + _t589 = Alloc(48); + buf = _t589; bux_sha384(data, len, buf); const char* result; - const char* _t599; - _t599 = bux_bytes_to_hex(buf, 48); - result = _t599; + const char* _t590; + _t590 = bux_bytes_to_hex(buf, 48); + result = _t590; Free(buf); return result; } const char* Hash_Sha512(const char* data) { - int _t601; + int _t592; int len; - unsigned int _t600; - _t600 = String_Len(data); - _t601 = (int)_t600; - len = _t601; + unsigned int _t591; + _t591 = String_Len(data); + _t592 = (int)_t591; + len = _t592; void* buf; - void* _t602; - _t602 = Alloc(64); - buf = _t602; + void* _t593; + _t593 = Alloc(64); + buf = _t593; bux_sha512(data, len, buf); const char* result; - const char* _t603; - _t603 = bux_bytes_to_hex(buf, 64); - result = _t603; + const char* _t594; + _t594 = bux_bytes_to_hex(buf, 64); + result = _t594; Free(buf); return result; } void Hash_Sha256Raw(const char* data, void* out) { - int _t605; - unsigned int _t604; - _t604 = String_Len(data); - _t605 = (int)_t604; - bux_sha256(data, _t605, out); + int _t596; + unsigned int _t595; + _t595 = String_Len(data); + _t596 = (int)_t595; + bux_sha256(data, _t596, out); } void Hash_Sha384Raw(const char* data, void* out) { - int _t607; - unsigned int _t606; - _t606 = String_Len(data); - _t607 = (int)_t606; - bux_sha384(data, _t607, out); + int _t598; + unsigned int _t597; + _t597 = String_Len(data); + _t598 = (int)_t597; + bux_sha384(data, _t598, out); } void Hash_Sha512Raw(const char* data, void* out) { - int _t609; - unsigned int _t608; - _t608 = String_Len(data); - _t609 = (int)_t608; - bux_sha512(data, _t609, out); + int _t600; + unsigned int _t599; + _t599 = String_Len(data); + _t600 = (int)_t599; + bux_sha512(data, _t600, out); } int Hash_Sha1Size(void) { @@ -3364,1498 +3363,1498 @@ int Hash_Sha512Size(void) { } const char* Base64_Encode(const char* s) { - int _t611; - unsigned int _t610; - _t610 = String_Len(s); - _t611 = (int)_t610; - const char* _t612; - _t612 = bux_base64_encode(s, _t611); - return _t612; + int _t602; + unsigned int _t601; + _t601 = String_Len(s); + _t602 = (int)_t601; + const char* _t603; + _t603 = bux_base64_encode(s, _t602); + return _t603; } const char* Base64_Decode(const char* s) { - int _t614; - void* _t615; + int _t605; + void* _t606; int outlen; outlen = 0; - unsigned int _t613; - _t613 = String_Len(s); - _t614 = (int)_t613; - _t615 = &outlen; - const char* _t616; - _t616 = bux_base64_decode(s, _t614, _t615); - return _t616; + unsigned int _t604; + _t604 = String_Len(s); + _t605 = (int)_t604; + _t606 = &outlen; + const char* _t607; + _t607 = bux_base64_decode(s, _t605, _t606); + return _t607; } const char* Base64URL_Encode(const char* s) { - int _t618; - unsigned int _t617; - _t617 = String_Len(s); - _t618 = (int)_t617; - const char* _t619; - _t619 = bux_base64url_encode(s, _t618); - return _t619; + int _t609; + unsigned int _t608; + _t608 = String_Len(s); + _t609 = (int)_t608; + const char* _t610; + _t610 = bux_base64url_encode(s, _t609); + return _t610; } const char* Base64URL_Decode(const char* s) { - int _t621; - void* _t622; + int _t612; + void* _t613; int outlen; outlen = 0; - unsigned int _t620; - _t620 = String_Len(s); - _t621 = (int)_t620; - _t622 = &outlen; - const char* _t623; - _t623 = bux_base64url_decode(s, _t621, _t622); - return _t623; + unsigned int _t611; + _t611 = String_Len(s); + _t612 = (int)_t611; + _t613 = &outlen; + const char* _t614; + _t614 = bux_base64url_decode(s, _t612, _t613); + return _t614; } const char* Hmac_Sha256(const char* key, const char* message) { - int _t625; - int _t627; + int _t616; + int _t618; int kl; - unsigned int _t624; - _t624 = String_Len(key); - _t625 = (int)_t624; - kl = _t625; + unsigned int _t615; + _t615 = String_Len(key); + _t616 = (int)_t615; + kl = _t616; int ml; - unsigned int _t626; - _t626 = String_Len(message); - _t627 = (int)_t626; - ml = _t627; + unsigned int _t617; + _t617 = String_Len(message); + _t618 = (int)_t617; + ml = _t618; void* buf; - void* _t628; - _t628 = Alloc(32); - buf = _t628; + void* _t619; + _t619 = Alloc(32); + buf = _t619; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - const char* _t629; - _t629 = bux_bytes_to_hex(buf, 32); - result = _t629; + const char* _t620; + _t620 = bux_bytes_to_hex(buf, 32); + result = _t620; Free(buf); return result; } void Hmac_Sha256Raw(const char* key, const char* message, void* out) { - int _t631; - int _t633; - unsigned int _t630; - _t630 = String_Len(key); - _t631 = (int)_t630; - unsigned int _t632; - _t632 = String_Len(message); - _t633 = (int)_t632; - bux_hmac_sha256(key, _t631, message, _t633, out); + int _t622; + int _t624; + unsigned int _t621; + _t621 = String_Len(key); + _t622 = (int)_t621; + unsigned int _t623; + _t623 = String_Len(message); + _t624 = (int)_t623; + bux_hmac_sha256(key, _t622, message, _t624, out); } const char* Hmac_Sha256Base64(const char* key, const char* message) { - int _t635; - int _t637; - const char* _t639; + int _t626; + int _t628; + const char* _t630; int kl; - unsigned int _t634; - _t634 = String_Len(key); - _t635 = (int)_t634; - kl = _t635; + unsigned int _t625; + _t625 = String_Len(key); + _t626 = (int)_t625; + kl = _t626; int ml; - unsigned int _t636; - _t636 = String_Len(message); - _t637 = (int)_t636; - ml = _t637; + unsigned int _t627; + _t627 = String_Len(message); + _t628 = (int)_t627; + ml = _t628; void* buf; - void* _t638; - _t638 = Alloc(32); - buf = _t638; + void* _t629; + _t629 = Alloc(32); + buf = _t629; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - _t639 = (const char*)buf; - const char* _t640; - _t640 = bux_base64_encode(_t639, 32); - result = _t640; + _t630 = (const char*)buf; + const char* _t631; + _t631 = bux_base64_encode(_t630, 32); + result = _t631; Free(buf); return result; } const char* Hmac_Sha384(const char* key, const char* message) { - int _t642; - int _t644; + int _t633; + int _t635; int kl; - unsigned int _t641; - _t641 = String_Len(key); - _t642 = (int)_t641; - kl = _t642; + unsigned int _t632; + _t632 = String_Len(key); + _t633 = (int)_t632; + kl = _t633; int ml; - unsigned int _t643; - _t643 = String_Len(message); - _t644 = (int)_t643; - ml = _t644; + unsigned int _t634; + _t634 = String_Len(message); + _t635 = (int)_t634; + ml = _t635; void* buf; - void* _t645; - _t645 = Alloc(48); - buf = _t645; + void* _t636; + _t636 = Alloc(48); + buf = _t636; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - const char* _t646; - _t646 = bux_bytes_to_hex(buf, 48); - result = _t646; + const char* _t637; + _t637 = bux_bytes_to_hex(buf, 48); + result = _t637; Free(buf); return result; } void Hmac_Sha384Raw(const char* key, const char* message, void* out) { - int _t648; - int _t650; - unsigned int _t647; - _t647 = String_Len(key); - _t648 = (int)_t647; - unsigned int _t649; - _t649 = String_Len(message); - _t650 = (int)_t649; - bux_hmac_sha384(key, _t648, message, _t650, out); + int _t639; + int _t641; + unsigned int _t638; + _t638 = String_Len(key); + _t639 = (int)_t638; + unsigned int _t640; + _t640 = String_Len(message); + _t641 = (int)_t640; + bux_hmac_sha384(key, _t639, message, _t641, out); } const char* Hmac_Sha384Base64(const char* key, const char* message) { - int _t652; - int _t654; - const char* _t656; + int _t643; + int _t645; + const char* _t647; int kl; - unsigned int _t651; - _t651 = String_Len(key); - _t652 = (int)_t651; - kl = _t652; + unsigned int _t642; + _t642 = String_Len(key); + _t643 = (int)_t642; + kl = _t643; int ml; - unsigned int _t653; - _t653 = String_Len(message); - _t654 = (int)_t653; - ml = _t654; + unsigned int _t644; + _t644 = String_Len(message); + _t645 = (int)_t644; + ml = _t645; void* buf; - void* _t655; - _t655 = Alloc(48); - buf = _t655; + void* _t646; + _t646 = Alloc(48); + buf = _t646; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - _t656 = (const char*)buf; - const char* _t657; - _t657 = bux_base64_encode(_t656, 48); - result = _t657; + _t647 = (const char*)buf; + const char* _t648; + _t648 = bux_base64_encode(_t647, 48); + result = _t648; Free(buf); return result; } const char* Hmac_Sha512(const char* key, const char* message) { - int _t659; - int _t661; + int _t650; + int _t652; int kl; - unsigned int _t658; - _t658 = String_Len(key); - _t659 = (int)_t658; - kl = _t659; + unsigned int _t649; + _t649 = String_Len(key); + _t650 = (int)_t649; + kl = _t650; int ml; - unsigned int _t660; - _t660 = String_Len(message); - _t661 = (int)_t660; - ml = _t661; + unsigned int _t651; + _t651 = String_Len(message); + _t652 = (int)_t651; + ml = _t652; void* buf; - void* _t662; - _t662 = Alloc(64); - buf = _t662; + void* _t653; + _t653 = Alloc(64); + buf = _t653; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - const char* _t663; - _t663 = bux_bytes_to_hex(buf, 64); - result = _t663; + const char* _t654; + _t654 = bux_bytes_to_hex(buf, 64); + result = _t654; Free(buf); return result; } void Hmac_Sha512Raw(const char* key, const char* message, void* out) { - int _t665; - int _t667; - unsigned int _t664; - _t664 = String_Len(key); - _t665 = (int)_t664; - unsigned int _t666; - _t666 = String_Len(message); - _t667 = (int)_t666; - bux_hmac_sha512(key, _t665, message, _t667, out); + int _t656; + int _t658; + unsigned int _t655; + _t655 = String_Len(key); + _t656 = (int)_t655; + unsigned int _t657; + _t657 = String_Len(message); + _t658 = (int)_t657; + bux_hmac_sha512(key, _t656, message, _t658, out); } const char* Hmac_Sha512Base64(const char* key, const char* message) { - int _t669; - int _t671; - const char* _t673; + int _t660; + int _t662; + const char* _t664; int kl; - unsigned int _t668; - _t668 = String_Len(key); - _t669 = (int)_t668; - kl = _t669; + unsigned int _t659; + _t659 = String_Len(key); + _t660 = (int)_t659; + kl = _t660; int ml; - unsigned int _t670; - _t670 = String_Len(message); - _t671 = (int)_t670; - ml = _t671; + unsigned int _t661; + _t661 = String_Len(message); + _t662 = (int)_t661; + ml = _t662; void* buf; - void* _t672; - _t672 = Alloc(64); - buf = _t672; + void* _t663; + _t663 = Alloc(64); + buf = _t663; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - _t673 = (const char*)buf; - const char* _t674; - _t674 = bux_base64_encode(_t673, 64); - result = _t674; + _t664 = (const char*)buf; + const char* _t665; + _t665 = bux_base64_encode(_t664, 64); + result = _t665; Free(buf); return result; } const char* Random_Bytes(int n) { - int _t675; - unsigned int _t676; - int _t679; - const char* _t680; - _t675 = (n <= 0); - if (!_t675) goto endif237; + int _t666; + unsigned int _t667; + int _t670; + const char* _t671; + _t666 = (n <= 0); + if (!_t666) goto endif224; { return ""; } - endif237:; + endif224:; void* buf; - _t676 = (unsigned int)n; - void* _t677; - _t677 = Alloc(_t676); - buf = _t677; - int _t678; - _t678 = bux_random_bytes(buf, n); - _t679 = (_t678 != 1); - if (!_t679) goto endif239; + _t667 = (unsigned int)n; + void* _t668; + _t668 = Alloc(_t667); + buf = _t668; + int _t669; + _t669 = bux_random_bytes(buf, n); + _t670 = (_t669 != 1); + if (!_t670) goto endif226; { Free(buf); return ""; } - endif239:; - _t680 = (const char*)buf; - return _t680; + endif226:; + _t671 = (const char*)buf; + return _t671; } const char* Random_Hex(int n) { - int _t681; - unsigned int _t682; - int _t685; - _t681 = (n <= 0); - if (!_t681) goto endif241; + int _t672; + unsigned int _t673; + int _t676; + _t672 = (n <= 0); + if (!_t672) goto endif228; { return ""; } - endif241:; + endif228:; void* buf; - _t682 = (unsigned int)n; - void* _t683; - _t683 = Alloc(_t682); - buf = _t683; - int _t684; - _t684 = bux_random_bytes(buf, n); - _t685 = (_t684 != 1); - if (!_t685) goto endif243; + _t673 = (unsigned int)n; + void* _t674; + _t674 = Alloc(_t673); + buf = _t674; + int _t675; + _t675 = bux_random_bytes(buf, n); + _t676 = (_t675 != 1); + if (!_t676) goto endif230; { Free(buf); return ""; } - endif243:; + endif230:; const char* result; - const char* _t686; - _t686 = bux_bytes_to_hex(buf, n); - result = _t686; + const char* _t677; + _t677 = bux_bytes_to_hex(buf, n); + result = _t677; Free(buf); return result; } const char* Random_Base64(int n) { - int _t687; - unsigned int _t688; - int _t691; - const char* _t692; - _t687 = (n <= 0); - if (!_t687) goto endif245; + int _t678; + unsigned int _t679; + int _t682; + const char* _t683; + _t678 = (n <= 0); + if (!_t678) goto endif232; { return ""; } - endif245:; + endif232:; void* buf; - _t688 = (unsigned int)n; - void* _t689; - _t689 = Alloc(_t688); - buf = _t689; - int _t690; - _t690 = bux_random_bytes(buf, n); - _t691 = (_t690 != 1); - if (!_t691) goto endif247; + _t679 = (unsigned int)n; + void* _t680; + _t680 = Alloc(_t679); + buf = _t680; + int _t681; + _t681 = bux_random_bytes(buf, n); + _t682 = (_t681 != 1); + if (!_t682) goto endif234; { Free(buf); return ""; } - endif247:; + endif234:; const char* result; - _t692 = (const char*)buf; - const char* _t693; - _t693 = bux_base64_encode(_t692, n); - result = _t693; + _t683 = (const char*)buf; + const char* _t684; + _t684 = bux_base64_encode(_t683, n); + result = _t684; Free(buf); return result; } unsigned int Random_Uint32(void) { - int _t696; - unsigned int* _t697; - unsigned int _t698; + int _t687; + unsigned int* _t688; + unsigned int _t689; void* buf; - void* _t694; - _t694 = Alloc(4); - buf = _t694; - int _t695; - _t695 = bux_random_bytes(buf, 4); - _t696 = (_t695 != 1); - if (!_t696) goto endif249; + void* _t685; + _t685 = Alloc(4); + buf = _t685; + int _t686; + _t686 = bux_random_bytes(buf, 4); + _t687 = (_t686 != 1); + if (!_t687) goto endif236; { Free(buf); return 0; } - endif249:; + endif236:; unsigned int* ptr; - _t697 = (unsigned int*)buf; - ptr = _t697; + _t688 = (unsigned int*)buf; + ptr = _t688; unsigned int val; - _t698 = *ptr; - val = _t698; + _t689 = *ptr; + val = _t689; Free(buf); return val; } const char* Aes_GenerateKey(void) { - unsigned int _t699; - int _t702; - const char* _t703; + unsigned int _t690; + int _t693; + const char* _t694; void* buf; - _t699 = (unsigned int)AES_KEY_SIZE; - void* _t700; - _t700 = Alloc(_t699); - buf = _t700; - int _t701; - _t701 = bux_random_bytes(buf, AES_KEY_SIZE); - _t702 = (_t701 != 1); - if (!_t702) goto endif251; + _t690 = (unsigned int)AES_KEY_SIZE; + void* _t691; + _t691 = Alloc(_t690); + buf = _t691; + int _t692; + _t692 = bux_random_bytes(buf, AES_KEY_SIZE); + _t693 = (_t692 != 1); + if (!_t693) goto endif238; { Free(buf); return ""; } - endif251:; - _t703 = (const char*)buf; - return _t703; + endif238:; + _t694 = (const char*)buf; + return _t694; } const char* Aes_GenerateIV(void) { - unsigned int _t704; - int _t707; - const char* _t708; + unsigned int _t695; + int _t698; + const char* _t699; void* buf; - _t704 = (unsigned int)AES_IV_SIZE; - void* _t705; - _t705 = Alloc(_t704); - buf = _t705; - int _t706; - _t706 = bux_random_bytes(buf, AES_IV_SIZE); - _t707 = (_t706 != 1); - if (!_t707) goto endif253; + _t695 = (unsigned int)AES_IV_SIZE; + void* _t696; + _t696 = Alloc(_t695); + buf = _t696; + int _t697; + _t697 = bux_random_bytes(buf, AES_IV_SIZE); + _t698 = (_t697 != 1); + if (!_t698) goto endif240; { Free(buf); return ""; } - endif253:; - _t708 = (const char*)buf; - return _t708; + endif240:; + _t699 = (const char*)buf; + return _t699; } const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv) { - int _t710; - void* _t711; + int _t701; + void* _t702; int outlen; outlen = 0; - unsigned int _t709; - _t709 = String_Len(plain); - _t710 = (int)_t709; - _t711 = &outlen; - const char* _t712; - _t712 = bux_aes_256_cbc_encrypt(plain, _t710, key, iv, _t711); - return _t712; + unsigned int _t700; + _t700 = String_Len(plain); + _t701 = (int)_t700; + _t702 = &outlen; + const char* _t703; + _t703 = bux_aes_256_cbc_encrypt(plain, _t701, key, iv, _t702); + return _t703; } const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv) { - int _t714; - void* _t715; + int _t705; + void* _t706; int outlen; outlen = 0; - unsigned int _t713; - _t713 = String_Len(cipher); - _t714 = (int)_t713; - _t715 = &outlen; - const char* _t716; - _t716 = bux_aes_256_cbc_decrypt(cipher, _t714, key, iv, _t715); - return _t716; + unsigned int _t704; + _t704 = String_Len(cipher); + _t705 = (int)_t704; + _t706 = &outlen; + const char* _t707; + _t707 = bux_aes_256_cbc_decrypt(cipher, _t705, key, iv, _t706); + return _t707; } const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag) { - int _t718; - void* _t719; + int _t709; + void* _t710; int outlen; outlen = 0; - unsigned int _t717; - _t717 = String_Len(plain); - _t718 = (int)_t717; - _t719 = &outlen; - const char* _t720; - _t720 = bux_aes_256_gcm_encrypt(plain, _t718, key, iv, tag, _t719); - return _t720; + unsigned int _t708; + _t708 = String_Len(plain); + _t709 = (int)_t708; + _t710 = &outlen; + const char* _t711; + _t711 = bux_aes_256_gcm_encrypt(plain, _t709, key, iv, tag, _t710); + return _t711; } const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag) { - int _t722; - void* _t723; + int _t713; + void* _t714; int outlen; outlen = 0; - unsigned int _t721; - _t721 = String_Len(cipher); - _t722 = (int)_t721; - _t723 = &outlen; - const char* _t724; - _t724 = bux_aes_256_gcm_decrypt(cipher, _t722, key, iv, tag, _t723); - return _t724; + unsigned int _t712; + _t712 = String_Len(cipher); + _t713 = (int)_t712; + _t714 = &outlen; + const char* _t715; + _t715 = bux_aes_256_gcm_decrypt(cipher, _t713, key, iv, tag, _t714); + return _t715; } const char* Jwt_MakeHeader(JwtAlg alg) { - int _t725; - int _t726; - int _t727; - int _t728; - int _t729; - int _t730; - int _t731; - int _t732; - int _t733; - _t725 = (alg == JwtAlg_HS256); - if (!_t725) goto endif255; + int _t716; + int _t717; + int _t718; + int _t719; + int _t720; + int _t721; + int _t722; + int _t723; + int _t724; + _t716 = (alg == JwtAlg_HS256); + if (!_t716) goto endif242; { return "{\"alg\":\"HS256\",\"typ\":\"JWT\"}"; } - endif255:; - _t726 = (alg == JwtAlg_HS384); - if (!_t726) goto endif257; + endif242:; + _t717 = (alg == JwtAlg_HS384); + if (!_t717) goto endif244; { return "{\"alg\":\"HS384\",\"typ\":\"JWT\"}"; } - endif257:; - _t727 = (alg == JwtAlg_HS512); - if (!_t727) goto endif259; + endif244:; + _t718 = (alg == JwtAlg_HS512); + if (!_t718) goto endif246; { return "{\"alg\":\"HS512\",\"typ\":\"JWT\"}"; } - endif259:; - _t728 = (alg == JwtAlg_RS256); - if (!_t728) goto endif261; + endif246:; + _t719 = (alg == JwtAlg_RS256); + if (!_t719) goto endif248; { return "{\"alg\":\"RS256\",\"typ\":\"JWT\"}"; } - endif261:; - _t729 = (alg == JwtAlg_RS384); - if (!_t729) goto endif263; + endif248:; + _t720 = (alg == JwtAlg_RS384); + if (!_t720) goto endif250; { return "{\"alg\":\"RS384\",\"typ\":\"JWT\"}"; } - endif263:; - _t730 = (alg == JwtAlg_RS512); - if (!_t730) goto endif265; + endif250:; + _t721 = (alg == JwtAlg_RS512); + if (!_t721) goto endif252; { return "{\"alg\":\"RS512\",\"typ\":\"JWT\"}"; } - endif265:; - _t731 = (alg == JwtAlg_ES256); - if (!_t731) goto endif267; + endif252:; + _t722 = (alg == JwtAlg_ES256); + if (!_t722) goto endif254; { return "{\"alg\":\"ES256\",\"typ\":\"JWT\"}"; } - endif267:; - _t732 = (alg == JwtAlg_ES384); - if (!_t732) goto endif269; + endif254:; + _t723 = (alg == JwtAlg_ES384); + if (!_t723) goto endif256; { return "{\"alg\":\"ES384\",\"typ\":\"JWT\"}"; } - endif269:; - _t733 = (alg == JwtAlg_EdDSA); - if (!_t733) goto endif271; + endif256:; + _t724 = (alg == JwtAlg_EdDSA); + if (!_t724) goto endif258; { return "{\"alg\":\"EdDSA\",\"typ\":\"JWT\"}"; } - endif271:; + endif258:; return "{\"alg\":\"none\",\"typ\":\"JWT\"}"; } const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key) { - int _t734; - const char* _t736; - int _t738; - const char* _t740; + int _t725; + const char* _t727; + int _t729; + const char* _t731; + int _t733; + const char* _t735; + int _t737; + int _t740; int _t742; - const char* _t744; - int _t746; - int _t749; - int _t751; - int _t754; - int _t756; - int _t759; - int _t761; - int _t764; - int _t766; - int _t769; - int _t771; - _t734 = (alg == JwtAlg_HS256); - if (!_t734) goto endif273; + int _t745; + int _t747; + int _t750; + int _t752; + int _t755; + int _t757; + int _t760; + int _t762; + _t725 = (alg == JwtAlg_HS256); + if (!_t725) goto endif260; { void* buf; - void* _t735; - _t735 = Alloc(32); - buf = _t735; + void* _t726; + _t726 = Alloc(32); + buf = _t726; Hmac_Sha256Raw(key, signingInput, buf); const char* result; - _t736 = (const char*)buf; - const char* _t737; - _t737 = bux_base64_encode(_t736, 32); - result = _t737; + _t727 = (const char*)buf; + const char* _t728; + _t728 = bux_base64_encode(_t727, 32); + result = _t728; Free(buf); return result; } - endif273:; - _t738 = (alg == JwtAlg_HS384); - if (!_t738) goto endif275; + endif260:; + _t729 = (alg == JwtAlg_HS384); + if (!_t729) goto endif262; { void* buf; - void* _t739; - _t739 = Alloc(48); - buf = _t739; + void* _t730; + _t730 = Alloc(48); + buf = _t730; Hmac_Sha384Raw(key, signingInput, buf); const char* result; - _t740 = (const char*)buf; - const char* _t741; - _t741 = bux_base64_encode(_t740, 48); - result = _t741; + _t731 = (const char*)buf; + const char* _t732; + _t732 = bux_base64_encode(_t731, 48); + result = _t732; Free(buf); return result; } - endif275:; - _t742 = (alg == JwtAlg_HS512); - if (!_t742) goto endif277; + endif262:; + _t733 = (alg == JwtAlg_HS512); + if (!_t733) goto endif264; { void* buf; - void* _t743; - _t743 = Alloc(64); - buf = _t743; + void* _t734; + _t734 = Alloc(64); + buf = _t734; Hmac_Sha512Raw(key, signingInput, buf); const char* result; - _t744 = (const char*)buf; - const char* _t745; - _t745 = bux_base64_encode(_t744, 64); - result = _t745; + _t735 = (const char*)buf; + const char* _t736; + _t736 = bux_base64_encode(_t735, 64); + result = _t736; Free(buf); return result; } - endif277:; - _t746 = (alg == JwtAlg_RS256); - if (!_t746) goto endif279; + endif264:; + _t737 = (alg == JwtAlg_RS256); + if (!_t737) goto endif266; { const char* raw; - const char* _t747; - _t747 = Rsa_SignSha256(key, signingInput); - raw = _t747; - unsigned int _t748; - _t748 = String_Len(raw); - _t749 = (int)_t748; - const char* _t750; - _t750 = bux_base64_encode(raw, _t749); - return _t750; + const char* _t738; + _t738 = Rsa_SignSha256(key, signingInput); + raw = _t738; + unsigned int _t739; + _t739 = String_Len(raw); + _t740 = (int)_t739; + const char* _t741; + _t741 = bux_base64_encode(raw, _t740); + return _t741; } - endif279:; - _t751 = (alg == JwtAlg_RS384); - if (!_t751) goto endif281; + endif266:; + _t742 = (alg == JwtAlg_RS384); + if (!_t742) goto endif268; { const char* raw; - const char* _t752; - _t752 = Rsa_SignSha384(key, signingInput); - raw = _t752; - unsigned int _t753; - _t753 = String_Len(raw); - _t754 = (int)_t753; - const char* _t755; - _t755 = bux_base64_encode(raw, _t754); - return _t755; + const char* _t743; + _t743 = Rsa_SignSha384(key, signingInput); + raw = _t743; + unsigned int _t744; + _t744 = String_Len(raw); + _t745 = (int)_t744; + const char* _t746; + _t746 = bux_base64_encode(raw, _t745); + return _t746; } - endif281:; - _t756 = (alg == JwtAlg_RS512); - if (!_t756) goto endif283; + endif268:; + _t747 = (alg == JwtAlg_RS512); + if (!_t747) goto endif270; { const char* raw; - const char* _t757; - _t757 = Rsa_SignSha512(key, signingInput); - raw = _t757; - unsigned int _t758; - _t758 = String_Len(raw); - _t759 = (int)_t758; - const char* _t760; - _t760 = bux_base64_encode(raw, _t759); - return _t760; + const char* _t748; + _t748 = Rsa_SignSha512(key, signingInput); + raw = _t748; + unsigned int _t749; + _t749 = String_Len(raw); + _t750 = (int)_t749; + const char* _t751; + _t751 = bux_base64_encode(raw, _t750); + return _t751; } - endif283:; - _t761 = (alg == JwtAlg_ES256); - if (!_t761) goto endif285; + endif270:; + _t752 = (alg == JwtAlg_ES256); + if (!_t752) goto endif272; { const char* raw; - const char* _t762; - _t762 = Ecdsa_SignP256(key, signingInput); - raw = _t762; - unsigned int _t763; - _t763 = String_Len(raw); - _t764 = (int)_t763; - const char* _t765; - _t765 = bux_base64_encode(raw, _t764); - return _t765; + const char* _t753; + _t753 = Ecdsa_SignP256(key, signingInput); + raw = _t753; + unsigned int _t754; + _t754 = String_Len(raw); + _t755 = (int)_t754; + const char* _t756; + _t756 = bux_base64_encode(raw, _t755); + return _t756; } - endif285:; - _t766 = (alg == JwtAlg_ES384); - if (!_t766) goto endif287; + endif272:; + _t757 = (alg == JwtAlg_ES384); + if (!_t757) goto endif274; { const char* raw; - const char* _t767; - _t767 = Ecdsa_SignP384(key, signingInput); - raw = _t767; - unsigned int _t768; - _t768 = String_Len(raw); - _t769 = (int)_t768; - const char* _t770; - _t770 = bux_base64_encode(raw, _t769); - return _t770; + const char* _t758; + _t758 = Ecdsa_SignP384(key, signingInput); + raw = _t758; + unsigned int _t759; + _t759 = String_Len(raw); + _t760 = (int)_t759; + const char* _t761; + _t761 = bux_base64_encode(raw, _t760); + return _t761; } - endif287:; - _t771 = (alg == JwtAlg_EdDSA); - if (!_t771) goto endif289; + endif274:; + _t762 = (alg == JwtAlg_EdDSA); + if (!_t762) goto endif276; { - const char* _t772; - _t772 = Ed25519_Sign(key, signingInput); - return _t772; + const char* _t763; + _t763 = Ed25519_Sign(key, signingInput); + return _t763; } - endif289:; + endif276:; return ""; } bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key) { - int _t773; - const char* _t775; - int _t778; - const char* _t780; + int _t764; + const char* _t766; + int _t769; + const char* _t771; + int _t774; + const char* _t776; + int _t779; + int _t781; int _t783; - const char* _t785; - int _t788; - int _t790; - int _t792; - int _t794; - int _t796; - int _t798; - _t773 = (alg == JwtAlg_HS256); - if (!_t773) goto endif291; + int _t785; + int _t787; + int _t789; + _t764 = (alg == JwtAlg_HS256); + if (!_t764) goto endif278; { void* expectBuf; - void* _t774; - _t774 = Alloc(32); - expectBuf = _t774; + void* _t765; + _t765 = Alloc(32); + expectBuf = _t765; Hmac_Sha256Raw(key, signingInput, expectBuf); const char* expectB64; - _t775 = (const char*)expectBuf; - const char* _t776; - _t776 = bux_base64_encode(_t775, 32); - expectB64 = _t776; + _t766 = (const char*)expectBuf; + const char* _t767; + _t767 = bux_base64_encode(_t766, 32); + expectB64 = _t767; Free(expectBuf); - bool _t777; - _t777 = String_Eq(expectB64, signatureB64); - return _t777; + bool _t768; + _t768 = String_Eq(expectB64, signatureB64); + return _t768; } - endif291:; - _t778 = (alg == JwtAlg_HS384); - if (!_t778) goto endif293; + endif278:; + _t769 = (alg == JwtAlg_HS384); + if (!_t769) goto endif280; { void* expectBuf; - void* _t779; - _t779 = Alloc(48); - expectBuf = _t779; + void* _t770; + _t770 = Alloc(48); + expectBuf = _t770; Hmac_Sha384Raw(key, signingInput, expectBuf); const char* expectB64; - _t780 = (const char*)expectBuf; - const char* _t781; - _t781 = bux_base64_encode(_t780, 48); - expectB64 = _t781; + _t771 = (const char*)expectBuf; + const char* _t772; + _t772 = bux_base64_encode(_t771, 48); + expectB64 = _t772; Free(expectBuf); - bool _t782; - _t782 = String_Eq(expectB64, signatureB64); - return _t782; + bool _t773; + _t773 = String_Eq(expectB64, signatureB64); + return _t773; } - endif293:; - _t783 = (alg == JwtAlg_HS512); - if (!_t783) goto endif295; + endif280:; + _t774 = (alg == JwtAlg_HS512); + if (!_t774) goto endif282; { void* expectBuf; - void* _t784; - _t784 = Alloc(64); - expectBuf = _t784; + void* _t775; + _t775 = Alloc(64); + expectBuf = _t775; Hmac_Sha512Raw(key, signingInput, expectBuf); const char* expectB64; - _t785 = (const char*)expectBuf; - const char* _t786; - _t786 = bux_base64_encode(_t785, 64); - expectB64 = _t786; + _t776 = (const char*)expectBuf; + const char* _t777; + _t777 = bux_base64_encode(_t776, 64); + expectB64 = _t777; Free(expectBuf); - bool _t787; - _t787 = String_Eq(expectB64, signatureB64); - return _t787; + bool _t778; + _t778 = String_Eq(expectB64, signatureB64); + return _t778; } - endif295:; - _t788 = (alg == JwtAlg_RS256); - if (!_t788) goto endif297; + endif282:; + _t779 = (alg == JwtAlg_RS256); + if (!_t779) goto endif284; { - bool _t789; - _t789 = Rsa_VerifySha256(key, signingInput, signatureB64); - return _t789; + bool _t780; + _t780 = Rsa_VerifySha256(key, signingInput, signatureB64); + return _t780; } - endif297:; - _t790 = (alg == JwtAlg_RS384); - if (!_t790) goto endif299; + endif284:; + _t781 = (alg == JwtAlg_RS384); + if (!_t781) goto endif286; { - bool _t791; - _t791 = Rsa_VerifySha384(key, signingInput, signatureB64); - return _t791; + bool _t782; + _t782 = Rsa_VerifySha384(key, signingInput, signatureB64); + return _t782; } - endif299:; - _t792 = (alg == JwtAlg_RS512); - if (!_t792) goto endif301; + endif286:; + _t783 = (alg == JwtAlg_RS512); + if (!_t783) goto endif288; { - bool _t793; - _t793 = Rsa_VerifySha512(key, signingInput, signatureB64); - return _t793; + bool _t784; + _t784 = Rsa_VerifySha512(key, signingInput, signatureB64); + return _t784; } - endif301:; - _t794 = (alg == JwtAlg_ES256); - if (!_t794) goto endif303; + endif288:; + _t785 = (alg == JwtAlg_ES256); + if (!_t785) goto endif290; { - bool _t795; - _t795 = Ecdsa_VerifyP256(key, signingInput, signatureB64); - return _t795; + bool _t786; + _t786 = Ecdsa_VerifyP256(key, signingInput, signatureB64); + return _t786; } - endif303:; - _t796 = (alg == JwtAlg_ES384); - if (!_t796) goto endif305; + endif290:; + _t787 = (alg == JwtAlg_ES384); + if (!_t787) goto endif292; { - bool _t797; - _t797 = Ecdsa_VerifyP384(key, signingInput, signatureB64); - return _t797; + bool _t788; + _t788 = Ecdsa_VerifyP384(key, signingInput, signatureB64); + return _t788; } - endif305:; - _t798 = (alg == JwtAlg_EdDSA); - if (!_t798) goto endif307; + endif292:; + _t789 = (alg == JwtAlg_EdDSA); + if (!_t789) goto endif294; { - bool _t799; - _t799 = Ed25519_Verify(key, signatureB64, signingInput); - return _t799; + bool _t790; + _t790 = Ed25519_Verify(key, signatureB64, signingInput); + return _t790; } - endif307:; + endif294:; return 0; } const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key) { const char* headerB64; - const char* _t800; - _t800 = Base64URL_Encode(headerJson); - headerB64 = _t800; + const char* _t791; + _t791 = Base64URL_Encode(headerJson); + headerB64 = _t791; const char* payloadB64; - const char* _t801; - _t801 = Base64URL_Encode(payloadJson); - payloadB64 = _t801; + const char* _t792; + _t792 = Base64URL_Encode(payloadJson); + payloadB64 = _t792; const char* signingInput; - const char* _t802; - _t802 = String_Concat(headerB64, "."); - signingInput = _t802; + const char* _t793; + _t793 = String_Concat(headerB64, "."); + signingInput = _t793; const char* signingInputFull; - const char* _t803; - _t803 = String_Concat(signingInput, payloadB64); - signingInputFull = _t803; + const char* _t794; + _t794 = String_Concat(signingInput, payloadB64); + signingInputFull = _t794; const char* sigB64; - const char* _t804; - _t804 = Jwt_Sign(alg, signingInputFull, key); - sigB64 = _t804; + const char* _t795; + _t795 = Jwt_Sign(alg, signingInputFull, key); + sigB64 = _t795; const char* part1; - const char* _t805; - _t805 = String_Concat(signingInputFull, "."); - part1 = _t805; - const char* _t806; - _t806 = String_Concat(part1, sigB64); - return _t806; + const char* _t796; + _t796 = String_Concat(signingInputFull, "."); + part1 = _t796; + const char* _t797; + _t797 = String_Concat(part1, sigB64); + return _t797; } bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut) { - int _t808; - int _t815; + int _t799; + int _t806; unsigned int partCount; - unsigned int _t807; - _t807 = bux_str_split_count(token, "."); - partCount = _t807; - _t808 = (partCount != 3); - if (!_t808) goto endif309; + unsigned int _t798; + _t798 = bux_str_split_count(token, "."); + partCount = _t798; + _t799 = (partCount != 3); + if (!_t799) goto endif296; { return 0; } - endif309:; + endif296:; const char* headerB64; - const char* _t809; - _t809 = bux_str_split_part(token, ".", 0); - headerB64 = _t809; + const char* _t800; + _t800 = bux_str_split_part(token, ".", 0); + headerB64 = _t800; const char* payloadB64; - const char* _t810; - _t810 = bux_str_split_part(token, ".", 1); - payloadB64 = _t810; + const char* _t801; + _t801 = bux_str_split_part(token, ".", 1); + payloadB64 = _t801; const char* sigB64; - const char* _t811; - _t811 = bux_str_split_part(token, ".", 2); - sigB64 = _t811; + const char* _t802; + _t802 = bux_str_split_part(token, ".", 2); + sigB64 = _t802; const char* input; - const char* _t812; - _t812 = String_Concat(headerB64, "."); - input = _t812; + const char* _t803; + _t803 = String_Concat(headerB64, "."); + input = _t803; const char* signingInput; - const char* _t813; - _t813 = String_Concat(input, payloadB64); - signingInput = _t813; - bool _t814; - _t814 = Jwt_Verify(alg, signingInput, sigB64, key); - _t815 = !_t814; - if (!_t815) goto endif311; + const char* _t804; + _t804 = String_Concat(input, payloadB64); + signingInput = _t804; + bool _t805; + _t805 = Jwt_Verify(alg, signingInput, sigB64, key); + _t806 = !_t805; + if (!_t806) goto endif298; { return 0; } - endif311:; - const char* _t816; - _t816 = Base64URL_Decode(headerB64); - headerOut[0] = _t816; - const char* _t817; - _t817 = Base64URL_Decode(payloadB64); - payloadOut[0] = _t817; + endif298:; + const char* _t807; + _t807 = Base64URL_Decode(headerB64); + headerOut[0] = _t807; + const char* _t808; + _t808 = Base64URL_Decode(payloadB64); + payloadOut[0] = _t808; return 1; } const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret) { const char* header; - const char* _t818; - _t818 = Jwt_MakeHeader(JwtAlg_HS256); - header = _t818; - const char* _t819; - _t819 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); - return _t819; + const char* _t809; + _t809 = Jwt_MakeHeader(JwtAlg_HS256); + header = _t809; + const char* _t810; + _t810 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); + return _t810; } const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret) { const char* header; - const char* _t820; - _t820 = Jwt_MakeHeader(JwtAlg_HS384); - header = _t820; - const char* _t821; - _t821 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); - return _t821; + const char* _t811; + _t811 = Jwt_MakeHeader(JwtAlg_HS384); + header = _t811; + const char* _t812; + _t812 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); + return _t812; } const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret) { const char* header; - const char* _t822; - _t822 = Jwt_MakeHeader(JwtAlg_HS512); - header = _t822; - const char* _t823; - _t823 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); - return _t823; + const char* _t813; + _t813 = Jwt_MakeHeader(JwtAlg_HS512); + header = _t813; + const char* _t814; + _t814 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); + return _t814; } const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t824; - _t824 = Jwt_MakeHeader(JwtAlg_RS256); - header = _t824; - const char* _t825; - _t825 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); - return _t825; + const char* _t815; + _t815 = Jwt_MakeHeader(JwtAlg_RS256); + header = _t815; + const char* _t816; + _t816 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); + return _t816; } const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t826; - _t826 = Jwt_MakeHeader(JwtAlg_ES256); - header = _t826; - const char* _t827; - _t827 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); - return _t827; + const char* _t817; + _t817 = Jwt_MakeHeader(JwtAlg_ES256); + header = _t817; + const char* _t818; + _t818 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); + return _t818; } const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey) { const char* header; - const char* _t828; - _t828 = Jwt_MakeHeader(JwtAlg_EdDSA); - header = _t828; - const char* _t829; - _t829 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); - return _t829; + const char* _t819; + _t819 = Jwt_MakeHeader(JwtAlg_EdDSA); + header = _t819; + const char* _t820; + _t820 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); + return _t820; } const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data) { - int _t831; - int _t833; - void* _t834; + int _t822; + int _t824; + void* _t825; int siglen; siglen = 0; - unsigned int _t830; - _t830 = String_Len(pemPrivateKey); - _t831 = (int)_t830; - unsigned int _t832; - _t832 = String_Len(data); - _t833 = (int)_t832; - _t834 = &siglen; - const char* _t835; - _t835 = bux_ecdsa_sign_p256(pemPrivateKey, _t831, data, _t833, _t834); - return _t835; + unsigned int _t821; + _t821 = String_Len(pemPrivateKey); + _t822 = (int)_t821; + unsigned int _t823; + _t823 = String_Len(data); + _t824 = (int)_t823; + _t825 = &siglen; + const char* _t826; + _t826 = bux_ecdsa_sign_p256(pemPrivateKey, _t822, data, _t824, _t825); + return _t826; } const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data) { - int _t838; + int _t829; const char* raw; - const char* _t836; - _t836 = Ecdsa_SignP256(pemPrivateKey, data); - raw = _t836; - unsigned int _t837; - _t837 = String_Len(raw); - _t838 = (int)_t837; - const char* _t839; - _t839 = bux_base64_encode(raw, _t838); - return _t839; + const char* _t827; + _t827 = Ecdsa_SignP256(pemPrivateKey, data); + raw = _t827; + unsigned int _t828; + _t828 = String_Len(raw); + _t829 = (int)_t828; + const char* _t830; + _t830 = bux_base64_encode(raw, _t829); + return _t830; } bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature) { - int _t841; - int _t843; - int _t845; - int _t847; + int _t832; + int _t834; + int _t836; + int _t838; int r; - unsigned int _t840; - _t840 = String_Len(pemPublicKey); - _t841 = (int)_t840; - unsigned int _t842; - _t842 = String_Len(data); - _t843 = (int)_t842; - unsigned int _t844; - _t844 = String_Len(signature); - _t845 = (int)_t844; - int _t846; - _t846 = bux_ecdsa_verify_p256(pemPublicKey, _t841, data, _t843, signature, _t845); - r = _t846; - _t847 = (r == 1); - return _t847; + unsigned int _t831; + _t831 = String_Len(pemPublicKey); + _t832 = (int)_t831; + unsigned int _t833; + _t833 = String_Len(data); + _t834 = (int)_t833; + unsigned int _t835; + _t835 = String_Len(signature); + _t836 = (int)_t835; + int _t837; + _t837 = bux_ecdsa_verify_p256(pemPublicKey, _t832, data, _t834, signature, _t836); + r = _t837; + _t838 = (r == 1); + return _t838; } bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t849; - void* _t850; + int _t840; + void* _t841; int outlen; outlen = 0; const char* sig; - unsigned int _t848; - _t848 = String_Len(signatureB64); - _t849 = (int)_t848; - _t850 = &outlen; - const char* _t851; - _t851 = bux_base64_decode(signatureB64, _t849, _t850); - sig = _t851; - bool _t852; - _t852 = Ecdsa_VerifyP256(pemPublicKey, data, sig); - return _t852; + unsigned int _t839; + _t839 = String_Len(signatureB64); + _t840 = (int)_t839; + _t841 = &outlen; + const char* _t842; + _t842 = bux_base64_decode(signatureB64, _t840, _t841); + sig = _t842; + bool _t843; + _t843 = Ecdsa_VerifyP256(pemPublicKey, data, sig); + return _t843; } const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data) { - int _t854; - int _t856; - void* _t857; + int _t845; + int _t847; + void* _t848; int siglen; siglen = 0; - unsigned int _t853; - _t853 = String_Len(pemPrivateKey); - _t854 = (int)_t853; - unsigned int _t855; - _t855 = String_Len(data); - _t856 = (int)_t855; - _t857 = &siglen; - const char* _t858; - _t858 = bux_ecdsa_sign_p384(pemPrivateKey, _t854, data, _t856, _t857); - return _t858; + unsigned int _t844; + _t844 = String_Len(pemPrivateKey); + _t845 = (int)_t844; + unsigned int _t846; + _t846 = String_Len(data); + _t847 = (int)_t846; + _t848 = &siglen; + const char* _t849; + _t849 = bux_ecdsa_sign_p384(pemPrivateKey, _t845, data, _t847, _t848); + return _t849; } const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data) { - int _t861; + int _t852; const char* raw; - const char* _t859; - _t859 = Ecdsa_SignP384(pemPrivateKey, data); - raw = _t859; - unsigned int _t860; - _t860 = String_Len(raw); - _t861 = (int)_t860; - const char* _t862; - _t862 = bux_base64_encode(raw, _t861); - return _t862; + const char* _t850; + _t850 = Ecdsa_SignP384(pemPrivateKey, data); + raw = _t850; + unsigned int _t851; + _t851 = String_Len(raw); + _t852 = (int)_t851; + const char* _t853; + _t853 = bux_base64_encode(raw, _t852); + return _t853; } bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature) { - int _t864; - int _t866; - int _t868; - int _t870; + int _t855; + int _t857; + int _t859; + int _t861; int r; - unsigned int _t863; - _t863 = String_Len(pemPublicKey); - _t864 = (int)_t863; - unsigned int _t865; - _t865 = String_Len(data); - _t866 = (int)_t865; - unsigned int _t867; - _t867 = String_Len(signature); - _t868 = (int)_t867; - int _t869; - _t869 = bux_ecdsa_verify_p384(pemPublicKey, _t864, data, _t866, signature, _t868); - r = _t869; - _t870 = (r == 1); - return _t870; + unsigned int _t854; + _t854 = String_Len(pemPublicKey); + _t855 = (int)_t854; + unsigned int _t856; + _t856 = String_Len(data); + _t857 = (int)_t856; + unsigned int _t858; + _t858 = String_Len(signature); + _t859 = (int)_t858; + int _t860; + _t860 = bux_ecdsa_verify_p384(pemPublicKey, _t855, data, _t857, signature, _t859); + r = _t860; + _t861 = (r == 1); + return _t861; } bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t872; - void* _t873; + int _t863; + void* _t864; int outlen; outlen = 0; const char* sig; - unsigned int _t871; - _t871 = String_Len(signatureB64); - _t872 = (int)_t871; - _t873 = &outlen; - const char* _t874; - _t874 = bux_base64_decode(signatureB64, _t872, _t873); - sig = _t874; - bool _t875; - _t875 = Ecdsa_VerifyP384(pemPublicKey, data, sig); - return _t875; + unsigned int _t862; + _t862 = String_Len(signatureB64); + _t863 = (int)_t862; + _t864 = &outlen; + const char* _t865; + _t865 = bux_base64_decode(signatureB64, _t863, _t864); + sig = _t865; + bool _t866; + _t866 = Ecdsa_VerifyP384(pemPublicKey, data, sig); + return _t866; } bool Ed25519_Keypair(void* pubKey, void* privKey) { - int _t877; + int _t868; int r; - int _t876; - _t876 = bux_ed25519_keypair(pubKey, privKey); - r = _t876; - _t877 = (r == 1); - return _t877; + int _t867; + _t867 = bux_ed25519_keypair(pubKey, privKey); + r = _t867; + _t868 = (r == 1); + return _t868; } const char* Ed25519_KeypairBase64(void) { - unsigned int _t878; - unsigned int _t880; - int _t883; - const char* _t884; - const char* _t886; + unsigned int _t869; + unsigned int _t871; + int _t874; + const char* _t875; + const char* _t877; void* pubBuf; - _t878 = (unsigned int)ED25519_PUBKEY_SIZE; - void* _t879; - _t879 = Alloc(_t878); - pubBuf = _t879; + _t869 = (unsigned int)ED25519_PUBKEY_SIZE; + void* _t870; + _t870 = Alloc(_t869); + pubBuf = _t870; void* priv; - _t880 = (unsigned int)ED25519_PRIVKEY_SIZE; - void* _t881; - _t881 = Alloc(_t880); - priv = _t881; - int _t882; - _t882 = bux_ed25519_keypair(pubBuf, priv); - _t883 = (_t882 != 1); - if (!_t883) goto endif313; + _t871 = (unsigned int)ED25519_PRIVKEY_SIZE; + void* _t872; + _t872 = Alloc(_t871); + priv = _t872; + int _t873; + _t873 = bux_ed25519_keypair(pubBuf, priv); + _t874 = (_t873 != 1); + if (!_t874) goto endif300; { Free(pubBuf); Free(priv); return ""; } - endif313:; + endif300:; const char* pubB64; - _t884 = (const char*)pubBuf; - const char* _t885; - _t885 = bux_base64_encode(_t884, ED25519_PUBKEY_SIZE); - pubB64 = _t885; + _t875 = (const char*)pubBuf; + const char* _t876; + _t876 = bux_base64_encode(_t875, ED25519_PUBKEY_SIZE); + pubB64 = _t876; const char* privB64; - _t886 = (const char*)priv; - const char* _t887; - _t887 = bux_base64_encode(_t886, ED25519_PRIVKEY_SIZE); - privB64 = _t887; + _t877 = (const char*)priv; + const char* _t878; + _t878 = bux_base64_encode(_t877, ED25519_PRIVKEY_SIZE); + privB64 = _t878; Free(pubBuf); Free(priv); const char* pair; - const char* _t888; - _t888 = String_Concat(pubB64, ":"); - pair = _t888; - const char* _t889; - _t889 = String_Concat(pair, privB64); - return _t889; + const char* _t879; + _t879 = String_Concat(pubB64, ":"); + pair = _t879; + const char* _t880; + _t880 = String_Concat(pair, privB64); + return _t880; } const char* Ed25519_Sign(const char* privKey, const char* data) { - unsigned int _t890; - int _t893; - int _t895; - const char* _t896; + unsigned int _t881; + int _t884; + int _t886; + const char* _t887; void* sig; - _t890 = (unsigned int)ED25519_SIG_SIZE; - void* _t891; - _t891 = Alloc(_t890); - sig = _t891; - unsigned int _t892; - _t892 = String_Len(data); - _t893 = (int)_t892; - int _t894; - _t894 = bux_ed25519_sign(privKey, data, _t893, sig); - _t895 = (_t894 != 1); - if (!_t895) goto endif315; + _t881 = (unsigned int)ED25519_SIG_SIZE; + void* _t882; + _t882 = Alloc(_t881); + sig = _t882; + unsigned int _t883; + _t883 = String_Len(data); + _t884 = (int)_t883; + int _t885; + _t885 = bux_ed25519_sign(privKey, data, _t884, sig); + _t886 = (_t885 != 1); + if (!_t886) goto endif302; { Free(sig); return ""; } - endif315:; - _t896 = (const char*)sig; - return _t896; + endif302:; + _t887 = (const char*)sig; + return _t887; } const char* Ed25519_SignBase64(const char* privKey, const char* data) { - int _t899; + int _t890; const char* sig; - const char* _t897; - _t897 = Ed25519_Sign(privKey, data); - sig = _t897; - unsigned int _t898; - _t898 = String_Len(sig); - _t899 = (_t898 == 0); - if (!_t899) goto endif317; + const char* _t888; + _t888 = Ed25519_Sign(privKey, data); + sig = _t888; + unsigned int _t889; + _t889 = String_Len(sig); + _t890 = (_t889 == 0); + if (!_t890) goto endif304; { return ""; } - endif317:; - const char* _t900; - _t900 = bux_base64_encode(sig, ED25519_SIG_SIZE); - return _t900; + endif304:; + const char* _t891; + _t891 = bux_base64_encode(sig, ED25519_SIG_SIZE); + return _t891; } bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data) { - int _t902; - int _t904; + int _t893; + int _t895; int r; - unsigned int _t901; - _t901 = String_Len(data); - _t902 = (int)_t901; - int _t903; - _t903 = bux_ed25519_verify(pubKey, signature, data, _t902); - r = _t903; - _t904 = (r == 1); - return _t904; + unsigned int _t892; + _t892 = String_Len(data); + _t893 = (int)_t892; + int _t894; + _t894 = bux_ed25519_verify(pubKey, signature, data, _t893); + r = _t894; + _t895 = (r == 1); + return _t895; } bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data) { - int _t906; - void* _t907; - int _t909; + int _t897; + void* _t898; + int _t900; int outlen; outlen = 0; const char* sig; - unsigned int _t905; - _t905 = String_Len(signatureB64); - _t906 = (int)_t905; - _t907 = &outlen; - const char* _t908; - _t908 = bux_base64_decode(signatureB64, _t906, _t907); - sig = _t908; - _t909 = (outlen != ED25519_SIG_SIZE); - if (!_t909) goto endif319; + unsigned int _t896; + _t896 = String_Len(signatureB64); + _t897 = (int)_t896; + _t898 = &outlen; + const char* _t899; + _t899 = bux_base64_decode(signatureB64, _t897, _t898); + sig = _t899; + _t900 = (outlen != ED25519_SIG_SIZE); + if (!_t900) goto endif306; { return 0; } - endif319:; - bool _t910; - _t910 = Ed25519_Verify(pubKey, sig, data); - return _t910; + endif306:; + bool _t901; + _t901 = Ed25519_Verify(pubKey, sig, data); + return _t901; } const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data) { - int _t912; - int _t914; - void* _t915; + int _t903; + int _t905; + void* _t906; int siglen; siglen = 0; - unsigned int _t911; - _t911 = String_Len(pemPrivateKey); - _t912 = (int)_t911; - unsigned int _t913; - _t913 = String_Len(data); - _t914 = (int)_t913; - _t915 = &siglen; - const char* _t916; - _t916 = bux_rsa_sign_sha256(pemPrivateKey, _t912, data, _t914, _t915); - return _t916; + unsigned int _t902; + _t902 = String_Len(pemPrivateKey); + _t903 = (int)_t902; + unsigned int _t904; + _t904 = String_Len(data); + _t905 = (int)_t904; + _t906 = &siglen; + const char* _t907; + _t907 = bux_rsa_sign_sha256(pemPrivateKey, _t903, data, _t905, _t906); + return _t907; } const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data) { - int _t918; - int _t920; - void* _t921; + int _t909; + int _t911; + void* _t912; int siglen; siglen = 0; - unsigned int _t917; - _t917 = String_Len(pemPrivateKey); - _t918 = (int)_t917; - unsigned int _t919; - _t919 = String_Len(data); - _t920 = (int)_t919; - _t921 = &siglen; - const char* _t922; - _t922 = bux_rsa_sign_sha384(pemPrivateKey, _t918, data, _t920, _t921); - return _t922; + unsigned int _t908; + _t908 = String_Len(pemPrivateKey); + _t909 = (int)_t908; + unsigned int _t910; + _t910 = String_Len(data); + _t911 = (int)_t910; + _t912 = &siglen; + const char* _t913; + _t913 = bux_rsa_sign_sha384(pemPrivateKey, _t909, data, _t911, _t912); + return _t913; } const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data) { - int _t924; - int _t926; - void* _t927; + int _t915; + int _t917; + void* _t918; int siglen; siglen = 0; - unsigned int _t923; - _t923 = String_Len(pemPrivateKey); - _t924 = (int)_t923; - unsigned int _t925; - _t925 = String_Len(data); - _t926 = (int)_t925; - _t927 = &siglen; - const char* _t928; - _t928 = bux_rsa_sign_sha512(pemPrivateKey, _t924, data, _t926, _t927); - return _t928; + unsigned int _t914; + _t914 = String_Len(pemPrivateKey); + _t915 = (int)_t914; + unsigned int _t916; + _t916 = String_Len(data); + _t917 = (int)_t916; + _t918 = &siglen; + const char* _t919; + _t919 = bux_rsa_sign_sha512(pemPrivateKey, _t915, data, _t917, _t918); + return _t919; } const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data) { - int _t931; + int _t922; const char* raw; - const char* _t929; - _t929 = Rsa_SignSha256(pemPrivateKey, data); - raw = _t929; - unsigned int _t930; - _t930 = String_Len(raw); - _t931 = (int)_t930; - const char* _t932; - _t932 = bux_base64_encode(raw, _t931); - return _t932; + const char* _t920; + _t920 = Rsa_SignSha256(pemPrivateKey, data); + raw = _t920; + unsigned int _t921; + _t921 = String_Len(raw); + _t922 = (int)_t921; + const char* _t923; + _t923 = bux_base64_encode(raw, _t922); + return _t923; } const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data) { - int _t935; + int _t926; const char* raw; - const char* _t933; - _t933 = Rsa_SignSha384(pemPrivateKey, data); - raw = _t933; - unsigned int _t934; - _t934 = String_Len(raw); - _t935 = (int)_t934; - const char* _t936; - _t936 = bux_base64_encode(raw, _t935); - return _t936; + const char* _t924; + _t924 = Rsa_SignSha384(pemPrivateKey, data); + raw = _t924; + unsigned int _t925; + _t925 = String_Len(raw); + _t926 = (int)_t925; + const char* _t927; + _t927 = bux_base64_encode(raw, _t926); + return _t927; } const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data) { - int _t939; + int _t930; const char* raw; - const char* _t937; - _t937 = Rsa_SignSha512(pemPrivateKey, data); - raw = _t937; - unsigned int _t938; - _t938 = String_Len(raw); - _t939 = (int)_t938; - const char* _t940; - _t940 = bux_base64_encode(raw, _t939); - return _t940; + const char* _t928; + _t928 = Rsa_SignSha512(pemPrivateKey, data); + raw = _t928; + unsigned int _t929; + _t929 = String_Len(raw); + _t930 = (int)_t929; + const char* _t931; + _t931 = bux_base64_encode(raw, _t930); + return _t931; } bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature) { - int _t942; - int _t944; - int _t946; - int _t948; + int _t933; + int _t935; + int _t937; + int _t939; int r; - unsigned int _t941; - _t941 = String_Len(pemPublicKey); - _t942 = (int)_t941; - unsigned int _t943; - _t943 = String_Len(data); - _t944 = (int)_t943; - unsigned int _t945; - _t945 = String_Len(signature); - _t946 = (int)_t945; - int _t947; - _t947 = bux_rsa_verify_sha256(pemPublicKey, _t942, data, _t944, signature, _t946); - r = _t947; - _t948 = (r == 1); - return _t948; + unsigned int _t932; + _t932 = String_Len(pemPublicKey); + _t933 = (int)_t932; + unsigned int _t934; + _t934 = String_Len(data); + _t935 = (int)_t934; + unsigned int _t936; + _t936 = String_Len(signature); + _t937 = (int)_t936; + int _t938; + _t938 = bux_rsa_verify_sha256(pemPublicKey, _t933, data, _t935, signature, _t937); + r = _t938; + _t939 = (r == 1); + return _t939; } bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature) { - int _t950; - int _t952; - int _t954; - int _t956; + int _t941; + int _t943; + int _t945; + int _t947; int r; - unsigned int _t949; - _t949 = String_Len(pemPublicKey); - _t950 = (int)_t949; - unsigned int _t951; - _t951 = String_Len(data); - _t952 = (int)_t951; - unsigned int _t953; - _t953 = String_Len(signature); - _t954 = (int)_t953; - int _t955; - _t955 = bux_rsa_verify_sha384(pemPublicKey, _t950, data, _t952, signature, _t954); - r = _t955; - _t956 = (r == 1); - return _t956; + unsigned int _t940; + _t940 = String_Len(pemPublicKey); + _t941 = (int)_t940; + unsigned int _t942; + _t942 = String_Len(data); + _t943 = (int)_t942; + unsigned int _t944; + _t944 = String_Len(signature); + _t945 = (int)_t944; + int _t946; + _t946 = bux_rsa_verify_sha384(pemPublicKey, _t941, data, _t943, signature, _t945); + r = _t946; + _t947 = (r == 1); + return _t947; } bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature) { - int _t958; - int _t960; - int _t962; - int _t964; + int _t949; + int _t951; + int _t953; + int _t955; int r; - unsigned int _t957; - _t957 = String_Len(pemPublicKey); - _t958 = (int)_t957; - unsigned int _t959; - _t959 = String_Len(data); - _t960 = (int)_t959; - unsigned int _t961; - _t961 = String_Len(signature); - _t962 = (int)_t961; - int _t963; - _t963 = bux_rsa_verify_sha512(pemPublicKey, _t958, data, _t960, signature, _t962); - r = _t963; - _t964 = (r == 1); - return _t964; + unsigned int _t948; + _t948 = String_Len(pemPublicKey); + _t949 = (int)_t948; + unsigned int _t950; + _t950 = String_Len(data); + _t951 = (int)_t950; + unsigned int _t952; + _t952 = String_Len(signature); + _t953 = (int)_t952; + int _t954; + _t954 = bux_rsa_verify_sha512(pemPublicKey, _t949, data, _t951, signature, _t953); + r = _t954; + _t955 = (r == 1); + return _t955; } bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t966; - void* _t967; + int _t957; + void* _t958; int outlen; outlen = 0; const char* sig; - unsigned int _t965; - _t965 = String_Len(signatureB64); - _t966 = (int)_t965; - _t967 = &outlen; - const char* _t968; - _t968 = bux_base64_decode(signatureB64, _t966, _t967); - sig = _t968; - bool _t969; - _t969 = Rsa_VerifySha256(pemPublicKey, data, sig); - return _t969; + unsigned int _t956; + _t956 = String_Len(signatureB64); + _t957 = (int)_t956; + _t958 = &outlen; + const char* _t959; + _t959 = bux_base64_decode(signatureB64, _t957, _t958); + sig = _t959; + bool _t960; + _t960 = Rsa_VerifySha256(pemPublicKey, data, sig); + return _t960; } bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t971; - void* _t972; + int _t962; + void* _t963; int outlen; outlen = 0; const char* sig; - unsigned int _t970; - _t970 = String_Len(signatureB64); - _t971 = (int)_t970; - _t972 = &outlen; - const char* _t973; - _t973 = bux_base64_decode(signatureB64, _t971, _t972); - sig = _t973; - bool _t974; - _t974 = Rsa_VerifySha384(pemPublicKey, data, sig); - return _t974; + unsigned int _t961; + _t961 = String_Len(signatureB64); + _t962 = (int)_t961; + _t963 = &outlen; + const char* _t964; + _t964 = bux_base64_decode(signatureB64, _t962, _t963); + sig = _t964; + bool _t965; + _t965 = Rsa_VerifySha384(pemPublicKey, data, sig); + return _t965; } bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t976; - void* _t977; + int _t967; + void* _t968; int outlen; outlen = 0; const char* sig; - unsigned int _t975; - _t975 = String_Len(signatureB64); - _t976 = (int)_t975; - _t977 = &outlen; - const char* _t978; - _t978 = bux_base64_decode(signatureB64, _t976, _t977); - sig = _t978; - bool _t979; - _t979 = Rsa_VerifySha512(pemPublicKey, data, sig); - return _t979; + unsigned int _t966; + _t966 = String_Len(signatureB64); + _t967 = (int)_t966; + _t968 = &outlen; + const char* _t969; + _t969 = bux_base64_decode(signatureB64, _t967, _t968); + sig = _t969; + bool _t970; + _t970 = Rsa_VerifySha512(pemPublicKey, data, sig); + return _t970; } int Main(void) { - int _t986; + int _t977; const char* hello; hello = "Hello"; const char* world; world = "World"; PrintLine("String operations:"); PrintLine("Length of 'Hello':"); - unsigned int _t980; - _t980 = String_Len(hello); - PrintInt(_t980); + unsigned int _t971; + _t971 = String_Len(hello); + PrintInt(_t971); PrintLine(""); const char* greeting; - const char* _t981; - _t981 = String_Concat(hello, ", "); - greeting = _t981; + const char* _t972; + _t972 = String_Concat(hello, ", "); + greeting = _t972; const char* greeting2; - const char* _t982; - _t982 = String_Concat(greeting, world); - greeting2 = _t982; + const char* _t973; + _t973 = String_Concat(greeting, world); + greeting2 = _t973; const char* full; - const char* _t983; - _t983 = String_Concat(greeting2, "!"); - full = _t983; + const char* _t974; + _t974 = String_Concat(greeting2, "!"); + full = _t974; PrintLine("Concatenated:"); PrintLine(full); - bool _t984; - _t984 = String_Eq(hello, "Hello"); - if (!_t984) goto endif321; + bool _t975; + _t975 = String_Eq(hello, "Hello"); + if (!_t975) goto endif308; { PrintLine("'Hello' equals 'Hello'"); } - endif321:; - bool _t985; - _t985 = String_Eq(hello, world); - _t986 = !_t985; - if (!_t986) goto endif323; + endif308:; + bool _t976; + _t976 = String_Eq(hello, world); + _t977 = !_t976; + if (!_t977) goto endif310; { PrintLine("'Hello' does not equal 'World'"); } - endif323:; + endif310:; return 0; } diff --git a/tests/golden/structs/expected.c b/tests/golden/structs/expected.c index b078dd2..4ad6106 100644 --- a/tests/golden/structs/expected.c +++ b/tests/golden/structs/expected.c @@ -199,6 +199,34 @@ extern const char* bux_base64_decode(const char* data, int len, int* outlen); #define ED25519_PRIVKEY_SIZE 32 #define ED25519_SIG_SIZE 64 +typedef struct Channel_float64 { + void* handle; +} Channel_float64; + +typedef struct TaskHandle { + void* handle; +} TaskHandle; + +typedef struct RwLock { + void* handle; +} RwLock; + +typedef struct Channel_int { + void* handle; +} Channel_int; + +typedef enum { + JwtAlg_HS256, + JwtAlg_HS384, + JwtAlg_HS512, + JwtAlg_RS256, + JwtAlg_RS384, + JwtAlg_RS512, + JwtAlg_ES256, + JwtAlg_ES384, + JwtAlg_EdDSA +} JwtAlg; + typedef enum { Result_Ok, Result_Err @@ -228,31 +256,6 @@ typedef struct { Option_Data data; } Option; -typedef enum { - JwtAlg_HS256, - JwtAlg_HS384, - JwtAlg_HS512, - JwtAlg_RS256, - JwtAlg_RS384, - JwtAlg_RS512, - JwtAlg_ES256, - JwtAlg_ES384, - JwtAlg_EdDSA -} JwtAlg; - - -typedef struct TaskHandle { - void* handle; -} TaskHandle; - -typedef struct Mutex { - void* handle; -} Mutex; - -typedef struct RwLock { - void* handle; -} RwLock; - typedef struct JsonValue { int tag; bool boolVal; @@ -267,12 +270,9 @@ typedef struct JsonValue { unsigned int objCap; } JsonValue; -typedef struct JsonParser { - const char* src; - unsigned int pos; - unsigned int len; - const char* error; -} JsonParser; +typedef struct Mutex { + void* handle; +} Mutex; typedef struct StringBuilder { void* handle; @@ -283,13 +283,12 @@ typedef struct Point { int y; } Point; -typedef struct Channel_int { - void* handle; -} Channel_int; - -typedef struct Channel_float64 { - void* handle; -} Channel_float64; +typedef struct JsonParser { + const char* src; + unsigned int pos; + unsigned int len; + const char* error; +} JsonParser; bool DirExists(const char* path); bool Mkdir(const char* path); @@ -873,7 +872,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { tmplLen = _t60; while1:; _t61 = (i < tmplLen); - if (!_t61) goto wend3; + if (!_t61) goto wend2; { const char* ch; const char* _t62; @@ -881,13 +880,13 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { ch = _t62; bool _t63; _t63 = String_Eq(ch, "{"); - if (!_t63) goto endif5; + if (!_t63) goto endif4; { unsigned int digitIdx; _t64 = i + 1; digitIdx = _t64; _t65 = (digitIdx < tmplLen); - if (!_t65) goto endif7; + if (!_t65) goto endif6; { const char* digitCh; const char* _t66; @@ -899,22 +898,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { d = _t67; bool __and_tmp_0; _t68 = (d >= 0); - if (!_t68) goto else8; + if (!_t68) goto else7; _t69 = (int64_t)argCount; _t70 = (d < _t69); *(bool*)&__and_tmp_0 = _t70; - goto endif9; - else8:; + goto endif8; + else7:; *(bool*)&__and_tmp_0 = 0; - endif9:; + endif8:; bool _t71; _t71 = *(bool*)&__and_tmp_0; - if (!_t71) goto endif11; + if (!_t71) goto endif10; { _t72 = i + 2; i = _t72; _t73 = (i < tmplLen); - if (!_t73) goto endif13; + if (!_t73) goto endif12; { const char* closeCh; const char* _t74; @@ -922,7 +921,7 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { closeCh = _t74; bool _t75; _t75 = String_Eq(closeCh, "}"); - if (!_t75) goto endif15; + if (!_t75) goto endif14; { _t76 = i + 1; i = _t76; @@ -935,22 +934,22 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { StringBuilder_Append(_t79, argStr); goto while1; } - endif15:; + endif14:; } - endif13:; + endif12:; } - endif11:; + endif10:; } - endif7:; + endif6:; } - endif5:; + endif4:; _t80 = &sb; StringBuilder_Append(_t80, ch); _t81 = i + 1; i = _t81; } goto while1; - wend3:; + wend2:; _t82 = &sb; const char* _t83; _t83 = StringBuilder_Build(_t82); @@ -958,276 +957,276 @@ const char* Fmt_Format(const char* tmpl, const char** argStrs, int argCount) { } const char* Fmt_Fmt1(const char* tmpl, const char* a1) { - const char** _t86; + const char** _t85; const char** args; /* sizeof(const char*) */ - void* _t85; - _t85 = bux_alloc(sizeof(const char*)); - _t86 = (const char**)_t85; - args = _t86; + void* _t84; + _t84 = bux_alloc(sizeof(const char*)); + _t85 = (const char**)_t84; + args = _t85; args[0] = a1; - const char* _t87; - _t87 = Fmt_Format(tmpl, args, 1); - return _t87; + const char* _t86; + _t86 = Fmt_Format(tmpl, args, 1); + return _t86; } const char* Fmt_FmtInt(const char* tmpl, int64_t val) { const char* s; + const char* _t87; + _t87 = String_FromInt(val); + s = _t87; const char* _t88; - _t88 = String_FromInt(val); - s = _t88; - const char* _t89; - _t89 = Fmt_Fmt1(tmpl, s); - return _t89; + _t88 = Fmt_Fmt1(tmpl, s); + return _t88; } const char* Fmt_FmtBool(const char* tmpl, bool val) { const char* s; + const char* _t89; + _t89 = String_FromBool(val); + s = _t89; const char* _t90; - _t90 = String_FromBool(val); - s = _t90; - const char* _t91; - _t91 = Fmt_Fmt1(tmpl, s); - return _t91; + _t90 = Fmt_Fmt1(tmpl, s); + return _t90; } const char* Fmt_FmtFloat(const char* tmpl, double val) { const char* s; + const char* _t91; + _t91 = String_FromFloat(val); + s = _t91; const char* _t92; - _t92 = String_FromFloat(val); - s = _t92; - const char* _t93; - _t93 = Fmt_Fmt1(tmpl, s); - return _t93; + _t92 = Fmt_Fmt1(tmpl, s); + return _t92; } const char* Fmt_Fmt2(const char* tmpl, const char* a1, const char* a2) { - int _t95; - const char** _t97; + int _t93; + const char** _t95; const char** args; /* sizeof(const char*) */ - _t95 = 2 * sizeof(const char*); - void* _t96; - _t96 = bux_alloc(_t95); - _t97 = (const char**)_t96; - args = _t97; + _t93 = 2 * sizeof(const char*); + void* _t94; + _t94 = bux_alloc(_t93); + _t95 = (const char**)_t94; + args = _t95; args[0] = a1; args[1] = a2; - const char* _t98; - _t98 = Fmt_Format(tmpl, args, 2); - return _t98; + const char* _t96; + _t96 = Fmt_Format(tmpl, args, 2); + return _t96; } const char* Fmt_Fmt3(const char* tmpl, const char* a1, const char* a2, const char* a3) { - int _t100; - const char** _t102; + int _t97; + const char** _t99; const char** args; /* sizeof(const char*) */ - _t100 = 3 * sizeof(const char*); - void* _t101; - _t101 = bux_alloc(_t100); - _t102 = (const char**)_t101; - args = _t102; + _t97 = 3 * sizeof(const char*); + void* _t98; + _t98 = bux_alloc(_t97); + _t99 = (const char**)_t98; + args = _t99; args[0] = a1; args[1] = a2; args[2] = a3; - const char* _t103; - _t103 = Fmt_Format(tmpl, args, 3); - return _t103; + const char* _t100; + _t100 = Fmt_Format(tmpl, args, 3); + return _t100; } const char* Crypto_Sha256(const char* data) { - int _t105; - void* _t107; + int _t102; + void* _t104; int len; - unsigned int _t104; - _t104 = String_Len(data); - _t105 = (int)_t104; - len = _t105; + unsigned int _t101; + _t101 = String_Len(data); + _t102 = (int)_t101; + len = _t102; void* hashBuf; - void* _t106; - _t106 = Alloc(32); - hashBuf = _t106; + void* _t103; + _t103 = Alloc(32); + hashBuf = _t103; bux_sha256(data, len, hashBuf); const char* result; - _t107 = (void*)hashBuf; - const char* _t108; - _t108 = bux_bytes_to_hex(_t107, 32); - result = _t108; + _t104 = (void*)hashBuf; + const char* _t105; + _t105 = bux_bytes_to_hex(_t104, 32); + result = _t105; Free(hashBuf); return result; } const char* Crypto_HmacSha256(const char* key, const char* message) { - int _t110; - int _t112; - void* _t114; + int _t107; + int _t109; + void* _t111; int keylen; - unsigned int _t109; - _t109 = String_Len(key); - _t110 = (int)_t109; - keylen = _t110; + unsigned int _t106; + _t106 = String_Len(key); + _t107 = (int)_t106; + keylen = _t107; int msglen; - unsigned int _t111; - _t111 = String_Len(message); - _t112 = (int)_t111; - msglen = _t112; + unsigned int _t108; + _t108 = String_Len(message); + _t109 = (int)_t108; + msglen = _t109; void* hmacBuf; - void* _t113; - _t113 = Alloc(32); - hmacBuf = _t113; + void* _t110; + _t110 = Alloc(32); + hmacBuf = _t110; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t114 = (void*)hmacBuf; - const char* _t115; - _t115 = bux_bytes_to_hex(_t114, 32); - result = _t115; + _t111 = (void*)hmacBuf; + const char* _t112; + _t112 = bux_bytes_to_hex(_t111, 32); + result = _t112; Free(hmacBuf); return result; } const char* Crypto_RandomBytes(int n) { - int _t116; - unsigned int _t117; - int _t120; - const char* _t121; - _t116 = (n <= 0); - if (!_t116) goto endif17; + int _t113; + unsigned int _t114; + int _t117; + const char* _t118; + _t113 = (n <= 0); + if (!_t113) goto endif16; { return ""; } - endif17:; + endif16:; void* buf; - _t117 = (unsigned int)n; - void* _t118; - _t118 = Alloc(_t117); - buf = _t118; - int _t119; - _t119 = bux_random_bytes(buf, n); - _t120 = (_t119 != 1); - if (!_t120) goto endif19; + _t114 = (unsigned int)n; + void* _t115; + _t115 = Alloc(_t114); + buf = _t115; + int _t116; + _t116 = bux_random_bytes(buf, n); + _t117 = (_t116 != 1); + if (!_t117) goto endif18; { Free(buf); return ""; } - endif19:; + endif18:; const char* result; - _t121 = (const char*)buf; - const char* _t122; - _t122 = bux_base64_encode(_t121, n); - result = _t122; + _t118 = (const char*)buf; + const char* _t119; + _t119 = bux_base64_encode(_t118, n); + result = _t119; Free(buf); return result; } const char* Crypto_Base64Encode(const char* s) { - int _t124; - unsigned int _t123; - _t123 = String_Len(s); - _t124 = (int)_t123; - const char* _t125; - _t125 = bux_base64_encode(s, _t124); - return _t125; + int _t121; + unsigned int _t120; + _t120 = String_Len(s); + _t121 = (int)_t120; + const char* _t122; + _t122 = bux_base64_encode(s, _t121); + return _t122; } const char* Crypto_HmacSha256Raw(const char* key, const char* message) { - int _t127; - int _t129; - const char* _t131; + int _t124; + int _t126; + const char* _t128; int keylen; - unsigned int _t126; - _t126 = String_Len(key); - _t127 = (int)_t126; - keylen = _t127; + unsigned int _t123; + _t123 = String_Len(key); + _t124 = (int)_t123; + keylen = _t124; int msglen; - unsigned int _t128; - _t128 = String_Len(message); - _t129 = (int)_t128; - msglen = _t129; + unsigned int _t125; + _t125 = String_Len(message); + _t126 = (int)_t125; + msglen = _t126; void* hmacBuf; - void* _t130; - _t130 = Alloc(32); - hmacBuf = _t130; + void* _t127; + _t127 = Alloc(32); + hmacBuf = _t127; bux_hmac_sha256(key, keylen, message, msglen, hmacBuf); const char* result; - _t131 = (const char*)hmacBuf; - const char* _t132; - _t132 = bux_base64_encode(_t131, 32); - result = _t132; + _t128 = (const char*)hmacBuf; + const char* _t129; + _t129 = bux_base64_encode(_t128, 32); + result = _t129; Free(hmacBuf); return result; } const char* Crypto_Base64Decode(const char* s) { - int _t134; - void* _t135; + int _t131; + void* _t132; int outlen; outlen = 0; - unsigned int _t133; - _t133 = String_Len(s); - _t134 = (int)_t133; - _t135 = &outlen; - const char* _t136; - _t136 = bux_base64_decode(s, _t134, _t135); - return _t136; + unsigned int _t130; + _t130 = String_Len(s); + _t131 = (int)_t130; + _t132 = &outlen; + const char* _t133; + _t133 = bux_base64_decode(s, _t131, _t132); + return _t133; } Mutex Mutex_New(void) { - Mutex _t138; - void* _t137; - _t137 = bux_mutex_new(); - _t138 = (Mutex){.handle = _t137}; - return _t138; + Mutex _t135; + void* _t134; + _t134 = bux_mutex_new(); + _t135 = (Mutex){.handle = _t134}; + return _t135; } void Mutex_Lock(Mutex* m) { - void* _t139; - _t139 = m->handle; - bux_mutex_lock(_t139); + void* _t136; + _t136 = m->handle; + bux_mutex_lock(_t136); } void Mutex_Unlock(Mutex* m) { - void* _t140; - _t140 = m->handle; - bux_mutex_unlock(_t140); + void* _t137; + _t137 = m->handle; + bux_mutex_unlock(_t137); } void Mutex_Free(Mutex* m) { - void* _t141; - _t141 = m->handle; - bux_mutex_free(_t141); + void* _t138; + _t138 = m->handle; + bux_mutex_free(_t138); } RwLock RwLock_New(void) { - RwLock _t143; - void* _t142; - _t142 = bux_rwlock_new(); - _t143 = (RwLock){.handle = _t142}; - return _t143; + RwLock _t140; + void* _t139; + _t139 = bux_rwlock_new(); + _t140 = (RwLock){.handle = _t139}; + return _t140; } void RwLock_ReadLock(RwLock* rw) { - void* _t144; - _t144 = rw->handle; - bux_rwlock_rdlock(_t144); + void* _t141; + _t141 = rw->handle; + bux_rwlock_rdlock(_t141); } void RwLock_WriteLock(RwLock* rw) { - void* _t145; - _t145 = rw->handle; - bux_rwlock_wrlock(_t145); + void* _t142; + _t142 = rw->handle; + bux_rwlock_wrlock(_t142); } void RwLock_Unlock(RwLock* rw) { - void* _t146; - _t146 = rw->handle; - bux_rwlock_unlock(_t146); + void* _t143; + _t143 = rw->handle; + bux_rwlock_unlock(_t143); } void RwLock_Free(RwLock* rw) { - void* _t147; - _t147 = rw->handle; - bux_rwlock_free(_t147); + void* _t144; + _t144 = rw->handle; + bux_rwlock_free(_t144); } void Test_Exit(int code) { @@ -1235,15 +1234,15 @@ void Test_Exit(int code) { } void Test_Assert(bool cond) { - int _t148; - _t148 = (int)cond; - bux_assert(_t148, "", 0, ""); + int _t145; + _t145 = (int)cond; + bux_assert(_t145, "", 0, ""); } void Test_AssertEqInt(int a, int b) { - int _t149; - _t149 = (a != b); - if (!_t149) goto endif21; + int _t146; + _t146 = (a != b); + if (!_t146) goto endif20; { PrintLine("ASSERT_EQ FAILED:"); PrintInt(a); @@ -1251,27 +1250,27 @@ void Test_AssertEqInt(int a, int b) { PrintInt(b); bux_exit(1); } - endif21:; + endif20:; } void Test_AssertTrue(bool cond) { - int _t150; - _t150 = !cond; - if (!_t150) goto endif23; + int _t147; + _t147 = !cond; + if (!_t147) goto endif22; { PrintLine("ASSERT_TRUE FAILED"); bux_exit(1); } - endif23:; + endif22:; } void Test_AssertFalse(bool cond) { - if (!cond) goto endif25; + if (!cond) goto endif24; { PrintLine("ASSERT_FALSE FAILED"); bux_exit(1); } - endif25:; + endif24:; } void Test_Fail(const char* msg) { @@ -1281,735 +1280,744 @@ void Test_Fail(const char* msg) { } Result Result_NewOk(int value) { - Result _t151; + Result _t148; Result r; - _t151 = (Result){.tag = Result_Ok}; - r = _t151; + _t148 = (Result){.tag = Result_Ok}; + r = _t148; r.data.Ok_0 = value; return r; } Result Result_NewErr(const char* msg) { - Result _t152; + Result _t149; Result r; - _t152 = (Result){.tag = Result_Err}; - r = _t152; + _t149 = (Result){.tag = Result_Err}; + r = _t149; r.data.Err_0 = msg; return r; } bool Result_IsOk(Result r) { - int _t154; - Result_Tag _t153; - _t153 = r.tag; - _t154 = (_t153 == Result_Ok); - return _t154; + int _t151; + Result_Tag _t150; + _t150 = r.tag; + _t151 = (_t150 == Result_Ok); + return _t151; } bool Result_IsErr(Result r) { - int _t156; - Result_Tag _t155; - _t155 = r.tag; - _t156 = (_t155 == Result_Err); - return _t156; + int _t153; + Result_Tag _t152; + _t152 = r.tag; + _t153 = (_t152 == Result_Err); + return _t153; } int Result_Unwrap(Result r) { - int _t158; - Result_Tag _t157; - _t157 = r.tag; - _t158 = (_t157 != Result_Ok); - if (!_t158) goto endif27; + int _t155; + Result_Tag _t154; + _t154 = r.tag; + _t155 = (_t154 != Result_Ok); + if (!_t155) goto endif26; { PrintLine("panic: unwrap on Err"); return 0; } - endif27:; - Result_Data _t159; - _t159 = r.data; - int _t160; - _t160 = _t159.Ok_0; - return _t160; + endif26:; + Result_Data _t156; + _t156 = r.data; + int _t157; + _t157 = _t156.Ok_0; + return _t157; } int Result_UnwrapOr(Result r, int fallback) { - int _t162; - Result_Tag _t161; - _t161 = r.tag; - _t162 = (_t161 == Result_Ok); - if (!_t162) goto endif29; + int _t159; + Result_Tag _t158; + _t158 = r.tag; + _t159 = (_t158 == Result_Ok); + if (!_t159) goto endif28; { - Result_Data _t163; - _t163 = r.data; - int _t164; - _t164 = _t163.Ok_0; - return _t164; + Result_Data _t160; + _t160 = r.data; + int _t161; + _t161 = _t160.Ok_0; + return _t161; } - endif29:; + endif28:; return fallback; } Option Option_NewSome(int value) { - Option _t165; + Option _t162; Option o; - _t165 = (Option){.tag = Option_Some}; - o = _t165; + _t162 = (Option){.tag = Option_Some}; + o = _t162; o.data.Some_0 = value; return o; } Option Option_NewNone(void) { - Option _t166; - _t166 = (Option){.tag = Option_None}; - return _t166; + Option _t163; + _t163 = (Option){.tag = Option_None}; + return _t163; } bool Option_IsSome(Option o) { - int _t168; - Option_Tag _t167; - _t167 = o.tag; - _t168 = (_t167 == Option_Some); - return _t168; + int _t165; + Option_Tag _t164; + _t164 = o.tag; + _t165 = (_t164 == Option_Some); + return _t165; } bool Option_IsNone(Option o) { - int _t170; - Option_Tag _t169; - _t169 = o.tag; - _t170 = (_t169 == Option_None); - return _t170; + int _t167; + Option_Tag _t166; + _t166 = o.tag; + _t167 = (_t166 == Option_None); + return _t167; } int Option_Unwrap(Option o) { - int _t172; - Option_Tag _t171; - _t171 = o.tag; - _t172 = (_t171 != Option_Some); - if (!_t172) goto endif31; + int _t169; + Option_Tag _t168; + _t168 = o.tag; + _t169 = (_t168 != Option_Some); + if (!_t169) goto endif30; { PrintLine("panic: unwrap on None"); return 0; } - endif31:; - Option_Data _t173; - _t173 = o.data; - int _t174; - _t174 = _t173.Some_0; - return _t174; + endif30:; + Option_Data _t170; + _t170 = o.data; + int _t171; + _t171 = _t170.Some_0; + return _t171; } int Option_UnwrapOr(Option o, int fallback) { - int _t176; - Option_Tag _t175; - _t175 = o.tag; - _t176 = (_t175 == Option_Some); - if (!_t176) goto endif33; + int _t173; + Option_Tag _t172; + _t172 = o.tag; + _t173 = (_t172 == Option_Some); + if (!_t173) goto endif32; { - Option_Data _t177; - _t177 = o.data; - int _t178; - _t178 = _t177.Some_0; - return _t178; + Option_Data _t174; + _t174 = o.data; + int _t175; + _t175 = _t174.Some_0; + return _t175; } - endif33:; + endif32:; return fallback; } JsonValue Json_Null(void) { - JsonValue _t179; - _t179 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t179; + JsonValue _t176; + _t176 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t176; } JsonValue Json_Bool(bool b) { - JsonValue _t180; - _t180 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t180; + JsonValue _t177; + _t177 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t177; } JsonValue Json_Number(double n) { - JsonValue _t181; - _t181 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t181; + JsonValue _t178; + _t178 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t178; } JsonValue Json_String(const char* s) { - JsonValue _t182; - _t182 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t182; + JsonValue _t179; + _t179 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t179; } JsonValue Json_Array(void) { - JsonValue _t183; - _t183 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t183; + JsonValue _t180; + _t180 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t180; } JsonValue Json_Object(void) { - JsonValue _t184; - _t184 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; - return _t184; + JsonValue _t181; + _t181 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0}; + return _t181; } unsigned int Json_ArrayLen(JsonValue v) { - int _t186; - int _t185; - _t185 = v.tag; - _t186 = (_t185 != JsonTagArray); - if (!_t186) goto endif35; + int _t183; + int _t182; + _t182 = v.tag; + _t183 = (_t182 != JsonTagArray); + if (!_t183) goto endif34; { return 0; } - endif35:; - unsigned int _t187; - _t187 = v.arrLen; - return _t187; + endif34:; + unsigned int _t184; + _t184 = v.arrLen; + return _t184; } JsonValue Json_ArrayGet(JsonValue v, unsigned int index) { + int _t186; int _t189; - int _t192; - int _t188; - _t188 = v.tag; - _t189 = (_t188 != JsonTagArray); - if (!_t189) goto endif37; + int _t185; + _t185 = v.tag; + _t186 = (_t185 != JsonTagArray); + if (!_t186) goto endif36; + { + JsonValue _t187; + _t187 = Json_Null(); + return _t187; + } + endif36:; + unsigned int _t188; + _t188 = v.arrLen; + _t189 = (index >= _t188); + if (!_t189) goto endif38; { JsonValue _t190; _t190 = Json_Null(); return _t190; } - endif37:; - unsigned int _t191; - _t191 = v.arrLen; - _t192 = (index >= _t191); - if (!_t192) goto endif39; - { - JsonValue _t193; - _t193 = Json_Null(); - return _t193; - } - endif39:; - JsonValue* _t194; - _t194 = v.arrData; - JsonValue _t195; - _t195 = _t194[index]; - return _t195; + endif38:; + JsonValue* _t191; + _t191 = v.arrData; + JsonValue _t192; + _t192 = _t191[index]; + return _t192; } void Json_ArrayPush(JsonValue* self, JsonValue val) { + int _t194; int _t197; + int _t199; int _t200; - int _t202; - int _t204; - JsonValue* _t206; - int _t207; - void* _t209; - int _t211; - JsonValue* _t213; - int _t217; - int _t196; - _t196 = self->tag; - _t197 = (_t196 != JsonTagArray); - if (!_t197) goto endif41; + JsonValue* _t202; + int _t203; + void* _t205; + int _t206; + JsonValue* _t208; + int _t212; + int _t193; + _t193 = self->tag; + _t194 = (_t193 != JsonTagArray); + if (!_t194) goto endif40; { return; } - endif41:; - unsigned int _t198; - _t198 = self->arrLen; - unsigned int _t199; - _t199 = self->arrCap; - _t200 = (_t198 >= _t199); - if (!_t200) goto endif43; + endif40:; + unsigned int _t195; + _t195 = self->arrLen; + unsigned int _t196; + _t196 = self->arrCap; + _t197 = (_t195 >= _t196); + if (!_t197) goto endif42; { unsigned int arrNewCap; - unsigned int _t201; - _t201 = self->arrCap; - arrNewCap = _t201; - _t202 = (arrNewCap == 0); - if (!_t202) goto else44; + unsigned int _t198; + _t198 = self->arrCap; + arrNewCap = _t198; + _t199 = (arrNewCap == 0); + if (!_t199) goto else43; { self->arrCap = 4; /* sizeof(JsonValue) */ - _t204 = 4 * sizeof(JsonValue); - void* _t205; - _t205 = Alloc(_t204); - _t206 = (JsonValue*)_t205; - self->arrData = _t206; + _t200 = 4 * sizeof(JsonValue); + void* _t201; + _t201 = Alloc(_t200); + _t202 = (JsonValue*)_t201; + self->arrData = _t202; } - goto endif45; - else44:; + goto endif44; + else43:; { unsigned int doubleCap; - _t207 = arrNewCap * 2; - doubleCap = _t207; + _t203 = arrNewCap * 2; + doubleCap = _t203; self->arrCap = doubleCap; - JsonValue* _t208; - _t208 = self->arrData; - _t209 = (void*)_t208; + JsonValue* _t204; + _t204 = self->arrData; + _t205 = (void*)_t204; /* sizeof(JsonValue) */ - _t211 = doubleCap * sizeof(JsonValue); - void* _t212; - _t212 = Realloc(_t209, _t211); - _t213 = (JsonValue*)_t212; - self->arrData = _t213; + _t206 = doubleCap * sizeof(JsonValue); + void* _t207; + _t207 = Realloc(_t205, _t206); + _t208 = (JsonValue*)_t207; + self->arrData = _t208; } - endif45:; + endif44:; } - endif43:; - JsonValue* _t214; - _t214 = self->arrData; - unsigned int _t215; - _t215 = self->arrLen; - _t214[_t215] = val; - unsigned int _t216; - _t216 = self->arrLen; - _t217 = _t216 + 1; - self->arrLen = _t217; + endif42:; + JsonValue* _t209; + _t209 = self->arrData; + unsigned int _t210; + _t210 = self->arrLen; + _t209[_t210] = val; + unsigned int _t211; + _t211 = self->arrLen; + _t212 = _t211 + 1; + self->arrLen = _t212; } unsigned int Json_ObjectLen(JsonValue v) { - int _t219; - int _t218; - _t218 = v.tag; - _t219 = (_t218 != JsonTagObject); - if (!_t219) goto endif47; + int _t214; + int _t213; + _t213 = v.tag; + _t214 = (_t213 != JsonTagObject); + if (!_t214) goto endif46; { return 0; } - endif47:; - unsigned int _t220; - _t220 = v.objLen; - return _t220; + endif46:; + unsigned int _t215; + _t215 = v.objLen; + return _t215; } JsonValue Json_ObjectGet(JsonValue v, const char* key) { - int _t222; - int _t225; - int _t231; - int _t221; - _t221 = v.tag; - _t222 = (_t221 != JsonTagObject); - if (!_t222) goto endif49; + int _t217; + int _t220; + int _t226; + int _t216; + _t216 = v.tag; + _t217 = (_t216 != JsonTagObject); + if (!_t217) goto endif48; { - JsonValue _t223; - _t223 = Json_Null(); - return _t223; + JsonValue _t218; + _t218 = Json_Null(); + return _t218; } - endif49:; + endif48:; unsigned int i; i = 0; - while50:; - unsigned int _t224; - _t224 = v.objLen; - _t225 = (i < _t224); - if (!_t225) goto wend52; + while49:; + unsigned int _t219; + _t219 = v.objLen; + _t220 = (i < _t219); + if (!_t220) goto wend50; { - const char** _t226; - _t226 = v.objKeys; - const char* _t227; - _t227 = _t226[i]; - bool _t228; - _t228 = String_Eq(_t227, key); - if (!_t228) goto endif54; + const char** _t221; + _t221 = v.objKeys; + const char* _t222; + _t222 = _t221[i]; + bool _t223; + _t223 = String_Eq(_t222, key); + if (!_t223) goto endif52; { - JsonValue* _t229; - _t229 = v.objValues; - JsonValue _t230; - _t230 = _t229[i]; - return _t230; + JsonValue* _t224; + _t224 = v.objValues; + JsonValue _t225; + _t225 = _t224[i]; + return _t225; } - endif54:; - _t231 = i + 1; - i = _t231; + endif52:; + _t226 = i + 1; + i = _t226; } - goto while50; - wend52:; - JsonValue _t232; - _t232 = Json_Null(); - return _t232; + goto while49; + wend50:; + JsonValue _t227; + _t227 = Json_Null(); + return _t227; } bool Json_ObjectHas(JsonValue v, const char* key) { - int _t234; - int _t236; - int _t240; - int _t233; - _t233 = v.tag; - _t234 = (_t233 != JsonTagObject); - if (!_t234) goto endif56; + int _t229; + int _t231; + int _t235; + int _t228; + _t228 = v.tag; + _t229 = (_t228 != JsonTagObject); + if (!_t229) goto endif54; { return 0; } - endif56:; + endif54:; unsigned int i; i = 0; - while57:; - unsigned int _t235; - _t235 = v.objLen; - _t236 = (i < _t235); - if (!_t236) goto wend59; + while55:; + unsigned int _t230; + _t230 = v.objLen; + _t231 = (i < _t230); + if (!_t231) goto wend56; { - const char** _t237; - _t237 = v.objKeys; - const char* _t238; - _t238 = _t237[i]; - bool _t239; - _t239 = String_Eq(_t238, key); - if (!_t239) goto endif61; + const char** _t232; + _t232 = v.objKeys; + const char* _t233; + _t233 = _t232[i]; + bool _t234; + _t234 = String_Eq(_t233, key); + if (!_t234) goto endif58; { return 1; } - endif61:; - _t240 = i + 1; - i = _t240; + endif58:; + _t235 = i + 1; + i = _t235; } - goto while57; - wend59:; + goto while55; + wend56:; return 0; } void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) { - int _t242; + int _t237; + int _t239; int _t244; + int _t247; int _t249; - int _t252; - int _t254; + int _t250; + const char** _t252; + int _t253; + JsonValue* _t255; int _t256; - const char** _t258; - int _t260; - JsonValue* _t262; - int _t263; - void* _t265; - int _t267; - const char** _t269; - void* _t271; - int _t273; - JsonValue* _t275; - int _t281; - int _t241; - _t241 = self->tag; - _t242 = (_t241 != JsonTagObject); - if (!_t242) goto endif63; + void* _t258; + int _t259; + const char** _t261; + void* _t263; + int _t264; + JsonValue* _t266; + int _t272; + int _t236; + _t236 = self->tag; + _t237 = (_t236 != JsonTagObject); + if (!_t237) goto endif60; { return; } - endif63:; + endif60:; unsigned int i; i = 0; - while64:; - unsigned int _t243; - _t243 = self->objLen; - _t244 = (i < _t243); - if (!_t244) goto wend66; + while61:; + unsigned int _t238; + _t238 = self->objLen; + _t239 = (i < _t238); + if (!_t239) goto wend62; { - const char** _t245; - _t245 = self->objKeys; - const char* _t246; - _t246 = _t245[i]; - bool _t247; - _t247 = String_Eq(_t246, key); - if (!_t247) goto endif68; + const char** _t240; + _t240 = self->objKeys; + const char* _t241; + _t241 = _t240[i]; + bool _t242; + _t242 = String_Eq(_t241, key); + if (!_t242) goto endif64; { - JsonValue* _t248; - _t248 = self->objValues; - _t248[i] = val; + JsonValue* _t243; + _t243 = self->objValues; + _t243[i] = val; return; } - endif68:; - _t249 = i + 1; - i = _t249; + endif64:; + _t244 = i + 1; + i = _t244; } - goto while64; - wend66:; - unsigned int _t250; - _t250 = self->objLen; - unsigned int _t251; - _t251 = self->objCap; - _t252 = (_t250 >= _t251); - if (!_t252) goto endif70; + goto while61; + wend62:; + unsigned int _t245; + _t245 = self->objLen; + unsigned int _t246; + _t246 = self->objCap; + _t247 = (_t245 >= _t246); + if (!_t247) goto endif66; { unsigned int objNewCap; - unsigned int _t253; - _t253 = self->objCap; - objNewCap = _t253; - _t254 = (objNewCap == 0); - if (!_t254) goto else71; + unsigned int _t248; + _t248 = self->objCap; + objNewCap = _t248; + _t249 = (objNewCap == 0); + if (!_t249) goto else67; { self->objCap = 4; /* sizeof(const char*) */ - _t256 = 4 * sizeof(const char*); - void* _t257; - _t257 = Alloc(_t256); - _t258 = (const char**)_t257; - self->objKeys = _t258; + _t250 = 4 * sizeof(const char*); + void* _t251; + _t251 = Alloc(_t250); + _t252 = (const char**)_t251; + self->objKeys = _t252; /* sizeof(JsonValue) */ - _t260 = 4 * sizeof(JsonValue); - void* _t261; - _t261 = Alloc(_t260); - _t262 = (JsonValue*)_t261; - self->objValues = _t262; + _t253 = 4 * sizeof(JsonValue); + void* _t254; + _t254 = Alloc(_t253); + _t255 = (JsonValue*)_t254; + self->objValues = _t255; } - goto endif72; - else71:; + goto endif68; + else67:; { unsigned int doubleCap; - _t263 = objNewCap * 2; - doubleCap = _t263; + _t256 = objNewCap * 2; + doubleCap = _t256; self->objCap = doubleCap; - const char** _t264; - _t264 = self->objKeys; - _t265 = (void*)_t264; + const char** _t257; + _t257 = self->objKeys; + _t258 = (void*)_t257; /* sizeof(const char*) */ - _t267 = doubleCap * sizeof(const char*); - void* _t268; - _t268 = Realloc(_t265, _t267); - _t269 = (const char**)_t268; - self->objKeys = _t269; - JsonValue* _t270; - _t270 = self->objValues; - _t271 = (void*)_t270; + _t259 = doubleCap * sizeof(const char*); + void* _t260; + _t260 = Realloc(_t258, _t259); + _t261 = (const char**)_t260; + self->objKeys = _t261; + JsonValue* _t262; + _t262 = self->objValues; + _t263 = (void*)_t262; /* sizeof(JsonValue) */ - _t273 = doubleCap * sizeof(JsonValue); - void* _t274; - _t274 = Realloc(_t271, _t273); - _t275 = (JsonValue*)_t274; - self->objValues = _t275; + _t264 = doubleCap * sizeof(JsonValue); + void* _t265; + _t265 = Realloc(_t263, _t264); + _t266 = (JsonValue*)_t265; + self->objValues = _t266; } - endif72:; + endif68:; } - endif70:; - const char** _t276; - _t276 = self->objKeys; - unsigned int _t277; - _t277 = self->objLen; - _t276[_t277] = key; - JsonValue* _t278; - _t278 = self->objValues; - unsigned int _t279; - _t279 = self->objLen; - _t278[_t279] = val; - unsigned int _t280; - _t280 = self->objLen; - _t281 = _t280 + 1; - self->objLen = _t281; + endif66:; + const char** _t267; + _t267 = self->objKeys; + unsigned int _t268; + _t268 = self->objLen; + _t267[_t268] = key; + JsonValue* _t269; + _t269 = self->objValues; + unsigned int _t270; + _t270 = self->objLen; + _t269[_t270] = val; + unsigned int _t271; + _t271 = self->objLen; + _t272 = _t271 + 1; + self->objLen = _t272; } bool Json_IsNull(JsonValue v) { - int _t283; - int _t282; - _t282 = v.tag; - _t283 = (_t282 == JsonTagNull); - return _t283; + int _t274; + int _t273; + _t273 = v.tag; + _t274 = (_t273 == JsonTagNull); + return _t274; } bool Json_AsBool(JsonValue v) { - int _t285; - int _t284; - _t284 = v.tag; - _t285 = (_t284 == JsonTagBool); - if (!_t285) goto endif74; + int _t276; + int _t275; + _t275 = v.tag; + _t276 = (_t275 == JsonTagBool); + if (!_t276) goto endif70; { - bool _t286; - _t286 = v.boolVal; - return _t286; + bool _t277; + _t277 = v.boolVal; + return _t277; } - endif74:; + endif70:; return 0; } double Json_AsNumber(JsonValue v) { - int _t288; - int _t287; - _t287 = v.tag; - _t288 = (_t287 == JsonTagNumber); - if (!_t288) goto endif76; + int _t279; + int _t278; + _t278 = v.tag; + _t279 = (_t278 == JsonTagNumber); + if (!_t279) goto endif72; { - double _t289; - _t289 = v.numVal; - return _t289; + double _t280; + _t280 = v.numVal; + return _t280; } - endif76:; + endif72:; return 0.0; } const char* Json_AsString(JsonValue v) { - int _t291; - int _t290; - _t290 = v.tag; - _t291 = (_t290 == JsonTagString); - if (!_t291) goto endif78; + int _t282; + int _t281; + _t281 = v.tag; + _t282 = (_t281 == JsonTagString); + if (!_t282) goto endif74; { - const char* _t292; - _t292 = v.strVal; - return _t292; + const char* _t283; + _t283 = v.strVal; + return _t283; } - endif78:; + endif74:; return ""; } int JsonParser_Peek(JsonParser* p) { - int _t295; - int _t299; - unsigned int _t293; - _t293 = p->pos; - unsigned int _t294; - _t294 = p->len; - _t295 = (_t293 >= _t294); - if (!_t295) goto endif80; + int _t286; + int _t290; + unsigned int _t284; + _t284 = p->pos; + unsigned int _t285; + _t285 = p->len; + _t286 = (_t284 >= _t285); + if (!_t286) goto endif76; { return 0; } - endif80:; - const char* _t296; - _t296 = p->src; - unsigned int _t297; - _t297 = p->pos; - int _t298; - _t298 = _t296[_t297]; - _t299 = (int)_t298; - return _t299; + endif76:; + const char* _t287; + _t287 = p->src; + unsigned int _t288; + _t288 = p->pos; + int _t289; + _t289 = _t287[_t288]; + _t290 = (int)_t289; + return _t290; } void JsonParser_Advance(JsonParser* p) { - int _t302; - int _t304; - unsigned int _t300; - _t300 = p->pos; - unsigned int _t301; - _t301 = p->len; - _t302 = (_t300 < _t301); - if (!_t302) goto endif82; + int _t293; + int _t295; + unsigned int _t291; + _t291 = p->pos; + unsigned int _t292; + _t292 = p->len; + _t293 = (_t291 < _t292); + if (!_t293) goto endif78; { - unsigned int _t303; - _t303 = p->pos; - _t304 = _t303 + 1; - p->pos = _t304; + unsigned int _t294; + _t294 = p->pos; + _t295 = _t294 + 1; + p->pos = _t295; } - endif82:; + endif78:; } void JsonParser_SkipWhitespace(JsonParser* p) { - int _t306; - int _t307; - int _t309; - int _t311; - while83:; - if (!1) goto wend85; + int _t297; + int _t298; + int _t300; + int _t302; + while79:; + if (!1) goto wend80; { int c; - int _t305; - _t305 = JsonParser_Peek(p); - c = _t305; + int _t296; + _t296 = JsonParser_Peek(p); + c = _t296; bool __or_tmp_1; bool __or_tmp_2; bool __or_tmp_3; - _t306 = (c == 32); - if (!_t306) goto else86; + _t297 = (c == 32); + if (!_t297) goto else81; *(bool*)&__or_tmp_3 = 1; - goto endif87; - else86:; - _t307 = (c == 9); - *(bool*)&__or_tmp_3 = _t307; - endif87:; - bool _t308; - _t308 = *(bool*)&__or_tmp_3; - if (!_t308) goto else88; + goto endif82; + else81:; + _t298 = (c == 9); + *(bool*)&__or_tmp_3 = _t298; + endif82:; + bool _t299; + _t299 = *(bool*)&__or_tmp_3; + if (!_t299) goto else83; *(bool*)&__or_tmp_2 = 1; - goto endif89; - else88:; - _t309 = (c == 10); - *(bool*)&__or_tmp_2 = _t309; - endif89:; - bool _t310; - _t310 = *(bool*)&__or_tmp_2; - if (!_t310) goto else90; + goto endif84; + else83:; + _t300 = (c == 10); + *(bool*)&__or_tmp_2 = _t300; + endif84:; + bool _t301; + _t301 = *(bool*)&__or_tmp_2; + if (!_t301) goto else85; *(bool*)&__or_tmp_1 = 1; - goto endif91; - else90:; - _t311 = (c == 13); - *(bool*)&__or_tmp_1 = _t311; - endif91:; - bool _t312; - _t312 = *(bool*)&__or_tmp_1; - if (!_t312) goto else92; + goto endif86; + else85:; + _t302 = (c == 13); + *(bool*)&__or_tmp_1 = _t302; + endif86:; + bool _t303; + _t303 = *(bool*)&__or_tmp_1; + if (!_t303) goto else87; { JsonParser_Advance(p); } - goto endif93; - else92:; + goto endif88; + else87:; { return; } - endif93:; + endif88:; } - goto while83; - wend85:; + goto while79; + wend80:; } bool JsonParser_Match(JsonParser* p, const char* expected) { + int _t306; + int _t308; + int _t309; + int _t312; int _t315; - int _t317; + int _t316; int _t318; - int _t321; - int _t324; - int _t325; - int _t327; unsigned int elen; - unsigned int _t313; - _t313 = String_Len(expected); - elen = _t313; - unsigned int _t314; - _t314 = p->pos; - _t315 = _t314 + elen; - unsigned int _t316; - _t316 = p->len; - _t317 = (_t315 > _t316); - if (!_t317) goto endif95; + unsigned int _t304; + _t304 = String_Len(expected); + elen = _t304; + unsigned int _t305; + _t305 = p->pos; + _t306 = _t305 + elen; + unsigned int _t307; + _t307 = p->len; + _t308 = (_t306 > _t307); + if (!_t308) goto endif90; { return 0; } - endif95:; + endif90:; unsigned int i; i = 0; - while96:; - _t318 = (i < elen); - if (!_t318) goto wend98; + while91:; + _t309 = (i < elen); + if (!_t309) goto wend92; { - const char* _t319; - _t319 = p->src; - unsigned int _t320; - _t320 = p->pos; - _t321 = _t320 + i; - int _t322; - _t322 = _t319[_t321]; - int _t323; - _t323 = expected[i]; - _t324 = (_t322 != _t323); - if (!_t324) goto endif100; + const char* _t310; + _t310 = p->src; + unsigned int _t311; + _t311 = p->pos; + _t312 = _t311 + i; + int _t313; + _t313 = _t310[_t312]; + int _t314; + _t314 = expected[i]; + _t315 = (_t313 != _t314); + if (!_t315) goto endif94; { return 0; } - endif100:; - _t325 = i + 1; - i = _t325; + endif94:; + _t316 = i + 1; + i = _t316; } - goto while96; - wend98:; - unsigned int _t326; - _t326 = p->pos; - _t327 = _t326 + elen; - p->pos = _t327; + goto while91; + wend92:; + unsigned int _t317; + _t317 = p->pos; + _t318 = _t317 + elen; + p->pos = _t318; return 1; } const char* JsonParser_ParseString(JsonParser* p) { - int _t329; - int _t332; + int _t320; + int _t323; + int _t324; + int _t326; + int _t328; + void* _t329; + int _t330; + void* _t331; + char _t332; int _t333; - int _t335; - int _t337; - void* _t338; + void* _t334; + char _t335; + int _t336; + void* _t337; + char _t338; int _t339; void* _t340; char _t341; @@ -2022,234 +2030,262 @@ const char* JsonParser_ParseString(JsonParser* p) { int _t348; void* _t349; char _t350; - int _t351; - void* _t352; - char _t353; - int _t354; + void* _t351; + char _t352; + void* _t353; + char _t354; void* _t355; char _t356; - int _t357; - void* _t358; - char _t359; + int _t358; + void* _t359; void* _t360; - char _t361; void* _t362; - char _t363; - void* _t364; - char _t365; - int _t367; - void* _t368; - void* _t369; - void* _t371; - int _t328; - _t328 = JsonParser_Peek(p); - _t329 = (_t328 != 34); - if (!_t329) goto endif102; + int _t319; + _t319 = JsonParser_Peek(p); + _t320 = (_t319 != 34); + if (!_t320) goto endif96; { p->error = "Expected string"; return ""; } - endif102:; + endif96:; JsonParser_Advance(p); StringBuilder sb; - StringBuilder _t330; - _t330 = StringBuilder_New(); - sb = _t330; - while103:; - if (!1) goto wend105; + StringBuilder _t321; + _t321 = StringBuilder_New(); + sb = _t321; + while97:; + if (!1) goto wend98; { int c; - int _t331; - _t331 = JsonParser_Peek(p); - c = _t331; + int _t322; + _t322 = JsonParser_Peek(p); + c = _t322; bool __or_tmp_4; - _t332 = (c == 0); - if (!_t332) goto else106; + _t323 = (c == 0); + if (!_t323) goto else99; *(bool*)&__or_tmp_4 = 1; - goto endif107; - else106:; - _t333 = (c == 34); - *(bool*)&__or_tmp_4 = _t333; - endif107:; - bool _t334; - _t334 = *(bool*)&__or_tmp_4; - if (!_t334) goto endif109; + goto endif100; + else99:; + _t324 = (c == 34); + *(bool*)&__or_tmp_4 = _t324; + endif100:; + bool _t325; + _t325 = *(bool*)&__or_tmp_4; + if (!_t325) goto endif102; { - goto wend105; + goto wend98; } - endif109:; - _t335 = (c == 92); - if (!_t335) goto else110; + endif102:; + _t326 = (c == 92); + if (!_t326) goto else103; { JsonParser_Advance(p); int esc; - int _t336; - _t336 = JsonParser_Peek(p); - esc = _t336; - _t337 = (esc == 0); - if (!_t337) goto endif113; + int _t327; + _t327 = JsonParser_Peek(p); + esc = _t327; + _t328 = (esc == 0); + if (!_t328) goto endif106; { p->error = "Unterminated string escape"; - _t338 = &sb; - StringBuilder_Free(_t338); + _t329 = &sb; + StringBuilder_Free(_t329); return ""; } - endif113:; - _t339 = (esc == 110); - if (!_t339) goto else114; + endif106:; + _t330 = (esc == 110); + if (!_t330) goto else107; + { + _t331 = &sb; + _t332 = (char)10; + StringBuilder_AppendChar(_t331, _t332); + } + goto endif108; + else107:; + _t333 = (esc == 116); + if (!_t333) goto else109; + { + _t334 = &sb; + _t335 = (char)9; + StringBuilder_AppendChar(_t334, _t335); + } + goto endif110; + else109:; + _t336 = (esc == 114); + if (!_t336) goto else111; + { + _t337 = &sb; + _t338 = (char)13; + StringBuilder_AppendChar(_t337, _t338); + } + goto endif112; + else111:; + _t339 = (esc == 98); + if (!_t339) goto else113; { _t340 = &sb; - _t341 = (char)10; + _t341 = (char)8; StringBuilder_AppendChar(_t340, _t341); } - goto endif115; - else114:; - _t342 = (esc == 116); - if (!_t342) goto else116; + goto endif114; + else113:; + _t342 = (esc == 102); + if (!_t342) goto else115; { _t343 = &sb; - _t344 = (char)9; + _t344 = (char)12; StringBuilder_AppendChar(_t343, _t344); } - goto endif117; - else116:; - _t345 = (esc == 114); - if (!_t345) goto else118; + goto endif116; + else115:; + _t345 = (esc == 34); + if (!_t345) goto else117; { _t346 = &sb; - _t347 = (char)13; + _t347 = (char)34; StringBuilder_AppendChar(_t346, _t347); } - goto endif119; - else118:; - _t348 = (esc == 98); - if (!_t348) goto else120; + goto endif118; + else117:; + _t348 = (esc == 92); + if (!_t348) goto else119; { _t349 = &sb; - _t350 = (char)8; + _t350 = (char)92; StringBuilder_AppendChar(_t349, _t350); } - goto endif121; - else120:; - _t351 = (esc == 102); - if (!_t351) goto else122; + goto endif120; + else119:; { - _t352 = &sb; - _t353 = (char)12; - StringBuilder_AppendChar(_t352, _t353); + _t351 = &sb; + _t352 = (char)92; + StringBuilder_AppendChar(_t351, _t352); + _t353 = &sb; + _t354 = (char)esc; + StringBuilder_AppendChar(_t353, _t354); } - goto endif123; - else122:; - _t354 = (esc == 34); - if (!_t354) goto else124; + endif120:; + endif118:; + endif116:; + endif114:; + endif112:; + endif110:; + endif108:; + JsonParser_Advance(p); + } + goto endif104; + else103:; { _t355 = &sb; - _t356 = (char)34; + _t356 = (char)c; StringBuilder_AppendChar(_t355, _t356); - } - goto endif125; - else124:; - _t357 = (esc == 92); - if (!_t357) goto else126; - { - _t358 = &sb; - _t359 = (char)92; - StringBuilder_AppendChar(_t358, _t359); - } - goto endif127; - else126:; - { - _t360 = &sb; - _t361 = (char)92; - StringBuilder_AppendChar(_t360, _t361); - _t362 = &sb; - _t363 = (char)esc; - StringBuilder_AppendChar(_t362, _t363); - } - endif127:; - endif125:; - endif123:; - endif121:; - endif119:; - endif117:; - endif115:; JsonParser_Advance(p); } - goto endif111; - else110:; - { - _t364 = &sb; - _t365 = (char)c; - StringBuilder_AppendChar(_t364, _t365); - JsonParser_Advance(p); + endif104:; } - endif111:; - } - goto while103; - wend105:; - int _t366; - _t366 = JsonParser_Peek(p); - _t367 = (_t366 != 34); - if (!_t367) goto endif129; + goto while97; + wend98:; + int _t357; + _t357 = JsonParser_Peek(p); + _t358 = (_t357 != 34); + if (!_t358) goto endif122; { p->error = "Unterminated string"; - _t368 = &sb; - StringBuilder_Free(_t368); + _t359 = &sb; + StringBuilder_Free(_t359); return ""; } - endif129:; + endif122:; JsonParser_Advance(p); const char* result; - _t369 = &sb; - const char* _t370; - _t370 = StringBuilder_Build(_t369); - result = _t370; - _t371 = &sb; - StringBuilder_Free(_t371); + _t360 = &sb; + const char* _t361; + _t361 = StringBuilder_Build(_t360); + result = _t361; + _t362 = &sb; + StringBuilder_Free(_t362); return result; } JsonValue JsonParser_ParseNumber(JsonParser* p) { - int _t374; - int _t376; - int _t377; - int _t380; - int _t382; - int _t383; - int _t387; - unsigned int start; - unsigned int _t372; - _t372 = p->pos; - start = _t372; - int c0; + int _t365; + int _t367; + int _t368; + int _t371; int _t373; - _t373 = JsonParser_Peek(p); - c0 = _t373; - _t374 = (c0 == 45); - if (!_t374) goto endif131; + int _t374; + int _t378; + unsigned int start; + unsigned int _t363; + _t363 = p->pos; + start = _t363; + int c0; + int _t364; + _t364 = JsonParser_Peek(p); + c0 = _t364; + _t365 = (c0 == 45); + if (!_t365) goto endif124; { JsonParser_Advance(p); } - endif131:; - while132:; + endif124:; + while125:; + if (!1) goto wend126; + { + int c; + int _t366; + _t366 = JsonParser_Peek(p); + c = _t366; + bool __and_tmp_5; + _t367 = (c >= 48); + if (!_t367) goto else127; + _t368 = (c <= 57); + *(bool*)&__and_tmp_5 = _t368; + goto endif128; + else127:; + *(bool*)&__and_tmp_5 = 0; + endif128:; + bool _t369; + _t369 = *(bool*)&__and_tmp_5; + if (!_t369) goto else129; + { + JsonParser_Advance(p); + } + goto endif130; + else129:; + { + goto wend126; + } + endif130:; + } + goto while125; + wend126:; + int _t370; + _t370 = JsonParser_Peek(p); + _t371 = (_t370 == 46); + if (!_t371) goto endif132; + { + JsonParser_Advance(p); + while133:; if (!1) goto wend134; { int c; - int _t375; - _t375 = JsonParser_Peek(p); - c = _t375; - bool __and_tmp_5; - _t376 = (c >= 48); - if (!_t376) goto else135; - _t377 = (c <= 57); - *(bool*)&__and_tmp_5 = _t377; + int _t372; + _t372 = JsonParser_Peek(p); + c = _t372; + bool __and_tmp_6; + _t373 = (c >= 48); + if (!_t373) goto else135; + _t374 = (c <= 57); + *(bool*)&__and_tmp_6 = _t374; goto endif136; else135:; - *(bool*)&__and_tmp_5 = 0; + *(bool*)&__and_tmp_6 = 0; endif136:; - bool _t378; - _t378 = *(bool*)&__and_tmp_5; - if (!_t378) goto else137; + bool _t375; + _t375 = *(bool*)&__and_tmp_6; + if (!_t375) goto else137; { JsonParser_Advance(p); } @@ -2260,1098 +2296,1061 @@ JsonValue JsonParser_ParseNumber(JsonParser* p) { } endif138:; } - goto while132; + goto while133; wend134:; - int _t379; - _t379 = JsonParser_Peek(p); - _t380 = (_t379 == 46); - if (!_t380) goto endif140; - { - JsonParser_Advance(p); - while141:; - if (!1) goto wend143; - { - int c; - int _t381; - _t381 = JsonParser_Peek(p); - c = _t381; - bool __and_tmp_6; - _t382 = (c >= 48); - if (!_t382) goto else144; - _t383 = (c <= 57); - *(bool*)&__and_tmp_6 = _t383; - goto endif145; - else144:; - *(bool*)&__and_tmp_6 = 0; - endif145:; - bool _t384; - _t384 = *(bool*)&__and_tmp_6; - if (!_t384) goto else146; - { - JsonParser_Advance(p); } - goto endif147; - else146:; - { - goto wend143; - } - endif147:; - } - goto while141; - wend143:; - } - endif140:; + endif132:; const char* numStr; - const char* _t385; - _t385 = p->src; - unsigned int _t386; - _t386 = p->pos; - _t387 = _t386 - start; - const char* _t388; - _t388 = String_Slice(_t385, start, _t387); - numStr = _t388; + const char* _t376; + _t376 = p->src; + unsigned int _t377; + _t377 = p->pos; + _t378 = _t377 - start; + const char* _t379; + _t379 = String_Slice(_t376, start, _t378); + numStr = _t379; double n; - double _t389; - _t389 = String_ToFloat(numStr); - n = _t389; - JsonValue _t390; - _t390 = Json_Number(n); - return _t390; + double _t380; + _t380 = String_ToFloat(numStr); + n = _t380; + JsonValue _t381; + _t381 = Json_Number(n); + return _t381; } JsonValue JsonParser_ParseArray(JsonParser* p) { - int _t393; - int _t396; - void* _t398; - int _t400; - int _t401; + int _t384; + int _t387; + void* _t389; + int _t391; + int _t392; JsonParser_Advance(p); JsonValue arr; - JsonValue _t391; - _t391 = Json_Array(); - arr = _t391; + JsonValue _t382; + _t382 = Json_Array(); + arr = _t382; JsonParser_SkipWhitespace(p); - int _t392; - _t392 = JsonParser_Peek(p); - _t393 = (_t392 == 93); - if (!_t393) goto endif149; + int _t383; + _t383 = JsonParser_Peek(p); + _t384 = (_t383 == 93); + if (!_t384) goto endif140; { JsonParser_Advance(p); return arr; } - endif149:; - while150:; - if (!1) goto wend152; + endif140:; + while141:; + if (!1) goto wend142; { JsonParser_SkipWhitespace(p); JsonValue val; - JsonValue _t394; - _t394 = JsonParser_ParseValue(p); - val = _t394; - const char* _t395; - _t395 = p->error; - _t396 = (_t395 != ""); - if (!_t396) goto endif154; + JsonValue _t385; + _t385 = JsonParser_ParseValue(p); + val = _t385; + const char* _t386; + _t386 = p->error; + _t387 = (_t386 != ""); + if (!_t387) goto endif144; { - JsonValue _t397; - _t397 = Json_Null(); - return _t397; + JsonValue _t388; + _t388 = Json_Null(); + return _t388; } - endif154:; - _t398 = &arr; - Json_ArrayPush(_t398, val); + endif144:; + _t389 = &arr; + Json_ArrayPush(_t389, val); JsonParser_SkipWhitespace(p); int c; - int _t399; - _t399 = JsonParser_Peek(p); - c = _t399; - _t400 = (c == 93); - if (!_t400) goto endif156; + int _t390; + _t390 = JsonParser_Peek(p); + c = _t390; + _t391 = (c == 93); + if (!_t391) goto endif146; { JsonParser_Advance(p); return arr; } - endif156:; - _t401 = (c == 44); - if (!_t401) goto else157; + endif146:; + _t392 = (c == 44); + if (!_t392) goto else147; { JsonParser_Advance(p); } - goto endif158; - else157:; + goto endif148; + else147:; { p->error = "Expected ',' or ']' in array"; - JsonValue _t402; - _t402 = Json_Null(); - return _t402; + JsonValue _t393; + _t393 = Json_Null(); + return _t393; } - endif158:; + endif148:; } - goto while150; - wend152:; + goto while141; + wend142:; } JsonValue JsonParser_ParseObject(JsonParser* p) { - int _t405; - int _t408; + int _t396; + int _t399; + int _t402; + int _t406; + void* _t408; + int _t410; int _t411; - int _t415; - void* _t417; - int _t419; - int _t420; JsonParser_Advance(p); JsonValue obj; - JsonValue _t403; - _t403 = Json_Object(); - obj = _t403; + JsonValue _t394; + _t394 = Json_Object(); + obj = _t394; JsonParser_SkipWhitespace(p); - int _t404; - _t404 = JsonParser_Peek(p); - _t405 = (_t404 == 125); - if (!_t405) goto endif160; + int _t395; + _t395 = JsonParser_Peek(p); + _t396 = (_t395 == 125); + if (!_t396) goto endif150; + { + JsonParser_Advance(p); + return obj; + } + endif150:; + while151:; + if (!1) goto wend152; + { + JsonParser_SkipWhitespace(p); + const char* key; + const char* _t397; + _t397 = JsonParser_ParseString(p); + key = _t397; + const char* _t398; + _t398 = p->error; + _t399 = (_t398 != ""); + if (!_t399) goto endif154; + { + JsonValue _t400; + _t400 = Json_Null(); + return _t400; + } + endif154:; + JsonParser_SkipWhitespace(p); + int _t401; + _t401 = JsonParser_Peek(p); + _t402 = (_t401 != 58); + if (!_t402) goto endif156; + { + p->error = "Expected ':' after object key"; + JsonValue _t403; + _t403 = Json_Null(); + return _t403; + } + endif156:; + JsonParser_Advance(p); + JsonParser_SkipWhitespace(p); + JsonValue val; + JsonValue _t404; + _t404 = JsonParser_ParseValue(p); + val = _t404; + const char* _t405; + _t405 = p->error; + _t406 = (_t405 != ""); + if (!_t406) goto endif158; + { + JsonValue _t407; + _t407 = Json_Null(); + return _t407; + } + endif158:; + _t408 = &obj; + Json_ObjectSet(_t408, key, val); + JsonParser_SkipWhitespace(p); + int c; + int _t409; + _t409 = JsonParser_Peek(p); + c = _t409; + _t410 = (c == 125); + if (!_t410) goto endif160; { JsonParser_Advance(p); return obj; } endif160:; - while161:; - if (!1) goto wend163; + _t411 = (c == 44); + if (!_t411) goto else161; { - JsonParser_SkipWhitespace(p); - const char* key; - const char* _t406; - _t406 = JsonParser_ParseString(p); - key = _t406; - const char* _t407; - _t407 = p->error; - _t408 = (_t407 != ""); - if (!_t408) goto endif165; - { - JsonValue _t409; - _t409 = Json_Null(); - return _t409; + JsonParser_Advance(p); } - endif165:; - JsonParser_SkipWhitespace(p); - int _t410; - _t410 = JsonParser_Peek(p); - _t411 = (_t410 != 58); - if (!_t411) goto endif167; + goto endif162; + else161:; { - p->error = "Expected ':' after object key"; + p->error = "Expected ',' or '}' in object"; JsonValue _t412; _t412 = Json_Null(); return _t412; } - endif167:; - JsonParser_Advance(p); - JsonParser_SkipWhitespace(p); - JsonValue val; - JsonValue _t413; - _t413 = JsonParser_ParseValue(p); - val = _t413; - const char* _t414; - _t414 = p->error; - _t415 = (_t414 != ""); - if (!_t415) goto endif169; - { - JsonValue _t416; - _t416 = Json_Null(); - return _t416; + endif162:; } - endif169:; - _t417 = &obj; - Json_ObjectSet(_t417, key, val); - JsonParser_SkipWhitespace(p); - int c; - int _t418; - _t418 = JsonParser_Peek(p); - c = _t418; - _t419 = (c == 125); - if (!_t419) goto endif171; - { - JsonParser_Advance(p); - return obj; - } - endif171:; - _t420 = (c == 44); - if (!_t420) goto else172; - { - JsonParser_Advance(p); - } - goto endif173; - else172:; - { - p->error = "Expected ',' or '}' in object"; - JsonValue _t421; - _t421 = Json_Null(); - return _t421; - } - endif173:; - } - goto while161; - wend163:; + goto while151; + wend152:; } JsonValue JsonParser_ParseValue(JsonParser* p) { + int _t414; + int _t416; + int _t419; + int _t421; int _t423; - int _t425; - int _t428; - int _t430; - int _t432; + int _t427; + int _t431; + int _t435; int _t436; - int _t440; - int _t444; - int _t445; - int _t447; + int _t438; JsonParser_SkipWhitespace(p); int c; - int _t422; - _t422 = JsonParser_Peek(p); - c = _t422; - _t423 = (c == 0); - if (!_t423) goto endif175; + int _t413; + _t413 = JsonParser_Peek(p); + c = _t413; + _t414 = (c == 0); + if (!_t414) goto endif164; { p->error = "Unexpected end of input"; - JsonValue _t424; - _t424 = Json_Null(); - return _t424; + JsonValue _t415; + _t415 = Json_Null(); + return _t415; } - endif175:; - _t425 = (c == 34); - if (!_t425) goto endif177; + endif164:; + _t416 = (c == 34); + if (!_t416) goto endif166; { - const char* _t426; - _t426 = JsonParser_ParseString(p); - JsonValue _t427; - _t427 = Json_String(_t426); - return _t427; + const char* _t417; + _t417 = JsonParser_ParseString(p); + JsonValue _t418; + _t418 = Json_String(_t417); + return _t418; } - endif177:; - _t428 = (c == 123); - if (!_t428) goto endif179; + endif166:; + _t419 = (c == 123); + if (!_t419) goto endif168; + { + JsonValue _t420; + _t420 = JsonParser_ParseObject(p); + return _t420; + } + endif168:; + _t421 = (c == 91); + if (!_t421) goto endif170; + { + JsonValue _t422; + _t422 = JsonParser_ParseArray(p); + return _t422; + } + endif170:; + _t423 = (c == 116); + if (!_t423) goto endif172; + { + bool _t424; + _t424 = JsonParser_Match(p, "true"); + if (!_t424) goto endif174; + { + JsonValue _t425; + _t425 = Json_Bool(1); + return _t425; + } + endif174:; + p->error = "Expected 'true'"; + JsonValue _t426; + _t426 = Json_Null(); + return _t426; + } + endif172:; + _t427 = (c == 102); + if (!_t427) goto endif176; + { + bool _t428; + _t428 = JsonParser_Match(p, "false"); + if (!_t428) goto endif178; { JsonValue _t429; - _t429 = JsonParser_ParseObject(p); + _t429 = Json_Bool(0); return _t429; } - endif179:; - _t430 = (c == 91); - if (!_t430) goto endif181; - { - JsonValue _t431; - _t431 = JsonParser_ParseArray(p); - return _t431; + endif178:; + p->error = "Expected 'false'"; + JsonValue _t430; + _t430 = Json_Null(); + return _t430; } - endif181:; - _t432 = (c == 116); - if (!_t432) goto endif183; + endif176:; + _t431 = (c == 110); + if (!_t431) goto endif180; { - bool _t433; - _t433 = JsonParser_Match(p, "true"); - if (!_t433) goto endif185; + bool _t432; + _t432 = JsonParser_Match(p, "null"); + if (!_t432) goto endif182; { + JsonValue _t433; + _t433 = Json_Null(); + return _t433; + } + endif182:; + p->error = "Expected 'null'"; JsonValue _t434; - _t434 = Json_Bool(1); + _t434 = Json_Null(); return _t434; } - endif185:; - p->error = "Expected 'true'"; - JsonValue _t435; - _t435 = Json_Null(); - return _t435; - } - endif183:; - _t436 = (c == 102); - if (!_t436) goto endif187; - { - bool _t437; - _t437 = JsonParser_Match(p, "false"); - if (!_t437) goto endif189; - { - JsonValue _t438; - _t438 = Json_Bool(0); - return _t438; - } - endif189:; - p->error = "Expected 'false'"; - JsonValue _t439; - _t439 = Json_Null(); - return _t439; - } - endif187:; - _t440 = (c == 110); - if (!_t440) goto endif191; - { - bool _t441; - _t441 = JsonParser_Match(p, "null"); - if (!_t441) goto endif193; - { - JsonValue _t442; - _t442 = Json_Null(); - return _t442; - } - endif193:; - p->error = "Expected 'null'"; - JsonValue _t443; - _t443 = Json_Null(); - return _t443; - } - endif191:; + endif180:; bool __or_tmp_7; bool __and_tmp_8; - _t444 = (c >= 48); - if (!_t444) goto else194; - _t445 = (c <= 57); - *(bool*)&__and_tmp_8 = _t445; - goto endif195; - else194:; + _t435 = (c >= 48); + if (!_t435) goto else183; + _t436 = (c <= 57); + *(bool*)&__and_tmp_8 = _t436; + goto endif184; + else183:; *(bool*)&__and_tmp_8 = 0; - endif195:; - bool _t446; - _t446 = *(bool*)&__and_tmp_8; - if (!_t446) goto else196; + endif184:; + bool _t437; + _t437 = *(bool*)&__and_tmp_8; + if (!_t437) goto else185; *(bool*)&__or_tmp_7 = 1; - goto endif197; - else196:; - _t447 = (c == 45); - *(bool*)&__or_tmp_7 = _t447; - endif197:; - bool _t448; - _t448 = *(bool*)&__or_tmp_7; - if (!_t448) goto endif199; + goto endif186; + else185:; + _t438 = (c == 45); + *(bool*)&__or_tmp_7 = _t438; + endif186:; + bool _t439; + _t439 = *(bool*)&__or_tmp_7; + if (!_t439) goto endif188; { - JsonValue _t449; - _t449 = JsonParser_ParseNumber(p); - return _t449; + JsonValue _t440; + _t440 = JsonParser_ParseNumber(p); + return _t440; } - endif199:; + endif188:; p->error = "Unexpected character"; - JsonValue _t450; - _t450 = Json_Null(); - return _t450; + JsonValue _t441; + _t441 = Json_Null(); + return _t441; } JsonValue Json_Parse(const char* s) { - JsonParser _t452; - void* _t453; - void* _t455; - int _t457; - int _t460; + JsonParser _t443; + void* _t444; + void* _t446; + int _t448; + int _t451; JsonParser p; - unsigned int _t451; - _t451 = String_Len(s); - _t452 = (JsonParser){.src = s, .pos = 0, .len = _t451, .error = ""}; - p = _t452; + unsigned int _t442; + _t442 = String_Len(s); + _t443 = (JsonParser){.src = s, .pos = 0, .len = _t442, .error = ""}; + p = _t443; JsonValue result; - _t453 = &p; - JsonValue _t454; - _t454 = JsonParser_ParseValue(_t453); - result = _t454; - _t455 = &p; - JsonParser_SkipWhitespace(_t455); + _t444 = &p; + JsonValue _t445; + _t445 = JsonParser_ParseValue(_t444); + result = _t445; + _t446 = &p; + JsonParser_SkipWhitespace(_t446); bool __and_tmp_9; - const char* _t456; - _t456 = p.error; - _t457 = (_t456 == ""); - if (!_t457) goto else200; - unsigned int _t458; - _t458 = p.pos; - unsigned int _t459; - _t459 = p.len; - _t460 = (_t458 != _t459); - *(bool*)&__and_tmp_9 = _t460; - goto endif201; - else200:; + const char* _t447; + _t447 = p.error; + _t448 = (_t447 == ""); + if (!_t448) goto else189; + unsigned int _t449; + _t449 = p.pos; + unsigned int _t450; + _t450 = p.len; + _t451 = (_t449 != _t450); + *(bool*)&__and_tmp_9 = _t451; + goto endif190; + else189:; *(bool*)&__and_tmp_9 = 0; - endif201:; - bool _t461; - _t461 = *(bool*)&__and_tmp_9; - if (!_t461) goto endif203; + endif190:; + bool _t452; + _t452 = *(bool*)&__and_tmp_9; + if (!_t452) goto endif192; { p.error = "Trailing data after JSON value"; - JsonValue _t462; - _t462 = Json_Null(); - return _t462; + JsonValue _t453; + _t453 = Json_Null(); + return _t453; } - endif203:; + endif192:; return result; } void Json_StringifyImpl(StringBuilder* sb, JsonValue v) { - int _t464; - int _t466; - int _t469; + int _t455; + int _t457; + int _t460; + int _t463; + char _t464; + char _t466; + int _t468; + char _t469; + int _t471; int _t472; char _t473; - char _t475; - int _t477; - char _t478; - int _t480; - int _t481; - char _t482; - int _t485; - char _t486; - int _t488; + int _t476; + char _t477; + int _t479; + char _t480; + int _t482; + int _t483; + char _t484; + char _t485; + char _t488; char _t489; - int _t491; int _t492; char _t493; - char _t494; - char _t497; - char _t498; - int _t501; - char _t502; - int _t463; - _t463 = v.tag; - _t464 = (_t463 == JsonTagNull); - if (!_t464) goto endif205; + int _t454; + _t454 = v.tag; + _t455 = (_t454 == JsonTagNull); + if (!_t455) goto endif194; { StringBuilder_Append(sb, "null"); return; } - endif205:; - int _t465; - _t465 = v.tag; - _t466 = (_t465 == JsonTagBool); - if (!_t466) goto endif207; + endif194:; + int _t456; + _t456 = v.tag; + _t457 = (_t456 == JsonTagBool); + if (!_t457) goto endif196; { - bool _t467; - _t467 = v.boolVal; - if (!_t467) goto else208; + bool _t458; + _t458 = v.boolVal; + if (!_t458) goto else197; { StringBuilder_Append(sb, "true"); } - goto endif209; - else208:; + goto endif198; + else197:; { StringBuilder_Append(sb, "false"); } - endif209:; + endif198:; return; } - endif207:; - int _t468; - _t468 = v.tag; - _t469 = (_t468 == JsonTagNumber); - if (!_t469) goto endif211; + endif196:; + int _t459; + _t459 = v.tag; + _t460 = (_t459 == JsonTagNumber); + if (!_t460) goto endif200; { - double _t470; - _t470 = v.numVal; - StringBuilder_AppendFloat(sb, _t470); + double _t461; + _t461 = v.numVal; + StringBuilder_AppendFloat(sb, _t461); return; } - endif211:; - int _t471; - _t471 = v.tag; - _t472 = (_t471 == JsonTagString); - if (!_t472) goto endif213; + endif200:; + int _t462; + _t462 = v.tag; + _t463 = (_t462 == JsonTagString); + if (!_t463) goto endif202; { - _t473 = (char)34; + _t464 = (char)34; + StringBuilder_AppendChar(sb, _t464); + const char* _t465; + _t465 = v.strVal; + StringBuilder_Append(sb, _t465); + _t466 = (char)34; + StringBuilder_AppendChar(sb, _t466); + return; + } + endif202:; + int _t467; + _t467 = v.tag; + _t468 = (_t467 == JsonTagArray); + if (!_t468) goto endif204; + { + _t469 = (char)91; + StringBuilder_AppendChar(sb, _t469); + unsigned int i; + i = 0; + while205:; + unsigned int _t470; + _t470 = v.arrLen; + _t471 = (i < _t470); + if (!_t471) goto wend206; + { + _t472 = (i > 0); + if (!_t472) goto endif208; + { + _t473 = (char)44; StringBuilder_AppendChar(sb, _t473); - const char* _t474; - _t474 = v.strVal; - StringBuilder_Append(sb, _t474); - _t475 = (char)34; - StringBuilder_AppendChar(sb, _t475); + } + endif208:; + JsonValue* _t474; + _t474 = v.arrData; + JsonValue _t475; + _t475 = _t474[i]; + Json_StringifyImpl(sb, _t475); + _t476 = i + 1; + i = _t476; + } + goto while205; + wend206:; + _t477 = (char)93; + StringBuilder_AppendChar(sb, _t477); return; } - endif213:; - int _t476; - _t476 = v.tag; - _t477 = (_t476 == JsonTagArray); - if (!_t477) goto endif215; + endif204:; + int _t478; + _t478 = v.tag; + _t479 = (_t478 == JsonTagObject); + if (!_t479) goto endif210; { - _t478 = (char)91; - StringBuilder_AppendChar(sb, _t478); + _t480 = (char)123; + StringBuilder_AppendChar(sb, _t480); unsigned int i; i = 0; - while216:; - unsigned int _t479; - _t479 = v.arrLen; - _t480 = (i < _t479); - if (!_t480) goto wend218; + while211:; + unsigned int _t481; + _t481 = v.objLen; + _t482 = (i < _t481); + if (!_t482) goto wend212; { - _t481 = (i > 0); - if (!_t481) goto endif220; + _t483 = (i > 0); + if (!_t483) goto endif214; { - _t482 = (char)44; - StringBuilder_AppendChar(sb, _t482); + _t484 = (char)44; + StringBuilder_AppendChar(sb, _t484); } - endif220:; - JsonValue* _t483; - _t483 = v.arrData; - JsonValue _t484; - _t484 = _t483[i]; - Json_StringifyImpl(sb, _t484); - _t485 = i + 1; - i = _t485; - } - goto while216; - wend218:; - _t486 = (char)93; - StringBuilder_AppendChar(sb, _t486); - return; - } - endif215:; - int _t487; - _t487 = v.tag; - _t488 = (_t487 == JsonTagObject); - if (!_t488) goto endif222; - { - _t489 = (char)123; + endif214:; + _t485 = (char)34; + StringBuilder_AppendChar(sb, _t485); + const char** _t486; + _t486 = v.objKeys; + const char* _t487; + _t487 = _t486[i]; + StringBuilder_Append(sb, _t487); + _t488 = (char)34; + StringBuilder_AppendChar(sb, _t488); + _t489 = (char)58; StringBuilder_AppendChar(sb, _t489); - unsigned int i; - i = 0; - while223:; - unsigned int _t490; - _t490 = v.objLen; - _t491 = (i < _t490); - if (!_t491) goto wend225; - { - _t492 = (i > 0); - if (!_t492) goto endif227; - { - _t493 = (char)44; + JsonValue* _t490; + _t490 = v.objValues; + JsonValue _t491; + _t491 = _t490[i]; + Json_StringifyImpl(sb, _t491); + _t492 = i + 1; + i = _t492; + } + goto while211; + wend212:; + _t493 = (char)125; StringBuilder_AppendChar(sb, _t493); - } - endif227:; - _t494 = (char)34; - StringBuilder_AppendChar(sb, _t494); - const char** _t495; - _t495 = v.objKeys; - const char* _t496; - _t496 = _t495[i]; - StringBuilder_Append(sb, _t496); - _t497 = (char)34; - StringBuilder_AppendChar(sb, _t497); - _t498 = (char)58; - StringBuilder_AppendChar(sb, _t498); - JsonValue* _t499; - _t499 = v.objValues; - JsonValue _t500; - _t500 = _t499[i]; - Json_StringifyImpl(sb, _t500); - _t501 = i + 1; - i = _t501; - } - goto while223; - wend225:; - _t502 = (char)125; - StringBuilder_AppendChar(sb, _t502); return; } - endif222:; + endif210:; } const char* Json_Stringify(JsonValue v) { - void* _t504; - void* _t505; + void* _t495; + void* _t496; StringBuilder sb; - StringBuilder _t503; - _t503 = StringBuilder_New(); - sb = _t503; - _t504 = &sb; - Json_StringifyImpl(_t504, v); - _t505 = &sb; - const char* _t506; - _t506 = StringBuilder_Build(_t505); - return _t506; + StringBuilder _t494; + _t494 = StringBuilder_New(); + sb = _t494; + _t495 = &sb; + Json_StringifyImpl(_t495, v); + _t496 = &sb; + const char* _t497; + _t497 = StringBuilder_Build(_t496); + return _t497; } unsigned int String_Len(const char* s) { - unsigned int _t507; - _t507 = bux_strlen(s); - return _t507; + unsigned int _t498; + _t498 = bux_strlen(s); + return _t498; } bool String_IsNull(const char* s) { - int _t509; - int _t508; - _t508 = bux_str_is_null(s); - _t509 = (_t508 != 0); - return _t509; + int _t500; + int _t499; + _t499 = bux_str_is_null(s); + _t500 = (_t499 != 0); + return _t500; } bool String_Eq(const char* a, const char* b) { - int _t511; - int _t510; - _t510 = bux_strcmp(a, b); - _t511 = (_t510 == 0); - return _t511; + int _t502; + int _t501; + _t501 = bux_strcmp(a, b); + _t502 = (_t501 == 0); + return _t502; } const char* String_Concat(const char* a, const char* b) { - int _t514; - int _t515; - char* _t517; + int _t505; + int _t506; + char* _t508; unsigned int len_a; - unsigned int _t512; - _t512 = bux_strlen(a); - len_a = _t512; + unsigned int _t503; + _t503 = bux_strlen(a); + len_a = _t503; unsigned int len_b; - unsigned int _t513; - _t513 = bux_strlen(b); - len_b = _t513; + unsigned int _t504; + _t504 = bux_strlen(b); + len_b = _t504; unsigned int total; - _t514 = len_a + len_b; - _t515 = _t514 + 1; - total = _t515; + _t505 = len_a + len_b; + _t506 = _t505 + 1; + total = _t506; char* buf; - void* _t516; - _t516 = bux_alloc(total); - _t517 = (char*)_t516; - buf = _t517; + void* _t507; + _t507 = bux_alloc(total); + _t508 = (char*)_t507; + buf = _t508; bux_strcpy(buf, a); bux_strcat(buf, b); return buf; } const char* String_Copy(const char* s) { - int _t519; - char* _t521; + int _t510; + char* _t512; unsigned int len; - unsigned int _t518; - _t518 = bux_strlen(s); - len = _t518; + unsigned int _t509; + _t509 = bux_strlen(s); + len = _t509; char* buf; - _t519 = len + 1; - void* _t520; - _t520 = bux_alloc(_t519); - _t521 = (char*)_t520; - buf = _t521; + _t510 = len + 1; + void* _t511; + _t511 = bux_alloc(_t510); + _t512 = (char*)_t511; + buf = _t512; bux_strcpy(buf, s); return buf; } bool String_StartsWith(const char* s, const char* prefix) { - int _t524; - int _t526; + int _t515; + int _t517; unsigned int s_len; - unsigned int _t522; - _t522 = bux_strlen(s); - s_len = _t522; + unsigned int _t513; + _t513 = bux_strlen(s); + s_len = _t513; unsigned int p_len; - unsigned int _t523; - _t523 = bux_strlen(prefix); - p_len = _t523; - _t524 = (p_len > s_len); - if (!_t524) goto endif229; + unsigned int _t514; + _t514 = bux_strlen(prefix); + p_len = _t514; + _t515 = (p_len > s_len); + if (!_t515) goto endif216; { return 0; } - endif229:; + endif216:; int r; - int _t525; - _t525 = bux_strncmp(s, prefix, p_len); - r = _t525; - _t526 = (r == 0); - return _t526; + int _t516; + _t516 = bux_strncmp(s, prefix, p_len); + r = _t516; + _t517 = (r == 0); + return _t517; } bool String_EndsWith(const char* s, const char* suffix) { - int _t529; - int _t530; - int _t533; + int _t520; + int _t521; + int _t524; unsigned int s_len; - unsigned int _t527; - _t527 = bux_strlen(s); - s_len = _t527; + unsigned int _t518; + _t518 = bux_strlen(s); + s_len = _t518; unsigned int suf_len; - unsigned int _t528; - _t528 = bux_strlen(suffix); - suf_len = _t528; - _t529 = (suf_len > s_len); - if (!_t529) goto endif231; + unsigned int _t519; + _t519 = bux_strlen(suffix); + suf_len = _t519; + _t520 = (suf_len > s_len); + if (!_t520) goto endif218; { return 0; } - endif231:; + endif218:; unsigned int start; - _t530 = s_len - suf_len; - start = _t530; + _t521 = s_len - suf_len; + start = _t521; const char* tail; - const char* _t531; - _t531 = bux_str_slice(s, start, suf_len); - tail = _t531; + const char* _t522; + _t522 = bux_str_slice(s, start, suf_len); + tail = _t522; bool eq; - int _t532; - _t532 = bux_strcmp(tail, suffix); - _t533 = (_t532 == 0); - eq = _t533; + int _t523; + _t523 = bux_strcmp(tail, suffix); + _t524 = (_t523 == 0); + eq = _t524; return eq; } bool String_Contains(const char* s, const char* substr) { - int _t535; + int _t526; int r; - int _t534; - _t534 = bux_str_contains(s, substr); - r = _t534; - _t535 = (r != 0); - return _t535; + int _t525; + _t525 = bux_str_contains(s, substr); + r = _t525; + _t526 = (r != 0); + return _t526; } const char* String_Slice(const char* s, unsigned int start, unsigned int len) { - const char* _t536; - _t536 = bux_str_slice(s, start, len); - return _t536; + const char* _t527; + _t527 = bux_str_slice(s, start, len); + return _t527; } const char* String_Trim(const char* s) { - const char* _t537; - _t537 = bux_str_trim(s); - return _t537; + const char* _t528; + _t528 = bux_str_trim(s); + return _t528; } const char* String_TrimLeft(const char* s) { - const char* _t538; - _t538 = bux_str_trim_left(s); - return _t538; + const char* _t529; + _t529 = bux_str_trim_left(s); + return _t529; } const char* String_TrimRight(const char* s) { - const char* _t539; - _t539 = bux_str_trim_right(s); - return _t539; + const char* _t530; + _t530 = bux_str_trim_right(s); + return _t530; } const char* String_FromInt(int64_t n) { - const char* _t540; - _t540 = bux_int_to_str(n); - return _t540; + const char* _t531; + _t531 = bux_int_to_str(n); + return _t531; } int64_t String_ToInt(const char* s) { - int64_t _t541; - _t541 = bux_str_to_int(s); - return _t541; + int64_t _t532; + _t532 = bux_str_to_int(s); + return _t532; } StringBuilder StringBuilder_New(void) { - StringBuilder _t543; - void* _t542; - _t542 = bux_sb_new(64); - _t543 = (StringBuilder){.handle = _t542}; - return _t543; + StringBuilder _t534; + void* _t533; + _t533 = bux_sb_new(64); + _t534 = (StringBuilder){.handle = _t533}; + return _t534; } StringBuilder StringBuilder_NewCap(unsigned int cap) { - StringBuilder _t545; - void* _t544; - _t544 = bux_sb_new(cap); - _t545 = (StringBuilder){.handle = _t544}; - return _t545; + StringBuilder _t536; + void* _t535; + _t535 = bux_sb_new(cap); + _t536 = (StringBuilder){.handle = _t535}; + return _t536; } void StringBuilder_Append(StringBuilder* sb, const char* s) { - void* _t546; - _t546 = sb->handle; - bux_sb_append(_t546, s); + void* _t537; + _t537 = sb->handle; + bux_sb_append(_t537, s); } void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) { - void* _t547; - _t547 = sb->handle; - bux_sb_append_int(_t547, n); + void* _t538; + _t538 = sb->handle; + bux_sb_append_int(_t538, n); } void StringBuilder_AppendFloat(StringBuilder* sb, double f) { - void* _t548; - _t548 = sb->handle; - bux_sb_append_float(_t548, f); + void* _t539; + _t539 = sb->handle; + bux_sb_append_float(_t539, f); } void StringBuilder_AppendChar(StringBuilder* sb, char c) { - void* _t549; - _t549 = sb->handle; - bux_sb_append_char(_t549, c); + void* _t540; + _t540 = sb->handle; + bux_sb_append_char(_t540, c); } const char* StringBuilder_Build(StringBuilder* sb) { - void* _t550; - _t550 = sb->handle; - const char* _t551; - _t551 = bux_sb_build(_t550); - return _t551; + void* _t541; + _t541 = sb->handle; + const char* _t542; + _t542 = bux_sb_build(_t541); + return _t542; } void StringBuilder_Free(StringBuilder* sb) { - void* _t552; - _t552 = sb->handle; - bux_sb_free(_t552); + void* _t543; + _t543 = sb->handle; + bux_sb_free(_t543); } unsigned int String_SplitCount(const char* s, const char* delim) { - unsigned int _t553; - _t553 = bux_str_split_count(s, delim); - return _t553; + unsigned int _t544; + _t544 = bux_str_split_count(s, delim); + return _t544; } const char* String_SplitPart(const char* s, const char* delim, unsigned int index) { - const char* _t554; - _t554 = bux_str_split_part(s, delim, index); - return _t554; + const char* _t545; + _t545 = bux_str_split_part(s, delim, index); + return _t545; } const char* String_Join2(const char* a, const char* b, const char* sep) { - const char* _t555; - _t555 = bux_str_join2(a, b, sep); - return _t555; + const char* _t546; + _t546 = bux_str_join2(a, b, sep); + return _t546; } const char* String_Chars(const char* s, unsigned int index) { - const char* _t556; - _t556 = bux_str_slice(s, index, 1); - return _t556; + const char* _t547; + _t547 = bux_str_slice(s, index, 1); + return _t547; } const char* String_Find(const char* haystack, const char* needle) { - const char* _t557; - _t557 = bux_strstr(haystack, needle); - return _t557; + const char* _t548; + _t548 = bux_strstr(haystack, needle); + return _t548; } unsigned int String_Offset(const char* pos, const char* base) { - unsigned int _t558; - _t558 = bux_str_offset(pos, base); - return _t558; + unsigned int _t549; + _t549 = bux_str_offset(pos, base); + return _t549; } const char* String_Replace(const char* s, const char* old, const char* new) { - int _t564; - int _t566; - int _t567; + int _t555; + int _t557; + int _t558; const char* pos; - const char* _t559; - _t559 = bux_strstr(s, old); - pos = _t559; - bool _t560; - _t560 = String_IsNull(pos); - if (!_t560) goto endif233; + const char* _t550; + _t550 = bux_strstr(s, old); + pos = _t550; + bool _t551; + _t551 = String_IsNull(pos); + if (!_t551) goto endif220; { return s; } - endif233:; + endif220:; unsigned int oldLen; - unsigned int _t561; - _t561 = bux_strlen(old); - oldLen = _t561; + unsigned int _t552; + _t552 = bux_strlen(old); + oldLen = _t552; unsigned int prefixLen; - unsigned int _t562; - _t562 = String_Offset(pos, s); - prefixLen = _t562; + unsigned int _t553; + _t553 = String_Offset(pos, s); + prefixLen = _t553; const char* prefix; - const char* _t563; - _t563 = bux_str_slice(s, 0, prefixLen); - prefix = _t563; + const char* _t554; + _t554 = bux_str_slice(s, 0, prefixLen); + prefix = _t554; const char* suffix; - _t564 = prefixLen + oldLen; - unsigned int _t565; - _t565 = bux_strlen(s); - _t566 = _t565 - prefixLen; - _t567 = _t566 - oldLen; - const char* _t568; - _t568 = bux_str_slice(s, _t564, _t567); - suffix = _t568; + _t555 = prefixLen + oldLen; + unsigned int _t556; + _t556 = bux_strlen(s); + _t557 = _t556 - prefixLen; + _t558 = _t557 - oldLen; + const char* _t559; + _t559 = bux_str_slice(s, _t555, _t558); + suffix = _t559; const char* temp; - const char* _t569; - _t569 = String_Concat(prefix, new); - temp = _t569; + const char* _t560; + _t560 = String_Concat(prefix, new); + temp = _t560; const char* result; - const char* _t570; - _t570 = String_Concat(temp, suffix); - result = _t570; + const char* _t561; + _t561 = String_Concat(temp, suffix); + result = _t561; return result; } double String_ToFloat(const char* s) { - double _t571; - _t571 = bux_str_to_float(s); - return _t571; + double _t562; + _t562 = bux_str_to_float(s); + return _t562; } const char* String_FromBool(bool b) { - if (!b) goto endif235; + if (!b) goto endif222; { return "true"; } - endif235:; + endif222:; return "false"; } const char* String_FromFloat(double f) { - const char* _t572; - _t572 = bux_float_to_string(f); - return _t572; + const char* _t563; + _t563 = bux_float_to_string(f); + return _t563; } const char* String_Format1(const char* pattern, const char* a0) { - const char* _t573; - _t573 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); - return _t573; + const char* _t564; + _t564 = bux_str_format(pattern, a0, "", "", "", "", "", "", ""); + return _t564; } const char* String_Format2(const char* pattern, const char* a0, const char* a1) { - const char* _t574; - _t574 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); - return _t574; + const char* _t565; + _t565 = bux_str_format(pattern, a0, a1, "", "", "", "", "", ""); + return _t565; } const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) { - const char* _t575; - _t575 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); - return _t575; + const char* _t566; + _t566 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", ""); + return _t566; } void Channel_SendInt(Channel_int* ch, int value) { - void* _t577; - void* _t578; - void* _t576; - _t576 = ch->handle; - _t577 = &value; - _t578 = (void*)_t577; - bux_channel_send(_t576, _t578); + void* _t568; + void* _t569; + void* _t567; + _t567 = ch->handle; + _t568 = &value; + _t569 = (void*)_t568; + bux_channel_send(_t567, _t569); } int Channel_RecvInt(Channel_int* ch) { - void* _t580; - void* _t581; + void* _t571; + void* _t572; int result; result = 0; - void* _t579; - _t579 = ch->handle; - _t580 = &result; - _t581 = (void*)_t580; - bux_channel_recv(_t579, _t581); + void* _t570; + _t570 = ch->handle; + _t571 = &result; + _t572 = (void*)_t571; + bux_channel_recv(_t570, _t572); return result; } void Channel_SendFloat64(Channel_float64* ch, double value) { - void* _t583; - void* _t584; - void* _t582; - _t582 = ch->handle; - _t583 = &value; - _t584 = (void*)_t583; - bux_channel_send(_t582, _t584); + void* _t574; + void* _t575; + void* _t573; + _t573 = ch->handle; + _t574 = &value; + _t575 = (void*)_t574; + bux_channel_send(_t573, _t575); } double Channel_RecvFloat64(Channel_float64* ch) { - void* _t586; - void* _t587; + void* _t577; + void* _t578; double result; result = 0.0; - void* _t585; - _t585 = ch->handle; - _t586 = &result; - _t587 = (void*)_t586; - bux_channel_recv(_t585, _t587); + void* _t576; + _t576 = ch->handle; + _t577 = &result; + _t578 = (void*)_t577; + bux_channel_recv(_t576, _t578); return result; } const char* Hash_Sha1(const char* data) { - int _t589; + int _t580; int len; - unsigned int _t588; - _t588 = String_Len(data); - _t589 = (int)_t588; - len = _t589; + unsigned int _t579; + _t579 = String_Len(data); + _t580 = (int)_t579; + len = _t580; void* buf; - void* _t590; - _t590 = Alloc(20); - buf = _t590; + void* _t581; + _t581 = Alloc(20); + buf = _t581; bux_sha1(data, len, buf); const char* result; - const char* _t591; - _t591 = bux_bytes_to_hex(buf, 20); - result = _t591; + const char* _t582; + _t582 = bux_bytes_to_hex(buf, 20); + result = _t582; Free(buf); return result; } const char* Hash_Sha256(const char* data) { - int _t593; + int _t584; int len; - unsigned int _t592; - _t592 = String_Len(data); - _t593 = (int)_t592; - len = _t593; + unsigned int _t583; + _t583 = String_Len(data); + _t584 = (int)_t583; + len = _t584; void* buf; - void* _t594; - _t594 = Alloc(32); - buf = _t594; + void* _t585; + _t585 = Alloc(32); + buf = _t585; bux_sha256(data, len, buf); const char* result; - const char* _t595; - _t595 = bux_bytes_to_hex(buf, 32); - result = _t595; + const char* _t586; + _t586 = bux_bytes_to_hex(buf, 32); + result = _t586; Free(buf); return result; } const char* Hash_Sha384(const char* data) { - int _t597; + int _t588; int len; - unsigned int _t596; - _t596 = String_Len(data); - _t597 = (int)_t596; - len = _t597; + unsigned int _t587; + _t587 = String_Len(data); + _t588 = (int)_t587; + len = _t588; void* buf; - void* _t598; - _t598 = Alloc(48); - buf = _t598; + void* _t589; + _t589 = Alloc(48); + buf = _t589; bux_sha384(data, len, buf); const char* result; - const char* _t599; - _t599 = bux_bytes_to_hex(buf, 48); - result = _t599; + const char* _t590; + _t590 = bux_bytes_to_hex(buf, 48); + result = _t590; Free(buf); return result; } const char* Hash_Sha512(const char* data) { - int _t601; + int _t592; int len; - unsigned int _t600; - _t600 = String_Len(data); - _t601 = (int)_t600; - len = _t601; + unsigned int _t591; + _t591 = String_Len(data); + _t592 = (int)_t591; + len = _t592; void* buf; - void* _t602; - _t602 = Alloc(64); - buf = _t602; + void* _t593; + _t593 = Alloc(64); + buf = _t593; bux_sha512(data, len, buf); const char* result; - const char* _t603; - _t603 = bux_bytes_to_hex(buf, 64); - result = _t603; + const char* _t594; + _t594 = bux_bytes_to_hex(buf, 64); + result = _t594; Free(buf); return result; } void Hash_Sha256Raw(const char* data, void* out) { - int _t605; - unsigned int _t604; - _t604 = String_Len(data); - _t605 = (int)_t604; - bux_sha256(data, _t605, out); + int _t596; + unsigned int _t595; + _t595 = String_Len(data); + _t596 = (int)_t595; + bux_sha256(data, _t596, out); } void Hash_Sha384Raw(const char* data, void* out) { - int _t607; - unsigned int _t606; - _t606 = String_Len(data); - _t607 = (int)_t606; - bux_sha384(data, _t607, out); + int _t598; + unsigned int _t597; + _t597 = String_Len(data); + _t598 = (int)_t597; + bux_sha384(data, _t598, out); } void Hash_Sha512Raw(const char* data, void* out) { - int _t609; - unsigned int _t608; - _t608 = String_Len(data); - _t609 = (int)_t608; - bux_sha512(data, _t609, out); + int _t600; + unsigned int _t599; + _t599 = String_Len(data); + _t600 = (int)_t599; + bux_sha512(data, _t600, out); } int Hash_Sha1Size(void) { @@ -3371,1500 +3370,1500 @@ int Hash_Sha512Size(void) { } const char* Base64_Encode(const char* s) { - int _t611; - unsigned int _t610; - _t610 = String_Len(s); - _t611 = (int)_t610; - const char* _t612; - _t612 = bux_base64_encode(s, _t611); - return _t612; + int _t602; + unsigned int _t601; + _t601 = String_Len(s); + _t602 = (int)_t601; + const char* _t603; + _t603 = bux_base64_encode(s, _t602); + return _t603; } const char* Base64_Decode(const char* s) { - int _t614; - void* _t615; + int _t605; + void* _t606; int outlen; outlen = 0; - unsigned int _t613; - _t613 = String_Len(s); - _t614 = (int)_t613; - _t615 = &outlen; - const char* _t616; - _t616 = bux_base64_decode(s, _t614, _t615); - return _t616; + unsigned int _t604; + _t604 = String_Len(s); + _t605 = (int)_t604; + _t606 = &outlen; + const char* _t607; + _t607 = bux_base64_decode(s, _t605, _t606); + return _t607; } const char* Base64URL_Encode(const char* s) { - int _t618; - unsigned int _t617; - _t617 = String_Len(s); - _t618 = (int)_t617; - const char* _t619; - _t619 = bux_base64url_encode(s, _t618); - return _t619; + int _t609; + unsigned int _t608; + _t608 = String_Len(s); + _t609 = (int)_t608; + const char* _t610; + _t610 = bux_base64url_encode(s, _t609); + return _t610; } const char* Base64URL_Decode(const char* s) { - int _t621; - void* _t622; + int _t612; + void* _t613; int outlen; outlen = 0; - unsigned int _t620; - _t620 = String_Len(s); - _t621 = (int)_t620; - _t622 = &outlen; - const char* _t623; - _t623 = bux_base64url_decode(s, _t621, _t622); - return _t623; + unsigned int _t611; + _t611 = String_Len(s); + _t612 = (int)_t611; + _t613 = &outlen; + const char* _t614; + _t614 = bux_base64url_decode(s, _t612, _t613); + return _t614; } const char* Hmac_Sha256(const char* key, const char* message) { - int _t625; - int _t627; + int _t616; + int _t618; int kl; - unsigned int _t624; - _t624 = String_Len(key); - _t625 = (int)_t624; - kl = _t625; + unsigned int _t615; + _t615 = String_Len(key); + _t616 = (int)_t615; + kl = _t616; int ml; - unsigned int _t626; - _t626 = String_Len(message); - _t627 = (int)_t626; - ml = _t627; + unsigned int _t617; + _t617 = String_Len(message); + _t618 = (int)_t617; + ml = _t618; void* buf; - void* _t628; - _t628 = Alloc(32); - buf = _t628; + void* _t619; + _t619 = Alloc(32); + buf = _t619; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - const char* _t629; - _t629 = bux_bytes_to_hex(buf, 32); - result = _t629; + const char* _t620; + _t620 = bux_bytes_to_hex(buf, 32); + result = _t620; Free(buf); return result; } void Hmac_Sha256Raw(const char* key, const char* message, void* out) { - int _t631; - int _t633; - unsigned int _t630; - _t630 = String_Len(key); - _t631 = (int)_t630; - unsigned int _t632; - _t632 = String_Len(message); - _t633 = (int)_t632; - bux_hmac_sha256(key, _t631, message, _t633, out); + int _t622; + int _t624; + unsigned int _t621; + _t621 = String_Len(key); + _t622 = (int)_t621; + unsigned int _t623; + _t623 = String_Len(message); + _t624 = (int)_t623; + bux_hmac_sha256(key, _t622, message, _t624, out); } const char* Hmac_Sha256Base64(const char* key, const char* message) { - int _t635; - int _t637; - const char* _t639; + int _t626; + int _t628; + const char* _t630; int kl; - unsigned int _t634; - _t634 = String_Len(key); - _t635 = (int)_t634; - kl = _t635; + unsigned int _t625; + _t625 = String_Len(key); + _t626 = (int)_t625; + kl = _t626; int ml; - unsigned int _t636; - _t636 = String_Len(message); - _t637 = (int)_t636; - ml = _t637; + unsigned int _t627; + _t627 = String_Len(message); + _t628 = (int)_t627; + ml = _t628; void* buf; - void* _t638; - _t638 = Alloc(32); - buf = _t638; + void* _t629; + _t629 = Alloc(32); + buf = _t629; bux_hmac_sha256(key, kl, message, ml, buf); const char* result; - _t639 = (const char*)buf; - const char* _t640; - _t640 = bux_base64_encode(_t639, 32); - result = _t640; + _t630 = (const char*)buf; + const char* _t631; + _t631 = bux_base64_encode(_t630, 32); + result = _t631; Free(buf); return result; } const char* Hmac_Sha384(const char* key, const char* message) { - int _t642; - int _t644; + int _t633; + int _t635; int kl; - unsigned int _t641; - _t641 = String_Len(key); - _t642 = (int)_t641; - kl = _t642; + unsigned int _t632; + _t632 = String_Len(key); + _t633 = (int)_t632; + kl = _t633; int ml; - unsigned int _t643; - _t643 = String_Len(message); - _t644 = (int)_t643; - ml = _t644; + unsigned int _t634; + _t634 = String_Len(message); + _t635 = (int)_t634; + ml = _t635; void* buf; - void* _t645; - _t645 = Alloc(48); - buf = _t645; + void* _t636; + _t636 = Alloc(48); + buf = _t636; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - const char* _t646; - _t646 = bux_bytes_to_hex(buf, 48); - result = _t646; + const char* _t637; + _t637 = bux_bytes_to_hex(buf, 48); + result = _t637; Free(buf); return result; } void Hmac_Sha384Raw(const char* key, const char* message, void* out) { - int _t648; - int _t650; - unsigned int _t647; - _t647 = String_Len(key); - _t648 = (int)_t647; - unsigned int _t649; - _t649 = String_Len(message); - _t650 = (int)_t649; - bux_hmac_sha384(key, _t648, message, _t650, out); + int _t639; + int _t641; + unsigned int _t638; + _t638 = String_Len(key); + _t639 = (int)_t638; + unsigned int _t640; + _t640 = String_Len(message); + _t641 = (int)_t640; + bux_hmac_sha384(key, _t639, message, _t641, out); } const char* Hmac_Sha384Base64(const char* key, const char* message) { - int _t652; - int _t654; - const char* _t656; + int _t643; + int _t645; + const char* _t647; int kl; - unsigned int _t651; - _t651 = String_Len(key); - _t652 = (int)_t651; - kl = _t652; + unsigned int _t642; + _t642 = String_Len(key); + _t643 = (int)_t642; + kl = _t643; int ml; - unsigned int _t653; - _t653 = String_Len(message); - _t654 = (int)_t653; - ml = _t654; + unsigned int _t644; + _t644 = String_Len(message); + _t645 = (int)_t644; + ml = _t645; void* buf; - void* _t655; - _t655 = Alloc(48); - buf = _t655; + void* _t646; + _t646 = Alloc(48); + buf = _t646; bux_hmac_sha384(key, kl, message, ml, buf); const char* result; - _t656 = (const char*)buf; - const char* _t657; - _t657 = bux_base64_encode(_t656, 48); - result = _t657; + _t647 = (const char*)buf; + const char* _t648; + _t648 = bux_base64_encode(_t647, 48); + result = _t648; Free(buf); return result; } const char* Hmac_Sha512(const char* key, const char* message) { - int _t659; - int _t661; + int _t650; + int _t652; int kl; - unsigned int _t658; - _t658 = String_Len(key); - _t659 = (int)_t658; - kl = _t659; + unsigned int _t649; + _t649 = String_Len(key); + _t650 = (int)_t649; + kl = _t650; int ml; - unsigned int _t660; - _t660 = String_Len(message); - _t661 = (int)_t660; - ml = _t661; + unsigned int _t651; + _t651 = String_Len(message); + _t652 = (int)_t651; + ml = _t652; void* buf; - void* _t662; - _t662 = Alloc(64); - buf = _t662; + void* _t653; + _t653 = Alloc(64); + buf = _t653; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - const char* _t663; - _t663 = bux_bytes_to_hex(buf, 64); - result = _t663; + const char* _t654; + _t654 = bux_bytes_to_hex(buf, 64); + result = _t654; Free(buf); return result; } void Hmac_Sha512Raw(const char* key, const char* message, void* out) { - int _t665; - int _t667; - unsigned int _t664; - _t664 = String_Len(key); - _t665 = (int)_t664; - unsigned int _t666; - _t666 = String_Len(message); - _t667 = (int)_t666; - bux_hmac_sha512(key, _t665, message, _t667, out); + int _t656; + int _t658; + unsigned int _t655; + _t655 = String_Len(key); + _t656 = (int)_t655; + unsigned int _t657; + _t657 = String_Len(message); + _t658 = (int)_t657; + bux_hmac_sha512(key, _t656, message, _t658, out); } const char* Hmac_Sha512Base64(const char* key, const char* message) { - int _t669; - int _t671; - const char* _t673; + int _t660; + int _t662; + const char* _t664; int kl; - unsigned int _t668; - _t668 = String_Len(key); - _t669 = (int)_t668; - kl = _t669; + unsigned int _t659; + _t659 = String_Len(key); + _t660 = (int)_t659; + kl = _t660; int ml; - unsigned int _t670; - _t670 = String_Len(message); - _t671 = (int)_t670; - ml = _t671; + unsigned int _t661; + _t661 = String_Len(message); + _t662 = (int)_t661; + ml = _t662; void* buf; - void* _t672; - _t672 = Alloc(64); - buf = _t672; + void* _t663; + _t663 = Alloc(64); + buf = _t663; bux_hmac_sha512(key, kl, message, ml, buf); const char* result; - _t673 = (const char*)buf; - const char* _t674; - _t674 = bux_base64_encode(_t673, 64); - result = _t674; + _t664 = (const char*)buf; + const char* _t665; + _t665 = bux_base64_encode(_t664, 64); + result = _t665; Free(buf); return result; } const char* Random_Bytes(int n) { - int _t675; - unsigned int _t676; - int _t679; - const char* _t680; - _t675 = (n <= 0); - if (!_t675) goto endif237; + int _t666; + unsigned int _t667; + int _t670; + const char* _t671; + _t666 = (n <= 0); + if (!_t666) goto endif224; { return ""; } - endif237:; + endif224:; void* buf; - _t676 = (unsigned int)n; - void* _t677; - _t677 = Alloc(_t676); - buf = _t677; - int _t678; - _t678 = bux_random_bytes(buf, n); - _t679 = (_t678 != 1); - if (!_t679) goto endif239; + _t667 = (unsigned int)n; + void* _t668; + _t668 = Alloc(_t667); + buf = _t668; + int _t669; + _t669 = bux_random_bytes(buf, n); + _t670 = (_t669 != 1); + if (!_t670) goto endif226; { Free(buf); return ""; } - endif239:; - _t680 = (const char*)buf; - return _t680; + endif226:; + _t671 = (const char*)buf; + return _t671; } const char* Random_Hex(int n) { - int _t681; - unsigned int _t682; - int _t685; - _t681 = (n <= 0); - if (!_t681) goto endif241; + int _t672; + unsigned int _t673; + int _t676; + _t672 = (n <= 0); + if (!_t672) goto endif228; { return ""; } - endif241:; + endif228:; void* buf; - _t682 = (unsigned int)n; - void* _t683; - _t683 = Alloc(_t682); - buf = _t683; - int _t684; - _t684 = bux_random_bytes(buf, n); - _t685 = (_t684 != 1); - if (!_t685) goto endif243; + _t673 = (unsigned int)n; + void* _t674; + _t674 = Alloc(_t673); + buf = _t674; + int _t675; + _t675 = bux_random_bytes(buf, n); + _t676 = (_t675 != 1); + if (!_t676) goto endif230; { Free(buf); return ""; } - endif243:; + endif230:; const char* result; - const char* _t686; - _t686 = bux_bytes_to_hex(buf, n); - result = _t686; + const char* _t677; + _t677 = bux_bytes_to_hex(buf, n); + result = _t677; Free(buf); return result; } const char* Random_Base64(int n) { - int _t687; - unsigned int _t688; - int _t691; - const char* _t692; - _t687 = (n <= 0); - if (!_t687) goto endif245; + int _t678; + unsigned int _t679; + int _t682; + const char* _t683; + _t678 = (n <= 0); + if (!_t678) goto endif232; { return ""; } - endif245:; + endif232:; void* buf; - _t688 = (unsigned int)n; - void* _t689; - _t689 = Alloc(_t688); - buf = _t689; - int _t690; - _t690 = bux_random_bytes(buf, n); - _t691 = (_t690 != 1); - if (!_t691) goto endif247; + _t679 = (unsigned int)n; + void* _t680; + _t680 = Alloc(_t679); + buf = _t680; + int _t681; + _t681 = bux_random_bytes(buf, n); + _t682 = (_t681 != 1); + if (!_t682) goto endif234; { Free(buf); return ""; } - endif247:; + endif234:; const char* result; - _t692 = (const char*)buf; - const char* _t693; - _t693 = bux_base64_encode(_t692, n); - result = _t693; + _t683 = (const char*)buf; + const char* _t684; + _t684 = bux_base64_encode(_t683, n); + result = _t684; Free(buf); return result; } unsigned int Random_Uint32(void) { - int _t696; - unsigned int* _t697; - unsigned int _t698; + int _t687; + unsigned int* _t688; + unsigned int _t689; void* buf; - void* _t694; - _t694 = Alloc(4); - buf = _t694; - int _t695; - _t695 = bux_random_bytes(buf, 4); - _t696 = (_t695 != 1); - if (!_t696) goto endif249; + void* _t685; + _t685 = Alloc(4); + buf = _t685; + int _t686; + _t686 = bux_random_bytes(buf, 4); + _t687 = (_t686 != 1); + if (!_t687) goto endif236; { Free(buf); return 0; } - endif249:; + endif236:; unsigned int* ptr; - _t697 = (unsigned int*)buf; - ptr = _t697; + _t688 = (unsigned int*)buf; + ptr = _t688; unsigned int val; - _t698 = *ptr; - val = _t698; + _t689 = *ptr; + val = _t689; Free(buf); return val; } const char* Aes_GenerateKey(void) { - unsigned int _t699; - int _t702; - const char* _t703; + unsigned int _t690; + int _t693; + const char* _t694; void* buf; - _t699 = (unsigned int)AES_KEY_SIZE; - void* _t700; - _t700 = Alloc(_t699); - buf = _t700; - int _t701; - _t701 = bux_random_bytes(buf, AES_KEY_SIZE); - _t702 = (_t701 != 1); - if (!_t702) goto endif251; + _t690 = (unsigned int)AES_KEY_SIZE; + void* _t691; + _t691 = Alloc(_t690); + buf = _t691; + int _t692; + _t692 = bux_random_bytes(buf, AES_KEY_SIZE); + _t693 = (_t692 != 1); + if (!_t693) goto endif238; { Free(buf); return ""; } - endif251:; - _t703 = (const char*)buf; - return _t703; + endif238:; + _t694 = (const char*)buf; + return _t694; } const char* Aes_GenerateIV(void) { - unsigned int _t704; - int _t707; - const char* _t708; + unsigned int _t695; + int _t698; + const char* _t699; void* buf; - _t704 = (unsigned int)AES_IV_SIZE; - void* _t705; - _t705 = Alloc(_t704); - buf = _t705; - int _t706; - _t706 = bux_random_bytes(buf, AES_IV_SIZE); - _t707 = (_t706 != 1); - if (!_t707) goto endif253; + _t695 = (unsigned int)AES_IV_SIZE; + void* _t696; + _t696 = Alloc(_t695); + buf = _t696; + int _t697; + _t697 = bux_random_bytes(buf, AES_IV_SIZE); + _t698 = (_t697 != 1); + if (!_t698) goto endif240; { Free(buf); return ""; } - endif253:; - _t708 = (const char*)buf; - return _t708; + endif240:; + _t699 = (const char*)buf; + return _t699; } const char* Aes_CbcEncrypt(const char* plain, const char* key, const char* iv) { - int _t710; - void* _t711; + int _t701; + void* _t702; int outlen; outlen = 0; - unsigned int _t709; - _t709 = String_Len(plain); - _t710 = (int)_t709; - _t711 = &outlen; - const char* _t712; - _t712 = bux_aes_256_cbc_encrypt(plain, _t710, key, iv, _t711); - return _t712; + unsigned int _t700; + _t700 = String_Len(plain); + _t701 = (int)_t700; + _t702 = &outlen; + const char* _t703; + _t703 = bux_aes_256_cbc_encrypt(plain, _t701, key, iv, _t702); + return _t703; } const char* Aes_CbcDecrypt(const char* cipher, const char* key, const char* iv) { - int _t714; - void* _t715; + int _t705; + void* _t706; int outlen; outlen = 0; - unsigned int _t713; - _t713 = String_Len(cipher); - _t714 = (int)_t713; - _t715 = &outlen; - const char* _t716; - _t716 = bux_aes_256_cbc_decrypt(cipher, _t714, key, iv, _t715); - return _t716; + unsigned int _t704; + _t704 = String_Len(cipher); + _t705 = (int)_t704; + _t706 = &outlen; + const char* _t707; + _t707 = bux_aes_256_cbc_decrypt(cipher, _t705, key, iv, _t706); + return _t707; } const char* Aes_GcmEncrypt(const char* plain, const char* key, const char* iv, void* tag) { - int _t718; - void* _t719; + int _t709; + void* _t710; int outlen; outlen = 0; - unsigned int _t717; - _t717 = String_Len(plain); - _t718 = (int)_t717; - _t719 = &outlen; - const char* _t720; - _t720 = bux_aes_256_gcm_encrypt(plain, _t718, key, iv, tag, _t719); - return _t720; + unsigned int _t708; + _t708 = String_Len(plain); + _t709 = (int)_t708; + _t710 = &outlen; + const char* _t711; + _t711 = bux_aes_256_gcm_encrypt(plain, _t709, key, iv, tag, _t710); + return _t711; } const char* Aes_GcmDecrypt(const char* cipher, const char* key, const char* iv, const char* tag) { - int _t722; - void* _t723; + int _t713; + void* _t714; int outlen; outlen = 0; - unsigned int _t721; - _t721 = String_Len(cipher); - _t722 = (int)_t721; - _t723 = &outlen; - const char* _t724; - _t724 = bux_aes_256_gcm_decrypt(cipher, _t722, key, iv, tag, _t723); - return _t724; + unsigned int _t712; + _t712 = String_Len(cipher); + _t713 = (int)_t712; + _t714 = &outlen; + const char* _t715; + _t715 = bux_aes_256_gcm_decrypt(cipher, _t713, key, iv, tag, _t714); + return _t715; } const char* Jwt_MakeHeader(JwtAlg alg) { - int _t725; - int _t726; - int _t727; - int _t728; - int _t729; - int _t730; - int _t731; - int _t732; - int _t733; - _t725 = (alg == JwtAlg_HS256); - if (!_t725) goto endif255; + int _t716; + int _t717; + int _t718; + int _t719; + int _t720; + int _t721; + int _t722; + int _t723; + int _t724; + _t716 = (alg == JwtAlg_HS256); + if (!_t716) goto endif242; { return "{\"alg\":\"HS256\",\"typ\":\"JWT\"}"; } - endif255:; - _t726 = (alg == JwtAlg_HS384); - if (!_t726) goto endif257; + endif242:; + _t717 = (alg == JwtAlg_HS384); + if (!_t717) goto endif244; { return "{\"alg\":\"HS384\",\"typ\":\"JWT\"}"; } - endif257:; - _t727 = (alg == JwtAlg_HS512); - if (!_t727) goto endif259; + endif244:; + _t718 = (alg == JwtAlg_HS512); + if (!_t718) goto endif246; { return "{\"alg\":\"HS512\",\"typ\":\"JWT\"}"; } - endif259:; - _t728 = (alg == JwtAlg_RS256); - if (!_t728) goto endif261; + endif246:; + _t719 = (alg == JwtAlg_RS256); + if (!_t719) goto endif248; { return "{\"alg\":\"RS256\",\"typ\":\"JWT\"}"; } - endif261:; - _t729 = (alg == JwtAlg_RS384); - if (!_t729) goto endif263; + endif248:; + _t720 = (alg == JwtAlg_RS384); + if (!_t720) goto endif250; { return "{\"alg\":\"RS384\",\"typ\":\"JWT\"}"; } - endif263:; - _t730 = (alg == JwtAlg_RS512); - if (!_t730) goto endif265; + endif250:; + _t721 = (alg == JwtAlg_RS512); + if (!_t721) goto endif252; { return "{\"alg\":\"RS512\",\"typ\":\"JWT\"}"; } - endif265:; - _t731 = (alg == JwtAlg_ES256); - if (!_t731) goto endif267; + endif252:; + _t722 = (alg == JwtAlg_ES256); + if (!_t722) goto endif254; { return "{\"alg\":\"ES256\",\"typ\":\"JWT\"}"; } - endif267:; - _t732 = (alg == JwtAlg_ES384); - if (!_t732) goto endif269; + endif254:; + _t723 = (alg == JwtAlg_ES384); + if (!_t723) goto endif256; { return "{\"alg\":\"ES384\",\"typ\":\"JWT\"}"; } - endif269:; - _t733 = (alg == JwtAlg_EdDSA); - if (!_t733) goto endif271; + endif256:; + _t724 = (alg == JwtAlg_EdDSA); + if (!_t724) goto endif258; { return "{\"alg\":\"EdDSA\",\"typ\":\"JWT\"}"; } - endif271:; + endif258:; return "{\"alg\":\"none\",\"typ\":\"JWT\"}"; } const char* Jwt_Sign(JwtAlg alg, const char* signingInput, const char* key) { - int _t734; - const char* _t736; - int _t738; - const char* _t740; + int _t725; + const char* _t727; + int _t729; + const char* _t731; + int _t733; + const char* _t735; + int _t737; + int _t740; int _t742; - const char* _t744; - int _t746; - int _t749; - int _t751; - int _t754; - int _t756; - int _t759; - int _t761; - int _t764; - int _t766; - int _t769; - int _t771; - _t734 = (alg == JwtAlg_HS256); - if (!_t734) goto endif273; + int _t745; + int _t747; + int _t750; + int _t752; + int _t755; + int _t757; + int _t760; + int _t762; + _t725 = (alg == JwtAlg_HS256); + if (!_t725) goto endif260; { void* buf; - void* _t735; - _t735 = Alloc(32); - buf = _t735; + void* _t726; + _t726 = Alloc(32); + buf = _t726; Hmac_Sha256Raw(key, signingInput, buf); const char* result; - _t736 = (const char*)buf; - const char* _t737; - _t737 = bux_base64_encode(_t736, 32); - result = _t737; + _t727 = (const char*)buf; + const char* _t728; + _t728 = bux_base64_encode(_t727, 32); + result = _t728; Free(buf); return result; } - endif273:; - _t738 = (alg == JwtAlg_HS384); - if (!_t738) goto endif275; + endif260:; + _t729 = (alg == JwtAlg_HS384); + if (!_t729) goto endif262; { void* buf; - void* _t739; - _t739 = Alloc(48); - buf = _t739; + void* _t730; + _t730 = Alloc(48); + buf = _t730; Hmac_Sha384Raw(key, signingInput, buf); const char* result; - _t740 = (const char*)buf; - const char* _t741; - _t741 = bux_base64_encode(_t740, 48); - result = _t741; + _t731 = (const char*)buf; + const char* _t732; + _t732 = bux_base64_encode(_t731, 48); + result = _t732; Free(buf); return result; } - endif275:; - _t742 = (alg == JwtAlg_HS512); - if (!_t742) goto endif277; + endif262:; + _t733 = (alg == JwtAlg_HS512); + if (!_t733) goto endif264; { void* buf; - void* _t743; - _t743 = Alloc(64); - buf = _t743; + void* _t734; + _t734 = Alloc(64); + buf = _t734; Hmac_Sha512Raw(key, signingInput, buf); const char* result; - _t744 = (const char*)buf; - const char* _t745; - _t745 = bux_base64_encode(_t744, 64); - result = _t745; + _t735 = (const char*)buf; + const char* _t736; + _t736 = bux_base64_encode(_t735, 64); + result = _t736; Free(buf); return result; } - endif277:; - _t746 = (alg == JwtAlg_RS256); - if (!_t746) goto endif279; + endif264:; + _t737 = (alg == JwtAlg_RS256); + if (!_t737) goto endif266; { const char* raw; - const char* _t747; - _t747 = Rsa_SignSha256(key, signingInput); - raw = _t747; - unsigned int _t748; - _t748 = String_Len(raw); - _t749 = (int)_t748; - const char* _t750; - _t750 = bux_base64_encode(raw, _t749); - return _t750; + const char* _t738; + _t738 = Rsa_SignSha256(key, signingInput); + raw = _t738; + unsigned int _t739; + _t739 = String_Len(raw); + _t740 = (int)_t739; + const char* _t741; + _t741 = bux_base64_encode(raw, _t740); + return _t741; } - endif279:; - _t751 = (alg == JwtAlg_RS384); - if (!_t751) goto endif281; + endif266:; + _t742 = (alg == JwtAlg_RS384); + if (!_t742) goto endif268; { const char* raw; - const char* _t752; - _t752 = Rsa_SignSha384(key, signingInput); - raw = _t752; - unsigned int _t753; - _t753 = String_Len(raw); - _t754 = (int)_t753; - const char* _t755; - _t755 = bux_base64_encode(raw, _t754); - return _t755; + const char* _t743; + _t743 = Rsa_SignSha384(key, signingInput); + raw = _t743; + unsigned int _t744; + _t744 = String_Len(raw); + _t745 = (int)_t744; + const char* _t746; + _t746 = bux_base64_encode(raw, _t745); + return _t746; } - endif281:; - _t756 = (alg == JwtAlg_RS512); - if (!_t756) goto endif283; + endif268:; + _t747 = (alg == JwtAlg_RS512); + if (!_t747) goto endif270; { const char* raw; - const char* _t757; - _t757 = Rsa_SignSha512(key, signingInput); - raw = _t757; - unsigned int _t758; - _t758 = String_Len(raw); - _t759 = (int)_t758; - const char* _t760; - _t760 = bux_base64_encode(raw, _t759); - return _t760; + const char* _t748; + _t748 = Rsa_SignSha512(key, signingInput); + raw = _t748; + unsigned int _t749; + _t749 = String_Len(raw); + _t750 = (int)_t749; + const char* _t751; + _t751 = bux_base64_encode(raw, _t750); + return _t751; } - endif283:; - _t761 = (alg == JwtAlg_ES256); - if (!_t761) goto endif285; + endif270:; + _t752 = (alg == JwtAlg_ES256); + if (!_t752) goto endif272; { const char* raw; - const char* _t762; - _t762 = Ecdsa_SignP256(key, signingInput); - raw = _t762; - unsigned int _t763; - _t763 = String_Len(raw); - _t764 = (int)_t763; - const char* _t765; - _t765 = bux_base64_encode(raw, _t764); - return _t765; + const char* _t753; + _t753 = Ecdsa_SignP256(key, signingInput); + raw = _t753; + unsigned int _t754; + _t754 = String_Len(raw); + _t755 = (int)_t754; + const char* _t756; + _t756 = bux_base64_encode(raw, _t755); + return _t756; } - endif285:; - _t766 = (alg == JwtAlg_ES384); - if (!_t766) goto endif287; + endif272:; + _t757 = (alg == JwtAlg_ES384); + if (!_t757) goto endif274; { const char* raw; - const char* _t767; - _t767 = Ecdsa_SignP384(key, signingInput); - raw = _t767; - unsigned int _t768; - _t768 = String_Len(raw); - _t769 = (int)_t768; - const char* _t770; - _t770 = bux_base64_encode(raw, _t769); - return _t770; + const char* _t758; + _t758 = Ecdsa_SignP384(key, signingInput); + raw = _t758; + unsigned int _t759; + _t759 = String_Len(raw); + _t760 = (int)_t759; + const char* _t761; + _t761 = bux_base64_encode(raw, _t760); + return _t761; } - endif287:; - _t771 = (alg == JwtAlg_EdDSA); - if (!_t771) goto endif289; + endif274:; + _t762 = (alg == JwtAlg_EdDSA); + if (!_t762) goto endif276; { - const char* _t772; - _t772 = Ed25519_Sign(key, signingInput); - return _t772; + const char* _t763; + _t763 = Ed25519_Sign(key, signingInput); + return _t763; } - endif289:; + endif276:; return ""; } bool Jwt_Verify(JwtAlg alg, const char* signingInput, const char* signatureB64, const char* key) { - int _t773; - const char* _t775; - int _t778; - const char* _t780; + int _t764; + const char* _t766; + int _t769; + const char* _t771; + int _t774; + const char* _t776; + int _t779; + int _t781; int _t783; - const char* _t785; - int _t788; - int _t790; - int _t792; - int _t794; - int _t796; - int _t798; - _t773 = (alg == JwtAlg_HS256); - if (!_t773) goto endif291; + int _t785; + int _t787; + int _t789; + _t764 = (alg == JwtAlg_HS256); + if (!_t764) goto endif278; { void* expectBuf; - void* _t774; - _t774 = Alloc(32); - expectBuf = _t774; + void* _t765; + _t765 = Alloc(32); + expectBuf = _t765; Hmac_Sha256Raw(key, signingInput, expectBuf); const char* expectB64; - _t775 = (const char*)expectBuf; - const char* _t776; - _t776 = bux_base64_encode(_t775, 32); - expectB64 = _t776; + _t766 = (const char*)expectBuf; + const char* _t767; + _t767 = bux_base64_encode(_t766, 32); + expectB64 = _t767; Free(expectBuf); - bool _t777; - _t777 = String_Eq(expectB64, signatureB64); - return _t777; + bool _t768; + _t768 = String_Eq(expectB64, signatureB64); + return _t768; } - endif291:; - _t778 = (alg == JwtAlg_HS384); - if (!_t778) goto endif293; + endif278:; + _t769 = (alg == JwtAlg_HS384); + if (!_t769) goto endif280; { void* expectBuf; - void* _t779; - _t779 = Alloc(48); - expectBuf = _t779; + void* _t770; + _t770 = Alloc(48); + expectBuf = _t770; Hmac_Sha384Raw(key, signingInput, expectBuf); const char* expectB64; - _t780 = (const char*)expectBuf; - const char* _t781; - _t781 = bux_base64_encode(_t780, 48); - expectB64 = _t781; + _t771 = (const char*)expectBuf; + const char* _t772; + _t772 = bux_base64_encode(_t771, 48); + expectB64 = _t772; Free(expectBuf); - bool _t782; - _t782 = String_Eq(expectB64, signatureB64); - return _t782; + bool _t773; + _t773 = String_Eq(expectB64, signatureB64); + return _t773; } - endif293:; - _t783 = (alg == JwtAlg_HS512); - if (!_t783) goto endif295; + endif280:; + _t774 = (alg == JwtAlg_HS512); + if (!_t774) goto endif282; { void* expectBuf; - void* _t784; - _t784 = Alloc(64); - expectBuf = _t784; + void* _t775; + _t775 = Alloc(64); + expectBuf = _t775; Hmac_Sha512Raw(key, signingInput, expectBuf); const char* expectB64; - _t785 = (const char*)expectBuf; - const char* _t786; - _t786 = bux_base64_encode(_t785, 64); - expectB64 = _t786; + _t776 = (const char*)expectBuf; + const char* _t777; + _t777 = bux_base64_encode(_t776, 64); + expectB64 = _t777; Free(expectBuf); - bool _t787; - _t787 = String_Eq(expectB64, signatureB64); - return _t787; + bool _t778; + _t778 = String_Eq(expectB64, signatureB64); + return _t778; } - endif295:; - _t788 = (alg == JwtAlg_RS256); - if (!_t788) goto endif297; + endif282:; + _t779 = (alg == JwtAlg_RS256); + if (!_t779) goto endif284; { - bool _t789; - _t789 = Rsa_VerifySha256(key, signingInput, signatureB64); - return _t789; + bool _t780; + _t780 = Rsa_VerifySha256(key, signingInput, signatureB64); + return _t780; } - endif297:; - _t790 = (alg == JwtAlg_RS384); - if (!_t790) goto endif299; + endif284:; + _t781 = (alg == JwtAlg_RS384); + if (!_t781) goto endif286; { - bool _t791; - _t791 = Rsa_VerifySha384(key, signingInput, signatureB64); - return _t791; + bool _t782; + _t782 = Rsa_VerifySha384(key, signingInput, signatureB64); + return _t782; } - endif299:; - _t792 = (alg == JwtAlg_RS512); - if (!_t792) goto endif301; + endif286:; + _t783 = (alg == JwtAlg_RS512); + if (!_t783) goto endif288; { - bool _t793; - _t793 = Rsa_VerifySha512(key, signingInput, signatureB64); - return _t793; + bool _t784; + _t784 = Rsa_VerifySha512(key, signingInput, signatureB64); + return _t784; } - endif301:; - _t794 = (alg == JwtAlg_ES256); - if (!_t794) goto endif303; + endif288:; + _t785 = (alg == JwtAlg_ES256); + if (!_t785) goto endif290; { - bool _t795; - _t795 = Ecdsa_VerifyP256(key, signingInput, signatureB64); - return _t795; + bool _t786; + _t786 = Ecdsa_VerifyP256(key, signingInput, signatureB64); + return _t786; } - endif303:; - _t796 = (alg == JwtAlg_ES384); - if (!_t796) goto endif305; + endif290:; + _t787 = (alg == JwtAlg_ES384); + if (!_t787) goto endif292; { - bool _t797; - _t797 = Ecdsa_VerifyP384(key, signingInput, signatureB64); - return _t797; + bool _t788; + _t788 = Ecdsa_VerifyP384(key, signingInput, signatureB64); + return _t788; } - endif305:; - _t798 = (alg == JwtAlg_EdDSA); - if (!_t798) goto endif307; + endif292:; + _t789 = (alg == JwtAlg_EdDSA); + if (!_t789) goto endif294; { - bool _t799; - _t799 = Ed25519_Verify(key, signatureB64, signingInput); - return _t799; + bool _t790; + _t790 = Ed25519_Verify(key, signatureB64, signingInput); + return _t790; } - endif307:; + endif294:; return 0; } const char* Jwt_Encode(const char* headerJson, const char* payloadJson, JwtAlg alg, const char* key) { const char* headerB64; - const char* _t800; - _t800 = Base64URL_Encode(headerJson); - headerB64 = _t800; + const char* _t791; + _t791 = Base64URL_Encode(headerJson); + headerB64 = _t791; const char* payloadB64; - const char* _t801; - _t801 = Base64URL_Encode(payloadJson); - payloadB64 = _t801; + const char* _t792; + _t792 = Base64URL_Encode(payloadJson); + payloadB64 = _t792; const char* signingInput; - const char* _t802; - _t802 = String_Concat(headerB64, "."); - signingInput = _t802; + const char* _t793; + _t793 = String_Concat(headerB64, "."); + signingInput = _t793; const char* signingInputFull; - const char* _t803; - _t803 = String_Concat(signingInput, payloadB64); - signingInputFull = _t803; + const char* _t794; + _t794 = String_Concat(signingInput, payloadB64); + signingInputFull = _t794; const char* sigB64; - const char* _t804; - _t804 = Jwt_Sign(alg, signingInputFull, key); - sigB64 = _t804; + const char* _t795; + _t795 = Jwt_Sign(alg, signingInputFull, key); + sigB64 = _t795; const char* part1; - const char* _t805; - _t805 = String_Concat(signingInputFull, "."); - part1 = _t805; - const char* _t806; - _t806 = String_Concat(part1, sigB64); - return _t806; + const char* _t796; + _t796 = String_Concat(signingInputFull, "."); + part1 = _t796; + const char* _t797; + _t797 = String_Concat(part1, sigB64); + return _t797; } bool Jwt_Decode(const char* token, JwtAlg alg, const char* key, const char** headerOut, const char** payloadOut) { - int _t808; - int _t815; + int _t799; + int _t806; unsigned int partCount; - unsigned int _t807; - _t807 = bux_str_split_count(token, "."); - partCount = _t807; - _t808 = (partCount != 3); - if (!_t808) goto endif309; + unsigned int _t798; + _t798 = bux_str_split_count(token, "."); + partCount = _t798; + _t799 = (partCount != 3); + if (!_t799) goto endif296; { return 0; } - endif309:; + endif296:; const char* headerB64; - const char* _t809; - _t809 = bux_str_split_part(token, ".", 0); - headerB64 = _t809; + const char* _t800; + _t800 = bux_str_split_part(token, ".", 0); + headerB64 = _t800; const char* payloadB64; - const char* _t810; - _t810 = bux_str_split_part(token, ".", 1); - payloadB64 = _t810; + const char* _t801; + _t801 = bux_str_split_part(token, ".", 1); + payloadB64 = _t801; const char* sigB64; - const char* _t811; - _t811 = bux_str_split_part(token, ".", 2); - sigB64 = _t811; + const char* _t802; + _t802 = bux_str_split_part(token, ".", 2); + sigB64 = _t802; const char* input; - const char* _t812; - _t812 = String_Concat(headerB64, "."); - input = _t812; + const char* _t803; + _t803 = String_Concat(headerB64, "."); + input = _t803; const char* signingInput; - const char* _t813; - _t813 = String_Concat(input, payloadB64); - signingInput = _t813; - bool _t814; - _t814 = Jwt_Verify(alg, signingInput, sigB64, key); - _t815 = !_t814; - if (!_t815) goto endif311; + const char* _t804; + _t804 = String_Concat(input, payloadB64); + signingInput = _t804; + bool _t805; + _t805 = Jwt_Verify(alg, signingInput, sigB64, key); + _t806 = !_t805; + if (!_t806) goto endif298; { return 0; } - endif311:; - const char* _t816; - _t816 = Base64URL_Decode(headerB64); - headerOut[0] = _t816; - const char* _t817; - _t817 = Base64URL_Decode(payloadB64); - payloadOut[0] = _t817; + endif298:; + const char* _t807; + _t807 = Base64URL_Decode(headerB64); + headerOut[0] = _t807; + const char* _t808; + _t808 = Base64URL_Decode(payloadB64); + payloadOut[0] = _t808; return 1; } const char* Jwt_EncodeHS256(const char* payloadJson, const char* secret) { const char* header; - const char* _t818; - _t818 = Jwt_MakeHeader(JwtAlg_HS256); - header = _t818; - const char* _t819; - _t819 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); - return _t819; + const char* _t809; + _t809 = Jwt_MakeHeader(JwtAlg_HS256); + header = _t809; + const char* _t810; + _t810 = Jwt_Encode(header, payloadJson, JwtAlg_HS256, secret); + return _t810; } const char* Jwt_EncodeHS384(const char* payloadJson, const char* secret) { const char* header; - const char* _t820; - _t820 = Jwt_MakeHeader(JwtAlg_HS384); - header = _t820; - const char* _t821; - _t821 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); - return _t821; + const char* _t811; + _t811 = Jwt_MakeHeader(JwtAlg_HS384); + header = _t811; + const char* _t812; + _t812 = Jwt_Encode(header, payloadJson, JwtAlg_HS384, secret); + return _t812; } const char* Jwt_EncodeHS512(const char* payloadJson, const char* secret) { const char* header; - const char* _t822; - _t822 = Jwt_MakeHeader(JwtAlg_HS512); - header = _t822; - const char* _t823; - _t823 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); - return _t823; + const char* _t813; + _t813 = Jwt_MakeHeader(JwtAlg_HS512); + header = _t813; + const char* _t814; + _t814 = Jwt_Encode(header, payloadJson, JwtAlg_HS512, secret); + return _t814; } const char* Jwt_EncodeRS256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t824; - _t824 = Jwt_MakeHeader(JwtAlg_RS256); - header = _t824; - const char* _t825; - _t825 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); - return _t825; + const char* _t815; + _t815 = Jwt_MakeHeader(JwtAlg_RS256); + header = _t815; + const char* _t816; + _t816 = Jwt_Encode(header, payloadJson, JwtAlg_RS256, pemPrivateKey); + return _t816; } const char* Jwt_EncodeES256(const char* payloadJson, const char* pemPrivateKey) { const char* header; - const char* _t826; - _t826 = Jwt_MakeHeader(JwtAlg_ES256); - header = _t826; - const char* _t827; - _t827 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); - return _t827; + const char* _t817; + _t817 = Jwt_MakeHeader(JwtAlg_ES256); + header = _t817; + const char* _t818; + _t818 = Jwt_Encode(header, payloadJson, JwtAlg_ES256, pemPrivateKey); + return _t818; } const char* Jwt_EncodeEdDSA(const char* payloadJson, const char* rawPrivKey) { const char* header; - const char* _t828; - _t828 = Jwt_MakeHeader(JwtAlg_EdDSA); - header = _t828; - const char* _t829; - _t829 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); - return _t829; + const char* _t819; + _t819 = Jwt_MakeHeader(JwtAlg_EdDSA); + header = _t819; + const char* _t820; + _t820 = Jwt_Encode(header, payloadJson, JwtAlg_EdDSA, rawPrivKey); + return _t820; } const char* Ecdsa_SignP256(const char* pemPrivateKey, const char* data) { - int _t831; - int _t833; - void* _t834; + int _t822; + int _t824; + void* _t825; int siglen; siglen = 0; - unsigned int _t830; - _t830 = String_Len(pemPrivateKey); - _t831 = (int)_t830; - unsigned int _t832; - _t832 = String_Len(data); - _t833 = (int)_t832; - _t834 = &siglen; - const char* _t835; - _t835 = bux_ecdsa_sign_p256(pemPrivateKey, _t831, data, _t833, _t834); - return _t835; + unsigned int _t821; + _t821 = String_Len(pemPrivateKey); + _t822 = (int)_t821; + unsigned int _t823; + _t823 = String_Len(data); + _t824 = (int)_t823; + _t825 = &siglen; + const char* _t826; + _t826 = bux_ecdsa_sign_p256(pemPrivateKey, _t822, data, _t824, _t825); + return _t826; } const char* Ecdsa_SignP256Base64(const char* pemPrivateKey, const char* data) { - int _t838; + int _t829; const char* raw; - const char* _t836; - _t836 = Ecdsa_SignP256(pemPrivateKey, data); - raw = _t836; - unsigned int _t837; - _t837 = String_Len(raw); - _t838 = (int)_t837; - const char* _t839; - _t839 = bux_base64_encode(raw, _t838); - return _t839; + const char* _t827; + _t827 = Ecdsa_SignP256(pemPrivateKey, data); + raw = _t827; + unsigned int _t828; + _t828 = String_Len(raw); + _t829 = (int)_t828; + const char* _t830; + _t830 = bux_base64_encode(raw, _t829); + return _t830; } bool Ecdsa_VerifyP256(const char* pemPublicKey, const char* data, const char* signature) { - int _t841; - int _t843; - int _t845; - int _t847; + int _t832; + int _t834; + int _t836; + int _t838; int r; - unsigned int _t840; - _t840 = String_Len(pemPublicKey); - _t841 = (int)_t840; - unsigned int _t842; - _t842 = String_Len(data); - _t843 = (int)_t842; - unsigned int _t844; - _t844 = String_Len(signature); - _t845 = (int)_t844; - int _t846; - _t846 = bux_ecdsa_verify_p256(pemPublicKey, _t841, data, _t843, signature, _t845); - r = _t846; - _t847 = (r == 1); - return _t847; + unsigned int _t831; + _t831 = String_Len(pemPublicKey); + _t832 = (int)_t831; + unsigned int _t833; + _t833 = String_Len(data); + _t834 = (int)_t833; + unsigned int _t835; + _t835 = String_Len(signature); + _t836 = (int)_t835; + int _t837; + _t837 = bux_ecdsa_verify_p256(pemPublicKey, _t832, data, _t834, signature, _t836); + r = _t837; + _t838 = (r == 1); + return _t838; } bool Ecdsa_VerifyP256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t849; - void* _t850; + int _t840; + void* _t841; int outlen; outlen = 0; const char* sig; - unsigned int _t848; - _t848 = String_Len(signatureB64); - _t849 = (int)_t848; - _t850 = &outlen; - const char* _t851; - _t851 = bux_base64_decode(signatureB64, _t849, _t850); - sig = _t851; - bool _t852; - _t852 = Ecdsa_VerifyP256(pemPublicKey, data, sig); - return _t852; + unsigned int _t839; + _t839 = String_Len(signatureB64); + _t840 = (int)_t839; + _t841 = &outlen; + const char* _t842; + _t842 = bux_base64_decode(signatureB64, _t840, _t841); + sig = _t842; + bool _t843; + _t843 = Ecdsa_VerifyP256(pemPublicKey, data, sig); + return _t843; } const char* Ecdsa_SignP384(const char* pemPrivateKey, const char* data) { - int _t854; - int _t856; - void* _t857; + int _t845; + int _t847; + void* _t848; int siglen; siglen = 0; - unsigned int _t853; - _t853 = String_Len(pemPrivateKey); - _t854 = (int)_t853; - unsigned int _t855; - _t855 = String_Len(data); - _t856 = (int)_t855; - _t857 = &siglen; - const char* _t858; - _t858 = bux_ecdsa_sign_p384(pemPrivateKey, _t854, data, _t856, _t857); - return _t858; + unsigned int _t844; + _t844 = String_Len(pemPrivateKey); + _t845 = (int)_t844; + unsigned int _t846; + _t846 = String_Len(data); + _t847 = (int)_t846; + _t848 = &siglen; + const char* _t849; + _t849 = bux_ecdsa_sign_p384(pemPrivateKey, _t845, data, _t847, _t848); + return _t849; } const char* Ecdsa_SignP384Base64(const char* pemPrivateKey, const char* data) { - int _t861; + int _t852; const char* raw; - const char* _t859; - _t859 = Ecdsa_SignP384(pemPrivateKey, data); - raw = _t859; - unsigned int _t860; - _t860 = String_Len(raw); - _t861 = (int)_t860; - const char* _t862; - _t862 = bux_base64_encode(raw, _t861); - return _t862; + const char* _t850; + _t850 = Ecdsa_SignP384(pemPrivateKey, data); + raw = _t850; + unsigned int _t851; + _t851 = String_Len(raw); + _t852 = (int)_t851; + const char* _t853; + _t853 = bux_base64_encode(raw, _t852); + return _t853; } bool Ecdsa_VerifyP384(const char* pemPublicKey, const char* data, const char* signature) { - int _t864; - int _t866; - int _t868; - int _t870; + int _t855; + int _t857; + int _t859; + int _t861; int r; - unsigned int _t863; - _t863 = String_Len(pemPublicKey); - _t864 = (int)_t863; - unsigned int _t865; - _t865 = String_Len(data); - _t866 = (int)_t865; - unsigned int _t867; - _t867 = String_Len(signature); - _t868 = (int)_t867; - int _t869; - _t869 = bux_ecdsa_verify_p384(pemPublicKey, _t864, data, _t866, signature, _t868); - r = _t869; - _t870 = (r == 1); - return _t870; + unsigned int _t854; + _t854 = String_Len(pemPublicKey); + _t855 = (int)_t854; + unsigned int _t856; + _t856 = String_Len(data); + _t857 = (int)_t856; + unsigned int _t858; + _t858 = String_Len(signature); + _t859 = (int)_t858; + int _t860; + _t860 = bux_ecdsa_verify_p384(pemPublicKey, _t855, data, _t857, signature, _t859); + r = _t860; + _t861 = (r == 1); + return _t861; } bool Ecdsa_VerifyP384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t872; - void* _t873; + int _t863; + void* _t864; int outlen; outlen = 0; const char* sig; - unsigned int _t871; - _t871 = String_Len(signatureB64); - _t872 = (int)_t871; - _t873 = &outlen; - const char* _t874; - _t874 = bux_base64_decode(signatureB64, _t872, _t873); - sig = _t874; - bool _t875; - _t875 = Ecdsa_VerifyP384(pemPublicKey, data, sig); - return _t875; + unsigned int _t862; + _t862 = String_Len(signatureB64); + _t863 = (int)_t862; + _t864 = &outlen; + const char* _t865; + _t865 = bux_base64_decode(signatureB64, _t863, _t864); + sig = _t865; + bool _t866; + _t866 = Ecdsa_VerifyP384(pemPublicKey, data, sig); + return _t866; } bool Ed25519_Keypair(void* pubKey, void* privKey) { - int _t877; + int _t868; int r; - int _t876; - _t876 = bux_ed25519_keypair(pubKey, privKey); - r = _t876; - _t877 = (r == 1); - return _t877; + int _t867; + _t867 = bux_ed25519_keypair(pubKey, privKey); + r = _t867; + _t868 = (r == 1); + return _t868; } const char* Ed25519_KeypairBase64(void) { - unsigned int _t878; - unsigned int _t880; - int _t883; - const char* _t884; - const char* _t886; + unsigned int _t869; + unsigned int _t871; + int _t874; + const char* _t875; + const char* _t877; void* pubBuf; - _t878 = (unsigned int)ED25519_PUBKEY_SIZE; - void* _t879; - _t879 = Alloc(_t878); - pubBuf = _t879; + _t869 = (unsigned int)ED25519_PUBKEY_SIZE; + void* _t870; + _t870 = Alloc(_t869); + pubBuf = _t870; void* priv; - _t880 = (unsigned int)ED25519_PRIVKEY_SIZE; - void* _t881; - _t881 = Alloc(_t880); - priv = _t881; - int _t882; - _t882 = bux_ed25519_keypair(pubBuf, priv); - _t883 = (_t882 != 1); - if (!_t883) goto endif313; + _t871 = (unsigned int)ED25519_PRIVKEY_SIZE; + void* _t872; + _t872 = Alloc(_t871); + priv = _t872; + int _t873; + _t873 = bux_ed25519_keypair(pubBuf, priv); + _t874 = (_t873 != 1); + if (!_t874) goto endif300; { Free(pubBuf); Free(priv); return ""; } - endif313:; + endif300:; const char* pubB64; - _t884 = (const char*)pubBuf; - const char* _t885; - _t885 = bux_base64_encode(_t884, ED25519_PUBKEY_SIZE); - pubB64 = _t885; + _t875 = (const char*)pubBuf; + const char* _t876; + _t876 = bux_base64_encode(_t875, ED25519_PUBKEY_SIZE); + pubB64 = _t876; const char* privB64; - _t886 = (const char*)priv; - const char* _t887; - _t887 = bux_base64_encode(_t886, ED25519_PRIVKEY_SIZE); - privB64 = _t887; + _t877 = (const char*)priv; + const char* _t878; + _t878 = bux_base64_encode(_t877, ED25519_PRIVKEY_SIZE); + privB64 = _t878; Free(pubBuf); Free(priv); const char* pair; - const char* _t888; - _t888 = String_Concat(pubB64, ":"); - pair = _t888; - const char* _t889; - _t889 = String_Concat(pair, privB64); - return _t889; + const char* _t879; + _t879 = String_Concat(pubB64, ":"); + pair = _t879; + const char* _t880; + _t880 = String_Concat(pair, privB64); + return _t880; } const char* Ed25519_Sign(const char* privKey, const char* data) { - unsigned int _t890; - int _t893; - int _t895; - const char* _t896; + unsigned int _t881; + int _t884; + int _t886; + const char* _t887; void* sig; - _t890 = (unsigned int)ED25519_SIG_SIZE; - void* _t891; - _t891 = Alloc(_t890); - sig = _t891; - unsigned int _t892; - _t892 = String_Len(data); - _t893 = (int)_t892; - int _t894; - _t894 = bux_ed25519_sign(privKey, data, _t893, sig); - _t895 = (_t894 != 1); - if (!_t895) goto endif315; + _t881 = (unsigned int)ED25519_SIG_SIZE; + void* _t882; + _t882 = Alloc(_t881); + sig = _t882; + unsigned int _t883; + _t883 = String_Len(data); + _t884 = (int)_t883; + int _t885; + _t885 = bux_ed25519_sign(privKey, data, _t884, sig); + _t886 = (_t885 != 1); + if (!_t886) goto endif302; { Free(sig); return ""; } - endif315:; - _t896 = (const char*)sig; - return _t896; + endif302:; + _t887 = (const char*)sig; + return _t887; } const char* Ed25519_SignBase64(const char* privKey, const char* data) { - int _t899; + int _t890; const char* sig; - const char* _t897; - _t897 = Ed25519_Sign(privKey, data); - sig = _t897; - unsigned int _t898; - _t898 = String_Len(sig); - _t899 = (_t898 == 0); - if (!_t899) goto endif317; + const char* _t888; + _t888 = Ed25519_Sign(privKey, data); + sig = _t888; + unsigned int _t889; + _t889 = String_Len(sig); + _t890 = (_t889 == 0); + if (!_t890) goto endif304; { return ""; } - endif317:; - const char* _t900; - _t900 = bux_base64_encode(sig, ED25519_SIG_SIZE); - return _t900; + endif304:; + const char* _t891; + _t891 = bux_base64_encode(sig, ED25519_SIG_SIZE); + return _t891; } bool Ed25519_Verify(const char* pubKey, const char* signature, const char* data) { - int _t902; - int _t904; + int _t893; + int _t895; int r; - unsigned int _t901; - _t901 = String_Len(data); - _t902 = (int)_t901; - int _t903; - _t903 = bux_ed25519_verify(pubKey, signature, data, _t902); - r = _t903; - _t904 = (r == 1); - return _t904; + unsigned int _t892; + _t892 = String_Len(data); + _t893 = (int)_t892; + int _t894; + _t894 = bux_ed25519_verify(pubKey, signature, data, _t893); + r = _t894; + _t895 = (r == 1); + return _t895; } bool Ed25519_VerifyBase64(const char* pubKey, const char* signatureB64, const char* data) { - int _t906; - void* _t907; - int _t909; + int _t897; + void* _t898; + int _t900; int outlen; outlen = 0; const char* sig; - unsigned int _t905; - _t905 = String_Len(signatureB64); - _t906 = (int)_t905; - _t907 = &outlen; - const char* _t908; - _t908 = bux_base64_decode(signatureB64, _t906, _t907); - sig = _t908; - _t909 = (outlen != ED25519_SIG_SIZE); - if (!_t909) goto endif319; + unsigned int _t896; + _t896 = String_Len(signatureB64); + _t897 = (int)_t896; + _t898 = &outlen; + const char* _t899; + _t899 = bux_base64_decode(signatureB64, _t897, _t898); + sig = _t899; + _t900 = (outlen != ED25519_SIG_SIZE); + if (!_t900) goto endif306; { return 0; } - endif319:; - bool _t910; - _t910 = Ed25519_Verify(pubKey, sig, data); - return _t910; + endif306:; + bool _t901; + _t901 = Ed25519_Verify(pubKey, sig, data); + return _t901; } const char* Rsa_SignSha256(const char* pemPrivateKey, const char* data) { - int _t912; - int _t914; - void* _t915; + int _t903; + int _t905; + void* _t906; int siglen; siglen = 0; - unsigned int _t911; - _t911 = String_Len(pemPrivateKey); - _t912 = (int)_t911; - unsigned int _t913; - _t913 = String_Len(data); - _t914 = (int)_t913; - _t915 = &siglen; - const char* _t916; - _t916 = bux_rsa_sign_sha256(pemPrivateKey, _t912, data, _t914, _t915); - return _t916; + unsigned int _t902; + _t902 = String_Len(pemPrivateKey); + _t903 = (int)_t902; + unsigned int _t904; + _t904 = String_Len(data); + _t905 = (int)_t904; + _t906 = &siglen; + const char* _t907; + _t907 = bux_rsa_sign_sha256(pemPrivateKey, _t903, data, _t905, _t906); + return _t907; } const char* Rsa_SignSha384(const char* pemPrivateKey, const char* data) { - int _t918; - int _t920; - void* _t921; + int _t909; + int _t911; + void* _t912; int siglen; siglen = 0; - unsigned int _t917; - _t917 = String_Len(pemPrivateKey); - _t918 = (int)_t917; - unsigned int _t919; - _t919 = String_Len(data); - _t920 = (int)_t919; - _t921 = &siglen; - const char* _t922; - _t922 = bux_rsa_sign_sha384(pemPrivateKey, _t918, data, _t920, _t921); - return _t922; + unsigned int _t908; + _t908 = String_Len(pemPrivateKey); + _t909 = (int)_t908; + unsigned int _t910; + _t910 = String_Len(data); + _t911 = (int)_t910; + _t912 = &siglen; + const char* _t913; + _t913 = bux_rsa_sign_sha384(pemPrivateKey, _t909, data, _t911, _t912); + return _t913; } const char* Rsa_SignSha512(const char* pemPrivateKey, const char* data) { - int _t924; - int _t926; - void* _t927; + int _t915; + int _t917; + void* _t918; int siglen; siglen = 0; - unsigned int _t923; - _t923 = String_Len(pemPrivateKey); - _t924 = (int)_t923; - unsigned int _t925; - _t925 = String_Len(data); - _t926 = (int)_t925; - _t927 = &siglen; - const char* _t928; - _t928 = bux_rsa_sign_sha512(pemPrivateKey, _t924, data, _t926, _t927); - return _t928; + unsigned int _t914; + _t914 = String_Len(pemPrivateKey); + _t915 = (int)_t914; + unsigned int _t916; + _t916 = String_Len(data); + _t917 = (int)_t916; + _t918 = &siglen; + const char* _t919; + _t919 = bux_rsa_sign_sha512(pemPrivateKey, _t915, data, _t917, _t918); + return _t919; } const char* Rsa_SignSha256Base64(const char* pemPrivateKey, const char* data) { - int _t931; + int _t922; const char* raw; - const char* _t929; - _t929 = Rsa_SignSha256(pemPrivateKey, data); - raw = _t929; - unsigned int _t930; - _t930 = String_Len(raw); - _t931 = (int)_t930; - const char* _t932; - _t932 = bux_base64_encode(raw, _t931); - return _t932; + const char* _t920; + _t920 = Rsa_SignSha256(pemPrivateKey, data); + raw = _t920; + unsigned int _t921; + _t921 = String_Len(raw); + _t922 = (int)_t921; + const char* _t923; + _t923 = bux_base64_encode(raw, _t922); + return _t923; } const char* Rsa_SignSha384Base64(const char* pemPrivateKey, const char* data) { - int _t935; + int _t926; const char* raw; - const char* _t933; - _t933 = Rsa_SignSha384(pemPrivateKey, data); - raw = _t933; - unsigned int _t934; - _t934 = String_Len(raw); - _t935 = (int)_t934; - const char* _t936; - _t936 = bux_base64_encode(raw, _t935); - return _t936; + const char* _t924; + _t924 = Rsa_SignSha384(pemPrivateKey, data); + raw = _t924; + unsigned int _t925; + _t925 = String_Len(raw); + _t926 = (int)_t925; + const char* _t927; + _t927 = bux_base64_encode(raw, _t926); + return _t927; } const char* Rsa_SignSha512Base64(const char* pemPrivateKey, const char* data) { - int _t939; + int _t930; const char* raw; - const char* _t937; - _t937 = Rsa_SignSha512(pemPrivateKey, data); - raw = _t937; - unsigned int _t938; - _t938 = String_Len(raw); - _t939 = (int)_t938; - const char* _t940; - _t940 = bux_base64_encode(raw, _t939); - return _t940; + const char* _t928; + _t928 = Rsa_SignSha512(pemPrivateKey, data); + raw = _t928; + unsigned int _t929; + _t929 = String_Len(raw); + _t930 = (int)_t929; + const char* _t931; + _t931 = bux_base64_encode(raw, _t930); + return _t931; } bool Rsa_VerifySha256(const char* pemPublicKey, const char* data, const char* signature) { - int _t942; - int _t944; - int _t946; - int _t948; + int _t933; + int _t935; + int _t937; + int _t939; int r; - unsigned int _t941; - _t941 = String_Len(pemPublicKey); - _t942 = (int)_t941; - unsigned int _t943; - _t943 = String_Len(data); - _t944 = (int)_t943; - unsigned int _t945; - _t945 = String_Len(signature); - _t946 = (int)_t945; - int _t947; - _t947 = bux_rsa_verify_sha256(pemPublicKey, _t942, data, _t944, signature, _t946); - r = _t947; - _t948 = (r == 1); - return _t948; + unsigned int _t932; + _t932 = String_Len(pemPublicKey); + _t933 = (int)_t932; + unsigned int _t934; + _t934 = String_Len(data); + _t935 = (int)_t934; + unsigned int _t936; + _t936 = String_Len(signature); + _t937 = (int)_t936; + int _t938; + _t938 = bux_rsa_verify_sha256(pemPublicKey, _t933, data, _t935, signature, _t937); + r = _t938; + _t939 = (r == 1); + return _t939; } bool Rsa_VerifySha384(const char* pemPublicKey, const char* data, const char* signature) { - int _t950; - int _t952; - int _t954; - int _t956; + int _t941; + int _t943; + int _t945; + int _t947; int r; - unsigned int _t949; - _t949 = String_Len(pemPublicKey); - _t950 = (int)_t949; - unsigned int _t951; - _t951 = String_Len(data); - _t952 = (int)_t951; - unsigned int _t953; - _t953 = String_Len(signature); - _t954 = (int)_t953; - int _t955; - _t955 = bux_rsa_verify_sha384(pemPublicKey, _t950, data, _t952, signature, _t954); - r = _t955; - _t956 = (r == 1); - return _t956; + unsigned int _t940; + _t940 = String_Len(pemPublicKey); + _t941 = (int)_t940; + unsigned int _t942; + _t942 = String_Len(data); + _t943 = (int)_t942; + unsigned int _t944; + _t944 = String_Len(signature); + _t945 = (int)_t944; + int _t946; + _t946 = bux_rsa_verify_sha384(pemPublicKey, _t941, data, _t943, signature, _t945); + r = _t946; + _t947 = (r == 1); + return _t947; } bool Rsa_VerifySha512(const char* pemPublicKey, const char* data, const char* signature) { - int _t958; - int _t960; - int _t962; - int _t964; + int _t949; + int _t951; + int _t953; + int _t955; int r; - unsigned int _t957; - _t957 = String_Len(pemPublicKey); - _t958 = (int)_t957; - unsigned int _t959; - _t959 = String_Len(data); - _t960 = (int)_t959; - unsigned int _t961; - _t961 = String_Len(signature); - _t962 = (int)_t961; - int _t963; - _t963 = bux_rsa_verify_sha512(pemPublicKey, _t958, data, _t960, signature, _t962); - r = _t963; - _t964 = (r == 1); - return _t964; + unsigned int _t948; + _t948 = String_Len(pemPublicKey); + _t949 = (int)_t948; + unsigned int _t950; + _t950 = String_Len(data); + _t951 = (int)_t950; + unsigned int _t952; + _t952 = String_Len(signature); + _t953 = (int)_t952; + int _t954; + _t954 = bux_rsa_verify_sha512(pemPublicKey, _t949, data, _t951, signature, _t953); + r = _t954; + _t955 = (r == 1); + return _t955; } bool Rsa_VerifySha256Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t966; - void* _t967; + int _t957; + void* _t958; int outlen; outlen = 0; const char* sig; - unsigned int _t965; - _t965 = String_Len(signatureB64); - _t966 = (int)_t965; - _t967 = &outlen; - const char* _t968; - _t968 = bux_base64_decode(signatureB64, _t966, _t967); - sig = _t968; - bool _t969; - _t969 = Rsa_VerifySha256(pemPublicKey, data, sig); - return _t969; + unsigned int _t956; + _t956 = String_Len(signatureB64); + _t957 = (int)_t956; + _t958 = &outlen; + const char* _t959; + _t959 = bux_base64_decode(signatureB64, _t957, _t958); + sig = _t959; + bool _t960; + _t960 = Rsa_VerifySha256(pemPublicKey, data, sig); + return _t960; } bool Rsa_VerifySha384Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t971; - void* _t972; + int _t962; + void* _t963; int outlen; outlen = 0; const char* sig; - unsigned int _t970; - _t970 = String_Len(signatureB64); - _t971 = (int)_t970; - _t972 = &outlen; - const char* _t973; - _t973 = bux_base64_decode(signatureB64, _t971, _t972); - sig = _t973; - bool _t974; - _t974 = Rsa_VerifySha384(pemPublicKey, data, sig); - return _t974; + unsigned int _t961; + _t961 = String_Len(signatureB64); + _t962 = (int)_t961; + _t963 = &outlen; + const char* _t964; + _t964 = bux_base64_decode(signatureB64, _t962, _t963); + sig = _t964; + bool _t965; + _t965 = Rsa_VerifySha384(pemPublicKey, data, sig); + return _t965; } bool Rsa_VerifySha512Base64(const char* pemPublicKey, const char* data, const char* signatureB64) { - int _t976; - void* _t977; + int _t967; + void* _t968; int outlen; outlen = 0; const char* sig; - unsigned int _t975; - _t975 = String_Len(signatureB64); - _t976 = (int)_t975; - _t977 = &outlen; - const char* _t978; - _t978 = bux_base64_decode(signatureB64, _t976, _t977); - sig = _t978; - bool _t979; - _t979 = Rsa_VerifySha512(pemPublicKey, data, sig); - return _t979; + unsigned int _t966; + _t966 = String_Len(signatureB64); + _t967 = (int)_t966; + _t968 = &outlen; + const char* _t969; + _t969 = bux_base64_decode(signatureB64, _t967, _t968); + sig = _t969; + bool _t970; + _t970 = Rsa_VerifySha512(pemPublicKey, data, sig); + return _t970; } Point AddPoints(Point a, Point b) { - int _t982; - int _t985; - Point _t986; + int _t973; + int _t976; + Point _t977; Point result; - int _t980; - _t980 = a.x; - int _t981; - _t981 = b.x; - _t982 = _t980 + _t981; - int _t983; - _t983 = a.y; - int _t984; - _t984 = b.y; - _t985 = _t983 + _t984; - _t986 = (Point){.x = _t982, .y = _t985}; - result = _t986; + int _t971; + _t971 = a.x; + int _t972; + _t972 = b.x; + _t973 = _t971 + _t972; + int _t974; + _t974 = a.y; + int _t975; + _t975 = b.y; + _t976 = _t974 + _t975; + _t977 = (Point){.x = _t973, .y = _t976}; + result = _t977; return result; } int Main(void) { - Point _t987; - Point _t988; + Point _t978; + Point _t979; Point p1; - _t987 = (Point){.x = 10, .y = 20}; - p1 = _t987; + _t978 = (Point){.x = 10, .y = 20}; + p1 = _t978; Point p2; - _t988 = (Point){.x = 5, .y = 15}; - p2 = _t988; + _t979 = (Point){.x = 5, .y = 15}; + p2 = _t979; Point sum; - Point _t989; - _t989 = AddPoints(p1, p2); - sum = _t989; + Point _t980; + _t980 = AddPoints(p1, p2); + sum = _t980; PrintLine("Point sum:"); PrintLine("x = "); - int _t990; - _t990 = sum.x; - PrintInt(_t990); + int _t981; + _t981 = sum.x; + PrintInt(_t981); PrintLine(""); PrintLine("y = "); - int _t991; - _t991 = sum.y; - PrintInt(_t991); + int _t982; + _t982 = sum.y; + PrintInt(_t982); PrintLine(""); return 0; } diff --git a/tests/hir_test.nim b/tests/hir_test.nim index 6eb91f8..8d21cc3 100644 --- a/tests/hir_test.nim +++ b/tests/hir_test.nim @@ -1,5 +1,5 @@ -import std/[unittest, strformat] -import ../bootstrap/[lexer, parser, sema, hir, hir_lower, types, scope] +import std/[unittest] +import ../bootstrap/[lexer, parser, sema, hir, hir_lower, scope] proc lowerSource(source: string): HirModule = let lexRes = tokenize(source, "") diff --git a/tests/lexer_test.nim b/tests/lexer_test.nim index 21c452e..e45a54e 100644 --- a/tests/lexer_test.nim +++ b/tests/lexer_test.nim @@ -1,5 +1,5 @@ -import std/[unittest, os, strutils] -import ../bootstrap/[lexer, token, source_location] +import std/[unittest, strutils] +import ../bootstrap/[lexer, token] proc tokenKinds(source: string): seq[TokenKind] = let res = tokenize(source, "") diff --git a/tests/parser_test.nim b/tests/parser_test.nim index fad2503..7dee4e5 100644 --- a/tests/parser_test.nim +++ b/tests/parser_test.nim @@ -1,4 +1,4 @@ -import std/[unittest, os, strutils] +import std/[unittest, os] import ../bootstrap/[lexer, parser, ast, token] proc parseSource(source: string): ParseResult = diff --git a/tests/sema_test.nim b/tests/sema_test.nim index 1d00885..f2f767e 100644 --- a/tests/sema_test.nim +++ b/tests/sema_test.nim @@ -1,5 +1,5 @@ import std/[unittest, strutils] -import ../bootstrap/[lexer, parser, sema, types] +import ../bootstrap/[lexer, parser, sema] proc checkSource(source: string): SemaResult = let lexRes = tokenize(source, "")