(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:tracing)
          op: Equal
          rhs: {(/sys/kernel/debug/tracing)}
          spids: [166]
        )
      ]
      spids: [166]
    )
    (Sentence
      child: 
        (Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(LhsName name:interval) op:Equal rhs:{(1)} spids:[169])]
          spids: [169]
        )
      terminator: <Op_Semi ";">
    )
    (Sentence
      child: 
        (Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(LhsName name:opt_timestamp) op:Equal rhs:{(0)} spids:[173])]
          spids: [173]
        )
      terminator: <Op_Semi ";">
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:opt_debug) op:Equal rhs:{(0)} spids:[177])]
      spids: [177]
    )
    (C {(trap)} {(SQ <"quit=1">)} {(INT)} {(QUIT)} {(TERM)} {(PIPE)} {(HUP)})
    (FuncDef
      name: usage
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(cat)}]
              redirects: [
                (HereDoc
                  op_id: Redir_DLessDash
                  fd: -1
                  body: 
                    {
                      (DQ ("USAGE: cachestat [-Dht] [interval]\n") 
                        ("                 -D              # print debug counters\n") ("                 -h              # this usage message\n") 
                        ("                 -t              # include timestamp\n") ("                 interval        # output interval in secs (default 1)\n") ("  eg,\n") 
                        ("       cachestat                 # show stats every second\n") ("       cachestat 5               # show stats every 5 seconds\n") ("\n") 
                        ("See the man page and example file for more info.\n")
                      )
                    }
                  do_expansion: True
                  here_end: END
                  was_filled: True
                  spids: [209]
                )
                (Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[212])
              ]
            )
            (C {(exit)})
          ]
          spids: [204]
        )
      spids: [200 203]
    )
    (FuncDef
      name: warn
      body: 
        (BraceGroup
          children: [
            (If
              arms: [
                (if_arm
                  cond: [
                    (Sentence
                      child: (Pipeline children:[(C {(eval)} {(DQ ($ VSub_At "$@"))})] negated:True)
                      terminator: <Op_Semi ";">
                    )
                  ]
                  action: [
                    (SimpleCommand
                      words: [
                        {(echo)}
                        {
                          (DQ ("WARNING: command failed ") 
                            (EscapedLiteralPart
                              token: <Lit_EscapedChar "\\\"">
                            ) ($ VSub_At "$@") (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">)
                          )
                        }
                      ]
                      redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[254])]
                    )
                  ]
                  spids: [-1 249]
                )
              ]
              spids: [-1 265]
            )
          ]
          spids: [235]
        )
      spids: [231 234]
    )
    (FuncDef
      name: die
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_At "$@"))}]
              redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[279])]
            )
            (C {(exit)} {(1)})
          ]
          spids: [274]
        )
      spids: [270 273]
    )
    (While
      cond: [(C {(getopts)} {(Dht)} {(opt)})]
      body: 
        (DoGroup
          children: [
            (Case
              to_match: {($ VSub_Name "$opt")}
              arms: [
                (case_arm
                  pat_list: [{(D)}]
                  action: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:opt_debug)
                          op: Equal
                          rhs: {(1)}
                          spids: [318]
                        )
                      ]
                      spids: [318]
                    )
                  ]
                  spids: [315 316 321 -1]
                )
                (case_arm
                  pat_list: [{(t)}]
                  action: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:opt_timestamp)
                          op: Equal
                          rhs: {(1)}
                          spids: [327]
                        )
                      ]
                      spids: [327]
                    )
                  ]
                  spids: [324 325 330 -1]
                )
                (case_arm
                  pat_list: [{(h)} {(Lit_Other "?")}]
                  action: [(C {(usage)})]
                  spids: [333 336 340 -1]
                )
              ]
              spids: [308 312 343]
            )
          ]
          spids: [305 345]
        )
    )
    (C {(shift)} 
      {
        (ArithSubPart
          anode: 
            (ArithBinary
              op_id: Arith_Minus
              left: (ArithWord w:{($ VSub_Name "$OPTIND")})
              right: (ArithWord w:{(Lit_Digits 1)})
            )
          spids: [349 358]
        )
      }
    )
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (DParen child:(ArithWord w:{($ VSub_Pound "$#")}))
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:interval)
                  op: Equal
                  rhs: {($ VSub_Number "$1")}
                  spids: [377]
                )
              ]
              spids: [377]
            )
          ]
          spids: [-1 374]
        )
      ]
      spids: [-1 380]
    )
    (C {(echo)} 
      {(DQ ("Counting cache functions... Output every ") ($ VSub_Name "$interval") (" seconds."))}
    )
    (AndOr
      children: [
        (C {(cd)} {($ VSub_Name "$tracing")})
        (C {(die)} 
          {
            (DQ ("ERROR: accessing tracing. Root user? Kernel has FTRACE?\n") 
              ("    debugfs mounted? (mount -t debugfs debugfs /sys/kernel/debug)")
            )
          }
        )
      ]
      op_id: Op_DPipe
    )
    (C {(sysctl)} {(-q)} {(kernel.ftrace_enabled) (Lit_Other "=") (1)})
    (AndOr
      children: [
        (SimpleCommand
          words: [
            {(printf)}
            {
              (DQ (mark_page_accessed) (EscapedLiteralPart token:<Lit_EscapedChar "\\n">) 
                (mark_buffer_dirty) (EscapedLiteralPart token:<Lit_EscapedChar "\\n">) (add_to_page_cache_lru) 
                (EscapedLiteralPart token:<Lit_EscapedChar "\\n">) (account_page_dirtied) (EscapedLiteralPart token:<Lit_EscapedChar "\\n">)
              )
            }
          ]
          redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(set_ftrace_filter)} spids:[435])]
        )
        (C {(die)} {(DQ ("ERROR: tracing these four kernel functions: mark_page_accessed,"))} 
          {
            (DQ 
              (
"mark_buffer_dirty, add_to_page_cache_lru and account_page_dirtied (unknown kernel version?). Exiting."
              )
            )
          }
        )
      ]
      op_id: Op_DPipe
    )
    (C {(warn)} {(DQ ("echo nop > current_tracer"))})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: 
                (Pipeline
                  children: [
                    (SimpleCommand
                      words: [{(echo)} {(1)}]
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: -1
                          arg_word: {(function_profile_enabled)}
                          spids: [468]
                        )
                      ]
                    )
                  ]
                  negated: True
                )
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (SimpleCommand
              words: [{(echo)}]
              redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(set_ftrace_filter)} spids:[478])]
            )
            (C {(die)} 
              {(DQ ("ERROR: enabling function profiling. Have CONFIG_FUNCTION_PROFILER? Exiting."))}
            )
          ]
          spids: [-1 473]
        )
      ]
      spids: [-1 489]
    )
    (AndOr
      children: [
        (DParen child:(ArithVarRef name:opt_timestamp))
        (C {(printf)} {(DQ ("%-8s "))} {(TIME)})
      ]
      op_id: Op_DAmp
    )
    (C {(printf)} {(DQ ("%8s %8s %8s %8s %12s %10s"))} {(HITS)} {(MISSES)} {(DIRTIES)} {(RATIO)} 
      {(DQ (BUFFERS_MB))} {(DQ (CACHE_MB))}
    )
    (AndOr
      children: [(DParen child:(ArithVarRef name:opt_debug)) (C {(printf)} {(DQ ("  DEBUG"))})]
      op_id: Op_DAmp
    )
    (C {(echo)})
    (Sentence
      child: 
        (Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(LhsName name:quit) op:Equal rhs:{(0)} spids:[552])]
          spids: [552]
        )
      terminator: <Op_Semi ";">
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:secs) op:Equal rhs:{(0)} spids:[556])]
      spids: [556]
    )
    (While
      cond: [
        (Sentence
          child: 
            (DParen
              child: 
                (ArithBinary
                  op_id: Arith_DAmp
                  left: (ArithUnary op_id:Arith_Bang child:(ArithVarRef name:quit))
                  right: 
                    (ArithBinary
                      op_id: Arith_DPipe
                      left: (ArithUnary op_id:Arith_Bang child:(ArithVarRef name:opt_duration))
                      right: 
                        (ArithBinary
                          op_id: Arith_Less
                          left: (ArithVarRef name:secs)
                          right: (ArithVarRef name:duration)
                        )
                    )
                )
            )
          terminator: <Op_Semi ";">
        )
      ]
      body: 
        (DoGroup
          children: [
            (DParen
              child: 
                (BinaryAssign
                  op_id: Arith_PlusEqual
                  left: (LhsName name:secs)
                  right: (ArithVarRef name:interval)
                )
            )
            (SimpleCommand
              words: [{(echo)} {(0)}]
              redirects: [
                (Redir
                  op_id: Redir_Great
                  fd: -1
                  arg_word: {(function_profile_enabled)}
                  spids: [604]
                )
              ]
            )
            (SimpleCommand
              words: [{(echo)} {(1)}]
              redirects: [
                (Redir
                  op_id: Redir_Great
                  fd: -1
                  arg_word: {(function_profile_enabled)}
                  spids: [613]
                )
              ]
            )
            (C {(sleep)} {($ VSub_Name "$interval")})
            (AndOr
              children: [
                (DParen child:(ArithVarRef name:opt_timestamp))
                (C {(printf)} {(DQ ("%(%H:%M:%S)T "))} {(-1)})
              ]
              op_id: Op_DAmp
            )
            (Pipeline
              children: [
                (C {(cat)} {(/proc/meminfo)} {(trace_stat/function) (Lit_Other "*")})
                (C {(awk)} {(-v)} {(Lit_VarLike "debug=") ($ VSub_Name "$opt_debug")} 
                  {
                    (SQ <"\n"> <"\t# match meminfo stats:\n"> 
                      <"\t$1 == \"Buffers:\" && $3 == \"kB\" { buffers_mb = $2 / 1024 }\n"> <"\t$1 == \"Cached:\" && $3 == \"kB\" { cached_mb = $2 / 1024 }\n"> 
                      <"\t# identify and save trace counts:\n"> <"\t$2 ~ /[0-9]/ && $3 != \"kB\" { a[$1] += $2 }\n"> <"\tEND {\n"> 
                      <"\t\tmpa = a[\"mark_page_accessed\"]\n"> <"\t\tmbd = a[\"mark_buffer_dirty\"]\n"> <"\t\tapcl = a[\"add_to_page_cache_lru\"]\n"> 
                      <"\t\tapd = a[\"account_page_dirtied\"]\n"> <"\n"> <"\t\ttotal = mpa - mbd\n"> <"\t\tmisses = apcl - apd\n"> <"\t\tif (misses < 0)\n"> 
                      <"\t\t\tmisses = 0\n"> <"\t\thits = total - misses\n"> <"\n"> <"\t\tratio = 100 * hits / total\n"> 
                      <"\t\tprintf \"%8d %8d %8d %7.1f%% %12.0f %10.0f\", hits, misses, mbd,\n"> <"\t\t    ratio, buffers_mb, cached_mb\n"> <"\t\tif (debug)\n"> 
                      <"\t\t\tprintf \"  (%d %d %d %d)\", mpa, mbd, apcl, apd\n"> <"\t\tprintf \"\\n\"\n"> <"\t}">
                    )
                  }
                )
              ]
              negated: False
            )
          ]
          spids: [585 691]
        )
    )
    (SimpleCommand
      words: [{(echo)}]
      redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[699])]
    )
    (SimpleCommand
      words: [{(echo)} {(DQ ("Ending tracing..."))}]
      redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[708])]
    )
    (C {(warn)} {(DQ ("echo 0 > function_profile_enabled"))})
    (C {(warn)} {(DQ ("echo > set_ftrace_filter"))})
  ]
)