(command.CommandList
  children: [
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (command.AndOr
                  ops: [Id.Op_DPipe]
                  children: [
                    (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_Number '$1'))} 
                      {<Id.Lit_Equals '='> <Id.Lit_Equals '='>} {(DQ <--verbose>)} {<Id.Lit_RBracket ']'>}
                    )
                    (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_Number '$1'))} 
                      {<Id.Lit_Equals '='> <Id.Lit_Equals '='>} {(DQ <-v>)} {<Id.Lit_RBracket ']'>}
                    )
                  ]
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (C {<shift>} {<1>})
            (command.ShFunction
              name: debug
              body: 
                (BraceGroup
                  children: [
                    (command.Sentence
                      child: (C {<echo>} {(DQ ($ Id.VSub_Star '$*'))})
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
            )
          ]
          spids: [14 49]
        )
      ]
      else_action: [
        (command.ShFunction
          name: debug
          body: 
            (BraceGroup
              children: [(command.Sentence child:(C {<Id.Lit_Colon ':'>}) terminator:<Id.Op_Semi _>)]
            )
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {<Id.Lit_LBracket '['>} {<-z>} {(DQ ($ Id.VSub_Number '$1'))} {<Id.Lit_RBracket ']'>})
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (C {<echo>} {(DQ <'Usage: '> ($ Id.VSub_Number '$0') <' <private_libdir>'>)})
            (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
          ]
          spids: [86 99]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:UNAME)
          op: assign_op.Equal
          rhs: {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<uname>} {<-s>})))}
          spids: [118]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$UNAME'))} {<Id.Lit_Equals '='>} 
                  {(DQ <Linux>)} {<Id.Lit_RBracket ']'>}
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:SHLIB_EXT)
                  op: assign_op.Equal
                  rhs: {(DQ <so>)}
                  spids: [147]
                )
              ]
            )
          ]
          spids: [127 144]
        )
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$UNAME'))} {<Id.Lit_Equals '='>} 
                  {(DQ <Darwin>)} {<Id.Lit_RBracket ']'>}
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:SHLIB_EXT)
                  op: assign_op.Equal
                  rhs: {(DQ <dylib>)}
                  spids: [172]
                )
              ]
            )
          ]
          spids: [152 169]
        )
      ]
      else_action: [
        (command.Simple
          words: [
            {<echo>}
            {
              (DQ <'WARNING: Could not autodetect platform type (\'uname -s\' == '> 
                ($ Id.VSub_DollarName '$UNAME') <'); assuming Linux'>
              )
            }
          ]
          redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
          do_fork: T
        )
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:UNAME)
              op: assign_op.Equal
              rhs: {(DQ <Linux>)}
              spids: [192]
            )
          ]
        )
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:SHLIB_EXT)
              op: assign_op.Equal
              rhs: {(DQ <so>)}
              spids: [198]
            )
          ]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:private_libdir)
          op: assign_op.Equal
          rhs: {($ Id.VSub_Number '$1')}
          spids: [206]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-f>} 
                  {
                    (DQ ($ Id.VSub_DollarName '$private_libdir') <'/libarpack.'> 
                      ($ Id.VSub_DollarName '$SHLIB_EXT')
                    )
                  } {<Id.Lit_RBracket ']'>}
                )
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.Simple
              words: [
                {<echo>}
                {
                  (DQ <'ERROR: Could not open '> ($ Id.VSub_DollarName '$private_libdir') 
                    <'/libarpack.'> ($ Id.VSub_DollarName '$SHLIB_EXT')
                  )
                }
              ]
              redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
              do_fork: T
            )
            (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<2>})
          ]
          spids: [210 227]
        )
      ]
    )
    (command.ShFunction
      name: find_shlib
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:lib_path)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_Number '$1'))}
                  spids: [257]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<-f>} {(DQ ($ Id.VSub_DollarName '$lib_path'))} 
                          {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$UNAME'))} 
                                  {<Id.Lit_Equals '='>} {(DQ <Linux>)} {<Id.Lit_RBracket ']'>}
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                          action: [
                            (command.Pipeline
                              children: [
                                (C {<ldd>} {(DQ ($ Id.VSub_DollarName '$lib_path'))})
                                (C {<grep>} {($ Id.VSub_Number '$2')})
                                (C {<cut>} {<-d> (SQ <' '>)} {<-f3>})
                                (C {<xargs>})
                              ]
                              negated: F
                            )
                          ]
                          spids: [279 296]
                        )
                      ]
                      else_action: [
                        (command.Pipeline
                          children: [
                            (C {<otool>} {<-L>} {(DQ ($ Id.VSub_DollarName '$lib_path'))})
                            (C {<grep>} {($ Id.VSub_Number '$2')})
                            (C {<cut>} {<-d> (SQ <' '>)} {<-f1>})
                            (C {<xargs>})
                          ]
                          negated: F
                        )
                      ]
                    )
                  ]
                  spids: [263 276]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: private_libname
      body: 
        (BraceGroup
          children: [
            (C {<echo>} 
              {
                (DQ ($ Id.VSub_DollarName '$private_libdir') <'/lib'> ($ Id.VSub_Number '$1') <.> 
                  ($ Id.VSub_DollarName '$SHLIB_EXT')
                )
              }
            )
          ]
        )
    )
    (command.ForEach
      iter_name: lib
      iter_words: [{<arpack>} {<lapack>}]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<-f>} 
                          {
                            (DQ ($ Id.VSub_DollarName '$private_libdir') <'/lib'> 
                              ($ Id.VSub_DollarName '$lib') <.> ($ Id.VSub_DollarName '$SHLIB_EXT')
                            )
                          } {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:LIBGFORTRAN_PATH)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (command_sub
                                left_token: <Id.Left_DollarParen '$('>
                                child: 
                                  (C {<find_shlib>} 
                                    {
                                      (DQ 
                                        (command_sub
                                          left_token: <Id.Left_DollarParen '$('>
                                          child: 
                                            (C {<private_libname>} {($ Id.VSub_DollarName '$lib')})
                                        )
                                      )
                                    } {<libgfortran>}
                                  )
                              )
                            }
                          spids: [436]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:LIBGCC_PATH)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (command_sub
                                left_token: <Id.Left_DollarParen '$('>
                                child: 
                                  (C {<find_shlib>} 
                                    {
                                      (DQ 
                                        (command_sub
                                          left_token: <Id.Left_DollarParen '$('>
                                          child: 
                                            (C {<private_libname>} {($ Id.VSub_DollarName '$lib')})
                                        )
                                      )
                                    } {<libgcc_s>}
                                  )
                              )
                            }
                          spids: [452]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:LIBQUADMATH_PATH)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (command_sub
                                left_token: <Id.Left_DollarParen '$('>
                                child: 
                                  (C {<find_shlib>} 
                                    {
                                      (DQ 
                                        (command_sub
                                          left_token: <Id.Left_DollarParen '$('>
                                          child: 
                                            (C {<private_libname>} {($ Id.VSub_DollarName '$lib')})
                                        )
                                      )
                                    } {<libquadmath>}
                                  )
                              )
                            }
                          spids: [468]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:LIBGFORTRAN_DIRS)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ ($ Id.VSub_DollarName '$LIBGFORTRAN_DIRS') <' '> 
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  child: (C {<dirname>} {($ Id.VSub_DollarName '$LIBGFORTRAN_PATH')})
                                )
                              )
                            }
                          spids: [493]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:LIBGFORTRAN_DIRS)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ ($ Id.VSub_DollarName '$LIBGFORTRAN_DIRS') <' '> 
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  child: (C {<dirname>} {($ Id.VSub_DollarName '$LIBGCC_PATH')})
                                )
                              )
                            }
                          spids: [505]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:LIBGFORTRAN_DIRS)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ ($ Id.VSub_DollarName '$LIBGFORTRAN_DIRS') <' '> 
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  child: (C {<dirname>} {($ Id.VSub_DollarName '$LIBQUADMATH_PATH')})
                                )
                              )
                            }
                          spids: [517]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:LIBGFORTRAN_SONAMES)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ ($ Id.VSub_DollarName '$LIBGFORTRAN_SONAMES') <' '> 
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  child: 
                                    (C {<basename>} {(DQ ($ Id.VSub_DollarName '$LIBGFORTRAN_PATH'))})
                                )
                              )
                            }
                          spids: [534]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:LIBGCC_SONAMES)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ ($ Id.VSub_DollarName '$LIBGCC_SONAMES') <' '> 
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  child: (C {<basename>} {(DQ ($ Id.VSub_DollarName '$LIBGCC_PATH'))})
                                )
                              )
                            }
                          spids: [548]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:LIBQUADMATH_SONAMES)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ ($ Id.VSub_DollarName '$LIBQUADMATH_SONAMES') <' '> 
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  child: 
                                    (C {<basename>} {(DQ ($ Id.VSub_DollarName '$LIBQUADMATH_PATH'))})
                                )
                              )
                            }
                          spids: [562]
                        )
                      ]
                    )
                  ]
                  spids: [408 425]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: uniquify
      body: 
        (BraceGroup
          children: [
            (command.Pipeline
              children: [
                (C {<echo>} {(DQ ($ Id.VSub_Number '$1'))})
                (C {<tr>} {(DQ <' '>)} {(DQ <Id.Lit_Other '\\'> <n>)})
                (C {<sort>})
                (C {<uniq>})
                (C {<grep>} {<-v>} {(SQ <'^$'>)})
                (C {<tr>} {(DQ <Id.Lit_Other '\\'> <n>)} {(DQ <' '>)})
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:LIBGFORTRAN_DIRS)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_DollarParen '$('>
                child: (C {<uniquify>} {(DQ ($ Id.VSub_DollarName '$LIBGFORTRAN_DIRS'))})
              )
            }
          spids: [644]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:SONAMES)
          op: assign_op.Equal
          rhs: 
            {
              (DQ 
                (command_sub
                  left_token: <Id.Left_DollarParen '$('>
                  child: 
                    (C {<uniquify>} 
                      {
                        (DQ ($ Id.VSub_DollarName '$LIBGFORTRAN_SONAMES') <' '> 
                          ($ Id.VSub_DollarName '$LIBGCC_SONAMES') <' '> ($ Id.VSub_DollarName '$LIBQUADMATH_SONAMES')
                        )
                      }
                    )
                )
              )
            }
          spids: [653]
        )
      ]
    )
    (C {<debug>} 
      {(DQ <'Discovered traces of libgfortran within '> ($ Id.VSub_DollarName '$LIBGFORTRAN_DIRS'))}
    )
    (C {<debug>} {(DQ <'Got SONAMES of '> ($ Id.VSub_DollarName '$SONAMES'))})
    (command.ForEach
      iter_name: soname
      iter_words: [{($ Id.VSub_DollarName '$SONAMES')}]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.ForEach
              iter_name: dir
              iter_words: [{($ Id.VSub_DollarName '$LIBGFORTRAN_DIRS')}]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (command.AndOr
                                  ops: [Id.Op_DAmp]
                                  children: [
                                    (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-f>} 
                                      {
                                        (DQ ($ Id.VSub_DollarName '$private_libdir') <'/'> 
                                          ($ Id.VSub_DollarName '$soname')
                                        )
                                      } {<Id.Lit_RBracket ']'>}
                                    )
                                    (C {<Id.Lit_LBracket '['>} {<-f>} 
                                      {
                                        (DQ ($ Id.VSub_DollarName '$dir') <'/'> 
                                          ($ Id.VSub_DollarName '$soname')
                                        )
                                      } {<Id.Lit_RBracket ']'>}
                                    )
                                  ]
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                          action: [
                            (C {<cp>} {<-v>} 
                              {
                                (DQ ($ Id.VSub_DollarName '$dir') <'/'> 
                                  ($ Id.VSub_DollarName '$soname')
                                )
                              } {(DQ ($ Id.VSub_DollarName '$private_libdir'))}
                            )
                            (C {<chmod>} {<755>} 
                              {
                                (DQ ($ Id.VSub_DollarName '$private_libdir') <'/'> 
                                  ($ Id.VSub_DollarName '$soname')
                                )
                              }
                            )
                            (command.If
                              arms: [
                                (if_arm
                                  cond: [
                                    (command.Sentence
                                      child: 
                                        (C {<Id.Lit_LBracket '['>} 
                                          {(DQ ($ Id.VSub_DollarName '$UNAME'))} {<Id.Lit_Equals '='>} {(DQ <Darwin>)} {<Id.Lit_RBracket ']'>}
                                        )
                                      terminator: <Id.Op_Semi _>
                                    )
                                  ]
                                  action: [
                                    (C {<install_name_tool>} {<-id>} 
                                      {(DQ <'@rpath/'> ($ Id.VSub_DollarName '$soname'))} {(DQ ($ Id.VSub_DollarName '$private_libdir') <'/'> ($ Id.VSub_DollarName '$soname'))}
                                    )
                                  ]
                                  spids: [770 787]
                                )
                              ]
                            )
                          ]
                          spids: [710 741]
                        )
                      ]
                    )
                  ]
                )
            )
          ]
        )
    )
    (command.ShFunction
      name: change_linkage
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:lib_path)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_Number '$1'))}
                  spids: [840]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {<Id.KW_Bang '!'>} {<-f>} 
                          {(DQ ($ Id.VSub_DollarName '$lib_path'))} {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (C {<debug>} 
                      {(DQ <'  '> ($ Id.VSub_DollarName '$lib_path') <' doesn\'t exist, skipping'>)}
                    )
                    (command.ControlFlow token:<Id.ControlFlow_Return return>)
                  ]
                  spids: [851 866]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:soname)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_Number '$2'))}
                  spids: [889]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$UNAME'))} 
                          {<Id.Lit_Equals '='>} {(DQ <Darwin>)} {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:old_link)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (command_sub
                                left_token: <Id.Left_DollarParen '$('>
                                child: 
                                  (C {<find_shlib>} {(DQ ($ Id.VSub_DollarName '$lib_path'))} 
                                    {(DQ ($ Id.VSub_DollarName '$soname'))}
                                  )
                              )
                            }
                          spids: [916]
                        )
                      ]
                    )
                    (C {<echo>} {(DQ <' '> ($ Id.VSub_DollarName '$old_link'))})
                    (C {<install_name_tool>} {<-change>} {(DQ ($ Id.VSub_DollarName '$old_link'))} 
                      {(DQ <'@rpath/'> ($ Id.VSub_DollarName '$soname'))} {(DQ ($ Id.VSub_DollarName '$lib_path'))}
                    )
                  ]
                  spids: [896 913]
                )
              ]
              else_action: [
                (C {<patchelf>} {<--set-rpath>} 
                  {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\$'>) <ORIGIN>} {(DQ ($ Id.VSub_DollarName '$lib_path'))}
                )
              ]
            )
          ]
        )
    )
    (command.ForEach
      iter_name: lib
      iter_words: [
        {<libopenblas>}
        {<libarpack>}
        {<libcholmod>}
        {<liblapack>}
        {($ Id.VSub_DollarName '$SONAMES')}
      ]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.ForEach
              iter_name: lib_path
              iter_words: [
                {($ Id.VSub_DollarName '$private_libdir') <'/'> ($ Id.VSub_DollarName '$lib') 
                  <Id.Lit_Star '*'>
                }
              ]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (command.ForEach
                      iter_name: soname
                      iter_words: [{($ Id.VSub_DollarName '$SONAMES')}]
                      do_arg_iter: F
                      body: 
                        (command.DoGroup
                          children: [
                            (C {<debug>} 
                              {
                                (DQ <'changing linkage of '> ($ Id.VSub_DollarName '$lib_path') 
                                  <' to '> ($ Id.VSub_DollarName '$soname')
                                )
                              }
                            )
                            (C {<change_linkage>} {(DQ ($ Id.VSub_DollarName '$lib_path'))} 
                              {(DQ ($ Id.VSub_DollarName '$soname'))}
                            )
                          ]
                        )
                    )
                  ]
                )
            )
          ]
        )
    )
  ]
)