(command.AndOr
  ops: [Id.Op_DAmp]
  children: [
    (command.ShFunction
      name: _apt_build
      body: 
        (command.BraceGroup
          children: [
            (C {<local>} {<cur>} {<prev>} {<words>} {<cword>})
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (C {<_init_completion>})
                (command.ControlFlow token:<Id.ControlFlow_Return return>)
              ]
            )
            (C {<local>} {<special>} {<i>})
            (command.ForExpr
              init: 
                (arith_expr.BinaryAssign
                  op_id: Id.Arith_Equal
                  left: (sh_lhs_expr.Name name:i)
                  right: (arith_expr.ArithWord w:{<Id.Lit_Digits 0>})
                )
              cond: 
                (arith_expr.Binary
                  op_id: Id.Arith_Less
                  left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike i>)
                  right: 
                    (arith_expr.Binary
                      op_id: Id.Arith_Minus
                      left: 
                        (arith_expr.ArithWord
                          w: 
                            {
                              (braced_var_sub
                                token: <Id.VSub_Name words>
                                prefix_op: (Id.VSub_Pound)
                                bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At)
                              )
                            }
                        )
                      right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                    )
                )
              update: (arith_expr.UnaryAssign op_id:Id.Node_PostDPlus child:(sh_lhs_expr.Name name:i))
              body: 
                (command.DoGroup
                  children: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Sentence
                              child: 
                                (command.DBracket
                                  expr: 
                                    (bool_expr.Binary
                                      op_id: Id.BoolBinary_GlobDEqual
                                      left: 
                                        {
                                          (braced_var_sub
                                            token: <Id.VSub_Name words>
                                            bracket_op: 
                                              (bracket_op.ArrayIndex
                                                expr: 
                                                  (arith_expr.VarRef
                                                    token: <Id.Lit_ArithVarLike i>
                                                  )
                                              )
                                          )
                                        }
                                      right: 
                                        {
                                          (word_part.ExtGlob
                                            op: <Id.ExtGlob_At '@('>
                                            arms: [{<install>} {<remove>} {<source>} {<info>} {<clean>}]
                                          )
                                        }
                                    )
                                )
                              terminator: <Id.Op_Semi _>
                            )
                          ]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:special)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (braced_var_sub
                                        token: <Id.VSub_Name words>
                                        bracket_op: 
                                          (bracket_op.ArrayIndex
                                            expr: (arith_expr.VarRef token:<Id.Lit_ArithVarLike i>)
                                          )
                                      )
                                    }
                                  spids: [102]
                                )
                              ]
                            )
                          ]
                          spids: [71 99]
                        )
                      ]
                    )
                  ]
                )
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Unary
                              op_id: Id.BoolUnary_n
                              child: {($ Id.VSub_DollarName '$special')}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.Case
                      to_match: {($ Id.VSub_DollarName '$special')}
                      arms: [
                        (case_arm
                          pat_list: [{<install>} {<source>} {<info>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:COMPREPLY)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (sh_array_literal
                                        left: <Id.Op_LParen _>
                                        words: [
                                          {
                                            (command_sub
                                              left_token: <Id.Left_DollarParen '$('>
                                              command_list: 
                                                (command.CommandList
                                                  children: [
                                                    (command.Simple
                                                      words: [
                                                        {<apt-cache>}
                                                        {<pkgnames>}
                                                        {(DQ ($ Id.VSub_DollarName '$cur'))}
                                                      ]
                                                      redirects: [
                                                        (redir.Redir
                                                          op: <Id.Redir_Great '2>'>
                                                          fd: 2
                                                          arg_word: {</dev/null>}
                                                        )
                                                      ]
                                                    )
                                                  ]
                                                )
                                            )
                                          }
                                        ]
                                      )
                                    }
                                  spids: [147]
                                )
                              ]
                            )
                            (command.ControlFlow
                              token: <Id.ControlFlow_Return return>
                              arg_word: {<0>}
                            )
                          ]
                          spids: [139 144 174 -1]
                        )
                        (case_arm
                          pat_list: [{<remove>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:COMPREPLY)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (sh_array_literal
                                        left: <Id.Op_LParen _>
                                        words: [
                                          {
                                            (command_sub
                                              left_token: <Id.Left_DollarParen '$('>
                                              command_list: 
                                                (command.CommandList
                                                  children: [
                                                    (C {<_xfunc>} {<dpkg>} 
                                                      {<_comp_dpkg_installed_packages>} {(DQ ($ Id.VSub_DollarName '$cur'))}
                                                    )
                                                  ]
                                                )
                                            )
                                          }
                                        ]
                                      )
                                    }
                                  spids: [181]
                                )
                              ]
                            )
                            (command.ControlFlow
                              token: <Id.ControlFlow_Return return>
                              arg_word: {<0>}
                            )
                          ]
                          spids: [177 178 208 -1]
                        )
                        (case_arm
                          pat_list: [{<Id.Lit_Star '*'>}]
                          action: [
                            (command.ControlFlow
                              token: <Id.ControlFlow_Return return>
                              arg_word: {<0>}
                            )
                          ]
                          spids: [211 212 220 -1]
                        )
                      ]
                    )
                  ]
                  spids: [118 129]
                )
              ]
            )
            (command.Case
              to_match: {($ Id.VSub_DollarName '$prev')}
              arms: [
                (case_arm
                  pat_list: [{<--patch>} {<--build-dir>} {<--repository-dir>}]
                  action: [
                    (C {<_filedir>})
                    (command.ControlFlow
                      token: <Id.ControlFlow_Return return>
                      arg_word: {<0>}
                    )
                  ]
                  spids: [237 242 253 -1]
                )
                (case_arm
                  pat_list: [{<-h>} {<--help>}]
                  action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})]
                  spids: [256 259 267 -1]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_GlobDEqual
                              left: {(DQ ($ Id.VSub_DollarName '$cur'))}
                              right: {<-> <Id.Lit_Other '*'>}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:COMPREPLY)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (sh_array_literal
                                left: <Id.Op_LParen _>
                                words: [
                                  {
                                    (command_sub
                                      left_token: <Id.Left_DollarParen '$('>
                                      command_list: 
                                        (command.CommandList
                                          children: [
                                            (C {<compgen>} {<-W>} 
                                              {
                                                (SQ <'--help --show-upgraded -u --build-dir\n'> 
                                                  <
'            --repository-dir --build-only --build-command --reinstall --rebuild\n'
                                                  > <'            --remove-builddep --no-wrapper --purge --patch --patch-strip -p\n'> 
                                                  <'            --yes -y --version -v --no-source'>
                                                )
                                              } {<-->} {(DQ ($ Id.VSub_DollarName '$cur'))}
                                            )
                                          ]
                                        )
                                    )
                                  }
                                ]
                              )
                            }
                          spids: [293]
                        )
                      ]
                    )
                  ]
                  spids: [274 290]
                )
              ]
              else_action: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:COMPREPLY)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (sh_array_literal
                            left: <Id.Op_LParen _>
                            words: [
                              {
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  command_list: 
                                    (command.CommandList
                                      children: [
                                        (C {<compgen>} {<-W>} 
                                          {
                                            (SQ <'update upgrade install remove source\n'> 
                                              <
'            dist-upgrade world clean info clean-build update-repository'
                                              >
                                            )
                                          } {<-->} {(DQ ($ Id.VSub_DollarName '$cur'))}
                                        )
                                      ]
                                    )
                                )
                              }
                            ]
                          )
                        }
                      spids: [324]
                    )
                  ]
                )
              ]
            )
            (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})
          ]
        )
    )
    (C {<complete>} {<-F>} {<_apt_build>} {<apt-build>})
  ]
)