(command.CommandList
  children: [
    (C {<Id.KW_Set set>} {<-o>} {<nounset>})
    (C {<Id.KW_Set set>} {<-o>} {<pipefail>})
    (C {<Id.KW_Set set>} {<-o>} {<errexit>})
    (C {<source>} {<'test/common.sh'>})
    (C {<source>} {<'benchmarks/common.sh'>})
    (C {<readonly>} {<Id.Lit_VarLike 'BASE_DIR='> <'_tmp/oheap'>})
    (command.ShFunction
      name: encode-one
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'script='> ($ Id.VSub_Number '$1')})
            (C {<local>} {<Id.Lit_VarLike 'oheap_out='> ($ Id.VSub_Number '$2')})
            (command.Simple
              words: [
                {($ Id.VSub_DollarName '$OSH_OVM')}
                {<-n>}
                {<--ast-format>}
                {<oheap>}
                {(DQ ($ Id.VSub_DollarName '$script'))}
              ]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$oheap_out')}
                )
              ]
              do_fork: T
            )
          ]
        )
    )
    (command.ShFunction
      name: task-spec
      body: 
        (BraceGroup
          children: [
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: [(command.Sentence child:(C {<read>} {<path>}) terminator:<Id.Op_Semi _>)]
              body: 
                (command.DoGroup
                  children: [
                    (C {<echo>} 
                      {
                        (DQ ($ Id.VSub_DollarName '$path') <' _tmp/oheap/'> 
                          (command_sub
                            left_token: <Id.Left_DollarParen '$('>
                            child: (C {<basename>} {($ Id.VSub_DollarName '$path')})
                          ) <__oheap>
                        )
                      }
                    )
                  ]
                )
              redirects: [
                (redir
                  op: <Id.Redir_Less '<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: {<'benchmarks/osh-parser-files.txt'>}
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: encode-all
      body: 
        (BraceGroup
          children: [
            (C {<mkdir>} {<-p>} {<'_tmp/oheap'>})
            (C {<local>} {<Id.Lit_VarLike 'times_csv='> <'_tmp/oheap/times.csv'>})
            (command.Simple
              words: [{<echo>} {(SQ <'status,elapsed_secs'>)}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$times_csv')}
                )
              ]
              do_fork: T
            )
            (command.Pipeline
              children: [
                (C {<task-spec>})
                (C {<xargs>} {<-n>} {<2>} {<--verbose>} {<-->} {<'benchmarks/time.py'>} {<--output>} 
                  {($ Id.VSub_DollarName '$times_csv')} {<-->} {($ Id.VSub_Number '$0')} {<encode-one>}
                )
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: compress-oheap
      body: 
        (BraceGroup
          children: [
            (C {<local>} 
              {<Id.Lit_VarLike 'c_dir='> ($ Id.VSub_DollarName '$BASE_DIR') <'/oheap-compressed'>}
            )
            (C {<mkdir>} {<-p>} {($ Id.VSub_DollarName '$c_dir')})
            (command.ForEach
              iter_name: bin
              iter_words: [{<'_tmp/oheap/'> <Id.Lit_Star '*'> <__oheap>}]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (C {<local>} 
                      {<Id.Lit_VarLike 'name='> 
                        (command_sub
                          left_token: <Id.Left_DollarParen '$('>
                          child: (C {<basename>} {($ Id.VSub_DollarName '$bin')})
                        )
                      }
                    )
                    (C {<log>} {(DQ <'Compressing '> ($ Id.VSub_DollarName '$name'))})
                    (command.Simple
                      words: [{<gzip>} {<--stdout>} {($ Id.VSub_DollarName '$bin')}]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: 
                            {($ Id.VSub_DollarName '$c_dir') <'/'> ($ Id.VSub_DollarName '$name') <.gz>}
                        )
                      ]
                      do_fork: T
                    )
                    (command.Simple
                      words: [{<xz>} {<--stdout>} {($ Id.VSub_DollarName '$bin')}]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: 
                            {($ Id.VSub_DollarName '$c_dir') <'/'> ($ Id.VSub_DollarName '$name') <.xz>}
                        )
                      ]
                      do_fork: T
                    )
                  ]
                )
            )
          ]
        )
    )
    (command.ShFunction
      name: compress-text
      body: 
        (BraceGroup
          children: [
            (C {<local>} 
              {<Id.Lit_VarLike 'c_dir='> ($ Id.VSub_DollarName '$BASE_DIR') <'/src-compressed'>}
            )
            (C {<mkdir>} {<-p>} {($ Id.VSub_DollarName '$c_dir')})
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: [(command.Sentence child:(C {<read>} {<src>}) terminator:<Id.Op_Semi _>)]
              body: 
                (command.DoGroup
                  children: [
                    (C {<local>} 
                      {<Id.Lit_VarLike 'name='> 
                        (command_sub
                          left_token: <Id.Left_DollarParen '$('>
                          child: (C {<basename>} {($ Id.VSub_DollarName '$src')})
                        )
                      }
                    )
                    (C {<log>} {(DQ <'Compressing '> ($ Id.VSub_DollarName '$name'))})
                    (command.Simple
                      words: [{<gzip>} {<--stdout>} {($ Id.VSub_DollarName '$src')}]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: 
                            {($ Id.VSub_DollarName '$c_dir') <'/'> (${ Id.VSub_Name name) <__text.gz>}
                        )
                      ]
                      do_fork: T
                    )
                    (command.Simple
                      words: [{<xz>} {<--stdout>} {($ Id.VSub_DollarName '$src')}]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: 
                            {($ Id.VSub_DollarName '$c_dir') <'/'> (${ Id.VSub_Name name) <__text.xz>}
                        )
                      ]
                      do_fork: T
                    )
                  ]
                )
              redirects: [
                (redir
                  op: <Id.Redir_Less '<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: {<'benchmarks/osh-parser-files.txt'>}
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: print-size
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'c1='> ($ Id.VSub_Number '$1')})
            (C {<local>} {<Id.Lit_VarLike 'c2='> ($ Id.VSub_Number '$2')})
            (C {<shift>} {<2>})
            (C {<find>} {(DQ ($ Id.VSub_At '$@'))} {<-maxdepth>} {<0>} {<-printf>} 
              {
                (DQ <'%s,'> ($ Id.VSub_DollarName '$c1') <','> ($ Id.VSub_DollarName '$c2') <',%p'> 
                  <Id.Lit_Other '\\'> <n>
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: print-csv
      body: 
        (BraceGroup
          children: [
            (C {<echo>} {(SQ <'num_bytes,format,compression,path'>)})
            (C {<print-size>} {<text>} {<none>} {<'benchmarks/testdata/'> <Id.Lit_Star '*'>})
            (C {<print-size>} {<text>} {<gz>} 
              {($ Id.VSub_DollarName '$BASE_DIR') <'/src-compressed/'> <Id.Lit_Star '*'> <.gz>}
            )
            (C {<print-size>} {<text>} {<xz>} 
              {($ Id.VSub_DollarName '$BASE_DIR') <'/src-compressed/'> <Id.Lit_Star '*'> <.xz>}
            )
            (C {<print-size>} {<oheap>} {<none>} 
              {($ Id.VSub_DollarName '$BASE_DIR') <'/'> <Id.Lit_Star '*'> <__oheap>}
            )
            (C {<print-size>} {<oheap>} {<gz>} 
              {($ Id.VSub_DollarName '$BASE_DIR') <'/oheap-compressed/'> <Id.Lit_Star '*'> <.gz>}
            )
            (C {<print-size>} {<oheap>} {<xz>} 
              {($ Id.VSub_DollarName '$BASE_DIR') <'/oheap-compressed/'> <Id.Lit_Star '*'> <.xz>}
            )
          ]
        )
    )
    (command.ShFunction
      name: measure
      body: (BraceGroup children:[(C {<encode-all>}) (C {<compress-oheap>}) (C {<compress-text>})])
    )
    (command.ShFunction
      name: stage1
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'out_dir='> ($ Id.VSub_DollarName '$BASE_DIR') <'/stage1'>})
            (C {<mkdir>} {<-p>} {($ Id.VSub_DollarName '$out_dir')})
            (command.Simple
              words: [{<print-csv>}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {($ Id.VSub_DollarName '$out_dir') <'/sizes.csv'>}
                )
              ]
              do_fork: T
            )
          ]
        )
    )
    (command.ShFunction
      name: print-report
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<Id.Lit_VarLike 'in_dir='> ($ Id.VSub_Number '$1')})
            (C {<local>} {<Id.Lit_VarLike 'base_url='> (SQ <'../../web'>)})
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.MultiLine
                      here_begin: {<EOF>}
                      here_end_span_id: 667
                      stdin_parts: [
                        <'<!DOCTYPE html>\n'>
                        <'<html>\n'>
                        <'  <head>\n'>
                        <'    <title>OHeap Encoding</title>\n'>
                        <'    <script type='>
                        <Id.Right_DoubleQuote '"'>
                        <'text/javascript'>
                        <Id.Right_DoubleQuote '"'>
                        <' src='>
                        <Id.Right_DoubleQuote '"'>
                        ($ Id.VSub_DollarName '$base_url')
                        <'/table/table-sort.js'>
                        <Id.Right_DoubleQuote '"'>
                        <'></script>\n'>
                        <'    <link rel='>
                        <Id.Right_DoubleQuote '"'>
                        <stylesheet>
                        <Id.Right_DoubleQuote '"'>
                        <' type='>
                        <Id.Right_DoubleQuote '"'>
                        <'text/css'>
                        <Id.Right_DoubleQuote '"'>
                        <' href='>
                        <Id.Right_DoubleQuote '"'>
                        ($ Id.VSub_DollarName '$base_url')
                        <'/table/table-sort.css'>
                        <Id.Right_DoubleQuote '"'>
                        <' />\n'>
                        <'    <link rel='>
                        <Id.Right_DoubleQuote '"'>
                        <stylesheet>
                        <Id.Right_DoubleQuote '"'>
                        <' type='>
                        <Id.Right_DoubleQuote '"'>
                        <'text/css'>
                        <Id.Right_DoubleQuote '"'>
                        <' href='>
                        <Id.Right_DoubleQuote '"'>
                        ($ Id.VSub_DollarName '$base_url')
                        <'/benchmarks.css'>
                        <Id.Right_DoubleQuote '"'>
                        <' />\n'>
                        <'\n'>
                        <'  </head>\n'>
                        <'  <body>\n'>
                        <'    <p id='>
                        <Id.Right_DoubleQuote '"'>
                        <home-link>
                        <Id.Right_DoubleQuote '"'>
                        <'>\n'>
                        <'      <a href='>
                        <Id.Right_DoubleQuote '"'>
                        <'/'>
                        <Id.Right_DoubleQuote '"'>
                        <'>oilshell.org</a>\n'>
                        <'    </p>\n'>
                        <'    <h2>OHeap Encoding</h2>\n'>
                        <'\n'>
                        <'    <h3>Encoding Size (KB)</h3>\n'>
                        <'\n'>
                        <'    <p>Sizes are in KB (powers of 10), not KiB (powers of 2).</p>\n'>
                      ]
                    )
                )
              ]
              do_fork: T
            )
            (C {<csv2html>} {($ Id.VSub_DollarName '$in_dir') <'/encoding_size.csv'>})
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.MultiLine
                      here_begin: {<EOF>}
                      here_end_span_id: 683
                      stdin_parts: [<'    <h3>Encoding Ratios</h3>\n'>]
                    )
                )
              ]
              do_fork: T
            )
            (C {<csv2html>} {($ Id.VSub_DollarName '$in_dir') <'/encoding_ratios.csv'>})
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.MultiLine
                      here_begin: {<EOF>}
                      here_end_span_id: 700
                      stdin_parts: [<'  </body>\n'> <'</html>\n'>]
                    )
                )
              ]
              do_fork: T
            )
          ]
        )
    )
    (command.ShFunction
      name: decode
      body: 
        (BraceGroup
          children: [
            (command.ForEach
              iter_name: bin
              iter_words: [{<'_tmp/oheap/'> <Id.Lit_Star '*'> <.oheap>}]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (command.TimeBlock
                      pipeline: 
                        (command.Pipeline
                          children: [
                            (C {<'_tmp/osh_demo'>} {($ Id.VSub_DollarName '$bin')})
                            (C {<wc>} {<-l>})
                          ]
                          negated: F
                        )
                    )
                  ]
                )
            )
          ]
        )
    )
    (C {(DQ ($ Id.VSub_At '$@'))})
  ]
)