1. A PHP function and its conceptual ZIR
A small, strict-typed helper. The lowering makes the cast and the two identity checks explicit operations; the (int) cast is total, so no exception path appears.
<?php
declare(strict_types=1);
// Normalise a user-supplied page size, with PHP's own clamp semantics.
function page_size(?string $raw, int $default = 20): int {
if ($raw === null || $raw === '') {
return $default;
}
$n = (int) $raw; // "12abc" -> 12, "abc" -> 0
return max(1, min($n, 100));
}; ZIR pseudocode. Conceptual lowering of page_size; not compiler output. fn page_size(%raw: ?str, %default: int) -> int %isnull = cmp.identical %raw null br %isnull use_default %empty = cmp.identical %raw "" br %empty use_default %n = cast.int %raw ; PHP (int) cast: leading digits, else 0; never throws %lo = call.builtin min %n 100 %v = call.builtin max 1 %lo ret %v use_default: ret %default