length := fn(ptr: ^u8): int { len := 0 loop if *(ptr + len) == 0 break else len += 1 return len } display_int := fn(num: int, p: ^u8): ^u8 { i := 0 if num == 0 { *p = 48; *(p + 1) = 0 return p } neg := false if num < 0 { neg = true num = -num } loop if num == 0 break else { *(p + i) = num % 10 + 48 num /= 10 i += 1 } if neg { *(p + i) = 45 i += 1 } reverse(p, i) return p } reverse := fn(p: ^u8, len: int): void { start := 0 end := len - 1 loop if start >= end break else { temp := *(p + start); *(p + start) = *(p + end); *(p + end) = temp start += 1 end -= 1 } return }