https://github.com/akkartik/mu/blob/main/410file.mu
1 fn read-lines in: (addr buffered-file), out: (addr handle array (handle array byte)) {
2 var stream: (stream (handle array byte) 0x10)
3 var stream-a/edi: (addr stream (handle array byte)) <- address stream
4 var line: (stream byte 0x10)
5 var line-a/esi: (addr stream byte) <- address line
6 {
7 clear-stream line-a
8 read-line-buffered in, line-a
9 var done?/eax: boolean <- stream-empty? line-a
10 compare done?, 0
11 break-if-!=
12
13 var h: (handle array byte)
14 var ah/eax: (addr handle array byte) <- address h
15 stream-to-array line-a, ah
16 write-to-stream stream-a, ah
17 loop
18 }
19 stream-to-array stream-a, out
20 }