(CommandList
  children: [
    (C {(set)} {(-e)})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (Pipeline children:[(C {(command)} {(-v)} {(curl)})] negated:True)
              terminator: <Op_Amp '&'>
            )
            (Sentence
              child: 
                (SimpleCommand
                  redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(/dev/null)} spids:[33])]
                )
              terminator: <Op_Semi ';'>
            )
          ]
          action: [
            (SimpleCommand
              words: [{(echo)} {(SQ <'error: "curl" not found!'>)}]
              redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[43])]
            )
            (C {(exit)} {(1)})
          ]
          spids: [16777215 38]
        )
      ]
      spids: [16777215 55]
    )
    (FuncDef
      name: usage
      body: 
        (BraceGroup
          children: [
            (C {(echo)} {(DQ ('usage: ') ($ VSub_Number '$0') (' dir image[:tag][@image-id] ...'))})
            (C {(echo)} {(DQ ('   ie: ') ($ VSub_Number '$0') (' /tmp/hello-world hello-world'))})
            (C {(echo)} {(DQ ('       ') ($ VSub_Number '$0') (' /tmp/debian-jessie debian:jessie'))})
            (C {(echo)} 
              {
                (DQ ('       ') ($ VSub_Number '$0') 
                  (
' /tmp/old-hello-world hello-world@ef872312fe1bbc5e05aae626791a47ee9b032efa8f3bda39cc0be7b56bfe59b9'
                  )
                )
              }
            )
            (C {(echo)} 
              {
                (DQ ('       ') ($ VSub_Number '$0') 
                  (
' /tmp/old-debian debian:latest@f6fab3b798be3174f45aa1eb731f8182705555f89c9026d8c1ef230cbf8301dd'
                  )
                )
              }
            )
            (AndOr
              children: [
                (C {(Lit_Other '[')} {(-z)} {(DQ ($ VSub_Number '$1'))} {(Lit_Other ']')})
                (C {(exit)} {(DQ ($ VSub_Number '$1'))})
              ]
              op_id: Op_DPipe
            )
          ]
          spids: [62]
        )
      spids: [58 61]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:dir)
          op: Equal
          rhs: {(DQ ($ VSub_Number '$1'))}
          spids: [131]
        )
      ]
      spids: [131]
    )
    (AndOr
      children: [
        (C {(shift)})
        (SimpleCommand
          words: [{(usage)} {(1)}]
          redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[147])]
        )
      ]
      op_id: Op_DPipe
    )
    (AndOr
      children: [
        (C {(Lit_Other '[')} {($ VSub_Pound '$#')} {(-gt)} {(0)} {(-a)} {(DQ ($ VSub_Name '$dir'))} 
          {(Lit_Other ']')}
        )
        (SimpleCommand
          words: [{(usage)} {(2)}]
          redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[173])]
        )
      ]
      op_id: Op_DPipe
    )
    (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name '$dir'))})
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:images) op:Equal rhs:{(ArrayLiteralPart)} spids:[188])]
      spids: [188]
    )
    (C {(rm)} {(-f)} {(DQ ($ VSub_Name '$dir')) (/tags-) (Lit_Other '*') (.tmp)})
    (While
      cond: [
        (Sentence
          child: (C {(Lit_Other '[')} {($ VSub_Pound '$#')} {(-gt)} {(0)} {(Lit_Other ']')})
          terminator: <Op_Semi ';'>
        )
      ]
      body: 
        (DoGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:imageTag)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                  spids: [223]
                )
              ]
              spids: [223]
            )
            (C {(shift)})
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:image)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (BracedVarSub
                          token: <VSub_Name imageTag>
                          suffix_op: (StringUnary op_id:VOp1_DPercent arg_word:{('[:@]*')})
                          spids: [234 238]
                        )
                      )
                    }
                  spids: [232]
                )
              ]
              spids: [232]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:tag)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (BracedVarSub
                          token: <VSub_Name imageTag>
                          suffix_op: (StringUnary op_id:VOp1_Pound arg_word:{('*:')})
                          spids: [244 248]
                        )
                      )
                    }
                  spids: [242]
                )
              ]
              spids: [242]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:imageId)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (BracedVarSub
                          token: <VSub_Name tag>
                          suffix_op: (StringUnary op_id:VOp1_DPound arg_word:{('*@')})
                          spids: [254 258]
                        )
                      )
                    }
                  spids: [252]
                )
              ]
              spids: [252]
            )
            (AndOr
              children: [
                (C {(Lit_Other '[')} {(DQ ($ VSub_Name '$imageId'))} {(KW_Bang '!') (Lit_Other '=')} 
                  {(DQ ($ VSub_Name '$tag'))} {(Lit_Other ']')}
                )
                (Assignment
                  keyword: Assign_None
                  pairs: [(assign_pair lhs:(LhsName name:imageId) op:Equal rhs:{(SQ )} spids:[279])]
                  spids: [279]
                )
              ]
              op_id: Op_DPipe
            )
            (AndOr
              children: [
                (C {(Lit_Other '[')} {(DQ ($ VSub_Name '$tag'))} {(KW_Bang '!') (Lit_Other '=')} 
                  {(DQ ($ VSub_Name '$imageTag'))} {(Lit_Other ']')}
                )
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:tag)
                      op: Equal
                      rhs: {(SQ <latest>)}
                      spids: [299]
                    )
                  ]
                  spids: [299]
                )
              ]
              op_id: Op_DPipe
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:tag)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (BracedVarSub
                          token: <VSub_Name tag>
                          suffix_op: (StringUnary op_id:VOp1_Percent arg_word:{('@*')})
                          spids: [307 311]
                        )
                      )
                    }
                  spids: [305]
                )
              ]
              spids: [305]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:imageFile)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (BracedVarSub
                          token: <VSub_Name image>
                          suffix_op: 
                            (PatSub
                              pat: {(EscapedLiteralPart token:<Lit_EscapedChar '\\/'>)}
                              replace: {(_)}
                              do_all: True
                              do_prefix: False
                              do_suffix: False
                            )
                          spids: [318 325]
                        )
                      )
                    }
                  spids: [316]
                )
              ]
              spids: [316]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:token)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (CommandSubPart
                          command_list: 
                            (CommandList
                              children: [
                                (Pipeline
                                  children: [
                                    (C {(curl)} {(-sSL)} {(-o)} {(/dev/null)} {(-D-)} {(-H)} 
                                      {(SQ <'X-Docker-Token: true'>)} {(DQ ('https://index.docker.io/v1/repositories/') ($ VSub_Name '$image') (/images))}
                                    )
                                    (C {(tr)} {(-d)} {(SQ <'\\r'>)})
                                    (C {(awk)} {(-F)} {(SQ <': *'>)} 
                                      {(SQ <'$1 == "X-Docker-Token" { print $2 }'>)}
                                    )
                                  ]
                                  negated: False
                                )
                              ]
                            )
                          left_token: <Left_CommandSub '$('>
                          spids: [335 381]
                        )
                      )
                    }
                  spids: [333]
                )
              ]
              spids: [333]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other '[')} {(-z)} {(DQ ($ VSub_Name '$imageId'))} {(Lit_Other ']')})
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:imageId)
                          op: Equal
                          rhs: 
                            {
                              (DQ 
                                (CommandSubPart
                                  command_list: 
                                    (CommandList
                                      children: [
                                        (C {(curl)} {(-sSL)} {(-H)} 
                                          {(DQ ('Authorization: Token ') ($ VSub_Name '$token'))} 
                                          {
                                            (DQ ('https://registry-1.docker.io/v1/repositories/') 
                                              ($ VSub_Name '$image') (/tags/) ($ VSub_Name '$tag')
                                            )
                                          }
                                        )
                                      ]
                                    )
                                  left_token: <Left_CommandSub '$('>
                                  spids: [404 422]
                                )
                              )
                            }
                          spids: [402]
                        )
                      ]
                      spids: [402]
                    )
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:imageId)
                          op: Equal
                          rhs: 
                            {
                              (DQ 
                                (BracedVarSub
                                  token: <VSub_Name imageId>
                                  suffix_op: 
                                    (PatSub
                                      pat: {(EscapedLiteralPart token:<Lit_EscapedChar '\\"'>)}
                                      replace: {(SQ )}
                                      do_all: True
                                      do_prefix: False
                                      do_suffix: False
                                    )
                                  spids: [428 434]
                                )
                              )
                            }
                          spids: [426]
                        )
                      ]
                      spids: [426]
                    )
                  ]
                  spids: [16777215 399]
                )
              ]
              spids: [16777215 438]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:ancestryJson)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (CommandSubPart
                          command_list: 
                            (CommandList
                              children: [
                                (C {(curl)} {(-sSL)} {(-H)} 
                                  {(DQ ('Authorization: Token ') ($ VSub_Name '$token'))} {(DQ ('https://registry-1.docker.io/v1/images/') ($ VSub_Name '$imageId') (/ancestry))}
                                )
                              ]
                            )
                          left_token: <Left_CommandSub '$('>
                          spids: [444 461]
                        )
                      )
                    }
                  spids: [442]
                )
              ]
              spids: [442]
            )
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other '[')} 
                          {
                            (DQ 
                              (BracedVarSub
                                token: <VSub_Name ancestryJson>
                                suffix_op: 
                                  (Slice
                                    begin: (ArithWord w:{(Lit_Digits 0)})
                                    length: (ArithWord w:{(Lit_Digits 1)})
                                  )
                                spids: [470 476]
                              )
                            )
                          } {(KW_Bang '!') (Lit_Other '=')} {(SQ <'['>)} {(Lit_Other ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (SimpleCommand
                      words: [
                        {(echo)}
                        {
                          (DQ ('error: /v1/images/') ($ VSub_Name '$imageId') 
                            ('/ancestry returned something unexpected:')
                          )
                        }
                      ]
                      redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[494])]
                    )
                    (SimpleCommand
                      words: [{(echo)} {(DQ ('  ') ($ VSub_Name '$ancestryJson'))}]
                      redirects: [(Redir op_id:Redir_GreatAnd fd:16777215 arg_word:{(2)} spids:[506])]
                    )
                    (C {(exit)} {(1)})
                  ]
                  spids: [16777215 489]
                )
              ]
              spids: [16777215 520]
            )
            (Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(LhsName name:IFS) op:Equal rhs:{(SQ <','>)} spids:[524])]
              spids: [524]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:ancestry)
                  op: Equal
                  rhs: 
                    {
                      (ArrayLiteralPart
                        words: [
                          {
                            (BracedVarSub
                              token: <VSub_Name ancestryJson>
                              suffix_op: 
                                (PatSub
                                  pat: 
                                    {('[') (EscapedLiteralPart token:<Lit_EscapedChar '\\['>) 
                                      (EscapedLiteralPart
                                        token: <Lit_EscapedChar '\\]'>
                                      ) (' ') (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) (']')
                                    }
                                  replace: {}
                                  do_all: True
                                  do_prefix: False
                                  do_suffix: False
                                )
                              spids: [533 544]
                            )
                          }
                        ]
                      )
                    }
                  spids: [530]
                )
              ]
              spids: [530]
            )
            (C {(unset)} {(IFS)})
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: 
                        (C {(Lit_Other '[')} {(-s)} 
                          {(DQ ($ VSub_Name '$dir') (/tags-) ($ VSub_Name '$imageFile') (.tmp))} {(Lit_Other ']')}
                        )
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  action: [
                    (SimpleCommand
                      words: [{(echo)} {(-n)} {(SQ <', '>)}]
                      redirects: [
                        (Redir
                          op_id: Redir_DGreat
                          fd: 16777215
                          arg_word: 
                            {(DQ ($ VSub_Name '$dir') (/tags-) ($ VSub_Name '$imageFile') (.tmp))}
                          spids: [582]
                        )
                      ]
                    )
                  ]
                  spids: [16777215 571]
                )
              ]
              else_action: [
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:images)
                      op: Equal
                      rhs: 
                        {
                          (ArrayLiteralPart
                            words: [
                              {
                                (DQ 
                                  (BracedVarSub
                                    token: <VSub_Name images>
                                    bracket_op: (WholeArray op_id:Lit_At)
                                    spids: [599 604]
                                  )
                                )
                              }
                              {(DQ ($ VSub_Name '$image'))}
                            ]
                          )
                        }
                      spids: [595]
                    )
                  ]
                  spids: [595]
                )
              ]
              spids: [592 614]
            )
            (SimpleCommand
              words: [
                {(echo)}
                {(-n)}
                {(SQ <'"'>) (DQ ($ VSub_Name '$tag')) (SQ <'": "'>) (DQ ($ VSub_Name '$imageId')) 
                  (SQ <'"'>)
                }
              ]
              redirects: [
                (Redir
                  op_id: Redir_DGreat
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_Name '$dir') (/tags-) ($ VSub_Name '$imageFile') (.tmp))}
                  spids: [637]
                )
              ]
            )
            (C {(echo)} 
              {
                (DQ ("Downloading '") ($ VSub_Name '$imageTag') ("' (") 
                  (BracedVarSub
                    token: <VSub_Name ancestry>
                    prefix_op: VSub_Pound
                    bracket_op: (WholeArray op_id:Lit_At)
                    spids: [654 660]
                  ) (' layers)...')
                )
              }
            )
            (ForEach
              iter_name: imageId
              iter_words: [
                {
                  (DQ 
                    (BracedVarSub
                      token: <VSub_Name ancestry>
                      bracket_op: (WholeArray op_id:Lit_At)
                      spids: [672 677]
                    )
                  )
                }
              ]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [
                    (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name '$dir') (/) ($ VSub_Name '$imageId'))})
                    (SimpleCommand
                      words: [{(echo)} {(SQ <1.0>)}]
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: 16777215
                          arg_word: {(DQ ($ VSub_Name '$dir') (/) ($ VSub_Name '$imageId') (/VERSION))}
                          spids: [701]
                        )
                      ]
                    )
                    (C {(curl)} {(-sSL)} {(-H)} {(DQ ('Authorization: Token ') ($ VSub_Name '$token'))} 
                      {
                        (DQ ('https://registry-1.docker.io/v1/images/') ($ VSub_Name '$imageId') 
                          (/json)
                        )
                      } {(-o)} {(DQ ($ VSub_Name '$dir') (/) ($ VSub_Name '$imageId') (/json))}
                    )
                    (If
                      arms: [
                        (if_arm
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other '[')} {(-f)} 
                                  {
                                    (DQ ($ VSub_Name '$dir') (/) ($ VSub_Name '$imageId') (/layer.tar))
                                  } {(Lit_Other ']')}
                                )
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          action: [
                            (C {(echo)} 
                              {
                                (DQ ('skipping existing ') 
                                  (BracedVarSub
                                    token: <VSub_Name imageId>
                                    suffix_op: 
                                      (Slice
                                        begin: (ArithWord w:{(Lit_Digits 0)})
                                        length: (ArithWord w:{(Lit_Digits 12)})
                                      )
                                    spids: [779 785]
                                  )
                                )
                              }
                            )
                            (ControlFlow
                              token: <ControlFlow_Continue continue>
                            )
                          ]
                          spids: [16777215 768]
                        )
                      ]
                      spids: [16777215 792]
                    )
                    (C {(curl)} {(-SL)} {(--progress)} {(-H)} 
                      {(DQ ('Authorization: Token ') ($ VSub_Name '$token'))} {(DQ ('https://registry-1.docker.io/v1/images/') ($ VSub_Name '$imageId') (/layer))} {(-o)} 
                      {(DQ ($ VSub_Name '$dir') (/) ($ VSub_Name '$imageId') (/layer.tar))}
                    )
                  ]
                  spids: [681 827]
                )
              spids: [670 679]
            )
            (C {(echo)})
          ]
          spids: [220 832]
        )
    )
    (SimpleCommand
      words: [{(echo)} {(-n)} {(SQ <'{'>)}]
      redirects: [
        (Redir
          op_id: Redir_Great
          fd: 16777215
          arg_word: {(DQ ($ VSub_Name '$dir') (/repositories))}
          spids: [843]
        )
      ]
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:firstImage) op:Equal rhs:{(1)} spids:[850])]
      spids: [850]
    )
    (ForEach
      iter_name: image
      iter_words: [
        {
          (DQ 
            (BracedVarSub
              token: <VSub_Name images>
              bracket_op: (WholeArray op_id:Lit_At)
              spids: [860 865]
            )
          )
        }
      ]
      do_arg_iter: False
      body: 
        (DoGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:imageFile)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (BracedVarSub
                          token: <VSub_Name image>
                          suffix_op: 
                            (PatSub
                              pat: {(EscapedLiteralPart token:<Lit_EscapedChar '\\/'>)}
                              replace: {(_)}
                              do_all: True
                              do_prefix: False
                              do_suffix: False
                            )
                          spids: [874 881]
                        )
                      )
                    }
                  spids: [872]
                )
              ]
              spids: [872]
            )
            (AndOr
              children: [
                (C {(Lit_Other '[')} {(DQ ($ VSub_Name '$firstImage'))} {(Lit_Other ']')})
                (SimpleCommand
                  words: [{(echo)} {(-n)} {(SQ <','>)}]
                  redirects: [
                    (Redir
                      op_id: Redir_DGreat
                      fd: 16777215
                      arg_word: {(DQ ($ VSub_Name '$dir') (/repositories))}
                      spids: [907]
                    )
                  ]
                )
              ]
              op_id: Op_DPipe
            )
            (Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(LhsName name:firstImage) op:Equal rhs:{(SQ )} spids:[915])]
              spids: [915]
            )
            (SimpleCommand
              words: [{(echo)} {(-n)} {(SQ <Lit_EscapedChar '\\n'> <Lit_EscapedChar '\\t'>)}]
              redirects: [
                (Redir
                  op_id: Redir_DGreat
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_Name '$dir') (/repositories))}
                  spids: [927]
                )
              ]
            )
            (SimpleCommand
              words: [
                {(echo)}
                {(-n)}
                {(SQ <'"'>) (DQ ($ VSub_Name '$image')) (SQ <'": { '>) 
                  (DQ 
                    (CommandSubPart
                      command_list: 
                        (CommandList
                          children: [
                            (C {(cat)} 
                              {(DQ ($ VSub_Name '$dir') (/tags-) ($ VSub_Name '$imageFile') (.tmp))}
                            )
                          ]
                        )
                      left_token: <Left_CommandSub '$('>
                      spids: [949 958]
                    )
                  ) (SQ <' }'>)
                }
              ]
              redirects: [
                (Redir
                  op_id: Redir_DGreat
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_Name '$dir') (/repositories))}
                  spids: [964]
                )
              ]
            )
          ]
          spids: [869 971]
        )
      spids: [858 867]
    )
    (SimpleCommand
      words: [{(echo)} {(-n)} {(SQ <Lit_EscapedChar '\\n'> <'}'> <Lit_EscapedChar '\\n'>)}]
      redirects: [
        (Redir
          op_id: Redir_DGreat
          fd: 16777215
          arg_word: {(DQ ($ VSub_Name '$dir') (/repositories))}
          spids: [983]
        )
      ]
    )
    (C {(rm)} {(-f)} {(DQ ($ VSub_Name '$dir')) (/tags-) (Lit_Other '*') (.tmp)})
    (C {(echo)} {(DQ ("Download of images into '") ($ VSub_Name '$dir') ("' complete."))})
    (C {(echo)} {(DQ ('Use something like the following to load the result into a Docker daemon:'))})
    (C {(echo)} {(DQ ("  tar -cC '") ($ VSub_Name '$dir') ("' . | docker load"))})
  ]
)