(command.CommandList
  children: [
    (command.Assignment
      pairs: [(assign_pair lhs:(lhs_expr.LhsName name:TOOL_MODE) op:Equal rhs:{(diff)})]
    )
    (C {(.)} {(git-mergetool--lib)})
    (command.FuncDef
      name: should_prompt
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:prompt_merge)
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.AndOr
                                ops: [Op_DPipe]
                                children: [
                                  (C {(git)} {(config)} {(--bool)} {(mergetool.prompt)})
                                  (C {(echo)} {(true)})
                                ]
                              )
                            ]
                          )
                      )
                    }
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:prompt)
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.AndOr
                                ops: [Op_DPipe]
                                children: [
                                  (C {(git)} {(config)} {(--bool)} {(difftool.prompt)})
                                  (C {(echo)} {($ VSub_DollarName '$prompt_merge')})
                                ]
                              )
                            ]
                          )
                      )
                    }
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(DQ ($ VSub_DollarName '$prompt'))} {(Lit_Other '=')} {(true)})]
                  action: [(C {(test)} {(-z)} {(DQ ($ VSub_DollarName '$GIT_DIFFTOOL_NO_PROMPT'))})]
                )
              ]
              else_action: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$GIT_DIFFTOOL_PROMPT'))})]
            )
          ]
        )
    )
    (command.FuncDef
      name: use_ext_cmd
      body: 
        (command.BraceGroup
          children: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$GIT_DIFFTOOL_EXTCMD'))})]
        )
    )
    (command.FuncDef
      name: launch_merge_tool
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:MERGED)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:LOCAL)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$2'))}
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:REMOTE)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$3'))}
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:BASE)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(should_prompt)})]
                  action: [
                    (C {(printf)} 
                      {(DQ (Lit_Other '\\') ("nViewing (%s/%s): '%s'") (Lit_Other '\\') (n))} {(DQ ($ VSub_DollarName '$GIT_DIFF_PATH_COUNTER'))} {(DQ ($ VSub_DollarName '$GIT_DIFF_PATH_TOTAL'))} 
                      {(DQ ($ VSub_DollarName '$MERGED'))}
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [(C {(use_ext_cmd)})]
                          action: [
                            (C {(printf)} {(DQ ("Launch '%s' [Y/n]? "))} 
                              {(DQ ($ VSub_DollarName '$GIT_DIFFTOOL_EXTCMD'))}
                            )
                          ]
                        )
                      ]
                      else_action: [
                        (C {(printf)} {(DQ ("Launch '%s' [Y/n]? "))} 
                          {(DQ ($ VSub_DollarName '$merge_tool'))}
                        )
                      ]
                    )
                    (command.AndOr
                      ops: [Op_DPipe]
                      children: [
                        (C {(read)} {(ans)})
                        (command.ControlFlow
                          token: <ControlFlow_Return return>
                        )
                      ]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [(C {(test)} {(DQ ($ VSub_DollarName '$ans'))} {(Lit_Other '=')} {(n)})]
                          action: [(command.ControlFlow token:<ControlFlow_Return return>)]
                        )
                      ]
                    )
                  ]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(use_ext_cmd)})]
                  action: [
                    (C {(export)} {(BASE)})
                    (C {(eval)} {($ VSub_DollarName '$GIT_DIFFTOOL_EXTCMD')} {(SQ <'"$LOCAL"'>)} 
                      {(SQ <'"$REMOTE"'>)}
                    )
                  ]
                )
              ]
              else_action: [(C {(run_merge_tool)} {(DQ ($ VSub_DollarName '$merge_tool'))})]
            )
          ]
        )
    )
    (command.If
      arms: [
        (if_arm
          cond: [(command.Pipeline children:[(C {(use_ext_cmd)})] negated:T)]
          action: [
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$GIT_DIFF_TOOL'))})]
                  action: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:merge_tool)
                          op: Equal
                          rhs: {(DQ ($ VSub_DollarName '$GIT_DIFF_TOOL'))}
                        )
                      ]
                    )
                  ]
                )
              ]
              else_action: [
                (command.AndOr
                  ops: [Op_DPipe]
                  children: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:merge_tool)
                          op: Equal
                          rhs: 
                            {
                              (DQ 
                                (word_part.CommandSub
                                  left_token: <Left_DollarParen '$('>
                                  command_list: 
                                    (command.CommandList
                                      children: [(C {(get_merge_tool)})]
                                    )
                                )
                              )
                            }
                        )
                      ]
                    )
                    (command.ControlFlow token:<ControlFlow_Exit exit>)
                  ]
                )
              ]
            )
          ]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$GIT_DIFFTOOL_DIRDIFF'))})]
          action: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:LOCAL)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:REMOTE)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$2'))}
                )
              ]
            )
            (C {(run_merge_tool)} {(DQ ($ VSub_DollarName '$merge_tool'))} {(false)})
          ]
        )
      ]
      else_action: [
        (command.WhileUntil
          keyword: <KW_While while>
          cond: [(C {(test)} {($ VSub_Pound '$#')} {(-gt)} {(6)})]
          body: 
            (command.DoGroup
              children: [
                (C {(launch_merge_tool)} {(DQ ($ VSub_Number '$1'))} {(DQ ($ VSub_Number '$2'))} 
                  {(DQ ($ VSub_Number '$5'))}
                )
                (command.Assignment
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:status)
                      op: Equal
                      rhs: {($ VSub_QMark '$?')}
                    )
                  ]
                )
                (command.If
                  arms: [
                    (if_arm
                      cond: [(C {(test)} {($ VSub_DollarName '$status')} {(-ge)} {(126)})]
                      action: [
                        (command.ControlFlow
                          token: <ControlFlow_Exit exit>
                          arg_word: {($ VSub_DollarName '$status')}
                        )
                      ]
                    )
                  ]
                )
                (command.If
                  arms: [
                    (if_arm
                      cond: [
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [
                            (C {(test)} {(DQ ($ VSub_DollarName '$status'))} 
                              {(KW_Bang '!') (Lit_Other '=')} {(0)}
                            )
                            (C {(test)} {(DQ ($ VSub_DollarName '$GIT_DIFFTOOL_TRUST_EXIT_CODE'))} 
                              {(Lit_Other '=')} {(true)}
                            )
                          ]
                        )
                      ]
                      action: [
                        (command.ControlFlow
                          token: <ControlFlow_Exit exit>
                          arg_word: {($ VSub_DollarName '$status')}
                        )
                      ]
                    )
                  ]
                )
                (C {(shift)} {(7)})
              ]
            )
        )
      ]
    )
    (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(0)})
  ]
)