https://github.com/akkartik/mu/blob/main/shell/life.mu
  1 fn state _grid: (addr array boolean), x: int, y: int -> _/eax: boolean {
  2   # clip at the edge
  3   compare x, 0
  4   {
  5     break-if->=
  6     return 0/false
  7   }
  8   compare y, 0
  9   {
 10     break-if->=
 11     return 0/false
 12   }
 13   compare x, 0x100/width
 14   {
 15     break-if-<
 16     return 0/false
 17   }
 18   compare y, 0xc0/height
 19   {
 20     break-if-<
 21     return 0/false
 22   }
 23   var idx/eax: int <- copy y
 24   idx <- shift-left 8/log2width
 25   idx <- add x
 26   var grid/esi: (addr array boolean) <- copy _grid
 27   var result/eax: (addr boolean) <- index grid, idx
 28   return *result
 29 }
 30 
 31 fn set-state _grid: (addr array boolean), x: int, y: int, val: boolean {
 32   # don't bother checking bounds
 33   var idx/eax: int <- copy y
 34   idx <- shift-left 8/log2width
 35   idx <- add x
 36   var grid/esi: (addr array boolean) <- copy _grid
 37   var result/eax: (addr boolean) <- index grid, idx
 38   var src/ecx: boolean <- copy val
 39   copy-to *result, src
 40 }
 41 
 42 fn num-live-neighbors grid: (addr array boolean), x: int, y: int -> _/eax: int {
 43   var result/edi: int <- copy 0
 44   # row above: zig
 45   decrement y
 46   decrement x
 47   var s/eax: boolean <- state grid, x, y
 48   {
 49     compare s, 0/false
 50     break-if-=
 51     result <- increment
 52   }
 53   increment x
 54   s <- state grid, x, y
 55   {
 56     compare s, 0/false
 57     break-if-=
 58     result <- increment
 59   }
 60   increment x
 61   s <- state grid, x, y
 62   {
 63     compare s, 0/false
 64     break-if-=
 65     result <- increment
 66   }
 67   # curr row: zag
 68   increment y
 69   s <- state grid, x, y
 70   {
 71     compare s, 0/false
 72     break-if-=
 73     result <- increment
 74   }
 75   subtract-from x, 2
 76   s <- state grid, x, y
 77   {
 78     compare s, 0/false
 79     break-if-=
 80     result <- increment
 81   }
 82   # row below: zig
 83   increment y
 84   s <- state grid, x, y
 85   {
 86     compare s, 0/false
 87     break-if-=
 88     result <- increment
 89   }
 90   increment x
 91   s <- state grid, x, y
 92   {
 93     compare s, 0/false
 94     break-if-=
 95     result <- increment
 96   }
 97   increment x
 98   s <- state grid, x, y
 99   {
100     compare s, 0/false
101     break-if-=
102     result <- increment
103   }
104   return result
105 }
106 
107 fn step old-grid: (addr array boolean), new-grid: (addr array boolean) {
108   var y/ecx: int <- cop
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module ranger.gui.displayable</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="ranger.html"><font color="#ffffff">ranger</font></a>.<a href="ranger.gui.html"><font color="#ffffff">gui</font></a>.displayable</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/ranger/ranger/gui/displayable.py">/home/hut/ranger/ranger/gui/displayable.py</a></font></td></tr></table>
    <p><tt>#&nbsp;Copyright&nbsp;(c)&nbsp;2009,&nbsp;2010&nbsp;hut&nbsp;&lt;hut@lavabit.com&gt;<br>
#<br>
#&nbsp;Permission&nbsp;to&nbsp;use,&nbsp;copy,&nbsp;modify,&nbsp;and/or&nbsp;distribute&nbsp;this&nbsp;software&nbsp;for&nbsp;any<br>
#&nbsp;purpose&nbsp;with&nbsp;or&nbsp;without&nbsp;fee&nbsp;is&nbsp;hereby&nbsp;granted,&nbsp;provided&nbsp;that&nbsp;the&nbsp;above<br>
#&nbsp;copyright&nbsp;notice&nbsp;and&nbsp;this&nbsp;permission&nbsp;notice&nbsp;appear&nbsp;in&nbsp;all&nbsp;copies.<br>
#<br>
#&nbsp;THE&nbsp;SOFTWARE&nbsp;IS&nbsp;PROVIDED&nbsp;"AS&nbsp;IS"&nbsp;AND&nbsp;THE&nbsp;AUTHOR&nbsp;DISCLAIMS&nbsp;ALL&nbsp;WARRANTIES<br>
#&nbsp;WITH&nbsp;REGARD&nbsp;TO&nbsp;THIS&nbsp;SOFTWARE&nbsp;INCLUDING&nbsp;ALL&nbsp;IMPLIED&nbsp;WARRANTIES&nbsp;OF<br>
#&nbsp;MERCHANTABILITY&nbsp;AND&nbsp;FITNESS.&nbsp;IN&nbsp;NO&nbsp;EVENT&nbsp;SHALL&nbsp;THE&nbsp;AUTHOR&nbsp;BE&nbsp;LIABLE&nbsp;FOR<br>
#&nbsp;ANY&nbsp;SPECIAL,&nbsp;DIRECT,&nbsp;INDIRECT,&nbsp;OR&nbsp;CONSEQUENTIAL&nbsp;DAMAGES&nbsp;OR&nbsp;ANY&nbsp;DAMAGES<br>
#&nbsp;WHATSOEVER&nbsp;RESULTING&nbsp;FROM&nbsp;LOSS&nbsp;OF&nbsp;USE,&nbsp;DATA&nbsp;OR&nbsp;PROFITS,&nbsp;WHETHER&nbsp;IN&nbsp;AN<br>
#&nbsp;ACTION&nbsp;OF&nbsp;CONTRACT,&nbsp;NEGLIGENCE&nbsp;OR&nbsp;OTHER&nbsp;TORTIOUS&nbsp;ACTION,&nbsp;ARISING&nbsp;OUT&nbsp;OF<br>
#&nbsp;OR&nbsp;IN&nbsp;CONNECTION&nbsp;WITH&nbsp;THE&nbsp;USE&nbsp;OR&nbsp;PERFORMANCE&nbsp;OF&nbsp;THIS&nbsp;SOFTWARE.</tt></p>
<