class SystemPages {

    private SystemPages() {
    }

    /**
     * Queries the {@code system_pages} kstat and returns available and physical memory
     *
     * @return A pair with the available and total memory, in pages. Mutiply by page size for bytes.
     */
    public static Pair<Long, Long> queryAvailableTotal() {<FILL_FUNCTION_BODY>}

    private static Pair<Long, Long> queryAvailableTotal2() {
        Object[] results = KstatUtil.queryKstat2("kstat:/pages/unix/system_pages", "availrmem", "physmem");
        long avail = results[0] == null ? 0L : (long) results[0];
        long total = results[1] == null ? 0L : (long) results[1];
        return new Pair<>(avail, total);
    }
}

        if (HAS_KSTAT2) {
            // Use Kstat2 implementation
            return queryAvailableTotal2();
        }
        long memAvailable = 0;
        long memTotal = 0;
        // Get first result
        try (KstatChain kc = KstatUtil.openChain()) {
            Kstat ksp = kc.lookup(null, -1, "system_pages");
            // Set values
            if (ksp != null && kc.read(ksp)) {
                memAvailable = KstatUtil.dataLookupLong(ksp, "availrmem"); // not a typo
                memTotal = KstatUtil.dataLookupLong(ksp, "physmem");
            }
        }
        return new Pair<>(memAvailable, memTotal);
    
<no_super_class>