https://github.com/akkartik/mu/blob/main/linux/312copy.subx
 1 == code
 2 
 3 copy-array-object:  # src: (addr array T), dest-ah: (addr handle array T)
 4     # . prologue
 5     55/push-ebp
 6     89/<- %ebp 4/r32/esp
 7     #
 8     (copy-array Heap *(ebp+8) *(ebp+0xc))
 9 $copy-array-object:end:
10     # . epilogue
11     89/<- %esp 5/r32/ebp
12     5d/pop-to-ebp
13     c3/return
14 
15 # create an independent copy of file src into dest
16 # there's no way to do this without knowing the filename
17 copy-file:  # src: (addr buffered-file), dest-ah: (addr handle buffered-file), filename: (addr array byte)
18     # . prologue
19     55/push-ebp
20     89/<- %ebp 4/r32/esp
21     # . save registers
22     50/push-eax
23     51/push-ecx
24     52/push-edx
25     53/push-ebx
26     56/push-esi
27     57/push-edi
28     # esi = src
29     8b/-> *(ebp+8) 6/r32/esi
30     # var n/ecx: int = src->buffer->size + 16
31     8b/-> *(esi+0xc) 0/r32/eax
32     05/add-to-eax 0x10/imm32  # buffered-file fields before buffer contents
33     89/<- %ecx 0/r32/eax
34     #
35     (allocate Heap %ecx *(ebp+0xc))
36     # var dest/edi: (addr buffered-file) = lookup(*dest-ah)
37     8b/-> *(ebp+0xc) 0/r32/eax
38     (lookup *eax *(eax+4))  # => eax
39     89/<- %edi 0/r32/eax
40     #
41     (copy-bytes %esi %edi %ecx)
42     # var offset/ecx: int = lseek(src->fd, 0, SEEK_CUR)
43     8b/-> *esi 3/r32/ebx
44     b9/copy-to-ecx 0/imm32/offset
45     ba/copy-to-edx 1/imm32/whence:SEEK_CUR
46     (syscall_lseek)
47     89/<- %ecx 0/r32/eax
48     # at this point dest is identical to src, including file descriptor. Now
49     # create an independent copy of the file descriptor
50     (open-fd *(ebp+0x10) 0)  # false => eax
51     89/<- *edi 0/r32/eax
52     # replicate offset in the new fd
53     89/<- %ebx 0/r32/eax  # fd
54     51/push-ecx  # offset
55     ba/copy-to-edx 0/imm32/whence:SEEK_SET
56     (syscall_lseek)
57 $copy-file:end:
58     # . restore registers
59     5f/pop-to-edi
60     5e/pop-to-esi
61     5b/pop-to-ebx
62     5a/pop-to-edx
63     59/pop-to-ecx
64     58/pop-to-eax
65     # . epilogue
66     89/<- %esp 5/r32/ebp
67     5d/pop-to-ebp
68     c3/return