(CommandList
  children: [
    (FuncDef
      name: printHelp
      body: 
        (BraceGroup
          children: [
            (C {(echo)} 
              {
                (DQ ('Usage: ') ($ VSub_Number '$0') (' -p 3 -i inputDirectory/ -x ') 
                  (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) ('command -to run/') (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>)
                )
              }
            )
            (C {(echo)} {(-e)} 
              {(DQ (Lit_Other '\\') ('t-p The maximum number of processes to start concurrently'))}
            )
            (C {(echo)} {(-e)} 
              {
                (DQ (Lit_Other '\\') ('t-i The directory containing the files to run the command on'))
              }
            )
            (C {(echo)} {(-e)} 
              {(DQ (Lit_Other '\\') ('t-x The command to run that the file will be appended to'))}
            )
            (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})
          ]
          spids: [9]
        )
      spids: [4 8]
    )
    (WhileUntil
      keyword: <KW_While while>
      cond: [(Sentence child:(C {(getopts)} {(DQ ('p:x:i:'))} {(opt)}) terminator:<Op_Semi ';'>)]
      body: 
        (DoGroup
          children: [
            (Case
              to_match: {(DQ ($ VSub_Name '$opt'))}
              arms: [
                (case_arm
                  pat_list: [{(p)}]
                  action: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:procs)
                          op: Equal
                          rhs: {(DQ ($ VSub_Name '$OPTARG'))}
                          spids: [89]
                        )
                      ]
                      spids: [89]
                    )
                  ]
                  spids: [85 87 94 16777215]
                )
                (case_arm
                  pat_list: [{(x)}]
                  action: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:command)
                          op: Equal
                          rhs: {(DQ ($ VSub_Name '$OPTARG'))}
                          spids: [101]
                        )
                      ]
                      spids: [101]
                    )
                  ]
                  spids: [97 99 106 16777215]
                )
                (case_arm
                  pat_list: [{(i)}]
                  action: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:inputdir)
                          op: Equal
                          rhs: {(DQ ($ VSub_Name '$OPTARG'))}
                          spids: [113]
                        )
                      ]
                      spids: [113]
                    )
                  ]
                  spids: [109 111 118 16777215]
                )
                (case_arm
                  pat_list: [{(Lit_Other '?')}]
                  action: [(C {(printHelp)})]
                  spids: [121 123 127 16777215]
                )
              ]
              spids: [76 82 130]
            )
          ]
          spids: [73 132]
        )
    )
    (If
      arms: [
        (if_arm
          cond: [
            (AndOr
              ops: [Op_DPipe Op_DPipe]
              children: [
                (DBracket
                  expr: (BoolUnary op_id:BoolUnary_z child:{($ VSub_Name '$procs')})
                )
                (DBracket
                  expr: (BoolUnary op_id:BoolUnary_z child:{($ VSub_Name '$command')})
                )
                (DBracket
                  expr: (BoolUnary op_id:BoolUnary_z child:{($ VSub_Name '$inputdir')})
                )
              ]
            )
          ]
          action: [(C {(echo)} {(DQ ('Invalid arguments'))}) (C {(printHelp)})]
          spids: [16777215 165]
        )
      ]
      spids: [16777215 177]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:total)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (CommandList
                    children: [
                      (Pipeline
                        children: [(C {(ls)} {($ VSub_Name '$inputdir')}) (C {(wc)} {(-l)})]
                        negated: F
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [181 191]
              )
            }
          spids: [180]
        )
      ]
      spids: [180]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:files)
          op: Equal
          rhs: 
            {
              (DQ 
                (CommandSubPart
                  command_list: 
                    (CommandList
                      children: [(C {(ls)} {(-Sr)} {($ VSub_Name '$inputdir')})]
                    )
                  left_token: <Left_CommandSub '$('>
                  spids: [195 201]
                )
              )
            }
          spids: [193]
        )
      ]
      spids: [193]
    )
    (ForEach
      iter_name: k
      iter_words: [
        {
          (CommandSubPart
            command_list: 
              (CommandList
                children: [(C {(seq)} {(1)} {($ VSub_Name '$procs')} {($ VSub_Name '$total')})]
              )
            left_token: <Left_CommandSub '$('>
            spids: [211 219]
          )
        }
      ]
      do_arg_iter: F
      body: 
        (DoGroup
          children: [
            (ForEach
              iter_name: i
              iter_words: [
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(seq)} {(0)} {($ VSub_Name '$procs')})])
                    left_token: <Left_CommandSub '$('>
                    spids: [230 236]
                  )
                }
              ]
              do_arg_iter: F
              body: 
                (DoGroup
                  children: [
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (C {(Lit_Other '[')} 
                              {
                                (ArithSubPart
                                  anode: 
                                    (ArithBinary
                                      op_id: Arith_Plus
                                      left: (ArithVarRef name:i)
                                      right: (ArithVarRef name:k)
                                    )
                                  spids: [246 251]
                                )
                              } {(-gt)} {($ VSub_Name '$total')} {(Lit_Other ']')}
                            )
                          ]
                          action: [
                            (C {(wait)})
                            (ControlFlow
                              token: <ControlFlow_Exit exit>
                              arg_word: {(0)}
                            )
                          ]
                          spids: [16777215 260]
                        )
                      ]
                      spids: [16777215 271]
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:file)
                          op: Equal
                          rhs: 
                            {
                              (CommandSubPart
                                command_list: 
                                  (CommandList
                                    children: [
                                      (Pipeline
                                        children: [
                                          (C {(echo)} {(DQ ($ VSub_Name '$files'))})
                                          (C {(sed)} 
                                            {
                                              (CommandSubPart
                                                command_list: 
                                                  (CommandList
                                                    children: [
                                                      (C {(expr)} {($ VSub_Name '$i')} {(Lit_Other '+')} 
                                                        {($ VSub_Name '$k')}
                                                      )
                                                    ]
                                                  )
                                                left_token: <Left_CommandSub '$('>
                                                spids: [287 295]
                                              ) (DQ ('q;d'))
                                            }
                                          )
                                        ]
                                        negated: F
                                      )
                                    ]
                                  )
                                left_token: <Left_CommandSub '$('>
                                spids: [276 299]
                              )
                            }
                          spids: [275]
                        )
                      ]
                      spids: [275]
                    )
                    (C {(echo)} 
                      {
                        (DQ ('Running ') ($ VSub_Name '$command') (' ') ($ VSub_Name '$inputdir') (/) 
                          ($ VSub_Name '$file')
                        )
                      }
                    )
                    (Sentence
                      child: 
                        (C {($ VSub_Name '$command')} 
                          {(DQ ($ VSub_Name '$inputdir') (/) ($ VSub_Name '$file'))}
                        )
                      terminator: <Op_Amp '&'>
                    )
                  ]
                  spids: [239 324]
                )
              spids: [229 16777215]
            )
            (C {(wait)})
          ]
          spids: [221 330]
        )
      spids: [210 16777215]
    )
  ]
)