(CommandList
  children: [
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (AndOr
                  children: [
                    (C {(Lit_Other "[")} {(-x)} {(./getscom)} {(Lit_Other "]")})
                    (C {(Lit_Other "[")} {(-x)} {(./putscom)} {(Lit_Other "]")})
                  ]
                  op_id: Op_DAmp
                )
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(LhsName name:GETSCOM) op:Equal rhs:{(./getscom)} spids:[65])]
              spids: [65]
            )
            (Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(LhsName name:PUTSCOM) op:Equal rhs:{(./putscom)} spids:[69])]
              spids: [69]
            )
          ]
          spids: [-1 62]
        )
        (if_arm
          cond: [
            (Sentence
              child: 
                (SimpleCommand
                  words: [{(which)} {(getscom)}]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[78])]
                )
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:GETSCOM)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: (CommandList children:[(C {(which)} {(getscom)})])
                        left_token: <Left_CommandSub "$(">
                        spids: [87 91]
                      )
                    }
                  spids: [86]
                )
              ]
              spids: [86]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:PUTSCOM)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: (CommandList children:[(C {(which)} {(putscom)})])
                        left_token: <Left_CommandSub "$(">
                        spids: [95 99]
                      )
                    }
                  spids: [94]
                )
              ]
              spids: [94]
            )
          ]
          spids: [72 83]
        )
      ]
      else_action: [
        (SimpleCommand
          words: [{(cat)}]
          redirects: [
            (HereDoc
              op_id: Redir_DLess
              fd: -1
              body: 
                {
                  (DQ ("Can't find getscom/putscom in . or ") 
                    (EscapedLiteralPart token:<Lit_EscapedChar "\\$">) ("PATH.\n") ("See https://github.com/open-power/skiboot.\n") ("The tool is in external/xscom-utils\n")
                  )
                }
              do_expansion: True
              here_end: EOF
              was_filled: True
              spids: [106]
            )
          ]
        )
        (C {(exit)} {(1)})
      ]
      spids: [101 119]
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:expected_hmis) op:Equal rhs:{(8)} spids:[128])]
      spids: [128]
    )
    (FuncDef
      name: COUNT_HMIS
      body: 
        (BraceGroup
          children: [
            (Pipeline
              children: [
                (C {(dmesg)})
                (C {(grep)} {(-c)} {(SQ <"Harmless Hypervisor Maintenance interrupt">)})
              ]
              negated: False
            )
          ]
          spids: [135]
        )
      spids: [131 134]
    )
    (C {(ppc64_cpu)} {(--smt-snooze-delay) (Lit_Other "=") (1000000000)})
    (C {(trap)} {(DQ ("ppc64_cpu --smt-snooze-delay=100"))} {(0)} {(1)})
    (Pipeline
      children: [
        (SimpleCommand
          words: [{(egrep)} {(-o)} {(SQ <"OCC: Chip [0-9a-f]+ Core [0-9a-f]">)}]
          redirects: [
            (Redir
              op_id: Redir_Less
              fd: -1
              arg_word: {(/sys/firmware/opal/msglog)}
              spids: [191]
            )
          ]
        )
        (While
          cond: [(Sentence child:(C {(read)} {(chipcore)}) terminator:<Op_Semi ";">)]
          body: 
            (DoGroup
              children: [
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:chip)
                      op: Equal
                      rhs: 
                        {
                          (CommandSubPart
                            command_list: 
                              (CommandList
                                children: [
                                  (Pipeline
                                    children: [
                                      (C {(echo)} {(DQ ($ VSub_Name "$chipcore"))})
                                      (C {(awk)} {(SQ <"{print $3}">)})
                                    ]
                                    negated: False
                                  )
                                ]
                              )
                            left_token: <Left_CommandSub "$(">
                            spids: [208 220]
                          )
                        }
                      spids: [207]
                    )
                  ]
                  spids: [207]
                )
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:core)
                      op: Equal
                      rhs: 
                        {
                          (CommandSubPart
                            command_list: 
                              (CommandList
                                children: [
                                  (Pipeline
                                    children: [
                                      (C {(echo)} {(DQ ($ VSub_Name "$chipcore"))})
                                      (C {(awk)} {(SQ <"{print $5}">)})
                                    ]
                                    negated: False
                                  )
                                ]
                              )
                            left_token: <Left_CommandSub "$(">
                            spids: [224 236]
                          )
                        }
                      spids: [223]
                    )
                  ]
                  spids: [223]
                )
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:fir)
                      op: Equal
                      rhs: {(DQ (0x1) (${ VSub_Name core) (013100))}
                      spids: [239]
                    )
                  ]
                  spids: [239]
                )
                (If
                  arms: [
                    (if_arm
                      cond: [
                        (Sentence
                          child: 
                            (C {(Lit_Other "[")} 
                              {
                                (DQ 
                                  (CommandSubPart
                                    command_list: 
                                      (CommandList
                                        children: [
                                          (C {($ VSub_Name "$GETSCOM")} {(-c)} 
                                            {(0x) (${ VSub_Name chip)} {($ VSub_Name "$fir")}
                                          )
                                        ]
                                      )
                                    left_token: <Left_CommandSub "$(">
                                    spids: [259 270]
                                  )
                                )
                              } {(KW_Bang "!") (Lit_Other "=")} {(0)} {(Lit_Other "]")}
                            )
                          terminator: <Op_Semi ";">
                        )
                      ]
                      action: [
                        (C {(echo)} 
                          {
                            (DQ ("FIR was not zero before injection for chip ") ($ VSub_Name "$chip") 
                              (", core ") ($ VSub_Name "$core") (". Aborting!")
                            )
                          }
                        )
                        (C {(echo)} 
                          {
                            (DQ ("Result of ") ($ VSub_Name "$GETSCOM") (" -c 0x") (${ VSub_Name chip) 
                              (" ") ($ VSub_Name "$fir") (":")
                            )
                          }
                        )
                        (C {($ VSub_Name "$GETSCOM")} {(-c)} {(0x) (${ VSub_Name chip)} 
                          {($ VSub_Name "$fir")}
                        )
                        (C {(echo)} 
                          {
                            (DQ 
                              (
"If you get a -5 error, the core may be in idle state. Try stress-ng."
                              )
                            )
                          }
                        )
                        (C {(echo)} 
                          {
                            (DQ ("Otherwise, try ") ($ VSub_Name "$PUTSCOM") (" -c 0x") 
                              (${ VSub_Name chip) (" ") ($ VSub_Name "$fir") (" 0")
                            )
                          }
                        )
                        (C {(exit)} {(1)})
                      ]
                      spids: [-1 281]
                    )
                  ]
                  spids: [-1 349]
                )
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:old_hmis)
                      op: Equal
                      rhs: 
                        {
                          (CommandSubPart
                            command_list: (CommandList children:[(C {(COUNT_HMIS)})])
                            left_token: <Left_CommandSub "$(">
                            spids: [358 360]
                          )
                        }
                      spids: [357]
                    )
                  ]
                  spids: [357]
                )
                (Pipeline
                  children: [
                    (C {(echo)} 
                      {
                        (DQ ("Injecting HMI on core ") ($ VSub_Name "$core") (", chip ") 
                          ($ VSub_Name "$chip")
                        )
                      }
                    )
                    (C {(tee)} {(/dev/kmsg)})
                  ]
                  negated: False
                )
                (If
                  arms: [
                    (if_arm
                      cond: [
                        (Sentence
                          child: 
                            (Pipeline
                              children: [
                                (SimpleCommand
                                  words: [
                                    {($ VSub_Name "$PUTSCOM")}
                                    {(-c)}
                                    {(0x) (${ VSub_Name chip)}
                                    {($ VSub_Name "$fir")}
                                    {(2000000000000000)}
                                  ]
                                  redirects: [
                                    (Redir
                                      op_id: Redir_Great
                                      fd: -1
                                      arg_word: {(/dev/null)}
                                      spids: [405]
                                    )
                                  ]
                                )
                              ]
                              negated: True
                            )
                          terminator: <Op_Semi ";">
                        )
                      ]
                      action: [(C {(echo)} {(DQ ("Error injecting. Aborting!"))}) (C {(exit)} {(1)})]
                      spids: [-1 410]
                    )
                  ]
                  spids: [-1 425]
                )
                (Sentence
                  child: 
                    (Assignment
                      keyword: Assign_None
                      pairs: [(assign_pair lhs:(LhsName name:i) op:Equal rhs:{(0)} spids:[437])]
                      spids: [437]
                    )
                  terminator: <Op_Semi ";">
                )
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:new_hmis)
                      op: Equal
                      rhs: 
                        {
                          (CommandSubPart
                            command_list: (CommandList children:[(C {(COUNT_HMIS)})])
                            left_token: <Left_CommandSub "$(">
                            spids: [443 445]
                          )
                        }
                      spids: [442]
                    )
                  ]
                  spids: [442]
                )
                (While
                  cond: [
                    (Sentence
                      child: 
                        (AndOr
                          children: [
                            (C {(Lit_Other "[")} {($ VSub_Name "$new_hmis")} {(-lt)} 
                              {
                                (ArithSubPart
                                  anode: 
                                    (ArithBinary
                                      op_id: Arith_Plus
                                      left: (ArithVarRef name:old_hmis)
                                      right: (ArithVarRef name:expected_hmis)
                                    )
                                  spids: [456 463]
                                )
                              } {(Lit_Other "]")}
                            )
                            (C {(Lit_Other "[")} {($ VSub_Name "$i")} {(-lt)} {(12)} {(Lit_Other "]")})
                          ]
                          op_id: Op_DAmp
                        )
                      terminator: <Op_Semi ";">
                    )
                  ]
                  body: 
                    (DoGroup
                      children: [
                        (C {(echo)} 
                          {
                            (DQ ("Seen ") 
                              (ArithSubPart
                                anode: 
                                  (ArithBinary
                                    op_id: Arith_Minus
                                    left: (ArithVarRef name:new_hmis)
                                    right: (ArithVarRef name:old_hmis)
                                  )
                                spids: [487 494]
                              ) (" HMI(s) out of ") ($ VSub_Name "$expected_hmis") (" expected, sleeping")
                            )
                          }
                        )
                        (Sentence
                          child: (C {(sleep)} {(5)})
                          terminator: <Op_Semi ";">
                        )
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:i)
                              op: Equal
                              rhs: 
                                {
                                  (ArithSubPart
                                    anode: 
                                      (ArithBinary
                                        op_id: Arith_Plus
                                        left: (ArithVarRef name:i)
                                        right: (ArithWord w:{(Lit_Digits 1)})
                                      )
                                    spids: [508 515]
                                  )
                                }
                              spids: [507]
                            )
                          ]
                          spids: [507]
                        )
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:new_hmis)
                              op: Equal
                              rhs: 
                                {
                                  (CommandSubPart
                                    command_list: (CommandList children:[(C {(COUNT_HMIS)})])
                                    left_token: <Left_CommandSub "$(">
                                    spids: [519 521]
                                  )
                                }
                              spids: [518]
                            )
                          ]
                          spids: [518]
                        )
                      ]
                      spids: [480 524]
                    )
                )
                (If
                  arms: [
                    (if_arm
                      cond: [
                        (Sentence
                          child: 
                            (C {(Lit_Other "[")} {($ VSub_Name "$i")} {(Lit_Other "=")} {(12)} 
                              {(Lit_Other "]")}
                            )
                          terminator: <Op_Semi ";">
                        )
                      ]
                      action: [
                        (C {(echo)} 
                          {
                            (DQ ("Haven't seen expected ") ($ VSub_Name "$expected_hmis") 
                              (" recoveries after 1 min. Aborting.")
                            )
                          }
                        )
                        (C {(exit)} {(1)})
                      ]
                      spids: [-1 540]
                    )
                  ]
                  spids: [-1 557]
                )
                (C {(echo)} 
                  {
                    (DQ ("Processed ") ($ VSub_Name "$expected_hmis") 
                      (" events; presumed success. Check dmesg.")
                    )
                  }
                )
                (C {(echo)} {(DQ )})
              ]
              spids: [204 574]
            )
        )
      ]
      negated: False
    )
  ]
)