(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:DIR)
          op: assign_op.Equal
          rhs: 
            {
              (DQ 
                (command_sub
                  left_token: <Id.Left_DollarParen '$('>
                  command_list: 
                    (command.CommandList
                      children: [
                        (command.AndOr
                          ops: [Id.Op_DAmp]
                          children: [
                            (C {<cd>} 
                              {
                                (DQ 
                                  (command_sub
                                    left_token: <Id.Left_DollarParen '$('>
                                    command_list: 
                                      (command.CommandList
                                        children: [
                                          (C {<dirname>} 
                                            {
                                              (DQ 
                                                (braced_var_sub
                                                  token: <Id.VSub_Name BASH_SOURCE>
                                                  bracket_op: 
                                                    (bracket_op.ArrayIndex
                                                      expr: 
                                                        (arith_expr.ArithWord
                                                          w: {<Id.Lit_Digits 0>}
                                                        )
                                                    )
                                                )
                                              )
                                            }
                                          )
                                        ]
                                      )
                                  )
                                )
                              }
                            )
                            (C {<pwd>})
                          ]
                        )
                      ]
                    )
                )
              )
            }
          spids: [21]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:REOPT)
          op: assign_op.Equal
          rhs: {(DQ )}
          spids: [52]
        )
      ]
    )
    (command.ShAssignment
      pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:REC) op:assign_op.Equal rhs:{(DQ )} spids:[57])]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Unary
                      op_id: Id.BoolUnary_f
                      child: {($ Id.VSub_DollarName '$DIR') </reopt.sh>}
                    )
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:REOPT)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_DollarName '$DIR') </reopt.sh>)}
                  spids: [77]
                )
              ]
            )
          ]
          spids: [62 74]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Unary
                      op_id: Id.BoolUnary_f
                      child: {($ Id.VSub_DollarName '$DIR') </reopt>}
                    )
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:REOPT)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_DollarName '$DIR') </reopt>)}
                  spids: [101]
                )
              ]
            )
          ]
          spids: [86 98]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ ($ Id.VSub_DollarName '$REOPT'))} 
                  {<Id.Lit_RBracket ']'>}
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (C {<echo>} {(DQ <"Couldn't find reopt">)})
            (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
          ]
          spids: [110 123]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Unary
                      op_id: Id.BoolUnary_f
                      child: {($ Id.VSub_DollarName '$DIR') </rec.sh>}
                    )
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:REC)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_DollarName '$DIR') </rec.sh>)}
                  spids: [155]
                )
              ]
            )
          ]
          spids: [140 152]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Unary
                      op_id: Id.BoolUnary_f
                      child: {($ Id.VSub_DollarName '$DIR') </rec>}
                    )
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:REC)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_DollarName '$DIR') </rec>)}
                  spids: [179]
                )
              ]
            )
          ]
          spids: [164 176]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ ($ Id.VSub_DollarName '$REC'))} 
                  {<Id.Lit_RBracket ']'>}
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (C {<echo>} {(DQ <"Couldn't find rec">)})
            (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
          ]
          spids: [188 201]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:OCAMLOPTIDX)
          op: assign_op.Equal
          rhs: {<-1>}
          spids: [225]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:OCAMLCIDX)
          op: assign_op.Equal
          rhs: {<-1>}
          spids: [228]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:USEOCAMLFIND)
          op: assign_op.Equal
          rhs: {<-1>}
          spids: [231]
        )
      ]
    )
    (command.ShAssignment
      pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:i) op:assign_op.Equal rhs:{<1>} spids:[238])]
    )
    (command.ForEach
      iter_name: var
      iter_words: [{(DQ ($ Id.VSub_At '$@'))}]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_GlobEqual
                              left: {($ Id.VSub_DollarName '$var')}
                              right: {(DQ <-ocamlopt>)}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:OCAMLOPTIDX)
                          op: assign_op.Equal
                          rhs: {($ Id.VSub_DollarName '$i')}
                          spids: [273]
                        )
                      ]
                    )
                  ]
                  spids: [254 270]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_GlobEqual
                              left: {($ Id.VSub_DollarName '$var')}
                              right: {(DQ <-ocamlc>)}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:OCAMLCIDX)
                          op: assign_op.Equal
                          rhs: {($ Id.VSub_DollarName '$i')}
                          spids: [300]
                        )
                      ]
                    )
                  ]
                  spids: [281 297]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_GlobEqual
                              left: {($ Id.VSub_DollarName '$var')}
                              right: {(DQ <-use-ocamlfind>)}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:USEOCAMLFIND)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [327]
                        )
                      ]
                    )
                  ]
                  spids: [308 324]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:i)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_DollarName '$i') <Id.Lit_Other '+'> <1>}
                  spids: [334]
                )
              ]
            )
          ]
        )
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:OCAMLOPT)
          op: assign_op.Equal
          rhs: {(DQ <ocamlopt.opt>)}
          spids: [345]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_ne
                      left: {($ Id.VSub_DollarName '$OCAMLOPTIDX')}
                      right: {<-1>}
                    )
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:VALUEIDX)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (word_part.ArithSub
                        anode: 
                          (arith_expr.Binary
                            op_id: Id.Arith_Plus
                            left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike OCAMLOPTIDX>)
                            right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                          )
                      )
                    }
                  spids: [370]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:OCAMLOPT)
                  op: assign_op.Equal
                  rhs: {(braced_var_sub token:<Id.VSub_Name VALUEIDX> prefix_op:(Id.VSub_Bang))}
                  spids: [379]
                )
              ]
            )
            (C {<Id.KW_Set set>} {<-->} 
              {
                (DQ 
                  (braced_var_sub
                    token: <Id.VSub_At '@'>
                    suffix_op: 
                      (suffix_op.Slice
                        begin: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                        length: 
                          (arith_expr.Binary
                            op_id: Id.Arith_Minus
                            left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike OCAMLOPTIDX>)
                            right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                          )
                      )
                  )
                )
              } 
              {
                (DQ 
                  (braced_var_sub
                    token: <Id.VSub_At '@'>
                    suffix_op: 
                      (suffix_op.Slice
                        begin: 
                          (arith_expr.Binary
                            op_id: Id.Arith_Plus
                            left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike VALUEIDX>)
                            right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                          )
                      )
                  )
                )
              }
            )
          ]
          spids: [350 363]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:OCAMLC)
          op: assign_op.Equal
          rhs: {(DQ <ocamlc.opt>)}
          spids: [423]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_ne
                      left: {($ Id.VSub_DollarName '$OCAMLCIDX')}
                      right: {<-1>}
                    )
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:VALUEIDX)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (word_part.ArithSub
                        anode: 
                          (arith_expr.Binary
                            op_id: Id.Arith_Plus
                            left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike OCAMLCIDX>)
                            right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                          )
                      )
                    }
                  spids: [448]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:OCAMLC)
                  op: assign_op.Equal
                  rhs: {(braced_var_sub token:<Id.VSub_Name VALUEIDX> prefix_op:(Id.VSub_Bang))}
                  spids: [457]
                )
              ]
            )
            (C {<Id.KW_Set set>} {<-->} 
              {
                (DQ 
                  (braced_var_sub
                    token: <Id.VSub_At '@'>
                    suffix_op: 
                      (suffix_op.Slice
                        begin: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                        length: 
                          (arith_expr.Binary
                            op_id: Id.Arith_Minus
                            left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike OCAMLCIDX>)
                            right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                          )
                      )
                  )
                )
              } 
              {
                (DQ 
                  (braced_var_sub
                    token: <Id.VSub_At '@'>
                    suffix_op: 
                      (suffix_op.Slice
                        begin: 
                          (arith_expr.Binary
                            op_id: Id.Arith_Plus
                            left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike VALUEIDX>)
                            right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                          )
                      )
                  )
                )
              }
            )
          ]
          spids: [428 441]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_ne
                      left: {($ Id.VSub_DollarName '$USEOCAMLFIND')}
                      right: {<-1>}
                    )
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (C {<env>} 
              {<Id.Lit_VarLike 'OCAMLFIND_COMMANDS='> 
                (DQ <'ocamlopt='> ($ Id.VSub_DollarName '$REOPT') <' ocamlc='> 
                  ($ Id.VSub_DollarName '$REC')
                )
              } {<reasonbuild>} {(DQ ($ Id.VSub_At '$@'))}
            )
          ]
          spids: [498 511]
        )
      ]
      else_action: [
        (C {<reasonbuild>} {<-ocamlopt>} 
          {
            (DQ <'env OCAMLOPT='> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
              ($ Id.VSub_DollarName '$OCAMLOPT') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <' '> ($ Id.VSub_DollarName '$REOPT')
            )
          } {<-ocamlc>} 
          {
            (DQ <'env OCAMLC='> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
              ($ Id.VSub_DollarName '$OCAMLC') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <' '> ($ Id.VSub_DollarName '$REC')
            )
          } {(DQ ($ Id.VSub_At '$@'))}
        )
      ]
    )
  ]
)